Exemple #1
0
        public static void SendStatusActive(Character chr, Battleground bg, int queueIndex)
        {
            BattlegroundStatus battlegroundStatus = BattlegroundStatus.Active;
            BattlegroundSide   battlegroundSide   = chr.FactionGroup.GetBattlegroundSide();

            using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_BATTLEFIELD_STATUS))
            {
                packet.Write(queueIndex);
                BattlegroundId id = bg.Template.Id;
                packet.Write((byte)0);
                packet.Write((byte)1);
                packet.Write((uint)id);
                packet.Write((ushort)8080);
                packet.Write((byte)0);
                packet.Write((byte)0);
                packet.Write(bg.InstanceId);
                packet.Write((byte)0);
                packet.Write((int)battlegroundStatus);
                packet.Write((int)bg.Id);
                packet.Write(bg.RemainingShutdownDelay);
                packet.Write(bg.RuntimeMillis);
                packet.Write((byte)battlegroundSide);
                chr.Send(packet, false);
            }
        }
Exemple #2
0
        public static void SendPvpData(IPacketReceiver reciever, BattlegroundSide side, Battleground bg)
        {
            bg.EnsureContext();
            using (RealmPacketOut packet =
                       new RealmPacketOut(RealmServerOpCode.MSG_PVP_LOG_DATA, 10 + bg.PlayerCount * 40))
            {
                BattlegroundTeam winner = bg.Winner;
                packet.Write(bg.IsArena);
                if (bg.IsArena)
                {
                    for (int index = 0; index < 2; ++index)
                    {
                        packet.Write(0);
                        packet.Write(3999);
                        packet.Write(0);
                    }

                    packet.WriteCString(string.Empty);
                    packet.WriteCString(string.Empty);
                }

                bool flag = bg.Winner != null;
                packet.Write(flag);
                if (flag)
                {
                    packet.Write((byte)bg.Winner.Side);
                }
                List <Character>         characters = bg.Characters;
                List <BattlegroundStats> listStats  = new List <BattlegroundStats>(characters.Count);
                characters.ForEach(chr => listStats.Add(chr.Battlegrounds.Stats));
                packet.Write(listStats.Count);
                for (int index = 0; index < listStats.Count; ++index)
                {
                    Character character = characters[index];
                    if (character.IsInBattleground)
                    {
                        BattlegroundStats stats = character.Battlegrounds.Stats;
                        packet.Write(character.EntityId);
                        packet.Write(stats.KillingBlows);
                        if (bg.IsArena)
                        {
                            packet.Write(winner != null && character.Battlegrounds.Team == winner);
                        }
                        else
                        {
                            packet.Write(stats.HonorableKills);
                            packet.Write(stats.Deaths);
                            packet.Write(stats.BonusHonor);
                        }

                        packet.Write(stats.TotalDamage);
                        packet.Write(stats.TotalHealing);
                        packet.Write(stats.SpecialStatCount);
                        stats.WriteSpecialStats(packet);
                    }
                }

                reciever.Send(packet, false);
            }
        }
Exemple #3
0
        protected void DoTryJoin(Character chr, bool asGroup, BattlegroundSide side)
        {
            EnsureContext();

            // if the character isn't in game, they can't join.
            if (!chr.IsInWorld)
            {
                return;
            }

            // can't join if the battleground isn't open
            if (!IsOpen)
            {
                return;
            }

            var team      = GetTeam(side);
            var teamQueue = _instanceQueue.GetTeamQueue(side);

            var chrs = teamQueue.GetCharacterSet(chr, asGroup);

            if (chrs != null)
            {
                team.Enqueue(chrs);
            }
        }
 public static FactionGroup GetFactionGroup(this BattlegroundSide side)
 {
     if (side == BattlegroundSide.Horde)
     {
         return(FactionGroup.Horde);
     }
     return(FactionGroup.Alliance);
 }
        /// <summary>Enqueues the given Character(s) for the given side</summary>
        public BattlegroundRelation Enqueue(ICharacterSet chrs, BattlegroundSide side)
        {
            BattlegroundTeamQueue teamQueue = this.GetTeamQueue(side);
            BattlegroundRelation  request   = new BattlegroundRelation(teamQueue, chrs);

            teamQueue.Enqueue(request);
            return(request);
        }
        /// <summary>
        /// Enqueues the given Character(s) for the given side
        /// </summary>
        public BattlegroundRelation Enqueue(ICharacterSet chrs, BattlegroundSide side)
        {
            var queue   = GetTeamQueue(side);
            var request = new BattlegroundRelation(queue, chrs);

            queue.Enqueue(request);

            return(request);
        }
