AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
Battlefield Class Referenceabstract

#include "Battlefield.h"

Inheritance diagram for Battlefield:
ZoneScript BattlefieldWG

Public Types

typedef std::vector< BfCapturePoint * > BfCapturePointVector
 typedef of map witch store capturepoint and the associate gameobject entry
 

Public Member Functions

 Battlefield ()
 Constructor.
 
 ~Battlefield () override
 Destructor.
 
virtual bool SetupBattlefield ()
 Call this to init the Battlefield.
 
void SendUpdateWorldState (uint32 field, uint32 value)
 Update data of a worldstate to all players present in zone.
 
virtual bool Update (uint32 diff)
 Called every time for update bf data and time.
 
void InvitePlayersInZoneToQueue ()
 Invite all players in zone to join the queue, called x minutes before battle start in Update()
 
void InvitePlayersInQueueToWar ()
 Invite all players in queue to join battle on battle start.
 
void InvitePlayersInZoneToWar ()
 Invite all players in zone to join battle on battle start.
 
virtual void HandleKill (Player *, Unit *)
 Called when a Unit is kill in battlefield zone.
 
uint32 GetTypeId ()
 
uint32 GetZoneId ()
 
void TeamApplyBuff (TeamId team, uint32 spellId, uint32 spellId2=0)
 
bool IsWarTime ()
 Return true if battle is start, false if battle is not started.
 
void ToggleBattlefield (bool enable)
 Enable or Disable battlefield.
 
bool IsEnabled ()
 Return if battlefield is enable.
 
void KickPlayerFromBattlefield (ObjectGuid guid)
 Kick player from battlefield and teleport him to kick-point location.
 
void HandlePlayerEnterZone (Player *player, uint32 zone)
 Called when player (player) enter in zone.
 
void HandlePlayerLeaveZone (Player *player, uint32 zone)
 Called when player (player) leave the zone.
 
uint64 GetData64 (uint32 dataId) const override
 
void SetData64 (uint32 dataId, uint64 value) override
 
uint32 GetData (uint32 dataId) const override
 
void SetData (uint32 dataId, uint32 value) override
 
virtual void UpdateData (uint32 index, int32 pad)
 
TeamId GetDefenderTeam ()
 
TeamId GetAttackerTeam ()
 
TeamId GetOtherTeam (TeamId team)
 
void SetDefenderTeam (TeamId team)
 
GroupGetFreeBfRaid (TeamId TeamId)
 Find a not full battlefield group, if there is no, create one.
 
GroupGetGroupPlayer (ObjectGuid guid, TeamId TeamId)
 Return battlefield group where player is.
 
bool AddOrSetPlayerToCorrectBfGroup (Player *player)
 Force player to join a battlefield group.
 
GraveyardStruct const * GetClosestGraveyard (Player *player)
 
virtual void AddPlayerToResurrectQueue (ObjectGuid npc_guid, ObjectGuid player_guid)
 
void RemovePlayerFromResurrectQueue (ObjectGuid player_guid)
 
void SetGraveyardNumber (uint32 number)
 
BfGraveyardGetGraveyardById (uint32 id) const
 
CreatureSpawnCreature (uint32 entry, float x, float y, float z, float o, TeamId teamId)
 
CreatureSpawnCreature (uint32 entry, Position pos, TeamId teamId)
 
GameObjectSpawnGameObject (uint32 entry, float x, float y, float z, float o)
 
CreatureGetCreature (ObjectGuid const guid)
 
GameObjectGetGameObject (ObjectGuid const guid)
 
virtual void OnBattleStart ()
 Called on start.
 
virtual void OnBattleEnd (bool)
 Called at the end of battle.
 
virtual void OnStartGrouping ()
 Called x minutes before battle start when player in zone are invite to join queue.
 
virtual void OnPlayerJoinWar (Player *)
 Called when a player accept to join the battle.
 
virtual void OnPlayerLeaveWar (Player *)
 Called when a player leave the battle.
 
virtual void OnPlayerLeaveZone (Player *)
 Called when a player leave battlefield zone.
 
virtual void OnPlayerEnterZone (Player *)
 Called when a player enter in battlefield zone.
 
void SendWarning (uint8 id, WorldObject const *target=nullptr)
 
void PlayerAcceptInviteToQueue (Player *player)
 
void PlayerAcceptInviteToWar (Player *player)
 
uint32 GetBattleId ()
 
void AskToLeaveQueue (Player *player)
 
void PlayerAskToLeave (Player *player)
 
virtual void SendInitWorldStatesToAll ()=0
 Send all worldstate data to all player in zone.
 
virtual void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &)=0
 
virtual void SendUpdateWorldStates (Player *player=nullptr)=0
 
bool CanFlyIn ()
 Return if we can use mount in battlefield.
 
void SendAreaSpiritHealerQueryOpcode (Player *player, const ObjectGuid &guid)
 
void StartBattle ()
 
void EndBattle (bool endByTimer)
 
void HideNpc (Creature *creature)
 
void ShowNpc (Creature *creature, bool aggressive)
 
GraveyardVect GetGraveyardVector ()
 
uint32 GetTimer ()
 
void SetTimer (uint32 timer)
 
void DoPlaySoundToAll (uint32 SoundID)
 
void InvitePlayerToQueue (Player *player)
 
void InvitePlayerToWar (Player *player)
 
void InitStalker (uint32 entry, float x, float y, float z, float o)
 
- Public Member Functions inherited from ZoneScript
 ZoneScript ()
 
virtual ~ZoneScript ()
 
virtual uint32 GetCreatureEntry (ObjectGuid::LowType, CreatureData const *data)
 
virtual uint32 GetGameObjectEntry (ObjectGuid::LowType, uint32 entry)
 
virtual void OnCreatureCreate (Creature *)
 
virtual void OnCreatureRemove (Creature *)
 
virtual void OnGameObjectCreate (GameObject *)
 
virtual void OnGameObjectRemove (GameObject *)
 
virtual void OnUnitDeath (Unit *)
 
virtual void OnCreatureEvade (Creature *)
 
virtual ObjectGuid GetGuidData (uint32) const
 
virtual void SetGuidData (uint32, ObjectGuid)
 
virtual void ProcessEvent (WorldObject *, uint32)
 

Protected Member Functions

void KickAfkPlayers ()
 
virtual void SendRemoveWorldStates (Player *)
 
void BroadcastPacketToZone (WorldPacket const *data) const
 
void BroadcastPacketToQueue (WorldPacket const *data) const
 
void BroadcastPacketToWar (WorldPacket const *data) const
 
void AddCapturePoint (BfCapturePoint *cp)
 
void RegisterZone (uint32 zoneid)
 
bool HasPlayer (Player *player) const
 
void TeamCastSpell (TeamId team, int32 spellId)
 

Protected Attributes

ObjectGuid StalkerGuid
 
uint32 m_Timer
 
bool m_IsEnabled
 
bool m_isActive
 
TeamId m_DefenderTeam
 
BfCapturePointVector m_capturePoints
 
GuidUnorderedSet m_players [PVP_TEAMS_COUNT]
 
GuidUnorderedSet m_PlayersInQueue [PVP_TEAMS_COUNT]
 
GuidUnorderedSet m_PlayersInWar [PVP_TEAMS_COUNT]
 
PlayerTimerMap m_InvitedPlayers [PVP_TEAMS_COUNT]
 
PlayerTimerMap m_PlayersWillBeKick [PVP_TEAMS_COUNT]
 
uint32 m_TypeId
 
uint32 m_BattleId
 
uint32 m_ZoneId
 
uint32 m_MapId
 
Mapm_Map
 
uint32 m_MaxPlayer
 
uint32 m_MinPlayer
 
uint32 m_MinLevel
 
uint32 m_BattleTime
 
uint32 m_NoWarBattleTime
 
uint32 m_RestartAfterCrash
 
uint32 m_TimeForAcceptInvite
 
uint32 m_uiKickDontAcceptTimer
 
WorldLocation KickPosition
 
uint32 m_uiKickAfkPlayersTimer
 
GraveyardVect m_GraveyardList
 
uint32 m_LastResurectTimer
 
uint32 m_StartGroupingTimer
 
