Allow guards to guard a guarding guard.
Explicitly disallowed in the past (see ticket), it now becomes possible to e.g. guard a catafalque with a hero and guard the hero with healers. Refs #2034. Differential Revision: D2732 Reviewed by: @Angen, @bb. This was SVN commit r24033.
This commit is contained in:
parent
9449e99553
commit
7853a50635
@ -801,10 +801,9 @@ var g_UnitActions =
|
||||
},
|
||||
"getActionInfo": function(entState, targetState)
|
||||
{
|
||||
if (!targetState.guard ||
|
||||
if (!targetState.guard || entState.id == targetState.id ||
|
||||
!playerCheck(entState, targetState, ["Player", "Ally"]) ||
|
||||
!entState.unitAI || !entState.unitAI.canGuard ||
|
||||
targetState.unitAI && targetState.unitAI.isGuarding)
|
||||
!entState.unitAI || !entState.unitAI.canGuard)
|
||||
return false;
|
||||
|
||||
return { "possible": true };
|
||||
|
@ -5269,6 +5269,9 @@ UnitAI.prototype.Guard = function(target, queued)
|
||||
return;
|
||||
}
|
||||
|
||||
if (target === this.entity)
|
||||
return;
|
||||
|
||||
// if we already had an old guard order, do nothing if the target is the same
|
||||
// and the order is running, otherwise remove the previous order
|
||||
if (this.isGuardOf)
|
||||
@ -5291,11 +5294,6 @@ UnitAI.prototype.AddGuard = function(target)
|
||||
if (!cmpGuard)
|
||||
return false;
|
||||
|
||||
// Do not allow to guard a unit already guarding
|
||||
var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|
||||
if (cmpUnitAI && cmpUnitAI.IsGuardOf())
|
||||
return false;
|
||||
|
||||
this.isGuardOf = target;
|
||||
this.guardRange = cmpGuard.GetRange(this.entity);
|
||||
cmpGuard.AddGuard(this.entity);
|
||||
@ -5343,12 +5341,6 @@ UnitAI.prototype.CanGuard = function()
|
||||
if (this.IsFormationController())
|
||||
return true;
|
||||
|
||||
// Do not let a unit already guarded to guard. This would work in principle,
|
||||
// but would clutter the gui with too much buttons to take all cases into account
|
||||
var cmpGuard = Engine.QueryInterface(this.entity, IID_Guard);
|
||||
if (cmpGuard && cmpGuard.GetEntities().length)
|
||||
return false;
|
||||
|
||||
return this.template.CanGuard == "true";
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user