TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Battlefield Class Referenceabstract

#include <Battlefield.h>

Public Types

typedef std::map< uint32,
BfCapturePoint * > 
BfCapturePointMap
 typedef of map witch store capturepoint and the associate gameobject entry More...
 

Public Member Functions

 Battlefield ()
 Constructor. More...
 
virtual ~Battlefield ()
 Destructor. More...
 
virtual bool SetupBattlefield ()
 Call this to init the Battlefield. More...
 
void SendUpdateWorldState (uint32 variable, uint32 value, bool hidden=false)
 Update data of a worldstate to all players present in zone. More...
 
virtual bool Update (uint32 diff)
 Called every time for update bf data and time. More...
 
void InvitePlayersInZoneToQueue ()
 Invite all players in zone to join the queue, called x minutes before battle start in Update() More...
 
void InvitePlayersInQueueToWar ()
 Invite all players in queue to join battle on battle start. More...
 
void InvitePlayersInZoneToWar ()
 Invite all players in zone to join battle on battle start. More...
 
virtual void HandleKill (Player *, Unit *)
 Called when a Unit is kill in battlefield zone. More...
 
uint32 GetTypeId () const
 
uint32 GetZoneId () const
 
uint64 GetQueueId () const
 
void TeamApplyBuff (TeamId team, uint32 spellId, uint32 spellId2=0)
 
bool IsWarTime () const
 Return true if battle is start, false if battle is not started. More...
 
int8 GetState () const
 
void ToggleBattlefield (bool enable)
 Enable or Disable battlefield. More...
 
bool IsEnabled () const
 Return if battlefield is enable. More...
 
void KickPlayerFromBattlefield (ObjectGuid guid)
 Kick player from battlefield and teleport him to kick-point location. More...
 
void HandlePlayerEnterZone (Player *player, uint32 zone)
 Called when player (player) enter in zone. More...
 
void HandlePlayerLeaveZone (Player *player, uint32 zone)
 Called when player (player) leave the zone. More...
 
virtual uint64 GetData64 (uint32 dataId) const override
 
virtual void SetData64 (uint32 dataId, uint64 value) override
 
virtual uint32 GetData (uint32 dataId) const override
 
virtual void SetData (uint32 dataId, uint32 value) override
 
virtual void UpdateData (uint32 index, int32 pad)
 
TeamId GetDefenderTeam () const
 
TeamId GetAttackerTeam () const
 
TeamId GetOtherTeam (TeamId team) const
 
void SetDefenderTeam (TeamId team)
 
GroupGetFreeBfRaid (TeamId TeamId)
 Find a not full battlefield group, if there is no, create one. More...
 
GroupGetGroupPlayer (ObjectGuid guid, TeamId TeamId)
 Return battlefield group where player is. More...
 
bool AddOrSetPlayerToCorrectBfGroup (Player *player)
 Force player to join a battlefield group. More...
 
WorldSafeLocsEntry constGetClosestGraveYard (Player *player)
 
virtual void AddPlayerToResurrectQueue (ObjectGuid npc_guid, ObjectGuid player_guid)
 
void RemovePlayerFromResurrectQueue (ObjectGuid player_guid)
 
void SetGraveyardNumber (uint32 number)
 
BfGraveyardGetGraveyardById (uint32 id) const
 
virtual CreatureSpawnCreature (uint32 entry, float x, float y, float z, float o, TeamId)
 
CreatureSpawnCreature (uint32 entry, Position const &pos, TeamId)
 
GameObjectSpawnGameObject (uint32 entry, float x, float y, float z, float o)
 
CreatureGetCreature (ObjectGuid guid)
 
GameObjectGetGameObject (ObjectGuid guid)
 
virtual void OnBattleStart ()
 Called on start. More...
 
virtual void OnBattleEnd (bool)
 Called at the end of battle. More...
 
virtual void OnStartGrouping ()
 Called x minutes before battle start when player in zone are invite to join queue. More...
 
virtual void OnPlayerJoinWar (Player *)
 Called when a player accept to join the battle. More...
 
virtual void OnPlayerLeaveWar (Player *)
 Called when a player leave the battle. More...
 
virtual void OnPlayerLeaveZone (Player *)
 Called when a player leave battlefield zone. More...
 
virtual void OnPlayerEnterZone (Player *)
 Called when a player enter in battlefield zone. More...
 
void SendWarning (uint8 id, WorldObject const *target=nullptr)
 
void PlayerAcceptInviteToQueue (Player *player)
 
void PlayerAcceptInviteToWar (Player *player)
 
uint32 GetBattleId () const
 
void AskToLeaveQueue (Player *player)
 
virtual void DoCompleteOrIncrementAchievement (uint32, Player *, uint8)
 
virtual void SendInitWorldStatesToAll ()=0
 Send all worldstate data to all player in zone. More...
 
virtual void FillInitialWorldStates (WorldPackets::WorldState::InitWorldStates &)=0
 
bool CanFlyIn ()
 Return if we can use mount in battlefield. More...
 
void SendAreaSpiritHealerQueryOpcode (Player *player, ObjectGuid const &guid)
 
void StartBattle ()
 
void EndBattle (bool endByTimer)
 
void HideNpc (Creature *creature)
 
void ShowNpc (Creature *creature, bool aggressive)
 
GraveyardVect GetGraveyardVector () const
 
uint32 GetTimer () const
 
void SetTimer (uint32 timer)
 
void DoPlaySoundToAll (uint32 SoundID)
 
void InvitePlayerToQueue (Player *player)
 
void InvitePlayerToWar (Player *player)
 
void InitStalker (uint32 entry, Position const &pos)
 
- 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 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)
 
BfCapturePointGetCapturePoint (uint32 entry) const
 
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
 
BfCapturePointMap m_capturePoints
 
GuidSet m_players [BG_TEAMS_COUNT]
 
GuidSet m_PlayersInQueue [BG_TEAMS_COUNT]
 
GuidSet m_PlayersInWar [BG_TEAMS_COUNT]
 
PlayerTimerMap m_InvitedPlayers [BG_TEAMS_COUNT]
 
PlayerTimerMap m_PlayersWillBeKick [BG_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_LastResurrectTimer
 
uint32 m_StartGroupingTimer
 
bool m_StartGrouping
 
GuidSet m_Groups [BG_TEAMS_COUNT]
 
std::vector< uint64m_Data64
 
std::vector< uint32m_Data32
 

Friends

class BattlefieldMgr
 

Member Typedef Documentation

typedef of map witch store capturepoint and the associate gameobject entry

Constructor & Destructor Documentation

Battlefield::Battlefield ( )

Constructor.

35 {
36  m_Timer = 0;
37  m_IsEnabled = true;
38  m_isActive = false;
40 
41  m_TypeId = 0;
42  m_BattleId = 0;
43  m_ZoneId = 0;
44  m_Map = NULL;
45  m_MapId = 0;
46  m_MaxPlayer = 0;
47  m_MinPlayer = 0;
48  m_MinLevel = 0;
49  m_BattleTime = 0;
54 
56 
59  m_StartGrouping = false;
60 }
Map * m_Map
Definition: Battlefield.h:379
arena_t NULL
Definition: jemalloc_internal.h:624
uint32 m_BattleId
Definition: Battlefield.h:376
Definition: SharedDefines.h:994
uint32 m_LastResurrectTimer
Definition: Battlefield.h:394
uint32 m_TimeForAcceptInvite
Definition: Battlefield.h:386
uint32 m_StartGroupingTimer
Definition: Battlefield.h:396
uint32 m_Timer
Definition: Battlefield.h:359
uint32 m_MaxPlayer
Definition: Battlefield.h:380
uint32 m_MapId
Definition: Battlefield.h:378
uint32 m_ZoneId
Definition: Battlefield.h:377
uint32 m_uiKickDontAcceptTimer
Definition: Battlefield.h:387
uint32 m_MinPlayer
Definition: Battlefield.h:381
bool m_IsEnabled
Definition: Battlefield.h:360
uint32 m_BattleTime
Definition: Battlefield.h:383
uint32 m_uiKickAfkPlayersTimer
Definition: Battlefield.h:390
Definition: Common.h:103
uint32 m_NoWarBattleTime
Definition: Battlefield.h:384
bool m_StartGrouping
Definition: Battlefield.h:397
bool m_isActive
Definition: Battlefield.h:361
uint32 m_TypeId
Definition: Battlefield.h:375
uint32 m_RestartAfterCrash
Definition: Battlefield.h:385
uint32 m_MinLevel
Definition: Battlefield.h:382
TeamId m_DefenderTeam
Definition: Battlefield.h:362
Battlefield::~Battlefield ( )
virtual

Destructor.

63 {
64  for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
65  delete itr->second;
66 
67  for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr)
68  delete *itr;
69 }
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
BfCapturePointMap m_capturePoints
Definition: Battlefield.h:365

Member Function Documentation

void Battlefield::AddCapturePoint ( BfCapturePoint cp)
protected
449 {
450  Battlefield::BfCapturePointMap::iterator i = m_capturePoints.find(cp->GetCapturePointEntry());
451  if (i != m_capturePoints.end())
452  {
453  TC_LOG_ERROR("bg.battlefield", "Battlefield::AddCapturePoint: CapturePoint %u already exists!", cp->GetCapturePointEntry());
454  delete i->second;
455  }
457 }
BfCapturePointMap m_capturePoints
Definition: Battlefield.h:365
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
uint32 GetCapturePointEntry() const
Definition: Battlefield.h:111

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battlefield::AddOrSetPlayerToCorrectBfGroup ( Player player)

Force player to join a battlefield group.

520 {
521  if (!player->IsInWorld())
522  return false;
523 
524  if (Group* group = player->GetGroup())
525  group->RemoveMember(player->GetGUID());
526 
527  Group* group = GetFreeBfRaid(player->GetTeamId());
528  if (!group)
529  {
530  group = new Group;
531  group->SetBattlefieldGroup(this);
532  group->Create(player);
533  sGroupMgr->AddGroup(group);
534  m_Groups[player->GetTeamId()].insert(group->GetGUID());
535  }
536  else if (group->IsMember(player->GetGUID()))
537  {
538  uint8 subgroup = group->GetMemberGroup(player->GetGUID());
539  player->SetBattlegroundOrBattlefieldRaid(group, subgroup);
540  }
541  else
542  group->AddMember(player);
543 
544  return true;
545 }
ObjectGuid GetGUID() const
Definition: Group.cpp:2534
void SetBattlefieldGroup(Battlefield *bf)
Definition: Group.cpp:2626
bool Create(Player *leader)
Definition: Group.cpp:98
bool AddMember(Player *player)
Definition: Group.cpp:368
GuidSet m_Groups[BG_TEAMS_COUNT]
Definition: Battlefield.h:399
#define sGroupMgr
Definition: GroupMgr.h:59
static Summons Group[]
Definition: boss_urom.cpp:77
bool IsMember(ObjectGuid guid) const
Definition: Group.cpp:2566
Group * GetFreeBfRaid(TeamId TeamId)
Find a not full battlefield group, if there is no, create one.
Definition: Battlefield.cpp:499
uint8 GetMemberGroup(ObjectGuid guid) const
Definition: Group.cpp:2613
uint8_t uint8
Definition: Define.h:152
Definition: Group.h:191

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::AddPlayerToResurrectQueue ( ObjectGuid  npc_guid,
ObjectGuid  player_guid 
)
virtual
598 {
599  for (uint8 i = 0; i < m_GraveyardList.size(); i++)
600  {
601  if (!m_GraveyardList[i])
602  continue;
603 
604  if (m_GraveyardList[i]->HasNpc(npcGuid))
605  {
606  m_GraveyardList[i]->AddPlayer(playerGuid);
607  break;
608  }
609  }
610 }
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
uint8_t uint8
Definition: Define.h:152
void Battlefield::AskToLeaveQueue ( Player player)
369 {
370  // Remove player from queue
371  m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
372 }
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]
Definition: Battlefield.h:369

+ Here is the caller graph for this function:

void Battlefield::BroadcastPacketToQueue ( WorldPacket const data) const
protected
418 {
419  for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
420  for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
421  if (Player* player = ObjectAccessor::FindConnectedPlayer(*itr))
422  player->SendDirectMessage(data);
423 }
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]
Definition: Battlefield.h:369
uint8_t uint8
Definition: Define.h:152
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:215

+ Here is the call graph for this function:

void Battlefield::BroadcastPacketToWar ( WorldPacket const data) const
protected
426 {
427  for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
428  for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
429  if (Player* player = ObjectAccessor::FindPlayer(*itr))
430  player->SendDirectMessage(data);
431 }
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::BroadcastPacketToZone ( WorldPacket const data) const
protected
410 {
411  for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
412  for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
413  if (Player* player = ObjectAccessor::FindPlayer(*itr))
414  player->SendDirectMessage(data);
415 }
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battlefield::CanFlyIn ( )
inline

Return if we can use mount in battlefield.

335 { return !m_isActive; }
bool m_isActive
Definition: Battlefield.h:361

+ Here is the caller graph for this function:

virtual void Battlefield::DoCompleteOrIncrementAchievement ( uint32  ,
Player ,
uint8   
)
inlinevirtual

Reimplemented in BattlefieldWG.

328 { }
void Battlefield::DoPlaySoundToAll ( uint32  SoundID)
349 {
351 }
static ObjectGuid const Empty
Definition: ObjectGuid.h:196
void BroadcastPacketToWar(WorldPacket const *data) const
Definition: Battlefield.cpp:425
Definition: MiscPackets.h:601

+ Here is the call graph for this function:

void Battlefield::EndBattle ( bool  endByTimer)
330 {
331  if (!m_isActive)
332  return;
333 
334  m_isActive = false;
335 
336  m_StartGrouping = false;
337 
338  if (!endByTimer)
340 
341  OnBattleEnd(endByTimer);
342 
343  // Reset battlefield timer
346 }
void SetDefenderTeam(TeamId team)
Definition: Battlefield.h:274
uint32 m_Timer
Definition: Battlefield.h:359
virtual void OnBattleEnd(bool)
Called at the end of battle.
Definition: Battlefield.h:309
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
uint32 m_NoWarBattleTime
Definition: Battlefield.h:384
bool m_StartGrouping
Definition: Battlefield.h:397
virtual void SendInitWorldStatesToAll()=0
Send all worldstate data to all player in zone.
bool m_isActive
Definition: Battlefield.h:361

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Implemented in BattlefieldWG.

TeamId Battlefield::GetAttackerTeam ( ) const
inline
272 { return TeamId(1 - m_DefenderTeam); }
TeamId
Definition: SharedDefines.h:990
TeamId m_DefenderTeam
Definition: Battlefield.h:362

+ Here is the caller graph for this function:

uint32 Battlefield::GetBattleId ( ) const
inline
325 { return m_BattleId; }
uint32 m_BattleId
Definition: Battlefield.h:376
BfCapturePoint * Battlefield::GetCapturePoint ( uint32  entry) const
protected
460 {
461  Battlefield::BfCapturePointMap::const_iterator itr = m_capturePoints.find(entry);
462  if (itr != m_capturePoints.end())
463  return itr->second;
464  return nullptr;
465 }
BfCapturePointMap m_capturePoints
Definition: Battlefield.h:365
WorldSafeLocsEntry const * Battlefield::GetClosestGraveYard ( Player player)
572 {
573  BfGraveyard* closestGY = NULL;
574  float maxdist = -1;
575  for (uint8 i = 0; i < m_GraveyardList.size(); i++)
576  {
577  if (m_GraveyardList[i])
578  {
579  if (m_GraveyardList[i]->GetControlTeamId() != player->GetTeamId())
580  continue;
581 
582  float dist = m_GraveyardList[i]->GetDistance(player);
583  if (dist < maxdist || maxdist < 0)
584  {
585  closestGY = m_GraveyardList[i];
586  maxdist = dist;
587  }
588  }
589  }
590 
591  if (closestGY)
592  return sWorldSafeLocsStore.LookupEntry(closestGY->GetGraveyardId());
593 
594  return NULL;
595 }
DBCStorage< WorldSafeLocsEntry > sWorldSafeLocsStore(WorldSafeLocsfmt)
arena_t NULL
Definition: jemalloc_internal.h:624
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
uint8_t uint8
Definition: Define.h:152
uint32 GetGraveyardId() const
Definition: Battlefield.h:186
Definition: Battlefield.h:149

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Battlefield::GetCreature ( ObjectGuid  guid)
846 {
847  if (!m_Map)
848  return NULL;
849  return m_Map->GetCreature(guid);
850 }
Map * m_Map
Definition: Battlefield.h:379
arena_t NULL
Definition: jemalloc_internal.h:624
Creature * GetCreature(ObjectGuid const &guid)
Definition: Map.cpp:3535

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual uint32 Battlefield::GetData ( uint32  dataId) const
inlineoverridevirtual

Reimplemented from ZoneScript.

Reimplemented in BattlefieldWG.

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

+ Here is the caller graph for this function:

virtual uint64 Battlefield::GetData64 ( uint32  dataId) const
inlineoverridevirtual

Reimplemented from ZoneScript.

262 { return m_Data64[dataId]; }
std::vector< uint64 > m_Data64
Definition: Battlefield.h:401
TeamId Battlefield::GetDefenderTeam ( ) const
inline
271 { return m_DefenderTeam; }
TeamId m_DefenderTeam
Definition: Battlefield.h:362

+ Here is the caller graph for this function:

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())
500 {
501  for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
502  if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
503  if (!group->IsFull())
504  return group;
505 
506  return NULL;
507 }
arena_t NULL
Definition: jemalloc_internal.h:624
GuidSet m_Groups[BG_TEAMS_COUNT]
Definition: Battlefield.h:399
#define sGroupMgr
Definition: GroupMgr.h:59
TeamId
Definition: SharedDefines.h:990
Definition: Group.h:191

+ Here is the caller graph for this function:

GameObject * Battlefield::GetGameObject ( ObjectGuid  guid)
853 {
854  if (!m_Map)
855  return NULL;
856  return m_Map->GetGameObject(guid);
857 }
Map * m_Map
Definition: Battlefield.h:379
arena_t NULL
Definition: jemalloc_internal.h:624
GameObject * GetGameObject(ObjectGuid const &guid)
Definition: Map.cpp:3545

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

BfGraveyard * Battlefield::GetGraveyardById ( uint32  id) const
557 {
558  if (id < m_GraveyardList.size())
559  {
560  if (BfGraveyard* graveyard = m_GraveyardList.at(id))
561  return graveyard;
562  else
563  TC_LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:%u not existed", id);
564  }
565  else
566  TC_LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:%u cant be found", id);
567 
568  return NULL;
569 }
arena_t NULL
Definition: jemalloc_internal.h:624
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
Definition: Battlefield.h:149

+ Here is the caller graph for this function:

GraveyardVect Battlefield::GetGraveyardVector ( ) const
inline
345 { return m_GraveyardList; }
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393

+ Here is the caller graph for this function:

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

Return battlefield group where player is.

