From add6eb9c95bcb4fea5cdb1e797cb5e78a57c3770 Mon Sep 17 00:00:00 2001 From: unknown Date: Sat, 16 Oct 2021 21:40:41 +0200 Subject: [PATCH] Fix particles and magnitudes for (damage) over time effects --- apps/openmw/mwmechanics/spelleffects.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/openmw/mwmechanics/spelleffects.cpp b/apps/openmw/mwmechanics/spelleffects.cpp index bc84a1df5e..0e67f06ba2 100644 --- a/apps/openmw/mwmechanics/spelleffects.cpp +++ b/apps/openmw/mwmechanics/spelleffects.cpp @@ -806,6 +806,7 @@ bool applyMagicEffect(const MWWorld::Ptr& target, const MWWorld::Ptr& caster, Ac } if(effect.mMagnitude == 0) { + effect.mMagnitude = oldMagnitude; effect.mFlags |= ESM::ActiveEffect::Flag_Applied | ESM::ActiveEffect::Flag_Remove; effect.mTimeLeft -= dt; return false; @@ -1027,15 +1028,15 @@ void onMagicEffectRemoved(const MWWorld::Ptr& target, ActiveSpells::ActiveSpellP { if(!(effect.mFlags & ESM::ActiveEffect::Flag_Applied)) return; - const auto world = MWBase::Environment::get().getWorld(); auto& magnitudes = target.getClass().getCreatureStats(target).getMagicEffects(); - const auto* magicEffect = world->getStore().get().find(effect.mEffectId); - if(magicEffect->mData.mFlags & ESM::MagicEffect::Flags::AppliedOnce) - magnitudes.add(EffectKey(effect.mEffectId, effect.mArg), EffectParam(-effect.mMagnitude)); + magnitudes.add(EffectKey(effect.mEffectId, effect.mArg), EffectParam(-effect.mMagnitude)); removeMagicEffect(target, spellParams, effect); - auto anim = world->getAnimation(target); - if(anim) - anim->removeEffect(effect.mEffectId); + if(magnitudes.get(effect.mEffectId).getMagnitude() <= 0.f) + { + auto anim = MWBase::Environment::get().getWorld()->getAnimation(target); + if(anim) + anim->removeEffect(effect.mEffectId); + } } }