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

#include "Battleground.h"

Inheritance diagram for Battleground:
Arena BattlegroundAB BattlegroundAV BattlegroundEY BattlegroundIC BattlegroundSA BattlegroundWS BattlegroundBE BattlegroundDS BattlegroundNA BattlegroundRL BattlegroundRV

Public Types

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

 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
 
virtual void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &)
 
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)
 
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)
 
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

static TeamId GetOtherTeamId (TeamId teamId)
 

Public Attributes

GuidSet readyMarkerClickedSet
 
ArenaLogEntryDataMap ArenaLogEntries
 
BGObjects BgObjects
 
BGCreatures BgCreatures
 

Protected Member Functions

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

Protected Attributes

bool m_SetupCompleted
 
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
 

Private Member Functions

virtual bool PreUpdateImpl (uint32)
 Pre-update hook.
 
virtual void PostUpdateImpl (uint32)
 Post-update hook.
 

Private Attributes

BattlegroundTypeId m_RealTypeID
 
BattlegroundTypeId m_RandomTypeID
 
uint32 m_InstanceID
 
BattlegroundStatus m_Status
 
uint32 m_ClientInstanceID
 
uint32 m_StartTime
 
uint32 m_ResetStatTimer
 
uint32 m_ValidStartPositionTimer
 
int32 m_EndTime
 
uint32 m_LastResurrectTime
 
BattlegroundBracketId m_BracketId { BG_BRACKET_ID_FIRST }
 
uint8 m_ArenaType
 
bool _InBGFreeSlotQueue { false }
 
bool m_SetDeleteThis
 
bool m_IsArena
 
bool m_IsTemplate
 
PvPTeamId m_WinnerId
 
int32 m_StartDelayTime
 
bool m_IsRated
 
bool m_PrematureCountDown
 
uint32 m_PrematureCountDownTimer
 
std::string m_Name {}
 
GuidVector m_ResurrectQueue
 
GuidDeque m_OfflineQueue
 
uint32 m_BgInvitedPlayers [PVP_TEAMS_COUNT]
 
Groupm_BgRaids [PVP_TEAMS_COUNT]
 
SpectatorList m_Spectators
 
ToBeTeleportedMap m_ToBeTeleported
 
uint32 m_PlayersCount [PVP_TEAMS_COUNT]
 
uint32 m_ArenaTeamIds [PVP_TEAMS_COUNT]
 
uint32 m_ArenaTeamMMR [PVP_TEAMS_COUNT]
 
uint32 m_LevelMin
 
uint32 m_LevelMax
 
uint32 m_MaxPlayersPerTeam
 
uint32 m_MinPlayersPerTeam
 
uint32 m_MapId
 
BattlegroundMapm_Map
 
float m_StartMaxDist
 
std::array< Position, PVP_TEAMS_COUNT_startPosition
 
uint32 ScriptId
 

Detailed Description

Member Typedef Documentation

◆ ArenaLogEntryDataMap

◆ BattlegroundPlayerMap

◆ BattlegroundScoreMap

◆ BGCreatures

◆ BGObjects

Todo:
: make this protected:

◆ SpectatorList

typedef std::set<Player*> Battleground::SpectatorList

◆ ToBeTeleportedMap

Constructor & Destructor Documentation

◆ Battleground()

Battleground::Battleground ( )
143{
146 m_InstanceID = 0;
149 m_EndTime = 0;
151 m_ArenaType = 0;
152 m_IsArena = false;
153 m_IsTemplate = true;
155 m_StartTime = 0;
158 m_Events = 0;
160 m_IsRated = false;
161 m_BuffChange = false;
162 m_IsRandom = false;
163 m_LevelMin = 0;
164 m_LevelMax = 0;
165 m_SetDeleteThis = false;
166
169
170 m_MapId = 0;
171 m_Map = nullptr;
172 m_StartMaxDist = 0.0f;
173 ScriptId = 0;
174
177
180
181 m_BgRaids[TEAM_ALLIANCE] = nullptr;
182 m_BgRaids[TEAM_HORDE] = nullptr;
183
186
189
192
193 m_PrematureCountDown = false;
195
197
198 m_SetupCompleted = false;
199
204
209
210 // pussywizard:
211 m_UpdateTimer = 0;
212}
@ BG_TEXT_START_TWO_MINUTES
Definition Battleground.h:68
@ BG_TEXT_BATTLE_HAS_BEGUN
Definition Battleground.h:71
@ BG_TEXT_START_ONE_MINUTE
Definition Battleground.h:69
@ BG_TEXT_START_HALF_MINUTE
Definition Battleground.h:70
@ BG_NORMAL
Definition Battleground.h:270
@ BG_START_DELAY_1M
Definition Battleground.h:171
@ BG_START_DELAY_30S
Definition Battleground.h:172
@ BG_START_DELAY_2M
Definition Battleground.h:170
@ BG_START_DELAY_NONE
Definition Battleground.h:174
@ STATUS_NONE
Definition Battleground.h:190
@ BG_STARTING_EVENT_THIRD
Definition Battleground.h:232
@ BG_STARTING_EVENT_SECOND
Definition Battleground.h:231
@ BG_STARTING_EVENT_FIRST
Definition Battleground.h:230
@ BG_STARTING_EVENT_FOURTH
Definition Battleground.h:233
@ PVP_TEAM_NEUTRAL
Definition SharedDefines.h:3708
@ BATTLEGROUND_TYPE_NONE
Definition SharedDefines.h:3746
@ TEAM_ALLIANCE
Definition SharedDefines.h:771
@ TEAM_HORDE
Definition SharedDefines.h:772
uint32 m_ArenaTeamMMR[PVP_TEAMS_COUNT]
Definition Battleground.h:724
bool m_SetDeleteThis
Definition Battleground.h:664
BGHonorMode m_HonorMode
Definition Battleground.h:639
uint32 m_MapId
Definition Battleground.h:733
uint32 m_ArenaTeamIds[PVP_TEAMS_COUNT]
Definition Battleground.h:723
uint32 m_ValidStartPositionTimer
Definition Battleground.h:658
int32 m_StartDelayTime
Definition Battleground.h:668
uint32 m_ClientInstanceID
Definition Battleground.h:655
uint32 m_LevelMax
Definition Battleground.h:728
PvPTeamId m_WinnerId
Definition Battleground.h:667
uint32 m_LastResurrectTime
Definition Battleground.h:660
uint32 m_BgInvitedPlayers[PVP_TEAMS_COUNT]
Definition Battleground.h:711
BattlegroundTypeId m_RandomTypeID
Definition Battleground.h:652
bool m_IsArena
Definition Battleground.h:665
bool m_IsRated
Definition Battleground.h:669
bool m_PrematureCountDown
Definition Battleground.h:670
uint32 m_PlayersCount[PVP_TEAMS_COUNT]
Definition Battleground.h:720
Group * m_BgRaids[PVP_TEAMS_COUNT]
Definition Battleground.h:714
uint32 m_PrematureCountDownTimer
Definition Battleground.h:671
int32 m_TeamScores[PVP_TEAMS_COUNT]
Definition Battleground.h:640
uint32 m_UpdateTimer
Definition Battleground.h:645
bool m_IsRandom
Definition Battleground.h:637
BattlegroundTypeId m_RealTypeID
Definition Battleground.h:651
BattlegroundStartTimeIntervals StartDelayTimes[BG_STARTING_EVENT_COUNT]
Definition Battleground.h:632
int32 m_EndTime
Definition Battleground.h:659
uint32 ScriptId
Definition Battleground.h:737
uint32 m_InstanceID
Definition Battleground.h:653
uint32 m_ResetStatTimer
Definition Battleground.h:657
bool m_BuffChange
Definition Battleground.h:636
uint32 m_MinPlayersPerTeam
Definition Battleground.h:730
uint8 m_ArenaType
Definition Battleground.h:662
uint8 m_Events
Definition Battleground.h:631
float m_StartMaxDist
Definition Battleground.h:735
uint32 m_MaxPlayersPerTeam
Definition Battleground.h:729
bool m_IsTemplate
Definition Battleground.h:666
uint32 m_LevelMin
Definition Battleground.h:727
uint32 m_StartTime
Definition Battleground.h:656
bool m_SetupCompleted
Definition Battleground.h:618
BattlegroundMap * m_Map
Definition Battleground.h:734
BattlegroundStatus m_Status
Definition Battleground.h:654
uint32 StartMessageIds[BG_STARTING_EVENT_COUNT]
Definition Battleground.h:634

References BATTLEGROUND_TYPE_NONE, BG_NORMAL, BG_START_DELAY_1M, BG_START_DELAY_2M, BG_START_DELAY_30S, BG_START_DELAY_NONE, BG_STARTING_EVENT_FIRST, BG_STARTING_EVENT_FOURTH, BG_STARTING_EVENT_SECOND, BG_STARTING_EVENT_THIRD, BG_TEXT_BATTLE_HAS_BEGUN, BG_TEXT_START_HALF_MINUTE, BG_TEXT_START_ONE_MINUTE, BG_TEXT_START_TWO_MINUTES, m_ArenaTeamIds, m_ArenaTeamMMR, m_ArenaType, m_BgInvitedPlayers, m_BgRaids, m_BuffChange, m_ClientInstanceID, m_EndTime, m_Events, m_HonorMode, m_InstanceID, m_IsArena, m_IsRandom, m_IsRated, m_IsTemplate, m_LastResurrectTime, m_LevelMax, m_LevelMin, m_Map, m_MapId, m_MaxPlayersPerTeam, m_MinPlayersPerTeam, m_PlayersCount, m_PrematureCountDown, m_PrematureCountDownTimer, m_RandomTypeID, m_RealTypeID, m_ResetStatTimer, m_SetDeleteThis, m_SetupCompleted, m_StartDelayTime, m_StartMaxDist, m_StartTime, m_Status, m_TeamScores, m_UpdateTimer, m_ValidStartPositionTimer, m_WinnerId, PVP_TEAM_NEUTRAL, ScriptId, StartDelayTimes, StartMessageIds, STATUS_NONE, TEAM_ALLIANCE, and TEAM_HORDE.

◆ ~Battleground()

Battleground::~Battleground ( )
virtual
215{
216 LOG_DEBUG("bg.battleground", "> Remove Battleground {} {} {}", GetName(), GetBgTypeID(), GetInstanceID());
217
219
220 // remove objects and creatures
221 // (this is done automatically in mapmanager update, when the instance is reset after the reset time)
222 uint32 size = uint32(BgCreatures.size());
223 for (uint32 i = 0; i < size; ++i)
224 DelCreature(i);
225
226 size = uint32(BgObjects.size());
227 for (uint32 i = 0; i < size; ++i)
228 DelObject(i);
229
230 sScriptMgr->OnBattlegroundDestroy(this);
231
232 sBattlegroundMgr->RemoveBattleground(GetBgTypeID(), GetInstanceID());
233 // unload map
234 if (m_Map)
235 {
236 m_Map->SetUnload();
237 //unlink to prevent crash, always unlink all pointer reference before destruction
238 m_Map->SetBG(nullptr);
239 m_Map = nullptr;
240 }
241
242 // remove from bg free slot queue
244
245 for (auto const& itr : PlayerScores)
246 delete itr.second;
247}
#define sBattlegroundMgr
Definition BattlegroundMgr.h:187
std::uint32_t uint32
Definition Define.h:107
#define LOG_DEBUG(filterType__,...)
Definition Log.h:170
#define sScriptMgr
Definition ScriptMgr.h:728
void SetUnload()
Definition Map.cpp:2345
void SetBG(Battleground *bg)
Definition Map.h:694
bool DelCreature(uint32 type)
Definition Battleground.cpp:1639
EventProcessor _reviveEvents
Definition Battleground.h:647
uint32 GetInstanceID() const
Definition Battleground.h:322
BGObjects BgObjects
Definition Battleground.h:540
bool DelObject(uint32 type)
Definition Battleground.cpp:1658
BattlegroundScoreMap PlayerScores
Definition Battleground.h:621
void RemoveFromBGFreeSlotQueue()
Definition Battleground.cpp:1270
BGCreatures BgCreatures
Definition Battleground.h:541
std::string GetName() const
Definition Battleground.h:319
BattlegroundTypeId GetBgTypeID(bool GetRandom=false) const
Definition Battleground.h:320
void KillAllEvents(bool force)
Definition EventProcessor.cpp:82

References _reviveEvents, BgCreatures, BgObjects, DelCreature(), DelObject(), GetBgTypeID(), GetInstanceID(), GetName(), EventProcessor::KillAllEvents(), LOG_DEBUG, m_Map, PlayerScores, RemoveFromBGFreeSlotQueue(), sBattlegroundMgr, BattlegroundMap::SetBG(), BattlegroundMap::SetUnload(), and sScriptMgr.

Member Function Documentation

◆ _CheckSafePositions()

void Battleground::_CheckSafePositions ( uint32  diff)
inlineprotected
326{
327 float maxDist = GetStartMaxDist();
328 if (!maxDist)
329 return;
330
332
334 {
336
337 for (auto const& [playerGuid, player] : GetPlayers())
338 {
339 Position pos = player->GetPosition();
340 Position const* startPos = GetTeamStartPosition(player->GetBgTeamId());
341
342 if (pos.GetExactDistSq(startPos) > maxDist)
343 {
344 LOG_DEBUG("bg.battleground", "BATTLEGROUND: Sending {} back to start location (map: {}) (possible exploit)", player->GetName(), GetMapId());
345 player->TeleportTo(GetMapId(), startPos->GetPositionX(), startPos->GetPositionY(), startPos->GetPositionZ(), startPos->GetOrientation());
346 }
347 }
348 }
349}
@ CHECK_PLAYER_POSITION_INVERVAL
Definition Battleground.h:153
uint32 GetMapId() const
Definition Battleground.h:436
Position const * GetTeamStartPosition(TeamId teamId) const
Definition Battleground.cpp:707
BattlegroundPlayerMap const & GetPlayers() const
Definition Battleground.h:409
float GetStartMaxDist() const
Definition Battleground.h:447
Definition Position.h:27
float GetPositionZ() const
Definition Position.h:123
float GetOrientation() const
Definition Position.h:124
float GetPositionX() const
Definition Position.h:121
void GetPosition(float &x, float &y) const
Definition Position.h:126
float GetPositionY() const
Definition Position.h:122
float GetExactDistSq(float x, float y, float z) const
Definition Position.h:174

References CHECK_PLAYER_POSITION_INVERVAL, Position::GetExactDistSq(), GetMapId(), Position::GetOrientation(), GetPlayers(), Position::GetPosition(), Position::GetPositionX(), Position::GetPositionY(), Position::GetPositionZ(), GetStartMaxDist(), GetTeamStartPosition(), LOG_DEBUG, and m_ValidStartPositionTimer.

Referenced by Update().

◆ _ProcessJoin()

void Battleground::_ProcessJoin ( uint32  diff)
inlineprotected
467{
468 // *********************************************************
469 // *** BATTLEGROUND STARTING SYSTEM ***
470 // *********************************************************
472
473 if (m_ResetStatTimer > 5000)
474 {
476 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
477 itr->second->ResetAllPowers();
478 }
479
480 if (!m_SetupCompleted)
481 {
482 if (!FindBgMap())
483 {
484 LOG_ERROR("bg.battleground", "Battleground::_ProcessJoin: map (map id: {}, instance id: {}) is not created!", m_MapId, m_InstanceID);
485 EndNow();
486 return;
487 }
488
489 // Setup here, only when at least one player has ported to the map
490 if (!SetupBattleground())
491 {
492 EndNow();
493 return;
494 }
495
497
498 // Get the configured prep time
499 uint32 configuredPrepTime;
500
501 // Special case for Strand of the Ancients - always use 120 seconds due to boat timing mechanics
503 configuredPrepTime = 120 * IN_MILLISECONDS;
504 else
505 configuredPrepTime = isArena() ?
508
509 SetStartDelayTime(configuredPrepTime);
510
511 // Pre-mark events for announcements that should be skipped based on configured prep time
512 if (configuredPrepTime < StartDelayTimes[BG_STARTING_EVENT_FIRST])
513 {
514 // Skip first announcement (120s for BG, 60s for Arena)
516
517 if (configuredPrepTime < StartDelayTimes[BG_STARTING_EVENT_SECOND])
518 {
519 // Skip second announcement (60s for BG, 30s for Arena)
521
522 if (configuredPrepTime < StartDelayTimes[BG_STARTING_EVENT_THIRD])
523 {
524 // Skip third announcement (30s for BG, 15s for Arena)
526 }
527 }
528 }
529
530 // Mark setup as completed
531 m_SetupCompleted = true;
532 }
533
534 // First announcement at 120s or 60s (Depending on BG or Arena and configured time)
536 {
538
541 }
542 // Second announcement at 60s or 30s
544 {
546
549 }
550 // Third announcement at 30s or 15s
552 {
554
557
558 if (isArena())
559 switch (GetBgTypeID())
560 {
561 case BATTLEGROUND_NA:
564 break;
565 case BATTLEGROUND_BE:
568 break;
569 case BATTLEGROUND_RL:
572 break;
573 case BATTLEGROUND_DS:
576 break;
577 case BATTLEGROUND_RV:
580 break;
581 default:
582 break;
583 }
584 }
585 // Delay expired (after configured prep time)
586 else if (GetStartDelayTime() <= 0 && !(m_Events & BG_STARTING_EVENT_4))
587 {
589
590 // Start the battle
592
595
598
599 // Remove preparation
600 if (isArena())
601 {
602 // pussywizard: initial visibility range is 30yd, set it to a proper value now:
603 if (BattlegroundMap* map = GetBgMap())
604 map->SetVisibilityRange(World::GetMaxVisibleDistanceInBGArenas());
605
606 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
607 if (Player* player = itr->second)
608 {
609 WorldPacket status;
610 sBattlegroundMgr->BuildBattlegroundStatusPacket(&status, this, player->GetCurrentBattlegroundQueueSlot(), STATUS_IN_PROGRESS, 0, GetStartTime(), GetArenaType(), player->GetBgTeamId());
611 player->SendDirectMessage(&status);
612
613 player->RemoveAurasDueToSpell(SPELL_ARENA_PREPARATION);
614 player->ResetAllPowers();
615 // remove auras with duration lower than 30s
616 Unit::AuraApplicationMap& auraMap = player->GetAppliedAuras();
617 for (Unit::AuraApplicationMap::iterator iter = auraMap.begin(); iter != auraMap.end();)
618 {
619 AuraApplication* aurApp = iter->second;
620 Aura* aura = aurApp->GetBase();
621 if (!aura->IsPermanent()
622 && aura->GetDuration() <= 30 * IN_MILLISECONDS
623 && aurApp->IsPositive()
624 // && (!aura->GetSpellInfo()->HasAttribute(SPELL_ATTR0_NO_IMMUNITIES)) Xinef: condition, ALL buffs should be removed
626 player->RemoveAura(iter);
627 else
628 ++iter;
629 }
630
631 player->UpdateObjectVisibility(true);
632 }
633
634 for (SpectatorList::const_iterator itr = m_Spectators.begin(); itr != m_Spectators.end(); ++itr)
636
638
639 // pussywizard: arena spectator stuff
641 {
642 for (ToBeTeleportedMap::const_iterator itr = m_ToBeTeleported.begin(); itr != m_ToBeTeleported.end(); ++itr)
643 if (Player* p = ObjectAccessor::FindConnectedPlayer(itr->first))
644 if (Player* t = ObjectAccessor::FindPlayer(itr->second))
645 {
646 if (!t->FindMap() || t->FindMap() != GetBgMap())
647 continue;
648
649 p->SetSummonPoint(t->GetMapId(), t->GetPositionX(), t->GetPositionY(), t->GetPositionZ(), 15, true);
650
651 WorldPacket data(SMSG_SUMMON_REQUEST, 8 + 4 + 4);
652 data << t->GetGUID();
653 data << uint32(t->GetZoneId());
654 data << uint32(15 * IN_MILLISECONDS);
655 p->SendDirectMessage(&data);
656 }
657 m_ToBeTeleported.clear();
658 }
659
660 sScriptMgr->OnArenaStart(this);
661 }
662 else
663 {
665
666 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
667 {
668 itr->second->RemoveAurasDueToSpell(SPELL_PREPARATION);
669 itr->second->ResetAllPowers();
670 }
671
672 // Announce BG starting
675
676 sScriptMgr->OnBattlegroundStart(this);
677 }
678 }
679}
@ BG_BE_OBJECT_READY_MARKER_1
Definition BattlegroundBE.h:31
@ BG_BE_OBJECT_READY_MARKER_2
Definition BattlegroundBE.h:32
@ BG_DS_OBJECT_READY_MARKER_1
Definition BattlegroundDS.h:33
@ BG_DS_OBJECT_READY_MARKER_2
Definition BattlegroundDS.h:34
@ BG_NA_OBJECT_READY_MARKER_1
Definition BattlegroundNA.h:31
@ BG_NA_OBJECT_READY_MARKER_2
Definition BattlegroundNA.h:32
@ BG_RL_OBJECT_READY_MARKER_2
Definition BattlegroundRL.h:30
@ BG_RL_OBJECT_READY_MARKER_1
Definition BattlegroundRL.h:29
@ BG_RV_OBJECT_READY_MARKER_2
Definition BattlegroundRV.h:46
@ BG_RV_OBJECT_READY_MARKER_1
Definition BattlegroundRV.h:45
@ BG_STARTING_EVENT_3
Definition Battleground.h:224
@ BG_STARTING_EVENT_2
Definition Battleground.h:223
@ BG_STARTING_EVENT_1
Definition Battleground.h:222
@ BG_STARTING_EVENT_4
Definition Battleground.h:225
@ SPELL_ARENA_PREPARATION
Definition Battleground.h:132
@ SPELL_PREPARATION
Definition Battleground.h:133
@ STATUS_IN_PROGRESS
Definition Battleground.h:193
@ SOUND_BG_START
Definition Battleground.h:78
constexpr auto IN_MILLISECONDS
Definition Common.h:53
@ LANG_BG_STARTED_ANNOUNCE_WORLD
Definition Language.h:694
#define LOG_ERROR(filterType__,...)
Definition Log.h:158
@ CHAT_MSG_BG_SYSTEM_NEUTRAL
Definition SharedDefines.h:3438
@ BATTLEGROUND_BE
Definition SharedDefines.h:3751
@ BATTLEGROUND_RV
Definition SharedDefines.h:3757
@ BATTLEGROUND_NA
Definition SharedDefines.h:3750
@ BATTLEGROUND_DS
Definition SharedDefines.h:3756
@ BATTLEGROUND_SA
Definition SharedDefines.h:3755
@ BATTLEGROUND_RL
Definition SharedDefines.h:3754
@ SPELL_AURA_MOD_INVISIBILITY
Definition SpellAuraDefines.h:81
@ CONFIG_ARENA_PREP_TIME
Definition WorldConfig.h:281
@ CONFIG_BATTLEGROUND_PREP_TIME
Definition WorldConfig.h:260
@ CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE
Definition WorldConfig.h:71
Definition SpellAuras.h:37
bool IsPositive() const
Definition SpellAuras.h:68
Aura * GetBase() const
Definition SpellAuras.h:62
Definition SpellAuras.h:87
int32 GetDuration() const
Definition SpellAuras.h:133
bool HasEffectType(AuraType type) const
Definition SpellAuras.cpp:1222
bool IsPermanent() const
Definition SpellAuras.h:139
Definition Map.h:680
void EndNow()
Definition Battleground.cpp:1702
uint32 GetMinLevel() const
Definition Battleground.h:329
virtual bool SetupBattleground()
Definition Battleground.h:301
uint8 GetArenaType() const
Definition Battleground.h:348
SpectatorList m_Spectators
Definition Battleground.h:716
void SetStartDelayTime(int32 Time)
Definition Battleground.h:378
BattlegroundMap * GetBgMap() const
Definition Battleground.h:440
BattlegroundMap * FindBgMap() const
Definition Battleground.h:441
void SetStatus(BattlegroundStatus Status)
Definition Battleground.h:364
virtual void StartingEventCloseDoors()
Definition Battleground.h:307
bool isArena() const
Definition Battleground.h:404
void SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject const *target=nullptr)
Definition Battleground.cpp:731
ToBeTeleportedMap m_ToBeTeleported
Definition Battleground.h:717
uint32 GetStartTime() const
Definition Battleground.h:325
int32 GetStartDelayTime() const
Definition Battleground.h:347
virtual void StartingEventOpenDoors()
Definition Battleground.h:308
BattlegroundStatus GetStatus() const
Definition Battleground.h:323
void ModifyStartDelayTime(int32 diff)
Definition Battleground.h:377
virtual void CheckWinConditions()
Definition Battleground.h:498
uint32 GetMaxLevel() const
Definition Battleground.h:330
void PlaySoundToAll(uint32 soundId)
Definition Battleground.cpp:744
Definition Chat.h:37
void SendWorldText(std::string_view str)
Definition Chat.cpp:131
Definition Player.h:1071
std::multimap< uint32, AuraApplication * > AuraApplicationMap
Definition Unit.h:659
Definition WorldPacket.h:26
static float GetMaxVisibleDistanceInBGArenas()
Definition World.h:215
@ SMSG_SUMMON_REQUEST
Definition Opcodes.h:713
#define sWorld
Definition World.h:316
AC_GAME_API void HandleResetCommand(Player *player)
Definition ArenaSpectator.cpp:227
Player * FindConnectedPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:257
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245

