Exemplo n.º 1
0
 public void AddMember(Character chr)
 {
     BattlegroundHandler.SendPlayerJoined((IPacketReceiver)this, chr);
     chr.Battlegrounds.Team = this;
     this._members.Add(chr);
     ++this._count;
 }
Exemplo n.º 2
0
 public void AddMember(Character chr)
 {
     BattlegroundHandler.SendPlayerJoined(this, chr);
     chr.Battlegrounds.Team = this;
     _members.Add(chr);
     _count++;
 }
Exemplo n.º 3
0
 public void RemoveMember(Character chr)
 {
     BattlegroundHandler.SendPlayerLeft(this, chr);
     chr.Battlegrounds.Team = null;
     _members.Remove(chr);
     _count--;
 }
Exemplo n.º 4
0
 public void SendPvpData()
 {
     foreach (Character character in this.m_characters)
     {
         BattlegroundHandler.SendPvpData((IPacketReceiver)character, character.Battlegrounds.Team.Side, this);
     }
 }
Exemplo n.º 5
0
 public void SendPvpData()
 {
     foreach (var chr in m_characters)
     {
         BattlegroundHandler.SendPvpData(chr, chr.Battlegrounds.Team.Side, this);
     }
 }
Exemplo n.º 6
0
 public void RemoveMember(Character chr)
 {
     BattlegroundHandler.SendPlayerLeft((IPacketReceiver)this, chr);
     chr.Battlegrounds.Team = (BattlegroundTeam)null;
     this._members.Remove(chr);
     --this._count;
 }
Exemplo n.º 7
0
        protected override void OnEnter(Character chr)
        {
            base.OnEnter(chr);

            var invitation = chr.Battlegrounds.Invitation;

            if (invitation == null)
            {
                // don't join a team if not invited
                return;
            }

            var team = invitation.Team;

            if (team.Battleground != this)
            {
                // decided for another BG in the meantime
                team.Battleground.TeleportInside(chr);
                return;
            }

            // stop cancel timer
            chr.RemoveUpdateAction(invitation.CancelTimer);

            // Cast the spell "10% Healing Reduction in BG/Arenas"
            chr.SpellCast.TriggerSelf(_healingReductionSpell);

            // join team
            JoinTeam(chr, team);

            BattlegroundHandler.SendStatusActive(chr, this, invitation.QueueIndex);
        }
Exemplo n.º 8
0
        internal void InviteTo(BattlegroundTeam team, int queueIndex, BattlegroundRelation relation)
        {
            this._chr.EnsureContext();
            relation.IsEnqueued = false;
            Battleground           bg = team.Battleground;
            BattlegroundInvitation battlegroundInvitation = new BattlegroundInvitation(team, queueIndex);

            this._chr.Battlegrounds.Invitation = battlegroundInvitation;
            battlegroundInvitation.CancelTimer = this._chr.CallDelayed(BattlegroundMgr.InvitationTimeoutMillis,
                                                                       (Action <WorldObject>)(obj => this.RemoveRelation(bg.Template.Id)));
            BattlegroundHandler.SendStatusInvited(this._chr);
        }
Exemplo n.º 9
0
        internal void RemoveRelation(int index, BattlegroundRelation relation, bool isCharActive)
        {
            _chr.EnsureContext();
            _relations[index] = null;

            var invite = Invitation;

            if (invite != null)
            {
                // cancel reserved slot
                invite.Team.ReservedSlots--;
                Invitation = null;
            }

            var bgId = relation.BattlegroundId;
            var bg   = _chr.Map as Battleground;

            if (bg != null &&
                bg.Template.Id == bgId &&
                !relation.IsEnqueued &&
                !_chr.IsTeleporting &&
                isCharActive)
            {
                bg.TeleportOutside(_chr);
            }

            if (isCharActive)
            {
                BattlegroundHandler.ClearStatus(_chr, index);
            }

            if (relation.IsEnqueued && relation.Characters.CharacterCount > 1)
            {
                var group = _chr.Group;
                if (group != null && group.IsLeader(_chr))
                {
                    // also dequeue everyone else
                    relation.Characters.ForeachCharacter(chr =>
                    {
                        if (chr != _chr)
                        {
                            chr.ExecuteInContext(() =>
                            {
                                chr.Battlegrounds.RemoveRelation(bgId);
                            });
                        }
                    });
                }
            }
        }
Exemplo n.º 10
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="relation"></param>
        /// <returns>The index of the newly created relation</returns>
        public int AddRelation(BattlegroundRelation relation)
        {
            this._chr.EnsureContext();
            int index = (int)ArrayUtil.AddOnlyOne <BattlegroundRelation>(ref this._relations, relation);

            ++this._relationCount;
            BattlegroundQueue parentQueue = relation.Queue.ParentQueue;

            if (parentQueue != null)
            {
                BattlegroundHandler.SendStatusEnqueued(this._chr, index, relation, parentQueue);
            }
            return(index);
        }
