mirror of
https://github.com/luanti-org/luanti.git
synced 2025-08-11 17:51:04 +00:00
Add reasons to on_dieplayer and on_hpchange
This commit is contained in:
parent
2323842dd3
commit
dfc8198349
14 changed files with 219 additions and 52 deletions
|
@ -1029,7 +1029,8 @@ PlayerSAO* Server::StageTwoClientInit(session_t peer_id)
|
|||
if (playersao->isDead())
|
||||
SendDeathscreen(peer_id, false, v3f(0,0,0));
|
||||
else
|
||||
SendPlayerHPOrDie(playersao);
|
||||
SendPlayerHPOrDie(playersao,
|
||||
PlayerHPChangeReason(PlayerHPChangeReason::SET_HP));
|
||||
|
||||
// Send Breath
|
||||
SendPlayerBreath(playersao);
|
||||
|
@ -1392,7 +1393,7 @@ void Server::SendMovement(session_t peer_id)
|
|||
Send(&pkt);
|
||||
}
|
||||
|
||||
void Server::SendPlayerHPOrDie(PlayerSAO *playersao)
|
||||
void Server::SendPlayerHPOrDie(PlayerSAO *playersao, const PlayerHPChangeReason &reason)
|
||||
{
|
||||
if (!g_settings->getBool("enable_damage"))
|
||||
return;
|
||||
|
@ -1403,7 +1404,7 @@ void Server::SendPlayerHPOrDie(PlayerSAO *playersao)
|
|||
if (is_alive)
|
||||
SendPlayerHP(peer_id);
|
||||
else
|
||||
DiePlayer(peer_id);
|
||||
DiePlayer(peer_id, reason);
|
||||
}
|
||||
|
||||
void Server::SendHP(session_t peer_id, u16 hp)
|
||||
|
@ -2493,7 +2494,7 @@ void Server::sendDetachedInventories(session_t peer_id)
|
|||
Something random
|
||||
*/
|
||||
|
||||
void Server::DiePlayer(session_t peer_id)
|
||||
void Server::DiePlayer(session_t peer_id, const PlayerHPChangeReason &reason)
|
||||
{
|
||||
PlayerSAO *playersao = getPlayerSAO(peer_id);
|
||||
// In some rare cases this can be NULL -- if the player is disconnected
|
||||
|
@ -2505,10 +2506,10 @@ void Server::DiePlayer(session_t peer_id)
|
|||
<< playersao->getPlayer()->getName()
|
||||
<< " dies" << std::endl;
|
||||
|
||||
playersao->setHP(0);
|
||||
playersao->setHP(0, reason);
|
||||
|
||||
// Trigger scripted stuff
|
||||
m_script->on_dieplayer(playersao);
|
||||
m_script->on_dieplayer(playersao, reason);
|
||||
|
||||
SendPlayerHP(peer_id);
|
||||
SendDeathscreen(peer_id, false, v3f(0,0,0));
|
||||
|
@ -2523,7 +2524,8 @@ void Server::RespawnPlayer(session_t peer_id)
|
|||
<< playersao->getPlayer()->getName()
|
||||
<< " respawns" << std::endl;
|
||||
|
||||
playersao->setHP(playersao->accessObjectProperties()->hp_max);
|
||||
playersao->setHP(playersao->accessObjectProperties()->hp_max,
|
||||
PlayerHPChangeReason(PlayerHPChangeReason::RESPAWN));
|
||||
playersao->setBreath(playersao->accessObjectProperties()->breath_max);
|
||||
|
||||
bool repositioned = m_script->on_respawnplayer(playersao);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue