Skip to content

Commit

Permalink
Various fixes for auto check complaints
Browse files Browse the repository at this point in the history
  • Loading branch information
Sleet01 committed Dec 28, 2023
1 parent c753658 commit 1a8774e
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 47 deletions.
33 changes: 5 additions & 28 deletions megamek/src/megamek/common/Aero.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,10 +484,12 @@ public int getMaxBombPoints() {
return maxExtBombPoints + maxIntBombPoints;
}

@Override
public int getMaxIntBombPoints() {
return (hasQuirk(OptionsConstants.QUIRK_POS_INTERNAL_BOMB)) ? maxIntBombPoints : 0;
}

@Override
public int getMaxExtBombPoints() {
return maxExtBombPoints;
}
Expand Down Expand Up @@ -533,14 +535,17 @@ public int reduceMPByBombLoad(int t) {
return t;
}

@Override
public void setUsedInternalBombs(int b){
usedInternalBombs = b;
}

@Override
public void increaseUsedInternalBombs(int b){
usedInternalBombs += b;
}

@Override
public int getUsedInternalBombs() {
return usedInternalBombs;
}
Expand Down Expand Up @@ -2768,34 +2773,6 @@ public void doDisbandDamage() {
}
}

/**
* Damage a capital fighter's weapons. WeaponGroups are damaged by critical hits.
* This matches up the individual fighter's weapons and critical slots and damages those
* for MHQ resolution
* @param loc - Int corresponding to the location struck
*/
public void damageCapFighterWeapons(int loc) {
for (Mounted weapon : weaponList) {
if (weapon.getLocation() == loc) {
//Damage the weapon
weapon.setHit(true);
//Damage the critical slot
for (int i = 0; i < getNumberOfCriticals(loc); i++) {
CriticalSlot slot1 = getCritical(loc, i);
if ((slot1 == null) ||
(slot1.getType() == CriticalSlot.TYPE_SYSTEM)) {
continue;
}
Mounted mounted = slot1.getMount();
if (mounted.equals(weapon)) {
hitAllCriticals(loc, i);
break;
}
}
}
}
}

