Skip to content

Commit

Permalink
feat: Adding HandleStatModifier for Unit (azerothcore#161)
Browse files Browse the repository at this point in the history
  • Loading branch information
iThorgrim committed Jan 28, 2024
1 parent d3638cd commit 5e45216
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/LuaEngine/LuaFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ ElunaRegister<Unit> UnitMethods[] =
#endif

// Other
{"HandleStatModifier", &LuaUnit::HandleStatModifier},
{ "AddAura", &LuaUnit::AddAura },
{ "RemoveAura", &LuaUnit::RemoveAura },
{ "RemoveAllAuras", &LuaUnit::RemoveAllAuras },
Expand Down
21 changes: 21 additions & 0 deletions src/LuaEngine/UnitMethods.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
*
Expand Down

0 comments on commit 5e45216

Please sign in to comment.