diff --git a/megamek/src/megamek/common/Infantry.java b/megamek/src/megamek/common/Infantry.java index 0419bfbd5b..1f0393bd9d 100644 --- a/megamek/src/megamek/common/Infantry.java +++ b/megamek/src/megamek/common/Infantry.java @@ -734,6 +734,7 @@ public void setInternal(int val, int loc) { if (loc == LOC_INFANTRY) { activeTroopers = Math.max(val, 0); damageFieldWeapons(); + restoreUncrewedFieldWeapons(); } } @@ -896,6 +897,22 @@ public void damageOrRestoreFieldWeapons() { } } + /** + * Field guns that are hit (uncrewed) will be set + * to not hit if they have the appropriate number + * of active troopers. Field guns that are destroyed + * will not be un-hit. + */ + public void restoreUncrewedFieldWeapons() { + int totalCrewNeeded = 0; + for (Mounted weapon : originalFieldWeapons()) { + totalCrewNeeded += requiredCrewForFieldWeapon((WeaponType) weapon.getType()); + if (activeTroopers >= totalCrewNeeded && !weapon.isDestroyed()) { + weapon.setHit(false); + } + } + } + /** * @return The crew required to operate the given field gun or field artillery * weapon, TO:AUE p.123.