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 SpiritofCompetitionEvent (PvPTeamId winnerTeamId)
 
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:630
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition: Battleground.h:632

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:760
@ TEAM_HORDE
Definition: SharedDefines.h:761
Player * FindPlayer(ObjectGuid const guid)
Definition: ObjectAccessor.cpp:248
void UpdateArenaWorldState()
Definition: Arena.cpp:155
Definition: ArenaScore.h:25
virtual void AddPlayer(Player *player)
Definition: Battleground.cpp:1117
BattlegroundScoreMap PlayerScores
Definition: Battleground.h:619
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition: Battleground.cpp:1868
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:2328
TeamId GetTeamId(bool original=false) const
Definition: Player.h:2072
Group * GetGroup()
Definition: Player.h:2431
TeamId GetBgTeamId() const
Definition: Player.h:2240
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:169
MemberSlotList const & GetMemberSlots() const
Definition: Group.h:242
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:180
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:1841
uint32 GetPlayersCountByTeam(TeamId teamId) const
Definition: Battleground.h:487

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 auto const& score = PlayerScores.find(playerGuid.GetCounter());
246 stmt2 = CharacterDatabase.GetPreparedStatement(CHAR_INS_ARENA_LOG_MEMBERSTATS);
247 stmt2->SetData(0, fightId);
248 stmt2->SetData(1, ++memberId);
249 stmt2->SetData(2, arenaLogEntryData.Name);
250 stmt2->SetData(3, arenaLogEntryData.Guid);
251 stmt2->SetData(4, arenaLogEntryData.ArenaTeamId);
252 stmt2->SetData(5, arenaLogEntryData.Acc);
253 stmt2->SetData(6, arenaLogEntryData.IP);
254 if (score != PlayerScores.end())
255 {
256 stmt2->SetData(7, score->second->GetDamageDone());
257 stmt2->SetData(8, score->second->GetHealingDone());
258 stmt2->SetData(9, score->second->GetKillingBlows());
259 }
260 else
261 {
262 stmt2->SetData(7, 0);
263 stmt2->SetData(8, 0);
264 stmt2->SetData(9, 0);
265 }
266 trans->Append(stmt2);
267 }
268
269 CharacterDatabase.CommitTransaction(trans);
270 };
271
272 if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam)
273 {
274 loserTeamRating = loserArenaTeam->GetRating();
275 loserMatchmakerRating = GetArenaMatchmakerRating(GetOtherTeamId(winnerTeamId));
276 winnerTeamRating = winnerArenaTeam->GetRating();
277 winnerMatchmakerRating = GetArenaMatchmakerRating(winnerTeamId);
278
279 if (winnerTeamId != TEAM_NEUTRAL)
280 {
281 winnerMatchmakerChange = bValidArena ? winnerArenaTeam->WonAgainst(winnerMatchmakerRating, loserMatchmakerRating, winnerChange, GetBgMap()) : 0;
282 loserMatchmakerChange = loserArenaTeam->LostAgainst(loserMatchmakerRating, winnerMatchmakerRating, loserChange, GetBgMap());
283
284 sScriptMgr->OnAfterArenaRatingCalculation(this, winnerMatchmakerChange, loserMatchmakerChange, winnerChange, loserChange);
285
286 LOG_DEBUG("bg.arena", "match Type: {} --- Winner: old rating: {}, rating gain: {}, old MMR: {}, MMR gain: {} --- Loser: old rating: {}, rating loss: {}, old MMR: {}, MMR loss: {} ---",
287 GetArenaType(), winnerTeamRating, winnerChange, winnerMatchmakerRating, winnerMatchmakerChange,
288 loserTeamRating, loserChange, loserMatchmakerRating, loserMatchmakerChange);
289
290 SetArenaMatchmakerRating(winnerTeamId, winnerMatchmakerRating + winnerMatchmakerChange);
291 SetArenaMatchmakerRating(GetOtherTeamId(winnerTeamId), loserMatchmakerRating + loserMatchmakerChange);
292
293 // bg team that the client expects is different to TeamId
294 // alliance 1, horde 0
295 uint8 winnerTeam = winnerTeamId == TEAM_ALLIANCE ? PVP_TEAM_ALLIANCE : PVP_TEAM_HORDE;
296 uint8 loserTeam = winnerTeamId == TEAM_ALLIANCE ? PVP_TEAM_HORDE : PVP_TEAM_ALLIANCE;
297
298 _arenaTeamScores[winnerTeam].Assign(winnerChange, winnerMatchmakerRating, winnerArenaTeam->GetName());
299 _arenaTeamScores[loserTeam].Assign(loserChange, loserMatchmakerRating, loserArenaTeam->GetName());
300
301 LOG_DEBUG("bg.arena", "Arena match Type: {} for Team1Id: {} - Team2Id: {} ended. WinnerTeamId: {}. Winner rating: +{}, Loser rating: {}",
302 GetArenaType(), GetArenaTeamIdForTeam(TEAM_ALLIANCE), GetArenaTeamIdForTeam(TEAM_HORDE), winnerArenaTeam->GetId(), winnerChange, loserChange);
303 }
304 else // Deduct 16 points from each teams arena-rating if there are no winners after 45+2 minutes
305 {
306 // pussywizard: in case of a draw, the following is always true:
307 // winnerArenaTeam => TEAM_HORDE, loserArenaTeam => TEAM_ALLIANCE
308
309 winnerTeamRating = winnerArenaTeam->GetRating();
310 winnerMatchmakerRating = GetArenaMatchmakerRating(TEAM_HORDE);
311 loserTeamRating = loserArenaTeam->GetRating();
312 loserMatchmakerRating = GetArenaMatchmakerRating(TEAM_ALLIANCE);
313 winnerMatchmakerChange = 0;
314 loserMatchmakerChange = 0;
315 winnerChange = ARENA_TIMELIMIT_POINTS_LOSS;
316 loserChange = ARENA_TIMELIMIT_POINTS_LOSS;
317
318 _arenaTeamScores[PVP_TEAM_ALLIANCE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, winnerMatchmakerRating, winnerArenaTeam->GetName());
319 _arenaTeamScores[PVP_TEAM_HORDE].Assign(ARENA_TIMELIMIT_POINTS_LOSS, loserMatchmakerRating, loserArenaTeam->GetName());
320
323 }
324 }
325
326 SaveArenaLogs();
327
328 uint8 aliveWinners = GetAlivePlayersCountByTeam(winnerTeamId);
329
330 for (auto const& [playerGuid, player] : GetPlayers())
331 {
332 auto const& bgTeamId = player->GetBgTeamId();
333
334 // per player calculation
335 if (winnerArenaTeam && loserArenaTeam && winnerArenaTeam != loserArenaTeam)
336 {
337 if (bgTeamId == winnerTeamId)
338 {
339 if (bValidArena)
340 {
341 // update achievement BEFORE personal rating update
342 uint32 rating = player->GetArenaPersonalRating(winnerArenaTeam->GetSlot());
343 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA, rating ? rating : 1);
344 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA, GetMapId());
345
346 // Last standing - Rated 5v5 arena & be solely alive player
347 if (GetArenaType() == ARENA_TYPE_5v5 && aliveWinners == 1 && player->IsAlive())
348 {
349 player->CastSpell(player, SPELL_LAST_MAN_STANDING, true);
350 }
351
352 winnerArenaTeam->MemberWon(player, loserMatchmakerRating, winnerMatchmakerChange);
353 }
354 }
355 else
356 {
357 loserArenaTeam->MemberLost(player, winnerMatchmakerRating, loserMatchmakerChange);
358
359 // Arena lost => reset the win_rated_arena having the "no_lose" condition
360 player->ResetAchievementCriteria(ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE, 0);
361 }
362
363 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA, GetMapId());
364 }
365 }
366
367 // update previous opponents for arena queue
368 winnerArenaTeam->SetPreviousOpponents(loserArenaTeam->GetId());
369 loserArenaTeam->SetPreviousOpponents(winnerArenaTeam->GetId());
370
371 // save the stat changes
372 if (bValidArena)
373 {
374 winnerArenaTeam->SaveToDB();
375 winnerArenaTeam->NotifyStatsChanged();
376 }
377
378 loserArenaTeam->SaveToDB();
379 loserArenaTeam->NotifyStatsChanged();
380 }
381
382 // end battleground
383 Battleground::EndBattleground(winnerTeamId);
384}
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:169
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
SQLTransaction< CharacterDatabaseConnection > CharacterDatabaseTransaction
Definition: DatabaseEnvFwd.h:70
@ 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:279
@ STATUS_IN_PROGRESS
Definition: Battleground.h:197
@ ARENA_TYPE_5v5
Definition: Battleground.h:214
#define sScriptMgr
Definition: ScriptMgr.h:698
@ ACHIEVEMENT_CRITERIA_CONDITION_NO_LOSE
Definition: DBCEnums.h:99
@ ACHIEVEMENT_CRITERIA_TYPE_PLAY_ARENA
Definition: DBCEnums.h:155
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_RATED_ARENA
Definition: DBCEnums.h:159
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_ARENA
Definition: DBCEnums.h:154
@ PVP_TEAM_HORDE
Definition: SharedDefines.h:3440
@ PVP_TEAM_ALLIANCE
Definition: SharedDefines.h:3441
@ TEAM_NEUTRAL
Definition: SharedDefines.h:762
#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:428
ArenaTeamScore _arenaTeamScores[PVP_TEAMS_COUNT]
Definition: Battleground.h:640
uint8 GetArenaType() const
Definition: Battleground.h:340
uint32 GetArenaMatchmakerRating(TeamId teamId) const
Definition: Battleground.h:503
ArenaLogEntryDataMap ArenaLogEntries
Definition: Battleground.h:409
static TeamId GetOtherTeamId(TeamId teamId)
Definition: Battleground.cpp:1813
bool isRated() const
Definition: Battleground.h:398
BattlegroundMap * GetBgMap() const
Definition: Battleground.h:432
void EndBattleground(PvPTeamId winnerTeamId)
Definition: Battleground.cpp:778
uint32 GetStartTime() const
Definition: Battleground.h:329
BattlegroundPlayerMap const & GetPlayers() const
Definition: Battleground.h:401
int32 GetStartDelayTime() const
Definition: Battleground.h:339
BattlegroundStatus GetStatus() const
Definition: Battleground.h:327
void SetArenaMatchmakerRating(TeamId teamId, uint32 MMR)
Definition: Battleground.h:502
uint32 GetArenaTeamIdForTeam(TeamId teamId) const
Definition: Battleground.h:501

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(), Battleground::PlayerScores, 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:1778

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:974
BattlegroundPlayerMap m_Players
Definition: Battleground.h:624

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()