510 {
511  for (GuidSet::const_iterator itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
512  if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
513  if (group->IsMember(guid))
514  return group;
515 
516  return NULL;
517 }
arena_t NULL
Definition: jemalloc_internal.h:624
GuidSet m_Groups[BG_TEAMS_COUNT]
Definition: Battlefield.h:399
#define sGroupMgr
Definition: GroupMgr.h:59
TeamId
Definition: SharedDefines.h:990
Definition: Group.h:191
TeamId Battlefield::GetOtherTeam ( TeamId  team) const
inline
273 { return (team == TEAM_HORDE ? TEAM_ALLIANCE : TEAM_HORDE); }
Definition: SharedDefines.h:992
Definition: SharedDefines.h:993

+ Here is the caller graph for this function:

uint64 Battlefield::GetQueueId ( ) const
inline
236 { return MAKE_PAIR64(m_BattleId | 0x20000, 0x1F100000); }
uint64 MAKE_PAIR64(uint32 l, uint32 h)
Definition: ObjectDefines.h:34
uint32 m_BattleId
Definition: Battlefield.h:376

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

int8 Battlefield::GetState ( ) const
inline
Definition: Battlefield.h:41
uint32 m_StartGroupingTimer
Definition: Battlefield.h:396
uint32 m_Timer
Definition: Battlefield.h:359
Definition: Battlefield.h:42
Definition: Battlefield.h:40
bool m_isActive
Definition: Battlefield.h:361

+ Here is the caller graph for this function:

uint32 Battlefield::GetTimer ( ) const
inline
347 { return m_Timer; }
uint32 m_Timer
Definition: Battlefield.h:359

+ Here is the caller graph for this function:

uint32 Battlefield::GetTypeId ( ) const
inline
234 { return m_TypeId; }
uint32 m_TypeId
Definition: Battlefield.h:375

+ Here is the caller graph for this function:

uint32 Battlefield::GetZoneId ( ) const
inline
235 { return m_ZoneId; }
uint32 m_ZoneId
Definition: Battlefield.h:377

+ Here is the caller graph for this function:

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

Called when a Unit is kill in battlefield zone.

Reimplemented in BattlefieldWG.

232 { };
void Battlefield::HandlePlayerEnterZone ( Player player,
uint32  zone 
)

Called when player (player) enter in zone.

Todo:
Send a packet to announce it to player
73 {
74  // If battle is started,
75  // If not full of players > invite player to join the war
76  // If full of players > announce to player that BF is full and kick him after a few second if he desn't leave
77  if (IsWarTime())
78  {
79  if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) // Vacant spaces
80  InvitePlayerToWar(player);
81  else // No more vacant places
82  {
84  m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
85  InvitePlayerToQueue(player);
86  }
87  }
88  else
89  {
90  // If time left is < 15 minutes invite player to join queue
92  InvitePlayerToQueue(player);
93  }
94 
95  // Add player in the list of player in zone
96  m_players[player->GetTeamId()].insert(player->GetGUID());
97  OnPlayerEnterZone(player);
98 }
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT]
Definition: Battlefield.h:372
arena_t NULL
Definition: jemalloc_internal.h:624
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]
Definition: Battlefield.h:371
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint32 m_StartGroupingTimer
Definition: Battlefield.h:396
uint32 m_Timer
Definition: Battlefield.h:359
uint32 m_MaxPlayer
Definition: Battlefield.h:380
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
virtual void OnPlayerEnterZone(Player *)
Called when a player enter in battlefield zone.
Definition: Battlefield.h:319
void InvitePlayerToWar(Player *player)
Definition: Battlefield.cpp:253
void InvitePlayerToQueue(Player *player)
Definition: Battlefield.cpp:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Called when player (player) leave the zone.

102 {
103  if (IsWarTime())
104  {
105  // If the player is participating to the battle
106  if (m_PlayersInWar[player->GetTeamId()].find(player->GetGUID()) != m_PlayersInWar[player->GetTeamId()].end())
107  {
108  m_PlayersInWar[player->GetTeamId()].erase(player->GetGUID());
109  player->GetSession()->SendBfLeaveMessage(GetQueueId(), GetState(), player->GetZoneId() == GetZoneId());
110  if (Group* group = player->GetGroup()) // Remove the player from the raid group
111  group->RemoveMember(player->GetGUID());
112 
113  OnPlayerLeaveWar(player);
114  }
115  }
116 
117  for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
118  itr->second->HandlePlayerLeave(player);
119 
120  m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
121  m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
122  m_players[player->GetTeamId()].erase(player->GetGUID());
123  SendRemoveWorldStates(player);
124  RemovePlayerFromResurrectQueue(player->GetGUID());
125  OnPlayerLeaveZone(player);
126 }
virtual void OnPlayerLeaveWar(Player *)
Called when a player leave the battle.
Definition: Battlefield.h:315
int8 GetState() const
Definition: Battlefield.h:243
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT]
Definition: Battlefield.h:372
virtual void OnPlayerLeaveZone(Player *)
Called when a player leave battlefield zone.
Definition: Battlefield.h:317
virtual void SendRemoveWorldStates(Player *)
Definition: Battlefield.h:407
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]
Definition: Battlefield.h:371
void RemovePlayerFromResurrectQueue(ObjectGuid player_guid)
Definition: Battlefield.cpp:612
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
BfCapturePointMap m_capturePoints
Definition: Battlefield.h:365
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
uint64 GetQueueId() const
Definition: Battlefield.h:236
uint32 GetZoneId() const
Definition: Battlefield.h:235
Definition: Group.h:191

+ Here is the call graph for this function:

bool Battlefield::HasPlayer ( Player player) const
protected
354 {
355  return m_players[player->GetTeamId()].find(player->GetGUID()) != m_players[player->GetTeamId()].end();
356 }
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368

+ Here is the caller graph for this function:

void Battlefield::HideNpc ( Creature creature)
473 {
474  creature->CombatStop();
475  creature->SetReactState(REACT_PASSIVE);
477  creature->DisappearAndDie();
478  creature->SetVisible(false);
479 }
Definition: Unit.h:674
Definition: Unit.h:1129
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
void SetVisible(bool x)
Definition: Unit.cpp:10368
Definition: UpdateFields.h:109
void CombatStop(bool includingCast=false)
Definition: Unit.cpp:7371
void DisappearAndDie()
Definition: Creature.cpp:256
void SetReactState(ReactStates st)
Definition: Creature.h:502
Definition: Unit.h:698

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::InitStalker ( uint32  entry,
Position const pos 
)
286 {
287  if (Creature* creature = SpawnCreature(entry, pos, TEAM_NEUTRAL))
288  StalkerGuid = creature->GetGUID();
289  else
290  TC_LOG_ERROR("bg.battlefield", "Battlefield::InitStalker: could not spawn Stalker (Creature entry %u), zone messeges will be un-available", entry);
291 }
Definition: Creature.h:467
Definition: SharedDefines.h:994
virtual Creature * SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId)
Definition: Battlefield.cpp:777
ObjectGuid StalkerGuid
Definition: Battlefield.h:358
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::InvitePlayersInQueueToWar ( )

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

