1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-16 05:19:55 +00:00
openmw-tes3mp/apps/openmw/mwmp/processors/player/ProcessorPlayerResurrect.hpp

53 lines
1.7 KiB
C++

//
// Created by koncord on 16.04.17.
//
#ifndef OPENMW_PROCESSORPLAYERRESURRECT_HPP
#define OPENMW_PROCESSORPLAYERRESURRECT_HPP
#include "../PlayerProcessor.hpp"
#include "apps/openmw/mwmp/Main.hpp"
#include "apps/openmw/mwmp/Networking.hpp"
namespace mwmp
{
class ProcessorPlayerResurrect : public PlayerProcessor
{
public:
ProcessorPlayerResurrect()
{
BPP_INIT(ID_PLAYER_RESURRECT)
}
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
LOG_MESSAGE_SIMPLE(Log::LOG_INFO, "Received ID_PLAYER_RESURRECT from server");
if (isLocal())
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about me with resurrectType of %i", player->resurrectType);
static_cast<LocalPlayer*>(player)->resurrect();
}
else if (player != 0)
{
LOG_APPEND(Log::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str());
player->creatureStats.mDead = false;
if (player->creatureStats.mDynamic[0].mMod < 1)
player->creatureStats.mDynamic[0].mMod = 1;
player->creatureStats.mDynamic[0].mCurrent = player->creatureStats.mDynamic[0].mMod;
MWWorld::Ptr ptr = static_cast<DedicatedPlayer*>(player)->getPtr();
ptr.getClass().getCreatureStats(ptr).resurrect();
MWMechanics::DynamicStat<float> health;
health.readState(player->creatureStats.mDynamic[0]);
ptr.getClass().getCreatureStats(ptr).setHealth(health);
}
}
};
}
#endif //OPENMW_PROCESSORPLAYERRESURRECT_HPP