1
0
forked from 0ad/0ad

Fix attacking miraged entities.

After 738b200dda, where the mirage should be queried in the
Start/StopAttacking functions.

Reported by: @bb
Differential revision: https://code.wildfiregames.com/D4267
Reviewed by: @bb
This was SVN commit r25914.
This commit is contained in:
Freagarach 2021-09-11 04:47:25 +00:00
parent e56d46548b
commit f2f412a6d2
2 changed files with 5 additions and 2 deletions

View File

@ -459,7 +459,7 @@ Attack.prototype.StartAttacking = function(target, type, callerIID)
if (!this.CanAttack(target, [type]))
return false;
let cmpResistance = Engine.QueryInterface(target, IID_Resistance);
const cmpResistance = QueryMiragedInterface(target, IID_Resistance);
if (!cmpResistance || !cmpResistance.AddAttacker(this.entity))
return false;
@ -504,7 +504,7 @@ Attack.prototype.StopAttacking = function(reason)
cmpTimer.CancelTimer(this.timer);
delete this.timer;
let cmpResistance = Engine.QueryInterface(this.target, IID_Resistance);
const cmpResistance = QueryMiragedInterface(this.target, IID_Resistance);
if (cmpResistance)
cmpResistance.RemoveAttacker(this.entity);

View File

@ -190,9 +190,12 @@ ResistanceMirage.prototype.Init = function(cmpResistance)
this.resistanceOfForm = {};
for (const entityForm in cmpResistance.template)
this.resistanceOfForm[entityForm] = cmpResistance.GetResistanceOfForm(entityForm);
this.attackers = new Set();
};
ResistanceMirage.prototype.IsInvulnerable = Resistance.prototype.IsInvulnerable;
ResistanceMirage.prototype.AddAttacker = Resistance.prototype.AddAttacker;
ResistanceMirage.prototype.RemoveAttacker = Resistance.prototype.RemoveAttacker;
ResistanceMirage.prototype.GetEffectiveResistanceAgainst = function(entityForm)
{