Exemple #7
0
 /// <summary>
 /// Removes up to the given amount of players from the Queues
 /// and adds them to the Battleground.
 /// </summary>
 /// <param name="amount"></param>
 /// <remarks>Map-Context required. Cannot be used once the Battleground is over.</remarks>
 /// <returns>The amount of remaining players</returns>
 public int ProcessPendingPlayers(BattlegroundSide side, int amount)
 {
     this.EnsureContext();
     if (this._instanceQueue == null)
     {
         return(0);
     }
     amount -= this._instanceQueue.GetTeamQueue(side).DequeueCharacters(amount, this);
     if (amount > 0)
     {
         amount -= this._parentQueue.GetTeamQueue(side).DequeueCharacters(amount, this);
     }
     return(amount);
 }
Exemple #8
0
        protected void DoTryJoin(Character chr, bool asGroup, BattlegroundSide side)
        {
            this.EnsureContext();
            if (!chr.IsInWorld || !this.IsOpen)
            {
                return;
            }
            BattlegroundTeam team         = this.GetTeam(side);
            ICharacterSet    characterSet = this._instanceQueue.GetTeamQueue(side).GetCharacterSet(chr, asGroup);

            if (characterSet == null)
            {
                return;
            }
            team.Enqueue(characterSet);
        }
Exemple #9
0
		public BattlegroundTeam(BattlegroundTeamQueue queue, BattlegroundSide side, Battleground battleground)
		{
			Queue = queue;
			Side = side;
			_battleground = battleground;

			var templ = battleground.Template;
			if (side == BattlegroundSide.Alliance)
			{
				_startPosition = templ.AllianceStartPosition;
				_startOrientation = templ.AllianceStartOrientation;
			}
			else
			{
				_startPosition = templ.HordeStartPosition;
				_startOrientation = templ.HordeStartOrientation;
			}
		}
Exemple #10
0
        public BattlegroundTeam(BattlegroundTeamQueue queue, BattlegroundSide side, Battleground battleground)
        {
            this.Queue         = queue;
            this.Side          = side;
            this._battleground = battleground;
            BattlegroundTemplate template = battleground.Template;

            if (side == BattlegroundSide.Alliance)
            {
                this._startPosition    = template.AllianceStartPosition;
                this._startOrientation = template.AllianceStartOrientation;
            }
            else
            {
                this._startPosition    = template.HordeStartPosition;
                this._startOrientation = template.HordeStartOrientation;
            }
        }
Exemple #11
0
        public BattlegroundTeam(BattlegroundTeamQueue queue, BattlegroundSide side, Battleground battleground)
        {
            Queue         = queue;
            Side          = side;
            _battleground = battleground;

            var templ = battleground.Template;

            if (side == BattlegroundSide.Alliance)
            {
                _startPosition    = templ.AllianceStartPosition;
                _startOrientation = templ.AllianceStartOrientation;
            }
            else
            {
                _startPosition    = templ.HordeStartPosition;
                _startOrientation = templ.HordeStartOrientation;
            }
        }
Exemple #12
0
        /// <summary>Is called when a Character logs back in</summary>
        protected internal virtual bool LogBackIn(Character chr)
        {
            BattlegroundSide battlegroundTeam = chr.Record.BattlegroundTeam;
            BattlegroundTeam team             = this.GetTeam(battlegroundTeam);

            if (battlegroundTeam != BattlegroundSide.End && !team.IsFull)
            {
                BattlegroundTeamQueue queue = team.Queue;
                int queueIndex =
                    chr.Battlegrounds.AddRelation(new BattlegroundRelation(queue, (ICharacterSet)chr, false));
                chr.Battlegrounds.Invitation = new BattlegroundInvitation(team, queueIndex);
            }
            else if (!chr.Role.IsStaff)
            {
                this.TeleportOutside(chr);
                return(false);
            }

            return(true);
        }
 /// <summary>
 /// Tries to enqueue the given character or his whole group for the given battleground.
 /// </summary>
 /// <param name="chr">the character who enqueued</param>
 /// <param name="asGroup">whether or not to enqueue the character or his/her group</param>
 public void TryEnqueue(Character chr, bool asGroup, uint instanceId, BattlegroundSide side)
 {
     // specific instance given
     if (instanceId != 0)
     {
         var queue = GetQueue(chr);
         if (queue != null)
         {
             var bg = queue.GetBattleground(instanceId);
             if (bg != null && bg.HasQueue)
             {
                 bg.TryJoin(chr, asGroup, side);
             }
         }
     }
     else
     {
         var teamQueue = GetQueue(chr).GetTeamQueue(side);
         teamQueue.Enqueue(chr, asGroup);
     }
 }
 /// <summary>
 /// Tries to enqueue the given character or his whole group for the given battleground.
 /// </summary>
 /// <param name="chr">the character who enqueued</param>
 /// <param name="asGroup">whether or not to enqueue the character or his/her group</param>
 public void TryEnqueue(Character chr, bool asGroup, uint instanceId, BattlegroundSide side)
 {
     if (instanceId != 0U)
     {
         GlobalBattlegroundQueue queue = this.GetQueue(chr);
         if (queue == null)
         {
             return;
         }
         Battleground battleground = queue.GetBattleground(instanceId);
         if (battleground == null || !battleground.HasQueue)
         {
             return;
         }
         battleground.TryJoin(chr, asGroup, side);
     }
     else
     {
         this.GetQueue(chr).GetTeamQueue(side).Enqueue(chr, asGroup);
     }
 }
Exemple #15
0
        /// <summary>
        /// Removes up to the given amount of players from the Queues
        /// and adds them to the Battleground.
        /// </summary>
        /// <param name="amount"></param>
        /// <remarks>Map-Context required. Cannot be used once the Battleground is over.</remarks>
        /// <returns>The amount of remaining players</returns>
        public int ProcessPendingPlayers(BattlegroundSide side, int amount)
        {
            EnsureContext();

            if (_instanceQueue == null)
            {
                return(0);
            }

            // dequeue from the instance queue first
            amount -= _instanceQueue.GetTeamQueue(side).DequeueCharacters(amount, this);

            if (amount > 0)
            {
                // we have slots left, try to pull from the global queue
                amount -= _parentQueue.GetTeamQueue(side).DequeueCharacters(amount, this);
            }

            // return the number of player slots that didn't get filled
            return(amount);
        }