References BATTLEGROUND_BE, BATTLEGROUND_DS, BATTLEGROUND_NA, BATTLEGROUND_RL, BATTLEGROUND_RV, BATTLEGROUND_SA, BG_BE_OBJECT_READY_MARKER_1, BG_BE_OBJECT_READY_MARKER_2, BG_DS_OBJECT_READY_MARKER_1, BG_DS_OBJECT_READY_MARKER_2, BG_NA_OBJECT_READY_MARKER_1, BG_NA_OBJECT_READY_MARKER_2, BG_RL_OBJECT_READY_MARKER_1, BG_RL_OBJECT_READY_MARKER_2, BG_RV_OBJECT_READY_MARKER_1, BG_RV_OBJECT_READY_MARKER_2, BG_STARTING_EVENT_1, BG_STARTING_EVENT_2, BG_STARTING_EVENT_3, BG_STARTING_EVENT_4, BG_STARTING_EVENT_FIRST, BG_STARTING_EVENT_FOURTH, BG_STARTING_EVENT_SECOND, BG_STARTING_EVENT_THIRD, CHAT_MSG_BG_SYSTEM_NEUTRAL, CheckWinConditions(), CONFIG_ARENA_PREP_TIME, CONFIG_BATTLEGROUND_PREP_TIME, CONFIG_BATTLEGROUND_QUEUE_ANNOUNCER_ENABLE, DelObject(), EndNow(), FindBgMap(), ObjectAccessor::FindConnectedPlayer(), ObjectAccessor::FindPlayer(), GetArenaType(), AuraApplication::GetBase(), GetBgMap(), GetBgTypeID(), Aura::GetDuration(), GetMaxLevel(), World::GetMaxVisibleDistanceInBGArenas(), GetMinLevel(), GetName(), GetPlayers(), GetStartDelayTime(), GetStartTime(), GetStatus(), ArenaSpectator::HandleResetCommand(), Aura::HasEffectType(), IN_MILLISECONDS, isArena(), Aura::IsPermanent(), AuraApplication::IsPositive(), LANG_BG_STARTED_ANNOUNCE_WORLD, LOG_ERROR, m_Events, m_InstanceID, m_MapId, m_ResetStatTimer, m_SetupCompleted, m_Spectators, m_ToBeTeleported, ModifyStartDelayTime(), PlaySoundToAll(), sBattlegroundMgr, SendBroadcastText(), ChatHandler::SendWorldText(), SetStartDelayTime(), SetStatus(), SetupBattleground(), SMSG_SUMMON_REQUEST, SOUND_BG_START, SPELL_ARENA_PREPARATION, SPELL_AURA_MOD_INVISIBILITY, SPELL_PREPARATION, sScriptMgr, StartDelayTimes, StartingEventCloseDoors(), StartingEventOpenDoors(), StartMessageIds, STATUS_IN_PROGRESS, and sWorld.

Referenced by Update().

◆ _ProcessLeave()

void Battleground::_ProcessLeave ( uint32  diff)
inlineprotected
682{
683 // *********************************************************
684 // *** BATTLEGROUND ENDING SYSTEM ***
685 // *********************************************************
686 // remove all players from battleground after 2 minutes
687 m_EndTime -= diff;
688 if (m_EndTime <= 0)
689 {
690 m_EndTime = TIME_TO_AUTOREMOVE; // pussywizard: 0 -> TIME_TO_AUTOREMOVE
691 BattlegroundPlayerMap::iterator itr, next;
692 for (itr = m_Players.begin(); itr != m_Players.end(); itr = next)
693 {
694 next = itr;
695 ++next;
696 itr->second->LeaveBattleground(this); //itr is erased here!
697 }
698 }
699}
@ TIME_TO_AUTOREMOVE
Definition Battleground.h:157
BattlegroundPlayerMap m_Players
Definition Battleground.h:626

References m_EndTime, m_Players, and TIME_TO_AUTOREMOVE.

Referenced by Update().

◆ _ProcessProgress()

void Battleground::_ProcessProgress ( uint32  diff)
inlineprotected
425{
426 // *********************************************************
427 // *** BATTLEGROUND BALLANCE SYSTEM ***
428 // *********************************************************
429 // if less then minimum players are in on one side, then start premature finish timer
431 {
433 m_PrematureCountDownTimer = sBattlegroundMgr->GetPrematureFinishTime();
434 }
435 else if (m_PrematureCountDownTimer < diff)
436 {
437 // time's up!
439 m_PrematureCountDown = false;
440 }
441 else if (!sBattlegroundMgr->isTesting())
442 {
443 uint32 newtime = m_PrematureCountDownTimer - diff;
444 // announce every minute
445 if (newtime > (MINUTE * IN_MILLISECONDS))
446 {
448 GetBgMap()->DoForAllPlayers([&](Player* player)
449 {
451 });
452 }
453 else
454 {
455 //announce every 15 seconds
456 if (newtime / (15 * IN_MILLISECONDS) != m_PrematureCountDownTimer / (15 * IN_MILLISECONDS))
457 GetBgMap()->DoForAllPlayers([&](Player* player)
458 {
460 });
461 }
463 }
464}
constexpr auto MINUTE
Definition Common.h:47
@ LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING
Definition Language.h:727
@ LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS
Definition Language.h:728
void EndBattleground(PvPTeamId winnerTeamId)
Definition Battleground.cpp:831
virtual TeamId GetPrematureWinner()
Definition Battleground.cpp:414
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition Chat.cpp:211
void DoForAllPlayers(std::function< void(Player *)> exec)
Definition Map.cpp:2918
WorldSession * GetSession() const
Definition Player.h:1998

References Map::DoForAllPlayers(), EndBattleground(), GetBgMap(), GetPrematureWinner(), Player::GetSession(), IN_MILLISECONDS, LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING, LANG_BATTLEGROUND_PREMATURE_FINISH_WARNING_SECS, m_PrematureCountDown, m_PrematureCountDownTimer, MINUTE, ChatHandler::PSendSysMessage(), and sBattlegroundMgr.

Referenced by Update().

◆ _ProcessResurrect()

void Battleground::_ProcessResurrect ( uint32  diff)
inlineprotected
352{
353 // *********************************************************
354 // *** BATTLEGROUND RESURRECTION SYSTEM ***
355 // *********************************************************
356 // this should be handled by spell system
357
358 _reviveEvents.Update(diff);
359
360 m_LastResurrectTime += diff;
362 {
363 if (GetReviveQueueSize())
364 {
365 for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
366 {
367 Creature* sh = nullptr;
368 for (ObjectGuid const& guid : itr->second)
369 {
370 Player* player = ObjectAccessor::FindPlayer(guid);
371 if (!player)
372 continue;
373
374 if (!sh && player->IsInWorld())
375 {
376 sh = player->GetMap()->GetCreature(itr->first);
377 // only for visual effect
378 if (sh)
379 // Spirit Heal, effect 117
380 sh->CastSpell(sh, SPELL_SPIRIT_HEAL, true);
381 }
382
383 // Resurrection visual
384 player->CastSpell(player, SPELL_RESURRECTION_VISUAL, true);
385 m_ResurrectQueue.push_back(guid);
386 }
387
388 itr->second.clear();
389 }
390
391 m_ReviveQueue.clear();
393 }
394 else
395 // queue is clear and time passed, just update last resurrection time
397 }
398 else if (m_LastResurrectTime > 500) // Resurrect players only half a second later, to see spirit heal effect on NPC
399 {
400 for (ObjectGuid const& guid : m_ResurrectQueue)
401 {
402 Player* player = ObjectAccessor::FindPlayer(guid);
403 if (!player)
404 continue;
405 player->ResurrectPlayer(1.0f);
406 player->CastSpell(player, 6962, true);
407 player->CastSpell(player, SPELL_SPIRIT_HEAL_MANA, true);
408 player->SpawnCorpseBones(false);
409 }
410 m_ResurrectQueue.clear();
411 }
412}
@ SPELL_SPIRIT_HEAL
Definition Battleground.h:130
@ SPELL_SPIRIT_HEAL_MANA
Definition Battleground.h:134
@ SPELL_RESURRECTION_VISUAL
Definition Battleground.h:131
#define RESURRECTION_INTERVAL
Definition Battleground.h:163
GuidVector m_ResurrectQueue
Definition Battleground.h:705
uint32 GetReviveQueueSize() const
Definition Battleground.h:421
std::map< ObjectGuid, GuidVector > m_ReviveQueue
Definition Battleground.h:628
Definition Creature.h:47
void Update(uint32 p_time)
Definition EventProcessor.cpp:40
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:2364
Definition ObjectGuid.h:118
bool IsInWorld() const
Definition Object.h:108
void SpawnCorpseBones(bool triggerSave=true)
Definition Player.cpp:4706
void ResurrectPlayer(float restore_percent, bool applySickness=false)
Definition Player.cpp:4487
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:1194
Map * GetMap() const
Definition Object.h:621

References _reviveEvents, Unit::CastSpell(), ObjectAccessor::FindPlayer(), Map::GetCreature(), WorldObject::GetMap(), GetReviveQueueSize(), Object::IsInWorld(), m_LastResurrectTime, m_ResurrectQueue, m_ReviveQueue, RESURRECTION_INTERVAL, Player::ResurrectPlayer(), Player::SpawnCorpseBones(), SPELL_RESURRECTION_VISUAL, SPELL_SPIRIT_HEAL, SPELL_SPIRIT_HEAL_MANA, and EventProcessor::Update().

Referenced by Update().

◆ AddCreature()

Creature * Battleground::AddCreature ( uint32  entry,
uint32  type,
float  x,
float  y,
float  z,
float  o,
uint32  respawntime = 0,
MotionTransport transport = nullptr 
)
1577{
1578 // If the assert is called, means that BgCreatures must be resized!
1579 ASSERT(type < BgCreatures.size());
1580
1581 Map* map = FindBgMap();
1582 if (!map)
1583 return nullptr;
1584
1585 if (transport)
1586 {
1587 transport->CalculatePassengerPosition(x, y, z, &o);
1588 if (Creature* creature = transport->SummonCreature(entry, x, y, z, o, TEMPSUMMON_MANUAL_DESPAWN))
1589 {
1590 transport->AddPassenger(creature, true);
1591 BgCreatures[type] = creature->GetGUID();
1592 return creature;
1593 }
1594
1595 return nullptr;
1596 }
1597
1598 Creature* creature = new Creature();
1599 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o))
1600 {
1601 LOG_ERROR("bg.battleground", "Battleground::AddCreature: cannot create creature (entry: {}) for BG (map: {}, instance id: {})!",
1602 entry, m_MapId, m_InstanceID);
1603 delete creature;
1604 return nullptr;
1605 }
1606
1607 creature->SetHomePosition(x, y, z, o);
1608
1609 CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
1610 if (!cinfo)
1611 {
1612 LOG_ERROR("bg.battleground", "Battleground::AddCreature: creature template (entry: {}) does not exist for BG (map: {}, instance id: {})!",
1613 entry, m_MapId, m_InstanceID);
1614 delete creature;
1615 return nullptr;
1616 }
1617 // Force using DB speeds
1618 creature->SetSpeed(MOVE_WALK, cinfo->speed_walk);
1619 creature->SetSpeed(MOVE_RUN, cinfo->speed_run);
1620
1621 if (!map->AddToMap(creature))
1622 {
1623 delete creature;
1624 return nullptr;
1625 }
1626
1627 BgCreatures[type] = creature->GetGUID();
1628
1629 if (respawntime)
1630 creature->SetRespawnDelay(respawntime);
1631
1632 // Xinef: Set PVP state for vehicles, should be for all creatures in bg?
1633 if (creature->IsVehicle())
1634 creature->SetPvP(true);
1635
1636 return creature;
1637}
#define ASSERT
Definition Errors.h:68
#define sObjectMgr
Definition ObjectMgr.h:1650
@ PHASEMASK_NORMAL
Definition Object.h:62
@ TEMPSUMMON_MANUAL_DESPAWN
Definition Object.h:55
@ MOVE_RUN
Definition UnitDefines.h:354
@ MOVE_WALK
Definition UnitDefines.h:353
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:339
void SetRespawnDelay(uint32 delay)
Definition Creature.h:295
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 vehId, float x, float y, float z, float ang, const CreatureData *data=nullptr)
Definition Creature.cpp:1138
Definition Map.h:163
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:480
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:301
void AddPassenger(WorldObject *passenger, bool withAll=false) override
Definition Transport.cpp:264
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:113
void CalculatePassengerPosition(float &x, float &y, float &z, float *o=nullptr) const override
This method transforms supplied transport offsets into global coordinates.
Definition Transport.h:33
bool IsVehicle() const
Definition Unit.h:783
void SetPvP(bool state)
Definition Unit.h:1024
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition Unit.cpp:14517
TempSummon * SummonCreature(uint32 id, const Position &pos, TempSummonType spwtype=TEMPSUMMON_MANUAL_DESPAWN, uint32 despwtime=0, uint32 vehId=0, SummonPropertiesEntry const *properties=nullptr, bool visibleBySummonerOnly=false) const
Definition Object.cpp:2359
Definition CreatureData.h:186
float speed_run
Definition CreatureData.h:201
float speed_walk
Definition CreatureData.h:200

References MotionTransport::AddPassenger(), Map::AddToMap(), ASSERT, BgCreatures, Transport::CalculatePassengerPosition(), Creature::Create(), FindBgMap(), Map::GenerateLowGuid(), Object::GetGUID(), Unit::IsVehicle(), LOG_ERROR, m_InstanceID, m_MapId, MOVE_RUN, MOVE_WALK, PHASEMASK_NORMAL, Creature::SetHomePosition(), Unit::SetPvP(), Creature::SetRespawnDelay(), Unit::SetSpeed(), sObjectMgr, CreatureTemplate::speed_run, CreatureTemplate::speed_walk, WorldObject::SummonCreature(), TEMPSUMMON_MANUAL_DESPAWN, and Unit.

Referenced by BattlegroundAV::AddAVCreature(), AddSpiritGuide(), BattlegroundSA::CaptureGraveyard(), BattlegroundEY::EventTeamCapturedPoint(), BattlegroundIC::HandleCapturedNodes(), BattlegroundAB::NodeOccupied(), BattlegroundAV::PopulateNode(), BattlegroundSA::ResetObjs(), BattlegroundDS::SetupBattleground(), and BattlegroundIC::SetupBattleground().

◆ AddObject()

bool Battleground::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 
)
1455{
1456 // If the assert is called, means that BgObjects must be resized!
1457 ASSERT(type < BgObjects.size());
1458
1459 Map* map = FindBgMap();
1460 if (!map)
1461 return false;
1462 // Must be created this way, adding to godatamap would add it to the base map of the instance
1463 // and when loading it (in go::LoadFromDB()), a new guid would be assigned to the object, and a new object would be created
1464 // So we must create it specific for this instance
1465 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
1466 if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, GetBgMap(),
1467 PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(rotation0, rotation1, rotation2, rotation3), 100, goState))
1468 {
1469 LOG_ERROR("sql.sql", "Battleground::AddObject: cannot create gameobject (entry: {}) for BG (map: {}, instance id: {})!",
1470 entry, m_MapId, m_InstanceID);
1471 LOG_ERROR("bg.battleground", "Battleground::AddObject: cannot create gameobject (entry: {}) for BG (map: {}, instance id: {})!",
1472 entry, m_MapId, m_InstanceID);
1473 delete go;
1474 return false;
1475 }
1476 /*
1477 ObjectGuid::LowType spawnId = go->GetSpawnId();
1478
1479 // without this, UseButtonOrDoor caused the crash, since it tried to get go info from godata
1480 // iirc that was changed, so adding to go data map is no longer required if that was the only function using godata from GameObject without checking if it existed
1481 GameObjectData& data = sObjectMgr->NewGOData(spawnId);
1482
1483 data.id = entry;
1484 data.mapid = GetMapId();
1485 data.posX = x;
1486 data.posY = y;
1487 data.posZ = z;
1488 data.orientation = o;
1489 data.rotation0 = rotation0;
1490 data.rotation1 = rotation1;
1491 data.rotation2 = rotation2;
1492 data.rotation3 = rotation3;
1493 data.spawntimesecs = respawnTime;
1494 data.spawnMask = 1;
1495 data.animprogress = 100;
1496 data.go_state = 1;
1497 */
1498 // Add to world, so it can be later looked up from HashMapHolder
1499 if (!map->AddToMap(go))
1500 {
1501 delete go;
1502 return false;
1503 }
1504 BgObjects[type] = go->GetGUID();
1505 return true;
1506}
Definition GameObject.h:120
virtual bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, G3D::Quat const &rotation, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition GameObject.cpp:254
Definition Transport.h:115

References Map::AddToMap(), ASSERT, BgObjects, GameObject::Create(), FindBgMap(), GameObject, Map::GenerateLowGuid(), GetBgMap(), Object::GetGUID(), LOG_ERROR, m_InstanceID, m_MapId, PHASEMASK_NORMAL, and sObjectMgr.

Referenced by BattlegroundSA::CaptureGraveyard(), BattlegroundIC::EventPlayerClickedOnFlag(), BattlegroundIC::HandleCapturedNodes(), BattlegroundIC::PostUpdateImpl(), BattlegroundSA::ResetObjs(), BattlegroundAB::SetupBattleground(), BattlegroundAV::SetupBattleground(), BattlegroundBE::SetupBattleground(), BattlegroundDS::SetupBattleground(), BattlegroundEY::SetupBattleground(), BattlegroundIC::SetupBattleground(), BattlegroundNA::SetupBattleground(), BattlegroundRL::SetupBattleground(), BattlegroundRV::SetupBattleground(), and BattlegroundWS::SetupBattleground().

◆ AddOrSetPlayerToCorrectBgGroup()

void Battleground::AddOrSetPlayerToCorrectBgGroup ( Player player,
TeamId  teamId 
)
1225{
1226 if (player->GetGroup() && (player->GetGroup()->isBGGroup() || player->GetGroup()->isBFGroup()))
1227 {
1228 LOG_INFO("misc", "Battleground::AddOrSetPlayerToCorrectBgGroup - player is already in {} group!", (player->GetGroup()->isBGGroup() ? "BG" : "BF"));
1229 return;
1230 }
1231
1232 ObjectGuid playerGuid = player->GetGUID();
1233 Group* group = GetBgRaid(teamId);
1234 if (!group) // first player joined
1235 {
1236 group = new Group;
1237 SetBgRaid(teamId, group);
1238 group->Create(player);
1239 sGroupMgr->AddGroup(group);
1240 }
1241 else if (group->IsMember(playerGuid))
1242 {
1243 uint8 subgroup = group->GetMemberGroup(playerGuid);
1244 player->SetBattlegroundOrBattlefieldRaid(group, subgroup);
1245 }
1246 else
1247 {
1248 group->AddMember(player);
1249
1250 if (Group* originalGroup = player->GetOriginalGroup())
1251 if (originalGroup->IsLeader(playerGuid))
1252 {
1253 group->ChangeLeader(playerGuid);
1254 group->SendUpdate();
1255 }
1256 }
1257}
std::uint8_t uint8
Definition Define.h:109
#define sGroupMgr
Definition GroupMgr.h:51
#define LOG_INFO(filterType__,...)
Definition Log.h:166
Group * GetBgRaid(TeamId teamId) const
Definition Battleground.h:482
void SetBgRaid(TeamId teamId, Group *bg_raid)
Definition Battleground.cpp:1849
Definition Group.h:169
uint8 GetMemberGroup(ObjectGuid guid) const
Definition Group.cpp:2394
bool AddMember(Player *player)
Definition Group.cpp:390
void SendUpdate()
Definition Group.cpp:1665
bool isBGGroup() const
Definition Group.cpp:2286
void ChangeLeader(ObjectGuid guid)
Definition Group.cpp:712
bool isBFGroup() const
Definition Group.cpp:2291
bool IsMember(ObjectGuid guid) const
Definition Group.cpp:2346
bool Create(Player *leader)
Definition Group.cpp:108
Group * GetGroup()
Definition Player.h:2472
Group * GetOriginalGroup()
Definition Player.h:2487
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition Player.cpp:13131

References Group::AddMember(), Group::ChangeLeader(), Group::Create(), GetBgRaid(), Player::GetGroup(), Object::GetGUID(), Group::GetMemberGroup(), Player::GetOriginalGroup(), Group::isBFGroup(), Group::isBGGroup(), Group::IsMember(), LOG_INFO, Group::SendUpdate(), Player::SetBattlegroundOrBattlefieldRaid(), SetBgRaid(), and sGroupMgr.

Referenced by AddPlayer().

◆ AddPlayer()

void Battleground::AddPlayer ( Player player)
virtual

Reimplemented in Arena, BattlegroundAB, BattlegroundAV, BattlegroundEY, BattlegroundIC, BattlegroundSA, and BattlegroundWS.

1160{
1161 // remove afk from player
1162 if (player->HasPlayerFlag(PLAYER_FLAGS_AFK))
1163 player->ToggleAFK();
1164
1165 sScriptMgr->OnBattlegroundBeforeAddPlayer(this, player);
1166
1167 // score struct must be created in inherited class
1168
1169 ObjectGuid guid = player->GetGUID();
1170 TeamId teamId = player->GetBgTeamId();
1171
1172 // Add to list/maps
1173 m_Players[guid] = player;
1174
1175 UpdatePlayersCountByTeam(teamId, false); // +1 player
1176
1177 WorldPacket data;
1178 sBattlegroundMgr->BuildPlayerJoinedBattlegroundPacket(&data, player);
1179 SendPacketToTeam(teamId, &data, player, false);
1180
1181 // add arena specific auras
1182 if (isArena())
1183 {
1184 // restore pets health before remove
1185 Pet* pet = player->GetPet();
1186 if (pet)
1187 if (pet->IsAlive())
1188 pet->SetHealth(pet->GetMaxHealth());
1189
1190 player->RemoveArenaAuras();
1191 if (pet)
1192 pet->RemoveArenaAuras();
1193 player->RemoveArenaSpellCooldowns(true);
1195 player->DestroyConjuredItems(true);
1196 player->UnsummonPetTemporaryIfAny();
1197
1198 if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
1199 {
1200 player->CastSpell(player, SPELL_ARENA_PREPARATION, true);
1201 player->ResetAllPowers();
1202 }
1203 }
1204 else
1205 {
1206 if (GetStatus() == STATUS_WAIT_JOIN) // not started yet
1207 player->CastSpell(player, SPELL_PREPARATION, true); // reduces all mana cost of spells.
1208 }
1209
1210 // Xinef: reset all map criterias on map enter
1212
1213 // setup BG group membership
1215 AddOrSetPlayerToCorrectBgGroup(player, teamId);
1216
1217 sScriptMgr->OnBattlegroundAddPlayer(this, player);
1218
1219 // Log
1220 LOG_DEBUG("bg.battleground", "BATTLEGROUND: Player {} joined the battle.", player->GetName());
1221}
@ STATUS_WAIT_JOIN
Definition Battleground.h:192
@ ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP
Definition DBCEnums.h:90
@ TEMP_ENCHANTMENT_SLOT
Definition Item.h:170
@ PLAYER_FLAGS_AFK
Definition Player.h:469
TeamId
Definition SharedDefines.h:770
void PlayerAddedToBGCheckIfBGIsRunning(Player *player)
Definition Battleground.cpp:1807
void SendPacketToTeam(TeamId teamId, WorldPacket const *packet, Player *sender=nullptr, bool self=true)
Definition Battleground.cpp:719
void UpdatePlayersCountByTeam(TeamId teamId, bool remove)
Definition Battleground.h:490
void AddOrSetPlayerToCorrectBgGroup(Player *player, TeamId teamId)
Definition Battleground.cpp:1224
Definition Pet.h:41
Pet * GetPet() const
Definition Player.cpp:8977
void DestroyConjuredItems(bool update)
Definition PlayerStorage.cpp:3336
void UnsummonPetTemporaryIfAny()
Definition Player.cpp:14267
void ResetAchievementCriteria(AchievementCriteriaCondition condition, uint32 value, bool evenIfCriteriaComplete=false)
Definition Player.cpp:13983
void ToggleAFK()
Definition Player.cpp:1308
void ResetAllPowers()
Definition Player.cpp:2035
bool HasPlayerFlag(PlayerFlags flags) const
Definition Player.h:1110
void RemoveArenaEnchantments(EnchantmentSlot slot)
Definition PlayerStorage.cpp:4219
TeamId GetBgTeamId() const
Definition Player.h:2282
void RemoveArenaSpellCooldowns(bool removeActivePetCooldowns=false)
Definition Player.cpp:3551
uint32 GetMaxHealth() const
Definition Unit.h:1071
bool IsAlive() const
Definition Unit.h:1748
void SetHealth(uint32 val)
Definition Unit.cpp:15507
void RemoveArenaAuras()
Definition Unit.cpp:5403
std::string const & GetName() const
Definition Object.h:525

References ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, AddOrSetPlayerToCorrectBgGroup(), Unit::CastSpell(), Player::DestroyConjuredItems(), Player::GetBgTeamId(), Object::GetGUID(), GetMapId(), Unit::GetMaxHealth(), WorldObject::GetName(), Player::GetPet(), GetStatus(), Player::HasPlayerFlag(), Unit::IsAlive(), isArena(), LOG_DEBUG, m_Players, PLAYER_FLAGS_AFK, PlayerAddedToBGCheckIfBGIsRunning(), Unit::RemoveArenaAuras(), Player::RemoveArenaEnchantments(), Player::RemoveArenaSpellCooldowns(), Player::ResetAchievementCriteria(), Player::ResetAllPowers(), sBattlegroundMgr, SendPacketToTeam(), Unit::SetHealth(), SPELL_ARENA_PREPARATION, SPELL_PREPARATION, sScriptMgr, STATUS_WAIT_JOIN, TEMP_ENCHANTMENT_SLOT, Player::ToggleAFK(), Player::UnsummonPetTemporaryIfAny(), and UpdatePlayersCountByTeam().

Referenced by Arena::AddPlayer(), BattlegroundAB::AddPlayer(), BattlegroundAV::AddPlayer(), BattlegroundEY::AddPlayer(), BattlegroundIC::AddPlayer(), BattlegroundSA::AddPlayer(), and BattlegroundWS::AddPlayer().

◆ AddPlayerToResurrectQueue()

void Battleground::AddPlayerToResurrectQueue ( ObjectGuid  npc_guid,
ObjectGuid  player_guid 
)
1408{
1409 m_ReviveQueue[npc_guid].push_back(player_guid);
1410
1411 Player* player = ObjectAccessor::FindPlayer(player_guid);
1412 if (!player)
1413 return;
1414
1415 player->CastSpell(player, SPELL_WAITING_FOR_RESURRECT, true);
1416}
@ SPELL_WAITING_FOR_RESURRECT
Definition Battleground.h:128

References Unit::CastSpell(), ObjectAccessor::FindPlayer(), m_ReviveQueue, and SPELL_WAITING_FOR_RESURRECT.

Referenced by WorldSession::HandleAreaSpiritHealerQueueOpcode(), and WorldSession::HandleGossipHelloOpcode().

◆ AddSpectator()

void Battleground::AddSpectator ( Player p)
inline
396{ m_Spectators.insert(p); }

References m_Spectators.

◆ AddSpiritGuide()

bool Battleground::AddSpiritGuide ( uint32  type,
float  x,
float  y,
float  z,
float  o,
TeamId  teamId 
)
Todo:
: Fix display here
1679{
1681
1682 if (Creature* creature = AddCreature(entry, type, x, y, z, o))
1683 {
1684 creature->setDeathState(DeathState::Dead);
1685 creature->SetGuidValue(UNIT_FIELD_CHANNEL_OBJECT, creature->GetGUID());
1686 // aura
1688 // creature->SetVisibleAura(0, SPELL_SPIRIT_HEAL_CHANNEL);
1689 // casting visual effect
1690 creature->SetUInt32Value(UNIT_CHANNEL_SPELL, SPELL_SPIRIT_HEAL_CHANNEL);
1691 // correct cast speed
1692 creature->SetFloatValue(UNIT_MOD_CAST_SPEED, 1.0f);
1693 //creature->CastSpell(creature, SPELL_SPIRIT_HEAL_CHANNEL, true);
1694 return true;
1695 }
1696 LOG_ERROR("bg.battleground", "Battleground::AddSpiritGuide: cannot create spirit guide (type: {}, entry: {}) for BG (map: {}, instance id: {})!",
1697 type, entry, m_MapId, m_InstanceID);
1698 EndNow();
1699 return false;
1700}
@ BG_CREATURE_ENTRY_H_SPIRITGUIDE
Definition Battleground.h:123
@ BG_CREATURE_ENTRY_A_SPIRITGUIDE
Definition Battleground.h:122
@ SPELL_SPIRIT_HEAL_CHANNEL
Definition Battleground.h:129
@ UNIT_FIELD_CHANNEL_OBJECT
Definition UpdateFields.h:93
@ UNIT_MOD_CAST_SPEED
Definition UpdateFields.h:137
@ UNIT_CHANNEL_SPELL
Definition UpdateFields.h:94
Creature * AddCreature(uint32 entry, uint32 type, float x, float y, float z, float o, uint32 respawntime=0, MotionTransport *transport=nullptr)
Definition Battleground.cpp:1576

References AddCreature(), BG_CREATURE_ENTRY_A_SPIRITGUIDE, BG_CREATURE_ENTRY_H_SPIRITGUIDE, Dead, EndNow(), LOG_ERROR, m_InstanceID, m_MapId, SPELL_SPIRIT_HEAL_CHANNEL, TEAM_ALLIANCE, UNIT_CHANNEL_SPELL, UNIT_FIELD_CHANNEL_OBJECT, and UNIT_MOD_CAST_SPEED.

Referenced by BattlegroundSA::CaptureGraveyard(), BattlegroundEY::EventTeamCapturedPoint(), BattlegroundIC::HandleCapturedNodes(), BattlegroundAB::NodeOccupied(), BattlegroundAV::PopulateNode(), BattlegroundSA::ResetObjs(), BattlegroundAB::SetupBattleground(), BattlegroundAV::SetupBattleground(), BattlegroundEY::SetupBattleground(), BattlegroundIC::SetupBattleground(), and BattlegroundWS::SetupBattleground().

◆ AddToBeTeleported()

void Battleground::AddToBeTeleported ( ObjectGuid  spectator,
ObjectGuid  participant 
)
inline
400{ m_ToBeTeleported[spectator] = participant; }

References m_ToBeTeleported.

Referenced by ArenaSpectator::HandleSpectatorSpectateCommand().

◆ AddToBGFreeSlotQueue()

void Battleground::AddToBGFreeSlotQueue ( )
1261{
1263 {
1264 sBattlegroundMgr->AddToBGFreeSlotQueue(m_RealTypeID, this);
1265 _InBGFreeSlotQueue = true;
1266 }
1267}
bool _InBGFreeSlotQueue
Definition Battleground.h:663
bool isBattleground() const
Definition Battleground.h:405

References _InBGFreeSlotQueue, isBattleground(), m_RealTypeID, and sBattlegroundMgr.

Referenced by RemovePlayerAtLeave(), and StartBattleground().

◆ AllNodesConrolledByTeam()

virtual bool Battleground::AllNodesConrolledByTeam ( TeamId  ) const
inlinevirtual

Reimplemented in BattlegroundAB, BattlegroundEY, and BattlegroundIC.

314{ return false; }

Referenced by achievement_bg_control_all_nodes::OnCheck().

◆ BlockMovement()

void Battleground::BlockMovement ( Player player)
1011{
1012 player->SetClientControl(player, 0); // movement disabled NOTE: the effect will be automatically removed by client when the player is teleported from the battleground, so no need to send with uint8(1) in RemovePlayerAtLeave()
1013}
void SetClientControl(Unit *target, bool allowMove, bool packetOnly=false)
Definition Player.cpp:12902

References Player::SetClientControl().

Referenced by EndBattleground(), and PlayerAddedToBGCheckIfBGIsRunning().

◆ BroadcastWorker()

template<class Do >
void Battleground::BroadcastWorker ( Do &  _do)
123{
124 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
125 _do(itr->second);
126}

References m_Players.

Referenced by SendBroadcastText().

◆ BuildPvPLogDataPacket()

void Battleground::BuildPvPLogDataPacket ( WorldPacket data)
1364{
1365 uint8 type = (isArena() ? 1 : 0);
1366
1367 data.Initialize(MSG_PVP_LOG_DATA, 1 + 1 + 4 + 40 * GetPlayerScores()->size());
1368 data << uint8(type); // type (battleground = 0 / arena = 1)
1369
1370 if (type) // arena
1371 {
1372 for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
1373 _arenaTeamScores[i].BuildRatingInfoBlock(data);
1374
1375 for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
1376 _arenaTeamScores[i].BuildTeamInfoBlock(data);
1377 }
1378
1380 {
1381 data << uint8(1); // bg ended
1382 data << uint8(GetWinner()); // who win
1383 }
1384 else
1385 data << uint8(0); // bg not ended
1386
1387 data << uint32(GetPlayerScores()->size());
1388
1389 for (auto const& score : PlayerScores)
1390 score.second->AppendToPacket(data);
1391}
@ STATUS_WAIT_LEAVE
Definition Battleground.h:194
uint8 constexpr PVP_TEAMS_COUNT
Definition SharedDefines.h:3711
ArenaTeamScore _arenaTeamScores[PVP_TEAMS_COUNT]
Definition Battleground.h:642
PvPTeamId GetWinner() const
Definition Battleground.h:349
BattlegroundScoreMap const * GetPlayerScores() const
Definition Battleground.h:418
void Initialize(uint16 opcode, std::size_t newres=200)
Definition WorldPacket.h:68
@ MSG_PVP_LOG_DATA
Definition Opcodes.h:766

References _arenaTeamScores, GetPlayerScores(), GetStatus(), GetWinner(), WorldPacket::Initialize(), isArena(), MSG_PVP_LOG_DATA, PlayerScores, PVP_TEAMS_COUNT, and STATUS_WAIT_LEAVE.

Referenced by EndBattleground(), WorldSession::HandlePVPLogDataOpcode(), and PlayerAddedToBGCheckIfBGIsRunning().

◆ CastSpellOnTeam()

void Battleground::CastSpellOnTeam ( uint32  spellId,
TeamId  teamId 
)
750{
751 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
752 if (itr->second->GetBgTeamId() == teamId)
753 itr->second->CastSpell(itr->second, spellId, true);
754}

References m_Players.

Referenced by BattlegroundIC::HandleCapturedNodes(), BattlegroundAV::HandleKillUnit(), BattlegroundAB::NodeOccupied(), and BattlegroundAV::PostUpdateImpl().

◆ CheckWinConditions()

virtual void Battleground::CheckWinConditions ( )
inlinevirtual

Reimplemented in Arena.

498{ }

Referenced by _ProcessJoin().

◆ DecreaseInvitedCount()

void Battleground::DecreaseInvitedCount ( TeamId  teamId)
inline
386{ if (m_BgInvitedPlayers[teamId]) --m_BgInvitedPlayers[teamId]; }

References m_BgInvitedPlayers.

Referenced by RemovePlayerAtLeave().

◆ DelCreature()

bool Battleground::DelCreature ( uint32  type)
1640{
1641 if (!BgCreatures[type])
1642 return true;
1643
1644 if (Creature* creature = GetBgMap()->GetCreature(BgCreatures[type]))
1645 {
1646 creature->AddObjectToRemoveList();
1647 BgCreatures[type].Clear();
1648 return true;
1649 }
1650
1651 LOG_ERROR("bg.battleground", "Battleground::DelCreature: creature (type: {}, {}) not found for BG (map: {}, instance id: {})!",
1652 type, BgCreatures[type].ToString(), m_MapId, m_InstanceID);
1653
1654 BgCreatures[type].Clear();
1655 return false;
1656}
std::string ToString(Type &&val, Params &&... params)
Definition StringConvert.h:250
Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:210

References WorldObject::AddObjectToRemoveList(), BgCreatures, GetBgMap(), LOG_ERROR, m_InstanceID, and m_MapId.

Referenced by BattlegroundSA::CaptureGraveyard(), BattlegroundAV::ChangeMineOwner(), BattlegroundAV::DePopulateNode(), BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundIC::EventPlayerClickedOnFlag(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundEY::EventTeamLostPoint(), BattlegroundIC::HandleContestedNodes(), BattlegroundAV::HandleKillUnit(), BattlegroundAB::NodeDeoccupied(), BattlegroundAV::PopulateNode(), BattlegroundAV::ResetBGSubclass(), BattlegroundSA::ResetObjs(), and ~Battleground().

◆ DelObject()

bool Battleground::DelObject ( uint32  type)
1659{
1660 if (!BgObjects[type])
1661 return true;
1662
1663 if (GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]))
1664 {
1665 obj->SetRespawnTime(0); // not save respawn time
1666 obj->Delete();
1667 BgObjects[type].Clear();
1668 return true;
1669 }
1670
1671 LOG_ERROR("bg.battleground", "Battleground::DelObject: gameobject (type: {}, {}) not found for BG (map: {}, instance id: {})!",
1672 type, BgObjects[type].ToString(), m_MapId, m_InstanceID);
1673
1674 BgObjects[type].Clear();
1675 return false;
1676}
GameObject * GetGameObject(WorldObject const &u, ObjectGuid const &guid)
Definition ObjectAccessor.cpp:184

References BgObjects, GetBgMap(), LOG_ERROR, m_InstanceID, and m_MapId.

Referenced by _ProcessJoin(), BattlegroundSA::CaptureGraveyard(), BattlegroundSA::DestroyGate(), BattlegroundIC::EventPlayerClickedOnFlag(), BattlegroundIC::HandleContestedNodes(), BattlegroundIC::PostUpdateImpl(), BattlegroundSA::ResetObjs(), and ~Battleground().

◆ DestroyGate()

virtual void Battleground::DestroyGate ( Player ,
GameObject  
)
inlinevirtual

Reimplemented in BattlegroundIC, and BattlegroundSA.

311{}

◆ DoAction()

virtual void Battleground::DoAction ( uint32  ,
ObjectGuid   
)
inlinevirtual

Reimplemented in BattlegroundIC.

520{}

◆ DoorClose()

void Battleground::DoorClose ( uint32  type)
1511{
1512 if (GameObject* obj = GetBgMap()->GetGameObject(BgObjects[type]))
1513 {
1514 // If doors are open, close it
1515 if (obj->getLootState() == GO_ACTIVATED && obj->GetGoState() != GO_STATE_READY)
1516 {
1517 obj->SetLootState(GO_READY);
1518 obj->SetGoState(GO_STATE_READY);
1519 }
1520 }
1521 else
1522 LOG_ERROR("bg.battleground", "Battleground::DoorClose: door gameobject (type: {}, {}) not found for BG (map: {}, instance id: {})!",
1523 type, BgObjects[type].ToString(), m_MapId, m_InstanceID);
1524}
@ GO_STATE_READY
Definition GameObjectData.h:692
@ GO_ACTIVATED
Definition GameObject.h:112
@ GO_READY
Definition GameObject.h:111

References BgObjects, GetBgMap(), GO_ACTIVATED, GO_READY, GO_STATE_READY, LOG_ERROR, m_InstanceID, and m_MapId.

Referenced by BattlegroundDS::PostUpdateImpl(), BattlegroundRV::PostUpdateImpl(), BattlegroundAB::StartingEventCloseDoors(), BattlegroundAV::StartingEventCloseDoors(), and BattlegroundWS::StartingEventCloseDoors().

◆ DoorOpen()

◆ EndBattleground() [1/2]

void Battleground::EndBattleground ( PvPTeamId  winnerTeamId)
832{
833 // xinef: if this is true, it means that endbattleground is called second time
834 // skip to avoid double rating reduce / add
835 // can bug out due to multithreading ?
836 // set as fast as possible
838 return;
839
842 SetWinner(winnerTeamId);
843
844 if (winnerTeamId == PVP_TEAM_ALLIANCE)
845 {
846 if (isBattleground())
848
849 PlaySoundToAll(SOUND_ALLIANCE_WINS); // alliance wins sound
850 }
851 else if (winnerTeamId == PVP_TEAM_HORDE)
852 {
853 if (isBattleground())
855
856 PlaySoundToAll(SOUND_HORDE_WINS); // horde wins sound
857 }
858
860 uint64 battlegroundId = 1;
862 {
863 stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_PVPSTATS_MAXID);
864 PreparedQueryResult result = CharacterDatabase.Query(stmt);
865
866 if (result)
867 {
868 Field* fields = result->Fetch();
869 battlegroundId = fields[0].Get<uint64>() + 1;
870 }
871
872 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PVPSTATS_BATTLEGROUND);
873 stmt->SetData(0, battlegroundId);
874 stmt->SetData(1, GetWinner());
875 stmt->SetData(2, GetUniqueBracketId());
876 stmt->SetData(3, GetBgTypeID(true));
877 CharacterDatabase.Execute(stmt);
878 }
879
880 //we must set it this way, because end time is sent in packet!
882
883 WorldPacket pvpLogData;
884 BuildPvPLogDataPacket(pvpLogData);
885
886 for (auto const& [playerGuid, player] : m_Players)
887 {
888 TeamId bgTeamId = player->GetBgTeamId();
889
890 // should remove spirit of redemption
891 if (player->HasSpiritOfRedemptionAura())
892 player->RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
893
894 if (!player->IsAlive())
895 {
896 player->ResurrectPlayer(1.0f);
897 player->SpawnCorpseBones();
898 }
899 else
900 {
901 //needed cause else in av some creatures will kill the players at the end
902 player->CombatStop();
903 player->getHostileRefMgr().deleteReferences();
904 }
905
906 uint32 winner_kills = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_HONOR_FIRST);
907 uint32 loser_kills = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_LOSER_HONOR_FIRST);
908 uint32 winner_arena = player->GetRandomWinner() ? sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_ARENA_LAST) : sWorld->getIntConfig(CONFIG_BG_REWARD_WINNER_ARENA_FIRST);
909
910 // Reward winner team
911 if (bgTeamId == GetTeamId(winnerTeamId))
912 {
914 {
916
917 // Xinef: check player level and not bracket level if (CanAwardArenaPoints())
918 if (player->GetLevel() >= sWorld->getIntConfig(CONFIG_DAILY_RBG_MIN_LEVEL_AP_REWARD))
919 player->ModifyArenaPoints(winner_arena);
920
921 if (!player->GetRandomWinner())
922 player->SetRandomWinner(true);
923 }
924
925 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, player->GetMapId());
926 }
927 else
928 {
931 }
932
933 sScriptMgr->OnBattlegroundEndReward(this, player, GetTeamId(winnerTeamId));
934
935 player->ResetAllPowers();
936 player->CombatStopWithPets(true);
937
938 BlockMovement(player);
939
940 player->SendDirectMessage(&pvpLogData);
941
943 {
944 stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_PVPSTATS_PLAYER);
945 auto const& score = PlayerScores.find(player->GetGUID().GetCounter());
946
947 stmt->SetData(0, battlegroundId);
948 stmt->SetData(1, player->GetGUID().GetCounter());
949 stmt->SetData(2, bgTeamId == GetTeamId(winnerTeamId));
950 stmt->SetData(3, score->second->GetKillingBlows());
951 stmt->SetData(4, score->second->GetDeaths());
952 stmt->SetData(5, score->second->GetHonorableKills());
953 stmt->SetData(6, score->second->GetBonusHonor());
954 stmt->SetData(7, score->second->GetDamageDone());
955 stmt->SetData(8, score->second->GetHealingDone());
956 stmt->SetData(9, score->second->GetAttr1());
957 stmt->SetData(10, score->second->GetAttr2());
958 stmt->SetData(11, score->second->GetAttr3());
959 stmt->SetData(12, score->second->GetAttr4());
960 stmt->SetData(13, score->second->GetAttr5());
961
962 CharacterDatabase.Execute(stmt);
963 }
964
965 WorldPacket data;
966 sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetCurrentBattlegroundQueueSlot(), STATUS_IN_PROGRESS, TIME_TO_AUTOREMOVE, GetStartTime(), GetArenaType(), player->GetBgTeamId());
967 player->SendDirectMessage(&data);
968
969 player->UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, player->GetMapId());
970 }
971
973 SpiritOfCompetitionEvent(winnerTeamId);
974
975 sScriptMgr->OnBattlegroundEnd(this, GetTeamId(winnerTeamId));
976}
@ SCORE_BONUS_HONOR
Definition BattlegroundScore.h:31
@ BG_TEXT_ALLIANCE_WINS
Definition Battleground.h:65
@ BG_TEXT_HORDE_WINS
Definition Battleground.h:66
SpiritOfCompetitionEvent
Definition Battleground.h:237
@ EVENT_SPIRIT_OF_COMPETITION
Definition Battleground.h:238
@ SOUND_ALLIANCE_WINS
Definition Battleground.h:77
@ SOUND_HORDE_WINS
Definition Battleground.h:76
@ CHAR_SEL_PVPSTATS_MAXID
Definition CharacterDatabase.h:495
@ CHAR_INS_PVPSTATS_PLAYER
Definition CharacterDatabase.h:497
@ CHAR_INS_PVPSTATS_BATTLEGROUND
Definition CharacterDatabase.h:496
@ ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND
Definition DBCEnums.h:132
@ ACHIEVEMENT_CRITERIA_TYPE_WIN_BG
Definition DBCEnums.h:123
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition DatabaseEnv.cpp:21
std::uint64_t uint64
Definition Define.h:106
bool IsEventActive(uint16 eventId)
Definition GameEventMgr.cpp:1965
@ PVP_TEAM_HORDE
Definition SharedDefines.h:3706
@ PVP_TEAM_ALLIANCE
Definition SharedDefines.h:3707
TeamId GetTeamId(PvPTeamId teamId)
Definition SharedDefines.h:3728
@ SPELL_AURA_MOD_SHAPESHIFT
Definition SpellAuraDefines.h:99
@ CONFIG_DAILY_RBG_MIN_LEVEL_AP_REWARD
Definition WorldConfig.h:379
@ CONFIG_BG_REWARD_LOSER_HONOR_LAST
Definition WorldConfig.h:352
@ CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE
Definition WorldConfig.h:74
@ CONFIG_BG_REWARD_WINNER_ARENA_FIRST
Definition WorldConfig.h:348
@ CONFIG_BG_REWARD_WINNER_ARENA_LAST
Definition WorldConfig.h:350
@ CONFIG_BG_REWARD_WINNER_HONOR_FIRST
Definition WorldConfig.h:347
@ CONFIG_BG_REWARD_LOSER_HONOR_FIRST
Definition WorldConfig.h:351
@ CONFIG_BG_REWARD_WINNER_HONOR_LAST
Definition WorldConfig.h:349
static bool IsBGWeekend(BattlegroundTypeId bgTypeId)
Definition BattlegroundMgr.cpp:910
uint8 GetUniqueBracketId() const
Definition Battleground.cpp:1892
void BlockMovement(Player *player)
Definition Battleground.cpp:1010
void SetWinner(PvPTeamId winner)
Definition Battleground.h:373
void BuildPvPLogDataPacket(WorldPacket &data)
Definition Battleground.cpp:1363
virtual bool UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true)
Definition Battleground.cpp:1393
bool IsRandom()
Definition Battleground.h:356
uint32 GetBonusHonorFromKill(uint32 kills) const
Definition Battleground.cpp:1003
Class used to access individual fields of database query result.
Definition Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition Field.h:112
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition PreparedStatement.h:77
Definition PreparedStatement.h:157

References ACHIEVEMENT_CRITERIA_TYPE_COMPLETE_BATTLEGROUND, ACHIEVEMENT_CRITERIA_TYPE_WIN_BG, BG_TEXT_ALLIANCE_WINS, BG_TEXT_HORDE_WINS, BlockMovement(), BuildPvPLogDataPacket(), CHAR_INS_PVPSTATS_BATTLEGROUND, CHAR_INS_PVPSTATS_PLAYER, CHAR_SEL_PVPSTATS_MAXID, CharacterDatabase, CHAT_MSG_BG_SYSTEM_NEUTRAL, CONFIG_BATTLEGROUND_STORE_STATISTICS_ENABLE, CONFIG_BG_REWARD_LOSER_HONOR_FIRST, CONFIG_BG_REWARD_LOSER_HONOR_LAST, CONFIG_BG_REWARD_WINNER_ARENA_FIRST, CONFIG_BG_REWARD_WINNER_ARENA_LAST, CONFIG_BG_REWARD_WINNER_HONOR_FIRST, CONFIG_BG_REWARD_WINNER_HONOR_LAST, CONFIG_DAILY_RBG_MIN_LEVEL_AP_REWARD, EVENT_SPIRIT_OF_COMPETITION, Field::Get(), GetArenaType(), GetBgTypeID(), GetBonusHonorFromKill(), GetStartTime(), GetStatus(), GetTeamId(), GetUniqueBracketId(), GetWinner(), isBattleground(), BattlegroundMgr::IsBGWeekend(), IsEventActive(), IsRandom(), m_EndTime, m_Players, PlayerScores, PlaySoundToAll(), PVP_TEAM_ALLIANCE, PVP_TEAM_HORDE, RemoveFromBGFreeSlotQueue(), sBattlegroundMgr, SCORE_BONUS_HONOR, SendBroadcastText(), PreparedStatementBase::SetData(), SetStatus(), SetWinner(), SOUND_ALLIANCE_WINS, SOUND_HORDE_WINS, SPELL_AURA_MOD_SHAPESHIFT, sScriptMgr, STATUS_IN_PROGRESS, STATUS_WAIT_LEAVE, sWorld, TIME_TO_AUTOREMOVE, and UpdatePlayerScore().

Referenced by _ProcessProgress(), EndBattleground(), Arena::EndBattleground(), BattlegroundAB::EndBattleground(), BattlegroundAV::EndBattleground(), BattlegroundEY::EndBattleground(), BattlegroundSA::EndBattleground(), BattlegroundWS::EndBattleground(), BattlegroundIC::HandleKillPlayer(), BattlegroundIC::HandleKillUnit(), and Update().

◆ EndBattleground() [2/2]

virtual void Battleground::EndBattleground ( TeamId  winnerTeamId)
inlinevirtual
Deprecated:
need delete

Reimplemented in Arena, BattlegroundAB, BattlegroundAV, BattlegroundEY, BattlegroundSA, and BattlegroundWS.

475 {
476 EndBattleground(GetPvPTeamId(winnerTeamId));
477 }
PvPTeamId GetPvPTeamId(TeamId teamId)
Definition SharedDefines.h:3713

References EndBattleground(), and GetPvPTeamId().

◆ EndNow()

void Battleground::EndNow ( )
protected
1703{
1706 SetEndTime(0);
1707}
void SetEndTime(uint32 Time)
Definition Battleground.h:367

References RemoveFromBGFreeSlotQueue(), SetEndTime(), SetStatus(), and STATUS_WAIT_LEAVE.

Referenced by _ProcessJoin(), and AddSpiritGuide().

◆ EventPlayerClickedOnFlag()

virtual void Battleground::EventPlayerClickedOnFlag ( Player ,
GameObject  
)
inlinevirtual

◆ EventPlayerDamagedGO()

virtual void Battleground::EventPlayerDamagedGO ( Player ,
GameObject ,
uint32   
)
inlinevirtual

Reimplemented in BattlegroundIC, and BattlegroundSA.

516{}

◆ EventPlayerDroppedFlag()

virtual void Battleground::EventPlayerDroppedFlag ( Player )
inlinevirtual

Reimplemented in BattlegroundEY, and BattlegroundWS.

514{}

◆ EventPlayerUsedGO()

virtual void Battleground::EventPlayerUsedGO ( Player ,
GameObject  
)
inlinevirtual

Reimplemented in BattlegroundSA.

517{}

◆ FillInitialWorldStates()

◆ FindBgMap()

◆ GetAlivePlayersCountByTeam()

uint32 Battleground::GetAlivePlayersCountByTeam ( TeamId  teamId) const
1823{
1824 uint32 count = 0;
1825 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
1826 if (itr->second->IsAlive() && !itr->second->HasByteFlag(UNIT_FIELD_BYTES_2, 3, FORM_SPIRITOFREDEMPTION) && itr->second->GetBgTeamId() == teamId)
1827 ++count;
1828
1829 return count;
1830}
@ FORM_SPIRITOFREDEMPTION
Definition UnitDefines.h:99
@ UNIT_FIELD_BYTES_2
Definition UpdateFields.h:161

References FORM_SPIRITOFREDEMPTION, m_Players, and UNIT_FIELD_BYTES_2.

Referenced by Arena::CheckWinConditions(), Arena::EndBattleground(), Arena::FillInitialWorldStates(), and Arena::UpdateArenaWorldState().

◆ GetArenaMatchmakerRating()

uint32 Battleground::GetArenaMatchmakerRating ( TeamId  teamId) const
inline
504{ return m_ArenaTeamMMR[teamId]; }

References m_ArenaTeamMMR.

Referenced by Arena::EndBattleground(), and Arena::RemovePlayerAtLeave().

◆ GetArenaTeamIdForTeam()

uint32 Battleground::GetArenaTeamIdForTeam ( TeamId  teamId) const
inline
502{ return m_ArenaTeamIds[teamId]; }

References m_ArenaTeamIds.

Referenced by Arena::EndBattleground(), and Arena::RemovePlayerAtLeave().

◆ GetArenaType()

◆ GetBGCreature()

◆ GetBgMap()

◆ GetBGObject()

◆ GetBgRaid()

Group * Battleground::GetBgRaid ( TeamId  teamId) const
inline
482{ return m_BgRaids[teamId]; }

References m_BgRaids.

Referenced by AddOrSetPlayerToCorrectBgGroup(), RemovePlayerAtLeave(), and Group::~Group().

◆ GetBgTypeID()

BattlegroundTypeId Battleground::GetBgTypeID ( bool  GetRandom = false) const
inline
320{ return GetRandom ? m_RandomTypeID : m_RealTypeID; }

References m_RandomTypeID, and m_RealTypeID.

Referenced by _ProcessJoin(), BattlegroundMgr::AddBattleground(), BattlegroundQueue::BattlegroundQueueUpdate(), BattlegroundMgr::BuildBattlegroundStatusPacket(), BGSpamProtect::CanAnnounce(), Group::CanJoinBattlegroundQueue(), EndBattleground(), BattlegroundAV::EndBattleground(), GetTeamScore(), WorldSession::HandleBattleFieldPortOpcode(), WorldSession::HandleBattlemasterJoinArena(), WorldSession::HandleBattlemasterJoinOpcode(), misc_commandscript::HandleSkirmishCommand(), BattlegroundQueue::InviteGroupToBG(), SpellArea::IsFitToRequirements(), achievement_resilient_victory::OnCheck(), achievement_bg_ic_resource_glut::OnCheck(), achievement_everything_counts::OnCheck(), achievement_bg_av_perfection::OnCheck(), achievement_sa_defense_of_the_ancients::OnCheck(), achievement_not_even_a_scratch::OnCheck(), achievement_save_the_day::OnCheck(), RemovePlayerAtLeave(), Player::SendInitWorldStates(), BattlegroundAB::SetupBattleground(), BattlegroundAV::SetupBattleground(), BattlegroundEY::SetupBattleground(), BattlegroundWS::SetupBattleground(), ToBattlegroundAB(), ToBattlegroundAB(), ToBattlegroundAV(), ToBattlegroundAV(), ToBattlegroundBE(), ToBattlegroundBE(), ToBattlegroundDS(), ToBattlegroundDS(), ToBattlegroundEY(), ToBattlegroundEY(), ToBattlegroundIC(), ToBattlegroundIC(), ToBattlegroundNA(), ToBattlegroundNA(), ToBattlegroundRL(), ToBattlegroundRL(), ToBattlegroundRV(), ToBattlegroundRV(), ToBattlegroundSA(), ToBattlegroundSA(), ToBattlegroundWS(), ToBattlegroundWS(), GameObject::Use(), and ~Battleground().

◆ GetBonusHonorFromKill()

