(L, 2);
Eluna::Push(L, group->GetMemberGUID(name));
return 1;
}
/**
* Returns the member count of this [Group]
*
* @return uint32 memberCount
*/
int GetMembersCount(lua_State* L, Group* group)
{
Eluna::Push(L, group->GetMembersCount());
return 1;
}
/**
* Returns the type of this [Group]
*
*
* enum GroupType
* {
* GROUPTYPE_NORMAL = 0,
* GROUPTYPE_BG = 1,
* GROUPTYPE_RAID = 2,
* GROUPTYPE_LFG_RESTRICTED = 4,
* GROUPTYPE_LFG = 8
* };
*
*
* @return [GroupType] groupType
*/
int GetGroupType(lua_State* L, Group* group)
{
Eluna::Push(L, group->GetGroupType());
return 1;
}
/**
* Returns the [Player]'s subgroup ID of this [Group]
*
* @param ObjectGuid guid : guid of the player
* @return uint8 subGroupID : a valid subgroup ID or MAX_RAID_SUBGROUPS+1
*/
int GetMemberGroup(lua_State* L, Group* group)
{
ObjectGuid guid = Eluna::CHECKVAL(L, 2);
Eluna::Push(L, group->GetMemberGroup(guid));
return 1;
}
/**
* Sets the leader of this [Group]
*
* @param ObjectGuid guid : guid of the new leader
*/
int SetLeader(lua_State* L, Group* group)
{
ObjectGuid guid = Eluna::CHECKVAL(L, 2);
group->ChangeLeader(guid);
group->SendUpdate();
return 0;
}
/**
* Sends a specified [WorldPacket] to this [Group]
*
* @param [WorldPacket] packet : the [WorldPacket] to send
* @param bool ignorePlayersInBg : ignores [Player]s in a battleground
* @param ObjectGuid ignore : ignore a [Player] by their GUID
*/
int SendPacket(lua_State* L, Group* group)
{
WorldPacket* data = Eluna::CHECKOBJ(L, 2);
bool ignorePlayersInBg = Eluna::CHECKVAL(L, 3);
ObjectGuid ignore = Eluna::CHECKVAL(L, 4);
group->BroadcastPacket(data, ignorePlayersInBg, -1, ignore);
return 0;
}
/**
* Removes a [Player] from this [Group] and returns 'true' if successful
*
*
* enum RemoveMethod
* {
* GROUP_REMOVEMETHOD_DEFAULT = 0,
* GROUP_REMOVEMETHOD_KICK = 1,
* GROUP_REMOVEMETHOD_LEAVE = 2,
* GROUP_REMOVEMETHOD_KICK_LFG = 3
* };
*
*
* @param ObjectGuid guid : guid of the player to remove
* @param [RemoveMethod] method : method used to remove the player
* @return bool removed
*/
int RemoveMember(lua_State* L, Group* group)
{
ObjectGuid guid = Eluna::CHECKVAL(L, 2);
uint32 method = Eluna::CHECKVAL(L, 3, 0);
Eluna::Push(L, group->RemoveMember(guid, (RemoveMethod)method));
return 1;
}
/**
* Disbands this [Group]
*
*/
int Disband(lua_State* /*L*/, Group* group)
{
group->Disband();
return 0;
}
/**
* Converts this [Group] to a raid [Group]
*
*/
int ConvertToRaid(lua_State* /*L*/, Group* group)
{
group->ConvertToRaid();
return 0;
}
/**
* Sets the member's subGroup
*
* @param ObjectGuid guid : guid of the player to move
* @param uint8 groupID : the subGroup's ID
*/
int SetMembersGroup(lua_State* L, Group* group)
{
ObjectGuid guid = Eluna::CHECKVAL(L, 2);
uint8 subGroup = Eluna::CHECKVAL(L, 3);
if (subGroup >= MAX_RAID_SUBGROUPS)
{
luaL_argerror(L, 3, "valid subGroup ID expected");
return 0;
}
if (!group->HasFreeSlotSubGroup(subGroup))
return 0;
group->ChangeMembersGroup(guid, subGroup);
return 0;
}
/**
* Sets the target icon of an object for the [Group]
*
* @param uint8 icon : the icon (Skull, Square, etc)
* @param ObjectGuid target : GUID of the icon target, 0 is to clear the icon
* @param ObjectGuid setter : GUID of the icon setter
*/
int SetTargetIcon(lua_State* L, Group* group)
{
uint8 icon = Eluna::CHECKVAL(L, 2);
ObjectGuid target = Eluna::CHECKVAL(L, 3);
ObjectGuid setter = Eluna::CHECKVAL(L, 4, ObjectGuid());
if (icon >= TARGETICONCOUNT)
return luaL_argerror(L, 2, "valid target icon expected");
group->SetTargetIcon(icon, setter, target);
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();
return 0;
}*/
};
#endif