From 805394c0ba388e7ac731f804fa893662b9d2664c Mon Sep 17 00:00:00 2001 From: algebro Date: Tue, 6 Aug 2024 17:35:45 -0400 Subject: [PATCH] track avionics and control system hits per round --- megamek/src/megamek/common/Aero.java | 22 +++++++++++++++++++++ megamek/src/megamek/common/IAero.java | 4 ++++ megamek/src/megamek/common/LandAirMech.java | 13 ++++++++++++ megamek/src/megamek/server/GameManager.java | 3 +++ 4 files changed, 42 insertions(+) diff --git a/megamek/src/megamek/common/Aero.java b/megamek/src/megamek/common/Aero.java index e1525ad97d5..3af59370fde 100644 --- a/megamek/src/megamek/common/Aero.java +++ b/megamek/src/megamek/common/Aero.java @@ -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; @@ -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; } @@ -1033,6 +1053,8 @@ public void newRound(int roundNumber) { setWhoFirst(); resetAltLossThisRound(); + setAvionicsHitsThisRound(0); + setControlHitsThisRound(0); // Reset usedInternalBombs setUsedInternalBombs(0); diff --git a/megamek/src/megamek/common/IAero.java b/megamek/src/megamek/common/IAero.java index f69fb6fd0ab..d50a788bddc 100644 --- a/megamek/src/megamek/common/IAero.java +++ b/megamek/src/megamek/common/IAero.java @@ -107,6 +107,10 @@ public interface IAero { int getAvionicsHits(); + int getAvionicsHitsThisRound(); + + void setAvionicsHitsThisRound(int i); + int getSensorHits(); int getFCSHits(); diff --git a/megamek/src/megamek/common/LandAirMech.java b/megamek/src/megamek/common/LandAirMech.java index c9a495b2a31..71850cf3cfd 100644 --- a/megamek/src/megamek/common/LandAirMech.java +++ b/megamek/src/megamek/common/LandAirMech.java @@ -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; @@ -880,6 +882,7 @@ public void newRound(int roundNumber) { setWhoFirst(); resetAltLossThisRound(); + setAvionicsHitsThisRound(0); } } @@ -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); diff --git a/megamek/src/megamek/server/GameManager.java b/megamek/src/megamek/server/GameManager.java index 04d7d39b3da..c213847c4ea 100644 --- a/megamek/src/megamek/server/GameManager.java +++ b/megamek/src/megamek/server/GameManager.java @@ -24044,6 +24044,7 @@ private Vector 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")); @@ -24342,6 +24343,7 @@ private Vector 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")); @@ -24358,6 +24360,7 @@ private Vector 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"));