forked from 0ad/0ad
Make charge attack unavailable from the simulation.
The order change to GetAttackTypes in a09c59e044
revealed that it was
only the GUI not triggering the buggy code.
Eliminate for-each of UnitAI calling that function.
This was SVN commit r18481.
This commit is contained in:
parent
0f38095dfd
commit
437cc13b95
@ -208,7 +208,7 @@ Attack.prototype.Serialize = null; // we have no dynamic state to save
|
||||
|
||||
Attack.prototype.GetAttackTypes = function()
|
||||
{
|
||||
return ["Melee", "Ranged", "Capture", "Charge"].filter(type => !!this.template[type]);
|
||||
return ["Melee", "Ranged", "Capture"].filter(type => !!this.template[type]);
|
||||
};
|
||||
|
||||
Attack.prototype.GetPreferredClasses = function(type)
|
||||
|
@ -4655,12 +4655,9 @@ UnitAI.prototype.ShouldAbandonChase = function(target, force, iid, type)
|
||||
{
|
||||
var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|
||||
var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|
||||
if (cmpUnitAI && cmpAttack)
|
||||
{
|
||||
for each (var targetType in cmpAttack.GetAttackTypes())
|
||||
if (cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, targetType))
|
||||
return false;
|
||||
}
|
||||
if (cmpUnitAI && cmpAttack &&
|
||||
cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|
||||
return false;
|
||||
}
|
||||
|
||||
// Stop if we're in hold-ground mode and it's too far from the holding point
|
||||
@ -4705,12 +4702,9 @@ UnitAI.prototype.ShouldChaseTargetedEntity = function(target, force)
|
||||
{
|
||||
var cmpUnitAI = Engine.QueryInterface(target, IID_UnitAI);
|
||||
var cmpAttack = Engine.QueryInterface(target, IID_Attack);
|
||||
if (cmpUnitAI && cmpAttack)
|
||||
{
|
||||
for each (var type in cmpAttack.GetAttackTypes())
|
||||
if (cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type))
|
||||
return true;
|
||||
}
|
||||
if (cmpUnitAI && cmpAttack &&
|
||||
cmpAttack.GetAttackTypes().some(type => cmpUnitAI.CheckTargetAttackRange(this.isGuardOf, type)))
|
||||
return true;
|
||||
}
|
||||
|
||||
if (force)
|
||||
|
Loading…
Reference in New Issue
Block a user