From d0c623ba394496553f1004605e2f4b6cf47dd995 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sat, 2 Mar 2024 14:46:47 -0500 Subject: [PATCH] Core/Battlegrounds: Rework Eye of the Storm Port From (https://github.com/TrinityCore/TrinityCore/commit/32af4bf8fa2936904a6bebe16445e66ef26340ce) --- .../Framework/Constants/BattleGroundsConst.cs | 4 +- .../Game/BattleGrounds/Zones/AlteracValley.cs | 4 +- Source/Game/BattleGrounds/Zones/EyeofStorm.cs | 1025 ++++++----------- .../BattleGrounds/Zones/IsleofConquest.cs | 2 +- .../Game/BattleGrounds/Zones/WarsongGluch.cs | 7 +- Source/Game/Entities/GameObject/GameObject.cs | 2 +- Source/Game/Entities/Player/Player.PvP.cs | 19 +- Source/Game/Spells/SpellInfo.cs | 2 - 8 files changed, 348 insertions(+), 717 deletions(-) diff --git a/Source/Framework/Constants/BattleGroundsConst.cs b/Source/Framework/Constants/BattleGroundsConst.cs index cbba33a5f..850f88435 100644 --- a/Source/Framework/Constants/BattleGroundsConst.cs +++ b/Source/Framework/Constants/BattleGroundsConst.cs @@ -72,7 +72,9 @@ namespace Framework.Constants public const uint SpellArenaPreparation = 32727; // Use This One, 32728 Not Correct public const uint SpellPreparation = 44521; // Preparation public const uint SpellSpiritHealMana = 44535; // Spirit Heal - public const uint SpellRecentlyDroppedFlag = 42792; // Recently Dropped Flag + public const uint SpellRecentlyDroppedAllianceFlag = 42792; // makes Alliance flag unselectable + public const uint SpellRecentlyDroppedHordeFlag = 42792; // makes Horde flag unselectable + public const uint SpellRecentlyDroppedNeutralFlag = 42792; // makes Neutral flag unselectable public const uint SpellAuraPlayerInactive = 43681; // Inactive public const uint SpellHonorableDefender25y = 68652; // +50% Honor When Standing At A Capture Point That You Control, 25yards Radius (Added In 3.2) public const uint SpellHonorableDefender60y = 66157; // +50% Honor When Standing At A Capture Point That You Control, 60yards Radius (Added In 3.2), Probably For 40+ Player Battlegrounds diff --git a/Source/Game/BattleGrounds/Zones/AlteracValley.cs b/Source/Game/BattleGrounds/Zones/AlteracValley.cs index 6e04f1b23..3e585661e 100644 --- a/Source/Game/BattleGrounds/Zones/AlteracValley.cs +++ b/Source/Game/BattleGrounds/Zones/AlteracValley.cs @@ -37,7 +37,7 @@ namespace Game.BattleGrounds.Zones.AlteracValley for (byte j = 0; j < 9; j++) m_Team_QuestStatus[i][j] = 0; - _captainBuffTimer[i].Reset(120000 + RandomHelper.URand(0, 4) * 60); //as far as i could see, the buff is randomly so i make 2minutes (thats the duration of the buff itself) + 0-4minutes @todo get the right times + _captainBuffTimer[i] = new(120000 + RandomHelper.URand(0, 4) * 60); //as far as i could see, the buff is randomly so i make 2minutes (thats the duration of the buff itself) + 0-4minutes @todo get the right times } _mineInfo[(byte)AlteracValleyMine.North] = new AlteracValleyMineInfo(Team.Other, new StaticMineInfo(WorldStateIds.IrondeepMineOwner, WorldStateIds.IrondeepMineAllianceControlled, WorldStateIds.IrondeepMineHordeControlled, WorldStateIds.IrondeepMineTroggControlled, (byte)TextIds.IrondeepMineAllianceTaken, (byte)TextIds.IrondeepMineHordeTaken)); @@ -53,7 +53,7 @@ namespace Game.BattleGrounds.Zones.AlteracValley InitNode(i, Team.Horde, true); InitNode(AVNodes.SnowfallGrave, Team.Other, false); //give snowfall neutral owner - _mineResourceTimer.Reset(MiscConst.MineResourceTimer); + _mineResourceTimer = new(MiscConst.MineResourceTimer); StartMessageIds[BattlegroundConst.EventIdSecond] = (uint)BroadcastTextIds.StartOneMinute; StartMessageIds[BattlegroundConst.EventIdThird] = (uint)BroadcastTextIds.StartHalfMinute; diff --git a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs index d1de6477e..51b7b1f44 100644 --- a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs +++ b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs @@ -3,8 +3,9 @@ using Framework.Constants; using Game.Entities; +using Game.Entities.GameObjectType; using Game.Maps; -using Game.Networking.Packets; +using Game.Spells; using System; using System.Collections.Generic; @@ -12,98 +13,78 @@ namespace Game.BattleGrounds.Zones.EyeofStorm { class BgEyeofStorm : Battleground { + uint[] m_HonorScoreTics = new uint[SharedConst.PvpTeamsCount]; + uint m_FlagCapturedBgObjectType; // type that should be despawned when flag is captured + + TimeTracker _pointsTimer; + uint m_HonorTics; + + Dictionary _controlZoneHandlers = new(); + List _doorGUIDs = new(); + ObjectGuid _flagGUID; + + // Focused/Brutal Assault + bool _assaultEnabled; + TimeTracker _flagAssaultTimer; + byte _assaultStackCount; + public BgEyeofStorm(BattlegroundTemplate battlegroundTemplate) : base(battlegroundTemplate) { - 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[BatttleGroundTeamId.Alliance] = 0; - m_HonorScoreTics[BatttleGroundTeamId.Horde] = 0; - m_TeamPointsCount[BatttleGroundTeamId.Alliance] = 0; - m_TeamPointsCount[BatttleGroundTeamId.Horde] = 0; - m_FlagKeeper.Clear(); - m_DroppedFlagGUID.Clear(); + m_HonorScoreTics = [0, 0]; m_FlagCapturedBgObjectType = 0; - m_FlagState = FlagState.OnBase; - m_FlagsTimer = 0; - m_TowerCapCheckTimer = 0; - m_PointAddingTimer = 0; m_HonorTics = 0; - - for (byte i = 0; i < Points.PointsMax; ++i) - { - m_PointOwnedByTeam[i] = Team.Other; - m_PointState[i] = PointState.Uncontrolled; - m_PointBarStatus[i] = ProgressBarConsts.ProgressBarStateMiddle; - m_LastPointCaptureStatus[i] = BattlegroundPointCaptureStatus.Neutral; - } - - for (byte i = 0; i < Points.PointsMax + 1; ++i) - m_PlayersNearPoint[i] = new List(); - - for (byte i = 0; i < 2 * Points.PointsMax; ++i) - m_CurrentPointPlayersCount[i] = 0; + _pointsTimer = new(MiscConst.PointsTickTime); + _assaultEnabled = false; + _assaultStackCount = 0; + _flagAssaultTimer = new(MiscConst.FlagAssaultTimer); } public override void PostUpdateImpl(uint diff) { if (GetStatus() == BattlegroundStatus.InProgress) { - m_PointAddingTimer -= (int)diff; - if (m_PointAddingTimer <= 0) + _pointsTimer.Update(diff); + if (_pointsTimer.Passed()) { - m_PointAddingTimer = Misc.FPointsTickTime; - if (m_TeamPointsCount[BatttleGroundTeamId.Alliance] > 0) - AddPoints(Team.Alliance, Misc.TickPoints[m_TeamPointsCount[BatttleGroundTeamId.Alliance] - 1]); - if (m_TeamPointsCount[BatttleGroundTeamId.Horde] > 0) - AddPoints(Team.Horde, Misc.TickPoints[m_TeamPointsCount[BatttleGroundTeamId.Horde] - 1]); + _pointsTimer.Reset(MiscConst.PointsTickTime); + + byte baseCountAlliance = GetControlledBaseCount(BatttleGroundTeamId.Alliance); + byte baseCountHorde = GetControlledBaseCount(BatttleGroundTeamId.Horde); + if (baseCountAlliance > 0) + AddPoints(Team.Alliance, MiscConst.TickPoints[baseCountAlliance - 1]); + if (baseCountHorde > 0) + AddPoints(Team.Horde, MiscConst.TickPoints[baseCountHorde - 1]); } - if (m_FlagState == FlagState.WaitRespawn || m_FlagState == FlagState.OnGround) + if (_assaultEnabled) { - m_FlagsTimer -= (int)diff; - - if (m_FlagsTimer < 0) + _flagAssaultTimer.Update(diff); + if (_flagAssaultTimer.Passed()) { - m_FlagsTimer = 0; - if (m_FlagState == FlagState.WaitRespawn) - RespawnFlag(true); - else - RespawnFlagAfterDrop(); + _flagAssaultTimer.Reset(MiscConst.FlagAssaultTimer); + _assaultStackCount++; + + // update assault debuff stacks + DoForFlagKeepers(player => ApplyAssaultDebuffToPlayer(player)); } } } } - public override void StartingEventCloseDoors() - { - SpawnBGObject(ObjectTypes.DoorA, BattlegroundConst.RespawnImmediately); - SpawnBGObject(ObjectTypes.DoorH, BattlegroundConst.RespawnImmediately); - - for (int i = ObjectTypes.ABannerFelReaverCenter; i < ObjectTypes.Max; ++i) - SpawnBGObject(i, BattlegroundConst.RespawnOneDay); - } - public override void StartingEventOpenDoors() { - SpawnBGObject(ObjectTypes.DoorA, BattlegroundConst.RespawnOneDay); - SpawnBGObject(ObjectTypes.DoorH, BattlegroundConst.RespawnOneDay); - - for (int i = ObjectTypes.NBannerFelReaverLeft; i <= ObjectTypes.FlagNetherstorm; ++i) - SpawnBGObject(i, BattlegroundConst.RespawnImmediately); - - for (int i = 0; i < Points.PointsMax; ++i) + foreach (ObjectGuid door in _doorGUIDs) { - //randomly spawn buff - byte buff = (byte)RandomHelper.URand(0, 2); - SpawnBGObject(ObjectTypes.SpeedbuffFelReaver + buff + i * 3, BattlegroundConst.RespawnImmediately); + GameObject gameObject = GetBgMap().GetGameObject(door); + if (gameObject != null) + { + gameObject.UseDoorOrButton(); + gameObject.DespawnOrUnsummon(TimeSpan.FromSeconds(3)); + } } // Achievement: Flurry - TriggerGameEvent(Misc.EventStartBattle); + TriggerGameEvent(MiscConst.EventStartBattle); } void AddPoints(Team Team, uint Points) @@ -119,20 +100,75 @@ namespace Game.BattleGrounds.Zones.EyeofStorm UpdateTeamScore(team_index); } - BattlegroundPointCaptureStatus GetPointCaptureStatus(uint point) + byte GetControlledBaseCount(int teamId) { - if (m_PointBarStatus[point] >= ProgressBarConsts.ProgressBarAliControlled) - return BattlegroundPointCaptureStatus.AllianceControlled; + byte baseCount = 0; + foreach (var controlZoneHandler in _controlZoneHandlers) + { + uint point = controlZoneHandler.Value.GetPoint(); + switch (teamId) + { + case BatttleGroundTeamId.Alliance: + if (GetBgMap().GetWorldStateValue(MiscConst.m_PointsIconStruct[point].WorldStateAllianceControlledIndex) == 1) + baseCount++; + break; + case BatttleGroundTeamId.Horde: + if (GetBgMap().GetWorldStateValue(MiscConst.m_PointsIconStruct[point].WorldStateHordeControlledIndex) == 1) + baseCount++; + break; + default: + break; + } + } + return baseCount; + } - if (m_PointBarStatus[point] <= ProgressBarConsts.ProgressBarHordeControlled) - return BattlegroundPointCaptureStatus.HordeControlled; + void DoForFlagKeepers(Action action) + { + GameObject flag = GetBgMap().GetGameObject(_flagGUID); + if (flag != null) + { + Player carrier = Global.ObjAccessor.FindPlayer(flag.GetFlagCarrierGUID()); + if (carrier != null) + action(carrier); + } + } - if (m_CurrentPointPlayersCount[2 * point] == m_CurrentPointPlayersCount[2 * point + 1]) - return BattlegroundPointCaptureStatus.Neutral; + void ResetAssaultDebuff() + { + _assaultEnabled = false; + _assaultStackCount = 0; + _flagAssaultTimer.Reset(MiscConst.FlagAssaultTimer); + DoForFlagKeepers(RemoveAssaultDebuffFromPlayer); + } - return m_CurrentPointPlayersCount[2 * point] > m_CurrentPointPlayersCount[2 * point + 1] - ? BattlegroundPointCaptureStatus.AllianceCapturing - : BattlegroundPointCaptureStatus.HordeCapturing; + void ApplyAssaultDebuffToPlayer(Player player) + { + if (_assaultStackCount == 0) + return; + + uint spellId = MiscConst.SpellFocusedAssault; + if (_assaultStackCount >= MiscConst.FlagBrutalAssaultStackCount) + { + player.RemoveAurasDueToSpell(MiscConst.SpellFocusedAssault); + spellId = MiscConst.SpellBrutalAssault; + } + + Aura aura = player.GetAura(spellId); + if (aura == null) + { + player.CastSpell(player, spellId, true); + aura = player.GetAura(spellId); + } + + if (aura != null) + aura.SetStackAmount(_assaultStackCount); + } + + void RemoveAssaultDebuffFromPlayer(Player player) + { + player.RemoveAurasDueToSpell(MiscConst.SpellFocusedAssault); + player.RemoveAurasDueToSpell(MiscConst.SpellBrutalAssault); } void UpdateTeamScore(int team) @@ -160,6 +196,7 @@ namespace Game.BattleGrounds.Zones.EyeofStorm RewardHonorToTeam(GetBonusHonorFromKill(1), Team.Alliance); if (winner == Team.Horde) RewardHonorToTeam(GetBonusHonorFromKill(1), Team.Horde); + // Complete map reward RewardHonorToTeam(GetBonusHonorFromKill(1), Team.Alliance); RewardHonorToTeam(GetBonusHonorFromKill(1), Team.Horde); @@ -167,461 +204,70 @@ namespace Game.BattleGrounds.Zones.EyeofStorm base.EndBattleground(winner); } - void UpdatePointsCount(Team team) + void UpdatePointsCount(uint teamId) { - if (team == Team.Alliance) - UpdateWorldState(WorldStateIds.AllianceBase, (int)m_TeamPointsCount[BatttleGroundTeamId.Alliance]); + if (teamId == BatttleGroundTeamId.Alliance) + UpdateWorldState(WorldStateIds.AllianceBase, GetControlledBaseCount(BatttleGroundTeamId.Alliance)); else - UpdateWorldState(WorldStateIds.HordeBase, (int)m_TeamPointsCount[BatttleGroundTeamId.Horde]); + UpdateWorldState(WorldStateIds.HordeBase, GetControlledBaseCount(BatttleGroundTeamId.Horde)); } - void UpdatePointsIcons(Team team, uint Point) + public override void OnGameObjectCreate(GameObject gameobject) { - //we MUST firstly send 0, after that we can send 1!!! - if (m_PointState[Point] == PointState.UnderControl) + switch (gameobject.GetEntry()) { - UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateControlIndex, 0); - if (team == Team.Alliance) - UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 1); - else - UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 1); - } - else - { - if (team == Team.Alliance) - UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateAllianceControlledIndex, 0); - else - UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateHordeControlledIndex, 0); - UpdateWorldState(Misc.m_PointsIconStruct[Point].WorldStateControlIndex, 1); - } - } - - public override void RemovePlayer(Player player, ObjectGuid guid, Team team) - { - // sometimes flag aura not removed :( - for (int j = Points.PointsMax; j >= 0; --j) - { - for (int i = 0; i < m_PlayersNearPoint[j].Count; ++i) - if (m_PlayersNearPoint[j][i] == guid) - m_PlayersNearPoint[j].RemoveAt(i); - } - if (IsFlagPickedup()) - { - if (m_FlagKeeper == guid) - { - if (player != null) - EventPlayerDroppedFlag(player); - else - { - SetFlagPicker(ObjectGuid.Empty); - RespawnFlag(true); - } - } - } - } - - [Obsolete("Remove me when eye of the storm is updated.")] - public override void HandleAreaTrigger(Player player, uint trigger, bool entered) - { - if (!player.IsAlive()) //hack code, must be removed later - return; - - switch (trigger) - { - case 4530: // Horde Start - case 4531: // Alliance Start - if (GetStatus() == BattlegroundStatus.WaitJoin && !entered) - TeleportPlayerToExploitLocation(player); + case GameobjectIds.ADoorEyEntry: + case GameobjectIds.HDoorEyEntry: + _doorGUIDs.Add(gameobject.GetGUID()); break; - 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, ObjectTypes.FlagBloodElf); - break; - 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, ObjectTypes.FlagFelReaver); - break; - 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, ObjectTypes.FlagMageTower); - break; - 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, ObjectTypes.FlagDraeneiRuins); - break; - case 4512: - case 4515: - case 4517: - case 4519: - case 4568: - case 4569: - case 4570: - case 4571: - case 5866: + case GameobjectIds.Flag2EyEntry: + _flagGUID = gameobject.GetGUID(); break; default: - base.HandleAreaTrigger(player, trigger, entered); break; } } - public override bool SetupBattleground() + public override bool CanCaptureFlag(AreaTrigger areaTrigger, Player player) { - // doors - 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(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(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(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(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(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(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."); + if (areaTrigger.GetEntry() != MiscConst.AreatriggerCaptureFlag) return false; + + GameObject flag = GetBgMap().GetGameObject(_flagGUID); + if (flag != null) + { + if (flag.GetFlagCarrierGUID() != player.GetGUID()) + return false; } - WorldSafeLocsEntry sg = Global.ObjectMgr.GetWorldSafeLoc(GaveyardIds.MainAlliance); - if (sg == null || !AddSpiritGuide(CreaturesTypes.SpiritMainAlliance, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.124139f, BatttleGroundTeamId.Alliance)) + GameObject controlzone = player.FindNearestGameObjectWithOptions(40.0f, new FindGameObjectOptions() { StringId = "bg_eye_of_the_storm_control_zone" }); + if (controlzone != null) { - Log.outError(LogFilter.Sql, "BatteGroundEY: Failed to spawn spirit guide. The battleground was not created."); - return false; - } - - sg = Global.ObjectMgr.GetWorldSafeLoc(GaveyardIds.MainHorde); - if (sg == null || !AddSpiritGuide(CreaturesTypes.SpiritMainHorde, sg.Loc.GetPositionX(), sg.Loc.GetPositionY(), sg.Loc.GetPositionZ(), 3.193953f, BatttleGroundTeamId.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; - } - - public override void Reset() - { - //call parent's class reset - base.Reset(); - - m_TeamScores[BatttleGroundTeamId.Alliance] = 0; - m_TeamScores[BatttleGroundTeamId.Horde] = 0; - m_TeamPointsCount[BatttleGroundTeamId.Alliance] = 0; - m_TeamPointsCount[BatttleGroundTeamId.Horde] = 0; - m_HonorScoreTics[BatttleGroundTeamId.Alliance] = 0; - m_HonorScoreTics[BatttleGroundTeamId.Horde] = 0; - 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) ? Misc.EYWeekendHonorTicks : Misc.NotEYWeekendHonorTicks; - - for (byte i = 0; i < Points.PointsMax; ++i) - { - m_PointOwnedByTeam[i] = Team.Other; - m_PointState[i] = PointState.Uncontrolled; - m_PointBarStatus[i] = ProgressBarConsts.ProgressBarStateMiddle; - m_PlayersNearPoint[i].Clear(); - } - m_PlayersNearPoint[Points.PlayersOutOfPoints].Clear(); - } - - void RespawnFlag(bool send_message) - { - if (m_FlagCapturedBgObjectType > 0) - SpawnBGObject((int)m_FlagCapturedBgObjectType, BattlegroundConst.RespawnOneDay); - - m_FlagCapturedBgObjectType = 0; - m_FlagState = FlagState.OnBase; - SpawnBGObject(ObjectTypes.FlagNetherstorm, BattlegroundConst.RespawnImmediately); - - if (send_message) - { - SendBroadcastText(BroadcastTextIds.FlagReset, ChatMsg.BgSystemNeutral); - PlaySoundToAll(SoundIds.FlagReset); // flags respawned sound... - } - - UpdateWorldState(WorldStateIds.NetherstormFlag, 1); - } - - void RespawnFlagAfterDrop() - { - RespawnFlag(true); - - GameObject obj = GetBgMap().GetGameObject(GetDroppedFlagGUID()); - if (obj != null) - obj.Delete(); - else - Log.outError(LogFilter.Battleground, "BattlegroundEY: Unknown dropped flag ({0}).", GetDroppedFlagGUID().ToString()); - - SetDroppedFlagGUID(ObjectGuid.Empty); - } - - public override void HandleKillPlayer(Player player, Player killer) - { - if (GetStatus() != BattlegroundStatus.InProgress) - return; - - base.HandleKillPlayer(player, killer); - EventPlayerDroppedFlag(player); - } - - public override void EventPlayerDroppedFlag(Player player) - { - if (GetStatus() != BattlegroundStatus.InProgress) - { - // if not running, do not cast things at the dropper player, neither send unnecessary messages - // just take off the aura - if (IsFlagPickedup() && GetFlagPickerGUID() == player.GetGUID()) + uint point = _controlZoneHandlers[controlzone.GetEntry()].GetPoint(); + switch (GetPlayerTeam(player.GetGUID())) { - SetFlagPicker(ObjectGuid.Empty); - player.RemoveAurasDueToSpell(Misc.SpellNetherstormFlag); + case Team.Alliance: + return GetBgMap().GetWorldStateValue(MiscConst.m_PointsIconStruct[point].WorldStateAllianceControlledIndex) == 1; + case Team.Horde: + return GetBgMap().GetWorldStateValue(MiscConst.m_PointsIconStruct[point].WorldStateHordeControlledIndex) == 1; + default: + return false; } - return; } - if (!IsFlagPickedup()) - return; - - if (GetFlagPickerGUID() != player.GetGUID()) - return; - - SetFlagPicker(ObjectGuid.Empty); - player.RemoveAurasDueToSpell(Misc.SpellNetherstormFlag); - m_FlagState = FlagState.OnGround; - m_FlagsTimer = Misc.FlagRespawnTime; - player.CastSpell(player, BattlegroundConst.SpellRecentlyDroppedFlag, true); - player.CastSpell(player, Misc.SpellPlayerDroppedFlag, true); - //this does not work correctly :((it should remove flag carrier name) - UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)FlagState.WaitRespawn); - UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)FlagState.WaitRespawn); - - if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) - SendBroadcastText(BroadcastTextIds.FlagDropped, ChatMsg.BgSystemAlliance, null); - else - SendBroadcastText(BroadcastTextIds.FlagDropped, ChatMsg.BgSystemHorde, null); + return false; } - public override void EventPlayerClickedOnFlag(Player player, GameObject target_obj) + public override void OnCaptureFlag(AreaTrigger areaTrigger, Player player) { - if (GetStatus() != BattlegroundStatus.InProgress || IsFlagPickedup() || !player.IsWithinDistInMap(target_obj, 10)) + if (areaTrigger.GetEntry() != MiscConst.AreatriggerCaptureFlag) return; - if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) - { - UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)FlagState.OnPlayer); - PlaySoundToAll(SoundIds.FlagPickedUpAlliance); - } - else - { - UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)FlagState.OnPlayer); - PlaySoundToAll(SoundIds.FlagPickedUpHorde); - } + uint baseCount = GetControlledBaseCount(GetTeamIndexByTeamId(GetPlayerTeam(player.GetGUID()))); - if (m_FlagState == FlagState.OnBase) - UpdateWorldState(WorldStateIds.NetherstormFlag, 0); - m_FlagState = FlagState.OnPlayer; - - SpawnBGObject(ObjectTypes.FlagNetherstorm, BattlegroundConst.RespawnOneDay); - SetFlagPicker(player.GetGUID()); - //get flag aura on player - player.CastSpell(player, Misc.SpellNetherstormFlag, true); - player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.PvPActive); - - if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) - SendBroadcastText(BroadcastTextIds.TakenFlag, ChatMsg.BgSystemAlliance, player); - else - SendBroadcastText(BroadcastTextIds.TakenFlag, ChatMsg.BgSystemHorde, player); - } - - public void EventTeamLostPoint(Team team, uint point, WorldObject controlZone) - { - if (GetStatus() != BattlegroundStatus.InProgress) - return; - - if (team == 0) - return; - - if (team == Team.Alliance) - { - m_TeamPointsCount[BatttleGroundTeamId.Alliance]--; - 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[BatttleGroundTeamId.Horde]--; - 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(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] = PointState.NoOwner; - - if (team == Team.Alliance) - SendBroadcastText(Misc.m_LosingPointTypes[point].MessageIdAlliance, ChatMsg.BgSystemAlliance, controlZone); - else - SendBroadcastText(Misc.m_LosingPointTypes[point].MessageIdHorde, ChatMsg.BgSystemHorde, controlZone); - - UpdatePointsIcons(team, point); - UpdatePointsCount(team); - - //remove bonus honor aura trigger creature when node is lost - if (point < Points.PointsMax) - DelCreature(point + 6);//null checks are in DelCreature! 0-5 spirit guides - } - - public void EventTeamCapturedPoint(Team team, uint point, WorldObject controlZone) - { - if (GetStatus() != BattlegroundStatus.InProgress) - return; - - 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); - - if (team == Team.Alliance) - { - m_TeamPointsCount[BatttleGroundTeamId.Alliance]++; - 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[BatttleGroundTeamId.Horde]++; - 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] = PointState.UnderControl; - - if (team == Team.Alliance) - SendBroadcastText(Misc.m_CapturingPointTypes[point].MessageIdAlliance, ChatMsg.BgSystemAlliance, controlZone); - else - SendBroadcastText(Misc.m_CapturingPointTypes[point].MessageIdHorde, ChatMsg.BgSystemHorde, controlZone); - - if (!BgCreatures[point].IsEmpty()) - DelCreature(point); - - 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, Misc.m_CapturingPointTypes[point].GraveyardId); - - // SpawnBGCreature(Point, RESPAWN_IMMEDIATELY); - - UpdatePointsIcons(team, point); - UpdatePointsCount(team); - - if (point >= Points.PointsMax) - return; - - Creature trigger = GetBGCreature(point + 6);//0-5 spirit guides - if (trigger == null) - 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.CastSpell(trigger, BattlegroundConst.SpellHonorableDefender25y, false); - } - } - - void EventPlayerCapturedFlag(Player player, uint BgObjectType) - { - if (GetStatus() != BattlegroundStatus.InProgress || GetFlagPickerGUID() != player.GetGUID()) - return; - - SetFlagPicker(ObjectGuid.Empty); - m_FlagState = FlagState.WaitRespawn; - player.RemoveAurasDueToSpell(Misc.SpellNetherstormFlag); - - player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.PvPActive); + GameObject gameObject = GetBgMap().GetGameObject(_flagGUID); + if (gameObject != null) + gameObject.HandleCustomTypeCommand(new SetNewFlagState(FlagState.Respawning, player)); Team team = GetPlayerTeam(player.GetGUID()); if (team == Team.Alliance) @@ -635,76 +281,137 @@ namespace Game.BattleGrounds.Zones.EyeofStorm PlaySoundToAll(SoundIds.FlagCapturedHorde); } - SpawnBGObject((int)BgObjectType, BattlegroundConst.RespawnImmediately); + if (baseCount > 0) + AddPoints(team, MiscConst.FlagPoints[baseCount - 1]); - m_FlagsTimer = Misc.FlagRespawnTime; - m_FlagCapturedBgObjectType = BgObjectType; + UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)EYFlagState.OnBase); + UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)EYFlagState.OnBase); - int team_id = GetTeamIndexByTeamId(team); - if (m_TeamPointsCount[team_id] > 0) - AddPoints(team, Misc.FlagPoints[m_TeamPointsCount[team_id] - 1]); + UpdatePvpStat(player, MiscConst.PvpStatFlagCaptures, 1); - UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)FlagState.OnBase); - UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)FlagState.OnBase); - - UpdatePvpStat(player, (uint)EyeOfTheStormPvpStats.FlagCaptures, 1); + player.RemoveAurasDueToSpell(MiscConst.SpellNetherstormFlag); + player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.PvPActive); } - public override WorldSafeLocsEntry GetClosestGraveyard(Player player) + public override void OnFlagStateChange(GameObject flagInBase, FlagState oldValue, FlagState newValue, Player player) { - uint g_id; - Team team = GetPlayerTeam(player.GetGUID()); - switch (team) + switch (newValue) { - case Team.Alliance: - g_id = GaveyardIds.MainAlliance; + case FlagState.InBase: + ResetAssaultDebuff(); break; - case Team.Horde: - g_id = GaveyardIds.MainHorde; + case FlagState.Dropped: + player.CastSpell(player, BattlegroundConst.SpellRecentlyDroppedNeutralFlag, true); + RemoveAssaultDebuffFromPlayer(player); + + UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)EYFlagState.WaitRespawn); + UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)EYFlagState.WaitRespawn); + + if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) + SendBroadcastText(BroadcastTextIds.FlagDropped, ChatMsg.BgSystemAlliance); + else + SendBroadcastText(BroadcastTextIds.FlagDropped, ChatMsg.BgSystemHorde); break; - default: return null; - } - - WorldSafeLocsEntry entry = Global.ObjectMgr.GetWorldSafeLoc(g_id); - WorldSafeLocsEntry nearestEntry = entry; - if (entry == null) - { - Log.outError(LogFilter.Battleground, "BattlegroundEY: The main team graveyard could not be found. The graveyard system will not be operational!"); - return null; - } - - float plr_x = player.GetPositionX(); - float plr_y = player.GetPositionY(); - float plr_z = player.GetPositionZ(); - - 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 < Points.PointsMax; ++i) - { - if (m_PointOwnedByTeam[i] == team && m_PointState[i] == PointState.UnderControl) - { - entry = Global.ObjectMgr.GetWorldSafeLoc(Misc.m_CapturingPointTypes[i].GraveyardId); - if (entry == null) - Log.outError(LogFilter.Battleground, "BattlegroundEY: Graveyard {0} could not be found.", Misc.m_CapturingPointTypes[i].GraveyardId); + case FlagState.Taken: + if (GetPlayerTeam(player.GetGUID()) == Team.Alliance) + { + UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)EYFlagState.OnPlayer); + PlaySoundToAll(SoundIds.FlagPickedUpAlliance); + SendBroadcastText(BroadcastTextIds.TakenFlag, ChatMsg.BgSystemAlliance, player); + } 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); - if (distance < nearestDistance) - { - nearestDistance = distance; - nearestEntry = entry; - } + UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)EYFlagState.OnPlayer); + PlaySoundToAll(SoundIds.FlagPickedUpHorde); + SendBroadcastText(BroadcastTextIds.TakenFlag, ChatMsg.BgSystemHorde, player); } - } + + ApplyAssaultDebuffToPlayer(player); + _assaultEnabled = true; + + player.RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags.PvPActive); + break; + case FlagState.Respawning: + ResetAssaultDebuff(); + break; + default: + break; } - return nearestEntry; + UpdateWorldState(WorldStateIds.NetherstormFlag, (int)newValue); + } + + public override bool SetupBattleground() + { + UpdateWorldState(WorldStateIds.MaxResources, (int)ScoreIds.MaxTeamScore); + + _controlZoneHandlers[GameobjectIds.FrTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.FelReaver); + _controlZoneHandlers[GameobjectIds.BeTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.BloodElf); + _controlZoneHandlers[GameobjectIds.DrTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.DraeneiRuins); + _controlZoneHandlers[GameobjectIds.HuTowerCapEyEntry] = new BgEyeOfStormControlZoneHandler(this, Points.MageTower); + + return true; + } + + public override void Reset() + { + //call parent's class reset + base.Reset(); + + m_TeamScores[BatttleGroundTeamId.Alliance] = 0; + m_TeamScores[BatttleGroundTeamId.Horde] = 0; + m_HonorScoreTics = [0, 0]; + m_FlagCapturedBgObjectType = 0; + bool isBGWeekend = Global.BattlegroundMgr.IsBGWeekend(GetTypeID()); + m_HonorTics = isBGWeekend ? MiscConst.EYWeekendHonorTicks : MiscConst.NotEYWeekendHonorTicks; + } + + public override void HandleKillPlayer(Player player, Player killer) + { + if (GetStatus() != BattlegroundStatus.InProgress) + return; + + base.HandleKillPlayer(player, killer); + EventPlayerDroppedFlag(player); + } + + public void EventTeamLostPoint(uint teamId, uint point, WorldObject controlZone) + { + if (teamId == BatttleGroundTeamId.Alliance) + { + SendBroadcastText(MiscConst.m_LosingPointTypes[point].MessageIdAlliance, ChatMsg.BgSystemAlliance, controlZone); + UpdateWorldState(MiscConst.m_PointsIconStruct[point].WorldStateAllianceControlledIndex, 0); + } + else if (teamId == BatttleGroundTeamId.Horde) + { + SendBroadcastText(MiscConst.m_LosingPointTypes[point].MessageIdHorde, ChatMsg.BgSystemHorde, controlZone); + UpdateWorldState(MiscConst.m_PointsIconStruct[point].WorldStateHordeControlledIndex, 0); + } + + UpdateWorldState(MiscConst.m_PointsIconStruct[point].WorldStateControlIndex, 1); + UpdatePointsCount(teamId); + } + + public void EventTeamCapturedPoint(uint teamId, uint point, WorldObject controlZone) + { + if (teamId == BatttleGroundTeamId.Alliance) + { + SendBroadcastText(MiscConst.m_CapturingPointTypes[point].MessageIdAlliance, ChatMsg.BgSystemAlliance, controlZone); + UpdateWorldState(MiscConst.m_PointsIconStruct[point].WorldStateAllianceControlledIndex, 1); + } + else if (teamId == BatttleGroundTeamId.Horde) + { + SendBroadcastText(MiscConst.m_CapturingPointTypes[point].MessageIdHorde, ChatMsg.BgSystemHorde, controlZone); + UpdateWorldState(MiscConst.m_PointsIconStruct[point].WorldStateHordeControlledIndex, 1); + } + + UpdateWorldState(MiscConst.m_PointsIconStruct[point].WorldStateControlIndex, 0); + UpdatePointsCount(teamId); } public override WorldSafeLocsEntry GetExploitTeleportLocation(Team team) { - return Global.ObjectMgr.GetWorldSafeLoc(team == Team.Alliance ? Misc.ExploitTeleportLocationAlliance : Misc.ExploitTeleportLocationHorde); + return Global.ObjectMgr.GetWorldSafeLoc(team == Team.Alliance ? MiscConst.ExploitTeleportLocationAlliance : MiscConst.ExploitTeleportLocationHorde); } public override Team GetPrematureWinner() @@ -728,19 +435,11 @@ namespace Game.BattleGrounds.Zones.EyeofStorm { if (gameobject.GetGoType() == GameObjectTypes.ControlZone) { - if (!ControlZoneHandlers.TryGetValue(gameobject.GetEntry(), out BgEyeOfStormControlZoneHandler handler)) + 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) + if (eventId == controlzone.NeutralEventAlliance) handler.HandleNeutralEventAlliance(gameobject); else if (eventId == controlzone.NeutralEventHorde) handler.HandleNeutralEventHorde(gameobject); @@ -753,41 +452,14 @@ namespace Game.BattleGrounds.Zones.EyeofStorm } } - public override ObjectGuid GetFlagPickerGUID(int team = -1) { return m_FlagKeeper; } - void SetFlagPicker(ObjectGuid guid) { m_FlagKeeper = guid; } - bool IsFlagPickedup() { return !m_FlagKeeper.IsEmpty(); } + void RemovePoint(Team team, uint Points = 1) { m_TeamScores[GetTeamIndexByTeamId(team)] -= Points; } - public override void SetDroppedFlagGUID(ObjectGuid guid, int TeamID = -1) { m_DroppedFlagGUID = guid; } - ObjectGuid GetDroppedFlagGUID() { return m_DroppedFlagGUID; } - - uint[] m_HonorScoreTics = new uint[2]; - uint[] m_TeamPointsCount = new uint[2]; - - 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 - FlagState m_FlagState; // for checking flag state - int m_FlagsTimer; - int m_TowerCapCheckTimer; - - 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(); + void SetTeamPoint(Team team, uint Points = 0) { m_TeamScores[GetTeamIndexByTeamId(team)] = Points; } } struct BgEyeOfStormPointIconsStruct { - public BgEyeOfStormPointIconsStruct(uint worldStateControlIndex, uint worldStateAllianceControlledIndex, uint worldStateHordeControlledIndex, uint worldStateAllianceStatusBarIcon, uint worldStateHordeStatusBarIcon) + public BgEyeOfStormPointIconsStruct(uint worldStateControlIndex, int worldStateAllianceControlledIndex, int worldStateHordeControlledIndex, uint worldStateAllianceStatusBarIcon, uint worldStateHordeStatusBarIcon) { WorldStateControlIndex = worldStateControlIndex; WorldStateAllianceControlledIndex = worldStateAllianceControlledIndex; @@ -797,8 +469,8 @@ namespace Game.BattleGrounds.Zones.EyeofStorm } public uint WorldStateControlIndex; - public uint WorldStateAllianceControlledIndex; - public uint WorldStateHordeControlledIndex; + public int WorldStateAllianceControlledIndex; + public int WorldStateHordeControlledIndex; public uint WorldStateAllianceStatusBarIcon; public uint WorldStateHordeStatusBarIcon; } @@ -854,51 +526,54 @@ namespace Game.BattleGrounds.Zones.EyeofStorm public override void HandleProgressEventHorde(GameObject controlZone) { - _battleground.EventTeamCapturedPoint(Team.Horde, _point, controlZone); + _battleground.EventTeamCapturedPoint(BatttleGroundTeamId.Horde, _point, controlZone); } public override void HandleProgressEventAlliance(GameObject controlZone) { - _battleground.EventTeamCapturedPoint(Team.Alliance, _point, controlZone); + _battleground.EventTeamCapturedPoint(BatttleGroundTeamId.Alliance, _point, controlZone); } public override void HandleNeutralEventHorde(GameObject controlZone) { - _battleground.EventTeamLostPoint(Team.Horde, _point, controlZone); + _battleground.EventTeamLostPoint(BatttleGroundTeamId.Horde, _point, controlZone); } public override void HandleNeutralEventAlliance(GameObject controlZone) { - _battleground.EventTeamLostPoint(Team.Alliance, _point, controlZone); + _battleground.EventTeamLostPoint(BatttleGroundTeamId.Alliance, _point, controlZone); } + + public uint GetPoint() { return _point; } } - struct Misc + #region Constants + struct MiscConst { + public static TimeSpan PointsTickTime = TimeSpan.FromSeconds(2); + public static TimeSpan FlagAssaultTimer = TimeSpan.FromSeconds(30); + public static ushort FlagBrutalAssaultStackCount = 5; + public const uint EventStartBattle = 13180; // Achievement: Flurry - public const int FlagRespawnTime = (8 * Time.InMilliseconds); - public const int FPointsTickTime = (2 * Time.InMilliseconds); public const uint NotEYWeekendHonorTicks = 260; public const uint EYWeekendHonorTicks = 160; public const uint SpellNetherstormFlag = 34976; - public const uint SpellPlayerDroppedFlag = 34991; + // Focused/Brutal Assault + public const uint SpellFocusedAssault = 46392; + public const uint SpellBrutalAssault = 46393; public const uint ExploitTeleportLocationAlliance = 3773; public const uint ExploitTeleportLocationHorde = 3772; - public static Position[] TriggerPositions = - { - new Position(2044.28f, 1729.68f, 1189.96f, 0.017453f), // FEL_REAVER center - new Position(2048.83f, 1393.65f, 1194.49f, 0.20944f), // BLOOD_ELF center - new Position(2286.56f, 1402.36f, 1197.11f, 3.72381f), // DRAENEI_RUINS center - new Position(2284.48f, 1731.23f, 1189.99f, 2.89725f) // MAGE_TOWER center - }; - public static byte[] TickPoints = { 1, 2, 5, 10 }; public static uint[] FlagPoints = { 75, 85, 100, 500 }; + public const uint AreatriggerCaptureFlag = 33; + + public const uint PvpStatFlagCaptures = 183; + public static BgEyeOfStormPointIconsStruct[] m_PointsIconStruct = { new BgEyeOfStormPointIconsStruct(WorldStateIds.FelReaverUncontrol, WorldStateIds.FelReaverAllianceControl, WorldStateIds.FelReaverHordeControl, WorldStateIds.FelReaverAllianceControlState, WorldStateIds.FelReaverHordeControlState), @@ -953,53 +628,39 @@ namespace Game.BattleGrounds.Zones.EyeofStorm struct WorldStateIds { - public const uint AllianceResources = 1776; - public const uint HordeResources = 1777; - public const uint MaxResources = 1780; - public const uint AllianceBase = 2752; - public const uint HordeBase = 2753; - public const uint DraeneiRuinsHordeControl = 2733; - public const uint DraeneiRuinsAllianceControl = 2732; - public const uint DraeneiRuinsUncontrol = 2731; - public const uint MageTowerAllianceControl = 2730; - public const uint MageTowerHordeControl = 2729; - public const uint MageTowerUncontrol = 2728; - public const uint FelReaverHordeControl = 2727; - public const uint FelReaverAllianceControl = 2726; - public const uint FelReaverUncontrol = 2725; - public const uint BloodElfHordeControl = 2724; - public const uint BloodElfAllianceControl = 2723; - public const uint BloodElfUncontrol = 2722; - public const uint ProgressBarPercentGrey = 2720; //100 = Empty (Only Grey); 0 = Blue|Red (No Grey) - public const uint ProgressBarStatus = 2719; //50 Init!; 48 ... Hordak Bere .. 33 .. 0 = Full 100% Hordacky; 100 = Full Alliance - public const uint ProgressBarShow = 2718; //1 Init; 0 Druhy Send - Bez Messagu; 1 = Controlled Aliance - public const uint NetherstormFlag = 8863; + public const int AllianceResources = 1776; + public const int HordeResources = 1777; + public const int MaxResources = 1780; + public const int AllianceBase = 2752; + public const int HordeBase = 2753; + public const int DraeneiRuinsHordeControl = 2733; + public const int DraeneiRuinsAllianceControl = 2732; + public const int DraeneiRuinsUncontrol = 2731; + public const int MageTowerAllianceControl = 2730; + public const int MageTowerHordeControl = 2729; + public const int MageTowerUncontrol = 2728; + public const int FelReaverHordeControl = 2727; + public const int FelReaverAllianceControl = 2726; + public const int FelReaverUncontrol = 2725; + public const int BloodElfHordeControl = 2724; + public const int BloodElfAllianceControl = 2723; + public const int BloodElfUncontrol = 2722; + public const int ProgressBarPercentGrey = 2720; //100 = Empty (Only Grey); 0 = Blue|Red (No Grey) + public const int ProgressBarStatus = 2719; //50 Init!; 48 ... Hordak Bere .. 33 .. 0 = Full 100% Hordacky; 100 = Full Alliance + public const int ProgressBarShow = 2718; //1 Init; 0 Druhy Send - Bez Messagu; 1 = Controlled Aliance + public const int NetherstormFlag = 8863; //Set To 2 When Flag Is Picked Up; And To 1 If It Is Dropped - public const uint NetherstormFlagStateAlliance = 9808; - public const uint NetherstormFlagStateHorde = 9809; + public const int NetherstormFlagStateAlliance = 9808; + public const int NetherstormFlagStateHorde = 9809; - public const uint DraeneiRuinsHordeControlState = 17362; - public const uint DraeneiRuinsAllianceControlState = 17366; - public const uint MageTowerHordeControlState = 17361; - public const uint MageTowerAllianceControlState = 17368; - public const uint FelReaverHordeControlState = 17364; - public const uint FelReaverAllianceControlState = 17367; - public const uint BloodElfHordeControlState = 17363; - public const uint BloodElfAllianceControlState = 17365; - } - - enum ProgressBarConsts - { - PointMaxCapturersCount = 5, - PointRadius = 70, - ProgressBarDontShow = 0, - ProgressBarShow = 1, - ProgressBarPercentGrey = 40, - ProgressBarStateMiddle = 50, - ProgressBarHordeControlled = 0, - ProgressBarNeutralLow = 30, - ProgressBarNeutralHigh = 70, - ProgressBarAliControlled = 100 + public const int DraeneiRuinsHordeControlState = 17362; + public const int DraeneiRuinsAllianceControlState = 17366; + public const int MageTowerHordeControlState = 17361; + public const int MageTowerAllianceControlState = 17368; + public const int FelReaverHordeControlState = 17364; + public const int FelReaverAllianceControlState = 17367; + public const int BloodElfHordeControlState = 17363; + public const int BloodElfAllianceControlState = 17365; } struct SoundIds @@ -1012,7 +673,7 @@ namespace Game.BattleGrounds.Zones.EyeofStorm public const uint FlagReset = 8192; } - struct ObjectIds + struct GameobjectIds { public const uint ADoorEyEntry = 184719; //Alliance Door public const uint HDoorEyEntry = 184720; //Horde Door @@ -1039,18 +700,6 @@ namespace Game.BattleGrounds.Zones.EyeofStorm public const uint BerserkBuffMageTowerEyEntry = 184975; } - struct PointsTrigger - { - public const uint BloodElfPoint = 4476; - public const uint FelReaverPoint = 4514; - public const uint MageTowerPoint = 4516; - public const uint DraeneiRuinsPoint = 4518; - public const uint BloodElfBuff = 4568; - public const uint FelReaverBuff = 4569; - public const uint MageTowerBuff = 4570; - public const uint DraeneiRuinsBuff = 4571; - } - struct GaveyardIds { public const int MainAlliance = 1103; @@ -1072,23 +721,6 @@ namespace Game.BattleGrounds.Zones.EyeofStorm public const int PointsMax = 4; } - struct CreaturesTypes - { - public const uint SpiritFelReaver = 0; - public const uint SpiritBloodElf = 1; - public const uint SpiritDraeneiRuins = 2; - public const uint SpiritMageTower = 3; - public const int SpiritMainAlliance = 4; - public const int SpiritMainHorde = 5; - - public const uint TriggerFelReaver = 6; - public const uint TriggerBloodElf = 7; - public const uint TriggerDraeneiRuins = 8; - public const uint TriggerMageTower = 9; - - public const uint Max = 10; - } - struct ObjectTypes { public const int DoorA = 0; @@ -1160,23 +792,12 @@ namespace Game.BattleGrounds.Zones.EyeofStorm public const uint MaxTeamScore = 1500; } - enum FlagState + enum EYFlagState { OnBase = 0, WaitRespawn = 1, OnPlayer = 2, OnGround = 3 } - - enum PointState - { - NoOwner = 0, - Uncontrolled = 0, - UnderControl = 3 - } - - enum EyeOfTheStormPvpStats - { - FlagCaptures = 183 - } + #endregion } diff --git a/Source/Game/BattleGrounds/Zones/IsleofConquest.cs b/Source/Game/BattleGrounds/Zones/IsleofConquest.cs index d340b4f30..244659add 100644 --- a/Source/Game/BattleGrounds/Zones/IsleofConquest.cs +++ b/Source/Game/BattleGrounds/Zones/IsleofConquest.cs @@ -1,6 +1,6 @@ // Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. - + namespace Game.BattleGrounds.Zones { class BgIsleofConquest : Battleground diff --git a/Source/Game/BattleGrounds/Zones/WarsongGluch.cs b/Source/Game/BattleGrounds/Zones/WarsongGluch.cs index 3ce31e0e7..d83f23923 100644 --- a/Source/Game/BattleGrounds/Zones/WarsongGluch.cs +++ b/Source/Game/BattleGrounds/Zones/WarsongGluch.cs @@ -2,11 +2,10 @@ // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. using Framework.Constants; -using Game.Entities; -using Game.Networking.Packets; using Game.DataStorage; -using System.Collections.Generic; +using Game.Entities; using System; +using System.Collections.Generic; namespace Game.BattleGrounds.Zones { @@ -401,7 +400,7 @@ namespace Game.BattleGrounds.Zones if (set) { - player.CastSpell(player, BattlegroundConst.SpellRecentlyDroppedFlag, true); + player.CastSpell(player, BattlegroundConst.SpellRecentlyDroppedNeutralFlag, true); UpdateFlagState(team, WSGFlagState.OnGround); if (team == Team.Alliance) diff --git a/Source/Game/Entities/GameObject/GameObject.cs b/Source/Game/Entities/GameObject/GameObject.cs index 27c295283..1b07958bc 100644 --- a/Source/Game/Entities/GameObject/GameObject.cs +++ b/Source/Game/Entities/GameObject/GameObject.cs @@ -3615,7 +3615,7 @@ namespace Game.Entities return newFlag.GetState(); } - ObjectGuid GetFlagCarrierGUID() + public ObjectGuid GetFlagCarrierGUID() { if (GetGoType() != GameObjectTypes.NewFlag) return ObjectGuid.Empty; diff --git a/Source/Game/Entities/Player/Player.PvP.cs b/Source/Game/Entities/Player/Player.PvP.cs index 64bf3cb7c..488cb64b4 100644 --- a/Source/Game/Entities/Player/Player.PvP.cs +++ b/Source/Game/Entities/Player/Player.PvP.cs @@ -321,7 +321,7 @@ namespace Game.Entities return; if (!GetCombatManager().HasPvPCombat()) - { + { RemoveAurasDueToSpell(PlayerConst.SpellPvpRulesEnabled); UpdateItemLevelAreaBasedScaling(); } @@ -493,7 +493,7 @@ namespace Game.Entities return m_bgBattlegroundQueueID[i].mercenary; return false; } - + public WorldLocation GetBattlegroundEntryPoint() { return m_bgData.joinPos; } public bool InBattleground() { return m_bgData.bgInstanceID != 0; } @@ -520,10 +520,21 @@ namespace Game.Entities return false; } + bool hasRecentlyDroppedFlagDebuff = HasAura(aura => + { + if (aura.GetSpellInfo().Id == BattlegroundConst.SpellRecentlyDroppedAllianceFlag) + return true; + else if (aura.GetSpellInfo().Id == BattlegroundConst.SpellRecentlyDroppedHordeFlag) + return true; + else if (aura.GetSpellInfo().Id == BattlegroundConst.SpellRecentlyDroppedNeutralFlag) + return true; + return false; + }); + // BUG: sometimes when player clicks on flag in AB - client won't send gameobject_use, only gameobject_report_use packet // Note: Mount, stealth and invisibility will be removed when used return (!IsTotalImmune() && // Damage immune - !HasAura(BattlegroundConst.SpellRecentlyDroppedFlag) && // Still has recently held flag debuff + !hasRecentlyDroppedFlagDebuff && // Still has recently held flag debuff IsAlive()); // Alive } @@ -615,7 +626,7 @@ namespace Game.Entities } public bool IsDeserter() { return HasAura(26013); } - + public bool CanJoinToBattleground(BattlegroundTemplate bg) { RBACPermissions perm = RBACPermissions.JoinNormalBg; diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index 3ec9ff3b0..8ba26fca6 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -908,8 +908,6 @@ namespace Game.Spells case 23333: // Warsong Flag case 23335: // Silverwing Flag return map_id == 489 && player != null && player.InBattleground() ? SpellCastResult.SpellCastOk : SpellCastResult.RequiresArea; - case 34976: // Netherstorm Flag - return map_id == 566 && player != null && player.InBattleground() ? SpellCastResult.SpellCastOk : SpellCastResult.RequiresArea; case 2584: // Waiting to Resurrect case 42792: // Recently Dropped Flag case 43681: // Inactive