Changeset View
Standalone View
binaries/data/mods/public/simulation/helpers/Attacking.js
/** | /** | ||||
* Provides attack and damage-related helpers under the Attacking umbrella (to avoid name ambiguity with the component). | * Provides attack and damage-related helpers under the Attacking umbrella (to avoid name ambiguity with the component). | ||||
*/ | */ | ||||
function Attacking() {} | function Attacking() {} | ||||
/** | /** | ||||
Silier: Defines how this status ..., currently it starts like question :)
\"Ignore\" means, that… | |||||
Done Inline ActionsAuras can be stackable too; how is it done there? Nescio: Auras can be stackable too; how is it done there?
Also, you can use proper opening and closing… | |||||
Done Inline Actionsthats defined in json so not documented in component or elsewhere Silier: thats defined in json so not documented in component or elsewhere | |||||
Done Inline ActionsIs this string something that shows up in game and is translated? Nescio: Is this string something that shows up in game and is translated? | |||||
Done Inline Actionsno, this is just for dev documentation, maybe some ide would show that, dont know Silier: no, this is just for dev documentation, maybe some ide would show that, dont know | |||||
Done Inline ActionsThen the exact formulation isn't terribly important. For comparison, simulation/components/Market.js has line 4: "<element name='TradeType' a:help='Specifies the type of possible trade route (land or naval).'>" + Is there a default choice? Is this element optional? Nescio: Then the exact formulation isn't terribly important. For comparison… | |||||
Done Inline ActionsTrue/False is not really an options, since there are four, mutually exclusive, choices. Freagarach: True/False is not really an options, since there are four, mutually exclusive, choices. | |||||
Done Inline ActionsFor comparison. Nescio: For comparison.
(Also full stop is missing.) | |||||
* 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. | ||||
* Attacks may also have a "Bonuses" element. | * Attacks may also have a "Bonuses" element. | ||||
* | * | ||||
* @return {string} - RelaxNG schema string | * @return {string} - RelaxNG schema string | ||||
*/ | */ | ||||
const DamageSchema = "" + | const DamageSchema = "" + | ||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||
▲ Show 20 Lines • Show All 66 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.GiveStatus) | if (template.GiveStatus) | ||||
ret.GiveStatus = template.GiveStatus; | { | ||||
for (let effect in template.GiveStatus) | |||||
{ | |||||
ret.GiveStatus[effect] = { | |||||
"Duration": ApplyValueModificationsToEntity(valueModifRoot + "/GiveStatus/" + effect + "/", +(template.GiveStatus[effect].Duration || 0), entity), | |||||
"Interval": ApplyValueModificationsToEntity(valueModifRoot + "/GiveStatus/" + effect + "/", +(template.GiveStatus[effect].Interval || 1000), entity) | |||||
}; | |||||
Object.assign(ret.GiveStatus[effect], this.GetAttackEffectsData(valueModifRoot + "/GiveStatus" + effect, template.GiveStatus[effect], entity)); | |||||
if (template.GiveStatus[effect].Modifiers) | |||||
Done Inline Actions1000 looks here like random number, StatusEffectReceiver has DefaultInterval property, that one should be used else this need to be kept in sync with it what is not good also, does this mean that Interval will always exist ? making // With neither an interval nor a duration, there is no point in starting a timer. if (!status.Duration && !status.Interval) return; and // We want an interval to update the GUI to show how much time of the status effect // is left even if the status effect itself has no interval. if (!status.Interval) status._interval = this.DefaultInterval; useless ? Silier: 1000 looks here like random number, StatusEffectReceiver has DefaultInterval property, that one… | |||||
{ | |||||
ret.GiveStatus[effect].Modifiers = {}; | |||||
for (let modifier in template.GiveStatus[effect].Modifiers) | |||||
{ | |||||
ret.GiveStatus[effect].Modifiers[modifier] = { | |||||
"Paths": template.GiveStatus[effect].Modifiers[modifier].Paths, | |||||
"Affects": template.GiveStatus[effect].Modifiers[modifier].Affects | |||||
Done Inline Actionslet someVariable = template.ApplyStatus[effect].Modifiers[modifier] and use it in next lines so it become a bit cleaner or try to for of Silier: let someVariable = template.ApplyStatus[effect].Modifiers[modifier] and use it in next lines so… | |||||
}; | |||||
if (template.GiveStatus[effect].Modifiers[modifier].Add) | |||||
ret.GiveStatus[effect].Modifiers[modifier].Add = ApplyValueModificationsToEntity(valueModifRoot + "/GiveStatus" + effect + "/Modifiers/" + modifier + "/Add", +(template.GiveStatus[effect].Modifiers[modifier].Add || 0), entity); | |||||
if (template.GiveStatus[effect].Modifiers[modifier].Multiply) | |||||
ret.GiveStatus[effect].Modifiers[modifier].Multiply = ApplyValueModificationsToEntity(valueModifRoot + "/GiveStatus" + effect + "/Modifiers/" + modifier + "/Multiply", +(template.GiveStatus[effect].Modifiers[modifier].Multiply || 0), entity); | |||||
if (template.GiveStatus[effect].Modifiers[modifier].Replace) | |||||
ret.GiveStatus[effect].Modifiers[modifier].Replace = template.GiveStatus[effect].Modifiers[modifier].Replace; | |||||
Done Inline Actionswhat if Add == 0 and author wants to increase it later with techs ? Silier: what if Add == 0 and author wants to increase it later with techs ? | |||||
} | |||||
Done Inline Actions|| 0 is not needed because if check above, so if here, that do exist Silier: `|| 0` is not needed because if check above, so if here, that do exist | |||||
Done Inline Actionscorrectly should be 1 to make it mathematicly neutral Silier: correctly should be 1 to make it mathematicly neutral | |||||
} | |||||
} | |||||
Done Inline Actionssame Silier: same | |||||
} | |||||
if (template.Bonuses) | if (template.Bonuses) | ||||
ret.Bonuses = template.Bonuses; | ret.Bonuses = template.Bonuses; | ||||
Done Inline ActionsThat modifier-only bit seems like it should be moved elsewhere wraitii: That modifier-only bit seems like it should be moved elsewhere | |||||
return ret; | return ret; | ||||
}; | }; | ||||
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) : {}; | ||||
▲ Show 20 Lines • Show All 214 Lines • Show Last 20 Lines |
Defines how this status ..., currently it starts like question :)
\"Ignore\" means, that nothing happens (and so on)
@Nescio thoughts ?