knocked out characters wait some time before getting up

pull/331/head
rexelion 7 years ago
parent 5e69f6033f
commit 5b8610b34b

@ -248,12 +248,15 @@ void CharacterController::refreshHitRecoilAnims()
bool knockdown = mPtr.getClass().getCreatureStats(mPtr).getKnockedDown(); bool knockdown = mPtr.getClass().getCreatureStats(mPtr).getKnockedDown();
bool block = mPtr.getClass().getCreatureStats(mPtr).getBlock(); bool block = mPtr.getClass().getCreatureStats(mPtr).getBlock();
bool isSwimming = MWBase::Environment::get().getWorld()->isSwimming(mPtr); bool isSwimming = MWBase::Environment::get().getWorld()->isSwimming(mPtr);
MWWorld::TimeStamp currentTime = MWBase::Environment::get().getWorld()->getTimeStamp();
float timeScale = MWBase::Environment::get().getWorld()->getTimeScaleFactor();
if(mHitState == CharState_None) if(mHitState == CharState_None)
{ {
if ((mPtr.getClass().getCreatureStats(mPtr).getFatigue().getCurrent() < 0 if ((mPtr.getClass().getCreatureStats(mPtr).getFatigue().getCurrent() < 0
|| mPtr.getClass().getCreatureStats(mPtr).getFatigue().getBase() == 0) || mPtr.getClass().getCreatureStats(mPtr).getFatigue().getBase() == 0)
&& mAnimation->hasAnimation("knockout")) && mAnimation->hasAnimation("knockout"))
{ {
mKnockoutTime = MWBase::Environment::get().getWorld()->getTimeStamp();
if (isSwimming && mAnimation->hasAnimation("swimknockout")) if (isSwimming && mAnimation->hasAnimation("swimknockout"))
{ {
mHitState = CharState_SwimKnockOut; mHitState = CharState_SwimKnockOut;
@ -338,7 +341,8 @@ void CharacterController::refreshHitRecoilAnims()
mPtr.getClass().getCreatureStats(mPtr).setBlock(false); mPtr.getClass().getCreatureStats(mPtr).setBlock(false);
mHitState = CharState_None; mHitState = CharState_None;
} }
else if (isKnockedOut() && mPtr.getClass().getCreatureStats(mPtr).getFatigue().getCurrent() > 0) else if (isKnockedOut() && mPtr.getClass().getCreatureStats(mPtr).getFatigue().getCurrent() > 0
&& (currentTime - mKnockoutTime) > 3*timeScale/3600) //Wait 3 seconds before getting up
{ {
mHitState = isSwimming ? CharState_SwimKnockDown : CharState_KnockDown; mHitState = isSwimming ? CharState_SwimKnockDown : CharState_KnockDown;
mAnimation->disable(mCurrentHit); mAnimation->disable(mCurrentHit);

@ -7,6 +7,7 @@
#include "../mwworld/ptr.hpp" #include "../mwworld/ptr.hpp"
#include "../mwworld/containerstore.hpp" #include "../mwworld/containerstore.hpp"
#include "../mwworld/timestamp.hpp"
#include "../mwrender/animation.hpp" #include "../mwrender/animation.hpp"
@ -196,6 +197,8 @@ class CharacterController : public MWRender::Animation::TextKeyListener
float mSecondsOfSwimming; float mSecondsOfSwimming;
float mSecondsOfRunning; float mSecondsOfRunning;
MWWorld::TimeStamp mKnockoutTime;
MWWorld::ConstPtr mHeadTrackTarget; MWWorld::ConstPtr mHeadTrackTarget;
float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning float mTurnAnimationThreshold; // how long to continue playing turning animation after actor stopped turning

Loading…
Cancel
Save