Changeset View
Changeset View
Standalone View
Standalone View
binaries/data/mods/public/simulation/helpers/Attacking.js
Show First 20 Lines • Show All 68 Lines • ▼ Show 20 Lines | Attacking.prototype.BuildAttackEffectsSchema = function() | ||||
"</oneOrMore>" + | "</oneOrMore>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Bonuses'>" + | "<element name='Bonuses'>" + | ||||
"<zeroOrMore>" + | "<zeroOrMore>" + | ||||
"<element>" + | "<element>" + | ||||
"<anyName/>" + | "<anyName/>" + | ||||
"<interleave>" + | "<interleave>" + | ||||
"<optional>" + | "<optional>" + | ||||
"<element name='Civ' a:help='If an entity has this civ then the bonus is applied'><text/></element>" + | "<element name='Civ' a:help='The bonus is only applied if the target has this civ.'><text/></element>" + | ||||
"</optional>" + | "</optional>" + | ||||
"<element name='Classes' a:help='If an entity has all these classes then the bonus is applied'><text/></element>" + | "<element name='Classes' a:help='The bonus is only applied if the target has this class.'><text/></element>" + | ||||
"<element name='Multiplier' a:help='The effect strength is multiplied by this'><ref name='nonNegativeDecimal'/></element>" + | "<element name='Multiplier' a:help='The effect strength is multiplied by this.'><ref name='nonNegativeDecimal'/></element>" + | ||||
"</interleave>" + | "</interleave>" + | ||||
"</element>" + | "</element>" + | ||||
"</zeroOrMore>" + | "</zeroOrMore>" + | ||||
"</element>" + | "</element>" + | ||||
"</optional>"; | "</optional>"; | ||||
}; | }; | ||||
/** | /** | ||||
▲ Show 20 Lines • Show All 73 Lines • ▼ Show 20 Lines | |||||
* @return {number} - The total value of the effect. | * @return {number} - The total value of the effect. | ||||
*/ | */ | ||||
Attacking.prototype.GetTotalAttackEffects = function(target, effectData, effectType, bonusMultiplier, cmpResistance) | Attacking.prototype.GetTotalAttackEffects = function(target, effectData, effectType, bonusMultiplier, cmpResistance) | ||||
{ | { | ||||
let total = 0; | let total = 0; | ||||
if (!cmpResistance) | if (!cmpResistance) | ||||
cmpResistance = Engine.QueryInterface(target, IID_Resistance); | cmpResistance = Engine.QueryInterface(target, IID_Resistance); | ||||
let resistanceStrengths = cmpResistance ? cmpResistance.GetEffectiveResistanceAgainst(effectType) : {}; | let resistanceStrengths = cmpResistance ? cmpResistance.GetEffectiveResistance() : {}; | ||||
if (effectType == "Damage") | if (effectType == "Damage" && effectData.Damage) | ||||
for (let type in effectData.Damage) | for (let type in effectData.Damage) | ||||
total += effectData.Damage[type] * Math.pow(0.9, resistanceStrengths.Damage ? resistanceStrengths.Damage[type] || 0 : 0); | total += effectData.Damage[type] * Math.pow(0.9, resistanceStrengths.Damage ? resistanceStrengths.Damage[type] || 0 : 0); | ||||
else if (effectType == "Capture") | else if (effectType == "Capture" && effectData.Capture) | ||||
{ | { | ||||
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 = QueryMiragedInterface(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(); | ||||
} | } | ||||
if (effectType != "ApplyStatus") | if (effectType != "ApplyStatus") | ||||
return total * bonusMultiplier; | return total * bonusMultiplier; | ||||
if (!resistanceStrengths.ApplyStatus) | if (!resistanceStrengths.ApplyStatus) | ||||
return effectData[effectType]; | return effectData[effectType]; | ||||
let result = {}; | let result = {}; | ||||
for (let statusEffect in effectData[effectType]) | for (let statusEffect in effectData[effectType]) | ||||
{ | { | ||||
if (!resistanceStrengths.ApplyStatus[statusEffect]) | if (!resistanceStrengths.ApplyStatus[statusEffect]) | ||||
{ | { | ||||
result[statusEffect] = effectData[effectType][statusEffect]; | result[statusEffect] = effectData[effectType][statusEffect]; | ||||
continue; | continue; | ||||
} | } | ||||
if (randBool(resistanceStrengths.ApplyStatus[statusEffect].blockChance)) | if (randBool(resistanceStrengths.ApplyStatus[statusEffect].blockChance)) | ||||
bb: hmm, this is bad... | |||||
wraitiiUnsubmitted Not Done Inline ActionsWhy? wraitii: Why? | |||||
bbAuthorUnsubmitted Done Inline Actionswill OOS when used. We query this function on a client side sometimes bb: will OOS when used. We query this function on a client side sometimes | |||||
continue; | continue; | ||||
result[statusEffect] = effectData[effectType][statusEffect]; | result[statusEffect] = effectData[effectType][statusEffect]; | ||||
if (effectData[effectType][statusEffect].Duration) | if (effectData[effectType][statusEffect].Duration) | ||||
result[statusEffect].Duration = effectData[effectType][statusEffect].Duration * | result[statusEffect].Duration = effectData[effectType][statusEffect].Duration * | ||||
resistanceStrengths.ApplyStatus[statusEffect].duration; | resistanceStrengths.ApplyStatus[statusEffect].duration; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 173 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator
hmm, this is bad...