diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index d2f2d58837..7aac81da31 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -497,6 +497,7 @@ void CharacterController::update(float duration, Movement &movement) { forcestateupdate = (mWeaponType != weaptype); mWeaponType = weaptype; + getWeaponGroup(mWeaponType, mCurrentWeapon); mUpdateWeapon = false; } @@ -524,6 +525,7 @@ void CharacterController::update(float duration, Movement &movement) } mWeaponType = weaptype; + getWeaponGroup(mWeaponType, mCurrentWeapon); if(weapon != inv.end()) { @@ -545,10 +547,8 @@ void CharacterController::update(float duration, Movement &movement) if(isWeapon) weapSpeed = weapon->get()->mBase->mData.mSpeed; - std::string weapgroup; - getWeaponGroup(mWeaponType, weapgroup); float complete; - bool animPlaying = mAnimation->getInfo(weapgroup, &complete); + bool animPlaying = mAnimation->getInfo(mCurrentWeapon, &complete); if(cls.getCreatureStats(mPtr).getAttackingOrSpell()) { @@ -567,27 +567,20 @@ void CharacterController::update(float duration, Movement &movement) else mAttackType = "thrust"; - mAnimation->play(weapgroup, Priority_Weapon, - MWRender::Animation::Group_UpperBody, false, - weapSpeed, mAttackType+" start", mAttackType+" min attack", 0.0f, 0); + mAnimation->play(mCurrentWeapon, Priority_Weapon, + MWRender::Animation::Group_UpperBody, false, + weapSpeed, mAttackType+" start", mAttackType+" min attack", + 0.0f, 0); mUpperBodyState = UpperCharState_StartToMinAttack; } } else if(mUpperBodyState == UpperCharState_MinAttackToMaxAttack) { - if(animPlaying) - { - mAnimation->disable(weapgroup); - mAnimation->play(weapgroup, Priority_Weapon, - MWRender::Animation::Group_UpperBody, false, - weapSpeed, mAttackType+" max attack", mAttackType+" min hit", 1-complete, 0); - } - else - { - mAnimation->play(weapgroup, Priority_Weapon, - MWRender::Animation::Group_UpperBody, false, - weapSpeed, mAttackType+" max attack", mAttackType+" min hit", 0, 0); - } + mAnimation->disable(mCurrentWeapon); + mAnimation->play(mCurrentWeapon, Priority_Weapon, + MWRender::Animation::Group_UpperBody, false, + weapSpeed, mAttackType+" max attack", mAttackType+" min hit", + 1.0f-complete, 0); mUpperBodyState = UpperCharState_MaxAttackToMinHit; } @@ -599,31 +592,34 @@ void CharacterController::update(float duration, Movement &movement) { if(mUpperBodyState == UpperCharState_StartToMinAttack && complete == 1.0f) { - mAnimation->disable(weapgroup); - mAnimation->play(weapgroup, Priority_Weapon, - MWRender::Animation::Group_UpperBody, false, - weapSpeed, mAttackType+" min attack", mAttackType+" max attack",0, 0); + mAnimation->disable(mCurrentWeapon); + mAnimation->play(mCurrentWeapon, Priority_Weapon, + MWRender::Animation::Group_UpperBody, false, + weapSpeed, mAttackType+" min attack", mAttackType+" max attack", + 0.0f, 0); mUpperBodyState = UpperCharState_MinAttackToMaxAttack; } else if(mUpperBodyState == UpperCharState_MaxAttackToMinHit && complete == 1.0f) { - mAnimation->disable(weapgroup); - mAnimation->play(weapgroup, Priority_Weapon, - MWRender::Animation::Group_UpperBody, false, - weapSpeed, mAttackType+" min hit", mAttackType+" hit",0, 0); + mAnimation->disable(mCurrentWeapon); + mAnimation->play(mCurrentWeapon, Priority_Weapon, + MWRender::Animation::Group_UpperBody, false, + weapSpeed, mAttackType+" min hit", mAttackType+" hit", + 0.0f, 0); mUpperBodyState = UpperCharState_MinHitToHit; } else if(mUpperBodyState == UpperCharState_MinHitToHit && complete == 1.0f) { - mAnimation->disable(weapgroup); - mAnimation->play(weapgroup, Priority_Weapon, - MWRender::Animation::Group_UpperBody, false, - weapSpeed, mAttackType+" large follow start", mAttackType+" large follow stop",0, 0); + mAnimation->disable(mCurrentWeapon); + mAnimation->play(mCurrentWeapon, Priority_Weapon, + MWRender::Animation::Group_UpperBody, false, + weapSpeed, mAttackType+" large follow start", mAttackType+" large follow stop", + 0.0f, 0); mUpperBodyState = UpperCharState_LargeFollowStartToLargeFollowStop; } else if(mUpperBodyState == UpperCharState_LargeFollowStartToLargeFollowStop && complete == 1.0f) { - mAnimation->disable(weapgroup); + mAnimation->disable(mCurrentWeapon); mUpperBodyState = UpperCharState_WeapEquiped; } } diff --git a/apps/openmw/mwmechanics/character.hpp b/apps/openmw/mwmechanics/character.hpp index ff9f3aa62f..5ee9f9c21e 100644 --- a/apps/openmw/mwmechanics/character.hpp +++ b/apps/openmw/mwmechanics/character.hpp @@ -132,6 +132,8 @@ class CharacterController UpperBodyCharacterState mUpperBodyState; WeaponType mWeaponType; + std::string mCurrentWeapon; + bool mSkipAnim; // Workaround for playing weapon draw animation and sound when going to new cell