Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/components/Resistance.js
function Resistance() {} | function Resistance() {} | ||||||||
/** | /** | ||||||||
* Builds a RelaxRNG schema of possible attack effects. | * Builds a RelaxRNG schema of possible attack effects. | ||||||||
* ToDo: Resistance to StatusEffects. | |||||||||
* | * | ||||||||
* @return {string} - RelaxNG schema string. | * @return {string} - RelaxNG schema string. | ||||||||
*/ | */ | ||||||||
Resistance.prototype.BuildResistanceSchema = function() | Resistance.prototype.BuildResistanceSchema = function() | ||||||||
{ | { | ||||||||
return "" + | return "" + | ||||||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||||||
"<choice>" + | "<choice>" + | ||||||||
"<element name='Damage'>" + | "<element name='Damage'>" + | ||||||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||||||
"<element a:help='Resistance against any number of damage types affecting health.'>" + | "<element a:help='Resistance against any number of damage types affecting health.'>" + | ||||||||
"<anyName/>" + | "<anyName/>" + | ||||||||
"<ref name='nonNegativeDecimal'/>" + | "<ref name='nonNegativeDecimal'/>" + | ||||||||
"</element>" + | "</element>" + | ||||||||
"</oneOrMore>" + | "</oneOrMore>" + | ||||||||
"</element>" + | "</element>" + | ||||||||
"<element name='Capture' a:help='Resistance against Capture attacks.'>" + | "<element name='Capture' a:help='Resistance against Capture attacks.'>" + | ||||||||
"<ref name='nonNegativeDecimal'/>" + | "<ref name='nonNegativeDecimal'/>" + | ||||||||
"</element>" + | "</element>" + | ||||||||
"<element name='ApplyStatus' a:help='Resistance against StatusEffects.'>" + | |||||||||
"<oneOrMore>" + | |||||||||
"<element a:help='Resistance against any number of status effects.'>" + | |||||||||
"<anyName/>" + | |||||||||
"<interleave>" + | |||||||||
"<optional>" + | |||||||||
"<element name='Duration' a:help='The reduction in duration of the status. The normal duration time is multiplied by this factor.'>" + | |||||||||
"<ref name='nonNegativeDecimal'/>" + | |||||||||
"</element>" + | |||||||||
"</optional>" + | |||||||||
"<optional>" + | |||||||||
"<element name='BlockChance' a:help='What the chance is of blocking the status. From zero to one.'><ref name='nonNegativeDecimal'/></element>" + | |||||||||
bbUnsubmitted Done Inline Actions
bb: | |||||||||
Done Inline Actions-is Freagarach: -`is` | |||||||||
"</optional>" + | |||||||||
"</interleave>" + | |||||||||
"</element>" + | |||||||||
"</oneOrMore>" + | |||||||||
"</element>" + | |||||||||
"</choice>" + | "</choice>" + | ||||||||
"</oneOrMore>"; | "</oneOrMore>"; | ||||||||
}; | }; | ||||||||
Resistance.prototype.Schema = | Resistance.prototype.Schema = | ||||||||
"<a:help>Controls the damage resistance of the unit.</a:help>" + | "<a:help>Controls the damage resistance of the unit.</a:help>" + | ||||||||
"<a:example>" + | "<a:example>" + | ||||||||
"<Foundation>" + | "<Foundation>" + | ||||||||
▲ Show 20 Lines • Show All 84 Lines • ▼ Show 20 Lines | if (template.Damage) | ||||||||
ret.Damage = {}; | ret.Damage = {}; | ||||||||
for (let damageType in template.Damage) | for (let damageType in template.Damage) | ||||||||
ret.Damage[damageType] = ApplyValueModificationsToEntity("Resistance/" + entityForm + "/Damage/" + damageType, +this.template[entityForm].Damage[damageType], this.entity); | ret.Damage[damageType] = ApplyValueModificationsToEntity("Resistance/" + entityForm + "/Damage/" + damageType, +this.template[entityForm].Damage[damageType], this.entity); | ||||||||
} | } | ||||||||
if (template.Capture) | if (template.Capture) | ||||||||
ret.Capture = ApplyValueModificationsToEntity("Resistance/" + entityForm + "/Capture", +this.template[entityForm].Capture, this.entity); | ret.Capture = ApplyValueModificationsToEntity("Resistance/" + entityForm + "/Capture", +this.template[entityForm].Capture, this.entity); | ||||||||
if (template.ApplyStatus) | |||||||||
{ | |||||||||
ret.ApplyStatus = {}; | |||||||||
for (let effect in template.ApplyStatus) | |||||||||
ret.ApplyStatus[effect] = { | |||||||||
"duration": ApplyValueModificationsToEntity("Resistance/" + entityForm + "/ApplyStatus/" + effect + "/Duration", +(template.ApplyStatus[effect].Duration || 1), this.entity), | |||||||||
"blockChance": ApplyValueModificationsToEntity("Resistance/" + entityForm + "/ApplyStatus/" + effect + "/BlockChance", +(template.ApplyStatus[effect].BlockChance || 0), this.entity) | |||||||||
}; | |||||||||
} | |||||||||
return ret; | return ret; | ||||||||
}; | }; | ||||||||
Engine.RegisterComponentType(IID_Resistance, "Resistance", Resistance); | Engine.RegisterComponentType(IID_Resistance, "Resistance", Resistance); |
Wildfire Games · Phabricator