Exemple #16
0
        public static void SendPvpData(IPacketReceiver reciever, BattlegroundSide side, Battleground bg)
        {
            bg.EnsureContext();

            using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_PVP_LOG_DATA, 10 + bg.PlayerCount * 40))
            {
            	var winner = bg.Winner;

                packet.Write(bg.IsArena);
                if (bg.IsArena)
                {
                    // TODO: Arena
                    for (var i = 0; i < 2; i++)
                    {
                        packet.Write(0); // old rating
                        packet.Write(3999); // new rating (3000 + diff)
                        packet.Write(0); // matchmaking value (lvl group/rank?)
                    }

                    packet.WriteCString(string.Empty); // arena team names
                    packet.WriteCString(string.Empty);
                }

                var isFinished = bg.Winner != null;
                packet.Write(isFinished);
                if (isFinished)
                {
                    packet.Write((byte)bg.Winner.Side);
                }

				var chrs = bg.Characters;

				var chrCount = 0;
            	var chrCountPos = packet.Position;
            	packet.Position += 4;
                for (var i = 0; i < chrCount; i++)
                {
                	var chr = chrs[i];
					if (!chr.IsInBattleground)
					{
						continue;
					}

                	var stats = chr.Battlegrounds.Stats;

                	++chrCount;
                    packet.Write(chr.EntityId); // player guid
					packet.Write(stats.KillingBlows);

                    if (bg.IsArena)
					{
                        packet.Write(winner != null && chr.Battlegrounds.Team == winner); // is on the winning team
                    }
                    else
                    {
						packet.Write(stats.HonorableKills);
						packet.Write(stats.Deaths);
						packet.Write(stats.BonusHonor);
                    }

					packet.Write(stats.TotalDamage);
					packet.Write(stats.TotalHealing);

                    packet.Write(stats.SpecialStatCount);

                	stats.WriteSpecialStats(packet);
                }

            	packet.Position = chrCountPos;
            	packet.Write(chrCount);

                reciever.Send(packet);
            }
        }
 protected BattlegroundTeamQueue(BattlegroundQueue parentQueue, BattlegroundSide side)
 {
     this._parentQueue = parentQueue;
     this.m_Side       = side;
 }
		protected BattlegroundTeamQueue(BattlegroundQueue parentQueue, BattlegroundSide side)
		{
			_parentQueue = parentQueue;
			m_Side = side;
		}
Exemple #19
0
 public static BattlegroundSide GetOppositeSide(this BattlegroundSide side)
 {
     return(side == BattlegroundSide.Alliance ? BattlegroundSide.Horde : BattlegroundSide.Alliance);
 }
Exemple #20
0
		protected void DoTryJoin(Character chr, bool asGroup, BattlegroundSide side)
		{
			EnsureContext();

			// if the character isn't in game, they can't join.
			if (!chr.IsInWorld)
				return;

			// can't join if the battleground isn't open
			if (!IsOpen)
				return;

			var team = GetTeam(side);
			var teamQueue = _instanceQueue.GetTeamQueue(side);

			var chrs = teamQueue.GetCharacterSet(chr, asGroup);
			if (chrs != null)
			{
				team.Enqueue(chrs);
			}
		}
Exemple #21
0
		/// <summary>
		/// Returns the <see cref="BattlegroundTeam"/> of the given side
		/// </summary>
		/// <param name="side"></param>
		/// <returns></returns>
		public BattlegroundTeam GetTeam(BattlegroundSide side)
		{
			return _teams[(int)side];
		}
Exemple #22
0
		/// <summary>
		/// TODO: Spawn the side's flag
		/// Finalizes a capture (Flag changes colour (de/respawns, casts spells, etc)
		/// </summary>
		public void Capture()
		{
			var stats = (ArathiStats)Capturer.Battlegrounds.Stats;
			stats.BasesAssaulted++;

			if (Capturer.Battlegrounds.Team.Side == BattlegroundSide.Horde)
			{
				Instance.HordeBaseCount++;
				BaseOwner = BattlegroundSide.Horde;
			}
			else
			{
				Instance.AllianceBaseCount++;
				BaseOwner = BattlegroundSide.Alliance;
			}

			// It takes a few minutes before a captured flag begins to give score.
			StartScoreTimer.Start(ScoreDelayMillis, 0);

			var evt = BaseCaptured;
			if (evt != null)
			{
				evt(Capturer);
			}
		}
 /// <summary>
 /// Enqueues a single Character to the global Queue of this Template
 /// </summary>
 /// <param name="chr"></param>
 /// <returns></returns>
 public BattlegroundRelation EnqueueCharacter(Character chr, BattlegroundSide side)
 {
     return(this.GetQueue(chr).Enqueue((ICharacterSet)chr, side));
 }
 public BattlegroundTeamQueue GetTeamQueue(BattlegroundSide side)
 {
     return(TeamQueues[(int)side]);
 }
 protected abstract BattlegroundTeamQueue CreateTeamQueue(BattlegroundSide side);
Exemple #26
0
		public BattlegroundTeamQueue GetTeamQueue(BattlegroundSide side)
		{
			return TeamQueues[(int)side];
		}
Exemple #27
0
		protected abstract BattlegroundTeamQueue CreateTeamQueue(BattlegroundSide side);
        public static void SendPvpData(IPacketReceiver reciever, BattlegroundSide side, Battleground bg)
        {
            bg.EnsureContext();

            using (var packet = new RealmPacketOut(RealmServerOpCode.MSG_PVP_LOG_DATA, 10 + bg.PlayerCount * 40))
            {
                var winner = bg.Winner;

                packet.Write(bg.IsArena);
                if (bg.IsArena)
                {
                    // TODO: Arena
                    for (var i = 0; i < 2; i++)
                    {
                        packet.Write(0);    // old rating
                        packet.Write(3999); // new rating (3000 + diff)
                        packet.Write(0);    // matchmaking value (lvl group/rank?)
                    }

                    packet.WriteCString(string.Empty); // arena team names
                    packet.WriteCString(string.Empty);
                }

                var isFinished = bg.Winner != null;
                packet.Write(isFinished);
                if (isFinished)
                {
                    packet.Write((byte)bg.Winner.Side);
                }

                var chrs = bg.Characters;
                List <BattlegroundStats> listStats = new List <BattlegroundStats>(chrs.Count);
                chrs.ForEach(chr => listStats.Add(chr.Battlegrounds.Stats));
                packet.Write(listStats.Count);

                for (var i = 0; i < listStats.Count; i++)
                {
                    var chr = chrs[i];
                    if (!chr.IsInBattleground)
                    {
                        continue;
                    }

                    var stats = chr.Battlegrounds.Stats;

                    packet.Write(chr.EntityId); // player guid
                    packet.Write(stats.KillingBlows);

                    if (bg.IsArena)
                    {
                        packet.Write(winner != null && chr.Battlegrounds.Team == winner); // is on the winning team
                    }
                    else
                    {
                        packet.Write(stats.HonorableKills);
                        packet.Write(stats.Deaths);
                        packet.Write(stats.BonusHonor);
                    }

                    packet.Write(stats.TotalDamage);
                    packet.Write(stats.TotalHealing);

                    packet.Write(stats.SpecialStatCount);

                    stats.WriteSpecialStats(packet);
                }

                reciever.Send(packet);
            }
        }
 /// <summary>
 /// Tries to enqueue the given Character or -if specified- his/her entire Group
 /// </summary>
 /// <param name="chr"></param>
 /// <param name="asGroup"></param>
 public void TryEnqueue(Character chr, bool asGroup, BattlegroundSide side)
 {
     this.TryEnqueue(chr, asGroup, 0U, side);
 }
Exemple #30
0
 /// <summary>
 /// Returns the <see cref="BattlegroundTeam"/> of the given side
 /// </summary>
 /// <param name="side"></param>
 /// <returns></returns>
 public BattlegroundTeam GetTeam(BattlegroundSide side)
 {
     return(_teams[(int)side]);
 }
		protected override BattlegroundTeamQueue CreateTeamQueue(BattlegroundSide side)
		{
			return new InstanceBGTeamQueue(this, side);
		}
Exemple #32
0
 /// <summary>
 /// Adds the given Character (or optionally his/her Group) to the Queue of this Battleground if possible.
 /// Make sure that HasQueue is true before calling this method.
 /// </summary>
 /// <param name="chr"></param>
 /// <param name="asGroup"></param>
 public void TryJoin(Character chr, bool asGroup, BattlegroundSide side)
 {
     ExecuteInContext(() => DoTryJoin(chr, asGroup, side));
 }
Exemple #33
0
 public GlobalBGTeamQueue(GlobalBattlegroundQueue parentQueue, BattlegroundSide side)
     : base(parentQueue, side)
 {
 }
 protected override BattlegroundTeamQueue CreateTeamQueue(BattlegroundSide side)
 {
     return(new InstanceBGTeamQueue(this, side));
 }
Exemple #35
0
		/// <summary>
		/// Adds the given Character (or optionally his/her Group) to the Queue of this Battleground if possible.
		/// Make sure that HasQueue is true before calling this method.
		/// </summary>
		/// <param name="chr"></param>
		/// <param name="asGroup"></param>
		public void TryJoin(Character chr, bool asGroup, BattlegroundSide side)
		{
			ExecuteInContext(() => DoTryJoin(chr, asGroup, side));
		}
 protected override BattlegroundTeamQueue CreateTeamQueue(BattlegroundSide side)
 {
     return((BattlegroundTeamQueue) new GlobalBGTeamQueue(this, side));
 }
Exemple #37
0
		/// <summary>
		/// Removes up to the given amount of players from the Queues
		/// and adds them to the Battleground.
		/// </summary>
		/// <param name="amount"></param>
		/// <remarks>Map-Context required. Cannot be used once the Battleground is over.</remarks>
		/// <returns>The amount of remaining players</returns>
		public int ProcessPendingPlayers(BattlegroundSide side, int amount)
		{
			EnsureContext();

			if (_instanceQueue == null)
				return 0;

			// dequeue from the instance queue first
			amount -= _instanceQueue.GetTeamQueue(side).DequeueCharacters(amount, this);

			if (amount > 0)
			{
				// we have slots left, try to pull from the global queue
				amount -= _parentQueue.GetTeamQueue(side).DequeueCharacters(amount, this);
			}

			// return the number of player slots that didn't get filled
			return amount;
		}
Exemple #38
0
 public AVFaction GetFaction(BattlegroundSide side)
 {
     return Factions[(int)side];
 }
Exemple #39
0
 public InstanceBGTeamQueue(InstanceBattlegroundQueue parentQueue, BattlegroundSide side)
     : base(parentQueue, side)
 {
 }
		/// <summary>
		/// Enqueues a single Character to the global Queue of this Template
		/// </summary>
		/// <param name="chr"></param>
		/// <returns></returns>
		public BattlegroundRelation EnqueueCharacter(Character chr, BattlegroundSide side)
		{
			return GetQueue(chr).Enqueue(chr, side);
		}
		public InstanceBGTeamQueue(InstanceBattlegroundQueue parentQueue, BattlegroundSide side)
			: base(parentQueue, side)
		{
		}
		/// <summary>
		/// Tries to enqueue the given Character or -if specified- his/her entire Group
		/// </summary>
		/// <param name="chr"></param>
		/// <param name="asGroup"></param>
		public void TryEnqueue(Character chr, bool asGroup, BattlegroundSide side)
		{
			TryEnqueue(chr, asGroup, 0u, side);
		}
 public GlobalBGTeamQueue(GlobalBattlegroundQueue parentQueue, BattlegroundSide side)
     : base(parentQueue, side)
 {
 }
		/// <summary>
		/// Tries to enqueue the given character or his whole group for the given battleground.
		/// </summary>
		/// <param name="chr">the character who enqueued</param>
		/// <param name="asGroup">whether or not to enqueue the character or his/her group</param>
		public void TryEnqueue(Character chr, bool asGroup, uint instanceId, BattlegroundSide side)
		{
			// specific instance given
			if (instanceId != 0)
			{
				var queue = GetQueue(chr);
				if (queue != null)
				{
					var bg = queue.GetBattleground(instanceId);
					if (bg != null && bg.HasQueue)
					{
						bg.TryJoin(chr, asGroup, side);
					}
				}
			}
			else
			{
				var teamQueue = GetQueue(chr).GetTeamQueue(side);
				teamQueue.Enqueue(chr, asGroup);
			}
		}
Exemple #45
0
 public AVFaction GetFaction(BattlegroundSide side)
 {
     return(Factions[(int)side]);
 }
Exemple #46
0
 /// <summary>
 /// Adds the given Character (or optionally his/her Group) to the Queue of this Battleground if possible.
 /// Make sure that HasQueue is true before calling this method.
 /// </summary>
 /// <param name="chr"></param>
 /// <param name="asGroup"></param>
 public void TryJoin(Character chr, bool asGroup, BattlegroundSide side)
 {
     this.ExecuteInContext((Action)(() => this.DoTryJoin(chr, asGroup, side)));
 }