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 2 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
17 changes: 12 additions & 5 deletions megamek/src/megamek/common/BattleArmor.java
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,16 @@ public String getMovementAbbr(EntityMovementType mtype) {
@Override
public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMode aimingMode,
int cover) {
return rollHitLocation(table, side, aimedLocation, aimingMode, cover, 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 table, int side, int aimedLocation, AimingMode aimingMode,

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'table' is never used.
int cover, boolean isAttackingConvInfantry) {

Check notice

Code scanning / CodeQL

Useless parameter

The parameter 'cover' is never used.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why add this method with two unused parameters? Keeping it consistent with the general rollHitLocation methods?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More like, didn't think about it. I guess it's not worth getting the compiler warnings and github alerts for it, so I removed them.


// If this squad was killed, target trooper 1 (just because).
if (isDoomed()) {
Expand Down Expand Up @@ -621,16 +631,13 @@ public HitData rollHitLocation(int table, int side, int aimedLocation, AimingMod
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);
}
}
}