Core/Battleground: Rework BattlegroundScore

Port From (https://github.com/TrinityCore/TrinityCore/commit/da0ec4f830c4428a17fd4e52124dca6c63e25961)
This commit is contained in:
hondacrx
2024-02-04 00:27:52 -05:00
parent 3c2bb6829c
commit 90ad7ed6ea
13 changed files with 184 additions and 369 deletions
@@ -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
@@ -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,
-3
View File
@@ -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
{
-42
View File
@@ -1,50 +1,8 @@
// Copyright (c) CypherCore <http://github.com/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)
+35 -12
View File
@@ -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);
}
@@ -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();
@@ -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.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();
@@ -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<uint> 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<uint> _pvpStatIds = new();
List<BattlegroundPlayerPosition> _playerPositions = new();
#endregion
+76 -18
View File
@@ -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<uint /*pvpStatID*/, uint /*value*/> PvpStats = new();
List<uint> _validPvpStatIds;
public BattlegroundScore(ObjectGuid playerGuid, Team team, List<uint> 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; }
}
}
+10 -74
View File
@@ -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;
}
/// <summary>
/// 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
}
+6 -58
View File
@@ -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<uint, BgEyeOfStormControlZoneHandler> 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
}
}
@@ -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<uint/*id*/, uint/*timer*/> 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
+10 -65
View File
@@ -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
}
+2
View File
@@ -258,6 +258,7 @@ namespace Game.DataStorage
PrestigeLevelInfoStorage = ReadDB2<PrestigeLevelInfoRecord>("PrestigeLevelInfo.db2", HotfixStatements.SEL_PRESTIGE_LEVEL_INFO, HotfixStatements.SEL_PRESTIGE_LEVEL_INFO_LOCALE);
PvpDifficultyStorage = ReadDB2<PvpDifficultyRecord>("PVPDifficulty.db2", HotfixStatements.SEL_PVP_DIFFICULTY);
PvpItemStorage = ReadDB2<PvpItemRecord>("PVPItem.db2", HotfixStatements.SEL_PVP_ITEM);
PvpStatStorage = ReadDB2<PvpStatRecord>("PVPStat.db2", HotfixStatements.SEL_PVP_STAT, HotfixStatements.SEL_PVP_STAT_LOCALE);
PvpSeasonStorage = ReadDB2<PvpSeasonRecord>("PvpSeason.db2", HotfixStatements.SEL_PVP_SEASON);
PvpTalentStorage = ReadDB2<PvpTalentRecord>("PvpTalent.db2", HotfixStatements.SEL_PVP_TALENT, HotfixStatements.SEL_PVP_TALENT_LOCALE);
PvpTalentCategoryStorage = ReadDB2<PvpTalentCategoryRecord>("PvpTalentCategory.db2", HotfixStatements.SEL_PVP_TALENT_CATEGORY);
@@ -693,6 +694,7 @@ namespace Game.DataStorage
public static DB6Storage<PrestigeLevelInfoRecord> PrestigeLevelInfoStorage;
public static DB6Storage<PvpDifficultyRecord> PvpDifficultyStorage;
public static DB6Storage<PvpItemRecord> PvpItemStorage;
public static DB6Storage<PvpStatRecord> PvpStatStorage;
public static DB6Storage<PvpSeasonRecord> PvpSeasonStorage;
public static DB6Storage<PvpTalentRecord> PvpTalentStorage;
public static DB6Storage<PvpTalentCategoryRecord> PvpTalentCategoryStorage;
+9
View File
@@ -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)
@@ -2223,6 +2226,11 @@ namespace Game.DataStorage
return null;
}
public List<uint> GetPVPStatIDsForMap(uint mapId)
{
return _pvpStatIdsByMap.LookupByKey(mapId);
}
public bool HasItemCurrencyCost(uint itemId) { return _itemsWithCurrencyCost.Contains(itemId); }
public Dictionary<uint, Dictionary<uint, MapDifficultyRecord>> GetMapDifficulties() { return _mapDifficulties; }
@@ -2316,6 +2324,7 @@ namespace Game.DataStorage
MultiMap<int, UiMapAssignmentRecord>[] _uiMapAssignmentByWmoGroup = new MultiMap<int, UiMapAssignmentRecord>[(int)UiMapSystem.Max];
List<int> _uiMapPhases = new();
Dictionary<Tuple<short, sbyte, int>, WMOAreaTableRecord> _wmoAreaTableLookup = new();
MultiMap<uint, uint> _pvpStatIdsByMap = new();
}
class UiMapBounds
@@ -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;