Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/DelayedDamage.js
Show All 35 Lines | if (cmpSoundManager && data.attackImpactSound) | ||||
cmpSoundManager.PlaySoundGroupAtPosition(data.attackImpactSound, data.position); | cmpSoundManager.PlaySoundGroupAtPosition(data.attackImpactSound, data.position); | ||||
// 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, | "attackerData": data.attackerData, | ||||
"attackerOwner": data.attackerOwner, | |||||
"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); | ||||
// Deal direct damage if we hit the main target | // Deal direct damage if we hit the main target | ||||
// and if the target has Resistance (not the case for a mirage for example) | // and if the target has Resistance (not the case for a mirage for example) | ||||
if (Attacking.TestCollision(data.target, data.position, lateness)) | if (Attacking.TestCollision(data.target, data.position, lateness)) | ||||
{ | { | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
Attacking.HandleAttackEffects(data.type, data.attackData, data.target, data.attacker, data.attackerOwner); | Attacking.HandleAttackEffects(data.type, data.attackData, data.target, data.attackerData); | ||||
return; | return; | ||||
} | } | ||||
let targetPosition = Attacking.InterpolatedLocation(data.target, lateness); | let targetPosition = Attacking.InterpolatedLocation(data.target, lateness); | ||||
if (!targetPosition) | if (!targetPosition) | ||||
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 cmpPlayer = QueryPlayerIDInterface(data.attackerOwner); | let cmpPlayer = QueryPlayerIDInterface(data.attackerData.owner); | ||||
let ents = Attacking.EntitiesNearPoint(Vector2D.from3D(data.position), targetPosition.horizDistanceTo(data.position) * 2, cmpPlayer.GetEnemies()); | let ents = Attacking.EntitiesNearPoint(Vector2D.from3D(data.position), targetPosition.horizDistanceTo(data.position) * 2, cmpPlayer.GetEnemies()); | ||||
for (let ent of ents) | for (let ent of ents) | ||||
{ | { | ||||
if (!Attacking.TestCollision(ent, data.position, lateness)) | if (!Attacking.TestCollision(ent, data.position, lateness)) | ||||
continue; | continue; | ||||
Attacking.HandleAttackEffects(data.type, data.attackData, ent, data.attacker, data.attackerOwner); | Attacking.HandleAttackEffects(data.type, data.attackData, ent, data.attackerData); | ||||
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