AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Arena Class Reference

#include "Arena.h"

Inheritance diagram for Arena:
Battleground BattlegroundBE BattlegroundDS BattlegroundNA BattlegroundRL BattlegroundRV

Protected Member Functions

 Arena ()
 
void AddPlayer (Player *player) override
 
void RemovePlayer (Player *) override
 
void FillInitialWorldStates (WorldPacket &data) override
 
void UpdateArenaWorldState ()
 
void HandleKillPlayer (Player *player, Player *killer) override
 
- Protected Member Functions inherited from Battleground
void EndNow ()
 
void PlayerAddedToBGCheckIfBGIsRunning (Player *player)
 
void _ProcessResurrect (uint32 diff)
 
void _ProcessProgress (uint32 diff)
 
void _ProcessLeave (uint32 diff)
 
void _ProcessJoin (uint32 diff)
 
void _CheckSafePositions (uint32 diff)
 
virtual void RemovePlayer (Player *)
 

Private Member Functions

void RemovePlayerAtLeave (Player *player) override
 
void CheckWinConditions () override
 
void EndBattleground (TeamId winnerTeamId) override
 

Additional Inherited Members

- Public Types inherited from Battleground
typedef std::set< Player * > SpectatorList
 
typedef std::map< ObjectGuid, ObjectGuidToBeTeleportedMap
 
typedef std::map< ObjectGuid, Player * > BattlegroundPlayerMap
 
typedef std::unordered_map< ObjectGuid::LowType, BattlegroundScore * > BattlegroundScoreMap
 
typedef std::unordered_map< ObjectGuid, ArenaLogEntryDataArenaLogEntryDataMap
 
typedef GuidVector BGObjects
 
typedef GuidVector BGCreatures
 
- Public Member Functions inherited from Battleground
 Battleground ()
 
virtual ~Battleground ()
 
void Update (uint32 diff)
 
virtual bool SetupBattleground ()
 
virtual void Init ()
 
virtual void StartingEventCloseDoors ()
 
virtual void StartingEventOpenDoors ()
 
virtual void ResetBGSubclass ()
 
virtual void DestroyGate (Player *, GameObject *)
 
virtual bool AllNodesConrolledByTeam (TeamId) const
 
void StartTimedAchievement (AchievementCriteriaTimedTypes type, uint32 entry)
 
std::string GetName () const
 
BattlegroundTypeId GetBgTypeID (bool GetRandom=false) const
 
BattlegroundBracketId GetBracketId () const
 
uint32 GetInstanceID () const
 
BattlegroundStatus GetStatus () const
 
uint32 GetClientInstanceID () const
 
uint32 GetStartTime () const
 
uint32 GetEndTime () const
 
uint32 GetLastResurrectTime () const
 
uint32 GetMinLevel () const
 
uint32 GetMaxLevel () const
 
uint32 GetMaxPlayersPerTeam () const
 
uint32 GetMinPlayersPerTeam () const
 
int32 GetStartDelayTime () const
 
uint8 GetArenaType () const
 
PvPTeamId GetWinner () const
 
uint32 GetScriptId () const
 
uint32 GetBonusHonorFromKill (uint32 kills) const
 
bool IsRandom ()
 
void SetName (std::string_view name)
 
void SetBgTypeID (BattlegroundTypeId TypeID)
 
void SetRandomTypeID (BattlegroundTypeId TypeID)
 
void SetBracket (PvPDifficultyEntry const *bracketEntry)
 
void SetInstanceID (uint32 InstanceID)
 
void SetStatus (BattlegroundStatus Status)
 
void SetClientInstanceID (uint32 InstanceID)
 
void SetStartTime (uint32 Time)
 
void SetEndTime (uint32 Time)
 
void SetLastResurrectTime (uint32 Time)
 
void SetLevelRange (uint32 min, uint32 max)
 
void SetRated (bool state)
 
void SetArenaType (uint8 type)
 
void SetArenaorBGType (bool _isArena)
 
void SetWinner (PvPTeamId winner)
 
void SetScriptId (uint32 scriptId)
 
void SetRandom (bool isRandom)
 
void ModifyStartDelayTime (int32 diff)
 
void SetStartDelayTime (int32 Time)
 
void SetMaxPlayersPerTeam (uint32 MaxPlayers)
 
void SetMinPlayersPerTeam (uint32 MinPlayers)
 
void AddToBGFreeSlotQueue ()
 
void RemoveFromBGFreeSlotQueue ()
 
void DecreaseInvitedCount (TeamId teamId)
 
void IncreaseInvitedCount (TeamId teamId)
 
uint32 GetInvitedCount (TeamId teamId) const
 
bool HasFreeSlots () const
 
uint32 GetFreeSlotsForTeam (TeamId teamId) const
 
uint32 GetMaxFreeSlots () const
 
void AddSpectator (Player *p)
 
