boolean bMekStealthActive = false;
if (ae instanceof Mech) {
bMekStealthActive = ae.isStealthActive();
}
Mounted mLinker = weapon.getLinkedBy();
AmmoType atype = (AmmoType) ammo.getType();
// is any hex in the flight path of the missile ECM affected?
boolean bECMAffected = false;
// if the attacker is affected by ECM or the target is protected by ECM
// then
// act as if effected.
if (Compute.isAffectedByECM(ae, ae.getPosition(), target.getPosition())) {
bECMAffected = true;
}
if (((mLinker != null) && (mLinker.getType() instanceof MiscType)
&& !mLinker.isDestroyed() && !mLinker.isMissing()
&& !mLinker.isBreached() && mLinker.getType().hasFlag(
MiscType.F_ARTEMIS))
&& (atype.getMunitionType() == AmmoType.M_ARTEMIS_CAPABLE)) {
if (bECMAffected) {
// ECM prevents bonus
r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekStealthActive) {
// stealth prevents bonus
r = new Report(3335);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 2;
}
} else if (((mLinker != null) && (mLinker.getType() instanceof MiscType)
&& !mLinker.isDestroyed() && !mLinker.isMissing()
&& !mLinker.isBreached() && mLinker.getType().hasFlag(
MiscType.F_APOLLO))
&& (atype.getAmmoType() == AmmoType.T_MRM)) {
nMissilesModifier -= 1;
} else if (atype.getAmmoType() == AmmoType.T_ATM) {
if (bECMAffected) {
// ECM prevents bonus
r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekStealthActive) {
// stealth prevents bonus
r = new Report(3335);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 2;
}
} else if ((entityTarget != null)
&& (entityTarget.isNarcedBy(ae.getOwner().getTeam()) || entityTarget
.isINarcedBy(ae.getOwner().getTeam()))) {
// only apply Narc bonus if we're not suffering ECM effect
// and we are using narc ammo, and we're not firing indirectly.
// narc capable missiles are only affected if the narc pod, which
// sits on the target, is ECM affected
boolean bTargetECMAffected = false;
bTargetECMAffected = Compute.isAffectedByECM(ae,
target.getPosition(), target.getPosition());
if (((atype.getAmmoType() == AmmoType.T_LRM) ||
(atype.getAmmoType() == AmmoType.T_SRM) ||
(atype.getAmmoType() == AmmoType.T_MML))
&& (atype.getMunitionType() == AmmoType.M_NARC_CAPABLE)
&& ((weapon.curMode() == null) || !weapon.curMode().equals(
"Indirect"))) {
if (bTargetECMAffected) {
// ECM prevents bonus
r = new Report(3330);