Skip to content

Commit

Permalink
Merge pull request #4087 from SJuliez/AS_NoAmmo_Fix
Browse files Browse the repository at this point in the history
AS conversion: disregard weapons lacking ammo
  • Loading branch information
SJuliez authored Jan 5, 2023
2 parents 27cf56b + 0183019 commit e7bb69e
Showing 1 changed file with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public class ASDamageConverter {
protected int rearLocation;
protected int turretLocation;

private final Map<WeaponType, Boolean> ammoForWeapon = new HashMap<>();
private final Map<WeaponType, Double> ammoModifier = new HashMap<>();
protected final boolean hasTargetingComputer;
protected List<Mounted> weaponsList;
protected double rawSDamage;
Expand Down Expand Up @@ -358,7 +358,7 @@ protected void processEDamage() { }

protected double getDamageMultiplier(Mounted weapon, WeaponType weaponType) {
// Low ammo count
double damageModifier = ammoForWeapon.getOrDefault(weaponType, true) ? 1 : 0.75;
double damageModifier = ammoModifier.getOrDefault(weaponType, 1d);

// Oneshot or Fusillade
if (weaponType.hasFlag(WeaponType.F_ONESHOT) && !(weaponType instanceof CLFussilade)) {
Expand Down Expand Up @@ -409,7 +409,14 @@ protected void assembleAmmoCounts() {
|| weaponType.getAmmoType() == AmmoType.T_AC_ULTRA_THB) {
divisor = 2;
}
ammoForWeapon.put(weaponType, ammoCount / weaponCount.get(weaponType) >= 10 * divisor);

if (ammoCount / weaponCount.get(weaponType) >= 10 * divisor) {
ammoModifier.put(weaponType, 1d);
} else if (ammoCount > 0) {
ammoModifier.put(weaponType, 0.75);
} else {
ammoModifier.put(weaponType, 0d);
}
}
}

Expand Down

0 comments on commit e7bb69e

Please sign in to comment.