void RemoveSpectator (Player *p)
 
bool HaveSpectators ()
 
const SpectatorListGetSpectators () const
 
void AddToBeTeleported (ObjectGuid spectator, ObjectGuid participant)
 
void RemoveToBeTeleported (ObjectGuid spectator)
 
void SpectatorsSendPacket (WorldPacket &data)
 
bool isArena () const
 
bool isBattleground () const
 
bool isRated () const
 
BattlegroundPlayerMap const & GetPlayers () const
 
uint32 GetPlayersSize () const
 
void ReadyMarkerClicked (Player *p)
 
BattlegroundScoreMap const * GetPlayerScores () const
 
std::size_t GetPlayerScoresSize () const
 
uint32 GetReviveQueueSize () const
 
void AddPlayerToResurrectQueue (ObjectGuid npc_guid, ObjectGuid player_guid)
 
void RemovePlayerFromResurrectQueue (Player *player)
 
void RelocateDeadPlayers (ObjectGuid queueIndex)
 Relocate all players in ReviveQueue to the closest graveyard.
 
void StartBattleground ()
 
GameObjectGetBGObject (uint32 type)
 
CreatureGetBGCreature (uint32 type)
 
void SetMapId (uint32 MapID)
 
uint32 GetMapId () const
 
void SetBgMap (BattlegroundMap *map)
 
BattlegroundMapGetBgMap () const
 
BattlegroundMapFindBgMap () const
 
void SetTeamStartPosition (TeamId teamId, Position const &pos)
 
Position const * GetTeamStartPosition (TeamId teamId) const
 
void SetStartMaxDist (float startMaxDist)
 
float GetStartMaxDist () const
 
virtual void FillInitialWorldStates (WorldPacket &)
 
void SendPacketToTeam (TeamId teamId, WorldPacket const *packet, Player *sender=nullptr, bool self=true)
 
void SendPacketToAll (WorldPacket const *packet)
 
void YellToAll (Creature *creature, const char *text, uint32 language)
 
void SendChatMessage (Creature *source, uint8 textId, WorldObject *target=nullptr)
 
void SendBroadcastText (uint32 id, ChatMsg msgType, WorldObject const *target=nullptr)
 
template<class Do >
void BroadcastWorker (Do &_do)
 
void PlaySoundToAll (uint32 soundId)
 
void CastSpellOnTeam (uint32 spellId, TeamId teamId)
 
void RemoveAuraOnTeam (uint32 spellId, TeamId teamId)
 
void RewardHonorToTeam (uint32 honor, TeamId teamId)
 
void RewardReputationToTeam (uint32 factionId, uint32 reputation, TeamId teamId)
 
uint32 GetRealRepFactionForPlayer (uint32 factionId, Player *player)
 
void UpdateWorldState (uint32 variable, uint32 value)
 
void EndBattleground (PvPTeamId winnerTeamId)
 
virtual void EndBattleground (TeamId winnerTeamId)
 
void BlockMovement (Player *player)
 
void SendWarningToAll (uint32 entry,...)
 
void SendMessageToAll (uint32 entry, ChatMsg type, Player const *source=nullptr)
 
void PSendMessageToAll (uint32 entry, ChatMsg type, Player const *source,...)
 
void SendMessage2ToAll (uint32 entry, ChatMsg type, Player const *source, uint32 strId1=0, uint32 strId2=0)
 
GroupGetBgRaid (TeamId teamId) const
 
void SetBgRaid (TeamId teamId, Group *bg_raid)
 
void BuildPvPLogDataPacket (WorldPacket &data)
 
virtual bool UpdatePlayerScore (Player *player, uint32 type, uint32 value, bool doAddHonor=true)
 
uint32 GetPlayersCountByTeam (TeamId teamId) const
 
uint32 GetAlivePlayersCountByTeam (TeamId teamId) const
 
void UpdatePlayersCountByTeam (TeamId teamId, bool remove)
 
virtual void CheckWinConditions ()
 
void SetArenaTeamIdForTeam (TeamId teamId, uint32 ArenaTeamId)
 
uint32 GetArenaTeamIdForTeam (TeamId teamId) const
 
void SetArenaMatchmakerRating (TeamId teamId, uint32 MMR)
 
uint32 GetArenaMatchmakerRating (TeamId teamId) const
 
virtual void HandleAreaTrigger (Player *, uint32)
 
virtual void HandleKillPlayer (Player *player, Player *killer)
 
virtual void HandleKillUnit (Creature *, Player *)
 
virtual void EventPlayerDroppedFlag (Player *)
 
virtual void EventPlayerClickedOnFlag (Player *, GameObject *)
 
virtual void EventPlayerDamagedGO (Player *, GameObject *, uint32)
 
virtual void EventPlayerUsedGO (Player *, GameObject *)
 
virtual void DoAction (uint32, ObjectGuid)
 
virtual void HandlePlayerResurrect (Player *)
 
virtual GraveyardStruct const * GetClosestGraveyard (Player *player)
 
virtual void AddPlayer (Player *player)
 
void AddOrSetPlayerToCorrectBgGroup (Player *player, TeamId teamId)
 
virtual void RemovePlayerAtLeave (Player *player)
 
void HandleTriggerBuff (GameObject *gameObject)
 
void SetHoliday (bool is_holiday)
 
void SpawnBGObject (uint32 type, uint32 respawntime, uint32 forceRespawnDelay=0)
 
bool AddObject (uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime=0, GOState goState=GO_STATE_READY)
 
CreatureAddCreature (uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime=0, MotionTransport *transport=nullptr)
 
bool DelCreature (uint32 type)
 
bool DelObject (uint32 type)
 
bool AddSpiritGuide (uint32 type, float x, float y, float z, float o, TeamId teamId)
 
int32 GetObjectType (ObjectGuid guid)
 
void DoorOpen (uint32 type)
 
void DoorClose (uint32 type)
 
const char * GetAcoreString (int32 entry)
 
virtual bool HandlePlayerUnderMap (Player *)
 
bool IsPlayerInBattleground (ObjectGuid guid) const
 
bool ToBeDeleted () const
 
void RewardXPAtKill (Player *killer, Player *victim)
 
virtual ObjectGuid GetFlagPickerGUID (TeamId=TEAM_NEUTRAL) const
 
virtual void SetDroppedFlagGUID (ObjectGuid, TeamId=TEAM_NEUTRAL)
 
uint32 GetTeamScore (TeamId teamId) const
 
virtual TeamId GetPrematureWinner ()
 
uint8 GetUniqueBracketId () const
 
BattlegroundAVToBattlegroundAV ()
 
BattlegroundAV const * ToBattlegroundAV () const
 
BattlegroundWSToBattlegroundWS ()
 
BattlegroundWS const * ToBattlegroundWS () const
 
BattlegroundABToBattlegroundAB ()
 
BattlegroundAB const * ToBattlegroundAB () const
 
BattlegroundNAToBattlegroundNA ()
 
BattlegroundNA const * ToBattlegroundNA () const
 
BattlegroundBEToBattlegroundBE ()
 
BattlegroundBE const * ToBattlegroundBE () const
 
BattlegroundEYToBattlegroundEY ()
 
BattlegroundEY const * ToBattlegroundEY () const
 
BattlegroundRLToBattlegroundRL ()
 
BattlegroundRL const * ToBattlegroundRL () const
 
BattlegroundSAToBattlegroundSA ()
 
BattlegroundSA const * ToBattlegroundSA () const
 
BattlegroundDSToBattlegroundDS ()
 
BattlegroundDS const * ToBattlegroundDS () const
 
BattlegroundRVToBattlegroundRV ()
 
BattlegroundRV const * ToBattlegroundRV () const
 
BattlegroundICToBattlegroundIC ()
 
BattlegroundIC const * ToBattlegroundIC () const
 
- Static Public Member Functions inherited from Battleground
static TeamId GetOtherTeamId (TeamId teamId)
 
- Public Attributes inherited from Battleground
GuidSet readyMarkerClickedSet
 
ArenaLogEntryDataMap ArenaLogEntries
 
BGObjects BgObjects
 
BGCreatures BgCreatures
 
- Protected Attributes inherited from Battleground
BattlegroundScoreMap PlayerScores
 
BattlegroundPlayerMap m_Players
 
std::map< ObjectGuid, GuidVectorm_ReviveQueue
 
uint8 m_Events
 
BattlegroundStartTimeIntervals StartDelayTimes [BG_STARTING_EVENT_COUNT]
 
uint32 StartMessageIds [BG_STARTING_EVENT_COUNT]
 
bool m_BuffChange
 
bool m_IsRandom
 
BGHonorMode m_HonorMode
 
int32 m_TeamScores [PVP_TEAMS_COUNT]
 
ArenaTeamScore _arenaTeamScores [PVP_TEAMS_COUNT]
 
uint32 m_UpdateTimer
 
EventProcessor _reviveEvents
 

Detailed Description

Constructor & Destructor Documentation

◆ Arena()

Arena::Arena ( )
protected
64{
69
74}
@ ARENA_TEXT_START_ONE_MINUTE
Definition: Arena.h:25
@ ARENA_TEXT_START_THIRTY_SECONDS
Definition: Arena.h:26
@ ARENA_TEXT_START_BATTLE_HAS_BEGUN
Definition: Arena.h:28
@ ARENA_TEXT_START_FIFTEEN_SECONDS
Definition: Arena.h:27
@ BG_START_DELAY_1M
Definition: Battleground.h:175
@ BG_START_DELAY_30S
Definition: Battleground.h:176
@ BG_START_DELAY_NONE
Definition: Battleground.h:178
@ BG_START_DELAY_15S
Definition: Battleground.h:177
@ BG_STARTING_EVENT_THIRD
Definition: Battleground.h:236
@ BG_STARTING_EVENT_SECOND
Definition: Battleground.h:235
@ BG_STARTING_EVENT_FIRST
Definition: Battleground.h:234
@ BG_STARTING_EVENT_FOURTH
Definition: Battleground.h:237
BattlegroundStartTimeIntervals StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:622
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:624