217 {
218  for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
219  {
220  for (GuidSet::const_iterator itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
221  {
222  if (Player* player = ObjectAccessor::FindPlayer(*itr))
223  {
224  if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
225  InvitePlayerToWar(player);
226  else
227  {
228  //Full
229  }
230  }
231  }
232  m_PlayersInQueue[team].clear();
233  }
234 }
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]
Definition: Battlefield.h:371
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]
Definition: Battlefield.h:369
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint32 m_MaxPlayer
Definition: Battlefield.h:380
uint8_t uint8
Definition: Define.h:152
void InvitePlayerToWar(Player *player)
Definition: Battlefield.cpp:253

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::InvitePlayersInZoneToQueue ( )

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

200 {
201  for (uint8 team = 0; team < 2; ++team)
202  for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
203  if (Player* player = ObjectAccessor::FindPlayer(*itr))
204  InvitePlayerToQueue(player);
205 }
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
uint8_t uint8
Definition: Define.h:152
void InvitePlayerToQueue(Player *player)
Definition: Battlefield.cpp:207

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::InvitePlayersInZoneToWar ( )

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

237 {
238  for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
239  for (GuidSet::const_iterator itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
240  {
241  if (Player* player = ObjectAccessor::FindPlayer(*itr))
242  {
243  if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
244  continue;
245  if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
246  InvitePlayerToWar(player);
247  else // Battlefield is full of players
248  m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
249  }
250  }
251 }
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT]
Definition: Battlefield.h:372
arena_t NULL
Definition: jemalloc_internal.h:624
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]
Definition: Battlefield.h:371
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint32 m_MaxPlayer
Definition: Battlefield.h:380
GuidSet m_players[BG_TEAMS_COUNT]
Definition: Battlefield.h:368
uint8_t uint8
Definition: Define.h:152
void InvitePlayerToWar(Player *player)
Definition: Battlefield.cpp:253

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::InvitePlayerToQueue ( Player player)
208 {
209  if (m_PlayersInQueue[player->GetTeamId()].count(player->GetGUID()))
210  return;
211 
212  if (m_PlayersInQueue[player->GetTeamId()].size() <= m_MinPlayer || m_PlayersInQueue[GetOtherTeam(player->GetTeamId())].size() >= m_MinPlayer)
213  player->GetSession()->SendBfInvitePlayerToQueue(GetQueueId(), GetState());
214 }
TeamId GetOtherTeam(TeamId team) const
Definition: Battlefield.h:273
int8 GetState() const
Definition: Battlefield.h:243
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]
Definition: Battlefield.h:369
uint32 m_MinPlayer
Definition: Battlefield.h:381
uint64 GetQueueId() const
Definition: Battlefield.h:236

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::InvitePlayerToWar ( Player player)
Todo:
needed ?
254 {
255  if (!player)
256  return;
257 
259  if (player->IsInFlight())
260  return;
261 
262  if (player->InArena() || player->GetBattleground())
263  {
264  m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
265  return;
266  }
267 
268  // If the player does not match minimal level requirements for the battlefield, kick him
269  if (player->getLevel() < m_MinLevel)
270  {
271  if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)
272  m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = time(NULL) + 10;
273  return;
274  }
275 
276  // Check if player is not already in war
277  if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
278  return;
279 
280  m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
281  m_InvitedPlayers[player->GetTeamId()][player->GetGUID()] = time(NULL) + m_TimeForAcceptInvite;
282  player->GetSession()->SendBfInvitePlayerToWar(GetQueueId(), m_ZoneId, m_TimeForAcceptInvite);
283 }
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT]
Definition: Battlefield.h:372
arena_t NULL
Definition: jemalloc_internal.h:624
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]
Definition: Battlefield.h:371
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]
Definition: Battlefield.h:369
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint32 m_TimeForAcceptInvite
Definition: Battlefield.h:386
uint32 m_ZoneId
Definition: Battlefield.h:377
uint64 GetQueueId() const
Definition: Battlefield.h:236
uint32 m_MinLevel
Definition: Battlefield.h:382

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

bool Battlefield::IsEnabled ( ) const
inline

Return if battlefield is enable.

248 { return m_IsEnabled; }
bool m_IsEnabled
Definition: Battlefield.h:360

+ Here is the caller graph for this function:

bool Battlefield::IsWarTime ( ) const
inline

Return true if battle is start, false if battle is not started.

241 { return m_isActive; }
bool m_isActive
Definition: Battlefield.h:361

+ Here is the caller graph for this function:

void Battlefield::KickAfkPlayers ( )
protected
294 {
295  for (uint8 team = 0; team < BG_TEAMS_COUNT; ++team)
296  for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
297  if (Player* player = ObjectAccessor::FindPlayer(*itr))
298  if (player->isAFK())
300 }
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint8_t uint8
Definition: Define.h:152
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
Definition: Battlefield.cpp:302

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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
303 {
304  if (Player* player = ObjectAccessor::FindPlayer(guid))
305  if (player->GetZoneId() == GetZoneId())
306  player->TeleportTo(KickPosition);
307 }
WorldLocation KickPosition
Definition: Battlefield.h:388
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
uint32 GetZoneId() const
Definition: Battlefield.h:235

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Battlefield::OnBattleEnd ( bool  )
inlinevirtual

Called at the end of battle.

Reimplemented in BattlefieldWG.

309 { }

+ Here is the caller graph for this function:

virtual void Battlefield::OnBattleStart ( )
inlinevirtual

Called on start.

Reimplemented in BattlefieldWG.

307 { }

+ Here is the caller graph for this function:

virtual void Battlefield::OnPlayerEnterZone ( Player )
inlinevirtual

Called when a player enter in battlefield zone.

Reimplemented in BattlefieldWG.

319 { }

+ Here is the caller graph for this function:

virtual void Battlefield::OnPlayerJoinWar ( Player )
inlinevirtual

Called when a player accept to join the battle.

Reimplemented in BattlefieldWG.

313 { }

+ Here is the caller graph for this function:

virtual void Battlefield::OnPlayerLeaveWar ( Player )
inlinevirtual

Called when a player leave the battle.

Reimplemented in BattlefieldWG.

315 { }

+ Here is the caller graph for this function:

virtual void Battlefield::OnPlayerLeaveZone ( Player )
inlinevirtual

Called when a player leave battlefield zone.

Reimplemented in BattlefieldWG.

317 { }

+ Here is the caller graph for this function:

virtual void Battlefield::OnStartGrouping ( )
inlinevirtual

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

Reimplemented in BattlefieldWG.

311 { }

+ Here is the caller graph for this function:

