From f4cc5d0399fd4e38ace958d5a6cb6204c730b5d8 Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 25 Aug 2016 21:17:40 +0900 Subject: [PATCH 1/4] Sometimes play 1st-person weapon idle to Stop key --- apps/openmw/mwmechanics/character.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 637c243007..7be10a5810 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -471,6 +471,7 @@ void CharacterController::refreshIdleAnims(const WeaponInfo* weap, CharacterStat if(force || idle != mIdleState) { mIdleState = idle; + size_t numLoops = ~0ul; std::string idle; MWRender::Animation::AnimPriority idlePriority (Priority_Default); @@ -494,14 +495,15 @@ void CharacterController::refreshIdleAnims(const WeaponInfo* weap, CharacterStat idle += weap->shortgroup; if(!mAnimation->hasAnimation(idle)) idle = "idle"; - } + numLoops = 1 + Misc::Rng::rollDice(4); + } } mAnimation->disable(mCurrentIdle); mCurrentIdle = idle; if(!mCurrentIdle.empty()) mAnimation->play(mCurrentIdle, idlePriority, MWRender::Animation::BlendMask_All, false, - 1.0f, "start", "stop", 0.0f, ~0ul, true); + 1.0f, "start", "stop", 0.0f, numLoops, true); } } From 6190ff1f0d405da5a15f8f4a94d76edf496ef5ce Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 25 Aug 2016 21:35:03 +0900 Subject: [PATCH 2/4] Update idle if current idle finishes playing --- apps/openmw/mwmechanics/character.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 7be10a5810..ed590817cb 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -468,7 +468,8 @@ void CharacterController::refreshMovementAnims(const WeaponInfo* weap, Character void CharacterController::refreshIdleAnims(const WeaponInfo* weap, CharacterState idle, bool force) { - if(force || idle != mIdleState) + if(force || idle != mIdleState || + ((idle == mIdleState) && !mAnimation->isPlaying(mCurrentIdle) && mAnimQueue.empty())) { mIdleState = idle; size_t numLoops = ~0ul; From 67bd882bc784dfe258d370535010c38cd0bdeb64 Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 25 Aug 2016 22:19:49 +0900 Subject: [PATCH 3/4] Disable current idle when an action is taken --- apps/openmw/mwmechanics/character.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index ed590817cb..1819c36ce7 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -311,12 +311,15 @@ void CharacterController::refreshHitRecoilAnims() mAnimation->disable(mCurrentHit); mAnimation->play(mCurrentHit, Priority_Knockdown, MWRender::Animation::BlendMask_All, true, 1, "loop stop", "stop", 0.0f, 0); } + if (mHitState != CharState_None) + mIdleState = CharState_None; } void CharacterController::refreshJumpAnims(const WeaponInfo* weap, JumpingState jump, bool force) { if(force || jump != mJumpState) { + mIdleState = CharState_None; bool startAtLoop = (jump == mJumpState); mJumpState = jump; @@ -359,6 +362,7 @@ void CharacterController::refreshMovementAnims(const WeaponInfo* weap, Character { if(force || movement != mMovementState) { + mIdleState = CharState_None; mMovementState = movement; std::string movementAnimName; @@ -1197,6 +1201,7 @@ bool CharacterController::updateWeaponState() bool animPlaying; if(mAttackingOrSpell) { + mIdleState = CharState_None; if(mUpperBodyState == UpperCharState_WeapEquiped && (mHitState == CharState_None || mHitState == CharState_Block)) { MWBase::Environment::get().getWorld()->breakInvisibility(mPtr); From 9e1bfde46f3d7a1363f7fe2fea593ab4531ccdad Mon Sep 17 00:00:00 2001 From: Allofich Date: Thu, 25 Aug 2016 23:42:24 +0900 Subject: [PATCH 4/4] Add comment --- apps/openmw/mwmechanics/character.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/openmw/mwmechanics/character.cpp b/apps/openmw/mwmechanics/character.cpp index 1819c36ce7..38fec4e4f5 100644 --- a/apps/openmw/mwmechanics/character.cpp +++ b/apps/openmw/mwmechanics/character.cpp @@ -500,7 +500,10 @@ void CharacterController::refreshIdleAnims(const WeaponInfo* weap, CharacterStat idle += weap->shortgroup; if(!mAnimation->hasAnimation(idle)) idle = "idle"; - numLoops = 1 + Misc::Rng::rollDice(4); + + // play until the Loop Stop key 2 to 5 times, then play until the Stop key + // this replicates original engine behavior for the "Idle1h" 1st-person animation + numLoops = 1 + Misc::Rng::rollDice(4); } }