Skip to content

Commit

Permalink
Consolidated indirect mode code.
Browse files Browse the repository at this point in the history
  • Loading branch information
neoancient committed Nov 4, 2023
1 parent 4ee3305 commit f261dce
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions megamek/src/megamek/common/EquipmentMode.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@

package megamek.common;

import megamek.common.weapons.Weapon;

import java.util.Hashtable;
import java.util.Objects;

Expand Down Expand Up @@ -115,4 +117,8 @@ public boolean equals(String modeName) {
public String toString() {
return getName();
}

public boolean isIndirect() {
return name.equals(Weapon.MODE_MISSILE_INDIRECT) || name.equals(Weapon.MODE_INDIRECT_HEAT);
}
}
3 changes: 1 addition & 2 deletions megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -366,8 +366,7 @@ private static ToHitData toHitCalc(Game game, int attackerId, Targetable target,
|| atype.countsAsFlak()
);

boolean isIndirect = (weapon.hasModes() && (weapon.curMode().equals(Weapon.MODE_MISSILE_INDIRECT)
||weapon.curMode().equals(Weapon.MODE_INDIRECT_HEAT)));
boolean isIndirect = weapon.hasModes() && (weapon.curMode().isIndirect());

// BMM p. 31, semi-guided indirect missile attacks vs tagged targets ignore terrain modifiers
boolean semiGuidedIndirectVsTaggedTarget = isIndirect &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ public int getSupportVeeSlots(Entity entity) {
@Override
protected AttackHandler getCorrectHandler(ToHitData toHit, WeaponAttackAction waa, Game game, GameManager manager) {
Mounted m = game.getEntity(waa.getEntityId()).getEquipment(waa.getWeaponId());
if (((null != m) && (m.curMode().equals(Weapon.MODE_FLAMER_HEAT) || m.curMode().equals(Weapon.MODE_INDIRECT_HEAT)
if (((null != m) && ((m.hasModes() && m.curMode().isIndirect())
|| (waa.getEntity(game).isSupportVehicle()
&& m.getLinked() != null
&& m.getLinked().getType() != null
Expand Down

0 comments on commit f261dce

Please sign in to comment.