From 2d915de6bc7dde86066b3bc3c29a05caf3acc825 Mon Sep 17 00:00:00 2001 From: Axel Cocat Date: Wed, 1 Mar 2023 10:34:36 +0100 Subject: [PATCH] feat: add Group:SetMemberFlag() (#102) --- README.md | 1 + src/LuaEngine/GroupMethods.h | 26 ++++++++++++++++++++++++++ src/LuaEngine/LuaFunctions.cpp | 1 + 3 files changed, 28 insertions(+) diff --git a/README.md b/README.md index 0e26223..a751b5a 100644 --- a/README.md +++ b/README.md @@ -97,6 +97,7 @@ Eluna API for AC: ### Group - Added `Group:GetGroupType()`: https://github.com/azerothcore/mod-eluna/pull/82 +- Added `Group:SetMemberFlag()`: https://github.com/azerothcore/mod-eluna/pull/102 ### Unit - Added `Unit:ModifyThreatPct()`: https://github.com/azerothcore/mod-eluna/pull/25 diff --git a/src/LuaEngine/GroupMethods.h b/src/LuaEngine/GroupMethods.h index d6fc9d2..763c18a 100644 --- a/src/LuaEngine/GroupMethods.h +++ b/src/LuaEngine/GroupMethods.h @@ -428,6 +428,32 @@ namespace LuaGroup return 0; } + /** + * Sets or removes a flag for a [Group] member + * + *
+     * enum GroupMemberFlags
+     * {
+     *     MEMBER_FLAG_ASSISTANT   = 0x01,
+     *     MEMBER_FLAG_MAINTANK    = 0x02,
+     *     MEMBER_FLAG_MAINASSIST  = 0x04,
+     * };
+     * 
+ * + * @param ObjectGuid target : GUID of the target + * @param bool apply : add the `flag` if `true`, remove the `flag` otherwise + * @param [GroupMemberFlags] flag : the flag to set or unset + */ + int SetMemberFlag(lua_State* L, Group* group) + { + ObjectGuid target = Eluna::CHECKVAL(L, 2); + bool apply = Eluna::CHECKVAL(L, 3); + GroupMemberFlags flag = static_cast(Eluna::CHECKVAL(L, 4)); + + group->SetGroupMemberFlag(target, apply, flag); + return 0; + } + /*int ConvertToLFG(lua_State* L, Group* group) // TODO: Implementation { group->ConvertToLFG(); diff --git a/src/LuaEngine/LuaFunctions.cpp b/src/LuaEngine/LuaFunctions.cpp index 2dbbb6e..967600f 100644 --- a/src/LuaEngine/LuaFunctions.cpp +++ b/src/LuaEngine/LuaFunctions.cpp @@ -1112,6 +1112,7 @@ ElunaRegister GroupMethods[] = { "SetLeader", &LuaGroup::SetLeader }, { "SetMembersGroup", &LuaGroup::SetMembersGroup }, { "SetTargetIcon", &LuaGroup::SetTargetIcon }, + { "SetMemberFlag", &LuaGroup::SetMemberFlag }, // Boolean { "IsLeader", &LuaGroup::IsLeader },