Skip to content

Commit

Permalink
Merge pull request #6431 from Sleet01/Fix_Artemis_Derivatives_Getting…
Browse files Browse the repository at this point in the history
…_Bonus_On_Indirect_Fire

Fix Artemis derivatives getting bonus on indirect fire
  • Loading branch information
Sleet01 authored Jan 21, 2025
2 parents 9724539 + 50f43e9 commit 02c911c
Show file tree
Hide file tree
Showing 2 changed files with 90 additions and 92 deletions.
3 changes: 2 additions & 1 deletion megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3352,14 +3352,15 @@ private static ToHitData compileAmmoToHitMods(Game game, Entity ae, Targetable t
}

// Missile Munitions
boolean isIndirect = weapon.hasModes() && (weapon.curMode().isIndirect());

// Apollo FCS for MRMs
if (bApollo) {
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.ApolloFcs"));
}

// add Artemis V bonus
if (bArtemisV) {
if (bArtemisV && !isIndirect) {
toHit.addModifier(-1, Messages.getString("WeaponAttackAction.ArtemisV"));
}

Expand Down
179 changes: 88 additions & 91 deletions megamek/src/megamek/common/weapons/LRMHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -134,115 +134,112 @@ protected int calcHits(Vector<Report> vPhaseReport) {
bECMAffected = true;
}

if (((mLinker != null) && (mLinker.getType() instanceof MiscType)
if (!weapon.curMode().equals("Indirect")) {
if (((mLinker != null) && (mLinker.getType() instanceof MiscType)
&& !mLinker.isDestroyed() && !mLinker.isMissing()
&& !mLinker.isBreached() && mLinker.getType().hasFlag(
MiscType.F_ARTEMIS))
&& (atype.getMunitionType().contains(AmmoType.Munitions.M_ARTEMIS_CAPABLE))
&& !weapon.curMode().equals("Indirect")) {
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report r = new Report(3335);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 2;
}

} else if (((mLinker != null)
MiscType.F_ARTEMIS))
&& (atype.getMunitionType().contains(AmmoType.Munitions.M_ARTEMIS_CAPABLE))) {
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report 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_ARTEMIS_PROTO))
MiscType.F_ARTEMIS_PROTO))
&& (atype.getMunitionType().contains(AmmoType.Munitions.M_ARTEMIS_CAPABLE))) {
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report r = new Report(3335);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 1;
}

} else if (((mLinker != null)
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report r = new Report(3335);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 1;
}
} else if (((mLinker != null)
&& (mLinker.getType() instanceof MiscType)
&& !mLinker.isDestroyed() && !mLinker.isMissing()
&& !mLinker.isBreached() && mLinker.getType().hasFlag(
MiscType.F_ARTEMIS_V))
MiscType.F_ARTEMIS_V))
&& (atype.getMunitionType().contains(AmmoType.Munitions.M_ARTEMIS_V_CAPABLE))) {
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report r = new Report(3335);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 3;
}
} else if (atype.getAmmoType() == AmmoType.T_ATM) {
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report 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 = ComputeECM.isAffectedByECM(ae,
target.getPosition(), target.getPosition());
if (((atype.getAmmoType() == AmmoType.T_LRM)
|| (atype.getAmmoType() == AmmoType.T_LRM_IMP)
|| (atype.getAmmoType() == AmmoType.T_SRM)
|| (atype.getAmmoType() == AmmoType.T_SRM_IMP)
|| (atype.getAmmoType() == AmmoType.T_MML)
|| (atype.getAmmoType() == AmmoType.T_NLRM))
&& (atype.getMunitionType().contains(AmmoType.Munitions.M_NARC_CAPABLE))
&& ((weapon.curMode() == null) || !weapon.curMode().equals(
"Indirect"))) {
if (bTargetECMAffected) {
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report r = new Report(3335);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 3;
}
} else if (atype.getAmmoType() == AmmoType.T_ATM) {
if (bECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else if (bMekTankStealthActive) {
// stealth prevents bonus
Report 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 = ComputeECM.isAffectedByECM(ae,
target.getPosition(), target.getPosition());
if (((atype.getAmmoType() == AmmoType.T_LRM)
|| (atype.getAmmoType() == AmmoType.T_LRM_IMP)
|| (atype.getAmmoType() == AmmoType.T_SRM)
|| (atype.getAmmoType() == AmmoType.T_SRM_IMP)
|| (atype.getAmmoType() == AmmoType.T_MML)
|| (atype.getAmmoType() == AmmoType.T_NLRM))
&& (atype.getMunitionType().contains(AmmoType.Munitions.M_NARC_CAPABLE))) {
if (bTargetECMAffected) {
// ECM prevents bonus
Report r = new Report(3330);
r.subject = subjectId;
r.newlines = 0;
vPhaseReport.addElement(r);
} else {
nMissilesModifier += 2;
}
}
}
}

Expand Down

0 comments on commit 02c911c

Please sign in to comment.