From e2caec12dccdd5e8b02f4524d151b7e99cfc63a7 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 31 Jan 2024 20:53:44 -0500 Subject: [PATCH] Core/GameObject: Implement ControlZone gameobject type Port From (https://github.com/TrinityCore/TrinityCore/commit/f96f041c3edadfb5f1f09705fe699c2d7a9ed423) --- Source/Game/Arenas/Zones/DalaranSewers.cs | 2 +- Source/Game/BattleFields/BattleField.cs | 389 ++------- Source/Game/BattleGrounds/BattleGround.cs | 14 +- .../Game/BattleGrounds/BattleGroundManager.cs | 1 + .../Game/BattleGrounds/Zones/ArathiBasin.cs | 6 +- Source/Game/BattleGrounds/Zones/EyeofStorm.cs | 763 ++++++++---------- .../BattleGrounds/Zones/StrandofAncients.cs | 8 +- Source/Game/Entities/GameObject/GameObject.cs | 268 +++++- Source/Game/Maps/ZoneScript.cs | 13 + Source/Game/OutdoorPVP/OutdoorPvP.cs | 357 ++------ .../OutdoorPVP/Zones/HellfirePeninsulaPvP.cs | 447 +++++----- 11 files changed, 998 insertions(+), 1270 deletions(-) diff --git a/Source/Game/Arenas/Zones/DalaranSewers.cs b/Source/Game/Arenas/Zones/DalaranSewers.cs index 67befc3d3..b35f40cfb 100644 --- a/Source/Game/Arenas/Zones/DalaranSewers.cs +++ b/Source/Game/Arenas/Zones/DalaranSewers.cs @@ -142,7 +142,7 @@ namespace Game.Arenas break; case DalaranSewersEvents.PipeKnockback: { - for (int i = DalaranSewersCreatureTypes.PipeKnockback1; i <= DalaranSewersCreatureTypes.PipeKnockback2; ++i) + for (uint i = DalaranSewersCreatureTypes.PipeKnockback1; i <= DalaranSewersCreatureTypes.PipeKnockback2; ++i) { Creature waterSpout = GetBGCreature(i); if (waterSpout != null) diff --git a/Source/Game/BattleFields/BattleField.cs b/Source/Game/BattleFields/BattleField.cs index 1273477f7..20e484b8e 100644 --- a/Source/Game/BattleFields/BattleField.cs +++ b/Source/Game/BattleFields/BattleField.cs @@ -90,9 +90,6 @@ namespace Game.BattleFields } } - foreach (var capturePoint in m_capturePoints.Values) - capturePoint.HandlePlayerLeave(player); - m_InvitedPlayers[player.GetTeamId()].Remove(player.GetGUID()); m_PlayersWillBeKick[player.GetTeamId()].Remove(player.GetGUID()); m_players[player.GetTeamId()].Remove(player.GetGUID()); @@ -121,7 +118,6 @@ namespace Game.BattleFields OnStartGrouping(); } - bool objective_changed = false; if (IsWarTime()) { if (m_uiKickAfkPlayersTimer <= diff) @@ -155,13 +151,9 @@ namespace Game.BattleFields } else m_uiKickDontAcceptTimer -= diff; - - foreach (var pair in m_capturePoints) - if (pair.Value.Update(diff)) - objective_changed = true; } - return objective_changed; + return false; } void InvitePlayersInZoneToQueue() @@ -268,6 +260,42 @@ namespace Game.BattleFields Log.outError(LogFilter.Battlefield, "Battlefield.InitStalker: could not spawn Stalker (Creature entry {0}), zone messeges will be un-available", entry); } + public override void ProcessEvent(WorldObject target, uint eventId, WorldObject invoker) + { + base.ProcessEvent(target, eventId, invoker); + + if (invoker != null) + { + GameObject gameobject = invoker.ToGameObject(); + if (gameobject != null) + { + if (gameobject.GetGoType() == GameObjectTypes.ControlZone) + { + if (!ControlZoneHandlers.TryGetValue(gameobject.GetEntry(), out BattleFieldControlZoneHandler handler)) + return; + + var controlzone = gameobject.GetGoInfo().ControlZone; + if (eventId == controlzone.CaptureEventAlliance) + handler.HandleCaptureEventAlliance(gameobject); + else if (eventId == controlzone.CaptureEventHorde) + handler.HandleCaptureEventHorde(gameobject); + else if (eventId == controlzone.ContestedEventAlliance) + handler.HandleContestedEventAlliance(gameobject); + else if (eventId == controlzone.ContestedEventHorde) + handler.HandleContestedEventHorde(gameobject); + else if (eventId == controlzone.NeutralEventAlliance) + handler.HandleNeutralEventAlliance(gameobject); + else if (eventId == controlzone.NeutralEventHorde) + handler.HandleNeutralEventHorde(gameobject); + else if (eventId == controlzone.ProgressEventAlliance) + handler.HandleProgressEventAlliance(gameobject); + else if (eventId == controlzone.ProgressEventHorde) + handler.HandleProgressEventHorde(gameobject); + } + } + } + } + void KickAfkPlayers() { for (byte team = 0; team < 2; ++team) @@ -439,19 +467,6 @@ namespace Game.BattleFields Global.CreatureTextMgr.SendChat(stalker, (byte)id, target); } - public void AddCapturePoint(BfCapturePoint cp) - { - if (m_capturePoints.ContainsKey(cp.GetCapturePointEntry())) - Log.outError(LogFilter.Battlefield, "Battlefield.AddCapturePoint: CapturePoint {0} already exists!", cp.GetCapturePointEntry()); - - m_capturePoints[cp.GetCapturePointEntry()] = cp; - } - - BfCapturePoint GetCapturePoint(uint entry) - { - return m_capturePoints.LookupByKey(entry); - } - public void RegisterZone(uint zoneId) { Global.BattleFieldMgr.AddZone(zoneId, this); @@ -657,8 +672,8 @@ namespace Game.BattleFields public uint GetTypeId() { return m_TypeId; } public uint GetZoneId() { return m_ZoneId; } - public uint GetMapId() { return m_MapId; } - public Map GetMap() { return m_Map; } + public uint GetMapId() { return m_MapId; } + public Map GetMap() { return m_Map; } public ulong GetQueueId() { return MathFunctions.MakePair64(m_BattleId | 0x20000, 0x1F100000); } // Return true if battle is start, false if battle is not started @@ -730,7 +745,7 @@ namespace Game.BattleFields protected uint m_DefenderTeam; // Map of the objectives belonging to this OutdoorPvP - Dictionary m_capturePoints = new(); + Dictionary ControlZoneHandlers = new(); // Players info maps protected List[] m_players = new List[2]; // Players in zone @@ -844,328 +859,18 @@ namespace Game.BattleFields protected BattleField m_Bf; } - public class BfCapturePoint + class BattleFieldControlZoneHandler : ControlZoneHandler { - public BfCapturePoint(BattleField battlefield) - { - m_Bf = battlefield; - m_capturePointGUID = ObjectGuid.Empty; - m_team = TeamId.Neutral; - m_value = 0; - m_minValue = 0.0f; - m_maxValue = 0.0f; - m_State = BattleFieldObjectiveStates.Neutral; - m_OldState = BattleFieldObjectiveStates.Neutral; - m_capturePointEntry = 0; - m_neutralValuePct = 0; - m_maxSpeed = 0; + BattleField _battlefield; - m_activePlayers[0] = new HashSet(); - m_activePlayers[1] = new HashSet(); + public BattleFieldControlZoneHandler(BattleField battlefield) + { + _battlefield = battlefield; } - public virtual bool HandlePlayerEnter(Player player) + public BattleField GetBattlefield() { - if (!m_capturePointGUID.IsEmpty()) - { - GameObject capturePoint = m_Bf.GetGameObject(m_capturePointGUID); - if (capturePoint != null) - { - player.SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldState1, 1); - player.SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldstate2, (uint)(Math.Ceiling((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f))); - player.SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldstate3, m_neutralValuePct); - } - } - - return m_activePlayers[player.GetTeamId()].Add(player.GetGUID()); + return _battlefield; } - - public virtual void HandlePlayerLeave(Player player) - { - if (!m_capturePointGUID.IsEmpty()) - { - GameObject capturePoint = m_Bf.GetGameObject(m_capturePointGUID); - if (capturePoint != null) - player.SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldState1, 0); - } - - m_activePlayers[player.GetTeamId()].Remove(player.GetGUID()); - } - - public virtual void SendChangePhase() - { - if (m_capturePointGUID.IsEmpty()) - return; - - GameObject capturePoint = m_Bf.GetGameObject(m_capturePointGUID); - if (capturePoint != null) - { - // send this too, sometimes the slider disappears, dunno why :( - SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldState1, 1); - // send these updates to only the ones in this objective - SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldstate2, (uint)Math.Ceiling((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); - // send this too, sometimes it resets :S - SendUpdateWorldState(capturePoint.GetGoInfo().ControlZone.worldstate3, m_neutralValuePct); - } - } - - public bool SetCapturePointData(GameObject capturePoint) - { - Cypher.Assert(capturePoint != null); - - Log.outError(LogFilter.Battlefield, "Creating capture point {0}", capturePoint.GetEntry()); - - m_capturePointGUID = capturePoint.GetGUID(); - m_capturePointEntry = capturePoint.GetEntry(); - - // check info existence - GameObjectTemplate goinfo = capturePoint.GetGoInfo(); - if (goinfo.type != GameObjectTypes.ControlZone) - { - Log.outError(LogFilter.Server, "OutdoorPvP: GO {0} is not capture point!", capturePoint.GetEntry()); - return false; - } - - // get the needed values from goinfo - m_maxValue = goinfo.ControlZone.maxTime; - m_maxSpeed = m_maxValue / (goinfo.ControlZone.minTime != 0 ? goinfo.ControlZone.minTime : 60); - m_neutralValuePct = goinfo.ControlZone.neutralPercent; - m_minValue = m_maxValue * goinfo.ControlZone.neutralPercent / 100; - - if (m_team == TeamId.Alliance) - { - m_value = m_maxValue; - m_State = BattleFieldObjectiveStates.Alliance; - } - else - { - m_value = -m_maxValue; - m_State = BattleFieldObjectiveStates.Horde; - } - - return true; - } - - GameObject GetCapturePointGo() - { - return m_Bf.GetGameObject(m_capturePointGUID); - } - - bool DelCapturePoint() - { - if (!m_capturePointGUID.IsEmpty()) - { - GameObject capturePoint = m_Bf.GetGameObject(m_capturePointGUID); - if (capturePoint != null) - { - capturePoint.SetRespawnTime(0); // not save respawn time - capturePoint.Delete(); - capturePoint.Dispose(); - } - m_capturePointGUID.Clear(); - } - - return true; - } - - public virtual bool Update(uint diff) - { - if (m_capturePointGUID.IsEmpty()) - return false; - - GameObject capturePoint = m_Bf.GetGameObject(m_capturePointGUID); - if (capturePoint != null) - { - float radius = capturePoint.GetGoInfo().ControlZone.radius; - - for (byte team = 0; team < SharedConst.PvpTeamsCount; ++team) - { - foreach (var guid in m_activePlayers[team]) - { - Player player = Global.ObjAccessor.FindPlayer(guid); - if (player != null) - { - if (!capturePoint.IsWithinDistInMap(player, radius) || !player.IsOutdoorPvPActive()) - HandlePlayerLeave(player); - } - } - } - - List players = new(); - var checker = new AnyPlayerInObjectRangeCheck(capturePoint, radius); - var searcher = new PlayerListSearcher(capturePoint, players, checker); - Cell.VisitWorldObjects(capturePoint, searcher, radius); - - foreach (Player player in players) - { - if (player.IsOutdoorPvPActive()) - { - if (m_activePlayers[player.GetTeamId()].Add(player.GetGUID())) - HandlePlayerEnter(player); - } - } - } - - // get the difference of numbers - float fact_diff = ((float)m_activePlayers[TeamId.Alliance].Count - m_activePlayers[TeamId.Horde].Count) * diff / 1000; - if (MathFunctions.fuzzyEq(fact_diff, 0.0f)) - return false; - - Team Challenger; - float maxDiff = m_maxSpeed * diff; - - if (fact_diff < 0) - { - // horde is in majority, but it's already horde-controlled . no change - if (m_State == BattleFieldObjectiveStates.Horde && m_value <= -m_maxValue) - return false; - - if (fact_diff < -maxDiff) - fact_diff = -maxDiff; - - Challenger = Team.Horde; - } - else - { - // ally is in majority, but it's already ally-controlled . no change - if (m_State == BattleFieldObjectiveStates.Alliance && m_value >= m_maxValue) - return false; - - if (fact_diff > maxDiff) - fact_diff = maxDiff; - - Challenger = Team.Alliance; - } - - float oldValue = m_value; - uint oldTeam = m_team; - - m_OldState = m_State; - - m_value += fact_diff; - - if (m_value < -m_minValue) // red - { - if (m_value < -m_maxValue) - m_value = -m_maxValue; - m_State = BattleFieldObjectiveStates.Horde; - m_team = TeamId.Horde; - } - else if (m_value > m_minValue) // blue - { - if (m_value > m_maxValue) - m_value = m_maxValue; - m_State = BattleFieldObjectiveStates.Alliance; - m_team = TeamId.Alliance; - } - else if (oldValue * m_value <= 0) // grey, go through mid point - { - // if challenger is ally, then n.a challenge - if (Challenger == Team.Alliance) - m_State = BattleFieldObjectiveStates.NeutralAllianceChallenge; - // if challenger is horde, then n.h challenge - else if (Challenger == Team.Horde) - m_State = BattleFieldObjectiveStates.NeutralHordeChallenge; - m_team = TeamId.Neutral; - } - else // grey, did not go through mid point - { - // old phase and current are on the same side, so one team challenges the other - if (Challenger == Team.Alliance && (m_OldState == BattleFieldObjectiveStates.Horde || m_OldState == BattleFieldObjectiveStates.NeutralHordeChallenge)) - m_State = BattleFieldObjectiveStates.HordeAllianceChallenge; - else if (Challenger == Team.Horde && (m_OldState == BattleFieldObjectiveStates.Alliance || m_OldState == BattleFieldObjectiveStates.NeutralAllianceChallenge)) - m_State = BattleFieldObjectiveStates.AllianceHordeChallenge; - m_team = TeamId.Neutral; - } - - if (MathFunctions.fuzzyNe(m_value, oldValue)) - SendChangePhase(); - - if (m_OldState != m_State) - { - if (oldTeam != m_team) - ChangeTeam(oldTeam); - return true; - } - - return false; - } - - void SendUpdateWorldState(uint field, uint value) - { - for (byte team = 0; team < SharedConst.PvpTeamsCount; ++team) - { - foreach (var guid in m_activePlayers[team]) // send to all players present in the area - { - Player player = Global.ObjAccessor.FindPlayer(guid); - if (player != null) - player.SendUpdateWorldState(field, value); - } - } - } - - void SendObjectiveComplete(uint id, ObjectGuid guid) - { - uint team; - switch (m_State) - { - case BattleFieldObjectiveStates.Alliance: - team = TeamId.Alliance; - break; - case BattleFieldObjectiveStates.Horde: - team = TeamId.Horde; - break; - default: - return; - } - - // send to all players present in the area - foreach (var _guid in m_activePlayers[team]) - { - Player player = Global.ObjAccessor.FindPlayer(_guid); - if (player != null) - player.KilledMonsterCredit(id, guid); - } - } - - bool IsInsideObjective(Player player) - { - return m_activePlayers[player.GetTeamId()].Contains(player.GetGUID()); - } - - public virtual void ChangeTeam(uint oldTeam) { } - - public uint GetCapturePointEntry() { return m_capturePointEntry; } - uint GetTeamId() { return m_team; } - - // active Players in the area of the objective, 0 - alliance, 1 - horde - HashSet[] m_activePlayers = new HashSet[SharedConst.PvpTeamsCount]; - - // Total shift needed to capture the objective - float m_maxValue; - float m_minValue; - - // Maximum speed of capture - float m_maxSpeed; - - // The status of the objective - float m_value; - protected uint m_team; - - // Objective states - BattleFieldObjectiveStates m_OldState; - BattleFieldObjectiveStates m_State; - - // Neutral value on capture bar - uint m_neutralValuePct; - - // Battlefield this objective belongs to - protected BattleField m_Bf; - - // Capture point entry - uint m_capturePointEntry; - - // Gameobject related to that capture point - ObjectGuid m_capturePointGUID; } } diff --git a/Source/Game/BattleGrounds/BattleGround.cs b/Source/Game/BattleGrounds/BattleGround.cs index 215de378a..0a381dec3 100644 --- a/Source/Game/BattleGrounds/BattleGround.cs +++ b/Source/Game/BattleGrounds/BattleGround.cs @@ -42,7 +42,7 @@ namespace Game.BattleGrounds { // remove objects and creatures // (this is done automatically in mapmanager update, when the instance is reset after the reset time) - for (var i = 0; i < BgCreatures.Length; ++i) + for (uint i = 0; i < BgCreatures.Length; ++i) DelCreature(i); for (var i = 0; i < BgObjects.Length; ++i) @@ -1348,7 +1348,7 @@ namespace Game.BattleGrounds return obj; } - public Creature GetBGCreature(int type) + public Creature GetBGCreature(uint type) { if (BgCreatures[type].IsEmpty()) return null; @@ -1398,7 +1398,7 @@ namespace Game.BattleGrounds } } - public virtual Creature AddCreature(uint entry, int type, float x, float y, float z, float o, int teamIndex = TeamId.Neutral, uint respawntime = 0, Transport transport = null) + public virtual Creature AddCreature(uint entry, uint type, float x, float y, float z, float o, int teamIndex = TeamId.Neutral, uint respawntime = 0, Transport transport = null) { Map map = FindBgMap(); if (map == null) @@ -1445,12 +1445,12 @@ namespace Game.BattleGrounds return creature; } - public Creature AddCreature(uint entry, int type, Position pos, int teamIndex = TeamId.Neutral, uint respawntime = 0, Transport transport = null) + public Creature AddCreature(uint entry, uint type, Position pos, int teamIndex = TeamId.Neutral, uint respawntime = 0, Transport transport = null) { return AddCreature(entry, type, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teamIndex, respawntime, transport); } - public bool DelCreature(int type) + public bool DelCreature(uint type) { if (BgCreatures[type].IsEmpty()) return true; @@ -1502,7 +1502,7 @@ namespace Game.BattleGrounds return false; } - public bool AddSpiritGuide(int type, float x, float y, float z, float o, int teamIndex) + public bool AddSpiritGuide(uint type, float x, float y, float z, float o, int teamIndex) { uint entry = (uint)(teamIndex == TeamId.Alliance ? BattlegroundCreatures.A_SpiritGuide : BattlegroundCreatures.H_SpiritGuide); @@ -1514,7 +1514,7 @@ namespace Game.BattleGrounds return false; } - public bool AddSpiritGuide(int type, Position pos, int teamIndex = TeamId.Neutral) + public bool AddSpiritGuide(uint type, Position pos, int teamIndex = TeamId.Neutral) { return AddSpiritGuide(type, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teamIndex); } diff --git a/Source/Game/BattleGrounds/BattleGroundManager.cs b/Source/Game/BattleGrounds/BattleGroundManager.cs index 49488a1a4..eafbb0ec2 100644 --- a/Source/Game/BattleGrounds/BattleGroundManager.cs +++ b/Source/Game/BattleGrounds/BattleGroundManager.cs @@ -11,6 +11,7 @@ using System; using System.Collections.Generic; using System.Linq; using Game.BattleGrounds.Zones; +using Game.BattleGrounds.Zones.EyeofStorm; namespace Game.BattleGrounds { diff --git a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs index 154bf2ab6..4ee0760da 100644 --- a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs +++ b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs @@ -353,9 +353,9 @@ namespace Game.BattleGrounds.Zones if (capturedNodes >= 4) CastSpellOnTeam(BattlegroundConst.AbQuestReward4Bases, team); - Creature trigger = !BgCreatures[node + 7].IsEmpty() ? GetBGCreature(node + 7) : null; // 0-6 spirit guides + Creature trigger = !BgCreatures[node + 7].IsEmpty() ? GetBGCreature(node + 7u) : null; // 0-6 spirit guides if (trigger == null) - trigger = AddCreature(SharedConst.WorldTrigger, node + 7, NodePositions[node], GetTeamIndexByTeamId(team)); + trigger = AddCreature(SharedConst.WorldTrigger, node + 7u, NodePositions[node], GetTeamIndexByTeamId(team)); //add bonus honor aura trigger creature when node is accupied //cast bonus aura (+50% honor in 25yards) @@ -374,7 +374,7 @@ namespace Game.BattleGrounds.Zones return; //remove bonus honor aura trigger creature when node is lost - DelCreature(node + 7);//null checks are in DelCreature! 0-6 spirit guides + DelCreature(node + 7u);//null checks are in DelCreature! 0-6 spirit guides DelCreature(node); diff --git a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs index b4f9bf778..e3d513111 100644 --- a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs +++ b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs @@ -3,21 +3,22 @@ using Framework.Constants; using Game.Entities; +using Game.Maps; using Game.Networking.Packets; using System.Collections.Generic; -namespace Game.BattleGrounds.Zones +namespace Game.BattleGrounds.Zones.EyeofStorm { class BgEyeofStorm : Battleground { public BgEyeofStorm(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { - BgObjects = new ObjectGuid[EotSObjectTypes.Max]; - BgCreatures= new ObjectGuid[EotSCreaturesTypes.Max]; - m_Points_Trigger[EotSPoints.FelReaver] = EotSPointsTrigger.FelReaverBuff; - m_Points_Trigger[EotSPoints.BloodElf] = EotSPointsTrigger.BloodElfBuff; - m_Points_Trigger[EotSPoints.DraeneiRuins] = EotSPointsTrigger.DraeneiRuinsBuff; - m_Points_Trigger[EotSPoints.MageTower] = EotSPointsTrigger.MageTowerBuff; + BgObjects = new ObjectGuid[ObjectTypes.Max]; + BgCreatures = new ObjectGuid[CreaturesTypes.Max]; + m_Points_Trigger[Points.FelReaver] = PointsTrigger.FelReaverBuff; + m_Points_Trigger[Points.BloodElf] = PointsTrigger.BloodElfBuff; + m_Points_Trigger[Points.DraeneiRuins] = PointsTrigger.DraeneiRuinsBuff; + m_Points_Trigger[Points.MageTower] = PointsTrigger.MageTowerBuff; m_HonorScoreTics[TeamId.Alliance] = 0; m_HonorScoreTics[TeamId.Horde] = 0; m_TeamPointsCount[TeamId.Alliance] = 0; @@ -25,24 +26,24 @@ namespace Game.BattleGrounds.Zones m_FlagKeeper.Clear(); m_DroppedFlagGUID.Clear(); m_FlagCapturedBgObjectType = 0; - m_FlagState = EotSFlagState.OnBase; + m_FlagState = FlagState.OnBase; m_FlagsTimer = 0; m_TowerCapCheckTimer = 0; m_PointAddingTimer = 0; m_HonorTics = 0; - for (byte i = 0; i < EotSPoints.PointsMax; ++i) + for (byte i = 0; i < Points.PointsMax; ++i) { m_PointOwnedByTeam[i] = Team.Other; - m_PointState[i] = EotSPointState.Uncontrolled; - m_PointBarStatus[i] = EotSProgressBarConsts.ProgressBarStateMiddle; + m_PointState[i] = PointState.Uncontrolled; + m_PointBarStatus[i] = ProgressBarConsts.ProgressBarStateMiddle; m_LastPointCaptureStatus[i] = BattlegroundPointCaptureStatus.Neutral; } - for (byte i = 0; i < EotSPoints.PointsMax + 1; ++i) + for (byte i = 0; i < Points.PointsMax + 1; ++i) m_PlayersNearPoint[i] = new List(); - for (byte i = 0; i < 2 * EotSPoints.PointsMax; ++i) + for (byte i = 0; i < 2 * Points.PointsMax; ++i) m_CurrentPointPlayersCount[i] = 0; } @@ -53,69 +54,55 @@ namespace Game.BattleGrounds.Zones m_PointAddingTimer -= (int)diff; if (m_PointAddingTimer <= 0) { - m_PointAddingTimer = EotSMisc.FPointsTickTime; + m_PointAddingTimer = Misc.FPointsTickTime; if (m_TeamPointsCount[TeamId.Alliance] > 0) - AddPoints(Team.Alliance, EotSMisc.TickPoints[m_TeamPointsCount[TeamId.Alliance] - 1]); + AddPoints(Team.Alliance, Misc.TickPoints[m_TeamPointsCount[TeamId.Alliance] - 1]); if (m_TeamPointsCount[TeamId.Horde] > 0) - AddPoints(Team.Horde, EotSMisc.TickPoints[m_TeamPointsCount[TeamId.Horde] - 1]); + AddPoints(Team.Horde, Misc.TickPoints[m_TeamPointsCount[TeamId.Horde] - 1]); } - if (m_FlagState == EotSFlagState.WaitRespawn || m_FlagState == EotSFlagState.OnGround) + if (m_FlagState == FlagState.WaitRespawn || m_FlagState == FlagState.OnGround) { m_FlagsTimer -= (int)diff; if (m_FlagsTimer < 0) { m_FlagsTimer = 0; - if (m_FlagState == EotSFlagState.WaitRespawn) + if (m_FlagState == FlagState.WaitRespawn) RespawnFlag(true); else RespawnFlagAfterDrop(); } } - - m_TowerCapCheckTimer -= (int)diff; - if (m_TowerCapCheckTimer <= 0) - { - //check if player joined point - /*I used this order of calls, because although we will check if one player is in gameobject's distance 2 times - but we can count of players on current point in CheckSomeoneLeftPoint - */ - CheckSomeoneJoinedPoint(); - //check if player left point - CheckSomeoneLeftPo(); - UpdatePointStatuses(); - m_TowerCapCheckTimer = EotSMisc.FPointsTickTime; - } } } public override void StartingEventCloseDoors() { - SpawnBGObject(EotSObjectTypes.DoorA, BattlegroundConst.RespawnImmediately); - SpawnBGObject(EotSObjectTypes.DoorH, BattlegroundConst.RespawnImmediately); + SpawnBGObject(ObjectTypes.DoorA, BattlegroundConst.RespawnImmediately); + SpawnBGObject(ObjectTypes.DoorH, BattlegroundConst.RespawnImmediately); - for (int i = EotSObjectTypes.ABannerFelReaverCenter; i < EotSObjectTypes.Max; ++i) + for (int i = ObjectTypes.ABannerFelReaverCenter; i < ObjectTypes.Max; ++i) SpawnBGObject(i, BattlegroundConst.RespawnOneDay); } public override void StartingEventOpenDoors() { - SpawnBGObject(EotSObjectTypes.DoorA, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSObjectTypes.DoorH, BattlegroundConst.RespawnOneDay); + SpawnBGObject(ObjectTypes.DoorA, BattlegroundConst.RespawnOneDay); + SpawnBGObject(ObjectTypes.DoorH, BattlegroundConst.RespawnOneDay); - for (int i = EotSObjectTypes.NBannerFelReaverLeft; i <= EotSObjectTypes.FlagNetherstorm; ++i) + for (int i = ObjectTypes.NBannerFelReaverLeft; i <= ObjectTypes.FlagNetherstorm; ++i) SpawnBGObject(i, BattlegroundConst.RespawnImmediately); - for (int i = 0; i < EotSPoints.PointsMax; ++i) + for (int i = 0; i < Points.PointsMax; ++i) { //randomly spawn buff byte buff = (byte)RandomHelper.URand(0, 2); - SpawnBGObject(EotSObjectTypes.SpeedbuffFelReaver + buff + i * 3, BattlegroundConst.RespawnImmediately); + SpawnBGObject(ObjectTypes.SpeedbuffFelReaver + buff + i * 3, BattlegroundConst.RespawnImmediately); } // Achievement: Flurry - TriggerGameEvent(EotSMisc.EventStartBattle); + TriggerGameEvent(Misc.EventStartBattle); } void AddPoints(Team Team, uint Points) @@ -133,10 +120,10 @@ namespace Game.BattleGrounds.Zones BattlegroundPointCaptureStatus GetPointCaptureStatus(uint point) { - if (m_PointBarStatus[point] >= EotSProgressBarConsts.ProgressBarAliControlled) + if (m_PointBarStatus[point] >= ProgressBarConsts.ProgressBarAliControlled) return BattlegroundPointCaptureStatus.AllianceControlled; - if (m_PointBarStatus[point] <= EotSProgressBarConsts.ProgressBarHordeControlled) + if (m_PointBarStatus[point] <= ProgressBarConsts.ProgressBarHordeControlled) return BattlegroundPointCaptureStatus.HordeControlled; if (m_CurrentPointPlayersCount[2 * point] == m_CurrentPointPlayersCount[2 * point + 1]) @@ -146,157 +133,13 @@ namespace Game.BattleGrounds.Zones ? BattlegroundPointCaptureStatus.AllianceCapturing : BattlegroundPointCaptureStatus.HordeCapturing; } - - void CheckSomeoneJoinedPoint() - { - GameObject obj; - for (byte i = 0; i < EotSPoints.PointsMax; ++i) - { - obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]); - if (obj != null) - { - byte j = 0; - while (j < m_PlayersNearPoint[EotSPoints.PointsMax].Count) - { - Player player = Global.ObjAccessor.FindPlayer(m_PlayersNearPoint[EotSPoints.PointsMax][j]); - if (player == null) - { - Log.outError(LogFilter.Battleground, "BattlegroundEY:CheckSomeoneJoinedPoint: Player ({0}) could not be found!", m_PlayersNearPoint[EotSPoints.PointsMax][j].ToString()); - ++j; - continue; - } - if (player.CanCaptureTowerPoint() && player.IsWithinDistInMap(obj, (float)EotSProgressBarConsts.PointRadius)) - { - //player joined point! - //show progress bar - player.SendUpdateWorldState(EotSWorldStateIds.ProgressBarPercentGrey, (uint)EotSProgressBarConsts.ProgressBarPercentGrey); - player.SendUpdateWorldState(EotSWorldStateIds.ProgressBarStatus, (uint)m_PointBarStatus[i]); - player.SendUpdateWorldState(EotSWorldStateIds.ProgressBarShow, (uint)EotSProgressBarConsts.ProgressBarShow); - //add player to point - m_PlayersNearPoint[i].Add(m_PlayersNearPoint[EotSPoints.PointsMax][j]); - //remove player from "free space" - m_PlayersNearPoint[EotSPoints.PointsMax].RemoveAt(j); - } - else - ++j; - } - } - } - } - - void CheckSomeoneLeftPo() - { - //reset current point counts - for (byte i = 0; i < 2 * EotSPoints.PointsMax; ++i) - m_CurrentPointPlayersCount[i] = 0; - - GameObject obj; - for (byte i = 0; i < EotSPoints.PointsMax; ++i) - { - obj = GetBgMap().GetGameObject(BgObjects[EotSObjectTypes.TowerCapFelReaver + i]); - if (obj != null) - { - byte j = 0; - while (j < m_PlayersNearPoint[i].Count) - { - Player player = Global.ObjAccessor.FindPlayer(m_PlayersNearPoint[i][j]); - if (player == null) - { - Log.outError(LogFilter.Battleground, "BattlegroundEY:CheckSomeoneLeftPoint Player ({0}) could not be found!", m_PlayersNearPoint[i][j].ToString()); - //move non-existing players to "free space" - this will cause many errors showing in log, but it is a very important bug - m_PlayersNearPoint[EotSPoints.PointsMax].Add(m_PlayersNearPoint[i][j]); - m_PlayersNearPoint[i].RemoveAt(j); - continue; - } - if (!player.CanCaptureTowerPoint() || !player.IsWithinDistInMap(obj, (float)EotSProgressBarConsts.PointRadius)) - //move player out of point (add him to players that are out of points - { - m_PlayersNearPoint[EotSPoints.PointsMax].Add(m_PlayersNearPoint[i][j]); - m_PlayersNearPoint[i].RemoveAt(j); - player.SendUpdateWorldState(EotSWorldStateIds.ProgressBarShow, (uint)EotSProgressBarConsts.ProgressBarDontShow); - } - else - { - //player is neat flag, so update count: - m_CurrentPointPlayersCount[2 * i + GetTeamIndexByTeamId(GetPlayerTeam(player.GetGUID()))]++; - ++j; - } - } - } - } - } - - void UpdatePointStatuses() - { - for (byte point = 0; point < EotSPoints.PointsMax; ++point) - { - if (!m_PlayersNearPoint[point].Empty()) - { - //count new point bar status: - int pointDelta = (int)(m_CurrentPointPlayersCount[2 * point]) - (int)(m_CurrentPointPlayersCount[2 * point + 1]); - MathFunctions.RoundToInterval(ref pointDelta, -(int)EotSProgressBarConsts.PointMaxCapturersCount, EotSProgressBarConsts.PointMaxCapturersCount); - m_PointBarStatus[point] += pointDelta; - - if (m_PointBarStatus[point] > EotSProgressBarConsts.ProgressBarAliControlled) - //point is fully alliance's - m_PointBarStatus[point] = EotSProgressBarConsts.ProgressBarAliControlled; - if (m_PointBarStatus[point] < EotSProgressBarConsts.ProgressBarHordeControlled) - //point is fully horde's - m_PointBarStatus[point] = EotSProgressBarConsts.ProgressBarHordeControlled; - - uint pointOwnerTeamId; - //find which team should own this point - if (m_PointBarStatus[point] <= EotSProgressBarConsts.ProgressBarNeutralLow) - pointOwnerTeamId = (uint)Team.Horde; - else if (m_PointBarStatus[point] >= EotSProgressBarConsts.ProgressBarNeutralHigh) - pointOwnerTeamId = (uint)Team.Alliance; - else - pointOwnerTeamId = (uint)EotSPointState.NoOwner; - - for (byte i = 0; i < m_PlayersNearPoint[point].Count; ++i) - { - Player player = Global.ObjAccessor.FindPlayer(m_PlayersNearPoint[point][i]); - if (player != null) - { - player.SendUpdateWorldState(EotSWorldStateIds.ProgressBarStatus, (uint)m_PointBarStatus[point]); - Team team = GetPlayerTeam(player.GetGUID()); - //if point owner changed we must evoke event! - if (pointOwnerTeamId != (uint)m_PointOwnedByTeam[point]) - { - //point was uncontrolled and player is from team which captured point - if (m_PointState[point] == EotSPointState.Uncontrolled && (uint)team == pointOwnerTeamId) - EventTeamCapturedPoint(player, point); - - //point was under control and player isn't from team which controlled it - if (m_PointState[point] == EotSPointState.UnderControl && team != m_PointOwnedByTeam[point]) - EventTeamLostPoint(player, point); - } - - // @workaround The original AreaTrigger is covered by a bigger one and not triggered on client side. - if (point == EotSPoints.FelReaver && m_PointOwnedByTeam[point] == team) - if (m_FlagState != 0 && GetFlagPickerGUID() == player.GetGUID()) - if (player.GetDistance(2044.0f, 1729.729f, 1190.03f) < 3.0f) - EventPlayerCapturedFlag(player, EotSObjectTypes.FlagFelReaver); - } - } - } - - BattlegroundPointCaptureStatus captureStatus = GetPointCaptureStatus(point); - if (m_LastPointCaptureStatus[point] != captureStatus) - { - UpdateWorldState(EotSMisc.m_PointsIconStruct[point].WorldStateAllianceStatusBarIcon, (int)(captureStatus == BattlegroundPointCaptureStatus.AllianceControlled ? 2 : (captureStatus == BattlegroundPointCaptureStatus.AllianceCapturing ? 1 : 0))); - UpdateWorldState(EotSMisc.m_PointsIconStruct[point].WorldStateHordeStatusBarIcon, (int)(captureStatus == BattlegroundPointCaptureStatus.HordeControlled ? 2 : (captureStatus == BattlegroundPointCaptureStatus.HordeCapturing ? 1 : 0))); - m_LastPointCaptureStatus[point] = captureStatus; - } - } - } void UpdateTeamScore(int team) { uint score = GetTeamScore(team); - if (score >= EotSScoreIds.MaxTeamScore) + if (score >= ScoreIds.MaxTeamScore) { - score = EotSScoreIds.MaxTeamScore; + score = ScoreIds.MaxTeamScore; if (team == TeamId.Alliance) EndBattleground(Team.Alliance); else @@ -304,9 +147,9 @@ namespace Game.BattleGrounds.Zones } if (team == TeamId.Alliance) - UpdateWorldState(EotSWorldStateIds.AllianceResources, (int)score); + UpdateWorldState(WorldStateIds.AllianceResources, (int)score); else - UpdateWorldState(EotSWorldStateIds.HordeResources, (int)score); + UpdateWorldState(WorldStateIds.HordeResources, (int)score); } public override void EndBattleground(Team winner) @@ -326,29 +169,29 @@ namespace Game.BattleGrounds.Zones void UpdatePointsCount(Team team) { if (team == Team.Alliance) - UpdateWorldState(EotSWorldStateIds.AllianceBase, (int)m_TeamPointsCount[TeamId.Alliance]); + UpdateWorldState(WorldStateIds.AllianceBase, (int)m_TeamPointsCount[TeamId.Alliance]); else - UpdateWorldState(EotSWorldStateIds.HordeBase, (int)m_TeamPointsCount[TeamId.Horde]); + UpdateWorldState(WorldStateIds.HordeBase, (int)m_TeamPointsCount[TeamId.Horde]); } - void UpdatePointsIcons(Team team, int Point) + void UpdatePointsIcons(Team team, uint Point) { //we MUST firstly send 0, after that we can send 1!!! - if (m_PointState[Point] == EotSPointState.UnderControl) + if (m_PointState[Point] == PointState.UnderControl) { - UpdateWorldState(EotSMisc.m_PointsIconStruct[Point].WorldStateControlIndex, 0); + UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateControlIndex, 0); if (team == Team.Alliance) - UpdateWorldState(EotSMisc.m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1); + UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1); else - UpdateWorldState(EotSMisc.m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 1); + UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 1); } else { if (team == Team.Alliance) - UpdateWorldState(EotSMisc.m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0); + UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0); else - UpdateWorldState(EotSMisc.m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 0); - UpdateWorldState(EotSMisc.m_PointsIconStruct[Point].WorldStateControlIndex, 1); + UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 0); + UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateControlIndex, 1); } } @@ -359,13 +202,13 @@ namespace Game.BattleGrounds.Zones if (!isInBattleground) PlayerScores[player.GetGUID()] = new BgEyeOfStormScore(player.GetGUID(), player.GetBGTeam()); - m_PlayersNearPoint[EotSPoints.PointsMax].Add(player.GetGUID()); + m_PlayersNearPoint[Points.PointsMax].Add(player.GetGUID()); } public override void RemovePlayer(Player player, ObjectGuid guid, Team team) { // sometimes flag aura not removed :( - for (int j = EotSPoints.PointsMax; j >= 0; --j) + for (int j = Points.PointsMax; j >= 0; --j) { for (int i = 0; i < m_PlayersNearPoint[j].Count; ++i) if (m_PlayersNearPoint[j][i] == guid) @@ -398,25 +241,25 @@ namespace Game.BattleGrounds.Zones if (GetStatus() == BattlegroundStatus.WaitJoin && !entered) TeleportPlayerToExploitLocation(player); break; - case EotSPointsTrigger.BloodElfPoint: - if (m_PointState[EotSPoints.BloodElf] == EotSPointState.UnderControl && m_PointOwnedByTeam[EotSPoints.BloodElf] == GetPlayerTeam(player.GetGUID())) + case PointsTrigger.BloodElfPoint: + if (m_PointState[Points.BloodElf] == PointState.UnderControl && m_PointOwnedByTeam[Points.BloodElf] == GetPlayerTeam(player.GetGUID())) if (m_FlagState != 0 && GetFlagPickerGUID() == player.GetGUID()) - EventPlayerCapturedFlag(player, EotSObjectTypes.FlagBloodElf); + EventPlayerCapturedFlag(player, ObjectTypes.FlagBloodElf); break; - case EotSPointsTrigger.FelReaverPoint: - if (m_PointState[EotSPoints.FelReaver] == EotSPointState.UnderControl && m_PointOwnedByTeam[EotSPoints.FelReaver] == GetPlayerTeam(player.GetGUID())) + case PointsTrigger.FelReaverPoint: + if (m_PointState[Points.FelReaver] == PointState.UnderControl && m_PointOwnedByTeam[Points.FelReaver] == GetPlayerTeam(player.GetGUID())) if (m_FlagState != 0 && GetFlagPickerGUID() == player.GetGUID()) - EventPlayerCapturedFlag(player, EotSObjectTypes.FlagFelReaver); + EventPlayerCapturedFlag(player, ObjectTypes.FlagFelReaver); break; - case EotSPointsTrigger.MageTowerPoint: - if (m_PointState[EotSPoints.MageTower] == EotSPointState.UnderControl && m_PointOwnedByTeam[EotSPoints.MageTower] == GetPlayerTeam(player.GetGUID())) + case PointsTrigger.MageTowerPoint: + if (m_PointState[Points.MageTower] == PointState.UnderControl && m_PointOwnedByTeam[Points.MageTower] == GetPlayerTeam(player.GetGUID())) if (m_FlagState != 0 && GetFlagPickerGUID() == player.GetGUID()) - EventPlayerCapturedFlag(player, EotSObjectTypes.FlagMageTower); + EventPlayerCapturedFlag(player, ObjectTypes.FlagMageTower); break; - case EotSPointsTrigger.DraeneiRuinsPoint: - if (m_PointState[EotSPoints.DraeneiRuins] == EotSPointState.UnderControl && m_PointOwnedByTeam[EotSPoints.DraeneiRuins] == GetPlayerTeam(player.GetGUID())) + case PointsTrigger.DraeneiRuinsPoint: + if (m_PointState[Points.DraeneiRuins] == PointState.UnderControl && m_PointOwnedByTeam[Points.DraeneiRuins] == GetPlayerTeam(player.GetGUID())) if (m_FlagState != 0 && GetFlagPickerGUID() == player.GetGUID()) - EventPlayerCapturedFlag(player, EotSObjectTypes.FlagDraeneiRuins); + EventPlayerCapturedFlag(player, ObjectTypes.FlagDraeneiRuins); break; case 4512: case 4515: @@ -437,91 +280,96 @@ namespace Game.BattleGrounds.Zones public override bool SetupBattleground() { // doors - if (!AddObject(EotSObjectTypes.DoorA, EotSObjectIds.ADoorEyEntry, 2527.59716796875f, 1596.90625f, 1238.4544677734375f, 3.159139871597290039f, 0.173641681671142578f, 0.001514434814453125f, -0.98476982116699218f, 0.008638577535748481f, BattlegroundConst.RespawnImmediately) - || !AddObject(EotSObjectTypes.DoorH, EotSObjectIds.HDoorEyEntry, 1803.2066650390625f, 1539.486083984375f, 1238.4544677734375f, 3.13898324966430664f, 0.173647880554199218f, 0.0f, 0.984807014465332031f, 0.001244877814315259f, BattlegroundConst.RespawnImmediately) + if (!AddObject(ObjectTypes.DoorA, ObjectIds.ADoorEyEntry, 2527.59716796875f, 1596.90625f, 1238.4544677734375f, 3.159139871597290039f, 0.173641681671142578f, 0.001514434814453125f, -0.98476982116699218f, 0.008638577535748481f, BattlegroundConst.RespawnImmediately) + || !AddObject(ObjectTypes.DoorH, ObjectIds.HDoorEyEntry, 1803.2066650390625f, 1539.486083984375f, 1238.4544677734375f, 3.13898324966430664f, 0.173647880554199218f, 0.0f, 0.984807014465332031f, 0.001244877814315259f, BattlegroundConst.RespawnImmediately) // banners (alliance) - || !AddObject(EotSObjectTypes.ABannerFelReaverCenter, EotSObjectIds.ABannerEyEntry, 2057.47265625f, 1735.109130859375f, 1188.065673828125f, 5.305802345275878906f, 0.0f, 0.0f, -0.46947097778320312f, 0.882947921752929687f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerFelReaverLeft, EotSObjectIds.ABannerEyEntry, 2032.248291015625f, 1729.546875f, 1191.2296142578125f, 1.797688722610473632f, 0.0f, 0.0f, 0.7826080322265625f, 0.622514784336090087f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerFelReaverRight, EotSObjectIds.ABannerEyEntry, 2092.338623046875f, 1775.4739990234375f, 1187.504150390625f, 5.811946868896484375f, 0.0f, 0.0f, -0.2334451675415039f, 0.972369968891143798f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerBloodElfCenter, EotSObjectIds.ABannerEyEntry, 2047.1910400390625f, 1349.1927490234375f, 1189.0032958984375f, 4.660029888153076171f, 0.0f, 0.0f, -0.72537422180175781f, 0.688354730606079101f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerBloodElfLeft, EotSObjectIds.ABannerEyEntry, 2074.319580078125f, 1385.779541015625f, 1194.7203369140625f, 0.488691210746765136f, 0.0f, 0.0f, 0.241921424865722656f, 0.970295846462249755f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerBloodElfRight, EotSObjectIds.ABannerEyEntry, 2025.125f, 1386.123291015625f, 1192.7354736328125f, 2.391098499298095703f, 0.0f, 0.0f, 0.930417060852050781f, 0.366502493619918823f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerDraeneiRuinsCenter, EotSObjectIds.ABannerEyEntry, 2276.796875f, 1400.407958984375f, 1196.333740234375f, 2.44346022605895996f, 0.0f, 0.0f, 0.939692497253417968f, 0.34202045202255249f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerDraeneiRuinsLeft, EotSObjectIds.ABannerEyEntry, 2305.776123046875f, 1404.5572509765625f, 1199.384765625f, 1.745326757431030273f, 0.0f, 0.0f, 0.766043663024902343f, 0.642788589000701904f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerDraeneiRuinsRight, EotSObjectIds.ABannerEyEntry, 2245.395751953125f, 1366.4132080078125f, 1195.27880859375f, 2.216565132141113281f, 0.0f, 0.0f, 0.894933700561523437f, 0.44619917869567871f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerMageTowerCenter, EotSObjectIds.ABannerEyEntry, 2270.8359375f, 1784.080322265625f, 1186.757080078125f, 2.426007747650146484f, 0.0f, 0.0f, 0.936672210693359375f, 0.350207358598709106f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerMageTowerLeft, EotSObjectIds.ABannerEyEntry, 2269.126708984375f, 1737.703125f, 1186.8145751953125f, 0.994837164878845214f, 0.0f, 0.0f, 0.477158546447753906f, 0.878817260265350341f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.ABannerMageTowerRight, EotSObjectIds.ABannerEyEntry, 2300.85595703125f, 1741.24658203125f, 1187.793212890625f, 5.497788906097412109f, 0.0f, 0.0f, -0.38268280029296875f, 0.923879802227020263f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerFelReaverCenter, ObjectIds.ABannerEyEntry, 2057.47265625f, 1735.109130859375f, 1188.065673828125f, 5.305802345275878906f, 0.0f, 0.0f, -0.46947097778320312f, 0.882947921752929687f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerFelReaverLeft, ObjectIds.ABannerEyEntry, 2032.248291015625f, 1729.546875f, 1191.2296142578125f, 1.797688722610473632f, 0.0f, 0.0f, 0.7826080322265625f, 0.622514784336090087f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerFelReaverRight, ObjectIds.ABannerEyEntry, 2092.338623046875f, 1775.4739990234375f, 1187.504150390625f, 5.811946868896484375f, 0.0f, 0.0f, -0.2334451675415039f, 0.972369968891143798f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerBloodElfCenter, ObjectIds.ABannerEyEntry, 2047.1910400390625f, 1349.1927490234375f, 1189.0032958984375f, 4.660029888153076171f, 0.0f, 0.0f, -0.72537422180175781f, 0.688354730606079101f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerBloodElfLeft, ObjectIds.ABannerEyEntry, 2074.319580078125f, 1385.779541015625f, 1194.7203369140625f, 0.488691210746765136f, 0.0f, 0.0f, 0.241921424865722656f, 0.970295846462249755f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerBloodElfRight, ObjectIds.ABannerEyEntry, 2025.125f, 1386.123291015625f, 1192.7354736328125f, 2.391098499298095703f, 0.0f, 0.0f, 0.930417060852050781f, 0.366502493619918823f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerDraeneiRuinsCenter, ObjectIds.ABannerEyEntry, 2276.796875f, 1400.407958984375f, 1196.333740234375f, 2.44346022605895996f, 0.0f, 0.0f, 0.939692497253417968f, 0.34202045202255249f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerDraeneiRuinsLeft, ObjectIds.ABannerEyEntry, 2305.776123046875f, 1404.5572509765625f, 1199.384765625f, 1.745326757431030273f, 0.0f, 0.0f, 0.766043663024902343f, 0.642788589000701904f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerDraeneiRuinsRight, ObjectIds.ABannerEyEntry, 2245.395751953125f, 1366.4132080078125f, 1195.27880859375f, 2.216565132141113281f, 0.0f, 0.0f, 0.894933700561523437f, 0.44619917869567871f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerMageTowerCenter, ObjectIds.ABannerEyEntry, 2270.8359375f, 1784.080322265625f, 1186.757080078125f, 2.426007747650146484f, 0.0f, 0.0f, 0.936672210693359375f, 0.350207358598709106f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerMageTowerLeft, ObjectIds.ABannerEyEntry, 2269.126708984375f, 1737.703125f, 1186.8145751953125f, 0.994837164878845214f, 0.0f, 0.0f, 0.477158546447753906f, 0.878817260265350341f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.ABannerMageTowerRight, ObjectIds.ABannerEyEntry, 2300.85595703125f, 1741.24658203125f, 1187.793212890625f, 5.497788906097412109f, 0.0f, 0.0f, -0.38268280029296875f, 0.923879802227020263f, BattlegroundConst.RespawnOneDay) // banners (horde) - || !AddObject(EotSObjectTypes.HBannerFelReaverCenter, EotSObjectIds.HBannerEyEntry, 2057.45654296875f, 1735.07470703125f, 1187.9063720703125f, 5.35816192626953125f, 0.0f, 0.0f, -0.446197509765625f, 0.894934535026550292f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerFelReaverLeft, EotSObjectIds.HBannerEyEntry, 2032.251708984375f, 1729.532958984375f, 1190.3251953125f, 1.867502212524414062f, 0.0f, 0.0f, 0.803856849670410156f, 0.594822824001312255f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerFelReaverRight, EotSObjectIds.HBannerEyEntry, 2092.354248046875f, 1775.4583740234375f, 1187.079345703125f, 5.881760597229003906f, 0.0f, 0.0f, -0.19936752319335937f, 0.979924798011779785f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerBloodElfCenter, EotSObjectIds.HBannerEyEntry, 2047.1978759765625f, 1349.1875f, 1188.5650634765625f, 4.625123500823974609f, 0.0f, 0.0f, -0.73727703094482421f, 0.67559051513671875f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerBloodElfLeft, EotSObjectIds.HBannerEyEntry, 2074.3056640625f, 1385.7725830078125f, 1194.4686279296875f, 0.471238493919372558f, 0.0f, 0.0f, 0.233445167541503906f, 0.972369968891143798f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerBloodElfRight, EotSObjectIds.HBannerEyEntry, 2025.09375f, 1386.12158203125f, 1192.6536865234375f, 2.373644113540649414f, 0.0f, 0.0f, 0.927183151245117187f, 0.37460830807685852f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerDraeneiRuinsCenter, EotSObjectIds.HBannerEyEntry, 2276.798583984375f, 1400.4410400390625f, 1196.2200927734375f, 2.495818138122558593f, 0.0f, 0.0f, 0.948323249816894531f, 0.317305892705917358f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerDraeneiRuinsLeft, EotSObjectIds.HBannerEyEntry, 2305.763916015625f, 1404.5972900390625f, 1199.3333740234375f, 1.640606880187988281f, 0.0f, 0.0f, 0.731352806091308593f, 0.6819993257522583f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerDraeneiRuinsRight, EotSObjectIds.HBannerEyEntry, 2245.382080078125f, 1366.454833984375f, 1195.1815185546875f, 2.373644113540649414f, 0.0f, 0.0f, 0.927183151245117187f, 0.37460830807685852f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerMageTowerCenter, EotSObjectIds.HBannerEyEntry, 2270.869873046875f, 1784.0989990234375f, 1186.4384765625f, 2.356194972991943359f, 0.0f, 0.0f, 0.923879623413085937f, 0.382683247327804565f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerMageTowerLeft, EotSObjectIds.HBannerEyEntry, 2268.59716796875f, 1737.0191650390625f, 1186.75390625f, 0.942476630210876464f, 0.0f, 0.0f, 0.453989982604980468f, 0.891006767749786376f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.HBannerMageTowerRight, EotSObjectIds.HBannerEyEntry, 2301.01904296875f, 1741.4930419921875f, 1187.48974609375f, 5.375615119934082031f, 0.0f, 0.0f, -0.4383707046508789f, 0.898794233798980712f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerFelReaverCenter, ObjectIds.HBannerEyEntry, 2057.45654296875f, 1735.07470703125f, 1187.9063720703125f, 5.35816192626953125f, 0.0f, 0.0f, -0.446197509765625f, 0.894934535026550292f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerFelReaverLeft, ObjectIds.HBannerEyEntry, 2032.251708984375f, 1729.532958984375f, 1190.3251953125f, 1.867502212524414062f, 0.0f, 0.0f, 0.803856849670410156f, 0.594822824001312255f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerFelReaverRight, ObjectIds.HBannerEyEntry, 2092.354248046875f, 1775.4583740234375f, 1187.079345703125f, 5.881760597229003906f, 0.0f, 0.0f, -0.19936752319335937f, 0.979924798011779785f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerBloodElfCenter, ObjectIds.HBannerEyEntry, 2047.1978759765625f, 1349.1875f, 1188.5650634765625f, 4.625123500823974609f, 0.0f, 0.0f, -0.73727703094482421f, 0.67559051513671875f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerBloodElfLeft, ObjectIds.HBannerEyEntry, 2074.3056640625f, 1385.7725830078125f, 1194.4686279296875f, 0.471238493919372558f, 0.0f, 0.0f, 0.233445167541503906f, 0.972369968891143798f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerBloodElfRight, ObjectIds.HBannerEyEntry, 2025.09375f, 1386.12158203125f, 1192.6536865234375f, 2.373644113540649414f, 0.0f, 0.0f, 0.927183151245117187f, 0.37460830807685852f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerDraeneiRuinsCenter, ObjectIds.HBannerEyEntry, 2276.798583984375f, 1400.4410400390625f, 1196.2200927734375f, 2.495818138122558593f, 0.0f, 0.0f, 0.948323249816894531f, 0.317305892705917358f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerDraeneiRuinsLeft, ObjectIds.HBannerEyEntry, 2305.763916015625f, 1404.5972900390625f, 1199.3333740234375f, 1.640606880187988281f, 0.0f, 0.0f, 0.731352806091308593f, 0.6819993257522583f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerDraeneiRuinsRight, ObjectIds.HBannerEyEntry, 2245.382080078125f, 1366.454833984375f, 1195.1815185546875f, 2.373644113540649414f, 0.0f, 0.0f, 0.927183151245117187f, 0.37460830807685852f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerMageTowerCenter, ObjectIds.HBannerEyEntry, 2270.869873046875f, 1784.0989990234375f, 1186.4384765625f, 2.356194972991943359f, 0.0f, 0.0f, 0.923879623413085937f, 0.382683247327804565f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerMageTowerLeft, ObjectIds.HBannerEyEntry, 2268.59716796875f, 1737.0191650390625f, 1186.75390625f, 0.942476630210876464f, 0.0f, 0.0f, 0.453989982604980468f, 0.891006767749786376f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.HBannerMageTowerRight, ObjectIds.HBannerEyEntry, 2301.01904296875f, 1741.4930419921875f, 1187.48974609375f, 5.375615119934082031f, 0.0f, 0.0f, -0.4383707046508789f, 0.898794233798980712f, BattlegroundConst.RespawnOneDay) // banners (natural) - || !AddObject(EotSObjectTypes.NBannerFelReaverCenter, EotSObjectIds.NBannerEyEntry, 2057.4931640625f, 1735.111083984375f, 1187.675537109375f, 5.340708732604980468f, 0.0f, 0.0f, -0.45398998260498046f, 0.891006767749786376f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerFelReaverLeft, EotSObjectIds.NBannerEyEntry, 2032.2569580078125f, 1729.5572509765625f, 1191.0802001953125f, 1.797688722610473632f, 0.0f, 0.0f, 0.7826080322265625f, 0.622514784336090087f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerFelReaverRight, EotSObjectIds.NBannerEyEntry, 2092.395751953125f, 1775.451416015625f, 1186.965576171875f, 5.89921426773071289f, 0.0f, 0.0f, -0.19080829620361328f, 0.981627285480499267f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerBloodElfCenter, EotSObjectIds.NBannerEyEntry, 2047.1875f, 1349.1944580078125f, 1188.5731201171875f, 4.642575740814208984f, 0.0f, 0.0f, -0.731353759765625f, 0.681998312473297119f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerBloodElfLeft, EotSObjectIds.NBannerEyEntry, 2074.3212890625f, 1385.76220703125f, 1194.362060546875f, 0.488691210746765136f, 0.0f, 0.0f, 0.241921424865722656f, 0.970295846462249755f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerBloodElfRight, EotSObjectIds.NBannerEyEntry, 2025.13720703125f, 1386.1336669921875f, 1192.5482177734375f, 2.391098499298095703f, 0.0f, 0.0f, 0.930417060852050781f, 0.366502493619918823f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerDraeneiRuinsCenter, EotSObjectIds.NBannerEyEntry, 2276.833251953125f, 1400.4375f, 1196.146728515625f, 2.478367090225219726f, 0.0f, 0.0f, 0.94551849365234375f, 0.325568377971649169f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerDraeneiRuinsLeft, EotSObjectIds.NBannerEyEntry, 2305.77783203125f, 1404.5364990234375f, 1199.246337890625f, 1.570795774459838867f, 0.0f, 0.0f, 0.707106590270996093f, 0.707106947898864746f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerDraeneiRuinsRight, EotSObjectIds.NBannerEyEntry, 2245.40966796875f, 1366.4410400390625f, 1195.1107177734375f, 2.356194972991943359f, 0.0f, 0.0f, 0.923879623413085937f, 0.382683247327804565f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerMageTowerCenter, EotSObjectIds.NBannerEyEntry, 2270.84033203125f, 1784.1197509765625f, 1186.1473388671875f, 2.303830623626708984f, 0.0f, 0.0f, 0.913544654846191406f, 0.406738430261611938f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerMageTowerLeft, EotSObjectIds.NBannerEyEntry, 2268.46533203125f, 1736.8385009765625f, 1186.742919921875f, 0.942476630210876464f, 0.0f, 0.0f, 0.453989982604980468f, 0.891006767749786376f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.NBannerMageTowerRight, EotSObjectIds.NBannerEyEntry, 2300.9931640625f, 1741.5504150390625f, 1187.10693359375f, 5.375615119934082031f, 0.0f, 0.0f, -0.4383707046508789f, 0.898794233798980712f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerFelReaverCenter, ObjectIds.NBannerEyEntry, 2057.4931640625f, 1735.111083984375f, 1187.675537109375f, 5.340708732604980468f, 0.0f, 0.0f, -0.45398998260498046f, 0.891006767749786376f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerFelReaverLeft, ObjectIds.NBannerEyEntry, 2032.2569580078125f, 1729.5572509765625f, 1191.0802001953125f, 1.797688722610473632f, 0.0f, 0.0f, 0.7826080322265625f, 0.622514784336090087f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerFelReaverRight, ObjectIds.NBannerEyEntry, 2092.395751953125f, 1775.451416015625f, 1186.965576171875f, 5.89921426773071289f, 0.0f, 0.0f, -0.19080829620361328f, 0.981627285480499267f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerBloodElfCenter, ObjectIds.NBannerEyEntry, 2047.1875f, 1349.1944580078125f, 1188.5731201171875f, 4.642575740814208984f, 0.0f, 0.0f, -0.731353759765625f, 0.681998312473297119f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerBloodElfLeft, ObjectIds.NBannerEyEntry, 2074.3212890625f, 1385.76220703125f, 1194.362060546875f, 0.488691210746765136f, 0.0f, 0.0f, 0.241921424865722656f, 0.970295846462249755f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerBloodElfRight, ObjectIds.NBannerEyEntry, 2025.13720703125f, 1386.1336669921875f, 1192.5482177734375f, 2.391098499298095703f, 0.0f, 0.0f, 0.930417060852050781f, 0.366502493619918823f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerDraeneiRuinsCenter, ObjectIds.NBannerEyEntry, 2276.833251953125f, 1400.4375f, 1196.146728515625f, 2.478367090225219726f, 0.0f, 0.0f, 0.94551849365234375f, 0.325568377971649169f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerDraeneiRuinsLeft, ObjectIds.NBannerEyEntry, 2305.77783203125f, 1404.5364990234375f, 1199.246337890625f, 1.570795774459838867f, 0.0f, 0.0f, 0.707106590270996093f, 0.707106947898864746f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerDraeneiRuinsRight, ObjectIds.NBannerEyEntry, 2245.40966796875f, 1366.4410400390625f, 1195.1107177734375f, 2.356194972991943359f, 0.0f, 0.0f, 0.923879623413085937f, 0.382683247327804565f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerMageTowerCenter, ObjectIds.NBannerEyEntry, 2270.84033203125f, 1784.1197509765625f, 1186.1473388671875f, 2.303830623626708984f, 0.0f, 0.0f, 0.913544654846191406f, 0.406738430261611938f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerMageTowerLeft, ObjectIds.NBannerEyEntry, 2268.46533203125f, 1736.8385009765625f, 1186.742919921875f, 0.942476630210876464f, 0.0f, 0.0f, 0.453989982604980468f, 0.891006767749786376f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.NBannerMageTowerRight, ObjectIds.NBannerEyEntry, 2300.9931640625f, 1741.5504150390625f, 1187.10693359375f, 5.375615119934082031f, 0.0f, 0.0f, -0.4383707046508789f, 0.898794233798980712f, BattlegroundConst.RespawnOneDay) // flags - || !AddObject(EotSObjectTypes.FlagNetherstorm, EotSObjectIds.Flag2EyEntry, 2174.444580078125f, 1569.421875f, 1159.852783203125f, 4.625123500823974609f, 0.0f, 0.0f, -0.73727703094482421f, 0.67559051513671875f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.FlagFelReaver, EotSObjectIds.Flag1EyEntry, 2044.28f, 1729.68f, 1189.96f, -0.017453f, 0, 0, 0.008727f, -0.999962f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.FlagBloodElf, EotSObjectIds.Flag1EyEntry, 2048.83f, 1393.65f, 1194.49f, 0.20944f, 0, 0, 0.104528f, 0.994522f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.FlagDraeneiRuins, EotSObjectIds.Flag1EyEntry, 2286.56f, 1402.36f, 1197.11f, 3.72381f, 0, 0, 0.957926f, -0.287016f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.FlagMageTower, EotSObjectIds.Flag1EyEntry, 2284.48f, 1731.23f, 1189.99f, 2.89725f, 0, 0, 0.992546f, 0.121869f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.FlagNetherstorm, ObjectIds.Flag2EyEntry, 2174.444580078125f, 1569.421875f, 1159.852783203125f, 4.625123500823974609f, 0.0f, 0.0f, -0.73727703094482421f, 0.67559051513671875f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.FlagFelReaver, ObjectIds.Flag1EyEntry, 2044.28f, 1729.68f, 1189.96f, -0.017453f, 0, 0, 0.008727f, -0.999962f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.FlagBloodElf, ObjectIds.Flag1EyEntry, 2048.83f, 1393.65f, 1194.49f, 0.20944f, 0, 0, 0.104528f, 0.994522f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.FlagDraeneiRuins, ObjectIds.Flag1EyEntry, 2286.56f, 1402.36f, 1197.11f, 3.72381f, 0, 0, 0.957926f, -0.287016f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.FlagMageTower, ObjectIds.Flag1EyEntry, 2284.48f, 1731.23f, 1189.99f, 2.89725f, 0, 0, 0.992546f, 0.121869f, BattlegroundConst.RespawnOneDay) // tower cap - || !AddObject(EotSObjectTypes.TowerCapFelReaver, EotSObjectIds.FrTowerCapEyEntry, 2024.600708f, 1742.819580f, 1195.157715f, 2.443461f, 0, 0, 0.939693f, 0.342020f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.TowerCapBloodElf, EotSObjectIds.BeTowerCapEyEntry, 2050.493164f, 1372.235962f, 1194.563477f, 1.710423f, 0, 0, 0.754710f, 0.656059f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.TowerCapDraeneiRuins, EotSObjectIds.DrTowerCapEyEntry, 2301.010498f, 1386.931641f, 1197.183472f, 1.570796f, 0, 0, 0.707107f, 0.707107f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.TowerCapMageTower, EotSObjectIds.HuTowerCapEyEntry, 2282.121582f, 1760.006958f, 1189.707153f, 1.919862f, 0, 0, 0.819152f, 0.573576f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.TowerCapFelReaver, ObjectIds.FrTowerCapEyEntry, 2024.600708f, 1742.819580f, 1195.157715f, 2.443461f, 0, 0, 0.939693f, 0.342020f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.TowerCapBloodElf, ObjectIds.BeTowerCapEyEntry, 2050.493164f, 1372.235962f, 1194.563477f, 1.710423f, 0, 0, 0.754710f, 0.656059f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.TowerCapDraeneiRuins, ObjectIds.DrTowerCapEyEntry, 2301.010498f, 1386.931641f, 1197.183472f, 1.570796f, 0, 0, 0.707107f, 0.707107f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.TowerCapMageTower, ObjectIds.HuTowerCapEyEntry, 2282.121582f, 1760.006958f, 1189.707153f, 1.919862f, 0, 0, 0.819152f, 0.573576f, BattlegroundConst.RespawnOneDay) // buffs - || !AddObject(EotSObjectTypes.SpeedbuffFelReaver, EotSObjectIds.SpeedBuffFelReaverEyEntry, 2046.462646484375f, 1749.1666259765625f, 1190.010498046875f, 5.410521507263183593f, 0.0f, 0.0f, -0.42261791229248046f, 0.906307935714721679f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.RegenbuffFelReaver, EotSObjectIds.RestorationBuffFelReaverEyEntry, 2046.462646484375f, 1749.1666259765625f, 1190.010498046875f, 5.410521507263183593f, 0.0f, 0.0f, -0.42261791229248046f, 0.906307935714721679f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.BerserkbuffFelReaver, EotSObjectIds.BerserkBuffFelReaverEyEntry, 2046.462646484375f, 1749.1666259765625f, 1190.010498046875f, 5.410521507263183593f, 0.0f, 0.0f, -0.42261791229248046f, 0.906307935714721679f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.SpeedbuffBloodElf, EotSObjectIds.SpeedBuffBloodElfEyEntry, 2050.46826171875f, 1372.2020263671875f, 1194.5634765625f, 1.675513744354248046f, 0.0f, 0.0f, 0.743144035339355468f, 0.669131457805633544f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.RegenbuffBloodElf, EotSObjectIds.RestorationBuffBloodElfEyEntry, 2050.46826171875f, 1372.2020263671875f, 1194.5634765625f, 1.675513744354248046f, 0.0f, 0.0f, 0.743144035339355468f, 0.669131457805633544f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.BerserkbuffBloodElf, EotSObjectIds.BerserkBuffBloodElfEyEntry, 2050.46826171875f, 1372.2020263671875f, 1194.5634765625f, 1.675513744354248046f, 0.0f, 0.0f, 0.743144035339355468f, 0.669131457805633544f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.SpeedbuffDraeneiRuins, EotSObjectIds.SpeedBuffDraeneiRuinsEyEntry, 2302.4765625f, 1391.244873046875f, 1197.7364501953125f, 1.762782454490661621f, 0.0f, 0.0f, 0.771624565124511718f, 0.636078238487243652f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.RegenbuffDraeneiRuins, EotSObjectIds.RestorationBuffDraeneiRuinsEyEntry, 2302.4765625f, 1391.244873046875f, 1197.7364501953125f, 1.762782454490661621f, 0.0f, 0.0f, 0.771624565124511718f, 0.636078238487243652f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.BerserkbuffDraeneiRuins, EotSObjectIds.BerserkBuffDraeneiRuinsEyEntry, 2302.4765625f, 1391.244873046875f, 1197.7364501953125f, 1.762782454490661621f, 0.0f, 0.0f, 0.771624565124511718f, 0.636078238487243652f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.SpeedbuffMageTower, EotSObjectIds.SpeedBuffMageTowerEyEntry, 2283.7099609375f, 1748.8699951171875f, 1189.7071533203125f, 4.782202720642089843f, 0.0f, 0.0f, -0.68199825286865234f, 0.731353819370269775f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.RegenbuffMageTower, EotSObjectIds.RestorationBuffMageTowerEyEntry, 2283.7099609375f, 1748.8699951171875f, 1189.7071533203125f, 4.782202720642089843f, 0.0f, 0.0f, -0.68199825286865234f, 0.731353819370269775f, BattlegroundConst.RespawnOneDay) - || !AddObject(EotSObjectTypes.BerserkbuffMageTower, EotSObjectIds.BerserkBuffMageTowerEyEntry, 2283.7099609375f, 1748.8699951171875f, 1189.7071533203125f, 4.782202720642089843f, 0.0f, 0.0f, -0.68199825286865234f, 0.731353819370269775f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.SpeedbuffFelReaver, ObjectIds.SpeedBuffFelReaverEyEntry, 2046.462646484375f, 1749.1666259765625f, 1190.010498046875f, 5.410521507263183593f, 0.0f, 0.0f, -0.42261791229248046f, 0.906307935714721679f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.RegenbuffFelReaver, ObjectIds.RestorationBuffFelReaverEyEntry, 2046.462646484375f, 1749.1666259765625f, 1190.010498046875f, 5.410521507263183593f, 0.0f, 0.0f, -0.42261791229248046f, 0.906307935714721679f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.BerserkbuffFelReaver, ObjectIds.BerserkBuffFelReaverEyEntry, 2046.462646484375f, 1749.1666259765625f, 1190.010498046875f, 5.410521507263183593f, 0.0f, 0.0f, -0.42261791229248046f, 0.906307935714721679f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.SpeedbuffBloodElf, ObjectIds.SpeedBuffBloodElfEyEntry, 2050.46826171875f, 1372.2020263671875f, 1194.5634765625f, 1.675513744354248046f, 0.0f, 0.0f, 0.743144035339355468f, 0.669131457805633544f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.RegenbuffBloodElf, ObjectIds.RestorationBuffBloodElfEyEntry, 2050.46826171875f, 1372.2020263671875f, 1194.5634765625f, 1.675513744354248046f, 0.0f, 0.0f, 0.743144035339355468f, 0.669131457805633544f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.BerserkbuffBloodElf, ObjectIds.BerserkBuffBloodElfEyEntry, 2050.46826171875f, 1372.2020263671875f, 1194.5634765625f, 1.675513744354248046f, 0.0f, 0.0f, 0.743144035339355468f, 0.669131457805633544f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.SpeedbuffDraeneiRuins, ObjectIds.SpeedBuffDraeneiRuinsEyEntry, 2302.4765625f, 1391.244873046875f, 1197.7364501953125f, 1.762782454490661621f, 0.0f, 0.0f, 0.771624565124511718f, 0.636078238487243652f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.RegenbuffDraeneiRuins, ObjectIds.RestorationBuffDraeneiRuinsEyEntry, 2302.4765625f, 1391.244873046875f, 1197.7364501953125f, 1.762782454490661621f, 0.0f, 0.0f, 0.771624565124511718f, 0.636078238487243652f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.BerserkbuffDraeneiRuins, ObjectIds.BerserkBuffDraeneiRuinsEyEntry, 2302.4765625f, 1391.244873046875f, 1197.7364501953125f, 1.762782454490661621f, 0.0f, 0.0f, 0.771624565124511718f, 0.636078238487243652f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.SpeedbuffMageTower, ObjectIds.SpeedBuffMageTowerEyEntry, 2283.7099609375f, 1748.8699951171875f, 1189.7071533203125f, 4.782202720642089843f, 0.0f, 0.0f, -0.68199825286865234f, 0.731353819370269775f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.RegenbuffMageTower, ObjectIds.RestorationBuffMageTowerEyEntry, 2283.7099609375f, 1748.8699951171875f, 1189.7071533203125f, 4.782202720642089843f, 0.0f, 0.0f, -0.68199825286865234f, 0.731353819370269775f, BattlegroundConst.RespawnOneDay) + || !AddObject(ObjectTypes.BerserkbuffMageTower, ObjectIds.BerserkBuffMageTowerEyEntry, 2283.7099609375f, 1748.8699951171875f, 1189.7071533203125f, 4.782202720642089843f, 0.0f, 0.0f, -0.68199825286865234f, 0.731353819370269775f, BattlegroundConst.RespawnOneDay) ) { Log.outError(LogFilter.Sql, "BatteGroundEY: Failed to spawn some objects. The battleground was not created."); return false; } - WorldSafeLocsEntry sg = Global.ObjectMgr.GetWorldSafeLoc(EotSGaveyardIds.MainAlliance); - if (sg == null || !AddSpiritGuide(EotSCreaturesTypes.SpiritMainAlliance, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.124139f, TeamId.Alliance)) + WorldSafeLocsEntry sg = Global.ObjectMgr.GetWorldSafeLoc(GaveyardIds.MainAlliance); + if (sg == null || !AddSpiritGuide(CreaturesTypes.SpiritMainAlliance, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.124139f, TeamId.Alliance)) { Log.outError(LogFilter.Sql, "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created."); return false; } - sg = Global.ObjectMgr.GetWorldSafeLoc(EotSGaveyardIds.MainHorde); - if (sg == null || !AddSpiritGuide(EotSCreaturesTypes.SpiritMainHorde, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.193953f, TeamId.Horde)) + sg = Global.ObjectMgr.GetWorldSafeLoc(GaveyardIds.MainHorde); + if (sg == null || !AddSpiritGuide(CreaturesTypes.SpiritMainHorde, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.193953f, TeamId.Horde)) { Log.outError(LogFilter.Sql, "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created."); return false; } + ControlZoneHandlers[ObjectIds.FrTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.FelReaver); + ControlZoneHandlers[ObjectIds.BeTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.BloodElf); + ControlZoneHandlers[ObjectIds.DrTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.DraeneiRuins); + ControlZoneHandlers[ObjectIds.HuTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.MageTower); + return true; } @@ -536,23 +384,23 @@ namespace Game.BattleGrounds.Zones m_TeamPointsCount[TeamId.Horde] = 0; m_HonorScoreTics[TeamId.Alliance] = 0; m_HonorScoreTics[TeamId.Horde] = 0; - m_FlagState = EotSFlagState.OnBase; + m_FlagState = FlagState.OnBase; m_FlagCapturedBgObjectType = 0; m_FlagKeeper.Clear(); m_DroppedFlagGUID.Clear(); m_PointAddingTimer = 0; m_TowerCapCheckTimer = 0; bool isBGWeekend = Global.BattlegroundMgr.IsBGWeekend(GetTypeID()); - m_HonorTics = (isBGWeekend) ? EotSMisc.EYWeekendHonorTicks : EotSMisc.NotEYWeekendHonorTicks; + m_HonorTics = (isBGWeekend) ? Misc.EYWeekendHonorTicks : Misc.NotEYWeekendHonorTicks; - for (byte i = 0; i < EotSPoints.PointsMax; ++i) + for (byte i = 0; i < Points.PointsMax; ++i) { m_PointOwnedByTeam[i] = Team.Other; - m_PointState[i] = EotSPointState.Uncontrolled; - m_PointBarStatus[i] = EotSProgressBarConsts.ProgressBarStateMiddle; + m_PointState[i] = PointState.Uncontrolled; + m_PointBarStatus[i] = ProgressBarConsts.ProgressBarStateMiddle; m_PlayersNearPoint[i].Clear(); } - m_PlayersNearPoint[EotSPoints.PlayersOutOfPoints].Clear(); + m_PlayersNearPoint[Points.PlayersOutOfPoints].Clear(); } void RespawnFlag(bool send_message) @@ -561,16 +409,16 @@ namespace Game.BattleGrounds.Zones SpawnBGObject((int)m_FlagCapturedBgObjectType, BattlegroundConst.RespawnOneDay); m_FlagCapturedBgObjectType = 0; - m_FlagState = EotSFlagState.OnBase; - SpawnBGObject(EotSObjectTypes.FlagNetherstorm, BattlegroundConst.RespawnImmediately); + m_FlagState = FlagState.OnBase; + SpawnBGObject(ObjectTypes.FlagNetherstorm, BattlegroundConst.RespawnImmediately); if (send_message) { - SendBroadcastText(EotSBroadcastTexts.FlagReset, ChatMsg.BgSystemNeutral); - PlaySoundToAll(EotSSoundIds.FlagReset); // flags respawned sound... + SendBroadcastText(BroadcastTextIds.FlagReset, ChatMsg.BgSystemNeutral); + PlaySoundToAll(SoundIds.FlagReset); // flags respawned sound... } - UpdateWorldState(EotSWorldStateIds.NetherstormFlag, 1); + UpdateWorldState(WorldStateIds.NetherstormFlag, 1); } void RespawnFlagAfterDrop() @@ -604,7 +452,7 @@ namespace Game.BattleGrounds.Zones if (IsFlagPickedup() && GetFlagPickerGUID() == player.GetGUID()) { SetFlagPicker(ObjectGuid.Empty); - player.RemoveAurasDueToSpell(EotSMisc.SpellNetherstormFlag); + player.RemoveAurasDueToSpell(Misc.SpellNetherstormFlag); } return; } @@ -616,19 +464,19 @@ namespace Game.BattleGrounds.Zones return; SetFlagPicker(ObjectGuid.Empty); - player.RemoveAurasDueToSpell(EotSMisc.SpellNetherstormFlag); - m_FlagState = EotSFlagState.OnGround; - m_FlagsTimer = EotSMisc.FlagRespawnTime; + player.RemoveAurasDueToSpell(Misc.SpellNetherstormFlag); + m_FlagState = FlagState.OnGround; + m_FlagsTimer = Misc.FlagRespawnTime; player.CastSpell(player, BattlegroundConst.SpellRecentlyDroppedFlag, true); - player.CastSpell(player, EotSMisc.SpellPlayerDroppedFlag, true); + player.CastSpell(player, Misc.SpellPlayerDroppedFlag, true); //this does not work correctly :((it should remove flag carrier name) - UpdateWorldState(EotSWorldStateIds.NetherstormFlagStateHorde, (int)EotSFlagState.WaitRespawn); - UpdateWorldState(EotSWorldStateIds.NetherstormFlagStateAlliance, (int)EotSFlagState.WaitRespawn); + UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)FlagState.WaitRespawn); + UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)FlagState.WaitRespawn); if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) - SendBroadcastText(EotSBroadcastTexts.FlagDropped, ChatMsg.BgSystemAlliance, null); + SendBroadcastText(BroadcastTextIds.FlagDropped, ChatMsg.BgSystemAlliance, null); else - SendBroadcastText(EotSBroadcastTexts.FlagDropped, ChatMsg.BgSystemHorde, null); + SendBroadcastText(BroadcastTextIds.FlagDropped, ChatMsg.BgSystemHorde, null); } public override void EventPlayerClickedOnFlag(Player player, GameObject target_obj) @@ -638,141 +486,136 @@ namespace Game.BattleGrounds.Zones if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) { - UpdateWorldState(EotSWorldStateIds.NetherstormFlagStateAlliance, (int)EotSFlagState.OnPlayer); - PlaySoundToAll(EotSSoundIds.FlagPickedUpAlliance); + UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)FlagState.OnPlayer); + PlaySoundToAll(SoundIds.FlagPickedUpAlliance); } else { - UpdateWorldState(EotSWorldStateIds.NetherstormFlagStateHorde, (int)EotSFlagState.OnPlayer); - PlaySoundToAll(EotSSoundIds.FlagPickedUpHorde); + UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)FlagState.OnPlayer); + PlaySoundToAll(SoundIds.FlagPickedUpHorde); } - if (m_FlagState == EotSFlagState.OnBase) - UpdateWorldState(EotSWorldStateIds.NetherstormFlag, 0); - m_FlagState = EotSFlagState.OnPlayer; + if (m_FlagState == FlagState.OnBase) + UpdateWorldState(WorldStateIds.NetherstormFlag, 0); + m_FlagState = FlagState.OnPlayer; - SpawnBGObject(EotSObjectTypes.FlagNetherstorm, BattlegroundConst.RespawnOneDay); + SpawnBGObject(ObjectTypes.FlagNetherstorm, BattlegroundConst.RespawnOneDay); SetFlagPicker(player.GetGUID()); //get flag aura on player - player.CastSpell(player, EotSMisc.SpellNetherstormFlag, true); + player.CastSpell(player, Misc.SpellNetherstormFlag, true); player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.PvPActive); if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) - SendBroadcastText(EotSBroadcastTexts.TakenFlag, ChatMsg.BgSystemAlliance, player); + SendBroadcastText(BroadcastTextIds.TakenFlag, ChatMsg.BgSystemAlliance, player); else - SendBroadcastText(EotSBroadcastTexts.TakenFlag, ChatMsg.BgSystemHorde, player); + SendBroadcastText(BroadcastTextIds.TakenFlag, ChatMsg.BgSystemHorde, player); } - void EventTeamLostPoint(Player player, int Point) + public void EventTeamLostPoint(Team team, uint point, WorldObject controlZone) { if (GetStatus() != BattlegroundStatus.InProgress) return; - //Natural point - Team Team = m_PointOwnedByTeam[Point]; - - if (Team == 0) + if (team == 0) return; - if (Team == Team.Alliance) + if (team == Team.Alliance) { m_TeamPointsCount[TeamId.Alliance]--; - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].DespawnObjectTypeAlliance, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 1, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].DespawnObjectTypeAlliance + 2, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_LosingPointTypes[point].DespawnObjectTypeAlliance, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_LosingPointTypes[point].DespawnObjectTypeAlliance + 1, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_LosingPointTypes[point].DespawnObjectTypeAlliance + 2, BattlegroundConst.RespawnOneDay); } else { m_TeamPointsCount[TeamId.Horde]--; - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].DespawnObjectTypeHorde, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].DespawnObjectTypeHorde + 1, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].DespawnObjectTypeHorde + 2, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_LosingPointTypes[point].DespawnObjectTypeHorde, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_LosingPointTypes[point].DespawnObjectTypeHorde + 1, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_LosingPointTypes[point].DespawnObjectTypeHorde + 2, BattlegroundConst.RespawnOneDay); } - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].SpawnNeutralObjectType, BattlegroundConst.RespawnImmediately); - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].SpawnNeutralObjectType + 1, BattlegroundConst.RespawnImmediately); - SpawnBGObject(EotSMisc.m_LosingPointTypes[Point].SpawnNeutralObjectType + 2, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_LosingPointTypes[point].SpawnNeutralObjectType, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_LosingPointTypes[point].SpawnNeutralObjectType + 1, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_LosingPointTypes[point].SpawnNeutralObjectType + 2, BattlegroundConst.RespawnImmediately); //buff isn't despawned - m_PointOwnedByTeam[Point] = Team.Other; - m_PointState[Point] = EotSPointState.NoOwner; + m_PointOwnedByTeam[point] = Team.Other; + m_PointState[point] = PointState.NoOwner; - if (Team == Team.Alliance) - SendBroadcastText(EotSMisc.m_LosingPointTypes[Point].MessageIdAlliance, ChatMsg.BgSystemAlliance, player); + if (team == Team.Alliance) + SendBroadcastText(Misc.m_LosingPointTypes[point].MessageIdAlliance, ChatMsg.BgSystemAlliance, controlZone); else - SendBroadcastText(EotSMisc.m_LosingPointTypes[Point].MessageIdHorde, ChatMsg.BgSystemHorde, player); + SendBroadcastText(Misc.m_LosingPointTypes[point].MessageIdHorde, ChatMsg.BgSystemHorde, controlZone); - UpdatePointsIcons(Team, Point); - UpdatePointsCount(Team); + UpdatePointsIcons(team, point); + UpdatePointsCount(team); //remove bonus honor aura trigger creature when node is lost - if (Point < EotSPoints.PointsMax) - DelCreature(Point + 6);//null checks are in DelCreature! 0-5 spirit guides + if (point < Points.PointsMax) + DelCreature(point + 6);//null checks are in DelCreature! 0-5 spirit guides } - void EventTeamCapturedPoint(Player player, int Point) + public void EventTeamCapturedPoint(Team team, uint point, WorldObject controlZone) { if (GetStatus() != BattlegroundStatus.InProgress) return; - Team Team = GetPlayerTeam(player.GetGUID()); + SpawnBGObject(Misc.m_CapturingPointTypes[point].DespawnNeutralObjectType, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_CapturingPointTypes[point].DespawnNeutralObjectType + 1, BattlegroundConst.RespawnOneDay); + SpawnBGObject(Misc.m_CapturingPointTypes[point].DespawnNeutralObjectType + 2, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].DespawnNeutralObjectType, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].DespawnNeutralObjectType + 1, BattlegroundConst.RespawnOneDay); - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].DespawnNeutralObjectType + 2, BattlegroundConst.RespawnOneDay); - - if (Team == Team.Alliance) + if (team == Team.Alliance) { m_TeamPointsCount[TeamId.Alliance]++; - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].SpawnObjectTypeAlliance, BattlegroundConst.RespawnImmediately); - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 1, BattlegroundConst.RespawnImmediately); - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].SpawnObjectTypeAlliance + 2, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_CapturingPointTypes[point].SpawnObjectTypeAlliance, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_CapturingPointTypes[point].SpawnObjectTypeAlliance + 1, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_CapturingPointTypes[point].SpawnObjectTypeAlliance + 2, BattlegroundConst.RespawnImmediately); } else { m_TeamPointsCount[TeamId.Horde]++; - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].SpawnObjectTypeHorde, BattlegroundConst.RespawnImmediately); - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 1, BattlegroundConst.RespawnImmediately); - SpawnBGObject(EotSMisc.m_CapturingPointTypes[Point].SpawnObjectTypeHorde + 2, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_CapturingPointTypes[point].SpawnObjectTypeHorde, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_CapturingPointTypes[point].SpawnObjectTypeHorde + 1, BattlegroundConst.RespawnImmediately); + SpawnBGObject(Misc.m_CapturingPointTypes[point].SpawnObjectTypeHorde + 2, BattlegroundConst.RespawnImmediately); } //buff isn't respawned - m_PointOwnedByTeam[Point] = Team; - m_PointState[Point] = EotSPointState.UnderControl; + m_PointOwnedByTeam[point] = team; + m_PointState[point] = PointState.UnderControl; - if (Team == Team.Alliance) - SendBroadcastText(EotSMisc.m_CapturingPointTypes[Point].MessageIdAlliance, ChatMsg.BgSystemAlliance, player); + if (team == Team.Alliance) + SendBroadcastText(Misc.m_CapturingPointTypes[point].MessageIdAlliance, ChatMsg.BgSystemAlliance, controlZone); else - SendBroadcastText(EotSMisc.m_CapturingPointTypes[Point].MessageIdHorde, ChatMsg.BgSystemHorde, player); + SendBroadcastText(Misc.m_CapturingPointTypes[point].MessageIdHorde, ChatMsg.BgSystemHorde, controlZone); - if (!BgCreatures[Point].IsEmpty()) - DelCreature(Point); + if (!BgCreatures[point].IsEmpty()) + DelCreature(point); - WorldSafeLocsEntry sg = Global.ObjectMgr.GetWorldSafeLoc(EotSMisc.m_CapturingPointTypes[Point].GraveyardId); - if (sg == null || !AddSpiritGuide(Point, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.124139f, GetTeamIndexByTeamId(Team))) + WorldSafeLocsEntry sg = Global.ObjectMgr.GetWorldSafeLoc(Misc.m_CapturingPointTypes[point].GraveyardId); + if (sg == null || !AddSpiritGuide(point, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.124139f, GetTeamIndexByTeamId(team))) Log.outError(LogFilter.Battleground, "BatteGroundEY: Failed to spawn spirit guide. point: {0}, team: {1}, graveyard_id: {2}", - Point, Team, EotSMisc.m_CapturingPointTypes[Point].GraveyardId); + point, team, Misc.m_CapturingPointTypes[point].GraveyardId); // SpawnBGCreature(Point, RESPAWN_IMMEDIATELY); - UpdatePointsIcons(Team, Point); - UpdatePointsCount(Team); + UpdatePointsIcons(team, point); + UpdatePointsCount(team); - if (Point >= EotSPoints.PointsMax) + if (point >= Points.PointsMax) return; - Creature trigger = GetBGCreature(Point + 6);//0-5 spirit guides + Creature trigger = GetBGCreature(point + 6);//0-5 spirit guides if (trigger == null) - trigger = AddCreature(SharedConst.WorldTrigger, Point + 6, EotSMisc.TriggerPositions[Point], GetTeamIndexByTeamId(Team)); + trigger = AddCreature(SharedConst.WorldTrigger, point + 6, Misc.TriggerPositions[point], GetTeamIndexByTeamId(team)); //add bonus honor aura trigger creature when node is accupied //cast bonus aura (+50% honor in 25yards) //aura should only apply to players who have accupied the node, set correct faction for trigger if (trigger != null) { - trigger.SetFaction(Team == Team.Alliance ? 84u : 83); + trigger.SetFaction(team == Team.Alliance ? 84u : 83); trigger.CastSpell(trigger, BattlegroundConst.SpellHonorableDefender25y, false); } } @@ -783,34 +626,34 @@ namespace Game.BattleGrounds.Zones return; SetFlagPicker(ObjectGuid.Empty); - m_FlagState = EotSFlagState.WaitRespawn; - player.RemoveAurasDueToSpell(EotSMisc.SpellNetherstormFlag); + m_FlagState = FlagState.WaitRespawn; + player.RemoveAurasDueToSpell(Misc.SpellNetherstormFlag); player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.PvPActive); Team team = GetPlayerTeam(player.GetGUID()); if (team == Team.Alliance) { - SendBroadcastText(EotSBroadcastTexts.AllianceCapturedFlag, ChatMsg.BgSystemAlliance, player); - PlaySoundToAll(EotSSoundIds.FlagCapturedAlliance); + SendBroadcastText(BroadcastTextIds.AllianceCapturedFlag, ChatMsg.BgSystemAlliance, player); + PlaySoundToAll(SoundIds.FlagCapturedAlliance); } else { - SendBroadcastText(EotSBroadcastTexts.HordeCapturedFlag, ChatMsg.BgSystemHorde, player); - PlaySoundToAll(EotSSoundIds.FlagCapturedHorde); + SendBroadcastText(BroadcastTextIds.HordeCapturedFlag, ChatMsg.BgSystemHorde, player); + PlaySoundToAll(SoundIds.FlagCapturedHorde); } SpawnBGObject((int)BgObjectType, BattlegroundConst.RespawnImmediately); - m_FlagsTimer = EotSMisc.FlagRespawnTime; + m_FlagsTimer = Misc.FlagRespawnTime; m_FlagCapturedBgObjectType = BgObjectType; int team_id = GetTeamIndexByTeamId(team); if (m_TeamPointsCount[team_id] > 0) - AddPoints(team, EotSMisc.FlagPoints[m_TeamPointsCount[team_id] - 1]); + AddPoints(team, Misc.FlagPoints[m_TeamPointsCount[team_id] - 1]); - UpdateWorldState(EotSWorldStateIds.NetherstormFlagStateHorde, (int)EotSFlagState.OnBase); - UpdateWorldState(EotSWorldStateIds.NetherstormFlagStateAlliance, (int)EotSFlagState.OnBase); + UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)FlagState.OnBase); + UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)FlagState.OnBase); UpdatePlayerScore(player, ScoreType.FlagCaptures, 1); } @@ -823,7 +666,7 @@ namespace Game.BattleGrounds.Zones switch (type) { case ScoreType.FlagCaptures: - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, EotSMisc.ObjectiveCaptureFlag); + player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, Misc.ObjectiveCaptureFlag); break; default: break; @@ -838,10 +681,10 @@ namespace Game.BattleGrounds.Zones switch (team) { case Team.Alliance: - g_id = EotSGaveyardIds.MainAlliance; + g_id = GaveyardIds.MainAlliance; break; case Team.Horde: - g_id = EotSGaveyardIds.MainHorde; + g_id = GaveyardIds.MainHorde; break; default: return null; } @@ -861,13 +704,13 @@ namespace Game.BattleGrounds.Zones float distance = (entry.Loc.GetPositionX() - plr_x) * (entry.Loc.GetPositionX() - plr_x) + (entry.Loc.GetPositionY() - plr_y) * (entry.Loc.GetPositionY() - plr_y) + (entry.Loc.GetPositionZ() - plr_z) * (entry.Loc.GetPositionZ() - plr_z); float nearestDistance = distance; - for (byte i = 0; i < EotSPoints.PointsMax; ++i) + for (byte i = 0; i < Points.PointsMax; ++i) { - if (m_PointOwnedByTeam[i] == team && m_PointState[i] == EotSPointState.UnderControl) + if (m_PointOwnedByTeam[i] == team && m_PointState[i] == PointState.UnderControl) { - entry = Global.ObjectMgr.GetWorldSafeLoc(EotSMisc.m_CapturingPointTypes[i].GraveyardId); + entry = Global.ObjectMgr.GetWorldSafeLoc(Misc.m_CapturingPointTypes[i].GraveyardId); if (entry == null) - Log.outError(LogFilter.Battleground, "BattlegroundEY: Graveyard {0} could not be found.", EotSMisc.m_CapturingPointTypes[i].GraveyardId); + Log.outError(LogFilter.Battleground, "BattlegroundEY: Graveyard {0} could not be found.", Misc.m_CapturingPointTypes[i].GraveyardId); else { distance = (entry.Loc.GetPositionX() - plr_x) * (entry.Loc.GetPositionX() - plr_x) + (entry.Loc.GetPositionY() - plr_y) * (entry.Loc.GetPositionY() - plr_y) + (entry.Loc.GetPositionZ() - plr_z) * (entry.Loc.GetPositionZ() - plr_z); @@ -885,7 +728,7 @@ namespace Game.BattleGrounds.Zones public override WorldSafeLocsEntry GetExploitTeleportLocation(Team team) { - return Global.ObjectMgr.GetWorldSafeLoc(team == Team.Alliance ? EotSMisc.ExploitTeleportLocationAlliance : EotSMisc.ExploitTeleportLocationHorde); + return Global.ObjectMgr.GetWorldSafeLoc(team == Team.Alliance ? Misc.ExploitTeleportLocationAlliance : Misc.ExploitTeleportLocationHorde); } public override Team GetPrematureWinner() @@ -898,6 +741,42 @@ namespace Game.BattleGrounds.Zones return base.GetPrematureWinner(); } + public override void ProcessEvent(WorldObject target, uint eventId, WorldObject invoker) + { + base.ProcessEvent(target, eventId, invoker); + + if (invoker != null) + { + GameObject gameobject = invoker.ToGameObject(); + if (gameobject != null) + { + if (gameobject.GetGoType() == GameObjectTypes.ControlZone) + { + if (!ControlZoneHandlers.TryGetValue(gameobject.GetEntry(), out BgEyeOfStormControlZoneHandler handler)) + return; + + var controlzone = gameobject.GetGoInfo().ControlZone; + if (eventId == controlzone.CaptureEventAlliance) + handler.HandleCaptureEventAlliance(gameobject); + else if (eventId == controlzone.CaptureEventHorde) + handler.HandleCaptureEventHorde(gameobject); + else if (eventId == controlzone.ContestedEventAlliance) + handler.HandleContestedEventAlliance(gameobject); + else if (eventId == controlzone.ContestedEventHorde) + handler.HandleContestedEventHorde(gameobject); + else if (eventId == controlzone.NeutralEventAlliance) + handler.HandleNeutralEventAlliance(gameobject); + else if (eventId == controlzone.NeutralEventHorde) + handler.HandleNeutralEventHorde(gameobject); + else if (eventId == controlzone.ProgressEventAlliance) + handler.HandleProgressEventAlliance(gameobject); + else if (eventId == controlzone.ProgressEventHorde) + handler.HandleProgressEventHorde(gameobject); + } + } + } + } + public override ObjectGuid GetFlagPickerGUID(int team = -1) { return m_FlagKeeper; } void SetFlagPicker(ObjectGuid guid) { m_FlagKeeper = guid; } bool IsFlagPickedup() { return !m_FlagKeeper.IsEmpty(); } @@ -908,24 +787,26 @@ namespace Game.BattleGrounds.Zones uint[] m_HonorScoreTics = new uint[2]; uint[] m_TeamPointsCount = new uint[2]; - uint[] m_Points_Trigger = new uint[EotSPoints.PointsMax]; + uint[] m_Points_Trigger = new uint[Points.PointsMax]; ObjectGuid m_FlagKeeper; // keepers guid ObjectGuid m_DroppedFlagGUID; uint m_FlagCapturedBgObjectType; // type that should be despawned when flag is captured - EotSFlagState m_FlagState; // for checking flag state + FlagState m_FlagState; // for checking flag state int m_FlagsTimer; int m_TowerCapCheckTimer; - Team[] m_PointOwnedByTeam = new Team[EotSPoints.PointsMax]; - EotSPointState[] m_PointState = new EotSPointState[EotSPoints.PointsMax]; - EotSProgressBarConsts[] m_PointBarStatus = new EotSProgressBarConsts[EotSPoints.PointsMax]; - BattlegroundPointCaptureStatus[] m_LastPointCaptureStatus = new BattlegroundPointCaptureStatus[EotSPoints.PointsMax]; - List[] m_PlayersNearPoint = new List[EotSPoints.PointsMax + 1]; - byte[] m_CurrentPointPlayersCount = new byte[2 * EotSPoints.PointsMax]; + Team[] m_PointOwnedByTeam = new Team[Points.PointsMax]; + PointState[] m_PointState = new PointState[Points.PointsMax]; + ProgressBarConsts[] m_PointBarStatus = new ProgressBarConsts[Points.PointsMax]; + BattlegroundPointCaptureStatus[] m_LastPointCaptureStatus = new BattlegroundPointCaptureStatus[Points.PointsMax]; + List[] m_PlayersNearPoint = new List[Points.PointsMax + 1]; + byte[] m_CurrentPointPlayersCount = new byte[2 * Points.PointsMax]; int m_PointAddingTimer; uint m_HonorTics; + + Dictionary ControlZoneHandlers = new(); } class BgEyeOfStormScore : BattlegroundScore @@ -949,7 +830,7 @@ namespace Game.BattleGrounds.Zones { base.BuildPvPLogPlayerDataPacket(out playerData); - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)EotSMisc.ObjectiveCaptureFlag, FlagCaptures)); + playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)Misc.ObjectiveCaptureFlag, FlagCaptures)); } public override uint GetAttr1() { return FlagCaptures; } @@ -957,9 +838,9 @@ namespace Game.BattleGrounds.Zones uint FlagCaptures; } - struct BattlegroundEYPointIconsStruct + struct BgEyeOfStormPointIconsStruct { - public BattlegroundEYPointIconsStruct(uint worldStateControlIndex, uint worldStateAllianceControlledIndex, uint worldStateHordeControlledIndex, uint worldStateAllianceStatusBarIcon, uint worldStateHordeStatusBarIcon) + public BgEyeOfStormPointIconsStruct(uint worldStateControlIndex, uint worldStateAllianceControlledIndex, uint worldStateHordeControlledIndex, uint worldStateAllianceStatusBarIcon, uint worldStateHordeStatusBarIcon) { WorldStateControlIndex = worldStateControlIndex; WorldStateAllianceControlledIndex = worldStateAllianceControlledIndex; @@ -975,9 +856,9 @@ namespace Game.BattleGrounds.Zones public uint WorldStateHordeStatusBarIcon; } - struct BattlegroundEYLosingPointStruct + struct BgEyeOfStormLosingPointStruct { - public BattlegroundEYLosingPointStruct(int _SpawnNeutralObjectType, int _DespawnObjectTypeAlliance, uint _MessageIdAlliance, int _DespawnObjectTypeHorde, uint _MessageIdHorde) + public BgEyeOfStormLosingPointStruct(int _SpawnNeutralObjectType, int _DespawnObjectTypeAlliance, uint _MessageIdAlliance, int _DespawnObjectTypeHorde, uint _MessageIdHorde) { SpawnNeutralObjectType = _SpawnNeutralObjectType; DespawnObjectTypeAlliance = _DespawnObjectTypeAlliance; @@ -993,9 +874,9 @@ namespace Game.BattleGrounds.Zones public uint MessageIdHorde; } - struct BattlegroundEYCapturingPointStruct + struct BgEyeOfStormCapturingPointStruct { - public BattlegroundEYCapturingPointStruct(int _DespawnNeutralObjectType, int _SpawnObjectTypeAlliance, uint _MessageIdAlliance, int _SpawnObjectTypeHorde, uint _MessageIdHorde, uint _GraveyardId) + public BgEyeOfStormCapturingPointStruct(int _DespawnNeutralObjectType, int _SpawnObjectTypeAlliance, uint _MessageIdAlliance, int _SpawnObjectTypeHorde, uint _MessageIdHorde, uint _GraveyardId) { DespawnNeutralObjectType = _DespawnNeutralObjectType; SpawnObjectTypeAlliance = _SpawnObjectTypeAlliance; @@ -1013,7 +894,39 @@ namespace Game.BattleGrounds.Zones public uint GraveyardId; } - struct EotSMisc + class BgEyeOfStormControlZoneHandler : ControlZoneHandler + { + BgEyeofStorm _battleground; + uint _point; + + public BgEyeOfStormControlZoneHandler(BgEyeofStorm bg, uint point) + { + _battleground = bg; + _point = point; + } + + public override void HandleProgressEventHorde(GameObject controlZone) + { + _battleground.EventTeamCapturedPoint(Team.Horde, _point, controlZone); + } + + public override void HandleProgressEventAlliance(GameObject controlZone) + { + _battleground.EventTeamCapturedPoint(Team.Alliance, _point, controlZone); + } + + public override void HandleNeutralEventHorde(GameObject controlZone) + { + _battleground.EventTeamLostPoint(Team.Horde, _point, controlZone); + } + + public override void HandleNeutralEventAlliance(GameObject controlZone) + { + _battleground.EventTeamLostPoint(Team.Alliance, _point, controlZone); + } + } + + struct Misc { public const uint EventStartBattle = 13180; // Achievement: Flurry public const int FlagRespawnTime = (8 * Time.InMilliseconds); @@ -1041,30 +954,30 @@ namespace Game.BattleGrounds.Zones public static byte[] TickPoints = { 1, 2, 5, 10 }; public static uint[] FlagPoints = { 75, 85, 100, 500 }; - public static BattlegroundEYPointIconsStruct[] m_PointsIconStruct = + public static BgEyeOfStormPointIconsStruct[] m_PointsIconStruct = { - new BattlegroundEYPointIconsStruct(EotSWorldStateIds.FelReaverUncontrol, EotSWorldStateIds.FelReaverAllianceControl, EotSWorldStateIds.FelReaverHordeControl, EotSWorldStateIds.FelReaverAllianceControlState, EotSWorldStateIds.FelReaverHordeControlState), - new BattlegroundEYPointIconsStruct(EotSWorldStateIds.BloodElfUncontrol, EotSWorldStateIds.BloodElfAllianceControl, EotSWorldStateIds.BloodElfHordeControl, EotSWorldStateIds.BloodElfAllianceControlState, EotSWorldStateIds.BloodElfHordeControlState), - new BattlegroundEYPointIconsStruct(EotSWorldStateIds.DraeneiRuinsUncontrol, EotSWorldStateIds.DraeneiRuinsAllianceControl, EotSWorldStateIds.DraeneiRuinsHordeControl, EotSWorldStateIds.DraeneiRuinsAllianceControlState, EotSWorldStateIds.DraeneiRuinsHordeControlState), - new BattlegroundEYPointIconsStruct(EotSWorldStateIds.MageTowerUncontrol, EotSWorldStateIds.MageTowerAllianceControl, EotSWorldStateIds.MageTowerHordeControl, EotSWorldStateIds.MageTowerAllianceControlState, EotSWorldStateIds.MageTowerHordeControlState) + new BgEyeOfStormPointIconsStruct(WorldStateIds.FelReaverUncontrol, WorldStateIds.FelReaverAllianceControl, WorldStateIds.FelReaverHordeControl, WorldStateIds.FelReaverAllianceControlState, WorldStateIds.FelReaverHordeControlState), + new BgEyeOfStormPointIconsStruct(WorldStateIds.BloodElfUncontrol, WorldStateIds.BloodElfAllianceControl, WorldStateIds.BloodElfHordeControl, WorldStateIds.BloodElfAllianceControlState, WorldStateIds.BloodElfHordeControlState), + new BgEyeOfStormPointIconsStruct(WorldStateIds.DraeneiRuinsUncontrol, WorldStateIds.DraeneiRuinsAllianceControl, WorldStateIds.DraeneiRuinsHordeControl, WorldStateIds.DraeneiRuinsAllianceControlState, WorldStateIds.DraeneiRuinsHordeControlState), + new BgEyeOfStormPointIconsStruct(WorldStateIds.MageTowerUncontrol, WorldStateIds.MageTowerAllianceControl, WorldStateIds.MageTowerHordeControl, WorldStateIds.MageTowerAllianceControlState, WorldStateIds.MageTowerHordeControlState) }; - public static BattlegroundEYLosingPointStruct[] m_LosingPointTypes = + public static BgEyeOfStormLosingPointStruct[] m_LosingPointTypes = { - new BattlegroundEYLosingPointStruct(EotSObjectTypes.NBannerFelReaverCenter, EotSObjectTypes.ABannerFelReaverCenter, EotSBroadcastTexts.AllianceLostFelReaverRuins, EotSObjectTypes.HBannerFelReaverCenter, EotSBroadcastTexts.HordeLostFelReaverRuins), - new BattlegroundEYLosingPointStruct(EotSObjectTypes.NBannerBloodElfCenter, EotSObjectTypes.ABannerBloodElfCenter, EotSBroadcastTexts.AllianceLostBloodElfTower, EotSObjectTypes.HBannerBloodElfCenter, EotSBroadcastTexts.HordeLostBloodElfTower), - new BattlegroundEYLosingPointStruct(EotSObjectTypes.NBannerDraeneiRuinsCenter, EotSObjectTypes.ABannerDraeneiRuinsCenter, EotSBroadcastTexts.AllianceLostDraeneiRuins, EotSObjectTypes.HBannerDraeneiRuinsCenter, EotSBroadcastTexts.HordeLostDraeneiRuins), - new BattlegroundEYLosingPointStruct(EotSObjectTypes.NBannerMageTowerCenter, EotSObjectTypes.ABannerMageTowerCenter, EotSBroadcastTexts.AllianceLostMageTower, EotSObjectTypes.HBannerMageTowerCenter, EotSBroadcastTexts.HordeLostMageTower) + new BgEyeOfStormLosingPointStruct(ObjectTypes.NBannerFelReaverCenter, ObjectTypes.ABannerFelReaverCenter, BroadcastTextIds.AllianceLostFelReaverRuins, ObjectTypes.HBannerFelReaverCenter, BroadcastTextIds.HordeLostFelReaverRuins), + new BgEyeOfStormLosingPointStruct(ObjectTypes.NBannerBloodElfCenter, ObjectTypes.ABannerBloodElfCenter, BroadcastTextIds.AllianceLostBloodElfTower, ObjectTypes.HBannerBloodElfCenter, BroadcastTextIds.HordeLostBloodElfTower), + new BgEyeOfStormLosingPointStruct(ObjectTypes.NBannerDraeneiRuinsCenter, ObjectTypes.ABannerDraeneiRuinsCenter, BroadcastTextIds.AllianceLostDraeneiRuins, ObjectTypes.HBannerDraeneiRuinsCenter, BroadcastTextIds.HordeLostDraeneiRuins), + new BgEyeOfStormLosingPointStruct(ObjectTypes.NBannerMageTowerCenter, ObjectTypes.ABannerMageTowerCenter, BroadcastTextIds.AllianceLostMageTower, ObjectTypes.HBannerMageTowerCenter, BroadcastTextIds.HordeLostMageTower) }; - public static BattlegroundEYCapturingPointStruct[] m_CapturingPointTypes = + public static BgEyeOfStormCapturingPointStruct[] m_CapturingPointTypes = { - new BattlegroundEYCapturingPointStruct(EotSObjectTypes.NBannerFelReaverCenter, EotSObjectTypes.ABannerFelReaverCenter, EotSBroadcastTexts.AllianceTakenFelReaverRuins, EotSObjectTypes.HBannerFelReaverCenter, EotSBroadcastTexts.HordeTakenFelReaverRuins, EotSGaveyardIds.FelReaver), - new BattlegroundEYCapturingPointStruct(EotSObjectTypes.NBannerBloodElfCenter, EotSObjectTypes.ABannerBloodElfCenter, EotSBroadcastTexts.AllianceTakenBloodElfTower, EotSObjectTypes.HBannerBloodElfCenter, EotSBroadcastTexts.HordeTakenBloodElfTower, EotSGaveyardIds.BloodElf), - new BattlegroundEYCapturingPointStruct(EotSObjectTypes.NBannerDraeneiRuinsCenter, EotSObjectTypes.ABannerDraeneiRuinsCenter, EotSBroadcastTexts.AllianceTakenDraeneiRuins, EotSObjectTypes.HBannerDraeneiRuinsCenter, EotSBroadcastTexts.HordeTakenDraeneiRuins, EotSGaveyardIds.DraeneiRuins), - new BattlegroundEYCapturingPointStruct(EotSObjectTypes.NBannerMageTowerCenter, EotSObjectTypes.ABannerMageTowerCenter, EotSBroadcastTexts.AllianceTakenMageTower, EotSObjectTypes.HBannerMageTowerCenter, EotSBroadcastTexts.HordeTakenMageTower, EotSGaveyardIds.MageTower) + new BgEyeOfStormCapturingPointStruct(ObjectTypes.NBannerFelReaverCenter, ObjectTypes.ABannerFelReaverCenter, BroadcastTextIds.AllianceTakenFelReaverRuins, ObjectTypes.HBannerFelReaverCenter, BroadcastTextIds.HordeTakenFelReaverRuins, GaveyardIds.FelReaver), + new BgEyeOfStormCapturingPointStruct(ObjectTypes.NBannerBloodElfCenter, ObjectTypes.ABannerBloodElfCenter, BroadcastTextIds.AllianceTakenBloodElfTower, ObjectTypes.HBannerBloodElfCenter, BroadcastTextIds.HordeTakenBloodElfTower, GaveyardIds.BloodElf), + new BgEyeOfStormCapturingPointStruct(ObjectTypes.NBannerDraeneiRuinsCenter, ObjectTypes.ABannerDraeneiRuinsCenter, BroadcastTextIds.AllianceTakenDraeneiRuins, ObjectTypes.HBannerDraeneiRuinsCenter, BroadcastTextIds.HordeTakenDraeneiRuins, GaveyardIds.DraeneiRuins), + new BgEyeOfStormCapturingPointStruct(ObjectTypes.NBannerMageTowerCenter, ObjectTypes.ABannerMageTowerCenter, BroadcastTextIds.AllianceTakenMageTower, ObjectTypes.HBannerMageTowerCenter, BroadcastTextIds.HordeTakenMageTower, GaveyardIds.MageTower) }; } - struct EotSBroadcastTexts + struct BroadcastTextIds { public const uint AllianceTakenFelReaverRuins = 17828; public const uint HordeTakenFelReaverRuins = 17829; @@ -1093,7 +1006,7 @@ namespace Game.BattleGrounds.Zones public const uint HordeCapturedFlag = 18384; } - struct EotSWorldStateIds + struct WorldStateIds { public const uint AllianceResources = 1776; public const uint HordeResources = 1777; @@ -1130,7 +1043,7 @@ namespace Game.BattleGrounds.Zones public const uint BloodElfAllianceControlState = 17365; } - enum EotSProgressBarConsts + enum ProgressBarConsts { PointMaxCapturersCount = 5, PointRadius = 70, @@ -1144,7 +1057,7 @@ namespace Game.BattleGrounds.Zones ProgressBarAliControlled = 100 } - struct EotSSoundIds + struct SoundIds { //strange ids, but sure about them public const uint FlagPickedUpAlliance = 8212; @@ -1154,7 +1067,7 @@ namespace Game.BattleGrounds.Zones public const uint FlagReset = 8192; } - struct EotSObjectIds + struct ObjectIds { public const uint ADoorEyEntry = 184719; //Alliance Door public const uint HDoorEyEntry = 184720; //Horde Door @@ -1181,7 +1094,7 @@ namespace Game.BattleGrounds.Zones public const uint BerserkBuffMageTowerEyEntry = 184975; } - struct EotSPointsTrigger + struct PointsTrigger { public const uint BloodElfPoint = 4476; public const uint FelReaverPoint = 4514; @@ -1193,7 +1106,7 @@ namespace Game.BattleGrounds.Zones public const uint DraeneiRuinsBuff = 4571; } - struct EotSGaveyardIds + struct GaveyardIds { public const int MainAlliance = 1103; public const uint MainHorde = 1104; @@ -1203,7 +1116,7 @@ namespace Game.BattleGrounds.Zones public const uint MageTower = 1108; } - struct EotSPoints + struct Points { public const int FelReaver = 0; public const int BloodElf = 1; @@ -1214,7 +1127,7 @@ namespace Game.BattleGrounds.Zones public const int PointsMax = 4; } - struct EotSCreaturesTypes + struct CreaturesTypes { public const uint SpiritFelReaver = 0; public const uint SpiritBloodElf = 1; @@ -1228,10 +1141,10 @@ namespace Game.BattleGrounds.Zones public const uint TriggerDraeneiRuins = 8; public const uint TriggerMageTower = 9; - public const uint Max = 10; + public const uint Max = 10; } - struct EotSObjectTypes + struct ObjectTypes { public const int DoorA = 0; public const int DoorH = 1; @@ -1296,13 +1209,13 @@ namespace Game.BattleGrounds.Zones public const int Max = 59; } - struct EotSScoreIds + struct ScoreIds { public const uint WarningNearVictoryScore = 1400; public const uint MaxTeamScore = 1500; } - enum EotSFlagState + enum FlagState { OnBase = 0, WaitRespawn = 1, @@ -1310,7 +1223,7 @@ namespace Game.BattleGrounds.Zones OnGround = 3 } - enum EotSPointState + enum PointState { NoOwner = 0, Uncontrolled = 0, diff --git a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs index 10e777bbf..e57b8f986 100644 --- a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs +++ b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs @@ -158,7 +158,7 @@ namespace Game.BattleGrounds.Zones ShipsStarted = false; //Graveyards - for (byte i = 0; i < SAGraveyards.Max; i++) + for (uint i = 0; i < SAGraveyards.Max; i++) { WorldSafeLocsEntry sg = Global.ObjectMgr.GetWorldSafeLoc(SAMiscConst.GYEntries[i]); if (sg == null) @@ -744,7 +744,7 @@ namespace Game.BattleGrounds.Zones } } - void CaptureGraveyard(int i, Player source) + void CaptureGraveyard(uint i, Player source) { if (GraveyardStatus[i] == Attackers) return; @@ -773,7 +773,7 @@ namespace Game.BattleGrounds.Zones SAMiscConst.ObjSpawnlocs[flag], 0, 0, 0, 0, BattlegroundConst.RespawnOneDay); npc = SACreatureTypes.Rigspark; - Creature rigspark = AddCreature(SAMiscConst.NpcEntries[npc], (int)npc, SAMiscConst.NpcSpawnlocs[npc], Attackers); + Creature rigspark = AddCreature(SAMiscConst.NpcEntries[npc], npc, SAMiscConst.NpcSpawnlocs[npc], Attackers); if (rigspark != null) rigspark.GetAI().Talk(SATextIds.SparklightRigsparkSpawn); @@ -801,7 +801,7 @@ namespace Game.BattleGrounds.Zones SAMiscConst.ObjSpawnlocs[flag], 0, 0, 0, 0, BattlegroundConst.RespawnOneDay); npc = SACreatureTypes.Sparklight; - Creature sparklight = AddCreature(SAMiscConst.NpcEntries[npc], (int)npc, SAMiscConst.NpcSpawnlocs[npc], Attackers); + Creature sparklight = AddCreature(SAMiscConst.NpcEntries[npc], npc, SAMiscConst.NpcSpawnlocs[npc], Attackers); if (sparklight != null) sparklight.GetAI().Talk(SATextIds.SparklightRigsparkSpawn); diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index a5197bd39..a854b7426 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -322,6 +322,10 @@ namespace Game.Entities m_invisibility.AddValue(InvisibilityType.Trap, 300); } break; + case GameObjectTypes.ControlZone: + m_goTypeImpl = new ControlZone(this); + SetActive(true); + break; case GameObjectTypes.NewFlag: m_goTypeImpl = new GameObjectType.NewFlag(this); if (map.Instanceable()) @@ -1594,6 +1598,10 @@ namespace Game.Entities Log.outError(LogFilter.Spells, $"Spell {spellId} has unhandled action {action} in effect {effectIndex}"); break; } + + // Apply side effects of type + if (m_goTypeImpl != null) + m_goTypeImpl.ActivateObject(action, param, spellCaster, spellId, effectIndex); } public void SetGoArtKit(uint kit) @@ -2670,7 +2678,7 @@ namespace Game.Entities } public string[] GetStringIds() { return m_stringIds; } - + public override string GetName(Locale locale = Locale.enUS) { if (locale != Locale.enUS) @@ -3622,6 +3630,15 @@ namespace Game.Entities return newFlag.GetTakenFromBaseTime(); } + public List GetInsidePlayers() + { + ControlZone controlZone = m_goTypeImpl as ControlZone; + if (controlZone != null) + return controlZone.GetInsidePlayers(); + + return null; + } + public bool MeetsInteractCondition(Player user) { if (m_goInfo.GetConditionID1() == 0) @@ -3943,6 +3960,7 @@ namespace Game.Entities public virtual void OnStateChanged(GameObjectState oldState, GameObjectState newState) { } public virtual void OnRelocated() { } public virtual bool IsNeverVisibleFor(WorldObject seer, bool allowServersideObjects) { return false; } + public virtual void ActivateObject(GameObjectActions action, int param, WorldObject spellCaster = null, uint spellId = 0, int effectIndex = -1) { } public class CustomCommand { @@ -4478,4 +4496,252 @@ namespace Game.Entities public GameObjectState? State; public bool Despawned; } + + class ControlZone : GameObjectTypeBase + { + TimeSpan _heartbeatRate; + TimeTracker _heartbeatTracker; + List _insidePlayers = new(); + int _previousTeamId; + float _value; + bool _contestedTriggered; + + public ControlZone(GameObject owner) : base(owner) + { + _value = owner.GetGoInfo().ControlZone.startingValue; + + + if (owner.GetMap().Instanceable()) + _heartbeatRate = TimeSpan.FromSeconds(1); + else if (owner.GetGoInfo().ControlZone.FrequentHeartbeat != 0) + _heartbeatRate = TimeSpan.FromSeconds(2.5); + else + _heartbeatRate = TimeSpan.FromSeconds(5); + + _heartbeatTracker = new(_heartbeatRate); + _previousTeamId = GetControllingTeam(); + _contestedTriggered = false; + } + + public override void Update(uint diff) + { + if (_owner.HasFlag(GameObjectFlags.NotSelectable)) + return; + + _heartbeatTracker.Update(diff); + if (_heartbeatTracker.Passed()) + { + _heartbeatTracker.Reset(_heartbeatRate); + HandleHeartbeat(); + } + } + + int GetControllingTeam() + { + if (_value < GetMaxHordeValue()) + return TeamId.Horde; + + if (_value > GetMinAllianceValue()) + return TeamId.Alliance; + + return TeamId.Neutral; + } + + public List GetInsidePlayers() { return _insidePlayers; } + + public override void ActivateObject(GameObjectActions action, int param, WorldObject spellCaster, uint spellId, int effectIndex) + { + switch (action) + { + case GameObjectActions.MakeInert: + foreach (ObjectGuid guid in _insidePlayers) + { + Player player = Global.ObjAccessor.GetPlayer(_owner, guid); + if (player != null) + player.SendUpdateWorldState(_owner.GetGoInfo().ControlZone.worldState1, 0); + } + + _insidePlayers.Clear(); + break; + default: + break; + } + } + + public void SetValue(float value) + { + _value = MathFunctions.RoundToInterval(ref value, 0.0f, 100.0f); + } + + void HandleHeartbeat() + { + // update player list inside control zone + List targetList = new(); + SearchTargets(targetList); + + int oldControllingTeam = GetControllingTeam(); + float pointsGained = CalculatePointsPerSecond(targetList) * (float)_heartbeatRate.TotalMilliseconds / 1000.0f; + if (pointsGained == 0) + return; + + int oldRoundedValue = (int)_value; + SetValue(_value + pointsGained); + int roundedValue = (int)_value; + if (oldRoundedValue == roundedValue) + return; + + int newControllingTeam = GetControllingTeam(); + int assaultingTeam = pointsGained > 0 ? TeamId.Alliance : TeamId.Horde; + + if (oldControllingTeam != newControllingTeam) + _contestedTriggered = false; + + if (oldControllingTeam != TeamId.Alliance && newControllingTeam == TeamId.Alliance) + TriggerEvent(_owner.GetGoInfo().ControlZone.ProgressEventAlliance); + else if (oldControllingTeam != TeamId.Horde && newControllingTeam == TeamId.Horde) + TriggerEvent(_owner.GetGoInfo().ControlZone.ProgressEventHorde); + else if (oldControllingTeam == TeamId.Horde && newControllingTeam == TeamId.Neutral) + TriggerEvent(_owner.GetGoInfo().ControlZone.NeutralEventHorde); + else if (oldControllingTeam == TeamId.Alliance && newControllingTeam == TeamId.Neutral) + TriggerEvent(_owner.GetGoInfo().ControlZone.NeutralEventAlliance); + + if (roundedValue == 100 && newControllingTeam == TeamId.Alliance && assaultingTeam == TeamId.Alliance) + TriggerEvent(_owner.GetGoInfo().ControlZone.CaptureEventAlliance); + else if (roundedValue == 0 && newControllingTeam == TeamId.Horde && assaultingTeam == TeamId.Horde) + TriggerEvent(_owner.GetGoInfo().ControlZone.CaptureEventHorde); + + if (oldRoundedValue == 100 && assaultingTeam == TeamId.Horde && !_contestedTriggered) + { + TriggerEvent(_owner.GetGoInfo().ControlZone.ContestedEventHorde); + _contestedTriggered = true; + } + else if (oldRoundedValue == 0 && assaultingTeam == TeamId.Alliance && !_contestedTriggered) + { + TriggerEvent(_owner.GetGoInfo().ControlZone.ContestedEventAlliance); + _contestedTriggered = true; + } + + foreach (Player player in targetList) + player.SendUpdateWorldState(_owner.GetGoInfo().ControlZone.worldstate2, (uint)roundedValue); + } + + void SearchTargets(List targetList) + { + AnyUnitInObjectRangeCheck check = new(_owner, _owner.GetGoInfo().ControlZone.radius, true); + PlayerListSearcher searcher = new(_owner, targetList, check); + Cell.VisitWorldObjects(_owner, searcher, _owner.GetGoInfo().ControlZone.radius); + HandleUnitEnterExit(targetList); + } + + float CalculatePointsPerSecond(List targetList) + { + int delta = 0; + + foreach (Player player in targetList) + { + if (!player.IsOutdoorPvPActive()) + continue; + + if (player.GetTeam() == Team.Horde) + delta--; + else + delta++; + } + + uint minTime = _owner.GetGoInfo().ControlZone.minTime; + uint maxTime = _owner.GetGoInfo().ControlZone.maxTime; + uint minSuperiority = _owner.GetGoInfo().ControlZone.minSuperiority; + uint maxSuperiority = _owner.GetGoInfo().ControlZone.maxSuperiority; + + if (Math.Abs(delta) < minSuperiority) + return 0; + + float slope = ((float)minTime - maxTime) / (maxSuperiority - minSuperiority); + float intercept = maxTime - slope * minSuperiority; + float timeNeeded = slope * Math.Abs(delta) + intercept; + float percentageIncrease = 100.0f / timeNeeded; + + if (delta < 0) + percentageIncrease *= -1; + + return percentageIncrease; + } + + void HandleUnitEnterExit(List newTargetList) + { + List exitPlayers = new(_insidePlayers); + + List enteringPlayers = new(); + + foreach (Player unit in newTargetList) + { + if (!exitPlayers.Remove(unit.GetGUID())) + enteringPlayers.Add(unit); + + _insidePlayers.Add(unit.GetGUID()); + } + + foreach (Player player in enteringPlayers) + { + player.SendUpdateWorldState(_owner.GetGoInfo().ControlZone.worldState1, 1); + player.SendUpdateWorldState(_owner.GetGoInfo().ControlZone.worldstate2, (uint)_value); + player.SendUpdateWorldState(_owner.GetGoInfo().ControlZone.worldstate3, _owner.GetGoInfo().ControlZone.neutralPercent); + } + + foreach (ObjectGuid exitPlayerGuid in exitPlayers) + { + Player player = Global.ObjAccessor.GetPlayer(_owner, exitPlayerGuid); + if (player != null) + player.SendUpdateWorldState(_owner.GetGoInfo().ControlZone.worldState1, 0); + } + } + + float GetMaxHordeValue() + { + // ex: if neutralPercent is 40; then 0 - 30 is Horde Controlled + return 50.0f - _owner.GetGoInfo().ControlZone.neutralPercent / 2.0f; + } + + float GetMinAllianceValue() + { + // ex: if neutralPercent is 40; then 70 - 100 is Alliance Controlled + return 50.0f + _owner.GetGoInfo().ControlZone.neutralPercent / 2.0f; + } + + void TriggerEvent(uint eventId) + { + if (eventId <= 0) + return; + + GameEvents.Trigger(eventId, _owner, null); + } + + public uint GetStartingValue() + { + return _owner.GetGoInfo().ControlZone.startingValue; + } + } + + class SetControlZoneValue : GameObjectTypeBase.CustomCommand + { + uint? _value; + + public SetControlZoneValue(uint? value = null) + { + _value = value; + } + + public override void Execute(GameObjectTypeBase type) + { + ControlZone controlZone = type as ControlZone; + if (controlZone != null) + { + uint value = controlZone.GetStartingValue(); + if (_value.HasValue) + value = _value.Value; + + controlZone.SetValue(value); + } + } + } } \ No newline at end of file diff --git a/Source/Game/Maps/ZoneScript.cs b/Source/Game/Maps/ZoneScript.cs index ff033d23e..699834d4f 100644 --- a/Source/Game/Maps/ZoneScript.cs +++ b/Source/Game/Maps/ZoneScript.cs @@ -51,4 +51,17 @@ namespace Game.Maps protected EventMap _events = new(); } + + public class ControlZoneHandler + { + public virtual void HandleCaptureEventHorde(GameObject controlZone) { } + public virtual void HandleCaptureEventAlliance(GameObject controlZone) { } + public virtual void HandleContestedEventHorde(GameObject controlZone) { } + public virtual void HandleContestedEventAlliance(GameObject controlZone) { } + public virtual void HandleProgressEventHorde(GameObject controlZone) { } + public virtual void HandleProgressEventAlliance(GameObject controlZone) { } + public virtual void HandleNeutralEventHorde(GameObject controlZone) { HandleNeutralEvent(controlZone); } + public virtual void HandleNeutralEventAlliance(GameObject controlZone) { HandleNeutralEvent(controlZone); } + public virtual void HandleNeutralEvent(GameObject controlZone) { } + } } diff --git a/Source/Game/OutdoorPVP/OutdoorPvP.cs b/Source/Game/OutdoorPVP/OutdoorPvP.cs index 8fd3cd0bc..5530051e8 100644 --- a/Source/Game/OutdoorPVP/OutdoorPvP.cs +++ b/Source/Game/OutdoorPVP/OutdoorPvP.cs @@ -2,18 +2,13 @@ // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; -using Framework.Database; using Game.Chat; -using Game.DataStorage; using Game.Entities; using Game.Groups; using Game.Maps; -using Game.Misc; using Game.Networking; using Game.Networking.Packets; -using System; using System.Collections.Generic; -using System.Linq; using System.Numerics; namespace Game.PvP @@ -36,9 +31,6 @@ namespace Game.PvP public virtual void HandlePlayerLeaveZone(Player player, uint zone) { - // inform the objectives of the leaving - foreach (var pair in m_capturePoints) - pair.Value.HandlePlayerLeave(player); // remove the world state information from the player (we can't keep everyone up to date, so leave out those who are not in the concerning zones) if (!player.GetSession().PlayerLogout()) SendRemoveWorldStates(player); @@ -48,15 +40,10 @@ namespace Game.PvP public virtual void HandlePlayerResurrects(Player player, uint zone) { } - public virtual bool Update(uint diff) + public virtual void Update(uint diff) { - bool objective_changed = false; - foreach (var pair in m_capturePoints) - { - if (pair.Value.Update(diff)) - objective_changed = true; - } - return objective_changed; + foreach (var (_, capturePoint) in m_capturePoints) + capturePoint.Update(diff); } public int GetWorldState(int worldStateId) @@ -87,27 +74,18 @@ namespace Game.PvP // creature kills must be notified, even if not inside objective / not outdoor pvp active // player kills only count if active and inside objective - if ((groupGuy.IsOutdoorPvPActive() && IsInsideObjective(groupGuy)) || killed.IsTypeId(TypeId.Unit)) + if (groupGuy.IsOutdoorPvPActive() || killed.IsTypeId(TypeId.Unit)) HandleKillImpl(groupGuy, killed); } } else { // creature kills must be notified, even if not inside objective / not outdoor pvp active - if ((killer.IsOutdoorPvPActive() && IsInsideObjective(killer)) || killed.IsTypeId(TypeId.Unit)) + if (killer.IsOutdoorPvPActive() || killed.IsTypeId(TypeId.Unit)) HandleKillImpl(killer, killed); } } - bool IsInsideObjective(Player player) - { - foreach (var pair in m_capturePoints) - if (pair.Value.IsInsideObjective(player)) - return true; - - return false; - } - public virtual bool HandleCustomSpell(Player player, uint spellId, GameObject go) { foreach (var pair in m_capturePoints) @@ -140,7 +118,7 @@ namespace Game.PvP return false; } - void BroadcastPacket(ServerPacket packet) + public void BroadcastPacket(ServerPacket packet) { // This is faster than sWorld.SendZoneMessage for (int team = 0; team < 2; ++team) @@ -185,26 +163,6 @@ namespace Game.PvP TeamCastSpell((uint)(teamIndex == TeamId.Alliance ? TeamId.Horde : TeamId.Alliance), spellId2 != 0 ? -(int)spellId2 : -(int)spellId); } - public override void OnGameObjectCreate(GameObject go) - { - if (go.GetGoType() != GameObjectTypes.ControlZone) - return; - - OPvPCapturePoint cp = GetCapturePoint(go.GetSpawnId()); - if (cp != null) - cp.m_capturePoint = go; - } - - public override void OnGameObjectRemove(GameObject go) - { - if (go.GetGoType() != GameObjectTypes.ControlZone) - return; - - OPvPCapturePoint cp = GetCapturePoint(go.GetSpawnId()); - if (cp != null) - cp.m_capturePoint = null; - } - public void SendDefenseMessage(uint zoneId, uint id) { DefenseMessageBuilder builder = new(zoneId, id); @@ -212,6 +170,40 @@ namespace Game.PvP BroadcastWorker(localizer, zoneId); } + public override void ProcessEvent(WorldObject target, uint eventId, WorldObject invoker) + { + if (invoker != null) + { + GameObject gameobject = invoker.ToGameObject(); + if (gameobject != null) + { + if (gameobject.GetGoType() == GameObjectTypes.ControlZone) + { + if (!ControlZoneHandlers.TryGetValue(gameobject.GetEntry(), out OutdoorPvPControlZoneHandler handler)) + return; + + var controlzone = gameobject.GetGoInfo().ControlZone; + if (eventId == controlzone.CaptureEventAlliance) + handler.HandleCaptureEventAlliance(gameobject); + else if (eventId == controlzone.CaptureEventHorde) + handler.HandleCaptureEventHorde(gameobject); + else if (eventId == controlzone.ContestedEventAlliance) + handler.HandleContestedEventAlliance(gameobject); + else if (eventId == controlzone.ContestedEventHorde) + handler.HandleContestedEventHorde(gameobject); + else if (eventId == controlzone.NeutralEventAlliance) + handler.HandleNeutralEventAlliance(gameobject); + else if (eventId == controlzone.NeutralEventHorde) + handler.HandleNeutralEventHorde(gameobject); + else if (eventId == controlzone.ProgressEventAlliance) + handler.HandleProgressEventAlliance(gameobject); + else if (eventId == controlzone.ProgressEventHorde) + handler.HandleProgressEventHorde(gameobject); + } + } + } + } + void BroadcastWorker(IDoWork _worker, uint zoneId) { for (uint i = 0; i < SharedConst.PvpTeamsCount; ++i) @@ -238,23 +230,11 @@ namespace Game.PvP public virtual void SendRemoveWorldStates(Player player) { } - public void AddCapturePoint(OPvPCapturePoint cp) - { - if (m_capturePoints.ContainsKey(cp.m_capturePointSpawnId)) - Log.outError(LogFilter.Outdoorpvp, "OutdoorPvP.AddCapturePoint: CapturePoint {0} already exists!", cp.m_capturePointSpawnId); - - m_capturePoints[cp.m_capturePointSpawnId] = cp; - } - - OPvPCapturePoint GetCapturePoint(ulong lowguid) - { - return m_capturePoints.LookupByKey(lowguid); - } - public Map GetMap() { return m_map; } // the map of the objectives belonging to this outdoorpvp public Dictionary m_capturePoints = new(); + protected Dictionary ControlZoneHandlers = new(); List[] m_players = new List[2]; public OutdoorPvPTypes m_TypeId; @@ -263,229 +243,24 @@ namespace Game.PvP public class OPvPCapturePoint { + uint m_team; + + // objective states + public ObjectiveStates OldState { get; set; } + public ObjectiveStates State { get; set; } + + // pointer to the OutdoorPvP this objective belongs to + public OutdoorPvP PvP { get; set; } + public OPvPCapturePoint(OutdoorPvP pvp) { m_team = TeamId.Neutral; OldState = ObjectiveStates.Neutral; State = ObjectiveStates.Neutral; PvP = pvp; - - m_activePlayers[0] = new HashSet(); - m_activePlayers[1] = new HashSet(); } - public virtual bool HandlePlayerEnter(Player player) - { - if (m_capturePoint != null) - { - player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldState1, 1); - player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate2, (uint)Math.Ceiling((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); - player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate3, m_neutralValuePct); - } - return m_activePlayers[player.GetTeamId()].Add(player.GetGUID()); - } - - public virtual void HandlePlayerLeave(Player player) - { - if (m_capturePoint != null) - player.SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldState1, 0); - m_activePlayers[player.GetTeamId()].Remove(player.GetGUID()); - } - - public virtual void SendChangePhase() - { - if (m_capturePoint == null) - return; - - // send this too, sometimes the slider disappears, dunno why :( - SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldState1, 1); - // send these updates to only the ones in this objective - SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate2, (uint)Math.Ceiling((m_value + m_maxValue) / (2 * m_maxValue) * 100.0f)); - // send this too, sometimes it resets :S - SendUpdateWorldState(m_capturePoint.GetGoInfo().ControlZone.worldstate3, m_neutralValuePct); - } - - public bool SetCapturePointData(uint entry) - { - Log.outDebug(LogFilter.Outdoorpvp, "Creating capture point {0}", entry); - - // check info existence - GameObjectTemplate goinfo = Global.ObjectMgr.GetGameObjectTemplate(entry); - if (goinfo == null || goinfo.type != GameObjectTypes.ControlZone) - { - Log.outError(LogFilter.Outdoorpvp, "OutdoorPvP: GO {0} is not capture point!", entry); - return false; - } - - // get the needed values from goinfo - m_maxValue = goinfo.ControlZone.maxTime; - m_maxSpeed = m_maxValue / (goinfo.ControlZone.minTime != 0 ? goinfo.ControlZone.minTime : 60); - m_neutralValuePct = goinfo.ControlZone.neutralPercent; - m_minValue = MathFunctions.CalculatePct(m_maxValue, m_neutralValuePct); - return true; - } - - public virtual bool Update(uint diff) - { - if (m_capturePoint == null) - return false; - - float radius = m_capturePoint.GetGoInfo().ControlZone.radius; - - for (int team = 0; team < 2; ++team) - { - foreach (var playerGuid in m_activePlayers[team].ToList()) - { - Player player = Global.ObjAccessor.FindPlayer(playerGuid); - if (player != null) - if (!m_capturePoint.IsWithinDistInMap(player, radius) || !player.IsOutdoorPvPActive()) - HandlePlayerLeave(player); - } - } - - List players = new(); - var checker = new AnyPlayerInObjectRangeCheck(m_capturePoint, radius); - var searcher = new PlayerListSearcher(m_capturePoint, players, checker); - Cell.VisitWorldObjects(m_capturePoint, searcher, radius); - - foreach (Player player in players) - { - if (player.IsOutdoorPvPActive()) - { - if (m_activePlayers[player.GetTeamId()].Add(player.GetGUID())) - HandlePlayerEnter(player); - } - } - - // get the difference of numbers - float fact_diff = (float)(m_activePlayers[0].Count - m_activePlayers[1].Count) * diff / 1000; - if (fact_diff == 0.0f) - return false; - - Team Challenger; - float maxDiff = m_maxSpeed * diff; - - if (fact_diff < 0) - { - // horde is in majority, but it's already horde-controlled . no change - if (State == ObjectiveStates.Horde && m_value <= -m_maxValue) - return false; - - if (fact_diff < -maxDiff) - fact_diff = -maxDiff; - - Challenger = Team.Horde; - } - else - { - // ally is in majority, but it's already ally-controlled . no change - if (State == ObjectiveStates.Alliance && m_value >= m_maxValue) - return false; - - if (fact_diff > maxDiff) - fact_diff = maxDiff; - - Challenger = Team.Alliance; - } - - float oldValue = m_value; - uint oldTeam = m_team; - - OldState = State; - - m_value += fact_diff; - - if (m_value < -m_minValue) // red - { - if (m_value < -m_maxValue) - m_value = -m_maxValue; - State = ObjectiveStates.Horde; - m_team = TeamId.Horde; - } - else if (m_value > m_minValue) // blue - { - if (m_value > m_maxValue) - m_value = m_maxValue; - State = ObjectiveStates.Alliance; - m_team = TeamId.Alliance; - } - else if (oldValue * m_value <= 0) // grey, go through mid point - { - // if challenger is ally, then n.a challenge - if (Challenger == Team.Alliance) - State = ObjectiveStates.NeutralAllianceChallenge; - // if challenger is horde, then n.h challenge - else if (Challenger == Team.Horde) - State = ObjectiveStates.NeutralHordeChallenge; - m_team = TeamId.Neutral; - } - else // grey, did not go through mid point - { - // old phase and current are on the same side, so one team challenges the other - if (Challenger == Team.Alliance && (OldState == ObjectiveStates.Horde || OldState == ObjectiveStates.NeutralHordeChallenge)) - State = ObjectiveStates.HordeAllianceChallenge; - else if (Challenger == Team.Horde && (OldState == ObjectiveStates.Alliance || OldState == ObjectiveStates.NeutralAllianceChallenge)) - State = ObjectiveStates.AllianceHordeChallenge; - m_team = TeamId.Neutral; - } - - if (m_value != oldValue) - SendChangePhase(); - - if (OldState != State) - { - if (oldTeam != m_team) - ChangeTeam(oldTeam); - ChangeState(); - return true; - } - - return false; - } - - public void SendUpdateWorldState(uint field, uint value) - { - for (int team = 0; team < 2; ++team) - { - // send to all players present in the area - foreach (var guid in m_activePlayers[team]) - { - Player player = Global.ObjAccessor.FindPlayer(guid); - if (player != null) - player.SendUpdateWorldState(field, value); - } - } - } - - public void SendObjectiveComplete(uint id, ObjectGuid guid) - { - uint team; - switch (State) - { - case ObjectiveStates.Alliance: - team = 0; - break; - case ObjectiveStates.Horde: - team = 1; - break; - default: - return; - } - - // send to all players present in the area - foreach (var playerGuid in m_activePlayers[team]) - { - Player player = Global.ObjAccessor.FindPlayer(playerGuid); - if (player != null) - player.KilledMonsterCredit(id, guid); - } - } - - public bool IsInsideObjective(Player player) - { - var plSet = m_activePlayers[player.GetTeamId()]; - return plSet.Contains(player.GetGUID()); - } + public virtual void Update(uint diff) { } public virtual bool HandleCustomSpell(Player player, uint spellId, GameObject go) { @@ -507,26 +282,18 @@ namespace Game.PvP public virtual void ChangeState() { } public virtual void ChangeTeam(uint oldTeam) { } + } - public ulong m_capturePointSpawnId; - public GameObject m_capturePoint; - // active players in the area of the objective, 0 - alliance, 1 - horde - public HashSet[] m_activePlayers = new HashSet[2]; - // total shift needed to capture the objective - public float m_maxValue; - float m_minValue; - // maximum speed of capture - float m_maxSpeed; - // the status of the objective - public float m_value; - uint m_team; - // objective states - public ObjectiveStates OldState { get; set; } - public ObjectiveStates State { get; set; } - // neutral value on capture bar - public uint m_neutralValuePct; - // pointer to the OutdoorPvP this objective belongs to - public OutdoorPvP PvP { get; set; } + public class OutdoorPvPControlZoneHandler : ControlZoneHandler + { + OutdoorPvP _pvp; + + public OutdoorPvPControlZoneHandler(OutdoorPvP pvp) + { + _pvp = pvp; + } + + public T GetOutdoorPvP() where T : OutdoorPvP { return _pvp as T; } } class DefenseMessageBuilder : MessageBuilder diff --git a/Source/Game/OutdoorPVP/Zones/HellfirePeninsulaPvP.cs b/Source/Game/OutdoorPVP/Zones/HellfirePeninsulaPvP.cs index 55e413d8b..918ee53e7 100644 --- a/Source/Game/OutdoorPVP/Zones/HellfirePeninsulaPvP.cs +++ b/Source/Game/OutdoorPVP/Zones/HellfirePeninsulaPvP.cs @@ -6,16 +6,55 @@ using Game.Entities; using Game.Maps; using Game.Networking.Packets; using Game.Scripting; +using System.Collections.Generic; -namespace Game.PvP +namespace Game.PvP.HellfirePeninsula { class HellfirePeninsulaPvP : OutdoorPvP { + // how many towers are controlled + uint m_AllianceTowersControlled; + uint m_HordeTowersControlled; + List _controlZoneGUIDs = new(); + public HellfirePeninsulaPvP(Map map) : base(map) { m_TypeId = OutdoorPvPTypes.HellfirePeninsula; m_AllianceTowersControlled = 0; m_HordeTowersControlled = 0; + + ControlZoneHandlers[(uint)GameObjectIds.TowerS] = new HellfirePeninsulaControlZoneHandler(this); + GetControlZoneTowerSouthHandler().SetFlagArtKitAlliance(65); + GetControlZoneTowerSouthHandler().SetFlagArtKitHorde(64); + GetControlZoneTowerSouthHandler().SetFlagArtKitNeutral(66); + GetControlZoneTowerSouthHandler().SetTextCaptureAlliance(DefenseMessages.BrokenHillTakenAlliance); + GetControlZoneTowerSouthHandler().SetTextCaptureHorde(DefenseMessages.BrokenHillTakenHorde); + GetControlZoneTowerSouthHandler().SetWorldstateAlliance(WorldStateIds.UiTowerSA); + GetControlZoneTowerSouthHandler().SetWorldstateHorde(WorldStateIds.UiTowerSH); + GetControlZoneTowerSouthHandler().SetWorldstateNeutral(WorldStateIds.UiTowerSN); + GetControlZoneTowerSouthHandler().SetKillCredit((uint)KillCreditIds.TowerS); + + ControlZoneHandlers[(uint)GameObjectIds.TowerN] = new HellfirePeninsulaControlZoneHandler(this); + GetControlZoneTowerNorthHandler().SetFlagArtKitAlliance(62); + GetControlZoneTowerNorthHandler().SetFlagArtKitHorde(61); + GetControlZoneTowerNorthHandler().SetFlagArtKitNeutral(63); + GetControlZoneTowerNorthHandler().SetTextCaptureAlliance(DefenseMessages.OverlookTakenAlliance); + GetControlZoneTowerNorthHandler().SetTextCaptureHorde(DefenseMessages.OverlookTakenHorde); + GetControlZoneTowerNorthHandler().SetWorldstateAlliance(WorldStateIds.UiTowerNA); + GetControlZoneTowerNorthHandler().SetWorldstateHorde(WorldStateIds.UiTowerNH); + GetControlZoneTowerNorthHandler().SetWorldstateNeutral(WorldStateIds.UiTowerNN); + GetControlZoneTowerNorthHandler().SetKillCredit((uint)KillCreditIds.TowerN); + + ControlZoneHandlers[(uint)GameObjectIds.TowerW] = new HellfirePeninsulaControlZoneHandler(this); + GetControlZoneTowerWestHandler().SetFlagArtKitAlliance(67); + GetControlZoneTowerWestHandler().SetFlagArtKitHorde(68); + GetControlZoneTowerWestHandler().SetFlagArtKitNeutral(69); + GetControlZoneTowerWestHandler().SetTextCaptureAlliance(DefenseMessages.StadiumTakenAlliance); + GetControlZoneTowerWestHandler().SetTextCaptureHorde(DefenseMessages.StadiumTakenHorde); + GetControlZoneTowerWestHandler().SetWorldstateAlliance(WorldStateIds.UiTowerWA); + GetControlZoneTowerWestHandler().SetWorldstateHorde(WorldStateIds.UiTowerWH); + GetControlZoneTowerWestHandler().SetWorldstateNeutral(WorldStateIds.UiTowerWN); + GetControlZoneTowerWestHandler().SetKillCredit((uint)KillCreditIds.TowerW); } public override bool SetupOutdoorPvP() @@ -24,8 +63,8 @@ namespace Game.PvP m_HordeTowersControlled = 0; // add the zones affected by the pvp buff - for (int i = 0; i < HPConst.BuffZones.Length; ++i) - RegisterZone(HPConst.BuffZones[i]); + for (int i = 0; i < Misc.BuffZones.Length; ++i) + RegisterZone(Misc.BuffZones[i]); return true; } @@ -34,23 +73,14 @@ namespace Game.PvP { switch (go.GetEntry()) { - case 182175: - AddCapturePoint(new HellfirePeninsulaCapturePoint(this, OutdoorPvPHPTowerType.BrokenHill, go, m_towerFlagSpawnIds[(int)OutdoorPvPHPTowerType.BrokenHill])); - break; - case 182174: - AddCapturePoint(new HellfirePeninsulaCapturePoint(this, OutdoorPvPHPTowerType.Overlook, go, m_towerFlagSpawnIds[(int)OutdoorPvPHPTowerType.Overlook])); - break; - case 182173: - AddCapturePoint(new HellfirePeninsulaCapturePoint(this, OutdoorPvPHPTowerType.Stadium, go, m_towerFlagSpawnIds[(int)OutdoorPvPHPTowerType.Stadium])); - break; case 183514: - m_towerFlagSpawnIds[(int)OutdoorPvPHPTowerType.BrokenHill] = go.GetSpawnId(); + GetControlZoneTowerSouthHandler().SetFlagGuid(go.GetGUID()); break; case 182525: - m_towerFlagSpawnIds[(int)OutdoorPvPHPTowerType.Overlook] = go.GetSpawnId(); + GetControlZoneTowerNorthHandler().SetFlagGuid(go.GetGUID()); break; case 183515: - m_towerFlagSpawnIds[(int)OutdoorPvPHPTowerType.Stadium] = go.GetSpawnId(); + GetControlZoneTowerWestHandler().SetFlagGuid(go.GetGUID()); break; default: break; @@ -65,12 +95,12 @@ namespace Game.PvP if (player.GetTeam() == Team.Alliance) { if (m_AllianceTowersControlled >= 3) - player.CastSpell(player, OutdoorPvPHPSpells.AllianceBuff, true); + player.CastSpell(player, SpellIds.AllianceBuff, true); } else { if (m_HordeTowersControlled >= 3) - player.CastSpell(player, OutdoorPvPHPSpells.HordeBuff, true); + player.CastSpell(player, SpellIds.HordeBuff, true); } base.HandlePlayerEnterZone(player, zone); } @@ -79,31 +109,29 @@ namespace Game.PvP { // remove buffs if (player.GetTeam() == Team.Alliance) - player.RemoveAurasDueToSpell(OutdoorPvPHPSpells.AllianceBuff); + player.RemoveAurasDueToSpell(SpellIds.AllianceBuff); else - player.RemoveAurasDueToSpell(OutdoorPvPHPSpells.HordeBuff); + player.RemoveAurasDueToSpell(SpellIds.HordeBuff); base.HandlePlayerLeaveZone(player, zone); } - public override bool Update(uint diff) + public override void Update(uint diff) { - bool changed = base.Update(diff); - if (changed) + base.Update(diff); + + if (m_AllianceTowersControlled == 3) + TeamApplyBuff(TeamId.Alliance, SpellIds.AllianceBuff, SpellIds.HordeBuff); + else if (m_HordeTowersControlled == 3) + TeamApplyBuff(TeamId.Horde, SpellIds.HordeBuff, SpellIds.AllianceBuff); + else { - if (m_AllianceTowersControlled == 3) - TeamApplyBuff(TeamId.Alliance, OutdoorPvPHPSpells.AllianceBuff, OutdoorPvPHPSpells.HordeBuff); - else if (m_HordeTowersControlled == 3) - TeamApplyBuff(TeamId.Horde, OutdoorPvPHPSpells.HordeBuff, OutdoorPvPHPSpells.AllianceBuff); - else - { - TeamCastSpell(TeamId.Alliance, -(int)OutdoorPvPHPSpells.AllianceBuff); - TeamCastSpell(TeamId.Horde, -(int)OutdoorPvPHPSpells.HordeBuff); - } - SetWorldState(OutdoorPvPHPWorldStates.Count_A, (int)m_AllianceTowersControlled); - SetWorldState(OutdoorPvPHPWorldStates.Count_H, (int)m_HordeTowersControlled); + TeamCastSpell(TeamId.Alliance, -(int)SpellIds.AllianceBuff); + TeamCastSpell(TeamId.Horde, -(int)SpellIds.HordeBuff); } - return changed; + + SetWorldState(WorldStateIds.CountA, (int)m_AllianceTowersControlled); + SetWorldState(WorldStateIds.CountH, (int)m_HordeTowersControlled); } public override void SendRemoveWorldStates(Player player) @@ -112,30 +140,53 @@ namespace Game.PvP initWorldStates.MapID = player.GetMapId(); initWorldStates.AreaID = player.GetZoneId(); initWorldStates.SubareaID = player.GetAreaId(); - initWorldStates.AddState(OutdoorPvPHPWorldStates.Display_A, 0); - initWorldStates.AddState(OutdoorPvPHPWorldStates.Display_H, 0); - initWorldStates.AddState(OutdoorPvPHPWorldStates.Count_H, 0); - initWorldStates.AddState(OutdoorPvPHPWorldStates.Count_A, 0); + initWorldStates.AddState(WorldStateIds.DisplayA, 0); + initWorldStates.AddState(WorldStateIds.DisplayH, 0); + initWorldStates.AddState(WorldStateIds.CountH, 0); + initWorldStates.AddState(WorldStateIds.CountA, 0); - for (int i = 0; i < (int)OutdoorPvPHPTowerType.Num; ++i) + foreach (var pair in ControlZoneHandlers) { - initWorldStates.AddState(HPConst.Map_N[i], 0); - initWorldStates.AddState(HPConst.Map_A[i], 0); - initWorldStates.AddState(HPConst.Map_H[i], 0); + HellfirePeninsulaControlZoneHandler handler = pair.Value as HellfirePeninsulaControlZoneHandler; + initWorldStates.AddState(handler.GetWorldStateNeutral(), 0); + initWorldStates.AddState(handler.GetWorldStateHorde(), 0); + initWorldStates.AddState(handler.GetWorldStateAlliance(), 0); } player.SendPacket(initWorldStates); } - public override void HandleKillImpl(Player killer, Unit killed) + public override void HandleKillImpl(Player player, Unit killed) { - if (!killed.IsTypeId(TypeId.Player)) + if (!killed.IsPlayer()) return; - if (killer.GetTeam() == Team.Alliance && killed.ToPlayer().GetTeam() != Team.Alliance) - killer.CastSpell(killer, OutdoorPvPHPSpells.AlliancePlayerKillReward, true); - else if (killer.GetTeam() == Team.Horde && killed.ToPlayer().GetTeam() != Team.Horde) - killer.CastSpell(killer, OutdoorPvPHPSpells.HordePlayerKillReward, true); + // need to check if player is inside an capture zone + bool isInsideCaptureZone = false; + foreach (ObjectGuid guid in _controlZoneGUIDs) + { + GameObject gameObject = GetMap().GetGameObject(guid); + if (gameObject != null) + { + var insidePlayerGuids = gameObject.GetInsidePlayers(); + if (!insidePlayerGuids.Empty()) + { + if (insidePlayerGuids.Contains(player.GetGUID())) + { + isInsideCaptureZone = true; + break; + } + } + } + } + + if (isInsideCaptureZone) + { + if (player.GetTeam() == Team.Alliance && killed.ToPlayer().GetTeam() != Team.Alliance) + player.CastSpell(player, SpellIds.AlliancePlayerKillReward, true); + else if (player.GetTeam() == Team.Horde && killed.ToPlayer().GetTeam() != Team.Horde) + player.CastSpell(player, SpellIds.HordePlayerKillReward, true); + } } public uint GetAllianceTowersControlled() @@ -158,131 +209,121 @@ namespace Game.PvP m_HordeTowersControlled = count; } - // how many towers are controlled - uint m_AllianceTowersControlled; - uint m_HordeTowersControlled; - ulong[] m_towerFlagSpawnIds = new ulong[(int)OutdoorPvPHPTowerType.Num]; + HellfirePeninsulaControlZoneHandler GetControlZoneTowerNorthHandler() { return ControlZoneHandlers[(uint)GameObjectIds.TowerN] as HellfirePeninsulaControlZoneHandler; } + HellfirePeninsulaControlZoneHandler GetControlZoneTowerSouthHandler() { return ControlZoneHandlers[(uint)GameObjectIds.TowerS] as HellfirePeninsulaControlZoneHandler; } + HellfirePeninsulaControlZoneHandler GetControlZoneTowerWestHandler() { return ControlZoneHandlers[(uint)GameObjectIds.TowerW] as HellfirePeninsulaControlZoneHandler; } } - class HellfirePeninsulaCapturePoint : OPvPCapturePoint + class HellfirePeninsulaControlZoneHandler : OutdoorPvPControlZoneHandler { - public HellfirePeninsulaCapturePoint(OutdoorPvP pvp, OutdoorPvPHPTowerType type, GameObject go, ulong flagSpawnId) : base(pvp) - { - m_TowerType = (uint)type; - m_flagSpawnId = flagSpawnId; + ObjectGuid _flagGuid; + uint _textCaptureAlliance; + uint _textCaptureHorde; + uint _flagArtKitNeutral; + uint _flagArtKitHorde; + uint _flagArtKitAlliance; + int _worldstateNeutral; + int _worldstateHorde; + int _worldstateAlliance; + uint _killCredit; - m_capturePointSpawnId = go.GetSpawnId(); - m_capturePoint = go; - SetCapturePointData(go.GetEntry()); + public HellfirePeninsulaControlZoneHandler(HellfirePeninsulaPvP pvp) : base(pvp) { } + + public override void HandleProgressEventHorde(GameObject controlZone) + { + base.HandleProgressEventHorde(controlZone); + + controlZone.SetGoArtKit(1); + controlZone.SendCustomAnim(0); + GameObject flag = controlZone.GetMap().GetGameObject(_flagGuid); + if (flag != null) + flag.SetGoArtKit(_flagArtKitHorde); + + controlZone.GetMap().SetWorldStateValue(_worldstateHorde, 1, false); + controlZone.GetMap().SetWorldStateValue(_worldstateAlliance, 0, false); + controlZone.GetMap().SetWorldStateValue(_worldstateNeutral, 0, false); + + GetOutdoorPvPHP().SendDefenseMessage(Misc.BuffZones[0], _textCaptureHorde); + + var guidSet = controlZone.GetInsidePlayers(); + foreach (ObjectGuid guid in guidSet) + { + Player player = Global.ObjAccessor.GetPlayer(controlZone, guid); + if (player != null && player.GetTeam() == Team.Horde) + player.KilledMonsterCredit(_killCredit); + } } - public override void ChangeState() + public override void HandleProgressEventAlliance(GameObject controlZone) { - uint field = 0; - switch (OldState) + base.HandleProgressEventAlliance(controlZone); + + controlZone.SetGoArtKit(2); + controlZone.SendCustomAnim(1); + GameObject flag = controlZone.GetMap().GetGameObject(_flagGuid); + if (flag != null) + flag.SetGoArtKit(_flagArtKitAlliance); + + controlZone.GetMap().SetWorldStateValue(_worldstateHorde, 0, false); + controlZone.GetMap().SetWorldStateValue(_worldstateAlliance, 1, false); + controlZone.GetMap().SetWorldStateValue(_worldstateNeutral, 0, false); + + GetOutdoorPvPHP().SendDefenseMessage(Misc.BuffZones[0], _textCaptureAlliance); + + var guidSet = controlZone.GetInsidePlayers(); + foreach (ObjectGuid guid in guidSet) { - case ObjectiveStates.Neutral: - field = HPConst.Map_N[m_TowerType]; - break; - case ObjectiveStates.Alliance: - field = HPConst.Map_A[m_TowerType]; - uint alliance_towers = ((HellfirePeninsulaPvP)PvP).GetAllianceTowersControlled(); - if (alliance_towers != 0) - ((HellfirePeninsulaPvP)PvP).SetAllianceTowersControlled(--alliance_towers); - break; - case ObjectiveStates.Horde: - field = HPConst.Map_H[m_TowerType]; - uint horde_towers = ((HellfirePeninsulaPvP)PvP).GetHordeTowersControlled(); - if (horde_towers != 0) - ((HellfirePeninsulaPvP)PvP).SetHordeTowersControlled(--horde_towers); - break; - case ObjectiveStates.NeutralAllianceChallenge: - field = HPConst.Map_N[m_TowerType]; - break; - case ObjectiveStates.NeutralHordeChallenge: - field = HPConst.Map_N[m_TowerType]; - break; - case ObjectiveStates.AllianceHordeChallenge: - field = HPConst.Map_A[m_TowerType]; - break; - case ObjectiveStates.HordeAllianceChallenge: - field = HPConst.Map_H[m_TowerType]; - break; + Player player = Global.ObjAccessor.GetPlayer(controlZone, guid); + if (player != null && player.GetTeam() == Team.Alliance) + player.KilledMonsterCredit(_killCredit); } - - // send world state update - if (field != 0) - { - PvP.SetWorldState((int)field, 0); - field = 0; - } - uint artkit = 21; - uint artkit2 = HPConst.TowerArtKit_N[m_TowerType]; - switch (State) - { - case ObjectiveStates.Neutral: - field = HPConst.Map_N[m_TowerType]; - break; - case ObjectiveStates.Alliance: - { - field = HPConst.Map_A[m_TowerType]; - artkit = 2; - artkit2 = HPConst.TowerArtKit_A[m_TowerType]; - uint alliance_towers = ((HellfirePeninsulaPvP)PvP).GetAllianceTowersControlled(); - if (alliance_towers < 3) - ((HellfirePeninsulaPvP)PvP).SetAllianceTowersControlled(++alliance_towers); - PvP.SendDefenseMessage(HPConst.BuffZones[0], HPConst.LangCapture_A[m_TowerType]); - break; - } - case ObjectiveStates.Horde: - { - field = HPConst.Map_H[m_TowerType]; - artkit = 1; - artkit2 = HPConst.TowerArtKit_H[m_TowerType]; - uint horde_towers = ((HellfirePeninsulaPvP)PvP).GetHordeTowersControlled(); - if (horde_towers < 3) - ((HellfirePeninsulaPvP)PvP).SetHordeTowersControlled(++horde_towers); - PvP.SendDefenseMessage(HPConst.BuffZones[0], HPConst.LangCapture_H[m_TowerType]); - break; - } - case ObjectiveStates.NeutralAllianceChallenge: - field = HPConst.Map_N[m_TowerType]; - break; - case ObjectiveStates.NeutralHordeChallenge: - field = HPConst.Map_N[m_TowerType]; - break; - case ObjectiveStates.AllianceHordeChallenge: - field = HPConst.Map_A[m_TowerType]; - artkit = 2; - artkit2 = HPConst.TowerArtKit_A[m_TowerType]; - break; - case ObjectiveStates.HordeAllianceChallenge: - field = HPConst.Map_H[m_TowerType]; - artkit = 1; - artkit2 = HPConst.TowerArtKit_H[m_TowerType]; - break; - } - - Map map = Global.MapMgr.FindMap(530, 0); - var bounds = map.GetGameObjectBySpawnIdStore().LookupByKey(m_capturePointSpawnId); - foreach (var go in bounds) - go.SetGoArtKit(artkit); - - bounds = map.GetGameObjectBySpawnIdStore().LookupByKey(m_flagSpawnId); - foreach (var go in bounds) - go.SetGoArtKit(artkit2); - - // send world state update - if (field != 0) - PvP.SetWorldState((int)field, 1); - - // complete quest objective - if (State == ObjectiveStates.Alliance || State == ObjectiveStates.Horde) - SendObjectiveComplete(HPConst.CreditMarker[m_TowerType], ObjectGuid.Empty); } - uint m_TowerType; - ulong m_flagSpawnId; + public override void HandleNeutralEventHorde(GameObject controlZone) + { + base.HandleNeutralEventHorde(controlZone); + GetOutdoorPvPHP().SetHordeTowersControlled(GetOutdoorPvPHP().GetHordeTowersControlled() - 1); + } + + public override void HandleNeutralEventAlliance(GameObject controlZone) + { + base.HandleNeutralEventAlliance(controlZone); + GetOutdoorPvPHP().SetAllianceTowersControlled(GetOutdoorPvPHP().GetAllianceTowersControlled() - 1); + } + + public override void HandleNeutralEvent(GameObject controlZone) + { + base.HandleNeutralEvent(controlZone); + controlZone.SetGoArtKit(21); + controlZone.SendCustomAnim(2); + GameObject flag = controlZone.GetMap().GetGameObject(_flagGuid); + if (flag != null) + flag.SetGoArtKit(_flagArtKitNeutral); + + controlZone.GetMap().SetWorldStateValue(_worldstateHorde, 0, false); + controlZone.GetMap().SetWorldStateValue(_worldstateAlliance, 0, false); + controlZone.GetMap().SetWorldStateValue(_worldstateNeutral, 1, false); + } + + public HellfirePeninsulaPvP GetOutdoorPvPHP() + { + return GetOutdoorPvP(); + } + + public void SetFlagGuid(ObjectGuid guid) { _flagGuid = guid; } + public void SetTextCaptureHorde(uint text) { _textCaptureHorde = text; } + public void SetTextCaptureAlliance(uint text) { _textCaptureAlliance = text; } + public void SetFlagArtKitNeutral(uint artKit) { _flagArtKitNeutral = artKit; } + public void SetFlagArtKitHorde(uint artKit) { _flagArtKitHorde = artKit; } + public void SetFlagArtKitAlliance(uint artKit) { _flagArtKitAlliance = artKit; } + public void SetWorldstateNeutral(int id) { _worldstateNeutral = id; } + public void SetWorldstateHorde(int id) { _worldstateHorde = id; } + public void SetWorldstateAlliance(int id) { _worldstateAlliance = id; } + public void SetKillCredit(uint credit) { _killCredit = credit; } + + public int GetWorldStateNeutral() { return _worldstateNeutral; } + public int GetWorldStateHorde() { return _worldstateHorde; } + public int GetWorldStateAlliance() { return _worldstateAlliance; } } [Script] @@ -296,32 +337,10 @@ namespace Game.PvP } } - struct HPConst + struct Misc { - public static uint[] LangCapture_A = { DefenseMessages.BrokenHillTakenAlliance, DefenseMessages.OverlookTakenAlliance, DefenseMessages.StadiumTakenAlliance }; - - public static uint[] LangCapture_H = { DefenseMessages.BrokenHillTakenHorde, DefenseMessages.OverlookTakenHorde, DefenseMessages.StadiumTakenHorde }; - - public static uint[] Map_N = { 2485, 2482, 0x9a8 }; - - public static uint[] Map_A = { 2483, 2480, 2471 }; - - public static uint[] Map_H = { 2484, 2481, 2470 }; - - public static uint[] TowerArtKit_A = { 65, 62, 67 }; - - public static uint[] TowerArtKit_H = { 64, 61, 68 }; - - public static uint[] TowerArtKit_N = { 66, 63, 69 }; - // HP, citadel, ramparts, blood furnace, shattered halls, mag's lair public static uint[] BuffZones = { 3483, 3563, 3562, 3713, 3714, 3836 }; - - public static uint[] CreditMarker = { 19032, 19028, 19029 }; - - public static uint[] CapturePointEventEnter = { 11404, 11396, 11388 }; - - public static uint[] CapturePointEventLeave = { 11403, 11395, 11387 }; } struct DefenseMessages @@ -334,7 +353,7 @@ namespace Game.PvP public const uint BrokenHillTakenHorde = 14846; // '|cffffff00Broken Hill has been taken by the Horde!|r' } - struct OutdoorPvPHPSpells + struct SpellIds { public const uint AlliancePlayerKillReward = 32155; public const uint HordePlayerKillReward = 32158; @@ -342,7 +361,7 @@ namespace Game.PvP public const uint HordeBuff = 32049; } - enum OutdoorPvPHPTowerType + enum TowerType { BrokenHill = 0, Overlook = 1, @@ -350,12 +369,56 @@ namespace Game.PvP Num = 3 } - struct OutdoorPvPHPWorldStates + struct WorldStateIds { - public const int Display_A = 0x9ba; - public const int Display_H = 0x9b9; + public const int DisplayA = 0x9ba; + public const int DisplayH = 0x9b9; - public const int Count_H = 0x9ae; - public const int Count_A = 0x9ac; + public const int CountH = 0x9ae; + public const int CountA = 0x9ac; + + public const int UiTowerSA = 2483; + public const int UiTowerSH = 2484; + public const int UiTowerSN = 2485; + + public const int UiTowerNA = 2480; + public const int UiTowerNH = 2481; + public const int UiTowerNN = 2482; + + public const int UiTowerWA = 2471; + public const int UiTowerWH = 2470; + public const int UiTowerWN = 2472; + } + + enum EventIds + { + HP_EVENT_TOWER_W_PROGRESS_HORDE = 11383, + HP_EVENT_TOWER_W_PROGRESS_ALLIANCE = 11387, + HP_EVENT_TOWER_W_NEUTRAL_HORDE = 11386, + HP_EVENT_TOWER_W_NEUTRAL_ALLIANCE = 11385, + + HP_EVENT_TOWER_N_PROGRESS_HORDE = 11396, + HP_EVENT_TOWER_N_PROGRESS_ALLIANCE = 11395, + HP_EVENT_TOWER_N_NEUTRAL_HORDE = 11394, + HP_EVENT_TOWER_N_NEUTRAL_ALLIANCE = 11393, + + HP_EVENT_TOWER_S_PROGRESS_HORDE = 11404, + HP_EVENT_TOWER_S_PROGRESS_ALLIANCE = 11403, + HP_EVENT_TOWER_S_NEUTRAL_HORDE = 11402, + HP_EVENT_TOWER_S_NEUTRAL_ALLIANCE = 11401 + } + + enum GameObjectIds + { + TowerW = 182173, + TowerN = 182174, + TowerS = 182175 + } + + enum KillCreditIds + { + TowerS = 19032, + TowerN = 19028, + TowerW = 19029 } }