Skip to content

Commit

Permalink
fix: Avoid penalizing Improved Heavy Lasers in weapon bays
Browse files Browse the repository at this point in the history
While heavy lasers incur an accuracy penalty, this obviously isn't meant
to apply to improved heavy lasers, which are improved specifically by
avoiding that.

The check has also been made a bit more efficient.
  • Loading branch information
Saklad5 committed Aug 18, 2024
1 parent 0e7ec4b commit 4f537c7
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -3835,15 +3835,14 @@ private static ToHitData compileAeroAttackerToHitMods(Game game, Entity ae, Targ
if (ae.usesWeaponBays() && wtype != null && weapon != null) {

// any heavy lasers
if (wtype.getAtClass() == WeaponType.CLASS_LASER) {
for (WeaponMounted bweap : weapon.getBayWeapons()) {
WeaponType bwtype = bweap.getType();
if ((bwtype.getInternalName().contains("Heavy"))
&& (bwtype.getInternalName().contains("Laser"))) {
toHit.addModifier(+1, Messages.getString("WeaponAttackAction.HeavyLaserInBay"));
break;
}
}
if (wtype.getAtClass() == WeaponType.CLASS_LASER &&
weapon.bayWeapons.stream()
.map(getEntity().getWeapon)

Check warning

Code scanning / CodeQL

Expression always evaluates to the same value Warning

Expression always evaluates to the same value.
.filter(Objects::nonNull)
.map(WeaponMounted::getType)
.map(WeaponType::getInternalName)
.anyMatch(i -> i.startsWith("CLHeavyLaser"))) {
toHit.addModifier(+1, Messages.getString("WeaponAttackAction.HeavyLaserInBay"));
}
// barracuda missiles
else if (wtype.getAtClass() == WeaponType.CLASS_CAPITAL_MISSILE) {
Expand Down

0 comments on commit 4f537c7

Please sign in to comment.