From 191549e51c23f674e6e27cb6292546e3bd884e93 Mon Sep 17 00:00:00 2001 From: Atrik Date: Fri, 11 Sep 2026 10:07:23 +0200 Subject: [PATCH] Fix crossed unit-to-target pairing sortEntitiesForEngagement projects both attackers and targets from the same origin (avgAttackers) onto the same vector, so reversing the target array was incorrect. --- binaries/data/mods/public/gui/session/input.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/binaries/data/mods/public/gui/session/input.js b/binaries/data/mods/public/gui/session/input.js index be8b6d4e23..5784efb628 100644 --- a/binaries/data/mods/public/gui/session/input.js +++ b/binaries/data/mods/public/gui/session/input.js @@ -2045,7 +2045,8 @@ function distributeAttackOrders(attackers, targets) * @param {number[]} attackers - Array of attacking entity IDs. * @param {number[]} targets - Array of target entity IDs. * @returns {Object} { attackers: number[], targets: number[] } - Both arrays sorted - * for cross-line engagement (targets automatically reversed). + * along the same shared axis so corresponding indices pair up + * for realistic line engagement. */ function sortEntitiesForEngagement(attackers, targets) { @@ -2066,10 +2067,9 @@ function sortEntitiesForEngagement(attackers, targets) const sortedAttackers = sortEntitiesAlongLine(attackers, avgAttackers, avgTargets); const sortedTargets = sortEntitiesAlongLine(targets, avgAttackers, avgTargets); - // Reverse targets so the leftmost attacker pairs with leftmost target return { "attackers": sortedAttackers, - "targets": sortedTargets.reverse() + "targets": sortedTargets }; }