Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] Allow mods to detect damage greater than the player's health. #14344

Open
ThePython10110 opened this issue Feb 3, 2024 · 0 comments
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API

Comments

@ThePython10110
Copy link

ThePython10110 commented Feb 3, 2024

Problem

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

@ThePython10110 ThePython10110 added the Feature request Issues that request the addition or enhancement of a feature label Feb 3, 2024
@ThePython10110 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature request Issues that request the addition or enhancement of a feature @ Script API
Projects
None yet
Development

No branches or pull requests

2 participants