Exemplo n.º 11
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="chr"></param>
        public static void TalkToBattlemaster(this NPC bm, Character chr)
        {
            chr.OnInteract(bm);

            BattlegroundTemplate templ = bm.Entry.BattlegroundTemplate;

            if (templ != null)
            {
                GlobalBattlegroundQueue queue = templ.GetQueue(chr.Level);
                if (queue != null)
                {
                    BattlegroundHandler.SendBattlefieldList(chr, queue);
                }
            }
        }
Exemplo n.º 12
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="relation"></param>
        /// <returns>The index of the newly created relation</returns>
        public int AddRelation(BattlegroundRelation relation)
        {
            _chr.EnsureContext();

            var index = (int)ArrayUtil.AddOnlyOne(ref _relations, relation);

            _relationCount++;
            var queue = relation.Queue.ParentQueue;

            if (queue != null)
            {
                BattlegroundHandler.SendStatusEnqueued(_chr, index, relation, queue);
            }

            return(index);
        }
Exemplo n.º 13
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="bm"></param>
        /// <param name="chr"></param>
        public static void TalkToBattlemaster(this NPC bm, Character chr)
        {
            chr.OnInteract((WorldObject)bm);
            BattlegroundTemplate battlegroundTemplate = bm.Entry.BattlegroundTemplate;

            if (battlegroundTemplate == null)
            {
                return;
            }
            GlobalBattlegroundQueue queue = battlegroundTemplate.GetQueue(chr.Level);

            if (queue == null)
            {
                return;
            }
            BattlegroundHandler.SendBattlefieldList(chr, queue);
        }
Exemplo n.º 14
0
        internal void InviteTo(BattlegroundTeam team, int queueIndex, BattlegroundRelation relation)
        {
            _chr.EnsureContext();

            relation.IsEnqueued = false;
            var bg     = team.Battleground;
            var invite = new BattlegroundInvitation(team, queueIndex);

            _chr.Battlegrounds.Invitation = invite;

            invite.CancelTimer = _chr.CallDelayed(BattlegroundMgr.InvitationTimeoutMillis, obj =>
            {
                RemoveRelation(bg.Template.Id);
            });

            BattlegroundHandler.SendStatusInvited(_chr);
        }
Exemplo n.º 15
0
        internal void RemoveRelation(int index, BattlegroundRelation relation, bool isCharActive)
        {
            this._chr.EnsureContext();
            this._relations[index] = (BattlegroundRelation)null;
            BattlegroundInvitation invitation = this.Invitation;

            if (invitation != null)
            {
                --invitation.Team.ReservedSlots;
                this.Invitation = (BattlegroundInvitation)null;
            }

            BattlegroundId bgId = relation.BattlegroundId;
            Battleground   map  = this._chr.Map as Battleground;

            if (map != null && map.Template.Id == bgId && (!relation.IsEnqueued && !this._chr.IsTeleporting) &&
                isCharActive)
            {
                map.TeleportOutside(this._chr);
            }
            if (isCharActive)
            {
                BattlegroundHandler.ClearStatus((IPacketReceiver)this._chr, index);
            }
            if (!relation.IsEnqueued || relation.Characters.CharacterCount <= 1)
            {
                return;
            }
            Group group = this._chr.Group;

            if (group == null || !group.IsLeader(this._chr))
            {
                return;
            }
            relation.Characters.ForeachCharacter((Action <Character>)(chr =>
            {
                if (chr == this._chr)
                {
                    return;
                }
                chr.ExecuteInContext((Action)(() => chr.Battlegrounds.RemoveRelation(bgId)));
            }));
        }
Exemplo n.º 16
0
 /// <summary>Enqueues players in a battleground queue.</summary>
 /// <param name="chr">the character who enqueued</param>
 /// <param name="bgId">the type of battleground</param>
 /// <param name="instanceId">the instance id of the battleground</param>
 /// <param name="asGroup">whether or not to enqueue the character or his/her group</param>
 internal static void EnqueuePlayers(Character chr, BattlegroundId bgId, uint instanceId, bool asGroup)
 {
     if (!chr.Battlegrounds.HasAvailableQueueSlots)
     {
         BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr, BattlegroundJoinError.Max3Battles);
     }
     else
     {
         if (chr.Battlegrounds.IsEnqueuedFor(bgId))
         {
             return;
         }
         BattlegroundTemplate template = BattlegroundMgr.GetTemplate(bgId);
         if (template == null)
         {
             return;
         }
         template.TryEnqueue(chr, asGroup, instanceId);
     }
 }
Exemplo n.º 17
0
        /// <summary>
        /// Enqueues players in a battleground queue.
        /// </summary>
        /// <param name="chr">the character who enqueued</param>
        /// <param name="bgId">the type of battleground</param>
        /// <param name="instanceId">the instance id of the battleground</param>
        /// <param name="asGroup">whether or not to enqueue the character or his/her group</param>
        internal static void EnqueuePlayers(Character chr, BattlegroundId bgId, uint instanceId, bool asGroup)
        {
            if (!chr.Battlegrounds.HasAvailableQueueSlots)
            {
                BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.Max3Battles);
                return;
            }
            // cannot enqueue twice for the same bg
            if (chr.Battlegrounds.IsEnqueuedFor(bgId))
            {
                return;
            }

            var template = GetTemplate(bgId);

            // TODO: Is Character just updating an existing queue slot?
            if (template != null)
            {
                template.TryEnqueue(chr, asGroup, instanceId);
            }
        }
