1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-03-30 16:20:21 +00:00

Fix spellcasting state getting stuck due to premature attack attempts

This commit is contained in:
Alexei Kotov 2022-07-31 09:00:44 +03:00
parent 79cdc08253
commit 7a6e984e90

View File

@ -1348,7 +1348,7 @@ bool CharacterController::updateWeaponState(CharacterState idle)
return forcestateupdate; return forcestateupdate;
float complete; float complete;
bool animPlaying; bool animPlaying = false;
ESM::WeaponType::Class weapclass = getWeaponType(mWeaponType)->mWeaponClass; ESM::WeaponType::Class weapclass = getWeaponType(mWeaponType)->mWeaponClass;
if(getAttackingOrSpell()) if(getAttackingOrSpell())
{ {
@ -1409,6 +1409,8 @@ bool CharacterController::updateWeaponState(CharacterState idle)
// Enchanted items by default do not use casting animations // Enchanted items by default do not use casting animations
world->castSpell(mPtr); world->castSpell(mPtr);
resetIdle = false; resetIdle = false;
// Spellcasting animation needs to "play" for at least one frame to reset the aiming factor
animPlaying = true;
mUpperBodyState = UpperCharState_CastingSpell; mUpperBodyState = UpperCharState_CastingSpell;
} }
// Play the spellcasting animation/VFX if the spellcasting was successful or failed due to insufficient magicka. // 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(); resetCurrentIdleState();
} }
// Spellcasting animation needs to "play" for at least one frame to reset the aiming factor if (!animPlaying)
animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete) || mUpperBodyState == UpperCharState_CastingSpell; animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete);
if(mUpperBodyState == UpperCharState_MinAttackToMaxAttack && !isKnockedDown()) if(mUpperBodyState == UpperCharState_MinAttackToMaxAttack && !isKnockedDown())
mAttackStrength = complete; mAttackStrength = complete;
} }