You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, there is no way for mods to detect whether damage is greater than the player's health.
2024-02-03 15:12:28: ACTION[Server]: singleplayer damaged by 43 hp at (-3,7.165,-22)
2024-02-03 15:12:28: [Server]: HP change: -20
The first line is logged by the engine and the second line is logged in a minetest.register_on_player_hpchange function. I've looked through the engine code and found that before running those functions, the new HP is limited to a minimum of 0 (thus limiting the hp_change to the player's current HP). This means that there is no way to tell the difference between fall damage from 27 meters and 60,000 meters.
The reason I noticed this is because of a mod I'm making that adds very powerful armor. With the armor, players don't take damage unless it's above a certain threshold. Unfortunately, this means that when a player's HP is below that threshold, the player literally can't take damage while wearing the armor.
Solutions
The HP change passed to minetest.register_on_player_hpchange functions should not be limited to the player's current health. It should be the same as the damage reported by the server.
Alternatives
Maybe adding a boolean argument to minetest.register_on_player_hpchange to decide whether the full or adjusted HP change should be used.
Additional context
No response
The text was updated successfully, but these errors were encountered:
ThePython10110
changed the title
Allow mods to detect damage greater than the player's health.
[Feature] Allow mods to detect damage greater than the player's health.
Feb 8, 2024
Problem
At the moment, there is no way for mods to detect whether damage is greater than the player's health.
The first line is logged by the engine and the second line is logged in a
minetest.register_on_player_hpchange
function. I've looked through the engine code and found that before running those functions, the new HP is limited to a minimum of 0 (thus limiting thehp_change
to the player's current HP). This means that there is no way to tell the difference between fall damage from 27 meters and 60,000 meters.The reason I noticed this is because of a mod I'm making that adds very powerful armor. With the armor, players don't take damage unless it's above a certain threshold. Unfortunately, this means that when a player's HP is below that threshold, the player literally can't take damage while wearing the armor.
Solutions
The HP change passed to
minetest.register_on_player_hpchange
functions should not be limited to the player's current health. It should be the same as the damage reported by the server.Alternatives
Maybe adding a boolean argument to
minetest.register_on_player_hpchange
to decide whether the full or adjusted HP change should be used.Additional context
No response
The text was updated successfully, but these errors were encountered: