Fix auto-gathering after constructing fields.
Fix building on top of animal corpses. Fix builders getting in the way of their own building. This was SVN commit r8900.
This commit is contained in:
parent
b8925fbbc9
commit
78e174af7d
@ -822,7 +822,7 @@ function doAction(action, ev)
|
||||
|
||||
case "build": // (same command as repair)
|
||||
case "repair":
|
||||
Engine.PostNetworkCommand({"type": "repair", "entities": selection, "target": action.target, "queued": queued});
|
||||
Engine.PostNetworkCommand({"type": "repair", "entities": selection, "target": action.target, "autocontinue": true, "queued": queued});
|
||||
Engine.GuiInterfaceCall("PlaySound", { "name": "order_repair", "entity": selection[0] });
|
||||
return true;
|
||||
|
||||
|
@ -56,6 +56,14 @@ var AnimalFsmSpec = {
|
||||
"Attacked": function(msg) {
|
||||
// Do nothing, because we're dead already
|
||||
},
|
||||
|
||||
"LeaveFoundation": function(msg) {
|
||||
// We can't walk away from the foundation (since we're dead),
|
||||
// but we mustn't block its construction (since the builders would get stuck),
|
||||
// and we don't want to trick gatherers into trying to reach us when
|
||||
// we're stuck in the middle of a building, so just delete our corpse.
|
||||
Engine.DestroyEntity(this.entity);
|
||||
},
|
||||
},
|
||||
|
||||
"SKITTISH": {
|
||||
|
@ -373,7 +373,7 @@ var UnitFsmSpec = {
|
||||
"Order.LeaveFoundation": function(msg) {
|
||||
// Move a tile outside the building
|
||||
var range = 4;
|
||||
var ok = this.MoveToTargetRangeExplicit(this.order.data.target, range, range);
|
||||
var ok = this.MoveToTargetRangeExplicit(msg.data.target, range, range);
|
||||
if (ok)
|
||||
{
|
||||
// We've started walking to the given point
|
||||
@ -785,6 +785,25 @@ var UnitFsmSpec = {
|
||||
|
||||
// TODO: look for a nearby foundation to help with
|
||||
},
|
||||
|
||||
// Override the LeaveFoundation order since we don't want to be
|
||||
// accidentally blocking our own building
|
||||
"Order.LeaveFoundation": function(msg) {
|
||||
// Move a tile outside the building
|
||||
var range = 4;
|
||||
var ok = this.MoveToTargetRangeExplicit(msg.data.target, range, range);
|
||||
if (ok)
|
||||
{
|
||||
// We've started walking to the given point
|
||||
this.SetNextState("INDIVIDUAL.WALKING");
|
||||
}
|
||||
else
|
||||
{
|
||||
// We are already at the target, or can't move at all
|
||||
this.FinishOrder();
|
||||
}
|
||||
},
|
||||
|
||||
},
|
||||
|
||||
"GARRISON": {
|
||||
@ -1416,8 +1435,7 @@ UnitAI.prototype.LeaveFoundation = function(target)
|
||||
// TODO: we should verify this is a friendly foundation, otherwise
|
||||
// there's no reason we should let them build here
|
||||
|
||||
var queued = true;
|
||||
this.AddOrder("LeaveFoundation", { "target": target }, queued);
|
||||
this.PushOrderFront("LeaveFoundation", { "target": target });
|
||||
};
|
||||
|
||||
UnitAI.prototype.Attack = function(target, queued)
|
||||
@ -1478,7 +1496,7 @@ UnitAI.prototype.ReturnResource = function(target, queued)
|
||||
this.AddOrder("ReturnResource", { "target": target }, queued);
|
||||
};
|
||||
|
||||
UnitAI.prototype.Repair = function(target, queued)
|
||||
UnitAI.prototype.Repair = function(target, autocontinue, queued)
|
||||
{
|
||||
if (!this.CanRepair(target))
|
||||
{
|
||||
@ -1486,7 +1504,7 @@ UnitAI.prototype.Repair = function(target, queued)
|
||||
return;
|
||||
}
|
||||
|
||||
this.AddOrder("Repair", { "target": target }, queued);
|
||||
this.AddOrder("Repair", { "target": target, "autocontinue": autocontinue }, queued);
|
||||
};
|
||||
|
||||
UnitAI.prototype.SetStance = function(stance)
|
||||
|
@ -37,7 +37,7 @@ function ProcessCommand(player, cmd)
|
||||
// This covers both repairing damaged buildings, and constructing unfinished foundations
|
||||
var cmpUnitAI = GetFormationUnitAI(cmd.entities);
|
||||
if (cmpUnitAI)
|
||||
cmpUnitAI.Repair(cmd.target, cmd.queued);
|
||||
cmpUnitAI.Repair(cmd.target, cmd.autocontinue, cmd.queued);
|
||||
break;
|
||||
|
||||
case "gather":
|
||||
@ -162,6 +162,7 @@ function ProcessCommand(player, cmd)
|
||||
"type": "repair",
|
||||
"entities": cmd.entities,
|
||||
"target": ent,
|
||||
"autocontinue": cmd.autocontinue,
|
||||
"queued": cmd.queued
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user