Skip to content

Commit

Permalink
Merge pull request #4890 from MegaMek/artillery_target_disengaged
Browse files Browse the repository at this point in the history
Handle artillery strike against offboard unit that has disengaged.
  • Loading branch information
neoancient authored Nov 15, 2023
2 parents c3187bf + 2cf4e21 commit 61330da
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 0 deletions.
1 change: 1 addition & 0 deletions megamek/i18n/megamek/common/report-messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@
3145=, the shot is an automatic hit (<data>),
3150=\ needs <data>,
3155=rolls <data> :
3158=<data> lands, but the offboard target is gone.
3160=<font color='C00000'>THE AUTOCANNON JAMS</font>;
3161=<font color='C00000'>THE DAMN THING JAMS</font>;
3162=<font color='C00000'>THE DAMN THING EXPLODES</font>;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,15 @@ public boolean handle(GamePhase phase, Vector<Report> 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<Integer> spottersBefore = aaa.getSpotterIds();
Coords targetPos = target.getPosition();
final int playerId = aaa.getPlayerId();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,15 @@ public boolean handle(GamePhase phase, Vector<Report> 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<Integer> spottersBefore = aaa.getSpotterIds();

Coords targetPos = target.getPosition();
Expand Down

0 comments on commit 61330da

Please sign in to comment.