Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/Attacking.js
Show All 14 Lines | const DirectEffectsSchema = | ||||
"<element name='Capture' a:help='Capture points value'>" + | "<element name='Capture' a:help='Capture points value'>" + | ||||
"<ref name='nonNegativeDecimal'/>" + | "<ref name='nonNegativeDecimal'/>" + | ||||
"</element>"; | "</element>"; | ||||
const StatusEffectsSchema = | const StatusEffectsSchema = | ||||
"<element name='ApplyStatus' a:help='Effects like poisoning or burning a unit.'>" + | "<element name='ApplyStatus' a:help='Effects like poisoning or burning a unit.'>" + | ||||
"<oneOrMore>" + | "<oneOrMore>" + | ||||
"<element>" + | "<element>" + | ||||
"<anyName/>" + | "<anyName/>" + | ||||
wraitii: You might add that it must match a JSON file's name. | |||||
"<interleave>" + | "<interleave>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='StatusName'><text/></element>" + | "<element name='StatusName'><text/></element>" + | ||||
Not Done Inline ActionsDidn't test, but I expect these strings not being required to pass through the guiinterface anymore, which is nice. Piping translatable strings through guiinterface can be argued to be bad (elexis), and when not really needed (as here) beter avoided. refs D2995. They probably also don't need to be loaded in the Templates.js bb: Didn't test, but I expect these strings not being required to pass through the guiinterface… | |||||
"</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='ApplierTooltip' a:help='The tooltip shown on the entity giving the effect, e.g. the attacker.'><text/></element>" + | "<element name='ApplierTooltip' a:help='The tooltip shown on the entity giving the effect, e.g. the attacker.'><text/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<optional>" + | "<optional>" + | ||||
▲ Show 20 Lines • Show All 156 Lines • ▼ Show 20 Lines | Attacking.prototype.GetTotalAttackEffects = function(target, effectData, effectType, bonusMultiplier, cmpResistance) | ||||
{ | { | ||||
total = effectData.Capture * Math.pow(0.9, resistanceStrengths.Capture || 0); | total = effectData.Capture * Math.pow(0.9, resistanceStrengths.Capture || 0); | ||||
// If Health is lower we are more susceptible to capture attacks. | // If Health is lower we are more susceptible to capture attacks. | ||||
let cmpHealth = Engine.QueryInterface(target, IID_Health); | let cmpHealth = Engine.QueryInterface(target, IID_Health); | ||||
if (cmpHealth) | if (cmpHealth) | ||||
total /= 0.1 + 0.9 * cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints(); | total /= 0.1 + 0.9 * cmpHealth.GetHitpoints() / cmpHealth.GetMaxHitpoints(); | ||||
} | } | ||||
else if (effectType == "ApplyStatus") | else if (effectType == "ApplyStatus") | ||||
Done Inline ActionsOne could argue it is more esthetic to have an early return bb: One could argue it is more esthetic to have an early return | |||||
Done Inline ActionsOr not ^^' Freagarach: Or not ^^' | |||||
{ | |||||
if (!resistanceStrengths.ApplyStatus) | |||||
return effectData[effectType]; | return effectData[effectType]; | ||||
let result = {}; | |||||
for (let statusEffect in effectData[effectType]) | |||||
{ | |||||
if (!resistanceStrengths.ApplyStatus[statusEffect]) | |||||
{ | |||||
result[statusEffect] = effectData[effectType][statusEffect]; | |||||
continue; | |||||
} | |||||
if (randBool(resistanceStrengths.ApplyStatus[statusEffect].blockChance)) | |||||
continue; | |||||
result[statusEffect] = effectData[effectType][statusEffect]; | |||||
if (effectData[effectType][statusEffect].Duration) | |||||
result[statusEffect].Duration = effectData[effectType][statusEffect].Duration * resistanceStrengths.ApplyStatus[statusEffect].duration; | |||||
} | |||||
return result; | |||||
} | |||||
return total * bonusMultiplier; | return total * bonusMultiplier; | ||||
}; | }; | ||||
/** | /** | ||||
* Gives the position of the given entity, taking the lateness into account. | * Gives the position of the given entity, taking the lateness into account. | ||||
* @param {number} ent - Entity id of the entity we are finding the location for. | * @param {number} ent - Entity id of the entity we are finding the location for. | ||||
* @param {number} lateness - The time passed since the expected time to fire the function. | * @param {number} lateness - The time passed since the expected time to fire the function. | ||||
* @return {Vector3D} The location of the entity. | * @return {Vector3D} The location of the entity. | ||||
▲ Show 20 Lines • Show All 240 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
You might add that it must match a JSON file's name.