diff --git a/megamek/src/megamek/common/actions/WeaponAttackAction.java b/megamek/src/megamek/common/actions/WeaponAttackAction.java index 3c21d30a349..392fdbeac39 100644 --- a/megamek/src/megamek/common/actions/WeaponAttackAction.java +++ b/megamek/src/megamek/common/actions/WeaponAttackAction.java @@ -456,24 +456,19 @@ private static ToHitData toHitCalc(Game game, int attackerId, Targetable target, && (munition.contains(AmmoType.Munitions.M_FOLLOW_THE_LEADER) && !ComputeECM.isAffectedByECM(ae, ae.getPosition(), target.getPosition())); - Mounted mLinker = weapon.getLinkedBy(); + Mounted mLinker; - boolean bApollo = ((mLinker != null) && (mLinker.getType() instanceof MiscType) && !mLinker.isDestroyed() - && !mLinker.isMissing() && !mLinker.isBreached() && mLinker.getType().hasFlag(MiscType.F_APOLLO)) - && (atype != null) && (atype.getAmmoType() == AmmoType.T_MRM); + boolean bApollo; - boolean bArtemisV = ((mLinker != null) && (mLinker.getType() instanceof MiscType) && !mLinker.isDestroyed() - && !mLinker.isMissing() && !mLinker.isBreached() && mLinker.getType().hasFlag(MiscType.F_ARTEMIS_V) - && !isECMAffected && !bMekTankStealthActive && (atype != null) - && (munition.contains(AmmoType.Munitions.M_ARTEMIS_V_CAPABLE))); + boolean bArtemisV; if (ae.usesWeaponBays()) { - for (WeaponMounted bayW : weapon.getBayWeapons()) { + (ae.usesWeaponBays() ? weapon.streamBayWeapons() : Stream.of(weapon)).forEach (bayW -> Mounted bayWAmmo = bayW.getLinked(); if (bayWAmmo == null) { //At present, all weapons below using mLinker use ammo, so this won't be a problem - continue; + return; } AmmoType bAmmo = (AmmoType) bayWAmmo.getType(); @@ -496,7 +491,7 @@ private static ToHitData toHitCalc(Game game, int attackerId, Targetable target, && !mLinker.isMissing() && !mLinker.isBreached() && mLinker.getType().hasFlag(MiscType.F_ARTEMIS_V) && !isECMAffected && !bMekTankStealthActive && (atype != null) && (bAmmo != null) && (bAmmo.getMunitionType().contains(AmmoType.Munitions.M_ARTEMIS_V_CAPABLE))); - } + ) } boolean inSameBuilding = Compute.isInSameBuilding(game, ae, te);