bool m_StartGrouping
 
GuidUnorderedSet m_Groups [PVP_TEAMS_COUNT]
 
std::vector< uint64m_Data64
 
std::vector< uint32m_Data32
 

Friends

class BattlefieldMgr
 

Detailed Description

Member Typedef Documentation

◆ BfCapturePointVector

typedef of map witch store capturepoint and the associate gameobject entry

Constructor & Destructor Documentation

◆ Battlefield()

Battlefield::Battlefield ( )

Constructor.

Todo:
: this import is not necessary for compilation and marked as unused by the IDE
43{
44 m_Timer = 0;
45 m_IsEnabled = true;
46 m_isActive = false;
48
49 m_TypeId = 0;
50 m_BattleId = 0;
51 m_ZoneId = 0;
52 m_Map = nullptr;
53 m_MapId = 0;
54 m_MaxPlayer = 0;
55 m_MinPlayer = 0;
56 m_MinLevel = 0;
57 m_BattleTime = 0;
62
64
67 m_StartGrouping = false;
68}
#define RESURRECTION_INTERVAL
Definition Battleground.h:173
@ TEAM_NEUTRAL
Definition SharedDefines.h:762
uint32 m_Timer
Definition Battlefield.h:365
uint32 m_MapId
Definition Battlefield.h:384
uint32 m_MaxPlayer
Definition Battlefield.h:386
uint32 m_NoWarBattleTime
Definition Battlefield.h:390
uint32 m_BattleTime
Definition Battlefield.h:389
uint32 m_ZoneId
Definition Battlefield.h:383
uint32 m_TypeId
Definition Battlefield.h:381
uint32 m_BattleId
Definition Battlefield.h:382
uint32 m_StartGroupingTimer
Definition Battlefield.h:402
uint32 m_LastResurectTimer
Definition Battlefield.h:400
Map * m_Map
Definition Battlefield.h:385
TeamId m_DefenderTeam
Definition Battlefield.h:368
uint32 m_uiKickAfkPlayersTimer
Definition Battlefield.h:396
uint32 m_TimeForAcceptInvite
Definition Battlefield.h:392
uint32 m_RestartAfterCrash
Definition Battlefield.h:391
uint32 m_MinLevel
Definition Battlefield.h:388
uint32 m_MinPlayer
Definition Battlefield.h:387
uint32 m_uiKickDontAcceptTimer
Definition Battlefield.h:393
bool m_IsEnabled
Definition Battlefield.h:366
bool m_StartGrouping
Definition Battlefield.h:403
bool m_isActive
Definition Battlefield.h:367

References m_BattleId, m_BattleTime, m_DefenderTeam, m_isActive, m_IsEnabled, m_LastResurectTimer, m_Map, m_MapId, m_MaxPlayer, m_MinLevel, m_MinPlayer, m_NoWarBattleTime, m_RestartAfterCrash, m_StartGrouping, m_StartGroupingTimer, m_TimeForAcceptInvite, m_Timer, m_TypeId, m_uiKickAfkPlayersTimer, m_uiKickDontAcceptTimer, m_ZoneId, RESURRECTION_INTERVAL, and TEAM_NEUTRAL.

◆ ~Battlefield()

Battlefield::~Battlefield ( )
override

Destructor.

71{
72 for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
73 delete *itr;
74
75 for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr)
76 delete *itr;
77
78 m_capturePoints.clear();
79}
GraveyardVect m_GraveyardList
Definition Battlefield.h:399
BfCapturePointVector m_capturePoints
Definition Battlefield.h:371

References m_capturePoints, and m_GraveyardList.

Member Function Documentation

◆ AddCapturePoint()

void Battlefield::AddCapturePoint ( BfCapturePoint cp)
inlineprotected
421{ m_capturePoints.push_back(cp); }

References m_capturePoints.

Referenced by BattlefieldWG::OnGameObjectCreate().

◆ AddOrSetPlayerToCorrectBfGroup()

bool Battlefield::AddOrSetPlayerToCorrectBfGroup ( Player player)

Force player to join a battlefield group.

549{
550 if (!player->IsInWorld())
551 return false;
552
553 if (player->GetGroup() && (player->GetGroup()->isBGGroup() || player->GetGroup()->isBFGroup()))
554 {
555 LOG_INFO("misc", "Battlefield::AddOrSetPlayerToCorrectBfGroup - player is already in {} group!", (player->GetGroup()->isBGGroup() ? "BG" : "BF"));
556 return false;
557 }
558
559 Group* group = GetFreeBfRaid(player->GetTeamId());
560 if (!group)
561 {
562 group = new Group;
563 group->SetBattlefieldGroup(this);
564 group->Create(player);
565 sGroupMgr->AddGroup(group);
566 m_Groups[player->GetTeamId()].insert(group->GetGUID());
567 }
568 else if (group->IsMember(player->GetGUID()))
569 {
570 uint8 subgroup = group->GetMemberGroup(player->GetGUID());
571 player->SetBattlegroundOrBattlefieldRaid(group, subgroup);
572 }
573 else
574 group->AddMember(player);
575
576 return true;
577}
std::uint8_t uint8
Definition Define.h:109
#define sGroupMgr
Definition GroupMgr.h:51
#define LOG_INFO(filterType__,...)
Definition Log.h:165
Group * GetFreeBfRaid(TeamId TeamId)
Find a not full battlefield group, if there is no, create one.
Definition Battlefield.cpp:528
GuidUnorderedSet m_Groups[PVP_TEAMS_COUNT]
Definition Battlefield.h:405
Definition Group.h:169
uint8 GetMemberGroup(ObjectGuid guid) const
Definition Group.cpp:2382
void SetBattlefieldGroup(Battlefield *bf)
Definition Group.cpp:2395
bool AddMember(Player *player)
Definition Group.cpp:388
ObjectGuid GetGUID() const
Definition Group.cpp:2304
bool isBGGroup() const
Definition Group.cpp:2274
bool isBFGroup() const
Definition Group.cpp:2279
bool IsMember(ObjectGuid guid) const
Definition Group.cpp:2334
bool Create(Player *leader)
Definition Group.cpp:106
bool IsInWorld() const
Definition Object.h:107
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:112
TeamId GetTeamId(bool original=false) const
Definition Player.h:2116
Group * GetGroup()
Definition Player.h:2476
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition Player.cpp:13142

References Group::AddMember(), Group::Create(), GetFreeBfRaid(), Player::GetGroup(), Group::GetGUID(), Object::GetGUID(), Group::GetMemberGroup(), Player::GetTeamId(), Group::isBFGroup(), Group::isBGGroup(), Object::IsInWorld(), Group::IsMember(), LOG_INFO, m_Groups, Group::SetBattlefieldGroup(), Player::SetBattlegroundOrBattlefieldRaid(), and sGroupMgr.

Referenced by PlayerAcceptInviteToWar().

◆ AddPlayerToResurrectQueue()

void Battlefield::AddPlayerToResurrectQueue ( ObjectGuid  npc_guid,
ObjectGuid  player_guid 
)
virtual
630{
631 for (uint8 i = 0; i < m_GraveyardList.size(); i++)
632 {
633 if (!m_GraveyardList[i])
634 continue;
635
636 if (m_GraveyardList[i]->HasNpc(npcGuid))
637 {
638 m_GraveyardList[i]->AddPlayer(playerGuid);
639 break;
640 }
641 }
642}

References BfGraveyard::AddPlayer(), and m_GraveyardList.

◆ AskToLeaveQueue()

void Battlefield::AskToLeaveQueue ( Player player)
407{
408 // Remove player from queue
409 m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
410 // Send notification
412}
GuidUnorderedSet m_PlayersInQueue[PVP_TEAMS_COUNT]
Definition Battlefield.h:375
WorldSession * GetSession() const
Definition Player.h:2005
void SendBfLeaveMessage(uint32 battleId, BFLeaveReason reason=BF_LEAVE_REASON_EXITED)
Definition BattlefieldHandler.cpp:85
@ BF_LEAVE_REASON_CLOSE
Definition WorldSession.h:199