References ARENA_TEXT_START_BATTLE_HAS_BEGUN, ARENA_TEXT_START_FIFTEEN_SECONDS, ARENA_TEXT_START_ONE_MINUTE, ARENA_TEXT_START_THIRTY_SECONDS, BG_START_DELAY_15S, BG_START_DELAY_1M, BG_START_DELAY_30S, BG_START_DELAY_NONE, BG_STARTING_EVENT_FIRST, BG_STARTING_EVENT_FOURTH, BG_STARTING_EVENT_SECOND, BG_STARTING_EVENT_THIRD, Battleground::StartDelayTimes, and Battleground::StartMessageIds.

Member Function Documentation

◆ AddPlayer()

void Arena::AddPlayer ( Player player)
overrideprotectedvirtual

Reimplemented from Battleground.

77{
79 PlayerScores.emplace(player->GetGUID().GetCounter(), new ArenaScore(player->GetGUID(), player->GetBgTeamId()));
80
81 if (player->GetBgTeamId() == TEAM_ALLIANCE) // gold
82 {
83 if (player->GetTeamId() == TEAM_HORDE)
84 player->CastSpell(player, SPELL_HORDE_GOLD_FLAG, true);
85 else
86 player->CastSpell(player, SPELL_ALLIANCE_GOLD_FLAG, true);
87 }
88 else // green
89 {
90 if (player->GetTeamId() == TEAM_HORDE)
91 player->CastSpell(player, SPELL_HORDE_GREEN_FLAG, true);
92 else
93 player->CastSpell(player, SPELL_ALLIANCE_GREEN_FLAG, true);
94 }
95
97
98 Group* group = player->GetGroup();
99 if (group)
100 {
101 // Hackfix for crossfaction arenas, recreate group when joining
102 // Without this, players in a crossfaction arena group would not be able to cast beneficial spells on their teammates
103
104 std::vector<Player*> members;
105 bool isCrossfaction = false;
106 for (Group::member_citerator mitr = group->GetMemberSlots().begin(); mitr != group->GetMemberSlots().end(); ++mitr)
107 {
108 Player* member = ObjectAccessor::FindPlayer(mitr->guid);
109 if (!member || member->GetGUID() == player->GetGUID())
110 {
111 continue;
112 }
113 members.push_back(member);
114 if (member->GetTeamId(true) != player->GetTeamId(true))
115 {
116 isCrossfaction = true;
117 }
118 }
119
120 if (isCrossfaction)
121 {
122 for (Player* member : members)
123 {
124 member->RemoveFromGroup();
125 }
126 group->Disband();
127
128 group = new Group();
129 SetBgRaid(player->GetBgTeamId(), group);
130 group->Create(player);
131 sGroupMgr->AddGroup(group);
132 for (Player* member : members)
133 {
134 group->AddMember(member);
135 }
136 }
137 }
138}
@ SPELL_ALLIANCE_GOLD_FLAG
Definition: Arena.h:33
@ SPELL_HORDE_GOLD_FLAG
Definition: Arena.h:35
@ SPELL_HORDE_GREEN_FLAG
Definition: Arena.h:36
@ SPELL_ALLIANCE_GREEN_FLAG
Definition: Arena.h:34
#define sGroupMgr
Definition: GroupMgr.h:51
@ TEAM_ALLIANCE
Definition: SharedDefines.h:732
@ TEAM_HORDE
Definition: SharedDefines.h:733
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:250
void UpdateArenaWorldState()
Definition: Arena.cpp:155
Definition: ArenaScore.h:25
virtual void AddPlayer(Player *player)
Definition: Battleground.cpp:1077
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:611
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition: Battleground.cpp:1828
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:106
LowType GetCounter() const
Definition: ObjectGuid.h:147
Definition: Player.h:1056
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition: Player.cpp:2323
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2069
Group * GetGroup()
Definition: Player.h:2428
TeamId GetBgTeamId() const
Definition: Player.h:2237
SpellCastResult CastSpell(SpellCastTargets const &targets, SpellInfo const *spellInfo, CustomSpellValues const *value, TriggerCastFlags triggerFlags=TRIGGERED_NONE, Item *castItem=nullptr, AuraEffect const *triggeredByAura=nullptr, ObjectGuid originalCaster=ObjectGuid::Empty)
Definition: Unit.cpp:1169
Definition: Group.h:168
MemberSlotList const & GetMemberSlots() const
Definition: Group.h:241
void Disband(bool hideDestroy=false)
Definition: Group.cpp:753
bool AddMember(Player *player)
Definition: Group.cpp:390
MemberSlotList::const_iterator member_citerator
Definition: Group.h:179
bool Create(Player *leader)
Definition: Group.cpp:108