uint32 Battleground::GetBonusHonorFromKill ( uint32  kills) const
1004{
1005 //variable kills means how many honorable kills you scored (so we need kills * honor_for_one_kill)
1006 uint32 maxLevel = std::min<uint32>(GetMaxLevel(), 80U);
1007 return Acore::Honor::hk_honor_at_level(maxLevel, float(kills));
1008}
uint32 hk_honor_at_level(uint8 level, float multiplier=1.0f)
Definition Formulas.h:38

References GetMaxLevel(), and Acore::Honor::hk_honor_at_level().

Referenced by BattlegroundEY::AddPoints(), BattlegroundSA::DestroyGate(), EndBattleground(), BattlegroundAB::EndBattleground(), BattlegroundAV::EndBattleground(), BattlegroundEY::EndBattleground(), BattlegroundSA::EndBattleground(), BattlegroundWS::EndBattleground(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundAV::HandleKillUnit(), and BattlegroundAB::PostUpdateImpl().

◆ GetBracketId()

BattlegroundBracketId Battleground::GetBracketId ( ) const
inline

◆ GetClientInstanceID()

uint32 Battleground::GetClientInstanceID ( ) const
inline

◆ GetClosestGraveyard()

GraveyardStruct const * Battleground::GetClosestGraveyard ( Player player)
virtual

Reimplemented in BattlegroundAB, BattlegroundAV, BattlegroundEY, BattlegroundIC, BattlegroundSA, and BattlegroundWS.

1860{
1861 return sGraveyard->GetClosestGraveyard(player, player->GetBgTeamId());
1862}
#define sGraveyard
Definition GameGraveyard.h:74

References Player::GetBgTeamId(), and sGraveyard.

Referenced by RelocateDeadPlayers().

◆ GetEndTime()

uint32 Battleground::GetEndTime ( ) const
inline
326{ return m_EndTime; }

References m_EndTime.

Referenced by PlayerAddedToBGCheckIfBGIsRunning().

◆ GetFlagPickerGUID()

virtual ObjectGuid Battleground::GetFlagPickerGUID ( TeamId  = TEAM_NEUTRAL) const
inlinevirtual

Reimplemented in BattlegroundWS, and BattlegroundEY.

564{ return ObjectGuid::Empty; }
static ObjectGuid const Empty
Definition ObjectGuid.h:120

References ObjectGuid::Empty.

Referenced by WorldSession::HandleBattlegroundPlayerPositionsOpcode().

◆ GetFreeSlotsForTeam()

uint32 Battleground::GetFreeSlotsForTeam ( TeamId  teamId) const
1280{
1282 return 0;
1283
1284 // if CONFIG_BATTLEGROUND_INVITATION_TYPE == BG_QUEUE_INVITATION_TYPE_NO_BALANCE, invite everyone unless the BG is full
1286 return (GetInvitedCount(teamId) < GetMaxPlayersPerTeam()) ? GetMaxPlayersPerTeam() - GetInvitedCount(teamId) : 0;
1287
1288 // if BG is already started or CONFIG_BATTLEGROUND_INVITATION_TYPE != BG_QUEUE_INVITATION_TYPE_NO_BALANCE, do not allow to join too many players of one faction
1289 uint32 thisTeamInvitedCount = teamId == TEAM_ALLIANCE ? GetInvitedCount(TEAM_ALLIANCE) : GetInvitedCount(TEAM_HORDE);
1291 uint32 otherTeamInvitedCount = teamId == TEAM_ALLIANCE ? GetInvitedCount(TEAM_HORDE) : GetInvitedCount(TEAM_ALLIANCE);
1293
1294 // difference based on ppl invited (not necessarily entered battle)
1295 // default: allow 0
1296 uint32 diff = 0;
1297 uint32 maxPlayersPerTeam = GetMaxPlayersPerTeam();
1298 uint32 minPlayersPerTeam = GetMinPlayersPerTeam();
1299
1300 // allow join one person if the sides are equal (to fill up bg to minPlayerPerTeam)
1301 if (otherTeamInvitedCount == thisTeamInvitedCount)
1302 diff = 1;
1303 else if (otherTeamInvitedCount > thisTeamInvitedCount) // allow join more ppl if the other side has more players
1304 diff = otherTeamInvitedCount - thisTeamInvitedCount;
1305
1306 // difference based on max players per team (don't allow inviting more)
1307 uint32 diff2 = (thisTeamInvitedCount < maxPlayersPerTeam) ? maxPlayersPerTeam - thisTeamInvitedCount : 0;
1308
1309 // difference based on players who already entered
1310 // default: allow 0
1311 uint32 diff3 = 0;
1312
1313 // allow join one person if the sides are equal (to fill up bg minPlayerPerTeam)
1314 if (otherTeamPlayersCount == thisTeamPlayersCount)
1315 diff3 = 1;
1316 else if (otherTeamPlayersCount > thisTeamPlayersCount) // allow join more ppl if the other side has more players
1317 diff3 = otherTeamPlayersCount - thisTeamPlayersCount;
1318 else if (thisTeamInvitedCount <= minPlayersPerTeam) // or other side has less than minPlayersPerTeam
1319 diff3 = minPlayersPerTeam - thisTeamInvitedCount + 1;
1320
1321 // return the minimum of the 3 differences
1322 // min of diff, diff2 and diff3
1323 return std::min({ diff, diff2, diff3 });
1324}
@ BG_QUEUE_INVITATION_TYPE_NO_BALANCE
Definition Battleground.h:288
@ CONFIG_BATTLEGROUND_INVITATION_TYPE
Definition WorldConfig.h:268
uint32 GetMinPlayersPerTeam() const
Definition Battleground.h:341
uint32 GetMaxPlayersPerTeam() const
Definition Battleground.h:340
uint32 GetInvitedCount(TeamId teamId) const
Definition Battleground.h:388
uint32 GetPlayersCountByTeam(TeamId teamId) const
Definition Battleground.h:488

References BG_QUEUE_INVITATION_TYPE_NO_BALANCE, CONFIG_BATTLEGROUND_INVITATION_TYPE, GetInvitedCount(), GetMaxPlayersPerTeam(), GetMinPlayersPerTeam(), GetPlayersCountByTeam(), GetStatus(), STATUS_IN_PROGRESS, STATUS_WAIT_JOIN, sWorld, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by BattlegroundQueue::FillPlayersToBG(), GetMaxFreeSlots(), and HasFreeSlots().

◆ GetInstanceID()

◆ GetInvitedCount()

uint32 Battleground::GetInvitedCount ( TeamId  teamId) const
inline
388{ return m_BgInvitedPlayers[teamId]; }

References m_BgInvitedPlayers.

Referenced by GetFreeSlotsForTeam(), and Update().

◆ GetLastResurrectTime()

uint32 Battleground::GetLastResurrectTime ( ) const
inline

◆ GetMapId()

◆ GetMaxFreeSlots()

uint32 Battleground::GetMaxFreeSlots ( ) const
1327{
1329}
uint32 GetFreeSlotsForTeam(TeamId teamId) const
Definition Battleground.cpp:1279

References GetFreeSlotsForTeam(), TEAM_ALLIANCE, and TEAM_HORDE.

◆ GetMaxLevel()

◆ GetMaxPlayersPerTeam()

uint32 Battleground::GetMaxPlayersPerTeam ( ) const
inline

◆ GetMinLevel()

uint32 Battleground::GetMinLevel ( ) const
inline

◆ GetMinPlayersPerTeam()

uint32 Battleground::GetMinPlayersPerTeam ( ) const
inline
342 {
343 auto lowLevelsOverride = sWorld->getIntConfig(CONFIG_BATTLEGROUND_OVERRIDE_LOWLEVELS_MINPLAYERS);
344 return (lowLevelsOverride && !isTemplate() && !isMaxLevel() && !isArena()) ? lowLevelsOverride : m_MinPlayersPerTeam;
345 }
@ CONFIG_BATTLEGROUND_OVERRIDE_LOWLEVELS_MINPLAYERS
Definition WorldConfig.h:261
bool isMaxLevel() const
Definition Battleground.h:333
bool isTemplate() const
Definition Battleground.h:332

References CONFIG_BATTLEGROUND_OVERRIDE_LOWLEVELS_MINPLAYERS, isArena(), isMaxLevel(), isTemplate(), m_MinPlayersPerTeam, and sWorld.

Referenced by Group::CanJoinBattlegroundQueue(), GetFreeSlotsForTeam(), GetMinPlayersPerTeam(), GetPrematureWinner(), WorldSession::HandleBattlemasterJoinOpcode(), and Update().

◆ GetName()

std::string Battleground::GetName ( ) const
inline

◆ GetObjectType()

int32 Battleground::GetObjectType ( ObjectGuid  guid)
1838{
1839 for (uint32 i = 0; i < BgObjects.size(); ++i)
1840 if (BgObjects[i] == guid)
1841 return i;
1842
1843 LOG_ERROR("bg.battleground", "Battleground::GetObjectType: player used gameobject ({}) which is not in internal data for BG (map: {}, instance id: {}), cheating?",
1844 guid.ToString(), m_MapId, m_InstanceID);
1845
1846 return -1;
1847}
std::string ToString() const
Definition ObjectGuid.cpp:47

References BgObjects, LOG_ERROR, m_InstanceID, m_MapId, and ObjectGuid::ToString().

Referenced by BattlegroundAV::EventPlayerClickedOnFlag().

◆ GetOtherTeamId()

◆ GetPlayers()

◆ GetPlayerScores()

BattlegroundScoreMap const * Battleground::GetPlayerScores ( ) const
inline
418{ return &PlayerScores; }

References PlayerScores.

Referenced by BuildPvPLogDataPacket().

◆ GetPlayerScoresSize()

std::size_t Battleground::GetPlayerScoresSize ( ) const
inline
419{ return PlayerScores.size(); }

References PlayerScores.

◆ GetPlayersCountByTeam()

uint32 Battleground::GetPlayersCountByTeam ( TeamId  teamId) const
inline

◆ GetPlayersSize()

uint32 Battleground::GetPlayersSize ( ) const
inline
410{ return m_Players.size(); }

References m_Players.

Referenced by HandleTriggerBuff(), and Update().

◆ GetPrematureWinner()

◆ GetRealRepFactionForPlayer()

uint32 Battleground::GetRealRepFactionForPlayer ( uint32  factionId,
Player player 
)
796{
797 if (player)
798 {
799 // if the bg team is not the original team, reverse reputation
800 if (player->GetBgTeamId() != player->GetTeamId(true))
801 {
802 switch (factionId)
803 {
805 return BG_REP_AB_HORDE;
806 case BG_REP_AB_HORDE:
807 return BG_REP_AB_ALLIANCE;
809 return BG_REP_AV_HORDE;
810 case BG_REP_AV_HORDE:
811 return BG_REP_AV_ALLIANCE;
813 return BG_REP_WS_HORDE;
814 case BG_REP_WS_HORDE:
815 return BG_REP_WS_ALLIANCE;
816 }
817 }
818 }
819
820 return factionId;
821}
@ BG_REP_AV_HORDE
Definition Battleground.h:143
@ BG_REP_AB_HORDE
Definition Battleground.h:145
@ BG_REP_WS_HORDE
Definition Battleground.h:147
@ BG_REP_WS_ALLIANCE
Definition Battleground.h:148
@ BG_REP_AV_ALLIANCE
Definition Battleground.h:144
@ BG_REP_AB_ALLIANCE
Definition Battleground.h:146
TeamId GetTeamId(bool original=false) const
Definition Player.h:2108

References BG_REP_AB_ALLIANCE, BG_REP_AB_HORDE, BG_REP_AV_ALLIANCE, BG_REP_AV_HORDE, BG_REP_WS_ALLIANCE, BG_REP_WS_HORDE, Player::GetBgTeamId(), and Player::GetTeamId().

Referenced by RewardReputationToTeam().

◆ GetReviveQueueSize()

uint32 Battleground::GetReviveQueueSize ( ) const
inline
421{ return m_ReviveQueue.size(); }

References m_ReviveQueue.

Referenced by _ProcessResurrect().

◆ GetScriptId()

uint32 Battleground::GetScriptId ( ) const
inline
350{ return ScriptId; }

References ScriptId.

◆ GetSpectators()

const SpectatorList & Battleground::GetSpectators ( ) const
inline
399{ return m_Spectators; }

References m_Spectators.

◆ GetStartDelayTime()

int32 Battleground::GetStartDelayTime ( ) const
inline

◆ GetStartMaxDist()

float Battleground::GetStartMaxDist ( ) const
inline
447{ return m_StartMaxDist; }

References m_StartMaxDist.

Referenced by _CheckSafePositions().

◆ GetStartTime()

◆ GetStatus()

BattlegroundStatus Battleground::GetStatus ( ) const
inline
323{ return m_Status; }

References m_Status.

Referenced by _ProcessJoin(), AddPlayer(), BattlegroundQueue::BattlegroundQueueUpdate(), BuildPvPLogDataPacket(), BattlegroundWS::CheckFlagKeeperInArea(), MapInstanced::CreateInstanceForPlayer(), EndBattleground(), Arena::EndBattleground(), BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundEY::EventPlayerClickedOnFlag(), BattlegroundWS::EventPlayerClickedOnFlag(), BattlegroundIC::EventPlayerClickedOnFlag(), BattlegroundAB::EventPlayerClickedOnFlag(), BattlegroundAV::EventPlayerClickedOnFlag(), BattlegroundAV::EventPlayerDefendsPoint(), BattlegroundEY::EventPlayerDroppedFlag(), BattlegroundWS::EventPlayerDroppedFlag(), BGQueueRemoveEvent::Execute(), BattlegroundAV::FillInitialWorldStates(), BattlegroundWS::FillInitialWorldStates(), BattlegroundWS::GetClosestGraveyard(), GetFreeSlotsForTeam(), BattlegroundAB::HandleAreaTrigger(), BattlegroundAV::HandleAreaTrigger(), BattlegroundBE::HandleAreaTrigger(), BattlegroundDS::HandleAreaTrigger(), BattlegroundEY::HandleAreaTrigger(), BattlegroundIC::HandleAreaTrigger(), BattlegroundNA::HandleAreaTrigger(), BattlegroundRL::HandleAreaTrigger(), BattlegroundRV::HandleAreaTrigger(), BattlegroundSA::HandleAreaTrigger(), BattlegroundWS::HandleAreaTrigger(), WorldSession::HandleBattleFieldPortOpcode(), Arena::HandleKillPlayer(), BattlegroundAV::HandleKillPlayer(), BattlegroundEY::HandleKillPlayer(), BattlegroundIC::HandleKillPlayer(), BattlegroundWS::HandleKillPlayer(), BattlegroundAV::HandleKillUnit(), BattlegroundIC::HandleKillUnit(), BattlegroundAV::HandleQuestComplete(), ArenaSpectator::HandleResetCommand(), ArenaSpectator::HandleSpectatorSpectateCommand(), ArenaSpectator::HandleSpectatorWatchCommand(), HandleTriggerBuff(), HasFreeSlots(), Player::LeaveBattleground(), Player::NeedSendSpectatorData(), PlayerAddedToBGCheckIfBGIsRunning(), BattlegroundAB::PostUpdateImpl(), BattlegroundAV::PostUpdateImpl(), BattlegroundDS::PostUpdateImpl(), BattlegroundEY::PostUpdateImpl(), BattlegroundIC::PostUpdateImpl(), BattlegroundRV::PostUpdateImpl(), BattlegroundSA::PostUpdateImpl(), BattlegroundWS::PostUpdateImpl(), ReadyMarkerClicked(), Arena::RemovePlayer(), RemovePlayerAtLeave(), Arena::RemovePlayerAtLeave(), Player::ReportedAfkBy(), BattlegroundWS::RespawnFlagAfterDrop(), and Update().

◆ GetTeamScore()

uint32 Battleground::GetTeamScore ( TeamId  teamId) const

◆ GetTeamStartPosition()

Position const * Battleground::GetTeamStartPosition ( TeamId  teamId) const
708{
709 ASSERT(teamId < TEAM_NEUTRAL);
710 return &_startPosition[teamId];
711}
std::array< Position, PVP_TEAMS_COUNT > _startPosition
Definition Battleground.h:736

References _startPosition, ASSERT, and TEAM_NEUTRAL.

Referenced by _CheckSafePositions().

◆ GetUniqueBracketId()

uint8 Battleground::GetUniqueBracketId ( ) const
1893{
1894 return GetMaxLevel() / 10;
1895}

References GetMaxLevel().

Referenced by EndBattleground().

◆ GetWinner()

PvPTeamId Battleground::GetWinner ( ) const
inline

◆ HandleAreaTrigger()

virtual void Battleground::HandleAreaTrigger ( Player ,
uint32   
)
inlinevirtual

◆ HandleKillPlayer()

void Battleground::HandleKillPlayer ( Player player,
Player killer 
)
virtual

Reimplemented in Arena, BattlegroundAV, BattlegroundEY, BattlegroundIC, and BattlegroundWS.

1760{
1761 // Keep in mind that for arena this will have to be changed a bit
1762
1763 // Add +1 deaths
1764 UpdatePlayerScore(victim, SCORE_DEATHS, 1);
1765 // Add +1 kills to group and +1 killing_blows to killer
1766 if (killer)
1767 {
1768 // Don't reward credit for killing ourselves, like fall damage of hellfire (warlock)
1769 if (killer == victim)
1770 return;
1771
1774
1775 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
1776 {
1777 Player* creditedPlayer = itr->second;
1778 if (creditedPlayer == killer)
1779 continue;
1780
1781 if (creditedPlayer->GetBgTeamId() == killer->GetBgTeamId() && (creditedPlayer == killer || creditedPlayer->IsAtGroupRewardDistance(victim)))
1782 UpdatePlayerScore(creditedPlayer, SCORE_HONORABLE_KILLS, 1);
1783 }
1784 }
1785
1786 if (!isArena())
1787 {
1788 // To be able to remove insignia -- ONLY IN Battlegrounds
1789 victim->SetUnitFlag(UNIT_FLAG_SKINNABLE);
1790 RewardXPAtKill(killer, victim);
1791 }
1792}
@ SCORE_KILLING_BLOWS
Definition BattlegroundScore.h:28
@ SCORE_DEATHS
Definition BattlegroundScore.h:29
@ SCORE_HONORABLE_KILLS
Definition BattlegroundScore.h:30
@ UNIT_FLAG_SKINNABLE
Definition UnitDefines.h:280
void RewardXPAtKill(Player *killer, Player *victim)
Definition Battleground.cpp:1886
bool IsAtGroupRewardDistance(WorldObject const *pRewardSource) const
Definition Player.cpp:12809

References Player::GetBgTeamId(), isArena(), Player::IsAtGroupRewardDistance(), m_Players, RewardXPAtKill(), SCORE_DEATHS, SCORE_HONORABLE_KILLS, SCORE_KILLING_BLOWS, Unit::SetUnitFlag(), UNIT_FLAG_SKINNABLE, and UpdatePlayerScore().

Referenced by Arena::HandleKillPlayer(), BattlegroundAV::HandleKillPlayer(), BattlegroundEY::HandleKillPlayer(), BattlegroundIC::HandleKillPlayer(), and BattlegroundWS::HandleKillPlayer().

◆ HandleKillUnit()

virtual void Battleground::HandleKillUnit ( Creature ,
Player  
)
inlinevirtual

Reimplemented in BattlegroundSA, BattlegroundAV, and BattlegroundIC.

511{ }

◆ HandlePlayerResurrect()

virtual void Battleground::HandlePlayerResurrect ( Player )
inlinevirtual

Reimplemented in BattlegroundIC.

522{}

◆ HandlePlayerUnderMap()

virtual bool Battleground::HandlePlayerUnderMap ( Player )
inlinevirtual

Reimplemented in BattlegroundBE, BattlegroundDS, BattlegroundNA, BattlegroundRL, and BattlegroundRV.

553{ return false; }

◆ HandleTriggerBuff()

void Battleground::HandleTriggerBuff ( GameObject gameObject)
1710{
1711 // Xinef: crash fix?
1712 if (GetStatus() != STATUS_IN_PROGRESS || !GetPlayersSize() || BgObjects.empty())
1713 return;
1714
1715 uint32 index = 0;
1716 for (; index < BgObjects.size() && BgObjects[index] != gameObject->GetGUID(); ++index);
1717 if (BgObjects[index] != gameObject->GetGUID())
1718 {
1719 return;
1720 }
1721
1722 if (m_BuffChange)
1723 {
1724 uint8 buff = urand(0, 2);
1725 if (gameObject->GetEntry() != Buff_Entries[buff])
1726 {
1728 for (uint8 currBuffTypeIndex = 0; currBuffTypeIndex < 3; ++currBuffTypeIndex)
1729 if (gameObject->GetEntry() == Buff_Entries[currBuffTypeIndex])
1730 {
1731 index -= currBuffTypeIndex;
1732 index += buff;
1733 }
1734 }
1735 }
1736
1737 uint32 respawnTime = SPEED_BUFF_RESPAWN_TIME;
1738 if (Map* map = FindBgMap())
1739 {
1740 if (GameObject* obj = map->GetGameObject(BgObjects[index]))
1741 {
1742 switch (obj->GetEntry())
1743 {
1745 respawnTime = RESTORATION_BUFF_RESPAWN_TIME;
1746 break;
1748 respawnTime = BERSERKING_BUFF_RESPAWN_TIME;
1749 break;
1750 default:
1751 break;
1752 }
1753 }
1754 }
1755
1756 SpawnBGObject(index, respawnTime);
1757}
@ RESPAWN_ONE_DAY
Definition Battleground.h:159
const uint32 Buff_Entries[3]
Definition Battleground.h:186
#define SPEED_BUFF_RESPAWN_TIME
Definition Battleground.h:166
@ BG_OBJECTID_REGENBUFF_ENTRY
Definition Battleground.h:182
@ BG_OBJECTID_BERSERKERBUFF_ENTRY
Definition Battleground.h:183
#define RESTORATION_BUFF_RESPAWN_TIME
Definition Battleground.h:164
#define BERSERKING_BUFF_RESPAWN_TIME
Definition Battleground.h:165
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:44
void SpawnBGObject(uint32 type, uint32 respawntime, uint32 forceRespawnDelay=0)
Definition Battleground.cpp:1556
uint32 GetPlayersSize() const
Definition Battleground.h:410
uint32 GetEntry() const
Definition Object.h:116

References BERSERKING_BUFF_RESPAWN_TIME, BG_OBJECTID_BERSERKERBUFF_ENTRY, BG_OBJECTID_REGENBUFF_ENTRY, BgObjects, Buff_Entries, FindBgMap(), Object::GetEntry(), Object::GetGUID(), GetPlayersSize(), GetStatus(), m_BuffChange, RESPAWN_ONE_DAY, RESTORATION_BUFF_RESPAWN_TIME, SpawnBGObject(), SPEED_BUFF_RESPAWN_TIME, STATUS_IN_PROGRESS, and urand().

◆ HasFreeSlots()

bool Battleground::HasFreeSlots ( ) const
1332{
1334 return false;
1335 for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
1336 if (GetFreeSlotsForTeam((TeamId)i) > 0)
1337 return true;
1338 return false;
1339}

References GetFreeSlotsForTeam(), GetStatus(), PVP_TEAMS_COUNT, STATUS_IN_PROGRESS, and STATUS_WAIT_JOIN.

Referenced by BattlegroundQueue::BattlegroundQueueUpdate().

◆ HaveSpectators()

bool Battleground::HaveSpectators ( )
inline
398{ return !m_Spectators.empty(); }

References m_Spectators.

Referenced by Player::NeedSendSpectatorData().

◆ IncreaseInvitedCount()

void Battleground::IncreaseInvitedCount ( TeamId  teamId)
inline
387{ ++m_BgInvitedPlayers[teamId]; }

References m_BgInvitedPlayers.

Referenced by BattlegroundQueue::InviteGroupToBG().

◆ Init()

void Battleground::Init ( )
virtual

Reimplemented in BattlegroundAB, BattlegroundEY, BattlegroundRV, BattlegroundSA, and BattlegroundWS.

1111{
1114 SetStartTime(0);
1115 SetEndTime(0);
1117
1118 m_Events = 0;
1119
1121 {
1122 LOG_ERROR("bg.battleground", "Battleground::Reset: one of the counters is not 0 (alliance: {}, horde: {}) for BG (map: {}, instance id: {})!", m_BgInvitedPlayers[TEAM_ALLIANCE], m_BgInvitedPlayers[TEAM_HORDE], m_MapId, m_InstanceID);
1123 ABORT();
1124 }
1125
1128 _InBGFreeSlotQueue = false;
1129
1130 m_Players.clear();
1131
1132 for (auto const& itr : PlayerScores)
1133 delete itr.second;
1134
1135 PlayerScores.clear();
1136
1137 for (auto& itr : _arenaTeamScores)
1138 itr.Reset();
1139
1141}
@ STATUS_WAIT_QUEUE
Definition Battleground.h:191
#define ABORT
Definition Errors.h:76
virtual void ResetBGSubclass()
Definition Battleground.h:309
void SetStartTime(uint32 Time)
Definition Battleground.h:366
void SetLastResurrectTime(uint32 Time)
Definition Battleground.h:368

References _arenaTeamScores, _InBGFreeSlotQueue, ABORT, LOG_ERROR, m_BgInvitedPlayers, m_Events, m_InstanceID, m_MapId, m_Players, PlayerScores, PVP_TEAM_NEUTRAL, ResetBGSubclass(), SetEndTime(), SetLastResurrectTime(), SetStartTime(), SetStatus(), SetWinner(), STATUS_WAIT_QUEUE, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by BattlegroundMgr::CreateNewBattleground(), BattlegroundAB::Init(), BattlegroundEY::Init(), BattlegroundRV::Init(), BattlegroundSA::Init(), and BattlegroundWS::Init().

◆ isArena()

◆ isBattleground()

◆ isMaxLevel()

bool Battleground::isMaxLevel ( ) const
inline
334 {
335 // NOTE: this only works when the BG is not a template but the real BG
336 auto maxPlayerLevel = sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL);
337 return GetMinLevel() <= maxPlayerLevel && maxPlayerLevel <= GetMaxLevel();
338 }
@ CONFIG_MAX_PLAYER_LEVEL
Definition WorldConfig.h:189

References CONFIG_MAX_PLAYER_LEVEL, GetMaxLevel(), GetMinLevel(), and sWorld.

Referenced by GetMinPlayersPerTeam().

◆ IsPlayerInBattleground()

bool Battleground::IsPlayerInBattleground ( ObjectGuid  guid) const
1800{
1801 BattlegroundPlayerMap::const_iterator itr = m_Players.find(guid);
1802 if (itr != m_Players.end())
1803 return true;
1804 return false;
1805}

References m_Players.

Referenced by ArenaSpectator::HandleSpectatorWatchCommand().

◆ IsRandom()

bool Battleground::IsRandom ( )
inline
356{ return m_IsRandom; }

References m_IsRandom.

Referenced by EndBattleground().

◆ isRated()

◆ isTemplate()

bool Battleground::isTemplate ( ) const
inline
332{ return m_IsTemplate; }

References m_IsTemplate.

Referenced by GetMinPlayersPerTeam(), and GetMinPlayersPerTeam().

◆ ModifyStartDelayTime()

void Battleground::ModifyStartDelayTime ( int32  diff)
inline
377{ m_StartDelayTime -= diff; }

References m_StartDelayTime.

Referenced by _ProcessJoin().

◆ PlayerAddedToBGCheckIfBGIsRunning()

void Battleground::PlayerAddedToBGCheckIfBGIsRunning ( Player player)
protected
1808{
1810 return;
1811
1812 WorldPacket data;
1813 BlockMovement(player);
1814
1816 player->SendDirectMessage(&data);
1817
1818 sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetCurrentBattlegroundQueueSlot(), STATUS_IN_PROGRESS, GetEndTime(), GetStartTime(), GetArenaType(), player->GetBgTeamId());
1819 player->SendDirectMessage(&data);
1820}
uint32 GetEndTime() const
Definition Battleground.h:326
uint32 GetCurrentBattlegroundQueueSlot() const
Definition Player.h:2260
void SendDirectMessage(WorldPacket const *data) const
Definition Player.cpp:5711

References BlockMovement(), BuildPvPLogDataPacket(), GetArenaType(), Player::GetBgTeamId(), Player::GetCurrentBattlegroundQueueSlot(), GetEndTime(), GetStartTime(), GetStatus(), sBattlegroundMgr, Player::SendDirectMessage(), STATUS_IN_PROGRESS, and STATUS_WAIT_LEAVE.

Referenced by AddPlayer().

◆ PlaySoundToAll()

◆ PostUpdateImpl()

virtual void Battleground::PostUpdateImpl ( uint32  )
inlineprivatevirtual

Post-update hook.

Will be called after battleground update has passed. May be used to implement custom update effects in subclasses.

Parameters
diffa time difference between two worldserver update loops in milliseconds.
See also
Update(), PreUpdateImpl().

Reimplemented in BattlegroundAB, BattlegroundAV, BattlegroundDS, BattlegroundEY, BattlegroundIC, BattlegroundRV, BattlegroundSA, and BattlegroundWS.

702{ }

Referenced by Update().

◆ PreUpdateImpl()

virtual bool Battleground::PreUpdateImpl ( uint32  )
inlineprivatevirtual

Pre-update hook.

Will be called before battleground update is started. Depending on the result of this call actual update body may be skipped.

Parameters
diffa time difference between two worldserver update loops in milliseconds.
Returns
true if update must be performed, false otherwise.
See also
Update(), PostUpdateImpl().
689{ return true; }

Referenced by Update().

◆ ReadyMarkerClicked()

void Battleground::ReadyMarkerClicked ( Player p)
1348{
1350 return;
1351 readyMarkerClickedSet.insert(p->GetGUID());
1352 uint32 count = readyMarkerClickedSet.size();
1354 ChatHandler(p->GetSession()).SendNotification("You are marked as ready {}/{}", count, req);
1355 if (count == req)
1356 {
1360 }
1361}
@ BG_START_DELAY_15S
Definition Battleground.h:173
static uint8 GetReqPlayersForType(uint32 type)
Definition ArenaTeam.cpp:1024
GuidSet readyMarkerClickedSet
Definition Battleground.h:413
void SendNotification(std::string_view str)
Definition Chat.cpp:105
bool IsSpectator() const
Definition Player.h:2576

References BG_START_DELAY_15S, BG_STARTING_EVENT_2, BG_STARTING_EVENT_3, GetArenaType(), Object::GetGUID(), ArenaTeam::GetReqPlayersForType(), Player::GetSession(), GetStartDelayTime(), GetStatus(), isArena(), Player::IsSpectator(), m_Events, m_StartTime, readyMarkerClickedSet, ChatHandler::SendNotification(), SetStartDelayTime(), and STATUS_IN_PROGRESS.

◆ RelocateDeadPlayers()

void Battleground::RelocateDeadPlayers ( ObjectGuid  queueIndex)

Relocate all players in ReviveQueue to the closest graveyard.

1431{
1432 // Those who are waiting to resurrect at this node are taken to the closest own node's graveyard
1433 GuidVector& ghostList = m_ReviveQueue[queueIndex];
1434 if (!ghostList.empty())
1435 {
1436 GraveyardStruct const* closestGrave = nullptr;
1437 for (ObjectGuid const& guid : ghostList)
1438 {
1439 Player* player = ObjectAccessor::FindPlayer(guid);
1440 if (!player)
1441 continue;
1442
1443 if (!closestGrave)
1444 closestGrave = GetClosestGraveyard(player);
1445
1446 if (closestGrave)
1447 player->TeleportTo(GetMapId(), closestGrave->x, closestGrave->y, closestGrave->z, player->GetOrientation());
1448 }
1449
1450 ghostList.clear();
1451 }
1452}
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:256
virtual GraveyardStruct const * GetClosestGraveyard(Player *player)
Definition Battleground.cpp:1859
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1350
Definition GameGraveyard.h:27
float z
Definition GameGraveyard.h:32
float x
Definition GameGraveyard.h:30
float y
Definition GameGraveyard.h:31

References ObjectAccessor::FindPlayer(), GetClosestGraveyard(), GetMapId(), Position::GetOrientation(), m_ReviveQueue, Player::TeleportTo(), GraveyardStruct::x, GraveyardStruct::y, and GraveyardStruct::z.

Referenced by BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundIC::EventPlayerClickedOnFlag(), BattlegroundEY::EventTeamLostPoint(), and BattlegroundAB::NodeDeoccupied().

◆ RemoveAuraOnTeam()

void Battleground::RemoveAuraOnTeam ( uint32  spellId,
TeamId  teamId 
)
757{
758 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
759 if (itr->second->GetBgTeamId() == teamId)
760 itr->second->RemoveAura(spellId);
761}

References m_Players.

Referenced by BattlegroundIC::HandleCapturedNodes().

◆ RemoveFromBGFreeSlotQueue()

void Battleground::RemoveFromBGFreeSlotQueue ( )

◆ RemovePlayer()

virtual void Battleground::RemovePlayer ( Player )
inlineprotectedvirtual

◆ RemovePlayerAtLeave()

void Battleground::RemovePlayerAtLeave ( Player player)
virtual

Reimplemented in Arena.

1016{
1017 TeamId teamId = player->GetBgTeamId();
1018
1019 // check if the player was a participant of the match, or only entered through gm command
1020 bool participant = false;
1021 BattlegroundPlayerMap::iterator itr = m_Players.find(player->GetGUID());
1022 if (itr != m_Players.end())
1023 {
1024 UpdatePlayersCountByTeam(teamId, true); // -1 player
1025 m_Players.erase(itr);
1026 participant = true;
1027 }
1028
1029 // delete player score if exists
1030 auto const& itr2 = PlayerScores.find(player->GetGUID().GetCounter());
1031 if (itr2 != PlayerScores.end())
1032 {
1033 delete itr2->second;
1034 PlayerScores.erase(itr2);
1035 }
1036
1038
1039 // resurrect on exit
1040 if (!player->IsAlive())
1041 {
1042 player->ResurrectPlayer(1.0f);
1043 player->SpawnCorpseBones();
1044 }
1045
1047
1048 // GetStatus might be changed in RemovePlayer - define it here
1049 BattlegroundStatus status = GetStatus();
1050
1051 // BG subclass specific code
1052 RemovePlayer(player);
1053
1054 // should remove spirit of redemption
1055 if (player->HasSpiritOfRedemptionAura())
1057
1058 // if the player was a match participant
1059 if (participant)
1060 {
1061 player->ClearAfkReports();
1062
1063 WorldPacket data;
1064 sBattlegroundMgr->BuildBattlegroundStatusPacket(&data, this, player->GetCurrentBattlegroundQueueSlot(), STATUS_NONE, 0, 0, 0, TEAM_NEUTRAL);
1065 player->SendDirectMessage(&data);
1066
1068
1069 // this call is important, because player, when joins to battleground, this method is not called, so it must be called when leaving bg
1070 player->RemoveBattlegroundQueueId(bgQueueTypeId);
1071
1072 // remove from raid group if player is member
1073 if (Group* group = GetBgRaid(teamId))
1074 if (group->IsMember(player->GetGUID()))
1075 if (!group->RemoveMember(player->GetGUID())) // group was disbanded
1076 SetBgRaid(teamId, nullptr);
1077
1078 // let others know
1079 sBattlegroundMgr->BuildPlayerLeftBattlegroundPacket(&data, player->GetGUID());
1080 SendPacketToTeam(teamId, &data, player, false);
1081
1082 // cast deserter
1083 if (isBattleground() && !player->IsGameMaster() && sWorld->getBoolConfig(CONFIG_BATTLEGROUND_CAST_DESERTER))
1084 if (status == STATUS_IN_PROGRESS || status == STATUS_WAIT_JOIN)
1086
1087 DecreaseInvitedCount(teamId);
1088
1089 //we should update battleground queue, but only if bg isn't ending
1091 {
1092 BattlegroundTypeId bgTypeId = GetBgTypeID();
1094
1095 // a player has left the battleground, so there are free slots -> add to queue
1097 sBattlegroundMgr->ScheduleQueueUpdate(0, 0, bgQueueTypeId, bgTypeId, GetBracketId());
1098 }
1099 }
1100
1102
1103 // Xinef: remove all criterias on bg leave
1105
1106 sScriptMgr->OnBattlegroundRemovePlayerAtLeave(this, player);
1107}
BattlegroundStatus
Definition Battleground.h:189
@ DELAYED_SPELL_CAST_DESERTER
Definition Player.h:900
BattlegroundTypeId
Definition SharedDefines.h:3745
BattlegroundQueueTypeId
Definition SharedDefines.h:3885
#define PLAYER_MAX_BATTLEGROUND_QUEUES
Definition SharedDefines.h:176
@ SPELL_AURA_MOUNTED
Definition SpellAuraDefines.h:141
@ CONFIG_BATTLEGROUND_CAST_DESERTER
Definition WorldConfig.h:70
static BattlegroundQueueTypeId BGQueueTypeId(BattlegroundTypeId bgTypeId, uint8 arenaType)
Definition BattlegroundMgr.cpp:686
void DecreaseInvitedCount(TeamId teamId)
Definition Battleground.h:386
void RemovePlayerFromResurrectQueue(Player *player)
Definition Battleground.cpp:1418
void AddToBGFreeSlotQueue()
Definition Battleground.cpp:1260
virtual void RemovePlayer(Player *)
Definition Battleground.h:623
BattlegroundBracketId GetBracketId() const
Definition Battleground.h:321
LowType GetCounter() const
Definition ObjectGuid.h:145
void ScheduleDelayedOperation(uint32 operation)
Definition Player.h:2099
void ClearAfkReports()
Definition Player.h:2288
void SetBattlegroundId(uint32 id, BattlegroundTypeId bgTypeId, uint32 queueSlot, bool invited, bool isRandom, TeamId teamId)
Definition Player.cpp:12356
void RemoveBattlegroundQueueId(BattlegroundQueueTypeId val)
Definition Player.cpp:12318
bool IsGameMaster() const
Definition Player.h:1161
void RemoveAurasByType(AuraType auraType, ObjectGuid casterGUID=ObjectGuid::Empty, Aura *except=nullptr, bool negative=true, bool positive=true)
Definition Unit.cpp:5178
bool HasSpiritOfRedemptionAura() const
Definition Unit.h:1759

References ACHIEVEMENT_CRITERIA_CONDITION_BG_MAP, AddToBGFreeSlotQueue(), BATTLEGROUND_TYPE_NONE, BattlegroundMgr::BGQueueTypeId(), Player::ClearAfkReports(), CONFIG_BATTLEGROUND_CAST_DESERTER, DecreaseInvitedCount(), DELAYED_SPELL_CAST_DESERTER, GetArenaType(), GetBgRaid(), Player::GetBgTeamId(), GetBgTypeID(), GetBracketId(), ObjectGuid::GetCounter(), Player::GetCurrentBattlegroundQueueSlot(), Object::GetGUID(), GetMapId(), GetStatus(), Unit::HasSpiritOfRedemptionAura(), Unit::IsAlive(), isBattleground(), Player::IsGameMaster(), m_Players, PLAYER_MAX_BATTLEGROUND_QUEUES, PlayerScores, Unit::RemoveAurasByType(), Player::RemoveBattlegroundQueueId(), RemovePlayer(), RemovePlayerFromResurrectQueue(), Player::ResetAchievementCriteria(), Player::ResurrectPlayer(), sBattlegroundMgr, Player::ScheduleDelayedOperation(), Player::SendDirectMessage(), SendPacketToTeam(), Player::SetBattlegroundId(), SetBgRaid(), Player::SpawnCorpseBones(), SPELL_AURA_MOD_SHAPESHIFT, SPELL_AURA_MOUNTED, sScriptMgr, STATUS_IN_PROGRESS, STATUS_NONE, STATUS_WAIT_JOIN, STATUS_WAIT_LEAVE, sWorld, TEAM_NEUTRAL, and UpdatePlayersCountByTeam().

Referenced by Arena::RemovePlayerAtLeave().

◆ RemovePlayerFromResurrectQueue()

void Battleground::RemovePlayerFromResurrectQueue ( Player player)
1419{
1420 for (std::map<ObjectGuid, GuidVector>::iterator itr = m_ReviveQueue.begin(); itr != m_ReviveQueue.end(); ++itr)
1421 for (GuidVector::iterator itr2 = itr->second.begin(); itr2 != itr->second.end(); ++itr2)
1422 if (*itr2 == player->GetGUID())
1423 {
1424 itr->second.erase(itr2);
1426 return;
1427 }
1428}
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:4977

References Object::GetGUID(), m_ReviveQueue, Unit::RemoveAurasDueToSpell(), and SPELL_WAITING_FOR_RESURRECT.

Referenced by RemovePlayerAtLeave().

◆ RemoveSpectator()

void Battleground::RemoveSpectator ( Player p)
inline
397{ m_Spectators.erase(p); }

