From 0bed33e39e73a8da22ebd2710bff1b4f02587cef Mon Sep 17 00:00:00 2001 From: David Cernat Date: Fri, 2 Jun 2017 06:58:33 +0300 Subject: [PATCH] [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. --- apps/openmw/mwmp/LocalPlayer.cpp | 4 +--- .../processors/player/ProcessorPlayerResurrect.hpp | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/apps/openmw/mwmp/LocalPlayer.cpp b/apps/openmw/mwmp/LocalPlayer.cpp index 439809554..3878a3f22 100644 --- a/apps/openmw/mwmp/LocalPlayer.cpp +++ b/apps/openmw/mwmp/LocalPlayer.cpp @@ -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; diff --git a/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp b/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp index f19fcebe5..bb490cdc4 100644 --- a/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp +++ b/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp @@ -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 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);