Damage parent of mirage instead of trying to damage the mirage
Reviewed By: Freagarach Differential Revision: D2979 This was SVN commit r24005.
This commit is contained in:
1 parent
221d5d4062
commit
5e6a2322e7
3 files changed
+49
-28
No files matched your search
@@ -59,19 +59,21 @@ DelayedDamage.prototype.MissileHit = function(data, lateness)
|
||||
|
||||
let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager);
|
||||
|
||||
let target = data.target;
|
||||
// Since we can't damage mirages, replace a miraged target by the real target.
|
||||
let cmpMirage = Engine.QueryInterface(data.target, IID_Mirage);
|
||||
if (cmpMirage)
|
||||
target = cmpMirage.GetParent();
|
||||
|
||||
// Deal direct damage if we hit the main target
|
||||
// and we could handle the attack.
|
||||
if (Attacking.TestCollision(data.target, data.position, lateness) &&
|
||||
Attacking.HandleAttackEffects(data.target, data.type, data.attackData, data.attacker, data.attackerOwner))
|
||||
if (Attacking.TestCollision(target, data.position, lateness) &&
|
||||
Attacking.HandleAttackEffects(target, data.type, data.attackData, data.attacker, data.attackerOwner))
|
||||
{
|
||||
cmpProjectileManager.RemoveProjectile(data.projectileId);
|
||||
return;
|
||||
}
|
||||
|
||||
let targetPosition = Attacking.InterpolatedLocation(data.target, lateness);
|
||||
if (!targetPosition)
|
||||
return;
|
||||
|
||||
// If we didn't hit the main target look for nearby units.
|
||||
let ents = Attacking.EntitiesNearPoint(Vector2D.from3D(data.position), this.MISSILE_HIT_RADIUS,
|
||||
Attacking.GetPlayersToDamage(data.attackerOwner, data.friendlyFire));
|
||||
|
||||
@@ -47,9 +47,9 @@ Mirage.prototype.SetParent = function(ent)
|
||||
this.parent = ent;
|
||||
};
|
||||
|
||||
Mirage.prototype.GetPlayer = function()
|
||||
Mirage.prototype.GetParent = function()
|
||||
{
|
||||
return this.player;
|
||||
return this.parent;
|
||||
};
|
||||
|
||||
Mirage.prototype.SetPlayer = function(player)
|
||||
@@ -57,6 +57,11 @@ Mirage.prototype.SetPlayer = function(player)
|
||||
this.player = player;
|
||||
};
|
||||
|
||||
Mirage.prototype.GetPlayer = function()
|
||||
{
|
||||
return this.player;
|
||||
};
|
||||
|
||||
Mirage.prototype.Mirages = function(iid)
|
||||
{
|
||||
return this.miragedIids.has(iid);
|
||||
|
||||
@@ -432,31 +432,16 @@ function Test_MissileHit()
|
||||
TS_ASSERT(hitEnts.has(60));
|
||||
hitEnts.clear();
|
||||
|
||||
// The main target is not hit but another one is hit.
|
||||
|
||||
AddMock(60, IID_Position, {
|
||||
"GetPosition": () => new Vector3D(900, 10, 0),
|
||||
"GetPreviousPosition": () => new Vector3D(900, 10, 0),
|
||||
"GetPosition2D": () => new Vector2D(900, 0),
|
||||
"IsInWorld": () => true,
|
||||
});
|
||||
|
||||
AddMock(60, IID_Health, {
|
||||
"TakeDamage": (amount, __, ___) => {
|
||||
TS_ASSERT_EQUALS(false);
|
||||
return { "healthChange": -amount };
|
||||
}
|
||||
});
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, {
|
||||
"ExecuteQueryAroundPos": () => [61]
|
||||
// Target is a mirage: hit the parent.
|
||||
AddMock(60, IID_Mirage, {
|
||||
"GetParent": () => 61
|
||||
});
|
||||
|
||||
AddMock(61, IID_Position, {
|
||||
"GetPosition": () => targetPos,
|
||||
"GetPreviousPosition": () => targetPos,
|
||||
"GetPosition2D": () => Vector2D.from3D(targetPos),
|
||||
"IsInWorld": () => true,
|
||||
"IsInWorld": () => true
|
||||
});
|
||||
|
||||
AddMock(61, IID_Health, {
|
||||
@@ -468,7 +453,36 @@ function Test_MissileHit()
|
||||
});
|
||||
|
||||
AddMock(61, IID_Footprint, {
|
||||
"GetShape": () => ({ "type": "circle", "radius": 20 }),
|
||||
"GetShape": () => ({ "type": "circle", "radius": 20 })
|
||||
});
|
||||
|
||||
cmpDelayedDamage.MissileHit(data, 0);
|
||||
TS_ASSERT(hitEnts.has(61));
|
||||
hitEnts.clear();
|
||||
|
||||
// Make sure we don't corrupt other tests.
|
||||
DeleteMock(60, IID_Mirage);
|
||||
cmpDelayedDamage.MissileHit(data, 0);
|
||||
TS_ASSERT(hitEnts.has(60));
|
||||
hitEnts.clear();
|
||||
|
||||
// The main target is not hit but another one is hit.
|
||||
AddMock(60, IID_Position, {
|
||||
"GetPosition": () => new Vector3D(900, 10, 0),
|
||||
"GetPreviousPosition": () => new Vector3D(900, 10, 0),
|
||||
"GetPosition2D": () => new Vector2D(900, 0),
|
||||
"IsInWorld": () => true
|
||||
});
|
||||
|
||||
AddMock(60, IID_Health, {
|
||||
"TakeDamage": (amount, __, ___) => {
|
||||
TS_ASSERT_EQUALS(false);
|
||||
return { "healthChange": -amount };
|
||||
}
|
||||
});
|
||||
|
||||
AddMock(SYSTEM_ENTITY, IID_RangeManager, {
|
||||
"ExecuteQueryAroundPos": () => [61]
|
||||
});
|
||||
|
||||
cmpDelayedDamage.MissileHit(data, 0);
|
||||
|
||||
Reference in new issue
Block a user