References m_Spectators.

◆ RemoveToBeTeleported()

void Battleground::RemoveToBeTeleported ( ObjectGuid  spectator)
inline
401{ ToBeTeleportedMap::iterator itr = m_ToBeTeleported.find(spectator); if (itr != m_ToBeTeleported.end()) m_ToBeTeleported.erase(itr); }

References m_ToBeTeleported.

◆ ResetBGSubclass()

virtual void Battleground::ResetBGSubclass ( )
inlinevirtual

Reimplemented in BattlegroundAV.

309{ } // must be implemented in BG subclass

Referenced by Init().

◆ RewardHonorToTeam()

◆ RewardReputationToTeam()

void Battleground::RewardReputationToTeam ( uint32  factionId,
uint32  reputation,
TeamId  teamId 
)
781{
782 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
783 if (itr->second->GetBgTeamId() == teamId)
784 {
785 uint32 realFactionId = GetRealRepFactionForPlayer(factionId, itr->second);
786
787 float repGain = static_cast<float>(reputation);
788 AddPct(repGain, itr->second->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
789 AddPct(repGain, itr->second->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, realFactionId));
790 if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(realFactionId))
791 itr->second->GetReputationMgr().ModifyReputation(factionEntry, repGain);
792 }
793}
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
@ SPELL_AURA_MOD_REPUTATION_GAIN
Definition SpellAuraDefines.h:219
@ SPELL_AURA_MOD_FACTION_REPUTATION_GAIN
Definition SpellAuraDefines.h:253
T AddPct(T &base, U pct)
Definition Util.h:67
uint32 GetRealRepFactionForPlayer(uint32 factionId, Player *player)
Definition Battleground.cpp:795
Definition DBCStructure.h:907

References AddPct(), GetRealRepFactionForPlayer(), m_Players, sFactionStore, SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, and SPELL_AURA_MOD_REPUTATION_GAIN.

