Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/binaries/data/mods/public/simulation/helpers/Attacking.js
Show All 26 Lines | "<oneOrMore>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='StatusName'><text/></element>" + | "<element name='StatusName'><text/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Icon' a:help='Icon for the status effect.'><text/></element>" + | "<element name='Icon' a:help='Icon for the status effect.'><text/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='StatusTooltip'><text/></element>" + | "<element name='ApplierTooltip' a:help='The tooltip shown on the entity giving the effect, e.g. the attacker.'><text/></element>" + | ||||
"</optional>" + | |||||
"<optional>" + | |||||
"<element name='ReceiverTooltip' a:help='The tooltip shown on the affected entity while the effect occurs.'><text/></element>" + | |||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Duration' a:help='The duration of the status while the effect occurs.'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Duration' a:help='The duration of the status while the effect occurs.'><ref name='nonNegativeDecimal'/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<element name='Interval' a:help='Interval between the occurances of the effect.'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Interval' a:help='Interval between the occurances of the effect.'><ref name='nonNegativeDecimal'/></element>" + | ||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||
"<choice>" + | "<choice>" + | ||||
DirectEffectsSchema + | DirectEffectsSchema + | ||||
"</choice>" + | "</choice>" + | ||||
"</oneOrMore>" + | "</oneOrMore>" + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
ModificationsSchema + | ModificationsSchema + | ||||
"</optional>" + | "</optional>" + | ||||
"<element name='Stackability' a:help='Defines how this status effect stacks, i.e. how subsequent status effects of the same kind are handled. Choices are: “Ignore”, which means a new one is ignored, “Extend”, which means the duration of a new one is added to the already active status effect, “Replace”, which means the currently active status effect is removed and the new one is put in place and “Stack”, which means that the status effect can be added multiple times.'>" + | |||||
"<choice>" + | |||||
"<value>Ignore</value>" + | |||||
"<value>Extend</value>" + | |||||
"<value>Replace</value>" + | |||||
"<value>Stack</value>" + | |||||
"</choice>" + | |||||
"</element>" + | |||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</oneOrMore>" + | "</oneOrMore>" + | ||||
"</element>"; | "</element>"; | ||||
/** | /** | ||||
* Builds a RelaxRNG schema of possible attack effects. | * Builds a RelaxRNG schema of possible attack effects. | ||||
* See globalscripts/AttackEffects.js for possible elements. | * See globalscripts/AttackEffects.js for possible elements. | ||||
▲ Show 20 Lines • Show All 42 Lines • ▼ Show 20 Lines | let applyMods = damageType => | ||||
ApplyValueModificationsToEntity(valueModifRoot + "/Damage/" + damageType, +(template.Damage[damageType] || 0), entity); | ApplyValueModificationsToEntity(valueModifRoot + "/Damage/" + damageType, +(template.Damage[damageType] || 0), entity); | ||||
for (let damageType in template.Damage) | for (let damageType in template.Damage) | ||||
ret.Damage[damageType] = applyMods(damageType); | ret.Damage[damageType] = applyMods(damageType); | ||||
} | } | ||||
if (template.Capture) | if (template.Capture) | ||||
ret.Capture = ApplyValueModificationsToEntity(valueModifRoot + "/Capture", +(template.Capture || 0), entity); | ret.Capture = ApplyValueModificationsToEntity(valueModifRoot + "/Capture", +(template.Capture || 0), entity); | ||||
if (template.ApplyStatus) | if (template.ApplyStatus) | ||||
ret.ApplyStatus = template.ApplyStatus; | ret.ApplyStatus = this.GetStatusEffectsData(valueModifRoot, template.ApplyStatus, entity); | ||||
if (template.Bonuses) | if (template.Bonuses) | ||||
ret.Bonuses = template.Bonuses; | ret.Bonuses = template.Bonuses; | ||||
return ret; | return ret; | ||||
}; | }; | ||||
Attacking.prototype.GetStatusEffectsData = function(valueModifRoot, template, entity) | |||||
{ | |||||
let result = {}; | |||||
for (let effect in template) | |||||
{ | |||||
let statusTemplate = template[effect]; | |||||
result[effect] = { | |||||
"StatusName": statusTemplate.StatusName, | |||||
"ApplierTooltip": statusTemplate.ApplierTooltip, | |||||
"ReceiverTooltip": statusTemplate.ReceiverTooltip, | |||||
"Duration": ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Duration", +(statusTemplate.Duration || 0), entity), | |||||
"Interval": ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Interval", +(statusTemplate.Interval || 0), entity), | |||||
"Stackability": statusTemplate.Stackability | |||||
}; | |||||
Object.assign(result[effect], this.GetAttackEffectsData(valueModifRoot + "/ApplyStatus" + effect, statusTemplate, entity)); | |||||
if (statusTemplate.Modifiers) | |||||
result[effect].Modifiers = this.GetStatusEffectsModifications(valueModifRoot, statusTemplate.Modifiers, entity, effect); | |||||
} | |||||
return result; | |||||
}; | |||||
Attacking.prototype.GetStatusEffectsModifications = function(valueModifRoot, template, entity, effect) | |||||
{ | |||||
let modifiers = {}; | |||||
for (let modifier in template) | |||||
{ | |||||
let modifierTemplate = template[modifier]; | |||||
modifiers[modifier] = { | |||||
"Paths": modifierTemplate.Paths, | |||||
"Affects": modifierTemplate.Affects | |||||
}; | |||||
if (modifierTemplate.Add !== undefined) | |||||
modifiers[modifier].Add = ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Modifiers/" + modifier + "/Add", +modifierTemplate.Add, entity); | |||||
if (modifierTemplate.Multiply !== undefined) | |||||
modifiers[modifier].Multiply = ApplyValueModificationsToEntity(valueModifRoot + "/ApplyStatus/" + effect + "/Modifiers/" + modifier + "/Multiply", +modifierTemplate.Multiply, entity); | |||||
if (modifierTemplate.Replace !== undefined) | |||||
modifiers[modifier].Replace = modifierTemplate.Replace; | |||||
} | |||||
return modifiers; | |||||
}; | |||||
Attacking.prototype.GetTotalAttackEffects = function(effectData, effectType, cmpResistance) | Attacking.prototype.GetTotalAttackEffects = function(effectData, effectType, cmpResistance) | ||||
{ | { | ||||
let total = 0; | let total = 0; | ||||
let armourStrengths = cmpResistance ? cmpResistance.GetArmourStrengths(effectType) : {}; | let armourStrengths = cmpResistance ? cmpResistance.GetArmourStrengths(effectType) : {}; | ||||
for (let type in effectData) | for (let type in effectData) | ||||
total += effectData[type] * Math.pow(0.9, armourStrengths[type] || 0); | total += effectData[type] * Math.pow(0.9, armourStrengths[type] || 0); | ||||
▲ Show 20 Lines • Show All 219 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator