Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Damage.js
Show First 20 Lines • Show All 127 Lines • ▼ Show 20 Lines | Damage.prototype.MissileHit = function(data, lateness) | ||||
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 DamageReceiver (not the case for a mirage for example) | // and if the target has DamageReceiver (not the case for a mirage for example) | ||||
let cmpDamageReceiver = Engine.QueryInterface(data.target, IID_DamageReceiver); | let cmpDamageReceiver = Engine.QueryInterface(data.target, IID_DamageReceiver); | ||||
if (cmpDamageReceiver && this.TestCollision(data.target, data.position, lateness)) | if (cmpDamageReceiver && this.TestCollision(data.target, data.position, lateness)) | ||||
{ | { | ||||
data.multiplier = GetDamageBonus(data.target, data.bonus); | data.multiplier = GetDamageBonus(data.target, data.bonus, data.type, data.attacker); | ||||
this.CauseDamage(data); | this.CauseDamage(data); | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
return; | return; | ||||
} | } | ||||
let targetPosition = this.InterpolatedLocation(data.target, lateness); | let targetPosition = this.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.attackerOwner); | ||||
let ents = this.EntitiesNearPoint(Vector2D.from3D(data.position), targetPosition.horizDistanceTo(data.position) * 2, cmpPlayer.GetEnemies()); | let ents = this.EntitiesNearPoint(Vector2D.from3D(data.position), targetPosition.horizDistanceTo(data.position) * 2, cmpPlayer.GetEnemies()); | ||||
for (let ent of ents) | for (let ent of ents) | ||||
{ | { | ||||
if (!this.TestCollision(ent, data.position, lateness)) | if (!this.TestCollision(ent, data.position, lateness)) | ||||
continue; | continue; | ||||
this.CauseDamage({ | this.CauseDamage({ | ||||
"strengths": data.strengths, | "strengths": data.strengths, | ||||
"target": ent, | "target": ent, | ||||
"attacker": data.attacker, | "attacker": data.attacker, | ||||
"multiplier": GetDamageBonus(ent, data.bonus), | "multiplier": GetDamageBonus(ent, data.bonus, data.type, data.attacker), | ||||
"type": data.type, | "type": data.type, | ||||
"attackerOwner": data.attackerOwner | "attackerOwner": data.attackerOwner | ||||
}); | }); | ||||
cmpProjectileManager.RemoveProjectile(data.projectileId); | cmpProjectileManager.RemoveProjectile(data.projectileId); | ||||
break; | break; | ||||
} | } | ||||
}; | }; | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | else if (data.shape == 'Linear') // linear effect with quadratic falloff in two directions (only used for certain missiles) | ||||
damageMultiplier = 0; | damageMultiplier = 0; | ||||
} | } | ||||
else // In case someone calls this function with an invalid shape. | else // In case someone calls this function with an invalid shape. | ||||
{ | { | ||||
warn("The " + data.shape + " splash damage shape is not implemented!"); | warn("The " + data.shape + " splash damage shape is not implemented!"); | ||||
} | } | ||||
if (data.splashBonus) | if (data.splashBonus) | ||||
damageMultiplier *= GetDamageBonus(ent, data.splashBonus); | damageMultiplier *= GetDamageBonus(ent, data.splashBonus, data.type, data.attacker); | ||||
// Call CauseDamage which reduces the hitpoints, posts network command, plays sounds.... | // Call CauseDamage which reduces the hitpoints, posts network command, plays sounds.... | ||||
this.CauseDamage({ | this.CauseDamage({ | ||||
"strengths": data.strengths, | "strengths": data.strengths, | ||||
"target": ent, | "target": ent, | ||||
"attacker": data.attacker, | "attacker": data.attacker, | ||||
"multiplier": damageMultiplier, | "multiplier": damageMultiplier, | ||||
"type": data.type + ".Splash", | "type": data.type + ".Splash", | ||||
▲ Show 20 Lines • Show All 78 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator