Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/DelayedDamage.js
Show All 39 Lines | DelayedDamage.prototype.MissileHit = function(data, lateness) | ||||
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, | ||||
"origin": Vector2D.from3D(data.position), | "origin": Vector2D.from3D(data.position), | ||||
"radius": data.splash.radius, | "minRange": data.splash.minRange, | ||||
"maxRange": data.splash.maxRange, | |||||
"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.attacker, data.attackerOwner); | ||||
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 ents = Attacking.EntitiesNearPoint(Vector2D.from3D(data.position), | let ents = Attacking.EntitiesNearPoint(Vector2D.from3D(data.position), 0, | ||||
targetPosition.horizDistanceTo(data.position) * 2, | targetPosition.horizDistanceTo(data.position) * 2, | ||||
Attacking.GetPlayersToDamage(data.attackerOwner, data.friendlyFire)); | Attacking.GetPlayersToDamage(data.attackerOwner, data.friendlyFire)); | ||||
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.attacker, data.attackerOwner); | ||||
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