Improve gathering behaviour if the target is exhausted.
This was SVN commit r11827.
This commit is contained in:
parent
bcf7c98b66
commit
ad87febd25
@ -1051,21 +1051,9 @@ var UnitFsmSpec = {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the target is exhausted, we switch to a new target
|
||||
if (status.exhausted)
|
||||
{
|
||||
var nearby = this.FindNearbyResource(function (ent, type, template) {
|
||||
return (
|
||||
type.specific == resourceType.specific
|
||||
&& (type.specific != "meat" || resourceTemplate == template)
|
||||
);
|
||||
});
|
||||
if (nearby)
|
||||
{
|
||||
this.PerformGather(nearby, false, false);
|
||||
return;
|
||||
}
|
||||
}
|
||||
// We can gather more from this target, do so in the next timer
|
||||
if (!status.exhausted)
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1090,42 +1078,42 @@ var UnitFsmSpec = {
|
||||
this.SetNextState("APPROACHING");
|
||||
return;
|
||||
}
|
||||
|
||||
// We're already in range, or can't get anywhere near it.
|
||||
|
||||
// Give up on this order and try our next queued order
|
||||
if (this.FinishOrder())
|
||||
return;
|
||||
|
||||
// No remaining orders - pick a useful default behaviour
|
||||
|
||||
// Try to find a new resource of the same specific type near our current position:
|
||||
// Also don't switch to a different type of huntable animal
|
||||
var nearby = this.FindNearbyResource(function (ent, type, template) {
|
||||
return (
|
||||
type.specific == resourceType.specific
|
||||
&& (type.specific != "meat" || resourceTemplate == template)
|
||||
);
|
||||
});
|
||||
if (nearby)
|
||||
{
|
||||
this.PerformGather(nearby, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Nothing else to gather - if we're carrying anything then we should
|
||||
// drop it off, and if not then we might as well head to the dropsite
|
||||
// anyway because that's a nice enough place to congregate and idle
|
||||
|
||||
var nearby = this.FindNearestDropsite(resourceType.generic);
|
||||
if (nearby)
|
||||
{
|
||||
this.PushOrderFront("ReturnResource", { "target": nearby, "force": false });
|
||||
return;
|
||||
}
|
||||
|
||||
// No dropsites - just give up
|
||||
}
|
||||
|
||||
// We're already in range, can't get anywhere near it or the target is exhausted.
|
||||
|
||||
// Give up on this order and try our next queued order
|
||||
if (this.FinishOrder())
|
||||
return;
|
||||
|
||||
// No remaining orders - pick a useful default behaviour
|
||||
|
||||
// Try to find a new resource of the same specific type near our current position:
|
||||
// Also don't switch to a different type of huntable animal
|
||||
var nearby = this.FindNearbyResource(function (ent, type, template) {
|
||||
return (
|
||||
type.specific == resourceType.specific
|
||||
&& (type.specific != "meat" || resourceTemplate == template)
|
||||
);
|
||||
});
|
||||
if (nearby)
|
||||
{
|
||||
this.PerformGather(nearby, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
// Nothing else to gather - if we're carrying anything then we should
|
||||
// drop it off, and if not then we might as well head to the dropsite
|
||||
// anyway because that's a nice enough place to congregate and idle
|
||||
|
||||
var nearby = this.FindNearestDropsite(resourceType.generic);
|
||||
if (nearby)
|
||||
{
|
||||
this.PushOrderFront("ReturnResource", { "target": nearby, "force": false });
|
||||
return;
|
||||
}
|
||||
|
||||
// No dropsites - just give up
|
||||
},
|
||||
},
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user