Beispiel #1
0
        // Group Hooks
        public override void OnAddMember(Group group, ObjectGuid guid)
        {
            if (!Global.LFGMgr.isOptionEnabled(LfgOptions.EnableDungeonFinder | LfgOptions.EnableRaidBrowser))
            {
                return;
            }

            ObjectGuid gguid  = group.GetGUID();
            ObjectGuid leader = group.GetLeaderGUID();

            if (leader == guid)
            {
                Log.outDebug(LogFilter.Lfg, "LFGScripts.OnAddMember [{0}]: added [{1} leader {2}]", gguid, guid, leader);
                Global.LFGMgr.SetLeader(gguid, guid);
            }
            else
            {
                LfgState gstate = Global.LFGMgr.GetState(gguid);
                LfgState state  = Global.LFGMgr.GetState(guid);
                Log.outDebug(LogFilter.Lfg, "LFGScripts.OnAddMember [{0}]: added [{1} leader {2}] gstate: {3}, state: {4}", gguid, guid, leader, gstate, state);

                if (state == LfgState.Queued)
                {
                    Global.LFGMgr.LeaveLfg(guid);
                }

                if (gstate == LfgState.Queued)
                {
                    Global.LFGMgr.LeaveLfg(gguid);
                }
            }

            Global.LFGMgr.SetGroup(guid, gguid);
            Global.LFGMgr.AddPlayerToGroup(gguid, guid);
        }
        public void SetState(LfgState state)
        {
            switch (state)
            {
            case LfgState.None:
            case LfgState.FinishedDungeon:
                m_Roles = 0;
                m_SelectedDungeons.Clear();
                goto case LfgState.Dungeon;

            case LfgState.Dungeon:
                m_OldState = state;
                break;
            }
            m_State = state;
        }
Beispiel #3
0
        public void SetState(LfgState state)
        {
            switch (state)
            {
            case LfgState.None:
                m_Dungeon   = 0;
                m_KicksLeft = SharedConst.LFGMaxKicks;
                m_OldState  = state;
                break;

            case LfgState.FinishedDungeon:
            case LfgState.Dungeon:
                m_OldState = state;
                break;
            }
            m_State = state;
        }
Beispiel #4
0
        public PartyResult CanUninviteFromGroup(ObjectGuid guidMember = default(ObjectGuid))
        {
            Group grp = GetGroup();

            if (!grp)
            {
                return(PartyResult.NotInGroup);
            }

            if (grp.isLFGGroup())
            {
                ObjectGuid gguid = grp.GetGUID();
                if (Global.LFGMgr.GetKicksLeft(gguid) == 0)
                {
                    return(PartyResult.PartyLfgBootLimit);
                }

                LfgState state = Global.LFGMgr.GetState(gguid);
                if (Global.LFGMgr.IsVoteKickActive(gguid))
                {
                    return(PartyResult.PartyLfgBootInProgress);
                }

                if (grp.GetMembersCount() <= SharedConst.LFGKickVotesNeeded)
                {
                    return(PartyResult.PartyLfgBootTooFewPlayers);
                }

                if (state == LfgState.FinishedDungeon)
                {
                    return(PartyResult.PartyLfgBootDungeonComplete);
                }

                if (grp.isRollLootActive())
                {
                    return(PartyResult.PartyLfgBootLootRolls);
                }

                // @todo Should also be sent when anyone has recently left combat, with an aprox ~5 seconds timer.
                for (GroupReference refe = grp.GetFirstMember(); refe != null; refe = refe.next())
                {
                    if (refe.GetSource() && refe.GetSource().IsInMap(this) && refe.GetSource().IsInCombat())
                    {
                        return(PartyResult.PartyLfgBootInCombat);
                    }
                }

                /* Missing support for these types
                 *  return ERR_PARTY_LFG_BOOT_COOLDOWN_S;
                 *  return ERR_PARTY_LFG_BOOT_NOT_ELIGIBLE_S;
                 */
            }
            else
            {
                if (!grp.IsLeader(GetGUID()) && !grp.IsAssistant(GetGUID()))
                {
                    return(PartyResult.NotLeader);
                }

                if (InBattleground())
                {
                    return(PartyResult.InviteRestricted);
                }

                if (grp.IsLeader(guidMember))
                {
                    return(PartyResult.NotLeader);
                }
            }

            return(PartyResult.Ok);
        }
Beispiel #5
0
        public override void OnRemoveMember(Group group, ObjectGuid guid, RemoveMethod method, ObjectGuid kicker, string reason)
        {
            if (!Global.LFGMgr.isOptionEnabled(LfgOptions.EnableDungeonFinder | LfgOptions.EnableRaidBrowser))
            {
                return;
            }

            ObjectGuid gguid = group.GetGUID();

            Log.outDebug(LogFilter.Lfg, "LFGScripts.OnRemoveMember [{0}]: remove [{1}] Method: {2} Kicker: {3} Reason: {4}", gguid, guid, method, kicker, reason);

            bool isLFG = group.isLFGGroup();

            if (isLFG && method == RemoveMethod.Kick)        // Player have been kicked
            {
                /// @todo - Update internal kick cooldown of kicker
                string str_reason = "";
                if (!string.IsNullOrEmpty(reason))
                {
                    str_reason = reason;
                }
                Global.LFGMgr.InitBoot(gguid, kicker, guid, str_reason);
                return;
            }

            LfgState state = Global.LFGMgr.GetState(gguid);

            // If group is being formed after proposal success do nothing more
            if (state == LfgState.Proposal && method == RemoveMethod.Default)
            {
                // LfgData: Remove player from group
                Global.LFGMgr.SetGroup(guid, ObjectGuid.Empty);
                Global.LFGMgr.RemovePlayerFromGroup(gguid, guid);
                return;
            }

            Global.LFGMgr.LeaveLfg(guid);
            Global.LFGMgr.SetGroup(guid, ObjectGuid.Empty);
            byte players = Global.LFGMgr.RemovePlayerFromGroup(gguid, guid);

            Player player = Global.ObjAccessor.FindPlayer(guid);

            if (player)
            {
                if (method == RemoveMethod.Leave && state == LfgState.Dungeon &&
                    players >= SharedConst.LFGKickVotesNeeded)
                {
                    player.CastSpell(player, SharedConst.LFGSpellDungeonDeserter, true);
                }
                //else if (state == LFG_STATE_BOOT)
                // Update internal kick cooldown of kicked

                player.GetSession().SendLfgUpdateStatus(new LfgUpdateData(LfgUpdateType.LeaderUnk1), true);
                if (isLFG && player.GetMap().IsDungeon())            // Teleport player out the dungeon
                {
                    Global.LFGMgr.TeleportPlayer(player, true);
                }
            }

            if (isLFG && state != LfgState.FinishedDungeon) // Need more players to finish the dungeon
            {
                Player leader = Global.ObjAccessor.FindPlayer(Global.LFGMgr.GetLeader(gguid));
                if (leader)
                {
                    leader.GetSession().SendLfgOfferContinue(Global.LFGMgr.GetDungeon(gguid, false));
                }
            }
        }