[Client] Reset player fatigue when being resurrected

This way, players killed by strong hand-to-hand attacks will no longer be forced to lie on the ground when resurrected.
pull/249/merge
David Cernat 8 years ago
parent 75a60a4700
commit 0bed33e39e

@ -188,9 +188,7 @@ void LocalPlayer::updateStatsDynamic(bool forceUpdate)
if (forceUpdate || (statTimer += MWBase::Environment::get().getFrameDuration()) >= timeoutSec)
{
// Update stats when they become 0 or they have changed enough
//
// Also check for an oldHealth of 0 changing to something else for resurrected NPCs
bool shouldUpdateHealth = oldHealth != health && (health.getCurrent() == 0 || oldHealth.getCurrent() == 0 || abs(oldHealth.getCurrent() - health.getCurrent()) > 3);
bool shouldUpdateHealth = oldHealth != health && (health.getCurrent() == 0 || abs(oldHealth.getCurrent() - health.getCurrent()) > 3);
bool shouldUpdateMagicka = false;
bool shouldUpdateFatigue = false;

@ -32,8 +32,18 @@ namespace mwmp
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
playerPtr.getClass().getCreatureStats(playerPtr).resurrect();
// If this player had a weapon or spell readied when dying, they will
// still have it readied but be unable to use it unless we clear it here
// The player could have died from a hand-to-hand attack, so reset their fatigue
// as well
if (player->creatureStats.mDynamic[2].mMod < 1)
player->creatureStats.mDynamic[2].mMod = 1;
player->creatureStats.mDynamic[2].mCurrent = player->creatureStats.mDynamic[2].mMod;
MWMechanics::DynamicStat<float> fatigue;
fatigue.readState(player->creatureStats.mDynamic[2]);
playerPtr.getClass().getCreatureStats(playerPtr).setFatigue(fatigue);
// If this player had a weapon or spell readied when dying, they will still have it
// readied but be unable to use it unless we clear it here
playerPtr.getClass().getNpcStats(playerPtr).setDrawState(MWMechanics::DrawState_Nothing);
packet.setPlayer(player);

Loading…
Cancel
Save