References Group::AddMember(), Battleground::AddPlayer(), Unit::CastSpell(), Group::Create(), Group::Disband(), ObjectAccessor::FindPlayer(), Player::GetBgTeamId(), ObjectGuid::GetCounter(), Player::GetGroup(), Object::GetGUID(), Group::GetMemberSlots(), Player::GetTeamId(), Battleground::PlayerScores, Battleground::SetBgRaid(), sGroupMgr, SPELL_ALLIANCE_GOLD_FLAG, SPELL_ALLIANCE_GREEN_FLAG, SPELL_HORDE_GOLD_FLAG, SPELL_HORDE_GREEN_FLAG, TEAM_ALLIANCE, TEAM_HORDE, and UpdateArenaWorldState().

◆ CheckWinConditions()

void Arena::CheckWinConditions ( )
overrideprivatevirtual

Reimplemented from Battleground.

194{
199}
void EndBattleground(TeamId winnerTeamId) override
Definition: Arena.cpp:201
uint32 GetAlivePlayersCountByTeam(TeamId teamId) const
Definition: Battleground.cpp:1801
uint32 GetPlayersCountByTeam(TeamId teamId) const
Definition: Battleground.h:479

References EndBattleground(), Battleground::GetAlivePlayersCountByTeam(), Battleground::GetPlayersCountByTeam(), TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by HandleKillPlayer(), and RemovePlayer().

◆ EndBattleground()

void Arena::EndBattleground ( TeamId  winnerTeamId)
overrideprivatevirtual
Deprecated:
need delete

Reimplemented from Battleground.

