Skip to content

Commit

Permalink
Simplify NOE, add Evading, reverse Below calc
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Jan 10, 2024
1 parent 6d900d3 commit 2959033
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4925,16 +4925,21 @@ private static ToHitData artilleryDirectToHit(Game game, Entity ae, Targetable t
}

// Ground-to-air attacks against a target flying at NOE
if (Compute.isGroundToAir(ae, target) && te.isNOE()) {
if (te.isNOE()) {

Check warning

Code scanning / CodeQL

Dereferenced variable may be null Warning

Variable
te
may be null at this access because of
this
assignment.
if (te.passedWithin(ae.getPosition(), 1)) {
toHit.addModifier(+1, Messages.getString("WeaponAttackAction.TeNoe"));
} else {
toHit.addModifier(+3, Messages.getString("WeaponAttackAction.TeNoe"));
}
}

// Vs Aero, hits from below
if ((ae.getAltitude() - target.getAltitude()) > 2) {
// evading bonuses
if (te.isEvading()) {
toHit.addModifier(te.getEvasionBonus(), Messages.getString("WeaponAttackAction.TeEvading"));
}

// Vs Aero, hits from below; attacker _should_ always be below target.
if ((te.getAltitude() - ae.getAltitude()) > 2) {
toHit.setHitTable(ToHitData.HIT_BELOW);
}
}
Expand Down

0 comments on commit 2959033

Please sign in to comment.