Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/DeathDamage.js
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | DeathDamage.prototype.GetDeathDamageStrengths = function(type) | ||||
return { | return { | ||||
"hack": applyMods("Hack"), | "hack": applyMods("Hack"), | ||||
"pierce": applyMods("Pierce"), | "pierce": applyMods("Pierce"), | ||||
"crush": applyMods("Crush") | "crush": applyMods("Crush") | ||||
}; | }; | ||||
}; | }; | ||||
DeathDamage.prototype.GetBonusTemplate = function() | |||||
{ | |||||
if (this.template.Bonuses) | |||||
return clone(this.template.Bonuses); | |||||
return null; | |||||
}; | |||||
DeathDamage.prototype.CauseDeathDamage = function() | DeathDamage.prototype.CauseDeathDamage = function() | ||||
{ | { | ||||
let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | let cmpPosition = Engine.QueryInterface(this.entity, IID_Position); | ||||
if (!cmpPosition || !cmpPosition.IsInWorld()) | if (!cmpPosition || !cmpPosition.IsInWorld()) | ||||
return; | return; | ||||
let pos = cmpPosition.GetPosition2D(); | let pos = cmpPosition.GetPosition2D(); | ||||
let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | let cmpOwnership = Engine.QueryInterface(this.entity, IID_Ownership); | ||||
let owner = cmpOwnership.GetOwner(); | let owner = cmpOwnership.GetOwner(); | ||||
if (owner == -1) | if (owner == -1) | ||||
warn("Unit causing death damage does not have any owner."); | warn("Unit causing death damage does not have any owner."); | ||||
let cmpDamage = Engine.QueryInterface(SYSTEM_ENTITY, IID_Damage); | let cmpDamage = Engine.QueryInterface(SYSTEM_ENTITY, IID_Damage); | ||||
let playersToDamage = cmpDamage.GetPlayersToDamage(owner, this.template.FriendlyFire); | let playersToDamage = cmpDamage.GetPlayersToDamage(owner, this.template.FriendlyFire); | ||||
let radius = ApplyValueModificationsToEntity("DeathDamage/Range", +this.template.Range, this.entity); | let radius = ApplyValueModificationsToEntity("DeathDamage/Range", +this.template.Range, this.entity); | ||||
cmpDamage.CauseSplashDamage({ | cmpDamage.CauseSplashDamage({ | ||||
"attacker": this.entity, | "attacker": this.entity, | ||||
"origin": pos, | "origin": pos, | ||||
"radius": radius, | "radius": radius, | ||||
"shape": this.template.Shape, | "shape": this.template.Shape, | ||||
"strengths": this.GetDeathDamageStrengths("Death"), | "strengths": this.GetDeathDamageStrengths("Death"), | ||||
"splashBonus": this.GetBonusTemplate(), | |||||
"playersToDamage": playersToDamage, | "playersToDamage": playersToDamage, | ||||
"type": "Death", | "type": "Death", | ||||
"attackerOwner": owner | "attackerOwner": owner | ||||
}); | }); | ||||
}; | }; | ||||
Engine.RegisterComponentType(IID_DeathDamage, "DeathDamage", DeathDamage); | Engine.RegisterComponentType(IID_DeathDamage, "DeathDamage", DeathDamage); |
Wildfire Games · Phabricator