From 2cf4e2110b7acbc0c78ec30557967c232c254444 Mon Sep 17 00:00:00 2001 From: cwspain Date: Tue, 14 Nov 2023 14:00:37 -0600 Subject: [PATCH] Handle artillery strike against offboard unit that has disengaged. --- megamek/i18n/megamek/common/report-messages.properties | 1 + .../weapons/ArtilleryBayWeaponIndirectFireHandler.java | 9 +++++++++ .../weapons/ArtilleryWeaponIndirectFireHandler.java | 9 +++++++++ 3 files changed, 19 insertions(+) diff --git a/megamek/i18n/megamek/common/report-messages.properties b/megamek/i18n/megamek/common/report-messages.properties index dba621a1c8c..21f1cc0ec81 100755 --- a/megamek/i18n/megamek/common/report-messages.properties +++ b/megamek/i18n/megamek/common/report-messages.properties @@ -302,6 +302,7 @@ 3145=, the shot is an automatic hit (), 3150=\ needs , 3155=rolls : +3158= lands, but the offboard target is gone. 3160=THE AUTOCANNON JAMS; 3161=THE DAMN THING JAMS; 3162=THE DAMN THING EXPLODES; diff --git a/megamek/src/megamek/common/weapons/ArtilleryBayWeaponIndirectFireHandler.java b/megamek/src/megamek/common/weapons/ArtilleryBayWeaponIndirectFireHandler.java index 7d374bf415b..bc9f2033ff7 100644 --- a/megamek/src/megamek/common/weapons/ArtilleryBayWeaponIndirectFireHandler.java +++ b/megamek/src/megamek/common/weapons/ArtilleryBayWeaponIndirectFireHandler.java @@ -136,6 +136,15 @@ public boolean handle(GamePhase phase, Vector vPhaseReport) { aaa.decrementTurnsTilHit(); return true; } + // Offboard shots are targeted at an entity rather than a hex. If null, the target has disengaged. + if (target == null) { + Report r = new Report(3158); + r.indent(); + r.subject = subjectId; + r.add(wtype.getName()); + vPhaseReport.add(r); + return true; + } final Vector spottersBefore = aaa.getSpotterIds(); Coords targetPos = target.getPosition(); final int playerId = aaa.getPlayerId(); diff --git a/megamek/src/megamek/common/weapons/ArtilleryWeaponIndirectFireHandler.java b/megamek/src/megamek/common/weapons/ArtilleryWeaponIndirectFireHandler.java index 0756a8f30bf..640173cfbac 100644 --- a/megamek/src/megamek/common/weapons/ArtilleryWeaponIndirectFireHandler.java +++ b/megamek/src/megamek/common/weapons/ArtilleryWeaponIndirectFireHandler.java @@ -102,6 +102,15 @@ public boolean handle(GamePhase phase, Vector vPhaseReport) { return true; } + // Offboard shots are targeted at an entity rather than a hex. If null, the target has disengaged. + if (target == null) { + Report r = new Report(3158); + r.indent(); + r.subject = subjectId; + r.add(wtype.getName()); + vPhaseReport.add(r); + return true; + } final Vector spottersBefore = aaa.getSpotterIds(); Coords targetPos = target.getPosition();