Implement SwimHit animation

This commit is contained in:
Andrei Kortunov 2017-09-22 15:49:42 +04:00
parent 3eb1308c0d
commit 1c6cfad3cc
2 changed files with 22 additions and 4 deletions

View file

@ -283,13 +283,23 @@ void CharacterController::refreshHitRecoilAnims()
} }
else if (recovery) else if (recovery)
{ {
std::string anim = chooseRandomGroup("hit"); std::string anim = isSwimming ? chooseRandomGroup("swimhit") : chooseRandomGroup("hit");
if (mAnimation->hasAnimation(anim)) if (isSwimming && mAnimation->hasAnimation(anim))
{ {
mHitState = CharState_Hit; mHitState = CharState_SwimHit;
mCurrentHit = anim; mCurrentHit = anim;
mAnimation->play(mCurrentHit, Priority_Hit, MWRender::Animation::BlendMask_All, true, 1, "start", "stop", 0.0f, 0); mAnimation->play(mCurrentHit, Priority_Hit, MWRender::Animation::BlendMask_All, true, 1, "start", "stop", 0.0f, 0);
} }
else
{
anim = chooseRandomGroup("hit");
if (mAnimation->hasAnimation(anim))
{
mHitState = CharState_Hit;
mCurrentHit = anim;
mAnimation->play(mCurrentHit, Priority_Hit, MWRender::Animation::BlendMask_All, true, 1, "start", "stop", 0.0f, 0);
}
}
} }
else if (block && mAnimation->hasAnimation("shield")) else if (block && mAnimation->hasAnimation("shield"))
{ {
@ -1157,7 +1167,7 @@ bool CharacterController::updateWeaponState()
mWeaponType > WeapType_HandToHand && mWeaponType < WeapType_Spell; mWeaponType > WeapType_HandToHand && mWeaponType < WeapType_Spell;
if(weaptype != mWeaponType && !isKnockedOut() && if(weaptype != mWeaponType && !isKnockedOut() &&
!isKnockedDown() && mHitState != CharState_Hit) !isKnockedDown() && !isRecovery())
{ {
forcestateupdate = true; forcestateupdate = true;
@ -2267,6 +2277,12 @@ bool CharacterController::isKnockedOut() const
mHitState == CharState_SwimKnockOut; mHitState == CharState_SwimKnockOut;
} }
bool CharacterController::isRecovery() const
{
return mHitState == CharState_Hit ||
mHitState == CharState_SwimHit;
}
bool CharacterController::isAttackingOrSpell() const bool CharacterController::isAttackingOrSpell() const
{ {
return mUpperBodyState != UpperCharState_Nothing && return mUpperBodyState != UpperCharState_Nothing &&

View file

@ -103,6 +103,7 @@ enum CharacterState {
CharState_DeathKnockOut, CharState_DeathKnockOut,
CharState_Hit, CharState_Hit,
CharState_SwimHit,
CharState_KnockDown, CharState_KnockDown,
CharState_KnockOut, CharState_KnockOut,
CharState_SwimKnockDown, CharState_SwimKnockDown,
@ -271,6 +272,7 @@ public:
bool isReadyToBlock() const; bool isReadyToBlock() const;
bool isKnockedDown() const; bool isKnockedDown() const;
bool isKnockedOut() const; bool isKnockedOut() const;
bool isRecovery() const;
bool isSneaking() const; bool isSneaking() const;
bool isRunning() const; bool isRunning() const;
bool isAttackingOrSpell() const; bool isAttackingOrSpell() const;