202{
203 if (isRated())
204 {
205 uint32 startDelay = GetStartDelayTime();
206 bool bValidArena = GetStatus() == STATUS_IN_PROGRESS && GetStartTime() >= startDelay + 15000; // pussywizard: only if arena lasted at least 15 secs
207
208 uint32 loserTeamRating = 0;
209 uint32 loserMatchmakerRating = 0;
210 int32 loserChange = 0;
211 int32 loserMatchmakerChange = 0;
212 uint32 winnerTeamRating = 0;
213 uint32 winnerMatchmakerRating = 0;
214 int32 winnerChange = 0;
215 int32 winnerMatchmakerChange = 0;
216
217 ArenaTeam* winnerArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(winnerTeamId == TEAM_NEUTRAL ? TEAM_HORDE : winnerTeamId));
218 ArenaTeam* loserArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(winnerTeamId == TEAM_NEUTRAL ? TEAM_ALLIANCE : GetOtherTeamId(winnerTeamId)));
219
220 auto SaveArenaLogs = [&]()
221 {
222 // pussywizard: arena logs in database
223 uint32 fightId = sArenaTeamMgr->GetNextArenaLogId();
224 uint32 currOnline = sWorld->GetActiveSessionCount();
225
226 CharacterDatabaseTransaction trans = CharacterDatabase.BeginTransaction();
228 stmt2->SetData(0, fightId);
229 stmt2->SetData(1, GetArenaType());
230 stmt2->SetData(2, ((GetStartTime() <= startDelay ? 0 : GetStartTime() - startDelay) / 1000));
231 stmt2->SetData(3, winnerArenaTeam->GetId());
232 stmt2->SetData(4, loserArenaTeam->GetId());
233 stmt2->SetData(5, (uint16)winnerTeamRating);
234 stmt2->SetData(6, (uint16)winnerMatchmakerRating);
235 stmt2->SetData(7, (int16)winnerChange);
236 stmt2->SetData(8, (uint16)loserTeamRating);
237 stmt2->SetData(9, (uint16)loserMatchmakerRating);
238 stmt2->SetData(10, (int16)loserChange);
239 stmt2->SetData(11, currOnline);
240 trans->Append(stmt2);
241
242 uint8 memberId = 0;
243 for (auto const& [playerGuid, arenaLogEntryData] : ArenaLogEntries)
244 {
245 stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
246 stmt2->SetData(0, fightId);
247 stmt2->SetData(1, ++memberId);
248 stmt2->SetData(2, arenaLogEntryData.Name);
249 stmt2->SetData(3, arenaLogEntryData.Guid);
250 stmt2->SetData(4, arenaLogEntryData.ArenaTeamId);
251 stmt2->SetData(5, arenaLogEntryData.Acc);
252 stmt2->SetData(6, arenaLogEntryData.IP);
253 stmt2->SetData(7, arenaLogEntryData.DamageDone);
254 stmt2->SetData(8, arenaLogEntryData.HealingDone);
255 stmt2->SetData(9, arenaLogEntryData.KillingBlows);
256 trans->Append(stmt2);
257 }
258
259 CharacterDatabase.CommitTransaction(trans);
260 };
261
262 if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam)
263 {
264 loserTeamRating = loserArenaTeam->GetRating();
265 loserMatchmakerRating = GetArenaMatchmakerRating(GetOtherTeamId(winnerTeamId));
266 winnerTeamRating = winnerArenaTeam->GetRating();
267 winnerMatchmakerRating = GetArenaMatchmakerRating(winnerTeamId);
268
269 if (winnerTeamId != TEAM_NEUTRAL)
270 {
271 winnerMatchmakerChange = bValidArena ? winnerArenaTeam->WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, winnerChange, GetBgMap()) : 0;
272 loserMatchmakerChange = loserArenaTeam->LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, loserChange, GetBgMap());
273
274 sScriptMgr->OnAfterArenaRatingCalculation(this, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange);
275
276 LOG_DEBUG("bg.arena", "match Type: {} --- Winner: old rating: {}, rating gain: {}, old MMR: {}, MMR gain: {} --- Loser: old rating: {}, rating loss: {}, old MMR: {}, MMR loss: {} ---",
277 GetArenaType(), winnerTeamRating, winnerChange, winnerMatchmakerRating, winnerMatchmakerChange,
278 loserTeamRating, loserChange, loserMatchmakerRating, loserMatchmakerChange);
279
280 SetArenaMatchmakerRating(winnerTeamId, winnerMatchmakerRating + winnerMatchmakerChange);
281 SetArenaMatchmakerRating(GetOtherTeamId(winnerTeamId), loserMatchmakerRating + loserMatchmakerChange);
282
283 // bg team that the client expects is different to TeamId
284 // alliance 1, horde 0
285 uint8 winnerTeam = winnerTeamId == TEAM_ALLIANCE ? PVP_TEAM_ALLIANCE : PVP_TEAM_HORDE;
286 uint8 loserTeam = winnerTeamId == TEAM_ALLIANCE ? PVP_TEAM_HORDE : PVP_TEAM_ALLIANCE;
287
288 _arenaTeamScores[winnerTeam].Assign(winnerChange, winnerMatchmakerRating, winnerArenaTeam->GetName());
289 _arenaTeamScores[loserTeam].Assign(loserChange, loserMatchmakerRating, loserArenaTeam->GetName());
290
291 LOG_DEBUG("bg.arena", "Arena match Type: {} for Team1Id: {} - Team2Id: {} ended. WinnerTeamId: {}. Winner rating: +{}, Loser rating: {}",
292 GetArenaType(), GetArenaTeamIdForTeam(TEAM_ALLIANCE), GetArenaTeamIdForTeam(TEAM_HORDE), winnerArenaTeam->GetId(), winnerChange, loserChange);
293 }
294 else // Deduct 16 points from each teams arena-rating if there are no winners after 45+2 minutes
295 {
296 // pussywizard: in case of a draw, the following is always true:
297 // winnerArenaTeam => TEAM_HORDE, loserArenaTeam => TEAM_ALLIANCE
298
299 winnerTeamRating = winnerArenaTeam->GetRating();
300 winnerMatchmakerRating = GetArenaMatchmakerRating(TEAM_HORDE);
301 loserTeamRating = loserArenaTeam->GetRating();
302 loserMatchmakerRating = GetArenaMatchmakerRating(TEAM_ALLIANCE);
303 winnerMatchmakerChange = 0;
304 loserMatchmakerChange = 0;
305 winnerChange = ARENA_TIMELIMIT_POINTS_LOSS;
306 loserChange = ARENA_TIMELIMIT_POINTS_LOSS;
307
308 _arenaTeamScores[PVP_TEAM_ALLIANCE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, winnerMatchmakerRating, winnerArenaTeam->GetName());
309 _arenaTeamScores[PVP_TEAM_HORDE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, loserMatchmakerRating, loserArenaTeam->GetName());
310
313 }
314 }
315
316 SaveArenaLogs();
317
318 uint8 aliveWinners = GetAlivePlayersCountByTeam(winnerTeamId);
319
320 for (auto const& [playerGuid, player] : GetPlayers())
321 {
322 auto const& bgTeamId = player->GetBgTeamId();
323
324 // per player calculation
325 if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam)
326 {
327 if (bgTeamId == winnerTeamId)
328 {
329 if (bValidArena)
330 {
331 // update achievement BEFORE personal rating update
332 uint32 rating = player->GetArenaPersonalRating(winnerArenaTeam->GetSlot());
333 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, rating ? rating : 1);
334 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, GetMapId());
335
336 // Last standing - Rated 5v5 arena & be solely alive player
337 if (GetArenaType() == ARENA_TYPE_5v5 && aliveWinners == 1 && player->IsAlive())
338 {
339 player->CastSpell(player, SPELL_LAST_MAN_STANDING, true);
340 }
341
342 winnerArenaTeam->MemberWon(player, loserMatchmakerRating, winnerMatchmakerChange);
343 }
344 }
345 else
346 {
347 loserArenaTeam->MemberLost(player, winnerMatchmakerRating, loserMatchmakerChange);
348
349 // Arena lost => reset the win_rated_arena having the "no_lose" condition
350 player->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE, 0);
351 }
352
353 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA, GetMapId());
354 }
355 }
356
357 // update previous opponents for arena queue
358 winnerArenaTeam->SetPreviousOpponents(loserArenaTeam->GetId());
359 loserArenaTeam->SetPreviousOpponents(winnerArenaTeam->GetId());
360
361 // save the stat changes
362 if (bValidArena)
363 {
364 winnerArenaTeam->SaveToDB();
365 winnerArenaTeam->NotifyStatsChanged();
366 }
367
368 loserArenaTeam->SaveToDB();
369 loserArenaTeam->NotifyStatsChanged();
370 }
371
372 // end battleground
373 Battleground::EndBattleground(winnerTeamId);
374}
std::int32_t int32
Definition: Define.h:104
std::uint8_t uint8
Definition: Define.h:110
std::uint32_t uint32
Definition: Define.h:108
std::uint16_t uint16
Definition: Define.h:109
std::int16_t int16
Definition: Define.h:105
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:171
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:74
@ CHAR_INS_ARENA_LOG_MEMBERSTATS
Definition: CharacterDatabase.h:314
@ CHAR_INS_ARENA_LOG_FIGHT
Definition: CharacterDatabase.h:313
@ SPELL_LAST_MAN_STANDING
Definition: Arena.h:38
#define sArenaTeamMgr
Definition: ArenaTeamMgr.h:67
#define ARENA_TIMELIMIT_POINTS_LOSS
Definition: Battleground.h:274
@ STATUS_IN_PROGRESS
Definition: Battleground.h:197
@ ARENA_TYPE_5v5
Definition: Battleground.h:214
#define sScriptMgr
Definition: ScriptMgr.h:2762
@ ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE
Definition: DBCEnums.h:97
@ ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA
Definition: DBCEnums.h:153
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
Definition: DBCEnums.h:157
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA
Definition: DBCEnums.h:152
@ PVP_TEAM_HORDE
Definition: SharedDefines.h:3412
@ PVP_TEAM_ALLIANCE
Definition: SharedDefines.h:3413
@ TEAM_NEUTRAL
Definition: SharedDefines.h:734
#define sWorld
Definition: World.h:447
Definition: PreparedStatement.h:158
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:78
void Assign(int32 ratingChange, uint32 matchMakerRating, std::string_view teamName)
Definition: ArenaScore.h:60
Definition: ArenaTeam.h:138
void SaveToDB(bool forceMemberSave=false)
Definition: ArenaTeam.cpp:930
uint32 GetRating() const
Definition: ArenaTeam.h:159
void MemberLost(Player *player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange=-12)
Definition: ArenaTeam.cpp:841
void SetPreviousOpponents(uint32 arenaTeamId)
Definition: ArenaTeam.h:212
int32 WonAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32 &rating_change, const Map *bgMap)
Definition: ArenaTeam.cpp:805
uint8 GetSlot() const
Definition: ArenaTeam.h:151
void NotifyStatsChanged()
Definition: ArenaTeam.cpp:504
int32 LostAgainst(uint32 Own_MMRating, uint32 Opponent_MMRating, int32 &rating_change, const Map *bgMap)
Definition: ArenaTeam.cpp:825
std::string const & GetName() const
Definition: ArenaTeam.h:155
void FinishGame(int32 mod, const Map *bgMap)
Definition: ArenaTeam.cpp:775
uint32 GetId() const
Definition: ArenaTeam.h:149
void MemberWon(Player *player, uint32 againstMatchmakerRating, int32 MatchmakerRatingChange)
Definition: ArenaTeam.cpp:867
uint32 GetMapId() const
Definition: Battleground.h:420
ArenaTeamScore _arenaTeamScores[PVP_TEAMS_COUNT]
Definition: Battleground.h:632
uint8 GetArenaType() const
Definition: Battleground.h:335
uint32 GetArenaMatchmakerRating(TeamId teamId) const
Definition: Battleground.h:495
ArenaLogEntryDataMap ArenaLogEntries
Definition: Battleground.h:401
static TeamId GetOtherTeamId(TeamId teamId)
Definition: Battleground.cpp:1773
bool isRated() const
Definition: Battleground.h:390
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:424
void EndBattleground(PvPTeamId winnerTeamId)
Definition: Battleground.cpp:778
uint32 GetStartTime() const
Definition: Battleground.h:324
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:393
int32 GetStartDelayTime() const
Definition: Battleground.h:334
BattlegroundStatus GetStatus() const
Definition: Battleground.h:322
void SetArenaMatchmakerRating(TeamId teamId, uint32 MMR)
Definition: Battleground.h:494
uint32 GetArenaTeamIdForTeam(TeamId teamId) const
Definition: Battleground.h:493