void Battlefield::PlayerAcceptInviteToQueue ( Player player)
360 {
361  // Add player in queue
362  m_PlayersInQueue[player->GetTeamId()].insert(player->GetGUID());
363  // Send notification
364  player->GetSession()->SendBfQueueInviteResponse(GetQueueId(), m_ZoneId, GetState());
365 }
int8 GetState() const
Definition: Battlefield.h:243
GuidSet m_PlayersInQueue[BG_TEAMS_COUNT]
Definition: Battlefield.h:369
uint32 m_ZoneId
Definition: Battlefield.h:377
uint64 GetQueueId() const
Definition: Battlefield.h:236

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::PlayerAcceptInviteToWar ( Player player)
376 {
377  if (!IsWarTime())
378  return;
379 
380  if (AddOrSetPlayerToCorrectBfGroup(player))
381  {
382  player->GetSession()->SendBfEntered(GetQueueId(), player->GetZoneId() != GetZoneId(), player->GetTeamId() == GetAttackerTeam());
383  m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID());
384  m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
385 
386  if (player->isAFK())
387  player->ToggleAFK();
388 
389  OnPlayerJoinWar(player); //for scripting
390  }
391 }
bool AddOrSetPlayerToCorrectBfGroup(Player *player)
Force player to join a battlefield group.
Definition: Battlefield.cpp:519
virtual void OnPlayerJoinWar(Player *)
Called when a player accept to join the battle.
Definition: Battlefield.h:313
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]
Definition: Battlefield.h:371
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
TeamId GetAttackerTeam() const
Definition: Battlefield.h:272
uint64 GetQueueId() const
Definition: Battlefield.h:236
uint32 GetZoneId() const
Definition: Battlefield.h:235

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::RegisterZone ( uint32  zoneid)
protected
468 {
469  sBattlefieldMgr->AddZone(zoneId, this);
470 }
#define sBattlefieldMgr
Definition: BattlefieldMgr.h:67

+ Here is the caller graph for this function:

void Battlefield::RemovePlayerFromResurrectQueue ( ObjectGuid  player_guid)
613 {
614  for (uint8 i = 0; i < m_GraveyardList.size(); i++)
615  {
616  if (!m_GraveyardList[i])
617  continue;
618 
619  if (m_GraveyardList[i]->HasPlayer(playerGuid))
620  {
621  m_GraveyardList[i]->RemovePlayer(playerGuid);
622  break;
623  }
624  }
625 }
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
bool HasPlayer(Player *player) const
Definition: Battlefield.cpp:353
uint8_t uint8
Definition: Define.h:152

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::SendAreaSpiritHealerQueryOpcode ( Player player,
ObjectGuid const guid 
)
628 {
630  areaSpiritHealerTime.HealerGuid = guid;
631  areaSpiritHealerTime.TimeLeft = m_LastResurrectTimer;
632  player->SendDirectMessage(areaSpiritHealerTime.Write());
633 }
int32 TimeLeft
Definition: BattlegroundPackets.h:70
Definition: BattlegroundPackets.h:62
uint32 m_LastResurrectTimer
Definition: Battlefield.h:394
ObjectGuid HealerGuid
Definition: BattlegroundPackets.h:69
WorldPacket const * Write() override
Definition: BattlegroundPackets.cpp:38

+ Here is the call graph for this function:

virtual void Battlefield::SendInitWorldStatesToAll ( )
pure virtual

Send all worldstate data to all player in zone.

Implemented in BattlefieldWG.

+ Here is the caller graph for this function:

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

+ Here is the caller graph for this function:

void Battlefield::SendUpdateWorldState ( uint32  variable,
uint32  value,
bool  hidden = false 
)

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

440 {
442  worldstate.VariableID = variable;
443  worldstate.Value = value;
444  worldstate.Hidden = hidden;
445  BroadcastPacketToZone(worldstate.Write());
446 }
uint32 VariableID
Definition: WorldStatePackets.h:59
Definition: WorldStatePackets.h:50
void BroadcastPacketToZone(WorldPacket const *data) const
Definition: Battlefield.cpp:409
int32 Value
Definition: WorldStatePackets.h:57
const FieldDescriptor value
Definition: descriptor.h:1522
bool Hidden
Definition: WorldStatePackets.h:58
WorldPacket const * Write() override
Definition: WorldStatePackets.cpp:44

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::SendWarning ( uint8  id,
WorldObject const target = nullptr 
)
434 {
435  if (Creature* stalker = GetCreature(StalkerGuid))
436  sCreatureTextMgr->SendChat(stalker, id, target);
437 }
Definition: Creature.h:467
#define sCreatureTextMgr
Definition: CreatureTextMgr.h:113
Creature * GetCreature(ObjectGuid guid)
Definition: Battlefield.cpp:845
ObjectGuid StalkerGuid
Definition: Battlefield.h:358

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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

Reimplemented from ZoneScript.

267 { m_Data32[dataId] = value; }
std::vector< uint32 > m_Data32
Definition: Battlefield.h:402
const FieldDescriptor value
Definition: descriptor.h:1522

+ Here is the caller graph for this function:

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

Reimplemented from ZoneScript.

263 { m_Data64[dataId] = value; }
std::vector< uint64 > m_Data64
Definition: Battlefield.h:401
const FieldDescriptor value
Definition: descriptor.h:1522
void Battlefield::SetDefenderTeam ( TeamId  team)
inline
274 { m_DefenderTeam = team; }
TeamId m_DefenderTeam
Definition: Battlefield.h:362

+ Here is the caller graph for this function:

void Battlefield::SetGraveyardNumber ( uint32  number)
inline
293 { m_GraveyardList.resize(number); }
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393

+ Here is the caller graph for this function:

void Battlefield::SetTimer ( uint32  timer)
inline
348 { m_Timer = timer; }
uint32 m_Timer
Definition: Battlefield.h:359

+ Here is the caller graph for this function:

virtual bool Battlefield::SetupBattlefield ( )
inlinevirtual

Call this to init the Battlefield.

Reimplemented in BattlefieldWG.

210 { return true; }

+ Here is the caller graph for this function:

