Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/DelayedDamage.js
Show All 37 Lines | |||||
{ | { | ||||
if (!data.position) | if (!data.position) | ||||
return; | return; | ||||
let cmpSoundManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager); | let cmpSoundManager = Engine.QueryInterface(SYSTEM_ENTITY, IID_SoundManager); | ||||
if (cmpSoundManager && data.attackImpactSound) | 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. | ||||
Freagarach: Not needed anymore, since rP14231. | |||||
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, | "radius": data.splash.radius, | ||||
Show All 29 Lines | if (!PositionHelper.TestCollision(ent, data.position, lateness) || | ||||
!Attacking.HandleAttackEffects(ent, data)) | !Attacking.HandleAttackEffects(ent, data)) | ||||
continue; | continue; | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
break; | break; | ||||
} | } | ||||
}; | }; | ||||
/** | |||||
* Handles damage caused by non projectile attack. | |||||
* @param {Object} data - The data sent by the caller. | |||||
* @param {string} data.type - The type of damage. | |||||
* @param {Object} data.attackData - Data of the form { 'effectType': { ...opaque effect data... }, 'Bonuses': {...} }. | |||||
* @param {number} data.target - The entity id of the target. | |||||
* @param {number} data.attacker - The entity id of the attacker. | |||||
* @param {number} data.attackerOwner - The player id of the owner of the attacker. | |||||
* @param {Vector3D} data.position - The expected position of the target. | |||||
* @param {Vector3D} data.direction - The unit vector defining the direction. | |||||
* @param {boolean} data.friendlyFire - A flag indicating whether allied entities can also be damaged. | |||||
* ***When splash damage*** | |||||
* @param {boolean} data.splash.friendlyFire - A flag indicating if allied entities are also damaged. | |||||
* @param {number} data.splash.radius - The radius of the splash damage. | |||||
* @param {string} data.splash.shape - The shape of the splash range. | |||||
* @param {Object} data.splash.attackData - same as attackData, for splash. | |||||
*/ | |||||
DelayedDamage.prototype.CauseAttackEffects = function(data, lateness) | |||||
{ | |||||
if (!data.position) | |||||
return; | |||||
if (data.splash) | |||||
Attacking.CauseDamageOverArea({ | |||||
"type": data.type, | |||||
"attackData": data.splash.attackData, | |||||
"attacker": data.attacker, | |||||
"attackerOwner": data.attackerOwner, | |||||
"origin": Vector2D.from3D(data.position), | |||||
"radius": data.splash.radius, | |||||
"shape": data.splash.shape, | |||||
"direction": data.direction, | |||||
"friendlyFire": data.splash.friendlyFire | |||||
}); | |||||
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(); | |||||
Attacking.HandleAttackEffects(target, data); | |||||
}; | |||||
Engine.RegisterSystemComponentType(IID_DelayedDamage, "DelayedDamage", DelayedDamage); | Engine.RegisterSystemComponentType(IID_DelayedDamage, "DelayedDamage", DelayedDamage); |
Wildfire Games · Phabricator
Not needed anymore, since rP14231.