References Battleground::_arenaTeamScores, ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE, ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, ARENA_TIMELIMIT_POINTS_LOSS, ARENA_TYPE_5v5, Battleground::ArenaLogEntries, ArenaTeamScore::Assign(), CHAR_INS_ARENA_LOG_FIGHT, CHAR_INS_ARENA_LOG_MEMBERSTATS, CharacterDatabase, Battleground::EndBattleground(), ArenaTeam::FinishGame(), Battleground::GetAlivePlayersCountByTeam(), Battleground::GetArenaMatchmakerRating(), Battleground::GetArenaTeamIdForTeam(), Battleground::GetArenaType(), Battleground::GetBgMap(), ArenaTeam::GetId(), Battleground::GetMapId(), ArenaTeam::GetName(), Battleground::GetOtherTeamId(), Battleground::GetPlayers(), ArenaTeam::GetRating(), ArenaTeam::GetSlot(), Battleground::GetStartDelayTime(), Battleground::GetStartTime(), Battleground::GetStatus(), Battleground::isRated(), LOG_DEBUG, ArenaTeam::LostAgainst(), ArenaTeam::MemberLost(), ArenaTeam::MemberWon(), ArenaTeam::NotifyStatsChanged(), PVP_TEAM_ALLIANCE, PVP_TEAM_HORDE, sArenaTeamMgr, ArenaTeam::SaveToDB(), Battleground::SetArenaMatchmakerRating(), PreparedStatementBase::SetData(), ArenaTeam::SetPreviousOpponents(), SPELL_LAST_MAN_STANDING, sScriptMgr, STATUS_IN_PROGRESS, sWorld, TEAM_ALLIANCE, TEAM_HORDE, TEAM_NEUTRAL, and ArenaTeam::WonAgainst().

