Differential D2269 Diff 16298 ps/trunk/binaries/data/mods/public/simulation/components/DelayedDamage.js
Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/DelayedDamage.js
Show First 20 Lines • Show All 62 Lines • ▼ Show 20 Lines | DelayedDamage.prototype.MissileHit = function(data, lateness) | ||||
// Since we can't damage mirages, replace a miraged target by the real target. | // Since we can't damage mirages, replace a miraged target by the real target. | ||||
let cmpMirage = Engine.QueryInterface(data.target, IID_Mirage); | let cmpMirage = Engine.QueryInterface(data.target, IID_Mirage); | ||||
if (cmpMirage) | if (cmpMirage) | ||||
target = cmpMirage.GetParent(); | target = cmpMirage.GetParent(); | ||||
// Deal direct damage if we hit the main target | // Deal direct damage if we hit the main target | ||||
// and we could handle the attack. | // and we could handle the attack. | ||||
if (PositionHelper.TestCollision(target, data.position, lateness) && | if (PositionHelper.TestCollision(target, data.position, lateness) && | ||||
Attacking.HandleAttackEffects(target, data.type, data.attackData, data.attacker, data.attackerOwner)) | Attacking.HandleAttackEffects(target, data)) | ||||
{ | { | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
return; | return; | ||||
} | } | ||||
// If we didn't hit the main target look for nearby units. | // If we didn't hit the main target look for nearby units. | ||||
let ents = PositionHelper.EntitiesNearPoint(Vector2D.from3D(data.position), this.MISSILE_HIT_RADIUS, | let ents = PositionHelper.EntitiesNearPoint(Vector2D.from3D(data.position), this.MISSILE_HIT_RADIUS, | ||||
Attacking.GetPlayersToDamage(data.attackerOwner, data.friendlyFire)); | Attacking.GetPlayersToDamage(data.attackerOwner, data.friendlyFire)); | ||||
for (let ent of ents) | for (let ent of ents) | ||||
{ | { | ||||
if (!PositionHelper.TestCollision(ent, data.position, lateness) || | if (!PositionHelper.TestCollision(ent, data.position, lateness) || | ||||
!Attacking.HandleAttackEffects(ent, data.type, data.attackData, data.attacker, data.attackerOwner)) | !Attacking.HandleAttackEffects(ent, data)) | ||||
continue; | continue; | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
break; | break; | ||||
} | } | ||||
}; | }; | ||||
Engine.RegisterSystemComponentType(IID_DelayedDamage, "DelayedDamage", DelayedDamage); | Engine.RegisterSystemComponentType(IID_DelayedDamage, "DelayedDamage", DelayedDamage); |
Wildfire Games · Phabricator