References BF_LEAVE_REASON_CLOSE, Object::GetGUID(), Player::GetSession(), Player::GetTeamId(), m_BattleId, m_PlayersInQueue, and WorldSession::SendBfLeaveMessage().

Referenced by WorldSession::HandleBfExitRequest().

◆ BroadcastPacketToQueue()

void Battlefield::BroadcastPacketToQueue ( WorldPacket const *  data) const
protected
465{
466 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
467 for (GuidUnorderedSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
468 if (Player* player = ObjectAccessor::FindPlayer(*itr))
469 player->GetSession()->SendPacket(data);
470}
uint8 constexpr PVP_TEAMS_COUNT
Definition SharedDefines.h:3445
Definition Player.h:1081
Player * FindPlayer(ObjectGuid const guid)
Definition ObjectAccessor.cpp:245

References ObjectAccessor::FindPlayer(), m_PlayersInQueue, and PVP_TEAMS_COUNT.

◆ BroadcastPacketToWar()

void Battlefield::BroadcastPacketToWar ( WorldPacket const *  data) const
protected
473{
474 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
475 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
476 if (Player* player = ObjectAccessor::FindPlayer(*itr))
477 player->GetSession()->SendPacket(data);
478}
GuidUnorderedSet m_PlayersInWar[PVP_TEAMS_COUNT]
Definition Battlefield.h:376

References ObjectAccessor::FindPlayer(), m_PlayersInWar, and PVP_TEAMS_COUNT.

Referenced by DoPlaySoundToAll().

◆ BroadcastPacketToZone()

void Battlefield::BroadcastPacketToZone ( WorldPacket const *  data) const
protected
457{
458 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
459 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
460 if (Player* player = ObjectAccessor::FindPlayer(*itr))
461 player->GetSession()->SendPacket(data);
462}
GuidUnorderedSet m_players[PVP_TEAMS_COUNT]
Definition Battlefield.h:374

References ObjectAccessor::FindPlayer(), m_players, and PVP_TEAMS_COUNT.

◆ CanFlyIn()

bool Battlefield::CanFlyIn ( )
inline

Return if we can use mount in battlefield.

341{ return !m_isActive; }

References m_isActive.

Referenced by Spell::CheckCast(), spell_gen_mount::HandleMount(), and SpellArea::IsFitToRequirements().

◆ DoPlaySoundToAll()

void Battlefield::DoPlaySoundToAll ( uint32  SoundID)
387{
389}
void BroadcastPacketToWar(WorldPacket const *data) const
Definition Battlefield.cpp:472
Definition MiscPackets.h:85

References BroadcastPacketToWar().

Referenced by EndBattle(), and StartBattle().

◆ EndBattle()

void Battlefield::EndBattle ( bool  endByTimer)
362{
363 if (!m_isActive)
364 return;
365
366 m_isActive = false;
367
368 m_StartGrouping = false;
369
370 if (!endByTimer)
372
375 else
377
378 OnBattleEnd(endByTimer);
379
380 // Reset battlefield timer
384}
@ BF_ALLIANCE_WINS
Definition Battlefield.h:52
@ BF_HORDE_WINS
Definition Battlefield.h:51
@ TEAM_ALLIANCE
Definition SharedDefines.h:760
void DoPlaySoundToAll(uint32 SoundID)
Definition Battlefield.cpp:386
virtual void SendInitWorldStatesToAll()=0
Send all worldstate data to all player in zone.
virtual void OnBattleEnd(bool)
Called at the end of battle.
Definition Battlefield.h:313
TeamId GetDefenderTeam()
Definition Battlefield.h:275
void SetDefenderTeam(TeamId team)
Definition Battlefield.h:278
virtual void SendUpdateWorldStates(Player *player=nullptr)=0
TeamId GetAttackerTeam()
Definition Battlefield.h:276

References BF_ALLIANCE_WINS, BF_HORDE_WINS, DoPlaySoundToAll(), GetAttackerTeam(), GetDefenderTeam(), m_isActive, m_NoWarBattleTime, m_StartGrouping, m_Timer, OnBattleEnd(), SendInitWorldStatesToAll(), SendUpdateWorldStates(), SetDefenderTeam(), and TEAM_ALLIANCE.

Referenced by bf_commandscript::HandleBattlefieldEnd(), bf_commandscript::HandleBattlefieldSwitch(), BattlefieldWG::ProcessEvent(), and Update().

◆ FillInitialWorldStates()

virtual void Battlefield::FillInitialWorldStates ( WorldPackets::WorldState::InitWorldStates )
pure virtual

Implemented in BattlefieldWG.

Referenced by Player::SendInitWorldStates().

◆ GetAttackerTeam()

◆ GetBattleId()

uint32 Battlefield::GetBattleId ( )
inline
329{ return m_BattleId; }

References m_BattleId.

◆ GetClosestGraveyard()

GraveyardStruct const * Battlefield::GetClosestGraveyard ( Player player)
604{
605 BfGraveyard* closestGY = nullptr;
606 float maxdist = -1;
607 for (uint8 i = 0; i < m_GraveyardList.size(); i++)
608 {
609 if (m_GraveyardList[i])
610 {
611 if (m_GraveyardList[i]->GetControlTeamId() != player->GetTeamId())
612 continue;
613
614 float dist = m_GraveyardList[i]->GetDistance(player);
615 if (dist < maxdist || maxdist < 0)
616 {
617 closestGY = m_GraveyardList[i];
618 maxdist = dist;
619 }
620 }
621 }
622
623 if (closestGY)
624 return sGraveyard->GetGraveyard(closestGY->GetGraveyardId());
625
626 return nullptr;
627}
#define sGraveyard
Definition GameGraveyard.h:74
Definition Battlefield.h:146
uint32 GetGraveyardId() const
Definition Battlefield.h:193
float GetDistance(Player *player)
Definition Battlefield.cpp:698

References BfGraveyard::GetDistance(), BfGraveyard::GetGraveyardId(), Player::GetTeamId(), m_GraveyardList, and sGraveyard.

Referenced by BfGraveyard::RelocateDeadPlayers().

◆ GetCreature()

Creature * Battlefield::GetCreature ( ObjectGuid const  guid)

◆ GetData()

uint32 Battlefield::GetData ( uint32  dataId) const
inlineoverridevirtual

Reimplemented from ZoneScript.

Reimplemented in BattlefieldWG.

270{ return m_Data32[dataId]; }
std::vector< uint32 > m_Data32
Definition Battlefield.h:408

References m_Data32.

Referenced by npc_wg_demolisher_engineer::canBuild(), BattlefieldWG::GetData(), and SpellArea::IsFitToRequirements().

◆ GetData64()

uint64 Battlefield::GetData64 ( uint32  dataId) const
inlineoverridevirtual

Reimplemented from ZoneScript.

266{ return m_Data64[dataId]; }
std::vector< uint64 > m_Data64
Definition Battlefield.h:407

References m_Data64.

◆ GetDefenderTeam()

◆ GetFreeBfRaid()

Group * Battlefield::GetFreeBfRaid ( TeamId  TeamId)

Find a not full battlefield group, if there is no, create one.

Parameters
TeamId: Id of player team for who we search a group (player->GetTeamId())
529{
530 for (GuidUnorderedSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
531 if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
532 if (!group->IsFull())
533 return group;
534
535 return nullptr;
536}

References m_Groups, and sGroupMgr.

Referenced by AddOrSetPlayerToCorrectBfGroup().

◆ GetGameObject()

GameObject * Battlefield::GetGameObject ( ObjectGuid const  guid)
867{
868 if (!m_Map)
869 return nullptr;
870
871 return m_Map->GetGameObject(guid);
872}
GameObject * GetGameObject(ObjectGuid const guid)
Definition Map.cpp:2503

References Map::GetGameObject(), and m_Map.

Referenced by BfWGGameObjectBuilding::Destroyed(), BfCapturePoint::GetCapturePointGo(), BattlefieldWG::GetRelic(), BfWGGameObjectBuilding::Rebuild(), and BfWGGameObjectBuilding::UpdateTurretAttack().

◆ GetGraveyardById()

BfGraveyard * Battlefield::GetGraveyardById ( uint32  id) const
589{
590 if (id < m_GraveyardList.size())
591 {
592 if (m_GraveyardList[id])
593 return m_GraveyardList[id];
594 else
595 LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:{} not existed", id);
596 }
597 else
598 LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:{} cant be found", id);
599
600 return nullptr;
601}
#define LOG_ERROR(filterType__,...)
Definition Log.h:157

References LOG_ERROR, and m_GraveyardList.

Referenced by BattlefieldWG::GetData(), WGWorkshop::GiveControlTo(), BattlefieldWG::OnBattleEnd(), Update(), and WGWorkshop::UpdateGraveyardAndWorkshop().

◆ GetGraveyardVector()

GraveyardVect Battlefield::GetGraveyardVector ( )
inline

◆ GetGroupPlayer()

Group * Battlefield::GetGroupPlayer ( ObjectGuid  guid,
TeamId  TeamId 
)

Return battlefield group where player is.

539{
540 for (GuidUnorderedSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
541 if (Group* group = sGroupMgr->GetGroupByGUID(itr->GetCounter()))
542 if (group->IsMember(guid))
543 return group;
544
545 return nullptr;
546}

References m_Groups, and sGroupMgr.

◆ GetOtherTeam()

TeamId Battlefield::GetOtherTeam ( TeamId  team)
inline
277{ return (team == TEAM_HORDE ? TEAM_ALLIANCE : TEAM_HORDE); }
@ TEAM_HORDE
Definition SharedDefines.h:761

References TEAM_ALLIANCE, and TEAM_HORDE.

Referenced by InvitePlayerToQueue().

◆ GetTimer()

◆ GetTypeId()

uint32 Battlefield::GetTypeId ( )
inline
241{ return m_TypeId; }

References m_TypeId.

Referenced by SpellArea::IsFitToRequirements(), and Player::SendInitWorldStates().

◆ GetZoneId()

uint32 Battlefield::GetZoneId ( )
inline

◆ HandleKill()

virtual void Battlefield::HandleKill ( Player ,
Unit  
)
inlinevirtual

Called when a Unit is kill in battlefield zone.

Reimplemented in BattlefieldWG.

239{};

◆ HandlePlayerEnterZone()

void Battlefield::HandlePlayerEnterZone ( Player player,
uint32  zone 
)

Called when player (player) enter in zone.

Todo:
: Send a packet to announce it to player
83{
84 // Xinef: do not invite players on taxi
85 if (!player->IsInFlight())
86 {
87 // If battle is started,
88 // If not full of players > invite player to join the war
89 // If full of players > announce to player that BF is full and kick him after a few second if he desn't leave
90 if (IsWarTime())
91 {
92 if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) // Vacant spaces
93 InvitePlayerToWar(player);
94 else // No more vacant places
95 {
97 m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime().count() + (player->IsGameMaster() ? 30 * MINUTE : 10);
98 InvitePlayerToQueue(player);
99 }
100 }
101 else
102 {
103 // If time left is < 15 minutes invite player to join queue
105 InvitePlayerToQueue(player);
106 }
107 }
108
109 // Add player in the list of player in zone
110 m_players[player->GetTeamId()].insert(player->GetGUID());
111 OnPlayerEnterZone(player);
112}
constexpr auto MINUTE
Definition Common.h:47
void InvitePlayerToQueue(Player *player)
Definition Battlefield.cpp:231
void InvitePlayerToWar(Player *player)
Definition Battlefield.cpp:278
bool IsWarTime()
Return true if battle is start, false if battle is not started.
Definition Battlefield.h:247
PlayerTimerMap m_PlayersWillBeKick[PVP_TEAMS_COUNT]
Definition Battlefield.h:378
PlayerTimerMap m_InvitedPlayers[PVP_TEAMS_COUNT]
Definition Battlefield.h:377
virtual void OnPlayerEnterZone(Player *)
Called when a player enter in battlefield zone.
Definition Battlefield.h:323
bool IsGameMaster() const
Definition Player.h:1175
bool IsInFlight() const
Definition Unit.h:1625
Seconds GetGameTime()
Definition GameTime.cpp:38

References GameTime::GetGameTime(), Object::GetGUID(), Player::GetTeamId(), InvitePlayerToQueue(), InvitePlayerToWar(), Player::IsGameMaster(), Unit::IsInFlight(), IsWarTime(), m_InvitedPlayers, m_MaxPlayer, m_players, m_PlayersInWar, m_PlayersWillBeKick, m_StartGroupingTimer, m_Timer, MINUTE, and OnPlayerEnterZone().

Referenced by BattlefieldMgr::HandlePlayerEnterZone().

◆ HandlePlayerLeaveZone()

void Battlefield::HandlePlayerLeaveZone ( Player player,
uint32  zone 
)

Called when player (player) leave the zone.

116{
117 if (IsWarTime())
118 {
119 // If the player is participating to the battle
120 if (m_PlayersInWar[player->GetTeamId()].find(player->GetGUID()) != m_PlayersInWar[player->GetTeamId()].end())
121 {
122 m_PlayersInWar[player->GetTeamId()].erase(player->GetGUID());
124 if (Group* group = player->GetGroup()) // Remove the player from the raid group
125 if (group->isBFGroup())
126 group->RemoveMember(player->GetGUID());
127
128 OnPlayerLeaveWar(player);
129 }
130 }
131
132 for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
133 (*itr)->HandlePlayerLeave(player);
134
135 m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
136 m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
137 m_players[player->GetTeamId()].erase(player->GetGUID());
138 SendRemoveWorldStates(player);
140 OnPlayerLeaveZone(player);
141}
virtual void SendRemoveWorldStates(Player *)
Definition Battlefield.h:413
virtual void OnPlayerLeaveZone(Player *)
Called when a player leave battlefield zone.
Definition Battlefield.h:321
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid)
Definition Battlefield.cpp:644
virtual void OnPlayerLeaveWar(Player *)
Called when a player leave the battle.
Definition Battlefield.h:319

References Player::GetGroup(), Object::GetGUID(), Player::GetSession(), Player::GetTeamId(), IsWarTime(), m_BattleId, m_capturePoints, m_InvitedPlayers, m_players, m_PlayersInWar, m_PlayersWillBeKick, OnPlayerLeaveWar(), OnPlayerLeaveZone(), RemovePlayerFromResurrectQueue(), WorldSession::SendBfLeaveMessage(), and SendRemoveWorldStates().

◆ HasPlayer()

bool Battlefield::HasPlayer ( Player player) const
protected
392{
393 return m_players[player->GetTeamId()].find(player->GetGUID()) != m_players[player->GetTeamId()].end();
394}

References Object::GetGUID(), Player::GetTeamId(), and m_players.

Referenced by RemovePlayerFromResurrectQueue().

◆ HideNpc()

void Battlefield::HideNpc ( Creature creature)
500{
501 creature->CombatStop();
502 creature->SetReactState(REACT_PASSIVE);
504 creature->SetPhaseMask(2, false); // pussywizard: false because UpdateObjectVisibility(true) is called below in SetVisible(), no need to have it here
505 creature->DisappearAndDie();
506 creature->SetVisible(false);
507}
@ UNIT_FLAG_NON_ATTACKABLE
Definition UnitDefines.h:251
@ UNIT_FLAG_NOT_SELECTABLE
Definition UnitDefines.h:275
@ REACT_PASSIVE
Definition Unit.h:548
void SetReactState(ReactStates state)
A creature can have 3 ReactStates : Agressive, Passive, Neutral.
Definition Creature.h:95
void DisappearAndDie()
Definition Creature.cpp:373
void SetVisible(bool x)
Definition Unit.cpp:14284
void CombatStop(bool includingCast=false)
Definition Unit.cpp:10481
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition Unit.cpp:19101
void SetUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:719

References Unit::CombatStop(), Creature::DisappearAndDie(), REACT_PASSIVE, Unit::SetPhaseMask(), Creature::SetReactState(), Unit::SetUnitFlag(), Unit::SetVisible(), UNIT_FLAG_NON_ATTACKABLE, and UNIT_FLAG_NOT_SELECTABLE.

Referenced by BfWGGameObjectBuilding::Damaged(), BfWGGameObjectBuilding::Init(), BattlefieldWG::OnBattleEnd(), BattlefieldWG::SetupBattlefield(), BfWGGameObjectBuilding::UpdateCreatureAndGo(), and BfWGGameObjectBuilding::UpdateTurretAttack().

◆ InitStalker()

void Battlefield::InitStalker ( uint32  entry,
float  x,
float  y,
float  z,
float  o 
)
311{
312 if (Creature* creature = SpawnCreature(entry, x, y, z, o, TEAM_NEUTRAL))
313 StalkerGuid = creature->GetGUID();
314 else
315 LOG_ERROR("bg.battlefield", "Battlefield::InitStalker: could not spawn Stalker (Creature entry {}), zone messeges will be un-available", entry);
316}
ObjectGuid StalkerGuid
Definition Battlefield.h:364
Creature * SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId teamId)
Definition Battlefield.cpp:791
Definition Creature.h:43

