Enforce `hp_max` also for entities
What happened
I was trying to heal an entity with set_hp(..), to then only notice that its life was going way higher than it should have (its hp_max). It took me 20 minutes to understand why.
Explanation
set_hp(..) ignores hp_max for entities. As stated in the DOCS:
For players: HP are also limited by hp_max specified in object properties
And hp_max is defined like so:
Defines the maximum and default HP of the object. For Lua entities, the maximum is not enforced.
So it is enforced, but only when setting default HPs. And this is so counterintuitive (it's literally called "HP max") that to me it sounds like a way to document a bug so that it can't be called as such. Why entities shouldn't have a health cap anyway? I don't want to write a different logic for players and entities when the underlying mechanism should be exactly the same
Additional notes
The lack of #9416 makes the handling of entities' HP even worse
Source: luanti-org/luanti