Untitled
unknown
c_cpp
2 years ago
775 B
5
Indexable
int LuaScriptInterface::luaCreatureAddHealth(lua_State* L) { // creature:addHealth(healthChange[, animationOnChange = true]) Creature* creature = getUserdata<Creature>(L, 1); if (!creature) { lua_pushnil(L); return 1; } int32_t healthChange = getNumber<int32_t>(L, 2); bool animationOnChange = getBoolean(L, 3, true); Player* player = creature->getPlayer(); if (player && !animationOnChange) { creature->changeHealth(healthChange); pushBoolean(L, true); } else { CombatDamage damage; damage.primary.value = healthChange; if (damage.primary.value >= 0) { damage.primary.type = COMBAT_HEALING; } else { damage.primary.type = COMBAT_UNDEFINEDDAMAGE; } pushBoolean(L, g_game.combatChangeHealth(nullptr, creature, damage)); } return 1; }
Editor is loading...