References LOG_ERROR, SpawnCreature(), StalkerGuid, and TEAM_NEUTRAL.

Referenced by BattlefieldWG::SetupBattlefield().

◆ InvitePlayersInQueueToWar()

void Battlefield::InvitePlayersInQueueToWar ( )

Invite all players in queue to join battle on battle start.

241{
242 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
243 {
245 for (GuidUnorderedSet::const_iterator itr = copy.begin(); itr != copy.end(); ++itr)
246 {
247 if (Player* player = ObjectAccessor::FindPlayer(*itr))
248 {
249 if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
250 InvitePlayerToWar(player);
251 else
252 {
253 //Full
254 }
255 }
256 }
257 m_PlayersInQueue[team].clear();
258 }
259}
std::unordered_set< ObjectGuid > GuidUnorderedSet
Definition ObjectGuid.h:257

References ObjectAccessor::FindPlayer(), InvitePlayerToWar(), m_InvitedPlayers, m_MaxPlayer, m_PlayersInQueue, m_PlayersInWar, and PVP_TEAMS_COUNT.

Referenced by StartBattle().

◆ InvitePlayersInZoneToQueue()

void Battlefield::InvitePlayersInZoneToQueue ( )

Invite all players in zone to join the queue, called x minutes before battle start in Update()

