1
0
mirror of https://gitlab.com/OpenMW/openmw.git synced 2025-01-26 18:35:20 +00:00

use game time instead of real time

This commit is contained in:
rexelion 2017-11-04 19:37:20 +00:00
parent ab66034ed1
commit 48ec680f23
2 changed files with 13 additions and 8 deletions

View File

@ -20,7 +20,6 @@
#include "character.hpp"
#include <iostream>
#include <random>
#include <components/misc/rng.hpp>
@ -243,6 +242,11 @@ std::string CharacterController::chooseRandomGroup (const std::string& prefix, i
return prefix + toString(roll);
}
void CharacterController::updateKnockoutTimer(float duration)
{
mTimeUntilWake -= duration;
}
void CharacterController::refreshHitRecoilAnims()
{
bool recovery = mPtr.getClass().getCreatureStats(mPtr).getHitRecovery();
@ -255,11 +259,7 @@ void CharacterController::refreshHitRecoilAnims()
|| mPtr.getClass().getCreatureStats(mPtr).getFatigue().getBase() == 0)
&& mAnimation->hasAnimation("knockout"))
{
std::random_device r;
std::mt19937 gen(r());
std::uniform_int_distribution<int> dist(1, 3);
mTimeToWake = time(NULL);
mTimeToWake += dist(gen); // Wake up after 1 to 3 seconds
mTimeUntilWake = Misc::Rng::rollClosedProbability() * 2 + 1; // Wake up after 1 to 3 seconds
if (isSwimming && mAnimation->hasAnimation("swimknockout"))
{
mHitState = CharState_SwimKnockOut;
@ -345,7 +345,7 @@ void CharacterController::refreshHitRecoilAnims()
mHitState = CharState_None;
}
else if (isKnockedOut() && mPtr.getClass().getCreatureStats(mPtr).getFatigue().getCurrent() > 0
&& time(NULL) > mTimeToWake)
&& mTimeUntilWake <= 0)
{
mHitState = isSwimming ? CharState_SwimKnockDown : CharState_KnockDown;
mAnimation->disable(mCurrentHit);
@ -1635,6 +1635,9 @@ void CharacterController::update(float duration)
float speed = 0.f;
updateMagicEffects();
if (isKnockedOut())
updateKnockoutTimer(duration);
bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();

View File

@ -196,7 +196,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener
float mSecondsOfSwimming;
float mSecondsOfRunning;
time_t mTimeToWake;
float mTimeUntilWake;
MWWorld::ConstPtr mHeadTrackTarget;
@ -226,6 +226,8 @@ class CharacterController : public MWRender::Animation::TextKeyListener
void updateMagicEffects();
void updateKnockoutTimer(float duration);
void playDeath(float startpoint, CharacterState death);
CharacterState chooseRandomDeathState() const;
void playRandomDeath(float startpoint = 0.0f);