Apply elemental shield magnitude to element resistance (Closes #1121)

deque
scrawl 11 years ago
parent 123157b216
commit 20a0040bdb

@ -286,13 +286,7 @@ namespace MWMechanics
if (i == 2)
element = ESM::MagicEffect::FrostDamage;
short resistanceEffect = ESM::MagicEffect::getResistanceEffect(element);
short weaknessEffect = ESM::MagicEffect::getWeaknessEffect(element);
float elementResistance = 0;
if (resistanceEffect != -1)
elementResistance += attackerStats.getMagicEffects().get(resistanceEffect).mMagnitude;
if (weaknessEffect != -1)
elementResistance -= attackerStats.getMagicEffects().get(weaknessEffect).mMagnitude;
float elementResistance = MWMechanics::getEffectResistanceAttribute(element, &attackerStats.getMagicEffects());
x = std::min(100.f, x + elementResistance);

@ -148,6 +148,27 @@ namespace MWMechanics
return school;
}
float getEffectResistanceAttribute (short effectId, const MagicEffects* actorEffects)
{
short resistanceEffect = ESM::MagicEffect::getResistanceEffect(effectId);
short weaknessEffect = ESM::MagicEffect::getWeaknessEffect(effectId);
float resistance = 0;
if (resistanceEffect != -1)
resistance += actorEffects->get(resistanceEffect).mMagnitude;
if (weaknessEffect != -1)
resistance -= actorEffects->get(weaknessEffect).mMagnitude;
if (effectId == ESM::MagicEffect::FireDamage)
resistance += actorEffects->get(ESM::MagicEffect::FireShield).mMagnitude;
if (effectId == ESM::MagicEffect::ShockDamage)
resistance += actorEffects->get(ESM::MagicEffect::LightningShield).mMagnitude;
if (effectId == ESM::MagicEffect::FrostDamage)
resistance += actorEffects->get(ESM::MagicEffect::FrostShield).mMagnitude;
return resistance;
}
float getEffectResistance (short effectId, const MWWorld::Ptr& actor, const MWWorld::Ptr& caster,
const ESM::Spell* spell, const MagicEffects* effects)
{
@ -163,16 +184,7 @@ namespace MWMechanics
float resisted = 0;
if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful)
{
short resistanceEffect = ESM::MagicEffect::getResistanceEffect(effectId);
short weaknessEffect = ESM::MagicEffect::getWeaknessEffect(effectId);
float resistance = 0;
if (resistanceEffect != -1)
resistance += magicEffects->get(resistanceEffect).mMagnitude;
if (weaknessEffect != -1)
resistance -= magicEffects->get(weaknessEffect).mMagnitude;
float resistance = getEffectResistanceAttribute(effectId, magicEffects);
float willpower = stats.getAttribute(ESM::Attribute::Willpower).getModified();
float luck = stats.getAttribute(ESM::Attribute::Luck).getModified();

@ -35,6 +35,11 @@ namespace MWMechanics
int getSpellSchool(const std::string& spellId, const MWWorld::Ptr& actor);
int getSpellSchool(const ESM::Spell* spell, const MWWorld::Ptr& actor);
/// Get the resistance attribute against an effect for a given actor. This will add together
/// ResistX and Weakness to X effects relevant against the given effect.
float getEffectResistanceAttribute (short effectId, const MagicEffects* actorEffects);
/// Get the effective resistance against an effect casted by the given actor in the given spell (optional).
/// @return >=100 for fully resisted. can also return negative value for damage amplification.
/// @param effects Override the actor's current magicEffects. Useful if there are effects currently
/// being applied (but not applied yet) that should also be considered.

Loading…
Cancel
Save