224{
225 for (uint8 team = 0; team < 2; ++team)
226 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
227 if (Player* player = ObjectAccessor::FindPlayer(*itr))
228 InvitePlayerToQueue(player);
229}

References ObjectAccessor::FindPlayer(), InvitePlayerToQueue(), and m_players.

Referenced by Update().

◆ InvitePlayersInZoneToWar()

void Battlefield::InvitePlayersInZoneToWar ( )

Invite all players in zone to join battle on battle start.

262{
263 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
264 for (GuidUnorderedSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
265 {
266 if (Player* player = ObjectAccessor::FindPlayer(*itr))
267 {
268 if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
269 continue;
270 if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
271 InvitePlayerToWar(player);
272 else if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)// Battlefield is full of players
273 m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime().count() + 10;
274 }
275 }
276}

References ObjectAccessor::FindPlayer(), GameTime::GetGameTime(), InvitePlayerToWar(), m_InvitedPlayers, m_MaxPlayer, m_players, m_PlayersInWar, m_PlayersWillBeKick, and PVP_TEAMS_COUNT.

Referenced by StartBattle(), and Update().

◆ InvitePlayerToQueue()

void Battlefield::InvitePlayerToQueue ( Player player)
232{
233 if (m_PlayersInQueue[player->GetTeamId()].count(player->GetGUID()))
234 return;
235
236 if (m_PlayersInQueue[player->GetTeamId()].size() <= m_MinPlayer || m_PlayersInQueue[GetOtherTeam(player->GetTeamId())].size() >= m_MinPlayer)
238}
TeamId GetOtherTeam(TeamId team)
Definition Battlefield.h:277
void SendBfInvitePlayerToQueue(uint32 battleId)
Definition BattlefieldHandler.cpp:45

References Object::GetGUID(), GetOtherTeam(), Player::GetSession(), Player::GetTeamId(), m_BattleId, m_MinPlayer, m_PlayersInQueue, and WorldSession::SendBfInvitePlayerToQueue().

Referenced by HandlePlayerEnterZone(), InvitePlayersInZoneToQueue(), and npc_wg_queue::OnGossipSelect().

◆ InvitePlayerToWar()

void Battlefield::InvitePlayerToWar ( Player player)
Todo:
: needed ?
279{
280 if (!player)
281 return;
282
284 if (player->IsInFlight())
285 return;
286
287 if (player->InBattleground())
288 {
289 m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
290 return;
291 }
292
293 // If the player does not match minimal level requirements for the battlefield, kick him
294 if (player->GetLevel() < m_MinLevel)
295 {
296 if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)
297 m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime().count() + 10;
298 return;
299 }
300
301 // Check if player is not already in war
302 if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
303 return;
304
305 m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
308}
bool InBattleground() const
Definition Player.h:2260
uint8 GetLevel() const
Definition Unit.h:1033
void SendBfInvitePlayerToWar(uint32 battleId, uint32 zoneId, uint32 time)
Definition BattlefieldHandler.cpp:31

References GameTime::GetGameTime(), Object::GetGUID(), Unit::GetLevel(), Player::GetSession(), Player::GetTeamId(), Player::InBattleground(), Unit::IsInFlight(), m_BattleId, m_InvitedPlayers, m_MinLevel, m_PlayersInQueue, m_PlayersInWar, m_PlayersWillBeKick, m_TimeForAcceptInvite, m_ZoneId, and WorldSession::SendBfInvitePlayerToWar().

Referenced by HandlePlayerEnterZone(), InvitePlayersInQueueToWar(), InvitePlayersInZoneToWar(), and npc_wg_queue::OnGossipSelect().

◆ IsEnabled()

bool Battlefield::IsEnabled ( )
inline

Return if battlefield is enable.

252{ return m_IsEnabled; }

References m_IsEnabled.

Referenced by bf_commandscript::HandleBattlefieldEnable(), and Update().

◆ IsWarTime()

◆ KickAfkPlayers()

void Battlefield::KickAfkPlayers ( )
protected
319{
320 // xinef: optimization, dont lookup player twice
321 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
322 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
323 if (Player* player = ObjectAccessor::FindPlayer(*itr))
324 if (player->isAFK() && player->GetZoneId() == GetZoneId() && !player->IsGameMaster())
325 player->TeleportTo(KickPosition);
326}
uint32 GetZoneId()
Definition Battlefield.h:242
WorldLocation KickPosition
Definition Battlefield.h:394

References ObjectAccessor::FindPlayer(), GetZoneId(), KickPosition, m_PlayersInWar, and PVP_TEAMS_COUNT.

Referenced by Update().

◆ KickPlayerFromBattlefield()

void Battlefield::KickPlayerFromBattlefield ( ObjectGuid  guid)

Kick player from battlefield and teleport him to kick-point location.

Parameters
guid: guid of player who must be kick
329{
330 if (Player* player = ObjectAccessor::FindPlayer(guid))
331 {
332 if (player->GetZoneId() == GetZoneId() && !player->IsGameMaster())
333 player->TeleportTo(KickPosition);
334 }
335}

References ObjectAccessor::FindPlayer(), GetZoneId(), and KickPosition.

Referenced by WorldSession::HandleBfEntryInviteResponse(), BattlefieldWG::OnPlayerEnterZone(), and Update().

◆ OnBattleEnd()

virtual void Battlefield::OnBattleEnd ( bool  )
inlinevirtual

Called at the end of battle.

Reimplemented in BattlefieldWG.

313{};

Referenced by EndBattle().

◆ OnBattleStart()

virtual void Battlefield::OnBattleStart ( )
inlinevirtual

Called on start.

Reimplemented in BattlefieldWG.

311{};

Referenced by StartBattle().

◆ OnPlayerEnterZone()

virtual void Battlefield::OnPlayerEnterZone ( Player )
inlinevirtual

Called when a player enter in battlefield zone.

Reimplemented in BattlefieldWG.

323{};

Referenced by HandlePlayerEnterZone().

◆ OnPlayerJoinWar()

