Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue #2652 TacOps BA crits #4046

Merged
merged 3 commits into from
Dec 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions megamek/src/megamek/common/BattleArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -589,19 +589,25 @@ public String getMovementAbbr(EntityMovementType mtype) {
@Override
public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMode aimingMode,
int cover) {
return rollHitLocation(side, aimedLocation, aimingMode, false);
}

/**
* Battle Armor units can only get hit in undestroyed troopers.
*
* @param isAttackingConvInfantry Set to true when attacked by CI, as these cannot score TacOps crits
*/
public HitData rollHitLocation(int side, int aimedLocation, AimingMode aimingMode,
boolean isAttackingConvInfantry) {
// If this squad was killed, target trooper 1 (just because).
if (isDoomed()) {
return new HitData(1);
}

if ((aimedLocation != LOC_NONE) && !aimingMode.isNone()) {

int roll = Compute.d6(2);

if ((5 < roll) && (roll < 9)) {
return new HitData(aimedLocation, side == ToHitData.SIDE_REAR,
true);
return new HitData(aimedLocation, side == ToHitData.SIDE_REAR, true);
}
}

Expand All @@ -612,25 +618,21 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod
// Remember that there's one more location than the number of troopers.
// In http://forums.classicbattletech.com/index.php/topic,43203.0.html,
// "previously destroyed includes the current phase" for rolling hits on
// a squad,
// modifying previous ruling in the AskThePM FAQ.
// a squad, modifying previous ruling in the AskThePM FAQ.
while ((loc >= locations())
|| (IArmorState.ARMOR_NA == this.getInternal(loc))
|| (IArmorState.ARMOR_DESTROYED == this.getInternal(loc))
|| ((IArmorState.ARMOR_DOOMED == this.getInternal(loc)) && !isDoomed())) {
loc = Compute.d6();
}

int critLocation = Compute.d6();
// TacOps p. 108 Trooper takes a crit if a second roll is the same
// location as the first.
// TO:AR p.108: Trooper takes a crit if a second roll is the same location as the first.
if (game.getOptions().booleanOption(OptionsConstants.ADVCOMBAT_TACOPS_BA_CRITICALS)
&& (loc == critLocation)) {
&& (loc == Compute.d6()) && !isAttackingConvInfantry) {
return new HitData(loc, false, HitData.EFFECT_CRITICAL);
}
// Hit that trooper.
return new HitData(loc);

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,4 +206,25 @@ public static double calculateBaseDamage(Entity ae, Mounted weapon, WeaponType w
return ((InfantryWeapon) wtype).getInfantryDamage();
}
}

@Override
protected void initHit(Entity entityTarget) {
if ((entityTarget instanceof BattleArmor) && ae.isConventionalInfantry()) {
// TacOps crits against BA do not happen for infantry weapon attacks
hit = ((BattleArmor) entityTarget).rollHitLocation(toHit.getHitTable(),
toHit.getSideTable(), waa.getAimedLocation(),
waa.getAimingMode(), toHit.getCover(), true);
hit.setGeneralDamageType(generalDamageType);
hit.setCapital(wtype.isCapital());
hit.setBoxCars(roll == 12);
hit.setCapMisCritMod(getCapMisMod());
hit.setFirstHit(firstHit);
hit.setAttackerId(getAttackerId());
if (weapon.isWeaponGroup()) {
hit.setSingleAV(attackValue);
}
} else {
super.initHit(entityTarget);
}
}
}