From 90ad7ed6ea3aabc7f2845a64d758885ea4882f56 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Sun, 4 Feb 2024 00:27:52 -0500 Subject: [PATCH] Core/Battleground: Rework BattlegroundScore Port From (https://github.com/TrinityCore/TrinityCore/commit/da0ec4f830c4428a17fd4e52124dca6c63e25961) --- .../Framework/Constants/BattleGroundsConst.cs | 19 ---- .../Database/Databases/HotfixDatabase.cs | 7 ++ Source/Game/Arenas/Arena.cs | 3 - Source/Game/Arenas/ArenaScore.cs | 42 --------- Source/Game/BattleGrounds/BattleGround.cs | 67 ++++++++----- .../Game/BattleGrounds/BattleGroundScore.cs | 94 +++++++++++++++---- .../Game/BattleGrounds/Zones/ArathiBasin.cs | 84 ++--------------- Source/Game/BattleGrounds/Zones/EyeofStorm.cs | 64 ++----------- .../BattleGrounds/Zones/StrandofAncients.cs | 62 +----------- .../Game/BattleGrounds/Zones/WarsongGluch.cs | 75 ++------------- Source/Game/DataStorage/CliDB.cs | 2 + Source/Game/DataStorage/DB2Manager.cs | 27 ++++-- Source/Game/DataStorage/Structs/P_Records.cs | 7 ++ 13 files changed, 184 insertions(+), 369 deletions(-) diff --git a/Source/Framework/Constants/BattleGroundsConst.cs b/Source/Framework/Constants/BattleGroundsConst.cs index a0cffaf21..cbba33a5f 100644 --- a/Source/Framework/Constants/BattleGroundsConst.cs +++ b/Source/Framework/Constants/BattleGroundsConst.cs @@ -332,25 +332,6 @@ namespace Framework.Constants BonusHonor = 4, DamageDone = 5, HealingDone = 6, - - // Ws And Ey - FlagCaptures = 7, - FlagReturns = 8, - - // Ab And Ic - BasesAssaulted = 9, - BasesDefended = 10, - - // Av - GraveyardsAssaulted = 11, - GraveyardsDefended = 12, - TowersAssaulted = 13, - TowersDefended = 14, - MinesCaptured = 15, - - // Sota - DestroyedDemolisher = 16, - DestroyedWall = 17 } //Arenas diff --git a/Source/Framework/Database/Databases/HotfixDatabase.cs b/Source/Framework/Database/Databases/HotfixDatabase.cs index 199160922..416cacd84 100644 --- a/Source/Framework/Database/Databases/HotfixDatabase.cs +++ b/Source/Framework/Database/Databases/HotfixDatabase.cs @@ -1028,6 +1028,10 @@ namespace Framework.Database // PvpItem.db2 PrepareStatement(HotfixStatements.SEL_PVP_ITEM, "SELECT ID, ItemID, ItemLevelDelta FROM pvp_item WHERE (`VerifiedBuild` > 0) = ?"); + // PvpStat.db2 + PrepareStatement(HotfixStatements.SEL_PVP_STAT, "SELECT Description, ID, MapID FROM pvp_stat WHERE (`VerifiedBuild` > 0) = ?"); + PrepareStatement(HotfixStatements.SEL_PVP_STAT_LOCALE, "SELECT ID, Description_lang FROM pvp_stat_locale WHERE (`VerifiedBuild` > 0) = ? AND locale = ?"); + // PvpSeason.db2 PrepareStatement(HotfixStatements.SEL_PVP_SEASON, "SELECT ID, MilestoneSeason, AllianceAchievementID, HordeAchievementID FROM pvp_season" + " WHERE (`VerifiedBuild` > 0) = ?"); @@ -2070,6 +2074,9 @@ namespace Framework.Database SEL_PVP_ITEM, + SEL_PVP_STAT, + SEL_PVP_STAT_LOCALE, + SEL_PVP_SEASON, SEL_PVP_TALENT, diff --git a/Source/Game/Arenas/Arena.cs b/Source/Game/Arenas/Arena.cs index 80b7186a4..a90593013 100644 --- a/Source/Game/Arenas/Arena.cs +++ b/Source/Game/Arenas/Arena.cs @@ -31,10 +31,7 @@ namespace Game.Arenas public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId) { - bool isInBattleground = IsPlayerInBattleground(player.GetGUID()); base.AddPlayer(player, queueId); - if (!isInBattleground) - PlayerScores[player.GetGUID()] = new ArenaScore(player.GetGUID(), player.GetBGTeam()); if (player.GetBGTeam() == Team.Alliance) // gold { diff --git a/Source/Game/Arenas/ArenaScore.cs b/Source/Game/Arenas/ArenaScore.cs index 4edbc4029..9a6c1695d 100644 --- a/Source/Game/Arenas/ArenaScore.cs +++ b/Source/Game/Arenas/ArenaScore.cs @@ -1,50 +1,8 @@ // Copyright (c) CypherCore All rights reserved. // Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information. -using Framework.Constants; -using Game.BattleGrounds; -using Game.Entities; -using Game.Networking.Packets; - namespace Game.Arenas { - class ArenaScore : BattlegroundScore - { - public ArenaScore(ObjectGuid playerGuid, Team team) : base(playerGuid, team) - { - TeamId = (int)(team == Team.Alliance ? PvPTeamId.Alliance : PvPTeamId.Horde); - } - - public override void BuildPvPLogPlayerDataPacket(out PVPMatchStatistics.PVPMatchPlayerStatistics playerData) - { - base.BuildPvPLogPlayerDataPacket(out playerData); - - if (PreMatchRating != 0) - playerData.PreMatchRating = PreMatchRating; - - if (PostMatchRating != PreMatchRating) - playerData.RatingChange = (int)(PostMatchRating - PreMatchRating); - - if (PreMatchMMR != 0) - playerData.PreMatchMMR = PreMatchMMR; - - if (PostMatchMMR != PreMatchMMR) - playerData.MmrChange = (int)(PostMatchMMR - PreMatchMMR); - } - - // For Logging purpose - public override string ToString() - { - return $"Damage done: {DamageDone} Healing done: {HealingDone} Killing blows: {KillingBlows} PreMatchRating: {PreMatchRating} " + - $"PreMatchMMR: {PreMatchMMR} PostMatchRating: {PostMatchRating} PostMatchMMR: {PostMatchMMR}"; - } - - uint PreMatchRating; - uint PreMatchMMR; - uint PostMatchRating; - uint PostMatchMMR; - } - public class ArenaTeamScore { public void Assign(uint preMatchRating, uint postMatchRating, uint preMatchMMR, uint postMatchMMR) diff --git a/Source/Game/BattleGrounds/BattleGround.cs b/Source/Game/BattleGrounds/BattleGround.cs index 0a381dec3..fb8f15b9f 100644 --- a/Source/Game/BattleGrounds/BattleGround.cs +++ b/Source/Game/BattleGrounds/BattleGround.cs @@ -148,7 +148,7 @@ namespace Game.BattleGrounds if (m_ValidStartPositionTimer >= BattlegroundConst.CheckPlayerPositionInverval) { m_ValidStartPositionTimer = 0; - + foreach (var guid in GetPlayers().Keys) { Player player = Global.ObjAccessor.FindPlayer(guid); @@ -177,7 +177,7 @@ namespace Game.BattleGrounds m_LastPlayerPositionBroadcast = 0; BattlegroundPlayerPositions playerPositions = new(); - for (var i =0; i < _playerPositions.Count; ++i) + for (var i = 0; i < _playerPositions.Count; ++i) { var playerPosition = _playerPositions[i]; // Update position data if we found player. @@ -477,7 +477,7 @@ namespace Game.BattleGrounds { return _battlegroundTemplate.MaxStartDistSq; } - + public void SendPacketToAll(ServerPacket packet) { foreach (var pair in m_Players) @@ -690,11 +690,11 @@ namespace Game.BattleGrounds stmt.AddValue(6, score.BonusHonor); stmt.AddValue(7, score.DamageDone); stmt.AddValue(8, score.HealingDone); - stmt.AddValue(9, score.GetAttr1()); - stmt.AddValue(10, score.GetAttr2()); - stmt.AddValue(11, score.GetAttr3()); - stmt.AddValue(12, score.GetAttr4()); - stmt.AddValue(13, score.GetAttr5()); + stmt.AddValue(9, score.GetAttr(1)); + stmt.AddValue(10, score.GetAttr(2)); + stmt.AddValue(11, score.GetAttr(3)); + stmt.AddValue(12, score.GetAttr(4)); + stmt.AddValue(13, score.GetAttr(5)); DB.Characters.Execute(stmt); } @@ -760,7 +760,7 @@ namespace Game.BattleGrounds { return _battlegroundTemplate.ScriptId; } - + public uint GetBonusHonorFromKill(uint kills) { //variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill) @@ -795,7 +795,7 @@ namespace Game.BattleGrounds Player player = Global.ObjAccessor.FindPlayer(guid); if (player != null) - { + { // should remove spirit of redemption if (player.HasAuraType(AuraType.SpiritOfRedemption)) player.RemoveAurasByType(AuraType.ModShapeshift); @@ -955,7 +955,10 @@ namespace Game.BattleGrounds m_Players[guid] = bp; if (!isInBattleground) + { UpdatePlayersCountByTeam(team, false); // +1 player + PlayerScores[player.GetGUID()] = new BattlegroundScore(player.GetGUID(), player.GetBGTeam(), _pvpStatIds); + } BattlegroundPlayerJoined playerJoined = new(); playerJoined.Guid = player.GetGUID(); @@ -1219,7 +1222,7 @@ namespace Game.BattleGrounds { return !IsArena(); } - + public bool HasFreeSlots() { return GetPlayersSize() < GetMaxPlayers(); @@ -1231,28 +1234,31 @@ namespace Game.BattleGrounds foreach (var score in PlayerScores) { - PVPMatchStatistics.PVPMatchPlayerStatistics playerData; - - score.Value.BuildPvPLogPlayerDataPacket(out playerData); - - Player player = Global.ObjAccessor.GetPlayer(GetBgMap(), playerData.PlayerGUID); + Player player = Global.ObjAccessor.GetPlayer(GetBgMap(), score.Key); if (player != null) { + score.Value.BuildPvPLogPlayerDataPacket(out PVPMatchStatistics.PVPMatchPlayerStatistics playerData); + playerData.IsInWorld = true; playerData.PrimaryTalentTree = (int)player.GetPrimarySpecialization(); playerData.Sex = (sbyte)player.GetGender(); playerData.PlayerRace = player.GetRace(); playerData.PlayerClass = (int)player.GetClass(); playerData.HonorLevel = (int)player.GetHonorLevel(); - } - pvpLogData.Statistics.Add(playerData); + pvpLogData.Statistics.Add(playerData); + } } pvpLogData.PlayerCount[(int)PvPTeamId.Horde] = (sbyte)GetPlayersCountByTeam(Team.Horde); pvpLogData.PlayerCount[(int)PvPTeamId.Alliance] = (sbyte)GetPlayersCountByTeam(Team.Alliance); } + public BattlegroundScore GetBattlegroundScore(Player player) + { + return PlayerScores.LookupByKey(player.GetGUID()); + } + public virtual bool UpdatePlayerScore(Player player, ScoreType type, uint value, bool doAddHonor = true) { var bgScore = PlayerScores.LookupByKey(player.GetGUID()); @@ -1267,6 +1273,13 @@ namespace Game.BattleGrounds return true; } + public void UpdatePvpStat(Player player, uint pvpStatId, uint value) + { + BattlegroundScore score = PlayerScores.LookupByKey(player.GetGUID()); + if (score != null) + score.UpdatePvpStat(pvpStatId, value); + } + public bool AddObject(int type, uint entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint respawnTime = 0, GameObjectState goState = GameObjectState.Ready) { Map map = FindBgMap(); @@ -1365,6 +1378,15 @@ namespace Game.BattleGrounds return (uint)_battlegroundTemplate.BattlemasterEntry.MapId[0]; } + public void SetBgMap(BattlegroundMap map) + { + m_Map = map; + if (map != null) + _pvpStatIds = Global.DB2Mgr.GetPVPStatIDsForMap(map.GetId()); + else + _pvpStatIds = null; + } + public void SpawnBGObject(int type, uint respawntime) { Map map = FindBgMap(); @@ -1548,7 +1570,7 @@ namespace Game.BattleGrounds { _playerPositions.RemoveAll(playerPosition => playerPosition.Guid == guid); } - + void EndNow() { RemoveFromBGFreeSlotQueue(); @@ -1630,7 +1652,7 @@ namespace Game.BattleGrounds return false; } - + void PlayerAddedToBGCheckIfBGIsRunning(Player player) { if (GetStatus() != BattlegroundStatus.WaitLeave) @@ -1800,7 +1822,7 @@ namespace Game.BattleGrounds { return m_Players.LookupByKey(playerGuid); } - + public virtual void StartingEventCloseDoors() { } public virtual void StartingEventOpenDoors() { } @@ -1825,6 +1847,7 @@ namespace Game.BattleGrounds public void SetRated(bool state) { m_IsRated = state; } public void SetArenaType(ArenaTypes type) { m_ArenaType = type; } public void SetWinner(PvPTeamId winnerTeamId) { _winnerTeamId = winnerTeamId; } + public List GetPvpStatIds() { return _pvpStatIds; } void ModifyStartDelayTime(int diff) { m_StartDelayTime -= diff; } void SetStartDelayTime(BattlegroundStartTimeIntervals Time) { m_StartDelayTime = (int)Time; } @@ -1852,7 +1875,6 @@ namespace Game.BattleGrounds uint GetPlayersSize() { return (uint)m_Players.Count; } uint GetPlayerScoresSize() { return (uint)PlayerScores.Count; } - public void SetBgMap(BattlegroundMap map) { m_Map = map; } BattlegroundMap FindBgMap() { return m_Map; } Group GetBgRaid(Team team) { return m_BgRaids[GetTeamIndexByTeamId(team)]; } @@ -1979,6 +2001,7 @@ namespace Game.BattleGrounds BattlegroundTemplate _battlegroundTemplate; PvpDifficultyRecord _pvpDifficultyEntry; + List _pvpStatIds = new(); List _playerPositions = new(); #endregion diff --git a/Source/Game/BattleGrounds/BattleGroundScore.cs b/Source/Game/BattleGrounds/BattleGroundScore.cs index 3b45572af..56482192c 100644 --- a/Source/Game/BattleGrounds/BattleGroundScore.cs +++ b/Source/Game/BattleGrounds/BattleGroundScore.cs @@ -4,15 +4,41 @@ using Framework.Constants; using Game.Entities; using Game.Networking.Packets; +using System.Collections.Generic; namespace Game.BattleGrounds { public class BattlegroundScore { - public BattlegroundScore(ObjectGuid playerGuid, Team team) + public ObjectGuid PlayerGuid; + public byte TeamId; // PvPTeamId + + // Default score, present in every type + public uint KillingBlows; + public uint Deaths; + public uint HonorableKills; + public uint BonusHonor; + public uint DamageDone; + public uint HealingDone; + + public uint PreMatchRating; + public uint PreMatchMMR; + public uint PostMatchRating; + public uint PostMatchMMR; + + public Dictionary PvpStats = new(); + + List _validPvpStatIds; + + public BattlegroundScore(ObjectGuid playerGuid, Team team, List pvpStatIds) { PlayerGuid = playerGuid; - TeamId = (int)(team == Team.Alliance ? PvPTeamId.Alliance : PvPTeamId.Horde); + TeamId = (byte)(team == Team.Alliance ? PvPTeamId.Alliance : PvPTeamId.Horde); + _validPvpStatIds = pvpStatIds; + + if (_validPvpStatIds != null) + foreach (uint pvpStatId in _validPvpStatIds) + PvpStats[pvpStatId] = 0; } public virtual void UpdateScore(ScoreType type, uint value) @@ -43,12 +69,34 @@ namespace Game.BattleGrounds } } + public void UpdatePvpStat(uint pvpStatID, uint value) + { + if (_validPvpStatIds == null) + return; + + if (!_validPvpStatIds.Contains(pvpStatID)) + { + Log.outWarn(LogFilter.Battleground, $"Tried updating PvpStat {pvpStatID} but this stat is not allowed on this map"); + return; + } + + PvpStats[pvpStatID] += value; + Player player = Global.ObjAccessor.FindConnectedPlayer(PlayerGuid); + if (player != null) + player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, pvpStatID); + } + + public uint GetAttr(byte index) + { + return PvpStats.LookupByKey(index); + } + public virtual void BuildPvPLogPlayerDataPacket(out PVPMatchStatistics.PVPMatchPlayerStatistics playerData) { playerData = new PVPMatchStatistics.PVPMatchPlayerStatistics(); playerData.PlayerGUID = PlayerGuid; playerData.Kills = KillingBlows; - playerData.Faction = (byte)TeamId; + playerData.Faction = TeamId; if (HonorableKills != 0 || Deaths != 0 || BonusHonor != 0) { PVPMatchStatistics.HonorData playerDataHonor = new(); @@ -60,23 +108,33 @@ namespace Game.BattleGrounds playerData.DamageDone = DamageDone; playerData.HealingDone = HealingDone; + + if (PreMatchRating != 0) + playerData.PreMatchRating = PreMatchRating; + + if (PostMatchRating != PreMatchRating) + playerData.RatingChange = (int)(PostMatchRating - PreMatchRating); + + if (PreMatchMMR != 0) + playerData.PreMatchMMR = PreMatchMMR; + + if (PostMatchMMR != PreMatchMMR) + playerData.MmrChange = (int)(PostMatchMMR - PreMatchMMR); + + foreach (var (pvpStatID, value) in PvpStats) + playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)pvpStatID, value)); } - public virtual uint GetAttr1() { return 0; } - public virtual uint GetAttr2() { return 0; } - public virtual uint GetAttr3() { return 0; } - public virtual uint GetAttr4() { return 0; } - public virtual uint GetAttr5() { return 0; } + public override string ToString() + { + return $"Damage done: {DamageDone}, Healing done: {HealingDone}, Killing blows: {KillingBlows}, PreMatchRating: {PreMatchRating}, PreMatchMMR: {PreMatchMMR}, PostMatchRating: {PostMatchRating}, PostMatchMMR: {PostMatchMMR}"; + } - public ObjectGuid PlayerGuid; - public int TeamId; - - // Default score, present in every type - public uint KillingBlows; - public uint Deaths; - public uint HonorableKills; - public uint BonusHonor; - public uint DamageDone; - public uint HealingDone; + public uint GetKillingBlows() { return KillingBlows; } + public uint GetDeaths() { return Deaths; } + public uint GetHonorableKills() { return HonorableKills; } + public uint GetBonusHonor() { return BonusHonor; } + public uint GetDamageDone() { return DamageDone; } + public uint GetHealingDone() { return HealingDone; } } } diff --git a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs index 4ee0760da..4440e2d06 100644 --- a/Source/Game/BattleGrounds/Zones/ArathiBasin.cs +++ b/Source/Game/BattleGrounds/Zones/ArathiBasin.cs @@ -208,18 +208,6 @@ namespace Game.BattleGrounds.Zones TriggerGameEvent(EventStartBattle); } - public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId) - { - bool isInBattleground = IsPlayerInBattleground(player.GetGUID()); - base.AddPlayer(player, queueId); - if (!isInBattleground) - PlayerScores[player.GetGUID()] = new BattlegroundABScore(player.GetGUID(), player.GetBGTeam()); - } - - public override void RemovePlayer(Player Player, ObjectGuid guid, Team team) - { - } - public override void HandleAreaTrigger(Player player, uint trigger, bool entered) { switch (trigger) @@ -412,7 +400,7 @@ namespace Game.BattleGrounds.Zones // If node is neutral, change to contested if (m_Nodes[node] == ABNodeStatus.Neutral) { - UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1); + UpdatePvpStat(source, (uint)ArathiBasinPvpStats.BasesAssaulted, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = (ABNodeStatus)(teamIndex + 1); // burn current neutral banner @@ -436,7 +424,7 @@ namespace Game.BattleGrounds.Zones // If last state is NOT occupied, change node to enemy-contested if (m_prevNodes[node] < ABNodeStatus.Occupied) { - UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1); + UpdatePvpStat(source, (uint)ArathiBasinPvpStats.BasesAssaulted, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = (ABNodeStatus.Contested + teamIndex); // burn current contested banner @@ -454,7 +442,7 @@ namespace Game.BattleGrounds.Zones // If contested, change back to occupied else { - UpdatePlayerScore(source, ScoreType.BasesDefended, 1); + UpdatePvpStat(source, (uint)ArathiBasinPvpStats.BasesDefended, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = (ABNodeStatus.Occupied + teamIndex); // burn current contested banner @@ -475,7 +463,7 @@ namespace Game.BattleGrounds.Zones // If node is occupied, change to enemy-contested else { - UpdatePlayerScore(source, ScoreType.BasesAssaulted, 1); + UpdatePvpStat(source, (uint)ArathiBasinPvpStats.BasesAssaulted, 1); m_prevNodes[node] = m_Nodes[node]; m_Nodes[node] = (ABNodeStatus.Contested + teamIndex); // burn current occupied banner @@ -657,25 +645,6 @@ namespace Game.BattleGrounds.Zones return Global.ObjectMgr.GetWorldSafeLoc(team == Team.Alliance ? ExploitTeleportLocationAlliance : ExploitTeleportLocationHorde); } - public override bool UpdatePlayerScore(Player player, ScoreType type, uint value, bool doAddHonor = true) - { - if (!base.UpdatePlayerScore(player, type, value, doAddHonor)) - return false; - - switch (type) - { - case ScoreType.BasesAssaulted: - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, (uint)ABObjectives.AssaultBase); - break; - case ScoreType.BasesDefended: - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, (uint)ABObjectives.DefendBase); - break; - default: - break; - } - return true; - } - /// /// Nodes info: /// 0: neutral @@ -768,45 +737,6 @@ namespace Game.BattleGrounds.Zones public static int[] NodeIcons = { 1842, 1846, 1845, 1844, 1843 }; } - class BattlegroundABScore : BattlegroundScore - { - public BattlegroundABScore(ObjectGuid playerGuid, Team team) : base(playerGuid, team) - { - BasesAssaulted = 0; - BasesDefended = 0; - } - - public override void UpdateScore(ScoreType type, uint value) - { - switch (type) - { - case ScoreType.BasesAssaulted: - BasesAssaulted += value; - break; - case ScoreType.BasesDefended: - BasesDefended += value; - break; - default: - base.UpdateScore(type, value); - break; - } - } - - public override void BuildPvPLogPlayerDataPacket(out PVPMatchStatistics.PVPMatchPlayerStatistics playerData) - { - base.BuildPvPLogPlayerDataPacket(out playerData); - - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)ABObjectives.AssaultBase, BasesAssaulted)); - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)ABObjectives.DefendBase, BasesDefended)); - } - - public override uint GetAttr1() { return BasesAssaulted; } - public override uint GetAttr2() { return BasesDefended; } - - uint BasesAssaulted; - uint BasesDefended; - } - struct BannerTimer { public uint timer; @@ -1003,5 +933,11 @@ namespace Game.BattleGrounds.Zones AssaultBase = 122, DefendBase = 123 } + + enum ArathiBasinPvpStats + { + BasesAssaulted = 926, + BasesDefended = 927, + } #endregion } diff --git a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs index e3d513111..1c79d9237 100644 --- a/Source/Game/BattleGrounds/Zones/EyeofStorm.cs +++ b/Source/Game/BattleGrounds/Zones/EyeofStorm.cs @@ -195,16 +195,6 @@ namespace Game.BattleGrounds.Zones.EyeofStorm } } - public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId) - { - bool isInBattleground = IsPlayerInBattleground(player.GetGUID()); - base.AddPlayer(player, queueId); - if (!isInBattleground) - PlayerScores[player.GetGUID()] = new BgEyeOfStormScore(player.GetGUID(), player.GetBGTeam()); - - m_PlayersNearPoint[Points.PointsMax].Add(player.GetGUID()); - } - public override void RemovePlayer(Player player, ObjectGuid guid, Team team) { // sometimes flag aura not removed :( @@ -655,23 +645,7 @@ namespace Game.BattleGrounds.Zones.EyeofStorm UpdateWorldState(WorldStateIds.NetherstormFlagStateHorde, (int)FlagState.OnBase); UpdateWorldState(WorldStateIds.NetherstormFlagStateAlliance, (int)FlagState.OnBase); - UpdatePlayerScore(player, ScoreType.FlagCaptures, 1); - } - - public override bool UpdatePlayerScore(Player player, ScoreType type, uint value, bool doAddHonor = true) - { - if (!base.UpdatePlayerScore(player, type, value, doAddHonor)) - return false; - - switch (type) - { - case ScoreType.FlagCaptures: - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, Misc.ObjectiveCaptureFlag); - break; - default: - break; - } - return true; + UpdatePvpStat(player, (uint)EyeOfTheStormPvpStats.FlagCaptures, 1); } public override WorldSafeLocsEntry GetClosestGraveyard(Player player) @@ -809,35 +783,6 @@ namespace Game.BattleGrounds.Zones.EyeofStorm Dictionary ControlZoneHandlers = new(); } - class BgEyeOfStormScore : BattlegroundScore - { - public BgEyeOfStormScore(ObjectGuid playerGuid, Team team) : base(playerGuid, team) { } - - public override void UpdateScore(ScoreType type, uint value) - { - switch (type) - { - case ScoreType.FlagCaptures: // Flags captured - FlagCaptures += value; - break; - default: - base.UpdateScore(type, value); - break; - } - } - - public override void BuildPvPLogPlayerDataPacket(out PVPMatchStatistics.PVPMatchPlayerStatistics playerData) - { - base.BuildPvPLogPlayerDataPacket(out playerData); - - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)Misc.ObjectiveCaptureFlag, FlagCaptures)); - } - - public override uint GetAttr1() { return FlagCaptures; } - - uint FlagCaptures; - } - struct BgEyeOfStormPointIconsStruct { public BgEyeOfStormPointIconsStruct(uint worldStateControlIndex, uint worldStateAllianceControlledIndex, uint worldStateHordeControlledIndex, uint worldStateAllianceStatusBarIcon, uint worldStateHordeStatusBarIcon) @@ -935,8 +880,6 @@ namespace Game.BattleGrounds.Zones.EyeofStorm public const uint NotEYWeekendHonorTicks = 260; public const uint EYWeekendHonorTicks = 160; - public const uint ObjectiveCaptureFlag = 183; - public const uint SpellNetherstormFlag = 34976; public const uint SpellPlayerDroppedFlag = 34991; @@ -1229,4 +1172,9 @@ namespace Game.BattleGrounds.Zones.EyeofStorm Uncontrolled = 0, UnderControl = 3 } + + enum EyeOfTheStormPvpStats + { + FlagCaptures = 183 + } } diff --git a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs index e57b8f986..c1da72156 100644 --- a/Source/Game/BattleGrounds/Zones/StrandofAncients.cs +++ b/Source/Game/BattleGrounds/Zones/StrandofAncients.cs @@ -420,8 +420,6 @@ namespace Game.BattleGrounds.Zones { bool isInBattleground = IsPlayerInBattleground(player.GetGUID()); base.AddPlayer(player, queueId); - if (!isInBattleground) - PlayerScores[player.GetGUID()] = new BattlegroundSAScore(player.GetGUID(), player.GetBGTeam()); SendTransportInit(player); @@ -560,7 +558,7 @@ namespace Game.BattleGrounds.Zones Player player = unit.GetCharmerOrOwnerPlayerOrPlayerItself(); if (player != null) { - UpdatePlayerScore(player, ScoreType.DestroyedWall, 1); + UpdatePvpStat(player, (uint)StrandOfTheAncientsPvpStats.GatesDestroyed, 1); if (rewardHonor) UpdatePlayerScore(player, ScoreType.BonusHonor, GetBonusHonorFromKill(1)); } @@ -586,7 +584,7 @@ namespace Game.BattleGrounds.Zones { if (creature.GetEntry() == SACreatureIds.Demolisher) { - UpdatePlayerScore(killer, ScoreType.DestroyedDemolisher, 1); + UpdatePvpStat(killer, (uint)StrandOfTheAncientsPvpStats.DemolishersDestroyed, 1); uint worldStateId = Attackers == TeamId.Horde ? SAWorldStateIds.DestroyedHordeVehicles : SAWorldStateIds.DestroyedAllianceVehicles; int currentDestroyedVehicles = Global.WorldStateMgr.GetValue((int)worldStateId, GetBgMap()); UpdateWorldState(worldStateId, currentDestroyedVehicles + 1); @@ -1022,25 +1020,6 @@ namespace Game.BattleGrounds.Zones return true; } - public override bool UpdatePlayerScore(Player player, ScoreType type, uint value, bool doAddHonor = true) - { - if (!base.UpdatePlayerScore(player, type, value, doAddHonor)) - return false; - - switch (type) - { - case ScoreType.DestroyedDemolisher: - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, (uint)SAObjectives.DemolishersDestroyed); - break; - case ScoreType.DestroyedWall: - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, (uint)SAObjectives.GatesDestroyed); - break; - default: - break; - } - return true; - } - SAGateInfo GetGate(uint entry) { foreach (var gate in SAMiscConst.Gates) @@ -1080,41 +1059,6 @@ namespace Game.BattleGrounds.Zones Dictionary DemoliserRespawnList = new(); } - class BattlegroundSAScore : BattlegroundScore - { - public BattlegroundSAScore(ObjectGuid playerGuid, Team team) : base(playerGuid, team) { } - - public override void UpdateScore(ScoreType type, uint value) - { - switch (type) - { - case ScoreType.DestroyedDemolisher: - DemolishersDestroyed += value; - break; - case ScoreType.DestroyedWall: - GatesDestroyed += value; - break; - default: - base.UpdateScore(type, value); - break; - } - } - - public override void BuildPvPLogPlayerDataPacket(out PVPMatchStatistics.PVPMatchPlayerStatistics playerData) - { - base.BuildPvPLogPlayerDataPacket(out playerData); - - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)SAObjectives.DemolishersDestroyed, DemolishersDestroyed)); - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat((int)SAObjectives.GatesDestroyed, GatesDestroyed)); - } - - public override uint GetAttr1() { return DemolishersDestroyed; } - public override uint GetAttr2() { return GatesDestroyed; } - - uint DemolishersDestroyed; - uint GatesDestroyed; - } - struct SARoundScore { public uint winner; @@ -1597,7 +1541,7 @@ namespace Game.BattleGrounds.Zones public const int Max = 5; } - enum SAObjectives + enum StrandOfTheAncientsPvpStats { GatesDestroyed = 231, DemolishersDestroyed = 232 diff --git a/Source/Game/BattleGrounds/Zones/WarsongGluch.cs b/Source/Game/BattleGrounds/Zones/WarsongGluch.cs index c39da30dd..842464584 100644 --- a/Source/Game/BattleGrounds/Zones/WarsongGluch.cs +++ b/Source/Game/BattleGrounds/Zones/WarsongGluch.cs @@ -184,14 +184,6 @@ namespace Game.BattleGrounds.Zones TriggerGameEvent(8563); } - public override void AddPlayer(Player player, BattlegroundQueueTypeId queueId) - { - bool isInBattleground = IsPlayerInBattleground(player.GetGUID()); - base.AddPlayer(player, queueId); - if (!isInBattleground) - PlayerScores[player.GetGUID()] = new BattlegroundWGScore(player.GetGUID(), player.GetBGTeam()); - } - void RespawnFlag(Team Team, bool captured) { if (Team == Team.Alliance) @@ -303,7 +295,7 @@ namespace Game.BattleGrounds.Zones UpdateFlagState(team, WSGFlagState.WaitRespawn); // flag state none UpdateTeamScore(GetTeamIndexByTeamId(team)); // only flag capture should be updated - UpdatePlayerScore(player, ScoreType.FlagCaptures, 1); // +1 flag captures + UpdatePvpStat(player, (uint)WarsongGulchPvpStats.FlagCaptures, 1); // +1 flag captures // update last flag capture to be used if teamscore is equal SetLastFlagCapture(team); @@ -482,7 +474,7 @@ namespace Game.BattleGrounds.Zones RespawnFlag(Team.Alliance, false); SpawnBGObject(WSGObjectTypes.AFlag, BattlegroundConst.RespawnImmediately); PlaySoundToAll(WSGSound.FlagReturned); - UpdatePlayerScore(player, ScoreType.FlagReturns, 1); + UpdatePvpStat(player, (uint)WarsongGulchPvpStats.FlagReturns, 1); _bothFlagsKept = false; HandleFlagRoomCapturePoint(TeamId.Horde); // Check Horde flag if it is in capture zone; if so, capture it @@ -516,7 +508,7 @@ namespace Game.BattleGrounds.Zones RespawnFlag(Team.Horde, false); SpawnBGObject(WSGObjectTypes.HFlag, BattlegroundConst.RespawnImmediately); PlaySoundToAll(WSGSound.FlagReturned); - UpdatePlayerScore(player, ScoreType.FlagReturns, 1); + UpdatePvpStat(player, (uint)WarsongGulchPvpStats.FlagReturns, 1); _bothFlagsKept = false; HandleFlagRoomCapturePoint(TeamId.Alliance); // Check Alliance flag if it is in capture zone; if so, capture it @@ -778,25 +770,6 @@ namespace Game.BattleGrounds.Zones base.HandleKillPlayer(victim, killer); } - public override bool UpdatePlayerScore(Player player, ScoreType type, uint value, bool doAddHonor = true) - { - if (!base.UpdatePlayerScore(player, type, value, doAddHonor)) - return false; - - switch (type) - { - case ScoreType.FlagCaptures: // flags captured - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, WSObjectives.CaptureFlag); - break; - case ScoreType.FlagReturns: // flags returned - player.UpdateCriteria(CriteriaType.TrackedWorldStateUIModified, WSObjectives.ReturnFlag); - break; - default: - break; - } - return true; - } - public override WorldSafeLocsEntry GetClosestGraveyard(Player player) { //if status in progress, it returns main graveyards with spiritguides @@ -883,41 +856,6 @@ namespace Game.BattleGrounds.Zones const uint ExploitTeleportLocationHorde = 3785; } - class BattlegroundWGScore : BattlegroundScore - { - public BattlegroundWGScore(ObjectGuid playerGuid, Team team) : base(playerGuid, team) { } - - public override void UpdateScore(ScoreType type, uint value) - { - switch (type) - { - case ScoreType.FlagCaptures: // Flags captured - FlagCaptures += value; - break; - case ScoreType.FlagReturns: // Flags returned - FlagReturns += value; - break; - default: - base.UpdateScore(type, value); - break; - } - } - - public override void BuildPvPLogPlayerDataPacket(out PVPMatchStatistics.PVPMatchPlayerStatistics playerData) - { - base.BuildPvPLogPlayerDataPacket(out playerData); - - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat(WSObjectives.CaptureFlag, FlagCaptures)); - playerData.Stats.Add(new PVPMatchStatistics.PVPMatchPlayerPVPStat(WSObjectives.ReturnFlag, FlagReturns)); - } - - public override uint GetAttr1() { return FlagCaptures; } - public override uint GetAttr2() { return FlagReturns; } - - uint FlagCaptures; - uint FlagReturns; - } - #region Constants enum WSGRewards { @@ -1057,10 +995,17 @@ namespace Game.BattleGrounds.Zones public const uint AllianceFlagReturned = 9808; public const uint HordeFlagReturned = 9809; } + struct WSObjectives { public const int CaptureFlag = 42; public const int ReturnFlag = 44; } + + enum WarsongGulchPvpStats + { + FlagCaptures = 928, + FlagReturns = 929 + } #endregion } diff --git a/Source/Game/DataStorage/CliDB.cs b/Source/Game/DataStorage/CliDB.cs index 03f15688b..e32505a31 100644 --- a/Source/Game/DataStorage/CliDB.cs +++ b/Source/Game/DataStorage/CliDB.cs @@ -258,6 +258,7 @@ namespace Game.DataStorage PrestigeLevelInfoStorage = ReadDB2("PrestigeLevelInfo.db2", HotfixStatements.SEL_PRESTIGE_LEVEL_INFO, HotfixStatements.SEL_PRESTIGE_LEVEL_INFO_LOCALE); PvpDifficultyStorage = ReadDB2("PVPDifficulty.db2", HotfixStatements.SEL_PVP_DIFFICULTY); PvpItemStorage = ReadDB2("PVPItem.db2", HotfixStatements.SEL_PVP_ITEM); + PvpStatStorage = ReadDB2("PVPStat.db2", HotfixStatements.SEL_PVP_STAT, HotfixStatements.SEL_PVP_STAT_LOCALE); PvpSeasonStorage = ReadDB2("PvpSeason.db2", HotfixStatements.SEL_PVP_SEASON); PvpTalentStorage = ReadDB2("PvpTalent.db2", HotfixStatements.SEL_PVP_TALENT, HotfixStatements.SEL_PVP_TALENT_LOCALE); PvpTalentCategoryStorage = ReadDB2("PvpTalentCategory.db2", HotfixStatements.SEL_PVP_TALENT_CATEGORY); @@ -693,6 +694,7 @@ namespace Game.DataStorage public static DB6Storage PrestigeLevelInfoStorage; public static DB6Storage PvpDifficultyStorage; public static DB6Storage PvpItemStorage; + public static DB6Storage PvpStatStorage; public static DB6Storage PvpSeasonStorage; public static DB6Storage PvpTalentStorage; public static DB6Storage PvpTalentCategoryStorage; diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index e2563e924..2c9b9efb0 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -630,6 +630,9 @@ namespace Game.DataStorage foreach (WMOAreaTableRecord entry in WMOAreaTableStorage.Values) _wmoAreaTableLookup[Tuple.Create((short)entry.WmoID, (sbyte)entry.NameSetID, entry.WmoGroupID)] = entry; + + foreach (PvpStatRecord pvpStat in PvpStatStorage.Values) + _pvpStatIdsByMap.Add(pvpStat.MapID, pvpStat.Id); } public IDB2Storage GetStorage(uint type) @@ -1051,7 +1054,7 @@ namespace Game.DataStorage return contentTuningId; } - + public ContentTuningLevels? GetContentTuningData(uint contentTuningId, uint redirectFlag, bool forItem = false) { ContentTuningRecord contentTuning = ContentTuningStorage.LookupByKey(GetRedirectedContentTuningId(contentTuningId, redirectFlag)); @@ -1095,7 +1098,7 @@ namespace Game.DataStorage { return _contentTuningLabels.Contains((contentTuningId, label)); } - + public string GetCreatureFamilyPetName(CreatureFamily petfamily, Locale locale) { if (petfamily == CreatureFamily.None) @@ -1294,16 +1297,16 @@ namespace Game.DataStorage { var mythicPlusSeason = MythicPlusSeasonStorage.LookupByKey(contentTuningXExpected.MinMythicPlusSeasonID); if (mythicPlusSeason != null) - if (ActiveMilestoneSeason < mythicPlusSeason.MilestoneSeason) - return mod; + if (ActiveMilestoneSeason < mythicPlusSeason.MilestoneSeason) + return mod; } if (contentTuningXExpected.MaxMythicPlusSeasonID != 0) { var mythicPlusSeason = MythicPlusSeasonStorage.LookupByKey(contentTuningXExpected.MaxMythicPlusSeasonID); if (mythicPlusSeason != null) - if (ActiveMilestoneSeason >= mythicPlusSeason.MilestoneSeason) - return mod; + if (ActiveMilestoneSeason >= mythicPlusSeason.MilestoneSeason) + return mod; } var expectedStatMod = ExpectedStatModStorage.LookupByKey(contentTuningXExpected.ExpectedStatModID); @@ -1872,7 +1875,7 @@ namespace Game.DataStorage { return _skillRaceClassInfoBySkill.LookupByKey(skill); } - + public SoulbindConduitRankRecord GetSoulbindConduitRank(int soulbindConduitId, int rank) { return _soulbindConduitRanks.LookupByKey(Tuple.Create(soulbindConduitId, rank)); @@ -1902,7 +1905,7 @@ namespace Game.DataStorage { return _spellVisualMissilesBySet.LookupByKey(spellVisualMissileSetId); } - + public List GetTalentsByPosition(Class class_, uint tier, uint column) { return _talentsByPosition[(int)class_][tier][column]; @@ -2223,6 +2226,11 @@ namespace Game.DataStorage return null; } + public List GetPVPStatIDsForMap(uint mapId) + { + return _pvpStatIdsByMap.LookupByKey(mapId); + } + public bool HasItemCurrencyCost(uint itemId) { return _itemsWithCurrencyCost.Contains(itemId); } public Dictionary> GetMapDifficulties() { return _mapDifficulties; } @@ -2316,6 +2324,7 @@ namespace Game.DataStorage MultiMap[] _uiMapAssignmentByWmoGroup = new MultiMap[(int)UiMapSystem.Max]; List _uiMapPhases = new(); Dictionary, WMOAreaTableRecord> _wmoAreaTableLookup = new(); + MultiMap _pvpStatIdsByMap = new(); } class UiMapBounds @@ -2526,7 +2535,7 @@ namespace Game.DataStorage UniqueID = data.ReadUInt32(); } } - + public class HotfixOptionalData { public uint Key; diff --git a/Source/Game/DataStorage/Structs/P_Records.cs b/Source/Game/DataStorage/Structs/P_Records.cs index 3b47497ba..301a9ea0c 100644 --- a/Source/Game/DataStorage/Structs/P_Records.cs +++ b/Source/Game/DataStorage/Structs/P_Records.cs @@ -178,6 +178,13 @@ namespace Game.DataStorage public byte ItemLevelDelta; } + public sealed class PvpStatRecord + { + public LocalizedString Description; + public uint Id; + public uint MapID; + } + public sealed class PvpSeasonRecord { public uint Id;