1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-12-23 15:05:29 +01:00

Add more information in PlayerHPChangeReason (#16024)

1) Add `node` and `node_pos` field for the `drown` field (analog to `node_damage` type)
2) Add `custom_type` field to allow a standardized way to report more details of the HP change
3) Make `builtin` report a `custom_type` for the HP changes caused by the `/kill` command and `core.do_item_eat`
4) Move the documentation of `PlayerHPChangeReason` to its own section
5) Fill in missing information of said documentation
This commit is contained in:
Wuzzy
2025-12-20 15:12:34 +01:00
committed by GitHub
parent 9c37b46e1f
commit f567449cd6
5 changed files with 43 additions and 20 deletions

View File

@@ -159,7 +159,8 @@ void PlayerSAO::step(float dtime, bool send_recommended)
// No more breath, damage player
if (m_breath == 0) {
PlayerHPChangeReason reason(PlayerHPChangeReason::DROWNING);
std::string nodename = c.name;
PlayerHPChangeReason reason(PlayerHPChangeReason::DROWNING, nodename, p);
setHP(m_hp - c.drowning, reason);
}
}

View File

@@ -250,7 +250,7 @@ struct PlayerHPChangeReason
// For PLAYER_PUNCH
ServerActiveObject *object = nullptr;
// For NODE_DAMAGE
// For NODE_DAMAGE and DROWNING
std::string node;
v3s16 node_pos;