void Battlefield::ShowNpc ( Creature creature,
bool  aggressive 
)
482 {
483  creature->SetVisible(true);
485  if (!creature->IsAlive())
486  creature->Respawn(true);
487  if (aggressive)
488  creature->SetReactState(REACT_AGGRESSIVE);
489  else
490  {
492  creature->SetReactState(REACT_PASSIVE);
493  }
494 }
Definition: Unit.h:674
Definition: Unit.h:1131
Definition: Unit.h:1129
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:1199
bool IsAlive() const
Definition: Unit.h:1692
void SetVisible(bool x)
Definition: Unit.cpp:10368
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:1214
void Respawn(bool force=false)
Definition: Creature.cpp:1697
Definition: UpdateFields.h:109
void SetReactState(ReactStates st)
Definition: Creature.h:502
Definition: Unit.h:698

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Battlefield::SpawnCreature ( uint32  entry,
float  x,
float  y,
float  z,
float  o,
TeamId   
)
virtual
778 {
779  //Get map object
780  Map* map = sMapMgr->CreateBaseMap(m_MapId);
781  if (!map)
782  {
783  TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u map not found", entry);
784  return nullptr;
785  }
786 
787  CreatureTemplate const* cinfo = sObjectMgr->GetCreatureTemplate(entry);
788  if (!cinfo)
789  {
790  TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry %u does not exist.", entry);
791  return nullptr;
792  }
793 
794  Creature* creature = new Creature();
795  if (!creature->Create(map->GenerateLowGuid<HighGuid::Creature>(), map, PHASEMASK_NORMAL, entry, x, y, z, o))
796  {
797  TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: %u", entry);
798  delete creature;
799  return nullptr;
800  }
801 
802  creature->SetHomePosition(x, y, z, o);
803 
804  // Set creature in world
805  map->AddToMap(creature);
806  creature->setActive(true);
807 
808  return creature;
809 }
void setActive(bool isActiveObject)
Definition: Object.cpp:1473
bool Create(ObjectGuid::LowType guidlow, Map *map, uint32 phaseMask, uint32 entry, float x, float y, float z, float ang, CreatureData const *data=nullptr, uint32 vehId=0)
Definition: Creature.cpp:834
void SetHomePosition(float x, float y, float z, float o)
Definition: Creature.h:670
Definition: Creature.h:467
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Object.h:66
G3D::int16 z
Definition: Vector3int16.h:46
bool AddToMap(T *)
Definition: Map.cpp:566
uint32 m_MapId
Definition: Battlefield.h:378
G3D::int16 y
Definition: Vector2int16.h:38
Definition: Map.h:259
#define sMapMgr
Definition: MapManager.h:194
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561
Definition: Creature.h:79

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Creature * Battlefield::SpawnCreature ( uint32  entry,
Position const pos,
TeamId  teamId 
)
773 {
774  return SpawnCreature(entry, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation(), teamId);
775 }
virtual Creature * SpawnCreature(uint32 entry, float x, float y, float z, float o, TeamId)
Definition: Battlefield.cpp:777

+ Here is the call graph for this function:

GameObject * Battlefield::SpawnGameObject ( uint32  entry,
float  x,
float  y,
float  z,
float  o 
)
813 {
814  // Get map object
815  Map* map = sMapMgr->CreateBaseMap(m_MapId);
816  if (!map)
817  {
818  TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Can't create GameObject (Entry: %u). Map not found.", entry);
819  return nullptr;
820  }
821 
822  GameObjectTemplate const* goInfo = sObjectMgr->GetGameObjectTemplate(entry);
823  if (!goInfo)
824  {
825  TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: GameObject template %u not found in database! Battlefield not created!", entry);
826  return nullptr;
827  }
828 
829  // Create gameobject
830  GameObject* go = new GameObject;
831  if (!go->Create(map->GenerateLowGuid<HighGuid::GameObject>(), entry, map, PHASEMASK_NORMAL, x, y, z, o, 0, 0, 0, 0, 100, GO_STATE_READY))
832  {
833  TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Cannot create gameobject template %u! Battlefield not created!", entry);
834  delete go;
835  return nullptr;
836  }
837 
838  // Add to world
839  map->AddToMap(go);
840  go->setActive(true);
841 
842  return go;
843 }
void setActive(bool isActiveObject)
Definition: Object.cpp:1473
Definition: GameObject.h:34
#define sObjectMgr
Definition: ObjectMgr.h:1567
Definition: Object.h:66
G3D::int16 z
Definition: Vector3int16.h:46
bool AddToMap(T *)
Definition: Map.cpp:566
uint32 m_MapId
Definition: Battlefield.h:378
G3D::int16 y
Definition: Vector2int16.h:38
Definition: GameObject.h:880
Definition: Map.h:259
Definition: GameObject.h:823
bool Create(ObjectGuid::LowType guidlow, uint32 name_id, Map *map, uint32 phaseMask, float x, float y, float z, float ang, float rotation0, float rotation1, float rotation2, float rotation3, uint32 animprogress, GOState go_state, uint32 artKit=0)
Definition: GameObject.cpp:173
#define sMapMgr
Definition: MapManager.h:194
#define TC_LOG_ERROR(filterType__,...)
Definition: Log.h:207
G3D::int16 x
Definition: Vector2int16.h:37
ObjectGuid::LowType GenerateLowGuid()
Definition: Map.h:561

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::StartBattle ( )
310 {
311  if (m_isActive)
312  return;
313 
314  for (int team = 0; team < BG_TEAMS_COUNT; team++)
315  {
316  m_PlayersInWar[team].clear();
317  m_Groups[team].clear();
318  }
319 
321  m_isActive = true;
322 
325 
326  OnBattleStart();
327 }
void InvitePlayersInQueueToWar()
Invite all players in queue to join battle on battle start.
Definition: Battlefield.cpp:216
virtual void OnBattleStart()
Called on start.
Definition: Battlefield.h:307
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
GuidSet m_Groups[BG_TEAMS_COUNT]
Definition: Battlefield.h:399
uint32 m_Timer
Definition: Battlefield.h:359
void InvitePlayersInZoneToWar()
Invite all players in zone to join battle on battle start.
Definition: Battlefield.cpp:236
uint32 m_BattleTime
Definition: Battlefield.h:383
bool m_isActive
Definition: Battlefield.h:361

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