virtual void Battlefield::OnPlayerJoinWar ( Player )
inlinevirtual

Called when a player accept to join the battle.

Reimplemented in BattlefieldWG.

317{};

Referenced by PlayerAcceptInviteToWar().

◆ OnPlayerLeaveWar()

virtual void Battlefield::OnPlayerLeaveWar ( Player )
inlinevirtual

Called when a player leave the battle.

Reimplemented in BattlefieldWG.

319{};

Referenced by HandlePlayerLeaveZone().

◆ OnPlayerLeaveZone()

virtual void Battlefield::OnPlayerLeaveZone ( Player )
inlinevirtual

Called when a player leave battlefield zone.

Reimplemented in BattlefieldWG.

321{};

Referenced by HandlePlayerLeaveZone().

◆ OnStartGrouping()

virtual void Battlefield::OnStartGrouping ( )
inlinevirtual

Called x minutes before battle start when player in zone are invite to join queue.

Reimplemented in BattlefieldWG.

315{};

Referenced by Update().

◆ PlayerAcceptInviteToQueue()

void Battlefield::PlayerAcceptInviteToQueue ( Player player)
398{
399 // Add player in queue
400 m_PlayersInQueue[player->GetTeamId()].insert(player->GetGUID());
401 // Send notification
403}
void SendBfQueueInviteResponse(uint32 battleId, uint32 zoneId, bool canQueue=true, bool full=false)
Definition BattlefieldHandler.cpp:61

References Object::GetGUID(), Player::GetSession(), Player::GetTeamId(), m_BattleId, m_PlayersInQueue, m_ZoneId, and WorldSession::SendBfQueueInviteResponse().

Referenced by WorldSession::HandleBfQueueInviteResponse().

◆ PlayerAcceptInviteToWar()

void Battlefield::PlayerAcceptInviteToWar ( Player player)
423{
424 if (!IsWarTime())
425 return;
426
428 {
430 m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID());
431 m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
432
433 if (player->isAFK())
434 player->ToggleAFK();
435
436 OnPlayerJoinWar(player); //for scripting
437 }
438}
virtual void OnPlayerJoinWar(Player *)
Called when a player accept to join the battle.
Definition Battlefield.h:317
bool AddOrSetPlayerToCorrectBfGroup(Player *player)
Force player to join a battlefield group.
Definition Battlefield.cpp:548
void ToggleAFK()
Definition Player.cpp:1297
bool isAFK() const
Definition Player.h:1151
void SendBfEntered(uint32 battleId)
Definition BattlefieldHandler.cpp:74

References AddOrSetPlayerToCorrectBfGroup(), Object::GetGUID(), Player::GetSession(), Player::GetTeamId(), Player::isAFK(), IsWarTime(), m_BattleId, m_InvitedPlayers, m_PlayersInWar, OnPlayerJoinWar(), WorldSession::SendBfEntered(), and Player::ToggleAFK().

Referenced by WorldSession::HandleBfEntryInviteResponse().

◆ PlayerAskToLeave()

void Battlefield::PlayerAskToLeave ( Player player)
416{
417 // Player leaving Wintergrasp, teleport to homebind possition.
418 player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, player->GetOrientation());
419}
float m_homebindZ
Definition Player.h:2381
uint32 m_homebindMapId
Definition Player.h:2377
float m_homebindY
Definition Player.h:2380
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, uint32 options=0, Unit *target=nullptr, bool newInstance=false)
Definition Player.cpp:1338
float m_homebindX
Definition Player.h:2379
float GetOrientation() const
Definition Position.h:124

References Position::GetOrientation(), Player::m_homebindMapId, Player::m_homebindX, Player::m_homebindY, Player::m_homebindZ, and Player::TeleportTo().

◆ RegisterZone()

void Battlefield::RegisterZone ( uint32  zoneid)
protected
495{
496 sBattlefieldMgr->AddZone(zoneId, this);
497}
#define sBattlefieldMgr
Definition BattlefieldMgr.h:77

References sBattlefieldMgr.

Referenced by BattlefieldWG::SetupBattlefield().

◆ RemovePlayerFromResurrectQueue()

void Battlefield::RemovePlayerFromResurrectQueue ( ObjectGuid  player_guid)
645{
646 for (uint8 i = 0; i < m_GraveyardList.size(); i++)
647 {
648 if (!m_GraveyardList[i])
649 continue;
650
651 if (m_GraveyardList[i]->HasPlayer(playerGuid))
652 {
653 m_GraveyardList[i]->RemovePlayer(playerGuid);
654 break;
655 }
656 }
657}
bool HasPlayer(Player *player) const
Definition Battlefield.cpp:391

References HasPlayer(), and m_GraveyardList.

Referenced by HandlePlayerLeaveZone().

◆ SendAreaSpiritHealerQueryOpcode()

void Battlefield::SendAreaSpiritHealerQueryOpcode ( Player player,
const ObjectGuid guid 
)
660{
662 uint32 time = m_LastResurectTimer; // resurrect every 30 seconds
663
664 data << guid << time;
665 ASSERT(player);
666 player->GetSession()->SendPacket(&data);
667}
std::uint32_t uint32
Definition Define.h:107
#define ASSERT
Definition Errors.h:68
Definition WorldPacket.h:26
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition WorldSession.cpp:226
@ SMSG_AREA_SPIRIT_HEALER_TIME
Definition Opcodes.h:770

References ASSERT, Player::GetSession(), m_LastResurectTimer, WorldSession::SendPacket(), and SMSG_AREA_SPIRIT_HEALER_TIME.

◆ SendInitWorldStatesToAll()

virtual void Battlefield::SendInitWorldStatesToAll ( )
pure virtual

Send all worldstate data to all player in zone.

Implemented in BattlefieldWG.

Referenced by EndBattle(), and bf_commandscript::HandleBattlefieldTimer().

◆ SendRemoveWorldStates()

virtual void Battlefield::SendRemoveWorldStates ( Player )
inlineprotectedvirtual
413{}

Referenced by HandlePlayerLeaveZone().

◆ SendUpdateWorldState()

void Battlefield::SendUpdateWorldState ( uint32  field,
uint32  value 
)

Update data of a worldstate to all players present in zone.

