mirror of
https://github.com/TES3MP/openmw-tes3mp.git
synced 2025-01-30 21:15:33 +00:00
use game time instead of real time
This commit is contained in:
parent
ab66034ed1
commit
48ec680f23
2 changed files with 13 additions and 8 deletions
|
@ -20,7 +20,6 @@
|
||||||
#include "character.hpp"
|
#include "character.hpp"
|
||||||
|
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <random>
|
|
||||||
|
|
||||||
#include <components/misc/rng.hpp>
|
#include <components/misc/rng.hpp>
|
||||||
|
|
||||||
|
@ -243,6 +242,11 @@ std::string CharacterController::chooseRandomGroup (const std::string& prefix, i
|
||||||
return prefix + toString(roll);
|
return prefix + toString(roll);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CharacterController::updateKnockoutTimer(float duration)
|
||||||
|
{
|
||||||
|
mTimeUntilWake -= duration;
|
||||||
|
}
|
||||||
|
|
||||||
void CharacterController::refreshHitRecoilAnims()
|
void CharacterController::refreshHitRecoilAnims()
|
||||||
{
|
{
|
||||||
bool recovery = mPtr.getClass().getCreatureStats(mPtr).getHitRecovery();
|
bool recovery = mPtr.getClass().getCreatureStats(mPtr).getHitRecovery();
|
||||||
|
@ -255,11 +259,7 @@ void CharacterController::refreshHitRecoilAnims()
|
||||||
|| mPtr.getClass().getCreatureStats(mPtr).getFatigue().getBase() == 0)
|
|| mPtr.getClass().getCreatureStats(mPtr).getFatigue().getBase() == 0)
|
||||||
&& mAnimation->hasAnimation("knockout"))
|
&& mAnimation->hasAnimation("knockout"))
|
||||||
{
|
{
|
||||||
std::random_device r;
|
mTimeUntilWake = Misc::Rng::rollClosedProbability() * 2 + 1; // Wake up after 1 to 3 seconds
|
||||||
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
|
|
||||||
if (isSwimming && mAnimation->hasAnimation("swimknockout"))
|
if (isSwimming && mAnimation->hasAnimation("swimknockout"))
|
||||||
{
|
{
|
||||||
mHitState = CharState_SwimKnockOut;
|
mHitState = CharState_SwimKnockOut;
|
||||||
|
@ -345,7 +345,7 @@ void CharacterController::refreshHitRecoilAnims()
|
||||||
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
|
||||||
&& time(NULL) > mTimeToWake)
|
&& mTimeUntilWake <= 0)
|
||||||
{
|
{
|
||||||
mHitState = isSwimming ? CharState_SwimKnockDown : CharState_KnockDown;
|
mHitState = isSwimming ? CharState_SwimKnockDown : CharState_KnockDown;
|
||||||
mAnimation->disable(mCurrentHit);
|
mAnimation->disable(mCurrentHit);
|
||||||
|
@ -1636,6 +1636,9 @@ void CharacterController::update(float duration)
|
||||||
|
|
||||||
updateMagicEffects();
|
updateMagicEffects();
|
||||||
|
|
||||||
|
if (isKnockedOut())
|
||||||
|
updateKnockoutTimer(duration);
|
||||||
|
|
||||||
bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
bool godmode = mPtr == MWMechanics::getPlayer() && MWBase::Environment::get().getWorld()->getGodModeState();
|
||||||
|
|
||||||
if(!cls.isActor())
|
if(!cls.isActor())
|
||||||
|
|
|
@ -196,7 +196,7 @@ class CharacterController : public MWRender::Animation::TextKeyListener
|
||||||
float mSecondsOfSwimming;
|
float mSecondsOfSwimming;
|
||||||
float mSecondsOfRunning;
|
float mSecondsOfRunning;
|
||||||
|
|
||||||
time_t mTimeToWake;
|
float mTimeUntilWake;
|
||||||
|
|
||||||
MWWorld::ConstPtr mHeadTrackTarget;
|
MWWorld::ConstPtr mHeadTrackTarget;
|
||||||
|
|
||||||
|
@ -226,6 +226,8 @@ class CharacterController : public MWRender::Animation::TextKeyListener
|
||||||
|
|
||||||
void updateMagicEffects();
|
void updateMagicEffects();
|
||||||
|
|
||||||
|
void updateKnockoutTimer(float duration);
|
||||||
|
|
||||||
void playDeath(float startpoint, CharacterState death);
|
void playDeath(float startpoint, CharacterState death);
|
||||||
CharacterState chooseRandomDeathState() const;
|
CharacterState chooseRandomDeathState() const;
|
||||||
void playRandomDeath(float startpoint = 0.0f);
|
void playRandomDeath(float startpoint = 0.0f);
|
||||||
|
|
Loading…
Reference in a new issue