From f7d50a80782376d2e1c068e4d0a7ce9632f28bda Mon Sep 17 00:00:00 2001 From: SmallJoker Date: Wed, 23 Aug 2017 22:32:10 +0200 Subject: 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 --- src/script/lua_api/l_object.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/script/lua_api') diff --git a/src/script/lua_api/l_object.cpp b/src/script/lua_api/l_object.cpp index 46ac61f27..24fdeca4b 100644 --- a/src/script/lua_api/l_object.cpp +++ b/src/script/lua_api/l_object.cpp @@ -751,6 +751,11 @@ int ObjectRef::l_set_properties(lua_State *L) if (!prop) return 0; read_object_properties(L, 2, prop, getServer(L)->idef()); + if (prop->hp_max < co->getHP()) { + co->setHP(prop->hp_max); + if (co->getType() == ACTIVEOBJECT_TYPE_PLAYER) + getServer(L)->SendPlayerHPOrDie((PlayerSAO *)co); + } co->notifyObjectPropertiesModified(); return 0; } -- cgit v1.2.3