487{
488 for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
489 for (GuidUnorderedSet::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
490 if (Player* player = ObjectAccessor::FindPlayer(*itr))
491 player->SendUpdateWorldState(field, value);
492}

References ObjectAccessor::FindPlayer(), m_players, and PVP_TEAMS_COUNT.

Referenced by BfWGGameObjectBuilding::Damaged(), BfWGGameObjectBuilding::Destroyed(), WGWorkshop::GiveControlTo(), and BfWGGameObjectBuilding::Rebuild().

◆ SendUpdateWorldStates()

virtual void Battlefield::SendUpdateWorldStates ( Player player = nullptr)
pure virtual

Implemented in BattlefieldWG.

Referenced by EndBattle(), StartBattle(), and Update().

◆ SendWarning()

void Battlefield::SendWarning ( uint8  id,
WorldObject const *  target = nullptr 
)
481{
482 if (Creature* stalker = GetCreature(StalkerGuid))
483 sCreatureTextMgr->SendChat(stalker, id, target);
484}
#define sCreatureTextMgr
Definition CreatureTextMgr.h:119
Creature * GetCreature(ObjectGuid const guid)
Definition Battlefield.cpp:858

References GetCreature(), sCreatureTextMgr, and StalkerGuid.

Referenced by BfWGGameObjectBuilding::Damaged(), BfWGGameObjectBuilding::Destroyed(), WGWorkshop::GiveControlTo(), BattlefieldWG::OnBattleEnd(), BattlefieldWG::OnBattleStart(), BattlefieldWG::OnStartGrouping(), and BattlefieldWG::PromotePlayer().

◆ SetData()

void Battlefield::SetData ( uint32  dataId,
uint32  value 
)
inlineoverridevirtual

Reimplemented from ZoneScript.

271{ m_Data32[dataId] = value; }

References m_Data32.

Referenced by BattlefieldWG::OnBattleStart(), and BattlefieldWG::UpdateCounterVehicle().

◆ SetData64()

void Battlefield::SetData64 ( uint32  dataId,
uint64  value 
)
inlineoverridevirtual

Reimplemented from ZoneScript.

267{ m_Data64[dataId] = value; }

References m_Data64.

◆ SetDefenderTeam()

void Battlefield::SetDefenderTeam ( TeamId  team)
inline
278{ m_DefenderTeam = team; }

References m_DefenderTeam.

Referenced by EndBattle().

◆ SetGraveyardNumber()

void Battlefield::SetGraveyardNumber ( uint32  number)
inline
297{ m_GraveyardList.resize(number); }

References m_GraveyardList.

Referenced by BattlefieldWG::SetupBattlefield().

◆ SetTimer()

void Battlefield::SetTimer ( uint32  timer)
inline
354{ m_Timer = timer; }

References m_Timer.

Referenced by bf_commandscript::HandleBattlefieldTimer().

◆ SetupBattlefield()

virtual bool Battlefield::SetupBattlefield ( )
inlinevirtual

Call this to init the Battlefield.

Reimplemented in BattlefieldWG.

217{ return true; }

Referenced by BattlefieldMgr::InitBattlefield().

◆ ShowNpc()

void Battlefield::ShowNpc ( Creature creature,
bool  aggressive 
)
510{
511 creature->SetPhaseMask(1, false); // pussywizard: false because UpdateObjectVisibility(true) is called below in SetVisible(), no need to have it here
512 creature->SetVisible(true);
514 if (!creature->IsAlive())
515 creature->Respawn(true);
516 if (aggressive)
518 else
519 {
521 creature->SetReactState(REACT_PASSIVE);
522 }
523}
@ REACT_AGGRESSIVE
Definition Unit.h:550
void Respawn(bool force=false)
Definition Creature.cpp:2044
bool IsAlive() const
Definition Unit.h:1707
void RemoveUnitFlag(UnitFlags flags)
UnitFlags available in UnitDefines.h.
Definition Unit.h:720

References Unit::IsAlive(), REACT_AGGRESSIVE, REACT_PASSIVE, Unit::RemoveUnitFlag(), Creature::Respawn(), Unit::SetPhaseMask(), Creature::SetReactState(), Unit::SetUnitFlag(), Unit::SetVisible(), UNIT_FLAG_NON_ATTACKABLE, and UNIT_FLAG_NOT_SELECTABLE.

Referenced by BattlefieldWG::OnBattleEnd(), BattlefieldWG::OnBattleStart(), BfWGGameObjectBuilding::UpdateCreatureAndGo(), and BfWGGameObjectBuilding::UpdateTurretAttack().

◆ SpawnCreature() [1/2]

Creature * Battlefield::SpawnCreature ( uint32  entry,
float  x,
float  y,
float  z,
float  o,
TeamId  teamId 
)
792{
793 //Get map object
794 Map* map = sMapMgr->CreateBaseMap(m_MapId);
795 if (!map)
796 {
797 LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: {} map not found", entry);
798 return nullptr;
799 }
800
801 CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
802 if (!cinfo)
803 {
804 LOG_ERROR("sql.sql", "Battlefield::SpawnCreature: entry {} does not exist.", entry);
805 return nullptr;
806 }
807
808 Creature* creature = new Creature(true);
809 if (!creature->Create(map->GenerateLowGuid<HighGuid::Unit>(), map, PHASEMASK_NORMAL, entry, 0, x, y, z, o))
810 {
811 LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: {}", entry);
812 delete creature;
813 return nullptr;
814 }
815
816 // no need to set faction for neutral team
817 if (teamId == TEAM_ALLIANCE || teamId == TEAM_HORDE)
818 creature->SetFaction(BattlefieldFactions[teamId]);
819
820 creature->SetHomePosition(x, y, z, o);
821
822 // force using DB speeds -- do we really need this?
823 creature->SetSpeed(MOVE_WALK, cinfo->speed_walk);
824 creature->SetSpeed(MOVE_RUN, cinfo->speed_run);
825
826 // Set creature in world
827 map->AddToMap(creature);
828 creature->setActive(true);
829
830 return creature;
831}
const uint32 BattlefieldFactions[PVP_TEAMS_COUNT]
Definition Battlefield.h:58
#define sMapMgr
Definition MapMgr.h:220
#define sObjectMgr
Definition ObjectMgr.h:1636
@ PHASEMASK_NORMAL
Definition Object.h:60
@ MOVE_RUN
Definition UnitDefines.h:350
@ MOVE_WALK
Definition UnitDefines.h:349
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:340
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:1131
Definition Map.h:156
ObjectGuid::LowType GenerateLowGuid()
Definition Map.h:487
bool AddToMap(T *, bool checkTransport=false)
Definition Map.cpp:394
void SetFaction(uint32 faction)
Definition Unit.cpp:10097
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition Unit.cpp:14481
void setActive(bool isActiveObject)
Definition Object.cpp:1094
Definition CreatureData.h:186
float speed_run
Definition CreatureData.h:201
float speed_walk
Definition CreatureData.h:200

References Map::AddToMap(), BattlefieldFactions, Creature::Create(), Map::GenerateLowGuid(), LOG_ERROR, m_MapId, MOVE_RUN, MOVE_WALK, PHASEMASK_NORMAL, WorldObject::setActive(), Unit::SetFaction(), Creature::SetHomePosition(), Unit::SetSpeed(), sMapMgr, sObjectMgr, CreatureTemplate::speed_run, CreatureTemplate::speed_walk, TEAM_ALLIANCE, TEAM_HORDE, and Unit.

Referenced by BfWGGameObjectBuilding::Init(), InitStalker(), BattlefieldWG::SetupBattlefield(), and SpawnCreature().

◆ SpawnCreature() [2/2]

Creature * Battlefield::SpawnCreature ( uint32  entry,
Position  pos,
TeamId  teamId 
)
787{
788 return SpawnCreature(entry, pos.m_positionX, pos.m_positionY, pos.m_positionZ, pos.m_orientation, teamId);
789}
float m_positionZ
Definition Position.h:57
float m_positionX
Definition Position.h:55
float m_positionY
Definition Position.h:56
float m_orientation
Definition Position.h:58

References Position::m_orientation, Position::m_positionX, Position::m_positionY, Position::m_positionZ, and SpawnCreature().

◆ SpawnGameObject()

GameObject * Battlefield::SpawnGameObject ( uint32  entry,
float  x,
float  y,
float  z,
float  o 
)
835{
836 // Get map object
837 Map* map = sMapMgr->CreateBaseMap(m_MapId);
838 if (!map)
839 return 0;
840
841 // Create gameobject
842 GameObject* go = sObjectMgr->IsGameObjectStaticTransport(entry) ? new StaticTransport() : new GameObject();
843 if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, PHASEMASK_NORMAL, x, y, z, o, G3D::Quat(), 100, GO_STATE_READY))
844 {
845 LOG_ERROR("sql.sql", "Battlefield::SpawnGameObject: Gameobject template {} not found in database! Battlefield not created!", entry);
846 LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Cannot create gameobject template {}! Battlefield not created!", entry);
847 delete go;
848 return nullptr;
849 }
850
851 // Add to world
852 map->AddToMap(go);
853 go->setActive(true);
854
855 return go;
856}
@ GO_STATE_READY
Definition GameObjectData.h:690
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:113

References Map::AddToMap(), GameObject::Create(), GameObject, Map::GenerateLowGuid(), GO_STATE_READY, LOG_ERROR, m_MapId, PHASEMASK_NORMAL, WorldObject::setActive(), sMapMgr, and sObjectMgr.

Referenced by BfWGGameObjectBuilding::Init(), BattlefieldWG::OnBattleStart(), and BattlefieldWG::SetupBattlefield().

◆ StartBattle()

void Battlefield::StartBattle ( )
338{
339 if (m_isActive)
340 return;
341
342 for (int team = 0; team < PVP_TEAMS_COUNT; team++)
343 {
344 m_PlayersInWar[team].clear();
345 m_Groups[team].clear();
346 }
347
349 m_isActive = true;
350
353
355
357
359}
@ BF_START
Definition Battlefield.h:53
void InvitePlayersInQueueToWar()
Invite all players in queue to join battle on battle start.
Definition Battlefield.cpp:240
virtual void OnBattleStart()
Called on start.
Definition Battlefield.h:311
void InvitePlayersInZoneToWar()
Invite all players in zone to join battle on battle start.
Definition Battlefield.cpp:261