/**
* @return The total number of crew available to supplement marines on boarding actions.
* Includes officers, enlisted, and bay personnel, but not marines/ba or passengers.
Expand Down
3 changes: 3 additions & 0 deletions megamek/src/megamek/common/LandAirMech.java
Original file line number Diff line number Diff line change
Expand Up @@ -1121,14 +1121,17 @@ public void setIntBombChoices(int[] bc) {
}
}

@Override
public void setUsedInternalBombs(int b){
// Do nothing; LAMs don't take internal bomb bay hits like this
}

@Override
public void increaseUsedInternalBombs(int b){
// Do nothing
}

@Override
public int getUsedInternalBombs() {
// Currently not possible
return 0;
Expand Down
17 changes: 11 additions & 6 deletions megamek/src/megamek/common/MULParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -2261,12 +2261,17 @@ private void parseBombs(Element bombsTag, Entity entity) {
continue;
}

if (internal) {
intBombChoices[bombType] += Integer.parseInt(load);
((IBomber) entity).setIntBombChoices(intBombChoices);
} else {
extBombChoices[bombType] += Integer.parseInt(load);
((IBomber) entity).setExtBombChoices(extBombChoices);
try {
if (internal) {
intBombChoices[bombType] += Integer.parseInt(load);
((IBomber) entity).setIntBombChoices(intBombChoices);
} else {
extBombChoices[bombType] += Integer.parseInt(load);
((IBomber) entity).setExtBombChoices(extBombChoices);
}
} catch (NumberFormatException ignore) {
// If something wrote bad bomb data, don't even bother with it - user
// can fix it in configure menu
}
}
}
Expand Down
3 changes: 3 additions & 0 deletions megamek/src/megamek/common/VTOL.java
Original file line number Diff line number Diff line change
Expand Up @@ -301,14 +301,17 @@ public int reduceMPByBombLoad(int t) {
return Math.max(0, (t - (int) this.getBombs().stream().filter(m -> (m.getUsableShotsLeft() > 0)).count()));
}

@Override
public void setUsedInternalBombs(int b){
// Do nothing
}

@Override
public void increaseUsedInternalBombs(int b){
// Do nothing
}

@Override
public int getUsedInternalBombs() {
// Currently not possible
return 0;
Expand Down
26 changes: 13 additions & 13 deletions megamek/src/megamek/server/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -20896,8 +20896,8 @@ private Vector<Report> resolveControl(Entity e) {
private Vector<Report> resolveInternalBombHits() {
Vector<Report> vFullReport = new Vector<>();
vFullReport.add(new Report(5600, Report.PUBLIC));
for (Iterator<Entity> i = game.getEntities(); i.hasNext(); ) {
Vector<Report> interim = resolveInternalBombHit(i.next());
for (Entity e : game.getEntitiesVector()) {
Vector<Report> interim = resolveInternalBombHit(e);
if (!interim.isEmpty()) {
vFullReport.addAll(interim);
}
Expand Down Expand Up @@ -20928,7 +20928,6 @@ private Vector<Report> resolveInternalBombHit(Entity e) {

if (b.getUsedInternalBombs() > 0) {
int id = e.getId();
Vector<TargetRoll> rolls = new Vector<>();

// Header
r = new Report(5601);
Expand Down Expand Up @@ -25103,11 +25102,12 @@ private Vector<Report> applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in
}
case Aero.CRIT_WEAPON:
if (aero.isCapitalFighter()) {
FighterSquadron cf = (FighterSquadron) aero;
boolean destroyAll = false;
// CRIT_WEAPON damages the capital fighter/squadron's weapon groups
// Go ahead and map damage for the fighter's weapon criticals for MHQ
// resolution.
aero.damageCapFighterWeapons(loc);
cf.damageCapFighterWeapons(loc);
if ((loc == Aero.LOC_NOSE) || (loc == Aero.LOC_AFT)) {
destroyAll = true;
}
Expand All @@ -25118,13 +25118,13 @@ private Vector<Report> applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in
}

if (loc == Aero.LOC_WINGS) {
if (aero.areWingsHit()) {
if (cf.areWingsHit()) {
destroyAll = true;
} else {
aero.setWingsHit(true);
cf.setWingsHit(true);
}
}
for (Mounted weapon : aero.getWeaponList()) {
for (Mounted weapon : cf.getWeaponList()) {
if (weapon.getLocation() == loc) {
if (destroyAll) {
weapon.setHit(true);
Expand All @@ -25134,7 +25134,7 @@ private Vector<Report> applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in
}
}
// also destroy any ECM or BAP in the location hit
for (Mounted misc : aero.getMisc()) {
for (Mounted misc : cf.getMisc()) {
if ((misc.getType().hasFlag(MiscType.F_ECM)
|| misc.getType().hasFlag(MiscType.F_ANGEL_ECM)
|| misc.getType().hasFlag(MiscType.F_BAP))
Expand All @@ -25143,23 +25143,23 @@ private Vector<Report> applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in
//Taharqa: We should also damage the critical slot, or
//MM and MHQ won't remember that this weapon is damaged on the MUL
//file
for (int i = 0; i < aero.getNumberOfCriticals(loc); i++) {
CriticalSlot slot1 = aero.getCritical(loc, i);
for (int i = 0; i < cf.getNumberOfCriticals(loc); i++) {
CriticalSlot slot1 = cf.getCritical(loc, i);
if ((slot1 == null) ||
(slot1.getType() == CriticalSlot.TYPE_SYSTEM)) {
continue;
}
Mounted mounted = slot1.getMount();
if (mounted.equals(misc)) {
aero.hitAllCriticals(loc, i);
cf.hitAllCriticals(loc, i);
break;
}
}
}
}
r = new Report(9152);
r.subject = aero.getId();
r.add(aero.getLocationName(loc));
r.subject = cf.getId();
r.add(cf.getLocationName(loc));
reports.add(r);
break;
}
Expand Down

0 comments on commit 1a8774e

Please sign in to comment.