Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/components/Damage.js
Show First 20 Lines • Show All 107 Lines • ▼ Show 20 Lines | Damage.prototype.MissileHit = function(data, lateness) | ||||
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 | ||||
if (data.isSplash) | if (data.isSplash) | ||||
{ | { | ||||
this.CauseSplashDamage({ | this.CauseDamageOverArea({ | ||||
"attacker": data.attacker, | "attacker": data.attacker, | ||||
"origin": Vector2D.from3D(data.position), | "origin": Vector2D.from3D(data.position), | ||||
"radius": data.radius, | "radius": data.radius, | ||||
"shape": data.shape, | "shape": data.shape, | ||||
"strengths": data.splashStrengths, | "strengths": data.splashStrengths, | ||||
"splashBonus": data.splashBonus, | "splashBonus": data.splashBonus, | ||||
"direction": data.direction, | "direction": data.direction, | ||||
"playersToDamage": this.GetPlayersToDamage(data.attackerOwner, data.friendlyFire), | "playersToDamage": this.GetPlayersToDamage(data.attackerOwner, data.friendlyFire), | ||||
▲ Show 20 Lines • Show All 54 Lines • ▼ Show 20 Lines | |||||
* @param {string} data.shape - The shape of the radius. | * @param {string} data.shape - The shape of the radius. | ||||
* @param {Object} data.strengths - Data of the form { 'hack': number, 'pierce': number, 'crush': number }. | * @param {Object} data.strengths - Data of the form { 'hack': number, 'pierce': number, 'crush': number }. | ||||
* @param {string} data.type - The type of damage. | * @param {string} data.type - The type of damage. | ||||
* @param {number} data.attackerOwner - The player id of the attacker. | * @param {number} data.attackerOwner - The player id of the attacker. | ||||
* @param {Vector3D} [data.direction] - The unit vector defining the direction. Needed for linear splash damage. | * @param {Vector3D} [data.direction] - The unit vector defining the direction. Needed for linear splash damage. | ||||
* @param {Object} data.splashBonus - The attack bonus template from the attacker. | * @param {Object} data.splashBonus - The attack bonus template from the attacker. | ||||
* @param {number[]} data.playersToDamage - The array of player id's to damage. | * @param {number[]} data.playersToDamage - The array of player id's to damage. | ||||
*/ | */ | ||||
Damage.prototype.CauseSplashDamage = function(data) | Damage.prototype.CauseDamageOverArea = function(data) | ||||
{ | { | ||||
// Get nearby entities and define variables | // Get nearby entities and define variables | ||||
let nearEnts = this.EntitiesNearPoint(data.origin, data.radius, data.playersToDamage); | let nearEnts = this.EntitiesNearPoint(data.origin, data.radius, data.playersToDamage); | ||||
let damageMultiplier = 1; | let damageMultiplier = 1; | ||||
// Cycle through all the nearby entities and damage it appropriately based on its distance from the origin. | // Cycle through all the nearby entities and damage it appropriately based on its distance from the origin. | ||||
for (let ent of nearEnts) | for (let ent of nearEnts) | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 117 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator