diff --git a/megamek/data/scenarios/Test Setups/DS_LOS.mms b/megamek/data/scenarios/Test Setups/DS_LOS.mms new file mode 100644 index 00000000000..bdce00a172c --- /dev/null +++ b/megamek/data/scenarios/Test Setups/DS_LOS.mms @@ -0,0 +1,15 @@ +MMSVersion: 2 +name: Grounded DS Test +planet: None +description: A grounded DS on a small map for use in range/LOS/FoV testing + +map: AGoAC Maps/16x17 Grassland 2.board + +factions: +- name: Test Player + + units: + - fullname: Intruder (3056) + at: [ 10, 9 ] + altitude: 0 + \ No newline at end of file diff --git a/megamek/src/megamek/client/ui/swing/boardview/FovHighlightingAndDarkening.java b/megamek/src/megamek/client/ui/swing/boardview/FovHighlightingAndDarkening.java index 6d9a1d95d33..5608c515cd0 100644 --- a/megamek/src/megamek/client/ui/swing/boardview/FovHighlightingAndDarkening.java +++ b/megamek/src/megamek/client/ui/swing/boardview/FovHighlightingAndDarkening.java @@ -75,10 +75,14 @@ boolean draw(Graphics boardGraph, Coords c, int drawX, int drawY, boolean saveBo Coords src; boolean hasLoS = true; // in movement phase, calc LOS based on selected hex, otherwise use selected Entity - if (this.boardView1.game.getPhase().isMovement() && this.boardView1.selected != null) { - src = this.boardView1.selected; - } else if (this.boardView1.getSelectedEntity() != null) { - src = this.boardView1.getSelectedEntity().getPosition(); + if (boardView1.game.getPhase().isMovement() && this.boardView1.selected != null) { + src = boardView1.selected; + } else if (boardView1.getSelectedEntity() != null) { + Entity viewer = boardView1.getSelectedEntity(); + src = viewer.getPosition(); + // multi-hex units look from the hex closest to the target to avoid self-blocking + src = viewer.getSecondaryPositions().values().stream() + .min(Comparator.comparingInt(co -> co.distance(c))).orElse(src); } else { src = null; }