Referenced by BattlegroundAV::EndBattleground(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundAV::HandleKillUnit(), BattlegroundAV::HandleQuestComplete(), and BattlegroundAB::PostUpdateImpl().

◆ RewardXPAtKill()

void Battleground::RewardXPAtKill ( Player killer,
Player victim 
)
1887{
1888 if (sWorld->getBoolConfig(CONFIG_BG_XP_FOR_KILL) && killer && victim)
1889 killer->RewardPlayerAndGroupAtKill(victim, true);
1890}
@ CONFIG_BG_XP_FOR_KILL
Definition WorldConfig.h:76
void RewardPlayerAndGroupAtKill(Unit *victim, bool isBattleGround)
Definition Player.cpp:12776

References CONFIG_BG_XP_FOR_KILL, Player::RewardPlayerAndGroupAtKill(), and sWorld.

Referenced by HandleKillPlayer().

◆ SendBroadcastText()

void Battleground::SendBroadcastText ( uint32  id,
ChatMsg  msgType,
WorldObject const *  target = nullptr 
)

◆ SendChatMessage()

void Battleground::SendChatMessage ( Creature source,
uint8  textId,
WorldObject target = nullptr 
)
727{
728 sCreatureTextMgr->SendChat(source, textId, target);
729}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:110

References sCreatureTextMgr.

◆ SendPacketToAll()

void Battleground::SendPacketToAll ( WorldPacket const *  packet)
714{
715 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
716 itr->second->SendDirectMessage(packet);
717}

References m_Players.

Referenced by PlaySoundToAll(), and UpdateWorldState().

◆ SendPacketToTeam()

void Battleground::SendPacketToTeam ( TeamId  teamId,
WorldPacket const *  packet,
Player sender = nullptr,
bool  self = true 
)
720{
721 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
722 if (itr->second->GetBgTeamId() == teamId && (self || sender != itr->second))
723 itr->second->SendDirectMessage(packet);
724}

References m_Players.

Referenced by AddPlayer(), and RemovePlayerAtLeave().

◆ SetArenaMatchmakerRating()

void Battleground::SetArenaMatchmakerRating ( TeamId  teamId,
uint32  MMR 
)
inline

◆ SetArenaorBGType()

void Battleground::SetArenaorBGType ( bool  _isArena)
inline
372{ m_IsArena = _isArena; }

References m_IsArena.

Referenced by BattlegroundMgr::CreateBattleground().

◆ SetArenaTeamIdForTeam()

void Battleground::SetArenaTeamIdForTeam ( TeamId  teamId,
uint32  ArenaTeamId 
)
inline
501{ m_ArenaTeamIds[teamId] = ArenaTeamId; }

References m_ArenaTeamIds.

Referenced by BattlegroundQueue::InviteGroupToBG().

◆ SetArenaType()

void Battleground::SetArenaType ( uint8  type)
inline
371{ m_ArenaType = type; }

References m_ArenaType.

Referenced by BattlegroundMgr::CreateNewBattleground().

◆ SetBgMap()

void Battleground::SetBgMap ( BattlegroundMap map)
inline

◆ SetBgRaid()

void Battleground::SetBgRaid ( TeamId  teamId,
Group bg_raid 
)
1850{
1851 Group*& old_raid = m_BgRaids[teamId];
1852 if (old_raid)
1853 old_raid->SetBattlegroundGroup(nullptr);
1854 if (bg_raid)
1855 bg_raid->SetBattlegroundGroup(this);
1856 old_raid = bg_raid;
1857}
void SetBattlegroundGroup(Battleground *bg)
Definition Group.cpp:2402

References m_BgRaids, and Group::SetBattlegroundGroup().

Referenced by AddOrSetPlayerToCorrectBgGroup(), Arena::AddPlayer(), RemovePlayerAtLeave(), and Group::~Group().

◆ SetBgTypeID()

void Battleground::SetBgTypeID ( BattlegroundTypeId  TypeID)
inline
360{ m_RealTypeID = TypeID; }
TypeID
Definition ObjectGuid.h:31

References m_RealTypeID.

Referenced by BattlegroundMgr::CreateBattleground(), and BattlegroundMgr::CreateNewBattleground().

◆ SetBracket()

void Battleground::SetBracket ( PvPDifficultyEntry const *  bracketEntry)
1865{
1866 m_IsTemplate = false;
1867 m_BracketId = bracketEntry->GetBracketId();
1868 SetLevelRange(bracketEntry->minLevel, bracketEntry->maxLevel);
1869}
void SetLevelRange(uint32 min, uint32 max)
Definition Battleground.h:369

References PvPDifficultyEntry::GetBracketId(), m_BracketId, m_IsTemplate, PvPDifficultyEntry::maxLevel, PvPDifficultyEntry::minLevel, and SetLevelRange().

Referenced by BattlegroundMgr::CreateNewBattleground().

◆ SetClientInstanceID()

void Battleground::SetClientInstanceID ( uint32  InstanceID)
inline
365{ m_ClientInstanceID = InstanceID; }

References m_ClientInstanceID.

Referenced by BattlegroundMgr::CreateNewBattleground().

◆ SetDroppedFlagGUID()

virtual void Battleground::SetDroppedFlagGUID ( ObjectGuid  ,
TeamId  = TEAM_NEUTRAL 
)
inlinevirtual

Reimplemented in BattlegroundWS, and BattlegroundEY.

565{}

◆ SetEndTime()

void Battleground::SetEndTime ( uint32  Time)
inline
367{ m_EndTime = Time; }

References m_EndTime.

Referenced by EndNow(), and Init().

◆ SetHoliday()

void Battleground::SetHoliday ( bool  is_holiday)
1833{
1834 m_HonorMode = is_holiday ? BG_HOLIDAY : BG_NORMAL;
1835}
@ BG_HOLIDAY
Definition Battleground.h:271

References BG_HOLIDAY, BG_NORMAL, and m_HonorMode.

◆ SetInstanceID()

void Battleground::SetInstanceID ( uint32  InstanceID)
inline

◆ SetLastResurrectTime()

void Battleground::SetLastResurrectTime ( uint32  Time)
inline
368{ m_LastResurrectTime = Time; }

References m_LastResurrectTime.

Referenced by Init(), and StartBattleground().

◆ SetLevelRange()

void Battleground::SetLevelRange ( uint32  min,
uint32  max 
)
inline
369{ m_LevelMin = min; m_LevelMax = max; }

References m_LevelMax, and m_LevelMin.

Referenced by BattlegroundMgr::CreateBattleground(), and SetBracket().

◆ SetMapId()

void Battleground::SetMapId ( uint32  MapID)
inline
435{ m_MapId = MapID; }

References m_MapId.

Referenced by BattlegroundMgr::CreateBattleground().

◆ SetMaxPlayersPerTeam()

void Battleground::SetMaxPlayersPerTeam ( uint32  MaxPlayers)
inline

◆ SetMinPlayersPerTeam()

void Battleground::SetMinPlayersPerTeam ( uint32  MinPlayers)
inline
381{ m_MinPlayersPerTeam = MinPlayers; }

References m_MinPlayersPerTeam.

Referenced by BattlegroundMgr::CreateBattleground().

◆ SetName()

void Battleground::SetName ( std::string_view  name)
inline
359{ m_Name = std::string(name); }

References m_Name.

Referenced by BattlegroundMgr::CreateBattleground().

◆ SetRandom()

void Battleground::SetRandom ( bool  isRandom)
inline

◆ SetRandomTypeID()

void Battleground::SetRandomTypeID ( BattlegroundTypeId  TypeID)
inline

◆ SetRated()

void Battleground::SetRated ( bool  state)
inline

◆ SetScriptId()

void Battleground::SetScriptId ( uint32  scriptId)
inline
374{ ScriptId = scriptId; }

References ScriptId.

Referenced by BattlegroundMgr::CreateBattleground().

◆ SetStartDelayTime()

void Battleground::SetStartDelayTime ( int32  Time)
inline
378{ m_StartDelayTime = Time; }

References m_StartDelayTime.

Referenced by _ProcessJoin(), and ReadyMarkerClicked().

◆ SetStartMaxDist()

void Battleground::SetStartMaxDist ( float  startMaxDist)
inline
446{ m_StartMaxDist = startMaxDist; }

References m_StartMaxDist.

Referenced by BattlegroundMgr::CreateBattleground().

◆ SetStartTime()

void Battleground::SetStartTime ( uint32  Time)
inline
366{ m_StartTime = Time; }

References m_StartTime.

Referenced by Init(), and StartBattleground().

◆ SetStatus()

◆ SetTeamStartPosition()

void Battleground::SetTeamStartPosition ( TeamId  teamId,
Position const &  pos 
)
702{
703 ASSERT(teamId < TEAM_NEUTRAL);
704 _startPosition[teamId] = pos;
705}

References _startPosition, ASSERT, and TEAM_NEUTRAL.

Referenced by BattlegroundMgr::CreateBattleground().

◆ SetupBattleground()

virtual bool Battleground::SetupBattleground ( )
inlinevirtual

◆ SetWinner()

void Battleground::SetWinner ( PvPTeamId  winner)
inline
373{ m_WinnerId = winner; }

References m_WinnerId.

Referenced by EndBattleground(), and Init().

◆ SpawnBGObject()

void Battleground::SpawnBGObject ( uint32  type,
uint32  respawntime,
uint32  forceRespawnDelay = 0 
)
1557{
1558 if (Map* map = FindBgMap())
1559 if (GameObject* obj = map->GetGameObject(BgObjects[type]))
1560 {
1561 if (respawntime)
1562 obj->SetLootState(GO_JUST_DEACTIVATED);
1563 else if (obj->getLootState() == GO_JUST_DEACTIVATED)
1564 // Change state from GO_JUST_DEACTIVATED to GO_READY in case battleground is starting again
1565 obj->SetLootState(GO_READY);
1566 obj->SetRespawnTime(respawntime);
1567 map->AddToMap(obj);
1568
1569 if (forceRespawnDelay)
1570 {
1571 obj->SetRespawnDelay(forceRespawnDelay);
1572 }
1573 }
1574}
@ GO_JUST_DEACTIVATED
Definition GameObject.h:113

References BgObjects, FindBgMap(), GO_JUST_DEACTIVATED, GO_READY, and Creature::SetRespawnTime().

Referenced by BattlegroundAB::CreateBanner(), BattlegroundAB::DeleteBanner(), BattlegroundAV::EventPlayerAssaultsPoint(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundEY::EventPlayerCapturedFlag(), BattlegroundEY::EventPlayerClickedOnFlag(), BattlegroundWS::EventPlayerClickedOnFlag(), BattlegroundAV::EventPlayerDefendsPoint(), BattlegroundAV::EventPlayerDestroyedPoint(), BattlegroundEY::EventTeamCapturedPoint(), BattlegroundEY::EventTeamLostPoint(), BattlegroundAV::HandleKillUnit(), HandleTriggerBuff(), BattlegroundWS::PostUpdateImpl(), BattlegroundSA::ResetObjs(), BattlegroundEY::RespawnFlag(), BattlegroundWS::RespawnFlagAfterDrop(), BattlegroundAV::SetupBattleground(), BattlegroundAB::StartingEventCloseDoors(), BattlegroundAV::StartingEventCloseDoors(), BattlegroundBE::StartingEventCloseDoors(), BattlegroundDS::StartingEventCloseDoors(), BattlegroundEY::StartingEventCloseDoors(), BattlegroundNA::StartingEventCloseDoors(), BattlegroundRL::StartingEventCloseDoors(), BattlegroundWS::StartingEventCloseDoors(), BattlegroundAB::StartingEventOpenDoors(), BattlegroundAV::StartingEventOpenDoors(), BattlegroundBE::StartingEventOpenDoors(), BattlegroundDS::StartingEventOpenDoors(), BattlegroundEY::StartingEventOpenDoors(), BattlegroundNA::StartingEventOpenDoors(), BattlegroundRL::StartingEventOpenDoors(), BattlegroundRV::StartingEventOpenDoors(), and BattlegroundWS::StartingEventOpenDoors().

◆ SpectatorsSendPacket()

void Battleground::SpectatorsSendPacket ( WorldPacket data)
1342{
1343 for (SpectatorList::const_iterator itr = m_Spectators.begin(); itr != m_Spectators.end(); ++itr)
1344 (*itr)->SendDirectMessage(&data);
1345}

References m_Spectators.

◆ SpiritOfCompetitionEvent()

void Battleground::SpiritOfCompetitionEvent ( PvPTeamId  winnerTeamId) const
979{
980 bool isDraw = winnerTeamId == PVP_TEAM_NEUTRAL;
981
982 std::vector<Player*> filteredPlayers;
983 GetBgMap()->DoForAllPlayers([&](Player* player)
984 {
985 // Reward all eligible players the participant reward
988
989 // Collect players of the winning team who has yet to recieve the winner reward
990 if (!isDraw && player->GetBgTeamId() == GetTeamId(winnerTeamId) &&
992 filteredPlayers.push_back(player);
993 });
994
995 // Randomly select one player from winners team to recieve the reward, if any eligible
996 if (!filteredPlayers.empty())
997 {
998 Player* wPlayer = filteredPlayers[rand() % filteredPlayers.size()];
999 wPlayer->CastSpell(wPlayer, SPELL_SPIRIT_OF_COMPETITION_WINNER, true);
1000 }
1001}
@ SPELL_SPIRIT_OF_COMPETITION_PARTICIPANT
Definition Battleground.h:241
@ QUEST_FLAG_WINNER
Definition Battleground.h:240
@ SPELL_SPIRIT_OF_COMPETITION_WINNER
Definition Battleground.h:242
@ QUEST_FLAG_PARTICIPANT
Definition Battleground.h:239
@ QUEST_STATUS_REWARDED
Definition QuestDef.h:106
QuestStatus GetQuestStatus(uint32 quest_id) const
Definition PlayerQuest.cpp:1430

References Unit::CastSpell(), Map::DoForAllPlayers(), GetBgMap(), Player::GetBgTeamId(), Player::GetQuestStatus(), GetTeamId(), PVP_TEAM_NEUTRAL, QUEST_FLAG_PARTICIPANT, QUEST_FLAG_WINNER, QUEST_STATUS_REWARDED, SPELL_SPIRIT_OF_COMPETITION_PARTICIPANT, and SPELL_SPIRIT_OF_COMPETITION_WINNER.

◆ StartBattleground()

void Battleground::StartBattleground ( )
1144{
1145 SetStartTime(0);
1147
1148 // add BG to free slot queue
1150
1151 // add bg to update list
1152 // this must be done here, because we need to have already invited some players when first Battleground::Update() method is executed
1153 sBattlegroundMgr->AddBattleground(this);
1154
1155 if (m_IsRated)
1156 LOG_DEBUG("bg.arena", "Arena match type: {} for Team1Id: {} - Team2Id: {} started.", m_ArenaType, m_ArenaTeamIds[TEAM_ALLIANCE], m_ArenaTeamIds[TEAM_HORDE]);
1157}

References AddToBGFreeSlotQueue(), LOG_DEBUG, m_ArenaTeamIds, m_ArenaType, m_IsRated, sBattlegroundMgr, SetLastResurrectTime(), SetStartTime(), TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by BattlegroundQueue::BattlegroundQueueUpdate(), and misc_commandscript::HandleSkirmishCommand().

◆ StartingEventCloseDoors()

virtual void Battleground::StartingEventCloseDoors ( )
inlinevirtual

◆ StartingEventOpenDoors()

virtual void Battleground::StartingEventOpenDoors ( )
inlinevirtual

◆ StartTimedAchievement()

void Battleground::StartTimedAchievement ( AchievementCriteriaTimedTypes  type,
uint32  entry 
)
1872{
1873 for (BattlegroundPlayerMap::const_iterator itr = GetPlayers().begin(); itr != GetPlayers().end(); ++itr)
1874 itr->second->StartTimedAchievement(type, entry);
1875}

References GetPlayers().

Referenced by BattlegroundSA::PostUpdateImpl(), BattlegroundAB::StartingEventOpenDoors(), BattlegroundAV::StartingEventOpenDoors(), BattlegroundEY::StartingEventOpenDoors(), and BattlegroundWS::StartingEventOpenDoors().

◆ ToBattlegroundAB() [1/2]

BattlegroundAB * Battleground::ToBattlegroundAB ( )
inline
579{ if (GetBgTypeID(true) == BATTLEGROUND_AB) return reinterpret_cast<BattlegroundAB*>(this); else return nullptr; }
@ BATTLEGROUND_AB
Definition SharedDefines.h:3749
Definition BattlegroundAB.h:250

References BATTLEGROUND_AB, and GetBgTypeID().

Referenced by achievement_resilient_victory::OnCheck().

◆ ToBattlegroundAB() [2/2]

BattlegroundAB const * Battleground::ToBattlegroundAB ( ) const
inline
580{ if (GetBgTypeID(true) == BATTLEGROUND_AB) return reinterpret_cast<const BattlegroundAB*>(this); else return nullptr; }

References BATTLEGROUND_AB, and GetBgTypeID().

◆ ToBattlegroundAV() [1/2]

BattlegroundAV * Battleground::ToBattlegroundAV ( )
inline
573{ if (GetBgTypeID(true) == BATTLEGROUND_AV) return reinterpret_cast<BattlegroundAV*>(this); else return nullptr; }
@ BATTLEGROUND_AV
Definition SharedDefines.h:3747
Definition BattlegroundAV.h:1758

References BATTLEGROUND_AV, and GetBgTypeID().

Referenced by achievement_everything_counts::OnCheck(), and achievement_bg_av_perfection::OnCheck().

◆ ToBattlegroundAV() [2/2]

BattlegroundAV const * Battleground::ToBattlegroundAV ( ) const
inline
574{ if (GetBgTypeID(true) == BATTLEGROUND_AV) return reinterpret_cast<const BattlegroundAV*>(this); else return nullptr; }

References BATTLEGROUND_AV, and GetBgTypeID().

◆ ToBattlegroundBE() [1/2]

BattlegroundBE * Battleground::ToBattlegroundBE ( )
inline
585{ if (GetBgTypeID(true) == BATTLEGROUND_BE) return reinterpret_cast<BattlegroundBE*>(this); else return nullptr; }
Definition BattlegroundBE.h:47

References BATTLEGROUND_BE, and GetBgTypeID().

◆ ToBattlegroundBE() [2/2]

BattlegroundBE const * Battleground::ToBattlegroundBE ( ) const
inline
586{ if (GetBgTypeID(true) == BATTLEGROUND_BE) return reinterpret_cast<const BattlegroundBE*>(this); else return nullptr; }

References BATTLEGROUND_BE, and GetBgTypeID().

◆ ToBattlegroundDS() [1/2]

BattlegroundDS * Battleground::ToBattlegroundDS ( )
inline
597{ if (GetBgTypeID(true) == BATTLEGROUND_DS) return reinterpret_cast<BattlegroundDS*>(this); else return nullptr; }
Definition BattlegroundDS.h:94

References BATTLEGROUND_DS, and GetBgTypeID().

◆ ToBattlegroundDS() [2/2]

BattlegroundDS const * Battleground::ToBattlegroundDS ( ) const
inline
598{ if (GetBgTypeID(true) == BATTLEGROUND_DS) return reinterpret_cast<const BattlegroundDS*>(this); else return nullptr; }

References BATTLEGROUND_DS, and GetBgTypeID().

◆ ToBattlegroundEY() [1/2]

BattlegroundEY * Battleground::ToBattlegroundEY ( )
inline
588{ if (GetBgTypeID(true) == BATTLEGROUND_EY) return reinterpret_cast<BattlegroundEY*>(this); else return nullptr; }
@ BATTLEGROUND_EY
Definition SharedDefines.h:3753
Definition BattlegroundEY.h:350

References BATTLEGROUND_EY, and GetBgTypeID().

◆ ToBattlegroundEY() [2/2]

BattlegroundEY const * Battleground::ToBattlegroundEY ( ) const
inline
589{ if (GetBgTypeID(true) == BATTLEGROUND_EY) return reinterpret_cast<const BattlegroundEY*>(this); else return nullptr; }

References BATTLEGROUND_EY, and GetBgTypeID().

◆ ToBattlegroundIC() [1/2]

BattlegroundIC * Battleground::ToBattlegroundIC ( )
inline
603{ if (GetBgTypeID(true) == BATTLEGROUND_IC) return reinterpret_cast<BattlegroundIC*>(this); else return nullptr; }
@ BATTLEGROUND_IC
Definition SharedDefines.h:3758
Definition BattlegroundIC.h:891

References BATTLEGROUND_IC, and GetBgTypeID().

Referenced by SpellArea::IsFitToRequirements(), and achievement_bg_ic_resource_glut::OnCheck().

◆ ToBattlegroundIC() [2/2]

BattlegroundIC const * Battleground::ToBattlegroundIC ( ) const
inline
604{ if (GetBgTypeID(true) == BATTLEGROUND_IC) return reinterpret_cast<const BattlegroundIC*>(this); else return nullptr; }

References BATTLEGROUND_IC, and GetBgTypeID().

◆ ToBattlegroundNA() [1/2]

BattlegroundNA * Battleground::ToBattlegroundNA ( )
inline
582{ if (GetBgTypeID(true) == BATTLEGROUND_NA) return reinterpret_cast<BattlegroundNA*>(this); else return nullptr; }
Definition BattlegroundNA.h:47

References BATTLEGROUND_NA, and GetBgTypeID().

◆ ToBattlegroundNA() [2/2]

BattlegroundNA const * Battleground::ToBattlegroundNA ( ) const
inline
583{ if (GetBgTypeID(true) == BATTLEGROUND_NA) return reinterpret_cast<const BattlegroundNA*>(this); else return nullptr; }

References BATTLEGROUND_NA, and GetBgTypeID().

◆ ToBattlegroundRL() [1/2]

BattlegroundRL * Battleground::ToBattlegroundRL ( )
inline
591{ if (GetBgTypeID(true) == BATTLEGROUND_RL) return reinterpret_cast<BattlegroundRL*>(this); else return nullptr; }
Definition BattlegroundRL.h:43

References BATTLEGROUND_RL, and GetBgTypeID().

◆ ToBattlegroundRL() [2/2]

BattlegroundRL const * Battleground::ToBattlegroundRL ( ) const
inline
592{ if (GetBgTypeID(true) == BATTLEGROUND_RL) return reinterpret_cast<const BattlegroundRL*>(this); else return nullptr; }

References BATTLEGROUND_RL, and GetBgTypeID().

◆ ToBattlegroundRV() [1/2]

BattlegroundRV * Battleground::ToBattlegroundRV ( )
inline
600{ if (GetBgTypeID(true) == BATTLEGROUND_RV) return reinterpret_cast<BattlegroundRV*>(this); else return nullptr; }
Definition BattlegroundRV.h:82

References BATTLEGROUND_RV, and GetBgTypeID().

◆ ToBattlegroundRV() [2/2]

BattlegroundRV const * Battleground::ToBattlegroundRV ( ) const
inline
601{ if (GetBgTypeID(true) == BATTLEGROUND_RV) return reinterpret_cast<const BattlegroundRV*>(this); else return nullptr; }

References BATTLEGROUND_RV, and GetBgTypeID().

◆ ToBattlegroundSA() [1/2]

BattlegroundSA * Battleground::ToBattlegroundSA ( )
inline
594{ if (GetBgTypeID(true) == BATTLEGROUND_SA) return reinterpret_cast<BattlegroundSA*>(this); else return nullptr; }
Class for manage Strand of Ancient battleground.
Definition BattlegroundSA.h:428

References BATTLEGROUND_SA, and GetBgTypeID().

Referenced by achievement_sa_defense_of_the_ancients::OnCheck(), and achievement_not_even_a_scratch::OnCheck().

◆ ToBattlegroundSA() [2/2]

BattlegroundSA const * Battleground::ToBattlegroundSA ( ) const
inline
595{ if (GetBgTypeID(true) == BATTLEGROUND_SA) return reinterpret_cast<const BattlegroundSA*>(this); else return nullptr; }

References BATTLEGROUND_SA, and GetBgTypeID().

◆ ToBattlegroundWS() [1/2]

BattlegroundWS * Battleground::ToBattlegroundWS ( )
inline
576{ if (GetBgTypeID(true) == BATTLEGROUND_WS) return reinterpret_cast<BattlegroundWS*>(this); else return nullptr; }
@ BATTLEGROUND_WS
Definition SharedDefines.h:3748
Definition BattlegroundWS.h:209

References BATTLEGROUND_WS, and GetBgTypeID().

Referenced by achievement_save_the_day::OnCheck().

◆ ToBattlegroundWS() [2/2]

BattlegroundWS const * Battleground::ToBattlegroundWS ( ) const
inline
577{ if (GetBgTypeID(true) == BATTLEGROUND_WS) return reinterpret_cast<const BattlegroundWS*>(this); else return nullptr; }

References BATTLEGROUND_WS, and GetBgTypeID().

◆ ToBeDeleted()

bool Battleground::ToBeDeleted ( ) const
inline
559{ return m_SetDeleteThis; }

References m_SetDeleteThis.

Referenced by BattlegroundMgr::Update().

◆ Update()

void Battleground::Update ( uint32  diff)
250{
251 // pussywizard:
252 m_UpdateTimer += diff;
254 return;
255
256 diff = BATTLEGROUND_UPDATE_INTERVAL; // just change diff value, no need to replace variable name in many places
258
259 if (!PreUpdateImpl(diff))
260 return;
261
262 if (!GetPlayersSize())
263 {
264 //BG is empty
265 // if there are no players invited, delete BG
266 // this will delete arena or bg object, where any player entered
267 // [[ but if you use battleground object again (more battles possible to be played on 1 instance)
268 // then this condition should be removed and code:
269 // if (!GetInvitedCount(TEAM_HORDE) && !GetInvitedCount(TEAM_ALLIANCE))
270 // AddToFreeBGObjectsQueue(); // not yet implemented
271 // should be used instead of current
272 // ]]
273 // Battleground Template instance cannot be updated, because it would be deleted
275 {
276 m_SetDeleteThis = true;
277 }
278
279 return;
280 }
281
282 switch (GetStatus())
283 {
284 case STATUS_WAIT_JOIN:
285 if (GetPlayersSize())
286 {
287 _ProcessJoin(diff);
289 }
290 break;
292 if (isArena())
293 {
294 if (GetStartTime() >= 46 * MINUTE * IN_MILLISECONDS) // pussywizard: 1min startup + 45min allowed duration
295 {
297 return;
298 }
299 }
300 else
301 {
302 _ProcessResurrect(diff);
304 _ProcessProgress(diff);
305 else if (m_PrematureCountDown)
306 m_PrematureCountDown = false;
307 }
308 break;
310 _ProcessLeave(diff);
311 break;
312 default:
313 break;
314 }
315
316 // Update start time and reset stats timer
317 m_StartTime += diff;
318 m_ResetStatTimer += diff;
319
320 PostUpdateImpl(diff);
321
322 sScriptMgr->OnBattlegroundUpdate(this, diff);
323}
#define BATTLEGROUND_UPDATE_INTERVAL
Definition Battleground.h:177
virtual void PostUpdateImpl(uint32)
Post-update hook.
Definition Battleground.h:702
void _ProcessResurrect(uint32 diff)
Definition Battleground.cpp:351
void _ProcessProgress(uint32 diff)
Definition Battleground.cpp:424
virtual bool PreUpdateImpl(uint32)
Pre-update hook.
Definition Battleground.h:689
void _CheckSafePositions(uint32 diff)
Definition Battleground.cpp:325
void _ProcessJoin(uint32 diff)
Definition Battleground.cpp:466
void _ProcessLeave(uint32 diff)
Definition Battleground.cpp:681

References _CheckSafePositions(), _ProcessJoin(), _ProcessLeave(), _ProcessProgress(), _ProcessResurrect(), BATTLEGROUND_UPDATE_INTERVAL, EndBattleground(), GetInvitedCount(), GetMinPlayersPerTeam(), GetPlayersCountByTeam(), GetPlayersSize(), GetStartTime(), GetStatus(), IN_MILLISECONDS, isArena(), m_PrematureCountDown, m_ResetStatTimer, m_SetDeleteThis, m_StartTime, m_UpdateTimer, MINUTE, PostUpdateImpl(), PreUpdateImpl(), PVP_TEAM_NEUTRAL, sBattlegroundMgr, sScriptMgr, STATUS_IN_PROGRESS, STATUS_WAIT_JOIN, STATUS_WAIT_LEAVE, TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by BattlegroundMgr::Update().

◆ UpdatePlayerScore()

bool Battleground::UpdatePlayerScore ( Player player,
uint32  type,
uint32  value,
bool  doAddHonor = true 
)
virtual

Reimplemented in BattlegroundAB, BattlegroundAV, BattlegroundEY, BattlegroundIC, and BattlegroundWS.

1394{
1395 auto const& itr = PlayerScores.find(player->GetGUID().GetCounter());
1396 if (itr == PlayerScores.end()) // player not found...
1397 return false;
1398
1399 if (type == SCORE_BONUS_HONOR && doAddHonor && isBattleground())
1400 player->RewardHonor(nullptr, 1, value); // RewardHonor calls UpdatePlayerScore with doAddHonor = false
1401 else
1402 itr->second->UpdateScore(type, value);
1403
1404 return true;
1405}
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool awardXP=true)
Definition Player.cpp:6090

References ObjectGuid::GetCounter(), Object::GetGUID(), isBattleground(), PlayerScores, Player::RewardHonor(), and SCORE_BONUS_HONOR.

Referenced by BattlegroundSA::DestroyGate(), EndBattleground(), HandleKillPlayer(), BattlegroundSA::HandleKillUnit(), RewardHonorToTeam(), BattlegroundAB::UpdatePlayerScore(), BattlegroundAV::UpdatePlayerScore(), BattlegroundEY::UpdatePlayerScore(), BattlegroundIC::UpdatePlayerScore(), and BattlegroundWS::UpdatePlayerScore().

◆ UpdatePlayersCountByTeam()

void Battleground::UpdatePlayersCountByTeam ( TeamId  teamId,
bool  remove 
)
inline
491 {
492 if (remove)
493 --m_PlayersCount[teamId];
494 else
495 ++m_PlayersCount[teamId];
496 }

References m_PlayersCount.

Referenced by AddPlayer(), and RemovePlayerAtLeave().

◆ UpdateWorldState()

void Battleground::UpdateWorldState ( uint32  variable,
uint32  value 
)
824{
826 worldstate.VariableID = variable;
827 worldstate.Value = value;
828 SendPacketToAll(worldstate.Write());
829}
Definition WorldStatePackets.h:50
int32 Value
Definition WorldStatePackets.h:57
WorldPacket const * Write() override
Definition WorldStatePackets.cpp:40
int32 VariableID
Definition WorldStatePackets.h:56

References SendPacketToAll(), WorldPackets::WorldState::UpdateWorldState::Value, WorldPackets::WorldState::UpdateWorldState::VariableID, and WorldPackets::WorldState::UpdateWorldState::Write().

Referenced by BattlegroundEY::AddPoints(), BattlegroundSA::CaptureGraveyard(), BattlegroundIC::DestroyGate(), BattlegroundSA::DestroyGate(), BattlegroundWS::EventPlayerCapturedFlag(), BattlegroundEY::EventPlayerClickedOnFlag(), BattlegroundSA::EventPlayerDamagedGO(), BattlegroundIC::HandleKillPlayer(), BattlegroundAB::PostUpdateImpl(), BattlegroundIC::PostUpdateImpl(), BattlegroundWS::PostUpdateImpl(), BattlegroundSA::ResetObjs(), BattlegroundEY::RespawnFlag(), BattlegroundAV::SendMineWorldStates(), BattlegroundAB::SendNodeUpdate(), BattlegroundSA::SendTime(), BattlegroundAV::StartingEventOpenDoors(), BattlegroundWS::StartingEventOpenDoors(), BattlegroundSA::ToggleTimer(), Arena::UpdateArenaWorldState(), BattlegroundWS::UpdateFlagState(), BattlegroundAV::UpdateNodeWorldState(), BattlegroundIC::UpdateNodeWorldState(), BattlegroundEY::UpdatePointsCount(), BattlegroundEY::UpdatePointsIcons(), and BattlegroundAV::UpdateScore().

◆ YellToAll()

void Battleground::YellToAll ( Creature creature,
const char *  text,
uint32  language 
)
764{
765 for (BattlegroundPlayerMap::const_iterator itr = m_Players.begin(); itr != m_Players.end(); ++itr)
766 {
767 WorldPacket data;
768 ChatHandler::BuildChatPacket(data, CHAT_MSG_MONSTER_YELL, Language(language), creature, itr->second, text);
769 itr->second->SendDirectMessage(&data);
770 }
771}
@ CHAT_MSG_MONSTER_YELL
Definition SharedDefines.h:3416
Language
Definition SharedDefines.h:745
static std::size_t BuildChatPacket(WorldPacket &data, ChatMsg chatType, Language language, ObjectGuid senderGUID, ObjectGuid receiverGUID, std::string_view message, uint8 chatTag, std::string const &senderName="", std::string const &receiverName="", uint32 achievementId=0, bool gmMessage=false, std::string const &channelName="")
Definition Chat.cpp:265

References ChatHandler::BuildChatPacket(), CHAT_MSG_MONSTER_YELL, and m_Players.

Referenced by BattlegroundAV::ChangeMineOwner(), and BattlegroundAV::PostUpdateImpl().

Member Data Documentation

◆ _arenaTeamScores

ArenaTeamScore Battleground::_arenaTeamScores[PVP_TEAMS_COUNT]
protected

◆ _InBGFreeSlotQueue

bool Battleground::_InBGFreeSlotQueue { false }
private
663{ false }; // used to make sure that BG is only once inserted into the BattlegroundMgr.BGFreeSlotQueue[bgTypeId] deque

Referenced by AddToBGFreeSlotQueue(), Init(), and RemoveFromBGFreeSlotQueue().

◆ _reviveEvents

◆ _startPosition

std::array<Position, PVP_TEAMS_COUNT> Battleground::_startPosition
private

◆ ArenaLogEntries

ArenaLogEntryDataMap Battleground::ArenaLogEntries

◆ BgCreatures

◆ BgObjects

◆ m_ArenaTeamIds

uint32 Battleground::m_ArenaTeamIds[PVP_TEAMS_COUNT]
private

◆ m_ArenaTeamMMR

uint32 Battleground::m_ArenaTeamMMR[PVP_TEAMS_COUNT]
private

◆ m_ArenaType

uint8 Battleground::m_ArenaType
private

◆ m_BgInvitedPlayers

uint32 Battleground::m_BgInvitedPlayers[PVP_TEAMS_COUNT]
private

◆ m_BgRaids

Group* Battleground::m_BgRaids[PVP_TEAMS_COUNT]
private

Referenced by Battleground(), GetBgRaid(), and SetBgRaid().

◆ m_BracketId

BattlegroundBracketId Battleground::m_BracketId { BG_BRACKET_ID_FIRST }
private
@ BG_BRACKET_ID_FIRST
Definition DBCEnums.h:47

Referenced by GetBracketId(), and SetBracket().

◆ m_BuffChange

bool Battleground::m_BuffChange
protected

◆ m_ClientInstanceID

uint32 Battleground::m_ClientInstanceID
private

◆ m_EndTime

int32 Battleground::m_EndTime
private

◆ m_Events

uint8 Battleground::m_Events
protected

◆ m_HonorMode

BGHonorMode Battleground::m_HonorMode
protected

Referenced by Battleground(), and SetHoliday().

◆ m_InstanceID

◆ m_IsArena

bool Battleground::m_IsArena
private

◆ m_IsRandom

bool Battleground::m_IsRandom
protected

Referenced by Battleground(), IsRandom(), and SetRandom().

◆ m_IsRated

bool Battleground::m_IsRated
private

◆ m_IsTemplate

bool Battleground::m_IsTemplate
private

◆ m_LastResurrectTime

uint32 Battleground::m_LastResurrectTime
private

◆ m_LevelMax

uint32 Battleground::m_LevelMax
private

◆ m_LevelMin

uint32 Battleground::m_LevelMin
private

◆ m_Map

BattlegroundMap* Battleground::m_Map
private

◆ m_MapId

◆ m_MaxPlayersPerTeam

uint32 Battleground::m_MaxPlayersPerTeam
private

◆ m_MinPlayersPerTeam

uint32 Battleground::m_MinPlayersPerTeam
private

◆ m_Name

std::string Battleground::m_Name {}
private
672{};

Referenced by GetName(), and SetName().

◆ m_OfflineQueue

GuidDeque Battleground::m_OfflineQueue
private

◆ m_Players

◆ m_PlayersCount

uint32 Battleground::m_PlayersCount[PVP_TEAMS_COUNT]
private

◆ m_PrematureCountDown

bool Battleground::m_PrematureCountDown
private

◆ m_PrematureCountDownTimer

uint32 Battleground::m_PrematureCountDownTimer
private

Referenced by _ProcessProgress(), and Battleground().

◆ m_RandomTypeID

BattlegroundTypeId Battleground::m_RandomTypeID
private

◆ m_RealTypeID

◆ m_ResetStatTimer

uint32 Battleground::m_ResetStatTimer
private

Referenced by _ProcessJoin(), Battleground(), and Update().

◆ m_ResurrectQueue

GuidVector Battleground::m_ResurrectQueue
private

Referenced by _ProcessResurrect().

◆ m_ReviveQueue

◆ m_SetDeleteThis

bool Battleground::m_SetDeleteThis
private

Referenced by Battleground(), ToBeDeleted(), and Update().

◆ m_SetupCompleted

bool Battleground::m_SetupCompleted
protected

Referenced by _ProcessJoin(), and Battleground().

◆ m_Spectators

◆ m_StartDelayTime

int32 Battleground::m_StartDelayTime
private

◆ m_StartMaxDist

float Battleground::m_StartMaxDist
private

◆ m_StartTime

uint32 Battleground::m_StartTime
private

◆ m_Status

BattlegroundStatus Battleground::m_Status
private

Referenced by Battleground(), GetStatus(), and SetStatus().

◆ m_TeamScores

◆ m_ToBeTeleported

ToBeTeleportedMap Battleground::m_ToBeTeleported
private

◆ m_UpdateTimer

uint32 Battleground::m_UpdateTimer
protected

Referenced by Battleground(), and Update().

◆ m_ValidStartPositionTimer

uint32 Battleground::m_ValidStartPositionTimer
private

◆ m_WinnerId

PvPTeamId Battleground::m_WinnerId
private

Referenced by Battleground(), GetWinner(), and SetWinner().

◆ PlayerScores

◆ readyMarkerClickedSet

GuidSet Battleground::readyMarkerClickedSet

Referenced by ReadyMarkerClicked().

◆ ScriptId

uint32 Battleground::ScriptId
private

◆ StartDelayTimes

BattlegroundStartTimeIntervals Battleground::StartDelayTimes[BG_STARTING_EVENT_COUNT]
protected

◆ StartMessageIds


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