Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/DelayedDamage.js
Show All 16 Lines | |||||
/** | /** | ||||
* Handles hit logic after the projectile travel time has passed. | * Handles hit logic after the projectile travel time has passed. | ||||
* @param {Object} data - The data sent by the caller. | * @param {Object} data - The data sent by the caller. | ||||
* @param {string} data.type - The type of damage. | * @param {string} data.type - The type of damage. | ||||
* @param {Object} data.attackData - Data of the form { 'effectType': { ...opaque effect data... }, 'Bonuses': {...} }. | * @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.target - The entity id of the target. | ||||
* @param {number} data.attacker - The entity id of the attacker. | * @param {number} data.attacker - The entity id of the attacker. | ||||
* @param {number} data.attackerOwner - The player id of the owner of the attacker. | * @param {number} data.attackerOwner - The player id of the owner of the attacker. | ||||
* @param {Vector2D} data.origin - The origin of the projectile hit. | |||||
* @param {Vector3D} data.position - The expected position of the target. | * @param {Vector3D} data.position - The expected position of the target. | ||||
* @param {number} data.projectileId - The id of the projectile. | * @param {number} data.projectileId - The id of the projectile. | ||||
* @param {Vector3D} data.direction - The unit vector defining the direction. | * @param {Vector3D} data.direction - The unit vector defining the direction. | ||||
* @param {string} data.attackImpactSound - The name of the sound emited on impact. | * @param {string} data.attackImpactSound - The name of the sound emited on impact. | ||||
* @param {boolean} data.friendlyFire - A flag indicating whether allied entities can also be damaged. | * @param {boolean} data.friendlyFire - A flag indicating whether allied entities can also be damaged. | ||||
* ***When splash damage*** | * ***When splash damage*** | ||||
* @param {boolean} data.splash.friendlyFire - A flag indicating if allied entities are also damaged. | * @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 {number} data.splash.radius - The radius of the splash damage. | ||||
▲ Show 20 Lines • Show All 52 Lines • ▼ Show 20 Lines | for (let ent of ents) | ||||
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; | ||||
} | } | ||||
}; | }; | ||||
/** | |||||
* Handles damage caused by immediate 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; | |||||
// Do this first in case the direct hit kills the target | |||||
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 | |||||
}); | |||||
} | |||||
Attacking.HandleAttackEffects(data.type, data.attackData, data.target, data.attacker, data.attackerOwner); | |||||
}; | |||||
Engine.RegisterSystemComponentType(IID_DelayedDamage, "DelayedDamage", DelayedDamage); | Engine.RegisterSystemComponentType(IID_DelayedDamage, "DelayedDamage", DelayedDamage); |
Wildfire Games · Phabricator