Skip to content

Commit

Permalink
track avionics and control system hits per round
Browse files Browse the repository at this point in the history
  • Loading branch information
Algebro7 committed Aug 6, 2024
1 parent f2ebf5b commit 805394c
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
22 changes: 22 additions & 0 deletions megamek/src/megamek/common/Aero.java
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,8 @@ public String[] getLocationNames() {
* applied before the attack resolves.
*/
private int altLossThisRound = 0;
private int avionicsHitsThisRound = 0;
private int controlHitsThisRound = 0;

private boolean spheroid = false;

Expand Down Expand Up @@ -759,6 +761,24 @@ public void setAvionicsHits(int hits) {
avionicsHits = hits;
}

@Override
public int getAvionicsHitsThisRound() {
return avionicsHitsThisRound;
}

@Override
public void setAvionicsHitsThisRound(int hits) {
avionicsHitsThisRound = hits;
}

public int getControlHitsThisRound() {
return controlHitsThisRound;
}

public void setControlHitsThisRound(int hits) {
controlHitsThisRound = hits;
}

public boolean isGearHit() {
return gearHit;
}
Expand Down Expand Up @@ -1033,6 +1053,8 @@ public void newRound(int roundNumber) {
setWhoFirst();

resetAltLossThisRound();
setAvionicsHitsThisRound(0);
setControlHitsThisRound(0);

// Reset usedInternalBombs
setUsedInternalBombs(0);
Expand Down
4 changes: 4 additions & 0 deletions megamek/src/megamek/common/IAero.java
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,10 @@ public interface IAero {

int getAvionicsHits();

int getAvionicsHitsThisRound();

void setAvionicsHitsThisRound(int i);

int getSensorHits();

int getFCSHits();
Expand Down
13 changes: 13 additions & 0 deletions megamek/src/megamek/common/LandAirMech.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,8 @@ public String[] getLocationAbbrs() {
private int straightMoves = 0;
private int altLoss = 0;
private int altLossThisRound = 0;
private int avionicsHitsThisRound = 0;


//Autoejection
private boolean critThresh = false;
Expand Down Expand Up @@ -880,6 +882,7 @@ public void newRound(int roundNumber) {
setWhoFirst();

resetAltLossThisRound();
setAvionicsHitsThisRound(0);
}
}

Expand Down Expand Up @@ -1331,6 +1334,16 @@ public int getAvionicsHits() {
return hits;
}

@Override
public int getAvionicsHitsThisRound() {
return avionicsHitsThisRound;
}

@Override
public void setAvionicsHitsThisRound(int hits) {
avionicsHitsThisRound = hits;
}

@Override
public int getSensorHits() {
return getBadCriticals(CriticalSlot.TYPE_SYSTEM, SYSTEM_SENSORS, LOC_HEAD);
Expand Down
3 changes: 3 additions & 0 deletions megamek/src/megamek/server/GameManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -24044,6 +24044,7 @@ private Vector<Report> applyMechSystemCritical(Entity en, int loc, CriticalSlot
break;
case LandAirMech.LAM_AVIONICS:
if (en.getConversionMode() == LandAirMech.CONV_MODE_FIGHTER) {
((LandAirMech)en).setAvionicsHitsThisRound(((LandAirMech)en).getAvionicsHitsThisRound() + 1);
if (en.isPartOfFighterSquadron()) {
game.addControlRoll(new PilotingRollData(
en.getTransportId(), 1, "avionics hit"));
Expand Down Expand Up @@ -24342,6 +24343,7 @@ private Vector<Report> applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in
r.subject = aero.getId();
reports.add(r);
aero.setAvionicsHits(aero.getAvionicsHits() + 1);
aero.setAvionicsHitsThisRound(aero.getAvionicsHitsThisRound() + 1);
if (aero.isPartOfFighterSquadron()) {
game.addControlRoll(new PilotingRollData(
aero.getTransportId(), 1, "avionics hit"));
Expand All @@ -24358,6 +24360,7 @@ private Vector<Report> applyAeroCritical(Aero aero, int loc, CriticalSlot cs, in
r = new Report(9115);
r.subject = aero.getId();
reports.add(r);
aero.setControlHitsThisRound(aero.getControlHitsThisRound() + 1);
if (aero.isPartOfFighterSquadron()) {
game.addControlRoll(new PilotingRollData(
aero.getTransportId(), 1, "critical hit"));
Expand Down

0 comments on commit 805394c

Please sign in to comment.