Extend magic resistance/weakness to all effects that can be resisted (fixes #4309)

0.6.3
Capostrophic 7 years ago committed by Capostrophic
parent 9b8c56761b
commit 2dca389a3b

@ -222,8 +222,6 @@ namespace MWMechanics
magicEffects = effects;
float resisted = 0;
if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful)
{
// Effects with no resistance attribute belonging to them can not be resisted
if (ESM::MagicEffect::getResistanceEffect(effectId) == -1)
return 0.f;
@ -260,7 +258,6 @@ namespace MWMechanics
x = std::min(x + resistance, 100.f);
resisted = x;
}
return resisted;
}
@ -458,13 +455,11 @@ namespace MWMechanics
}
float magnitudeMult = 1;
if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful && target.getClass().isActor())
{
if (absorbed)
continue;
// Try reflecting
if (!reflected && !caster.isEmpty() && caster != target && !(magicEffect->mData.mFlags & ESM::MagicEffect::Unreflectable))
if (!absorbed)
{
// Reflect harmful effects
if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful && !reflected && !caster.isEmpty() && caster != target && !(magicEffect->mData.mFlags & ESM::MagicEffect::Unreflectable))
{
float reflect = target.getClass().getCreatureStats(target).getMagicEffects().get(ESM::MagicEffect::Reflect).getMagnitude();
bool isReflected = (Misc::Rng::roll0to99() < reflect);
@ -488,13 +483,14 @@ namespace MWMechanics
else if (castByPlayer)
MWBase::Environment::get().getWindowManager()->messageBox("#{sMagicTargetResisted}");
}
// If player is attempting to cast a harmful spell, show the target's HP bar
if (castByPlayer && target != caster)
else if (magicEffect->mData.mFlags & ESM::MagicEffect::Harmful && castByPlayer && target != caster)
{
// If player is attempting to cast a harmful spell and it wasn't fully resisted, show the target's HP bar
MWBase::Environment::get().getWindowManager()->setEnemy(target);
}
// Notify the target actor they've been hit
if (target != caster && !caster.isEmpty())
if (target != caster && !caster.isEmpty() && magicEffect->mData.mFlags & ESM::MagicEffect::Harmful)
target.getClass().onHit(target, 0.0f, true, MWWorld::Ptr(), caster, osg::Vec3f(), true);
}

Loading…
Cancel
Save