Referenced by CheckWinConditions().

◆ FillInitialWorldStates()

◆ HandleKillPlayer()

void Arena::HandleKillPlayer ( Player player,
Player killer 
)
overrideprotectedvirtual

Reimplemented from Battleground.

162{
164 return;
165
166 Battleground::HandleKillPlayer(player, killer);
167
170}
void CheckWinConditions() override
Definition: Arena.cpp:193
virtual void HandleKillPlayer(Player *player, Player *killer)
Definition: Battleground.cpp:1738

References CheckWinConditions(), Battleground::GetStatus(), Battleground::HandleKillPlayer(), STATUS_IN_PROGRESS, and UpdateArenaWorldState().

◆ RemovePlayer()

void Arena::RemovePlayer ( Player )
overrideprotectedvirtual

Reimplemented from Battleground.

141{
143 return;
144
147}
@ STATUS_WAIT_LEAVE
Definition: Battleground.h:198

References CheckWinConditions(), Battleground::GetStatus(), STATUS_WAIT_LEAVE, and UpdateArenaWorldState().

◆ RemovePlayerAtLeave()

void Arena::RemovePlayerAtLeave ( Player player)
overrideprivatevirtual

Reimplemented from Battleground.

173{
175 {
176 if (auto const& member = Acore::Containers::MapGetValuePtr(m_Players, player->GetGUID()))
177 {
178 // if the player was a match participant, calculate rating
179 auto teamId = member->GetBgTeamId();
180
181 ArenaTeam* winnerArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(GetOtherTeamId(teamId)));
182 ArenaTeam* loserArenaTeam = sArenaTeamMgr->GetArenaTeamById(GetArenaTeamIdForTeam(teamId));
183
184 if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam)
185 loserArenaTeam->MemberLost(player, GetArenaMatchmakerRating(GetOtherTeamId(teamId)));
186 }
187 }
188
189 // remove player
191}
auto MapGetValuePtr(M &map, typename M::key_type const &key) -> decltype(AddressOrSelf(map.find(key) ->second))
Definition: Containers.h:208
virtual void RemovePlayerAtLeave(Player *player)
Definition: Battleground.cpp:934
BattlegroundPlayerMap m_Players
Definition: Battleground.h:616

References Battleground::GetArenaMatchmakerRating(), Battleground::GetArenaTeamIdForTeam(), Object::GetGUID(), Battleground::GetOtherTeamId(), Battleground::GetStatus(), Battleground::isRated(), Battleground::m_Players, Acore::Containers::MapGetValuePtr(), ArenaTeam::MemberLost(), Battleground::RemovePlayerAtLeave(), sArenaTeamMgr, and STATUS_IN_PROGRESS.

◆ UpdateArenaWorldState()