From d72152183f9cd8d4aeba13ab5ae8a720bb645993 Mon Sep 17 00:00:00 2001 From: Capostrophic Date: Sat, 30 May 2020 21:41:25 +0300 Subject: [PATCH] Update spell effects during death animation (#5403) --- CHANGELOG.md | 1 + apps/openmw/mwmechanics/actors.cpp | 7 ++++++- apps/openmw/mwmechanics/spellcasting.cpp | 13 +++++++++---- apps/openmw/mwworld/inventorystore.cpp | 3 ++- 4 files changed, 18 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 85d65526df..62dd1c2db2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ Bug #5370: Opening an unlocked but trapped door uses the key Bug #5397: NPC greeting does not reset if you leave + reenter area Bug #5400: Editor: Verifier checks race of non-skin bodyparts + Bug #5403: Enchantment effect doesn't show on an enemy during death animation Bug #5415: Environment maps in ebony cuirass and HiRez Armors Indoril cuirass don't work Bug #5416: Junk non-node records before the root node are not handled gracefully Bug #5424: Creatures do not headtrack player diff --git a/apps/openmw/mwmechanics/actors.cpp b/apps/openmw/mwmechanics/actors.cpp index 873d5fa7c1..41836c74f0 100644 --- a/apps/openmw/mwmechanics/actors.cpp +++ b/apps/openmw/mwmechanics/actors.cpp @@ -1623,9 +1623,14 @@ namespace MWMechanics iter->first.getClass().getCreatureStats(iter->first).getActiveSpells().update(duration); - // For dead actors we need to remove looping spell particles + // For dead actors we need to update looping spell particles if (iter->first.getClass().getCreatureStats(iter->first).isDead()) + { + // They can be added during the death animation + if (!iter->first.getClass().getCreatureStats(iter->first).isDeathAnimationFinished()) + adjustMagicEffects(iter->first); ctrl->updateContinuousVfx(); + } else { bool cellChanged = world->hasCellChanged(); diff --git a/apps/openmw/mwmechanics/spellcasting.cpp b/apps/openmw/mwmechanics/spellcasting.cpp index 7aec5d4716..9f7108239f 100644 --- a/apps/openmw/mwmechanics/spellcasting.cpp +++ b/apps/openmw/mwmechanics/spellcasting.cpp @@ -60,8 +60,13 @@ namespace MWMechanics void CastSpell::inflict(const MWWorld::Ptr &target, const MWWorld::Ptr &caster, const ESM::EffectList &effects, ESM::RangeType range, bool reflected, bool exploded) { - if (!target.isEmpty() && target.getClass().isActor() && target.getClass().getCreatureStats(target).isDead()) - return; + if (!target.isEmpty() && target.getClass().isActor()) + { + // Early-out for characters that have departed. + const auto& stats = target.getClass().getCreatureStats(target); + if (stats.isDead() && stats.isDeathAnimationFinished()) + return; + } // If none of the effects need to apply, we can early-out bool found = false; @@ -201,9 +206,9 @@ namespace MWMechanics } bool effectAffectsHealth = isHarmful || effectIt->mEffectID == ESM::MagicEffect::RestoreHealth; - if (castByPlayer && target != caster && effectAffectsHealth) + if (castByPlayer && target != caster && !target.getClass().getCreatureStats(target).isDead() && effectAffectsHealth) { - // If player is attempting to cast a harmful spell or is healing someone, show the target's HP bar. + // If player is attempting to cast a harmful spell on or is healing a living target, show the target's HP bar. MWBase::Environment::get().getWindowManager()->setEnemy(target); } diff --git a/apps/openmw/mwworld/inventorystore.cpp b/apps/openmw/mwworld/inventorystore.cpp index d4358532c4..7ef0dd09a7 100644 --- a/apps/openmw/mwworld/inventorystore.cpp +++ b/apps/openmw/mwworld/inventorystore.cpp @@ -572,7 +572,8 @@ void MWWorld::InventoryStore::updateMagicEffects(const Ptr& actor) mMagicEffects = MWMechanics::MagicEffects(); - if (actor.getClass().getCreatureStats(actor).isDead()) + const auto& stats = actor.getClass().getCreatureStats(actor); + if (stats.isDead() && stats.isDeathAnimationFinished()) return; for (TSlots::const_iterator iter (mSlots.begin()); iter!=mSlots.end(); ++iter)