References BF_START, DoPlaySoundToAll(), InvitePlayersInQueueToWar(), InvitePlayersInZoneToWar(), m_BattleTime, m_Groups, m_isActive, m_PlayersInWar, m_Timer, OnBattleStart(), PVP_TEAMS_COUNT, and SendUpdateWorldStates().

Referenced by bf_commandscript::HandleBattlefieldStart(), and Update().

◆ TeamApplyBuff()

void Battlefield::TeamApplyBuff ( TeamId  team,
uint32  spellId,
uint32  spellId2 = 0 
)

◆ TeamCastSpell()

void Battlefield::TeamCastSpell ( TeamId  team,
int32  spellId 
)
protected
441{
442 if (spellId > 0)
443 {
444 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
445 if (Player* player = ObjectAccessor::FindPlayer(*itr))
446 player->CastSpell(player, uint32(spellId), true);
447 }
448 else
449 {
450 for (GuidUnorderedSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
451 if (Player* player = ObjectAccessor::FindPlayer(*itr))
452 player->RemoveAuraFromStack(uint32(-spellId));
453 }
454}

References ObjectAccessor::FindPlayer(), and m_PlayersInWar.

◆ ToggleBattlefield()

void Battlefield::ToggleBattlefield ( bool  enable)
inline

Enable or Disable battlefield.

250{ m_IsEnabled = enable; }

References m_IsEnabled.

Referenced by bf_commandscript::HandleBattlefieldEnable().

◆ Update()

bool Battlefield::Update ( uint32  diff)
virtual

Called every time for update bf data and time.

  • Update timer for start/end battle
  • Invite player in zone to queue m_StartGroupingTimer minutes before start
  • Kick Afk players
    Parameters
    diff: time ellapsed since last call (in ms)

Reimplemented in BattlefieldWG.

144{
145 if (m_Timer <= diff)
146 {
147 if (!IsEnabled() || (!IsWarTime() && sWorldSessionMgr->GetActiveSessionCount() > 3500)) // if WG is disabled or there is more than 3500 connections, switch automaticly
148 {
149 m_isActive = true;
150 EndBattle(false);
151 return false;
152 }
153 // Battlefield ends on time
154 if (IsWarTime())
155 EndBattle(true);
156 else // Time to start a new battle!
157 StartBattle();
158 }
159 else
160 m_Timer -= diff;
161
162 if (!IsEnabled())
163 return false;
164
165 // Invite players a few minutes before the battle's beginning
167 {
168 m_StartGrouping = true;
172 }
173
174 bool objective_changed = false;
175 if (IsWarTime())
176 {
177 if (m_uiKickAfkPlayersTimer <= diff)
178 {
181 }
182 else
184
185 // Kick players who chose not to accept invitation to the battle
186 if (m_uiKickDontAcceptTimer <= diff)
187 {
188 time_t now = GameTime::GetGameTime().count();
189 for (int team = 0; team < 2; team++)
190 for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr)
191 if (itr->second <= now)
192 KickPlayerFromBattlefield(itr->first);
193
195 for (int team = 0; team < 2; team++)
196 for (PlayerTimerMap::iterator itr = m_PlayersWillBeKick[team].begin(); itr != m_PlayersWillBeKick[team].end(); ++itr)
197 if (itr->second <= now)
198 KickPlayerFromBattlefield(itr->first);
199
201 }
202 else
204
205 for (BfCapturePointVector::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
206 if ((*itr)->Update(diff))
207 objective_changed = true;
208 }
209
210 if (m_LastResurectTimer <= diff)
211 {
212 for (uint8 i = 0; i < m_GraveyardList.size(); i++)
213 if (GetGraveyardById(i))
216 }
217 else
218 m_LastResurectTimer -= diff;
219
220 return objective_changed;
221}
#define sWorldSessionMgr
Definition WorldSessionMgr.h:110
void Resurrect(Creature *target)
Definition bosses_opera.cpp:892
void EndBattle(bool endByTimer)
Definition Battlefield.cpp:361
void InvitePlayersInZoneToQueue()
Invite all players in zone to join the queue, called x minutes before battle start in Update()
Definition Battlefield.cpp:223
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
Definition Battlefield.cpp:328
void StartBattle()
Definition Battlefield.cpp:337
BfGraveyard * GetGraveyardById(uint32 id) const
Definition Battlefield.cpp:588
void KickAfkPlayers()
Definition Battlefield.cpp:318
virtual void OnStartGrouping()
Called x minutes before battle start when player in zone are invite to join queue.
Definition Battlefield.h:315
bool IsEnabled()
Return if battlefield is enable.
Definition Battlefield.h:252

References EndBattle(), GameTime::GetGameTime(), GetGraveyardById(), InvitePlayersInZoneToQueue(), InvitePlayersInZoneToWar(), IsEnabled(), IsWarTime(), KickAfkPlayers(), KickPlayerFromBattlefield(), m_capturePoints, m_GraveyardList, m_InvitedPlayers, m_isActive, m_LastResurectTimer, m_PlayersWillBeKick, m_StartGrouping, m_StartGroupingTimer, m_Timer, m_uiKickAfkPlayersTimer, m_uiKickDontAcceptTimer, OnStartGrouping(), Resurrect(), RESURRECTION_INTERVAL, SendUpdateWorldStates(), StartBattle(), and sWorldSessionMgr.

Referenced by BattlefieldMgr::Update(), and BattlefieldWG::Update().

◆ UpdateData()

virtual void Battlefield::UpdateData ( uint32  index,
int32  pad 
)
inlinevirtual
272{ m_Data32[index] += pad; }

References m_Data32.

Friends And Related Symbol Documentation

◆ BattlefieldMgr

friend class BattlefieldMgr
friend

Member Data Documentation

◆ KickPosition

WorldLocation Battlefield::KickPosition
protected

◆ m_BattleId

◆ m_BattleTime

uint32 Battlefield::m_BattleTime
protected

◆ m_capturePoints

◆ m_Data32

std::vector<uint32> Battlefield::m_Data32
protected

◆ m_Data64

std::vector<uint64> Battlefield::m_Data64
protected

Referenced by GetData64(), and SetData64().

◆ m_DefenderTeam

◆ m_GraveyardList

◆ m_Groups

◆ m_InvitedPlayers

◆ m_isActive

◆ m_IsEnabled

bool Battlefield::m_IsEnabled
protected

◆ m_LastResurectTimer

uint32 Battlefield::m_LastResurectTimer
protected

◆ m_Map

Map* Battlefield::m_Map
protected

◆ m_MapId

◆ m_MaxPlayer

◆ m_MinLevel

uint32 Battlefield::m_MinLevel
protected

◆ m_MinPlayer

uint32 Battlefield::m_MinPlayer
protected

◆ m_NoWarBattleTime

uint32 Battlefield::m_NoWarBattleTime
protected

◆ m_players

◆ m_PlayersInQueue

◆ m_PlayersInWar

◆ m_PlayersWillBeKick

◆ m_RestartAfterCrash

uint32 Battlefield::m_RestartAfterCrash
protected

◆ m_StartGrouping

bool Battlefield::m_StartGrouping
protected

◆ m_StartGroupingTimer

uint32 Battlefield::m_StartGroupingTimer
protected

◆ m_TimeForAcceptInvite

uint32 Battlefield::m_TimeForAcceptInvite
protected

◆ m_Timer

◆ m_TypeId

uint32 Battlefield::m_TypeId
protected

◆ m_uiKickAfkPlayersTimer

uint32 Battlefield::m_uiKickAfkPlayersTimer
protected

Referenced by Battlefield(), and Update().

◆ m_uiKickDontAcceptTimer

uint32 Battlefield::m_uiKickDontAcceptTimer
protected

Referenced by Battlefield(), and Update().

◆ m_ZoneId

◆ StalkerGuid

ObjectGuid Battlefield::StalkerGuid
protected

Referenced by InitStalker(), and SendWarning().


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