diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index ebf32d8459..36378ac3fd 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -401,6 +401,7 @@ ElunaRegister UnitMethods[] = #endif // Other + {"HandleStatModifier", &LuaUnit::HandleStatModifier}, { "AddAura", &LuaUnit::AddAura }, { "RemoveAura", &LuaUnit::RemoveAura }, { "RemoveAllAuras", &LuaUnit::RemoveAllAuras }, diff --git a/src/LuaEngine/UnitMethods.h b/src/LuaEngine/UnitMethods.h index 50e467b00e..85924ff048 100644 --- a/src/LuaEngine/UnitMethods.h +++ b/src/LuaEngine/UnitMethods.h @@ -12,6 +12,27 @@ */ namespace LuaUnit { + /** + * The [Unit] modifies a specific stat + * + * @param int32 stat : The stat to modify + * @param int8 type : The type of modifier to apply + * @param float value : The value to apply to the stat + * @param bool apply = false : Whether the modifier should be applied or removed + * @return bool : Whether the stat modification was successful + */ + int HandleStatModifier(lua_State* L, Unit* unit) + { + int32 stat = Eluna::CHECKVAL(L, 2); + int8 type = Eluna::CHECKVAL(L, 3); + + float value = Eluna::CHECKVAL(L, 4); + bool apply = Eluna::CHECKVAL(L, 5, false); + + Eluna::Push(L, unit->HandleStatModifier(UnitMods(UNIT_MOD_STAT_START + stat), (UnitModifierType)type, value, apply)); + return 1; + } + /** * The [Unit] tries to attack a given target *