Core/Battleground: Rework BattlegroundScore
Port From (https://github.com/TrinityCore/TrinityCore/commit/da0ec4f830c4428a17fd4e52124dca6c63e25961)
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user