protected void handleEntityDamage(Entity entityTarget,
Vector<Report> vPhaseReport, Building bldg, int hits, int nCluster,
int nDamPerHit, int bldgAbsorbs) {
AmmoType atype = (AmmoType) weapon.getLinked().getType();
int nDamage;
HitData hit = entityTarget.rollHitLocation(toHit.getHitTable(), toHit
.getSideTable(), waa.getAimedLocation(), waa.getAimingMode());
hit.setGeneralDamageType(generalDamageType);
if (entityTarget.removePartialCoverHits(hit.getLocation(), toHit
.getCover(), Compute.targetSideTable(ae, entityTarget))) {
// Weapon strikes Partial Cover.
Report r = new Report(3460);
r.subject = subjectId;
r.add(entityTarget.getShortName());
r.add(entityTarget.getLocationAbbr(hit));
r.newlines = 0;
r.indent(2);
vPhaseReport.addElement(r);
nDamage = 0;
missed = true;
return;
}
// Each hit in the salvo get's its own hit location.
r = new Report(3405);
r.subject = subjectId;
r.add(toHit.getTableDesc());
r.add(entityTarget.getLocationAbbr(hit));
r.newlines = 0;
vPhaseReport.addElement(r);
if (hit.hitAimedLocation()) {
r = new Report(3410);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
}
// Resolve damage normally.
nDamage = nDamPerHit * Math.min(nCluster, hits);
if ( bDirect && (!(target instanceof Infantry) || (target instanceof BattleArmor)) ){
hit.makeDirectBlow(toHit.getMoS()/3);
}
// A building may be damaged, even if the squad is not.
if (bldgAbsorbs > 0) {
int toBldg = Math.min(bldgAbsorbs, nDamage);
nDamage -= toBldg;
Report.addNewline(vPhaseReport);
Vector<Report> buildingReport = server.damageBuilding(bldg, toBldg, entityTarget.getPosition());
for (Report report : buildingReport) {
report.subject = subjectId;
}
vPhaseReport.addAll(buildingReport);
}
nDamage = checkTerrain(nDamage, entityTarget,vPhaseReport);
// A building may absorb the entire shot.
if (nDamage == 0) {
r = new Report(3415);
r.subject = subjectId;
r.indent(2);
r.addDesc(entityTarget);
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
int critModifer = 0;
if (bGlancing) {
hit.makeGlancingBlow();
critModifer -= 2;
}else if ( bDirect ) {
critModifer += toHit.getMoS()/3;
}
hit.makeArmorPiercing(atype,critModifer);
vPhaseReport
.addAll(server.damageEntity(entityTarget, hit, nDamage,
false, ae.getSwarmTargetId() == entityTarget
.getId() ? DamageType.IGNORE_PASSENGER
: damageType, false, false, throughFront, underWater));