From 549ec9d5614a28d1695f852ff7d4493012127f41 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Sun, 9 May 2010 00:44:33 +0000 Subject: [PATCH] Fix units attacking rocks and trees instead of gathering resources from them This was SVN commit r7520. --- binaries/data/mods/public/gui/session_new/input.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/binaries/data/mods/public/gui/session_new/input.js b/binaries/data/mods/public/gui/session_new/input.js index 5d52f3fbc4..ceeb9dae95 100644 --- a/binaries/data/mods/public/gui/session_new/input.js +++ b/binaries/data/mods/public/gui/session_new/input.js @@ -89,15 +89,16 @@ function determineAction(x, y) // e.g. prefer to attack an enemy unit, even if some friendly units are closer to the mouse) var targetState = Engine.GuiInterfaceCall("GetEntityState", targets[0]); - // Different owner -> attack - if (entState.attack && targetState.player != entState.player) - return {"type": "attack", "cursor": "action-attack", "target": targets[0]}; - // Resource -> gather var resource = findGatherType(entState.resourceGatherRates, targetState.resourceSupply); if (resource) return {"type": "gather", "cursor": "action-gather-"+resource, "target": targets[0]}; + // Different owner -> attack + // (TODO: this should only happen if the target is really targetable, not e.g. a tree that this unit can't gather) + if (entState.attack && targetState.player != entState.player) + return {"type": "attack", "cursor": "action-attack", "target": targets[0]}; + // If a builder, then: Foundation -> build if (entState.buildEntities && targetState.foundation) return {"type": "build", "cursor": "action-build", "target": targets[0]};