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 (WorldPackets::WorldState::InitWorldStates &packet) 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)
 

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
 
bool isTemplate () const
 
bool isMaxLevel () const
 
uint32 GetMaxPlayersPerTeam () const
 
uint32 GetMinPlayersPerTeam () const
 
int32 GetStartDelayTime () const
 
uint8 GetArenaType () const
 
PvPTeamId GetWinner () const
 
uint32 GetScriptId () const
 
uint32 GetBonusHonorFromKill (uint32 kills) const
 
void SpiritOfCompetitionEvent (PvPTeamId winnerTeamId) 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
 
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)
 
void BlockMovement (Player *player)
 
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)
 
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 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)
 
void AddOrSetPlayerToCorrectBgGroup (Player *player, TeamId teamId)
 
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)
 
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
66{
71
76}
@ 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:181
@ BG_START_DELAY_30S
Definition Battleground.h:182
@ BG_START_DELAY_NONE
Definition Battleground.h:184
@ BG_START_DELAY_15S
Definition Battleground.h:183
@ BG_STARTING_EVENT_THIRD
Definition Battleground.h:242
@ BG_STARTING_EVENT_SECOND
Definition Battleground.h:241
@ BG_STARTING_EVENT_FIRST
Definition Battleground.h:240
@ BG_STARTING_EVENT_FOURTH
Definition Battleground.h:243
BattlegroundStartTimeIntervals StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition Battleground.h:639
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition Battleground.h:641

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.

79{
81 PlayerScores.emplace(player->GetGUID().GetCounter(), new ArenaScore(player->GetGUID(), player->GetBgTeamId()));
82
83 if (player->GetBgTeamId() == TEAM_ALLIANCE) // gold
84 {
85 if (player->GetTeamId() == TEAM_HORDE)
86 player->CastSpell(player, SPELL_HORDE_GOLD_FLAG, true);
87 else
88 player->CastSpell(player, SPELL_ALLIANCE_GOLD_FLAG, true);
89 }
90 else // green
91 {
92 if (player->GetTeamId() == TEAM_HORDE)
93 player->CastSpell(player, SPELL_HORDE_GREEN_FLAG, true);
94 else
95 player->CastSpell(player, SPELL_ALLIANCE_GREEN_FLAG, true);
96 }
97
99
100 Group* group = player->GetGroup();
101 if (group)
102 {
103 // Hackfix for crossfaction arenas, recreate group when joining
104 // Without this, players in a crossfaction arena group would not be able to cast beneficial spells on their teammates
105
106 std::vector<Player*> members;
107 bool isCrossfaction = false;
108 for (Group::member_citerator mitr = group->GetMemberSlots().begin(); mitr != group->GetMemberSlots().end(); ++mitr)
109 {
110 Player* member = ObjectAccessor::FindPlayer(mitr->guid);
111 if (!member || member->GetGUID() == player->GetGUID())
112 {
113 continue;
114 }
115 members.push_back(member);
116 if (member->GetTeamId(true) != player->GetTeamId(true))
117 {
118 isCrossfaction = true;
119 }
120 }
121
122 if (isCrossfaction)
123 {
124 for (Player* member : members)
125 {
126 member->RemoveFromGroup();
127 }
128 group->Disband();
129
130 group = new Group();
131 SetBgRaid(player->GetBgTeamId(), group);
132 group->Create(player);
133 sGroupMgr->AddGroup(group);
134 for (Player* member : members)
135 {
136 group->AddMember(member);
137 }
138 }
139 }
140}
@ 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
void UpdateArenaWorldState()
Definition Arena.cpp:158
virtual void AddPlayer(Player *player)
Definition Battleground.cpp:1119
BattlegroundScoreMap PlayerScores
Definition Battleground.h:628
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition Battleground.cpp:1806
Definition Group.h:169
MemberSlotList const & GetMemberSlots() const
Definition Group.h:242
void Disband(bool hideDestroy=false)
Definition Group.cpp:751
bool AddMember(Player *player)
Definition Group.cpp:388
MemberSlotList::const_iterator member_citerator
Definition Group.h:180
bool Create(Player *leader)
Definition Group.cpp:106
LowType GetCounter() const
Definition ObjectGuid.h:145
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:112
Definition Player.h:1081
static void RemoveFromGroup(Group *group, ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Player.cpp:2371
TeamId GetTeamId(bool original=false) const
Definition Player.h:2116
Group * GetGroup()
Definition Player.h:2476
TeamId GetBgTeamId() const
Definition Player.h:2286
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:1178
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245
Definition ArenaScore.h:26

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.

197{
198 if (!sScriptMgr->OnBeforeArenaCheckWinConditions(this))
199 return;
200
205}
#define sScriptMgr
Definition ScriptMgr.h:727
void EndBattleground(TeamId winnerTeamId) override
Definition Arena.cpp:207
uint32 GetAlivePlayersCountByTeam(TeamId teamId) const
Definition Battleground.cpp:1779
uint32 GetPlayersCountByTeam(TeamId teamId) const
Definition Battleground.h:498

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

Referenced by HandleKillPlayer(), and RemovePlayer().

◆ EndBattleground()

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

Reimplemented from Battleground.

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

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, sWorldSessionMgr, 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.

165{
167 return;
168
169 Battleground::HandleKillPlayer(player, killer);
170
173}
void CheckWinConditions() override
Definition Arena.cpp:196
virtual void HandleKillPlayer(Player *player, Player *killer)
Definition Battleground.cpp:1716

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

◆ RemovePlayer()

void Arena::RemovePlayer ( Player )
overrideprotectedvirtual

Reimplemented from Battleground.

143{
145 return;
146
149}
@ STATUS_WAIT_LEAVE
Definition Battleground.h:204

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

◆ RemovePlayerAtLeave()

void Arena::RemovePlayerAtLeave ( Player player)
overrideprivatevirtual

Reimplemented from Battleground.

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

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


The documentation for this class was generated from the following files: