1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

Report node for drowning in PlayerHPChangeReason

This commit is contained in:
Wuzzy 2025-04-14 18:09:37 +02:00
parent 6d3057b08e
commit a21dd0a992
3 changed files with 5 additions and 3 deletions

View file

@ -11086,7 +11086,8 @@ The `PlayerHPChangeReason` table specifies a reason for player health changes.
* `node_damage`: `damage_per_second` from a neighboring node.
`reason.node` will hold the node name or nil.
`reason.node_pos` will hold the position of the node
* `drown`: Drowning damage.
* `drown`: Drowning damage from a node with the `drowning` field set.
`reason.node` and `reason.node_pos` are same as for `node_damage`
* `respawn`: HP restored by respawning.
* The `detail` field may optionally be used to provide a more detailed reason
as a string. It's recommended to follow the `modname:detail` naming convention.

View file

@ -154,7 +154,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

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