From 7a6e984e904cc611a1f796c897a106d238642f0e Mon Sep 17 00:00:00 2001 From: Alexei Kotov Date: Sun, 31 Jul 2022 09:00:44 +0300 Subject: [PATCH] Fix spellcasting state getting stuck due to premature attack attempts --- apps/openmw/mwmechanics/character.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 3530df4053..4de7dda4ce 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -1348,7 +1348,7 @@ bool CharacterController::updateWeaponState(CharacterState idle) return forcestateupdate; float complete; - bool animPlaying; + bool animPlaying = false; ESM::WeaponType::Class weapclass = getWeaponType(mWeaponType)->mWeaponClass; if(getAttackingOrSpell()) { @@ -1409,6 +1409,8 @@ bool CharacterController::updateWeaponState(CharacterState idle) // Enchanted items by default do not use casting animations world->castSpell(mPtr); resetIdle = false; + // Spellcasting animation needs to "play" for at least one frame to reset the aiming factor + animPlaying = true; mUpperBodyState = UpperCharState_CastingSpell; } // Play the spellcasting animation/VFX if the spellcasting was successful or failed due to insufficient magicka. @@ -1583,8 +1585,8 @@ bool CharacterController::updateWeaponState(CharacterState idle) resetCurrentIdleState(); } - // Spellcasting animation needs to "play" for at least one frame to reset the aiming factor - animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete) || mUpperBodyState == UpperCharState_CastingSpell; + if (!animPlaying) + animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete); if(mUpperBodyState == UpperCharState_MinAttackToMaxAttack && !isKnockedDown()) mAttackStrength = complete; }