feat: Adding HandleStatModifier for Unit (#161)

This commit is contained in:
V
2024-01-28 13:52:12 +01:00
committed by GitHub
parent d3638cd99d
commit 5e4521696f
2 changed files with 22 additions and 0 deletions

View File

@@ -401,6 +401,7 @@ ElunaRegister<Unit> UnitMethods[] =
#endif
// Other
{"HandleStatModifier", &LuaUnit::HandleStatModifier},
{ "AddAura", &LuaUnit::AddAura },
{ "RemoveAura", &LuaUnit::RemoveAura },
{ "RemoveAllAuras", &LuaUnit::RemoveAllAuras },

View File

@@ -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<int32>(L, 2);
int8 type = Eluna::CHECKVAL<int8>(L, 3);
float value = Eluna::CHECKVAL<float>(L, 4);
bool apply = Eluna::CHECKVAL<bool>(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
*