[Client] Add resurrect() method to DedicatedPlayer

This commit is contained in:
David Cernat 2020-11-15 00:44:10 +02:00
parent 1083fa5196
commit cd835104b7
3 changed files with 16 additions and 12 deletions

View File

@ -459,6 +459,20 @@ void DedicatedPlayer::equipItem(std::string itemId, bool noSound)
} }
} }
void DedicatedPlayer::resurrect()
{
creatureStats.mDead = false;
if (creatureStats.mDynamic[0].mMod < 1)
creatureStats.mDynamic[0].mMod = 1;
creatureStats.mDynamic[0].mCurrent = creatureStats.mDynamic[0].mMod;
MWBase::Environment::get().getMechanicsManager()->resurrect(getPtr());
MWMechanics::DynamicStat<float> health;
health.readState(creatureStats.mDynamic[0]);
getPtr().getClass().getCreatureStats(getPtr()).setHealth(health);
}
void DedicatedPlayer::updateMarker() void DedicatedPlayer::updateMarker()
{ {
if (!markerEnabled) if (!markerEnabled)

View File

@ -46,6 +46,7 @@ namespace mwmp
void playSpeech(); void playSpeech();
void equipItem(std::string itemId, bool noSound = false); void equipItem(std::string itemId, bool noSound = false);
void resurrect();
void updateMarker(); void updateMarker();
void removeMarker(); void removeMarker();

View File

@ -32,18 +32,7 @@ namespace mwmp
{ {
LOG_APPEND(TimedLog::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str()); LOG_APPEND(TimedLog::LOG_INFO, "- Packet was about %s", player->npc.mName.c_str());
player->creatureStats.mDead = false; static_cast<DedicatedPlayer*>(player)->resurrect();
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();
MWBase::Environment::get().getMechanicsManager()->resurrect(ptr);
MWMechanics::DynamicStat<float> health;
health.readState(player->creatureStats.mDynamic[0]);
ptr.getClass().getCreatureStats(ptr).setHealth(health);
} }
} }
}; };