[Client] Add die() method to LocalPlayer

pull/593/head
David Cernat 4 years ago
parent cd835104b7
commit ae0e4a929f

@ -831,6 +831,19 @@ void LocalPlayer::removeSpellsActive()
}
}
void LocalPlayer::die()
{
creatureStats.mDead = true;
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::DynamicStat<float> health = playerPtr.getClass().getCreatureStats(playerPtr).getHealth();
health.setCurrent(0);
playerPtr.getClass().getCreatureStats(playerPtr).setHealth(health);
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DEATH)->setPlayer(this);
Main::get().getNetworking()->getPlayerPacket(ID_PLAYER_DEATH)->Send();
}
void LocalPlayer::resurrect()
{
creatureStats.mDead = false;

@ -53,6 +53,7 @@ namespace mwmp
void removeSpells();
void removeSpellsActive();
void die();
void resurrect();
void closeInventoryWindows();

@ -17,18 +17,12 @@ namespace mwmp
virtual void Do(PlayerPacket &packet, BasePlayer *player)
{
LOG_MESSAGE_SIMPLE(TimedLog::LOG_INFO, "Received ID_PLAYER_DEATH from server");
if (isLocal())
{
LOG_APPEND(TimedLog::LOG_INFO, "- Packet was about me");
player->creatureStats.mDead = true;
MWWorld::Ptr playerPtr = MWBase::Environment::get().getWorld()->getPlayerPtr();
MWMechanics::DynamicStat<float> health = playerPtr.getClass().getCreatureStats(playerPtr).getHealth();
health.setCurrent(0);
playerPtr.getClass().getCreatureStats(playerPtr).setHealth(health);
packet.setPlayer(player);
packet.Send(serverAddr);
static_cast<LocalPlayer*>(player)->die();
}
else if (player != 0)
{

Loading…
Cancel
Save