Ensure that animals that aren't visible when the order is executed are killed before being gathered from. Fixes #1826.
This was SVN commit r13132.
This commit is contained in:
parent
f503dd4e3e
commit
7e60f07df5
@ -463,9 +463,8 @@ var UnitFsmSpec = {
|
||||
},
|
||||
|
||||
"Order.Gather": function(msg) {
|
||||
|
||||
// If the target is still alive, we need to kill it first
|
||||
if (this.MustKillGatherTarget(this.order.data.target) && this.CheckTargetVisible(this.order.data.target))
|
||||
if (this.MustKillGatherTarget(this.order.data.target))
|
||||
{
|
||||
// Make sure we can attack the target, else we'll get very stuck
|
||||
if (!this.GetBestAttackAgainst(this.order.data.target))
|
||||
@ -475,6 +474,22 @@ var UnitFsmSpec = {
|
||||
this.FinishOrder();
|
||||
return;
|
||||
}
|
||||
// The target was visible when this order was issued,
|
||||
// but could now be invisible again.
|
||||
if (!this.CheckTargetVisible(this.order.data.target))
|
||||
{
|
||||
if (this.order.data.secondTry === undefined)
|
||||
{
|
||||
this.order.data.secondTry = true;
|
||||
this.PushOrderFront("Walk", this.order.data.lastPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We couldn't move there, or the target moved away
|
||||
this.FinishOrder();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.PushOrderFront("Attack", { "target": this.order.data.target, "force": false, "hunting": true });
|
||||
return;
|
||||
@ -691,8 +706,25 @@ var UnitFsmSpec = {
|
||||
},
|
||||
|
||||
"Order.Gather": function(msg) {
|
||||
if (this.MustKillGatherTarget(msg.data.target) && this.CheckTargetVisible(msg.data.target))
|
||||
if (this.MustKillGatherTarget(msg.data.target))
|
||||
{
|
||||
// The target was visible when this order was given,
|
||||
// but could now be invisible.
|
||||
if (!this.CheckTargetVisible(msg.data.target))
|
||||
{
|
||||
if (msg.data.secondTry === undefined)
|
||||
{
|
||||
msg.data.secondTry = true;
|
||||
this.PushOrderFront("Walk", msg.data.lastPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
// We couldn't move there, or the target moved away
|
||||
this.FinishOrder();
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
this.PushOrderFront("Attack", { "target": msg.data.target, "hunting": true });
|
||||
return;
|
||||
}
|
||||
@ -3111,10 +3143,10 @@ UnitAI.prototype.FaceTowardsTarget = function(target)
|
||||
{
|
||||
var cmpPosition = Engine.QueryInterface(this.entity, IID_Position);
|
||||
if (!cmpPosition || !cmpPosition.IsInWorld())
|
||||
return;
|
||||
return;
|
||||
var cmpTargetPosition = Engine.QueryInterface(target, IID_Position);
|
||||
if (!cmpTargetPosition || !cmpTargetPosition.IsInWorld())
|
||||
return;
|
||||
return;
|
||||
var pos = cmpPosition.GetPosition();
|
||||
var targetpos = cmpTargetPosition.GetPosition();
|
||||
var angle = Math.atan2(targetpos.x - pos.x, targetpos.z - pos.z);
|
||||
|
Loading…
Reference in New Issue
Block a user