1
0
forked from 0ad/0ad

Fix units attacking rocks and trees instead of gathering resources from them

This was SVN commit r7520.
This commit is contained in:
Ykkrosh 2010-05-09 00:44:33 +00:00
parent c75029b6ab
commit 549ec9d561

View File

@ -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]};