void Battlefield::TeamApplyBuff ( TeamId  team,
uint32  spellId,
uint32  spellId2 = 0 
)
void Battlefield::TeamCastSpell ( TeamId  team,
int32  spellId 
)
protected
394 {
395  if (spellId > 0)
396  {
397  for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
398  if (Player* player = ObjectAccessor::FindPlayer(*itr))
399  player->CastSpell(player, uint32(spellId), true);
400  }
401  else
402  {
403  for (GuidSet::const_iterator itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
404  if (Player* player = ObjectAccessor::FindPlayer(*itr))
405  player->RemoveAuraFromStack(uint32(-spellId));
406  }
407 }
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
Definition: ObjectAccessor.cpp:209
GuidSet m_PlayersInWar[BG_TEAMS_COUNT]
Definition: Battlefield.h:370
uint32_t uint32
Definition: Define.h:150

+ Here is the call graph for this function:

void Battlefield::ToggleBattlefield ( bool  enable)
inline

Enable or Disable battlefield.

246 { m_IsEnabled = enable; }
bool m_IsEnabled
Definition: Battlefield.h:360

+ Here is the caller graph for this function:

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.

129 {
130  if (m_Timer <= diff)
131  {
132  // Battlefield ends on time
133  if (IsWarTime())
134  EndBattle(true);
135  else // Time to start a new battle!
136  StartBattle();
137  }
138  else
139  m_Timer -= diff;
140 
141  // Invite players a few minutes before the battle's beginning
143  {
144  m_StartGrouping = true;
146  OnStartGrouping();
147  }
148 
149  bool objective_changed = false;
150  if (IsWarTime())
151  {
152  if (m_uiKickAfkPlayersTimer <= diff)
153  {
155  KickAfkPlayers();
156  }
157  else
158  m_uiKickAfkPlayersTimer -= diff;
159 
160  // Kick players who chose not to accept invitation to the battle
161  if (m_uiKickDontAcceptTimer <= diff)
162  {
163  time_t now = time(NULL);
164  for (int team = 0; team < 2; team++)
165  for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr)
166  if (itr->second <= now)
167  KickPlayerFromBattlefield(itr->first);
168 
170  for (int team = 0; team < 2; team++)
171  for (PlayerTimerMap::iterator itr = m_PlayersWillBeKick[team].begin(); itr != m_PlayersWillBeKick[team].end(); ++itr)
172  if (itr->second <= now)
173  KickPlayerFromBattlefield(itr->first);
174 
176  }
177  else
178  m_uiKickDontAcceptTimer -= diff;
179 
180  for (BfCapturePointMap::iterator itr = m_capturePoints.begin(); itr != m_capturePoints.end(); ++itr)
181  if (itr->second->Update(diff))
182  objective_changed = true;
183  }
184 
185 
186  if (m_LastResurrectTimer <= diff)
187  {
188  for (uint8 i = 0; i < m_GraveyardList.size(); i++)
189  if (GetGraveyardById(i))
192  }
193  else
194  m_LastResurrectTimer -= diff;
195 
196  return objective_changed;
197 }
void InvitePlayersInZoneToQueue()
Invite all players in zone to join the queue, called x minutes before battle start in Update() ...
Definition: Battlefield.cpp:199
Definition: Battleground.h:122
void KickAfkPlayers()
Definition: Battlefield.cpp:293
PlayerTimerMap m_PlayersWillBeKick[BG_TEAMS_COUNT]
Definition: Battlefield.h:372
arena_t NULL
Definition: jemalloc_internal.h:624
GraveyardVect m_GraveyardList
Definition: Battlefield.h:393
PlayerTimerMap m_InvitedPlayers[BG_TEAMS_COUNT]
Definition: Battlefield.h:371
uint32 m_LastResurrectTimer
Definition: Battlefield.h:394
BfCapturePointMap m_capturePoints
Definition: Battlefield.h:365
virtual void OnStartGrouping()
Called x minutes before battle start when player in zone are invite to join queue.
Definition: Battlefield.h:311
void EndBattle(bool endByTimer)
Definition: Battlefield.cpp:329
uint32 m_StartGroupingTimer
Definition: Battlefield.h:396
void Resurrect(Creature *target)
Definition: bosses_opera.cpp:1037
uint32 m_Timer
Definition: Battlefield.h:359
void InvitePlayersInZoneToWar()
Invite all players in zone to join battle on battle start.
Definition: Battlefield.cpp:236
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
Definition: Battlefield.h:241
BfGraveyard * GetGraveyardById(uint32 id) const
Definition: Battlefield.cpp:556
uint32 m_uiKickDontAcceptTimer
Definition: Battlefield.h:387
void StartBattle()
Definition: Battlefield.cpp:309
uint32 m_uiKickAfkPlayersTimer
Definition: Battlefield.h:390
uint8_t uint8
Definition: Define.h:152
bool m_StartGrouping
Definition: Battlefield.h:397
void KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
Definition: Battlefield.cpp:302

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

virtual void Battlefield::UpdateData ( uint32  index,
int32  pad 
)
inlinevirtual
268 { m_Data32[index] += pad; }
IntFormatSpec< int, AlignTypeSpec< TYPE_CODE >, Char > pad(int value, unsigned width, Char fill= ' ')
std::vector< uint32 > m_Data32
Definition: Battlefield.h:402

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Friends And Related Function Documentation

friend class BattlefieldMgr
friend

Member Data Documentation

WorldLocation Battlefield::KickPosition
protected
uint32 Battlefield::m_BattleId
protected
uint32 Battlefield::m_BattleTime
protected
BfCapturePointMap Battlefield::m_capturePoints
protected
std::vector<uint32> Battlefield::m_Data32
protected
std::vector<uint64> Battlefield::m_Data64
protected
TeamId Battlefield::m_DefenderTeam
protected
GraveyardVect Battlefield::m_GraveyardList
protected
GuidSet Battlefield::m_Groups[BG_TEAMS_COUNT]
protected
PlayerTimerMap Battlefield::m_InvitedPlayers[BG_TEAMS_COUNT]
protected
bool Battlefield::m_isActive
protected
bool Battlefield::m_IsEnabled
protected
uint32 Battlefield::m_LastResurrectTimer
protected
Map* Battlefield::m_Map
protected
uint32 Battlefield::m_MapId
protected
uint32 Battlefield::m_MaxPlayer
protected
uint32 Battlefield::m_MinLevel
protected
uint32 Battlefield::m_MinPlayer
protected
uint32 Battlefield::m_NoWarBattleTime
protected
GuidSet Battlefield::m_players[BG_TEAMS_COUNT]
protected
GuidSet Battlefield::m_PlayersInQueue[BG_TEAMS_COUNT]
protected
GuidSet Battlefield::m_PlayersInWar[BG_TEAMS_COUNT]
protected
PlayerTimerMap Battlefield::m_PlayersWillBeKick[BG_TEAMS_COUNT]
protected
uint32 Battlefield::m_RestartAfterCrash
protected
bool Battlefield::m_StartGrouping
protected
uint32 Battlefield::m_StartGroupingTimer
protected
uint32 Battlefield::m_TimeForAcceptInvite
protected
uint32 Battlefield::m_Timer
protected
uint32 Battlefield::m_TypeId
protected
uint32 Battlefield::m_uiKickAfkPlayersTimer
protected
uint32 Battlefield::m_uiKickDontAcceptTimer
protected
uint32 Battlefield::m_ZoneId
protected
ObjectGuid Battlefield::StalkerGuid
protected

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