Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/DeathDamage.js
Show All 25 Lines | "<a:example>" + | ||||
"<FriendlyFire>false</FriendlyFire>" + | "<FriendlyFire>false</FriendlyFire>" + | ||||
"<Damage>" + | "<Damage>" + | ||||
"<Hack>0.0</Hack>" + | "<Hack>0.0</Hack>" + | ||||
"<Pierce>10.0</Pierce>" + | "<Pierce>10.0</Pierce>" + | ||||
"<Crush>50.0</Crush>" + | "<Crush>50.0</Crush>" + | ||||
"</Damage>" + | "</Damage>" + | ||||
"</a:example>" + | "</a:example>" + | ||||
"<element name='Shape' a:help='Shape of the splash damage, can be circular'><text/></element>" + | "<element name='Shape' a:help='Shape of the splash damage, can be circular'><text/></element>" + | ||||
"<optional>" + | |||||
"<element name='MinRange' a:help='Inner size of the area not affected by the splash.'><ref name='nonNegativeDecimal'/></element>" + | |||||
"</optional>" + | |||||
"<element name='Range' a:help='Size of the area affected by the splash'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Range' a:help='Size of the area affected by the splash'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<element name='FriendlyFire' a:help='Whether the splash damage can hurt non enemy units'><data type='boolean'/></element>" + | "<element name='FriendlyFire' a:help='Whether the splash damage can hurt non enemy units'><data type='boolean'/></element>" + | ||||
Attacking.BuildAttackEffectsSchema(); | Attacking.BuildAttackEffectsSchema(); | ||||
DeathDamage.prototype.Init = function() | DeathDamage.prototype.Init = function() | ||||
{ | { | ||||
}; | }; | ||||
Show All 11 Lines | 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 == INVALID_PLAYER) | if (owner == INVALID_PLAYER) | ||||
warn("Unit causing death damage does not have any owner."); | warn("Unit causing death damage does not have any owner."); | ||||
let radius = ApplyValueModificationsToEntity("DeathDamage/Range", +this.template.Range, this.entity); | let minRange = ApplyValueModificationsToEntity("DeathDamage/MinRange", +(this.template.MinRange || 0), this.entity); | ||||
let maxRange = ApplyValueModificationsToEntity("DeathDamage/Range", +this.template.Range, this.entity); | |||||
Attacking.CauseDamageOverArea({ | Attacking.CauseDamageOverArea({ | ||||
"type": "Death", | "type": "Death", | ||||
"attackData": this.GetDeathDamageEffects(), | "attackData": this.GetDeathDamageEffects(), | ||||
"attacker": this.entity, | "attacker": this.entity, | ||||
"attackerOwner": owner, | "attackerOwner": owner, | ||||
"origin": pos, | "origin": pos, | ||||
"radius": radius, | "minRange": minRange, | ||||
"maxRange": maxRange, | |||||
"shape": this.template.Shape, | "shape": this.template.Shape, | ||||
"friendlyFire": this.template.FriendlyFire == "true", | "friendlyFire": this.template.FriendlyFire == "true", | ||||
}); | }); | ||||
}; | }; | ||||
Engine.RegisterComponentType(IID_DeathDamage, "DeathDamage", DeathDamage); | Engine.RegisterComponentType(IID_DeathDamage, "DeathDamage", DeathDamage); |
Wildfire Games · Phabricator