Exemplo n.º 18
0
        protected override void OnEnter(Character chr)
        {
            base.OnEnter(chr);
            BattlegroundInvitation invitation = chr.Battlegrounds.Invitation;

            if (invitation == null)
            {
                return;
            }
            BattlegroundTeam team = invitation.Team;

            if (team.Battleground != this)
            {
                team.Battleground.TeleportInside(chr);
            }
            else
            {
                chr.RemoveUpdateAction((ObjectUpdateTimer)invitation.CancelTimer);
                chr.SpellCast.TriggerSelf(this._healingReductionSpell);
                this.JoinTeam(chr, team);
                BattlegroundHandler.SendStatusActive(chr, this, invitation.QueueIndex);
            }
        }
Exemplo n.º 19
0
        public ICharacterSet GetCharacterSet(Character chr, bool asGroup)
        {
            // we are working with a non-synchronized Character object here
            if (asGroup)
            {
                var group = chr.Group;
                if (group == null || !group.IsLeader(chr))
                {
                    // invalid request
                    GroupHandler.SendResult(chr, GroupResultType.Swap, GroupResult.DontHavePermission);
                }
                else
                {
                    var chrs = group.GetAllCharacters();

                    // if no characters in the group, return the original character
                    if (chrs.Length == 0)
                    {
                        return(chr);
                    }

                    // make sure the group isn't bigger than the max team size for this BG
                    if (chrs.Length > _parentQueue.Template.MaxPlayersPerTeam)
                    {
                        BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.GroupJoinedNotEligible);
                        return(null);
                    }

                    // make sure there are no deserters
                    foreach (Character groupChr in chrs)
                    {
                        if (groupChr != null && groupChr.Battlegrounds.IsDeserter)
                        {
                            BattlegroundHandler.SendBattlegroundError(group, BattlegroundJoinError.Deserter);
                            return(null);
                        }
                    }

                    var list = new SynchronizedCharacterList(Side.GetFactionGroup());

                    foreach (var groupChr in chrs)
                    {
                        if (groupChr.IsInWorld && (groupChr.GodMode || _parentQueue.CanEnter(groupChr)))
                        {
                            list.Add(groupChr);
                        }
                        else
                        {
                            // cannot join the same team
                            BattlegroundHandler.SendBattlegroundError(groupChr, BattlegroundJoinError.GroupJoinedNotEligible);
                        }
                    }

                    return(list);
                }
            }
            else
            {
                // enqueue the character if they aren't a deserter
                if (!chr.Battlegrounds.IsDeserter)
                {
                    return(chr);
                }

                BattlegroundHandler.SendBattlegroundError(chr, BattlegroundJoinError.Deserter);
            }

            return(null);
        }
Exemplo n.º 20
0
        public ICharacterSet GetCharacterSet(Character chr, bool asGroup)
        {
            if (asGroup)
            {
                Group group = chr.Group;
                if (group == null || !group.IsLeader(chr))
                {
                    GroupHandler.SendResult((IPacketReceiver)chr, GroupResult.DontHavePermission);
                }
                else
                {
                    Character[] allCharacters = group.GetAllCharacters();
                    if (allCharacters.Length == 0)
                    {
                        return((ICharacterSet)chr);
                    }
                    if (allCharacters.Length > this._parentQueue.Template.MaxPlayersPerTeam)
                    {
                        BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr,
                                                                  BattlegroundJoinError.GroupJoinedNotEligible);
                        return((ICharacterSet)null);
                    }

                    foreach (Character character in allCharacters)
                    {
                        if (character != null && character.Battlegrounds.IsDeserter)
                        {
                            BattlegroundHandler.SendBattlegroundError((IPacketReceiver)group,
                                                                      BattlegroundJoinError.Deserter);
                            return((ICharacterSet)null);
                        }
                    }

                    SynchronizedCharacterList synchronizedCharacterList =
                        new SynchronizedCharacterList(this.Side.GetFactionGroup());
                    foreach (Character chr1 in allCharacters)
                    {
                        if (chr1.IsInWorld && (chr1.GodMode || this._parentQueue.CanEnter(chr1)))
                        {
                            synchronizedCharacterList.Add(chr1);
                        }
                        else
                        {
                            BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr1,
                                                                      BattlegroundJoinError.GroupJoinedNotEligible);
                        }
                    }

                    return((ICharacterSet)synchronizedCharacterList);
                }
            }
            else
            {
                if (!chr.Battlegrounds.IsDeserter)
                {
                    return((ICharacterSet)chr);
                }
                BattlegroundHandler.SendBattlegroundError((IPacketReceiver)chr, BattlegroundJoinError.Deserter);
            }

            return((ICharacterSet)null);
        }
Exemplo n.º 21
0
            public override void Process(CmdTrigger <RealmServerCmdArgs> trigger)
            {
                var err = trigger.Text.NextEnum(BattlegroundJoinError.None);

                BattlegroundHandler.SendBattlegroundError(trigger.Args.Character, err);
            }