Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/DelayedDamage.js
Show First 20 Lines • Show All 44 Lines • ▼ Show 20 Lines | DelayedDamage.prototype.MissileHit = function(data, lateness) | ||||
// Do this first in case the direct hit kills the target. | // Do this first in case the direct hit kills the target. | ||||
if (data.splash) | if (data.splash) | ||||
Attacking.CauseDamageOverArea({ | Attacking.CauseDamageOverArea({ | ||||
"type": data.type, | "type": data.type, | ||||
"attackData": data.splash.attackData, | "attackData": data.splash.attackData, | ||||
"attacker": data.attacker, | "attacker": data.attacker, | ||||
"attackerOwner": data.attackerOwner, | "attackerOwner": data.attackerOwner, | ||||
"attackerPosition": data.attackerPosition, | |||||
"attackHeightOffset": data.attackHeightOffset, | |||||
"origin": Vector2D.from3D(data.position), | "origin": Vector2D.from3D(data.position), | ||||
"radius": data.splash.radius, | "radius": data.splash.radius, | ||||
"shape": data.splash.shape, | "shape": data.splash.shape, | ||||
"direction": data.direction, | "direction": data.direction, | ||||
"friendlyFire": data.splash.friendlyFire | "friendlyFire": data.splash.friendlyFire | ||||
}); | }); | ||||
let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager); | let cmpProjectileManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_ProjectileManager); | ||||
let target = data.target; | let target = data.target; | ||||
// 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.type, data.attackData, data.attacker, data.attackerOwner, data.attackerPosition, data.attackHeightOffset)) | ||||
{ | { | ||||
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.type, data.attackData, data.attacker, data.attackerOwner, data.attackerPosition, data.attackHeightOffset)) | ||||
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