forked from 0ad/0ad
tune the guard behaviour
This was SVN commit r14321.
This commit is contained in:
parent
a44e88fa42
commit
683349333b
@ -1267,7 +1267,7 @@ var UnitFsmSpec = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// if we already are targeting another unit still alive, finish with it first
|
// if we already are targeting another unit still alive, finish with it first
|
||||||
if (this.order && this.order.type == "WalkAndFight")
|
if (this.order && (this.order.type == "WalkAndFight" || this.order.type == "Attack"))
|
||||||
if (this.order.data.target != msg.data.attacker && this.TargetIsAlive(msg.data.attacker))
|
if (this.order.data.target != msg.data.attacker && this.TargetIsAlive(msg.data.attacker))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -1283,15 +1283,28 @@ var UnitFsmSpec = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// target the unit
|
// if the attacker is a building and we can repair the guarded, repair it rather than attacking
|
||||||
var cmpPosition = Engine.QueryInterface(msg.data.attacker, IID_Position);
|
var cmpBuildingAI = Engine.QueryInterface(msg.data.attacker, IID_BuildingAI);
|
||||||
if (!cmpPosition || !cmpPosition.IsInWorld())
|
if (cmpBuildingAI && this.CanRepair(this.isGuardOf) && cmpHealth.IsRepairable())
|
||||||
|
{
|
||||||
|
this.PushOrderFront("Repair", { "target": this.isGuardOf, "autocontinue": false, "force": false });
|
||||||
return;
|
return;
|
||||||
var pos = cmpPosition.GetPosition();
|
}
|
||||||
this.PushOrderFront("WalkAndFight", { "x": pos.x, "z": pos.z, "target": msg.data.attacker, "force": false });
|
|
||||||
// if we already had a WalkAndFight, keep only the most recent one in case the target has moved
|
// target the unit
|
||||||
if (this.orderQueue[1] && this.orderQueue[1].type == "WalkAndFight")
|
if (this.CheckTargetVisible(msg.data.attacker))
|
||||||
this.orderQueue.splice(1, 1);
|
this.PushOrderFront("Attack", { "target": msg.data.attacker, "force": false });
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var cmpPosition = Engine.QueryInterface(msg.data.attacker, IID_Position);
|
||||||
|
if (!cmpPosition || !cmpPosition.IsInWorld())
|
||||||
|
return;
|
||||||
|
var pos = cmpPosition.GetPosition();
|
||||||
|
this.PushOrderFront("WalkAndFight", { "x": pos.x, "z": pos.z, "target": msg.data.attacker, "force": false });
|
||||||
|
// if we already had a WalkAndFight, keep only the most recent one in case the target has moved
|
||||||
|
if (this.orderQueue[1] && this.orderQueue[1].type == "WalkAndFight")
|
||||||
|
this.orderQueue.splice(1, 1);
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
"IDLE": {
|
"IDLE": {
|
||||||
|
Loading…
Reference in New Issue
Block a user