Skip to content

Commit

Permalink
Merge pull request #6307 from psikomonkie/issue-6305-partial-cover-in…
Browse files Browse the repository at this point in the history
…-water-and-hull-down

Fixes #6305: Partial Cover from water should now apply and hull down should grant a bonus now
  • Loading branch information
HoneySkull authored Dec 25, 2024
2 parents a211b3d + feb13be commit 90b1a03
Showing 1 changed file with 30 additions and 30 deletions.
60 changes: 30 additions & 30 deletions megamek/src/megamek/common/actions/WeaponAttackAction.java
Original file line number Diff line number Diff line change
Expand Up @@ -4250,35 +4250,6 @@ private static ToHitData compileTargetToHitMods(Game game, Entity ae, Targetable
toHit.addModifier(te.getEvasionBonus(), Messages.getString("WeaponAttackAction.TeEvading"));
}

// Hull Down
if ((te != null) && te.isHullDown()) {
if ((te instanceof Mek) && !(te instanceof QuadVee && te.getConversionMode() == QuadVee.CONV_MODE_VEHICLE)
&& (los.getTargetCover() > LosEffects.COVER_NONE)) {
toHit.addModifier(2, Messages.getString("WeaponAttackAction.HullDown"));
}
// tanks going Hull Down is different rules then 'Meks, the
// direction the attack comes from matters
else if ((te instanceof Tank
|| (te instanceof QuadVee && te.getConversionMode() == QuadVee.CONV_MODE_VEHICLE))
&& targHex.containsTerrain(Terrains.FORTIFIED)) {
// TODO make this a LoS mod so that attacks will come in from
// directions that grant Hull Down Mods
int moveInDirection;

if (!((Tank) te).isBackedIntoHullDown()) {
moveInDirection = ToHitData.SIDE_FRONT;
} else {
moveInDirection = ToHitData.SIDE_REAR;
}

if ((te.sideTable(ae.getPosition()) == moveInDirection)
|| (te.sideTable(ae.getPosition()) == ToHitData.SIDE_LEFT)
|| (te.sideTable(ae.getPosition()) == ToHitData.SIDE_RIGHT)) {
toHit.addModifier(2, Messages.getString("WeaponAttackAction.HullDown"));
}
}
}

// Infantry taking cover per TacOps special rules
if ((te instanceof Infantry) && ((Infantry) te).isTakingCover()) {
if (te.getPosition().direction(ae.getPosition()) == te.getFacing()) {
Expand Down Expand Up @@ -4668,7 +4639,7 @@ private static ToHitData compileTerrainAndLosToHitMods(Game game, Entity ae, Tar
// target in partial water
&& (targHex.terrainLevel(Terrains.WATER) == partialWaterLevel) && (targEl == 0) && (te.height() > 0)) {
los.setTargetCover(los.getTargetCover() | LosEffects.COVER_HORIZONTAL);
losMods = los.losModifiers(game, eistatus, underWater);
toHit.append(los.losModifiers(game, eistatus, underWater));
}

// Change hit table for partial cover, accommodate for partial underwater (legs)
Expand Down Expand Up @@ -4701,6 +4672,35 @@ private static ToHitData compileTerrainAndLosToHitMods(Game game, Entity ae, Tar
}
}

// Hull Down - Some cover states are dependent on LOS
if ((te != null) && te.isHullDown()) {
if ((te instanceof Mek) && !(te instanceof QuadVee && te.getConversionMode() == QuadVee.CONV_MODE_VEHICLE)
&& (los.getTargetCover() > LosEffects.COVER_NONE)) {
toHit.addModifier(2, Messages.getString("WeaponAttackAction.HullDown"));
}
// tanks going Hull Down is different rules then 'Meks, the
// direction the attack comes from matters
else if ((te instanceof Tank
|| (te instanceof QuadVee && te.getConversionMode() == QuadVee.CONV_MODE_VEHICLE))
&& targetHexContainsFortified) {
// TODO make this a LoS mod so that attacks will come in from
// directions that grant Hull Down Mods
int moveInDirection;

if (!((Tank) te).isBackedIntoHullDown()) {
moveInDirection = ToHitData.SIDE_FRONT;
} else {
moveInDirection = ToHitData.SIDE_REAR;
}

if ((te.sideTable(ae.getPosition()) == moveInDirection)
|| (te.sideTable(ae.getPosition()) == ToHitData.SIDE_LEFT)
|| (te.sideTable(ae.getPosition()) == ToHitData.SIDE_RIGHT)) {
toHit.addModifier(2, Messages.getString("WeaponAttackAction.HullDown"));
}
}
}

// Special Equipment

// BAP Targeting rule enabled - TO:AR 6th p.97
Expand Down

0 comments on commit 90b1a03

Please sign in to comment.