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

Respect object property hp_max field for players (#6287)

* Respect object property hp_max field for players
This allows modders to configure the maximal HP per player

* Statbars: Downscale bar to full 20 HP when exceeding this value
Add default max HP for players and breath constants to builtin
Document the constants

* Rename PLAYER_MAX_HP -> PLAYER_MAX_HP_DEFAULT
This commit is contained in:
SmallJoker 2017-08-23 22:32:10 +02:00 committed by Loïc Blot
parent d01b65abeb
commit f7d50a8078
9 changed files with 51 additions and 27 deletions

View file

@ -183,7 +183,9 @@ void read_object_properties(lua_State *L, int index,
if(!lua_istable(L, index))
return;
prop->hp_max = getintfield_default(L, -1, "hp_max", 10);
int hp_max = 0;
if (getintfield(L, -1, "hp_max", hp_max))
prop->hp_max = (s16)rangelim(hp_max, 0, S16_MAX);
getboolfield(L, -1, "physical", prop->physical);
getboolfield(L, -1, "collide_with_objects", prop->collideWithObjects);