Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding HandleStatModifier for Unit #161

Merged
merged 2 commits into from
Jan 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading