TrinityCore
Loading...
Searching...
No Matches
Battlefield.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "Battlefield.h"
19#include "BattlefieldMgr.h"
20#include "Battleground.h"
21#include "BattlegroundPackets.h"
22#include "CellImpl.h"
23#include "CreatureTextMgr.h"
24#include "GameTime.h"
25#include "GridNotifiers.h"
26#include "GridNotifiersImpl.h"
27#include "Group.h"
28#include "GroupMgr.h"
29#include "Log.h"
30#include "Map.h"
31#include "MiscPackets.h"
32#include "ObjectAccessor.h"
33#include "ObjectMgr.h"
34#include <G3D/g3dmath.h>
35
37{
38 m_Timer = 0;
39 m_IsEnabled = true;
40 m_isActive = false;
42
43 m_TypeId = 0;
44 m_BattleId = 0;
45 m_ZoneId = 0;
46 m_Map = map;
47 m_MapId = map->GetId();
48 m_MaxPlayer = 0;
49 m_MinPlayer = 0;
50 m_MinLevel = 0;
51 m_BattleTime = 0;
56
58
60 m_StartGrouping = false;
61}
62
64{
65 for (GraveyardVect::const_iterator itr = m_GraveyardList.begin(); itr != m_GraveyardList.end(); ++itr)
66 delete *itr;
67}
68
69// Called when a player enters the zone
71{
72 // If battle is started,
73 // If not full of players > invite player to join the war
74 // If full of players > announce to player that BF is full and kick him after a few second if he desn't leave
75 if (IsWarTime())
76 {
77 if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer) // Vacant spaces
78 InvitePlayerToWar(player);
79 else // No more vacant places
80 {
82 m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10;
83 InvitePlayerToQueue(player);
84 }
85 }
86 else
87 {
88 // If time left is < 15 minutes invite player to join queue
90 InvitePlayerToQueue(player);
91 }
92
93 // Add player in the list of player in zone
94 m_players[player->GetTeamId()].insert(player->GetGUID());
95 OnPlayerEnterZone(player);
96}
97
98// Called when a player leave the zone
100{
101 if (IsWarTime())
102 {
103 // If the player is participating to the battle
104 if (m_PlayersInWar[player->GetTeamId()].find(player->GetGUID()) != m_PlayersInWar[player->GetTeamId()].end())
105 {
106 m_PlayersInWar[player->GetTeamId()].erase(player->GetGUID());
107 if (Group* group = player->GetGroup()) // Remove the player from the raid group
108 group->RemoveMember(player->GetGUID());
109
110 OnPlayerLeaveWar(player);
111 }
112 }
113
114 m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
115 m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
116 m_players[player->GetTeamId()].erase(player->GetGUID());
117 SendRemoveWorldStates(player);
118 OnPlayerLeaveZone(player);
119}
120
122{
123 if (m_Timer <= diff)
124 {
125 // Battlefield ends on time
126 if (IsWarTime())
127 EndBattle(true);
128 else // Time to start a new battle!
129 StartBattle();
130 }
131 else
132 m_Timer -= diff;
133
134 // Invite players a few minutes before the battle's beginning
136 {
137 m_StartGrouping = true;
140 }
141
142 if (IsWarTime())
143 {
144 if (m_uiKickAfkPlayersTimer <= diff)
145 {
148 }
149 else
151
152 // Kick players who chose not to accept invitation to the battle
153 if (m_uiKickDontAcceptTimer <= diff)
154 {
155 time_t now = GameTime::GetGameTime();
156 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
157 for (PlayerTimerMap::iterator itr = m_InvitedPlayers[team].begin(); itr != m_InvitedPlayers[team].end(); ++itr)
158 if (itr->second <= now)
159 KickPlayerFromBattlefield(itr->first);
160
162 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
163 for (PlayerTimerMap::iterator itr = m_PlayersWillBeKick[team].begin(); itr != m_PlayersWillBeKick[team].end(); ++itr)
164 if (itr->second <= now)
165 KickPlayerFromBattlefield(itr->first);
166
168 }
169 else
171 }
172
173 return false;
174}
175
177{
178 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
179 for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
180 if (Player* player = ObjectAccessor::FindPlayer(*itr))
181 InvitePlayerToQueue(player);
182}
183
185{
186 if (m_PlayersInQueue[player->GetTeamId()].count(player->GetGUID()))
187 return;
188
189 if (m_PlayersInQueue[player->GetTeamId()].size() <= m_MinPlayer || m_PlayersInQueue[GetOtherTeam(player->GetTeamId())].size() >= m_MinPlayer)
191}
192
194{
195 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
196 {
197 for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
198 {
199 if (Player* player = ObjectAccessor::FindPlayer(*itr))
200 {
201 if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
202 InvitePlayerToWar(player);
203 else
204 {
205 //Full
206 }
207 }
208 }
209 m_PlayersInQueue[team].clear();
210 }
211}
212
214{
215 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
216 {
217 for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
218 {
219 if (Player* player = ObjectAccessor::FindPlayer(*itr))
220 {
221 if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
222 continue;
223 if (m_PlayersInWar[player->GetTeamId()].size() + m_InvitedPlayers[player->GetTeamId()].size() < m_MaxPlayer)
224 InvitePlayerToWar(player);
225 else // Battlefield is full of players
226 m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10;
227 }
228 }
229 }
230}
231
233{
234 return MAKE_PAIR64(m_BattleId | 0x20000, 0x1F100000);
235}
236
238{
239 if (!player)
240 return;
241
243 if (player->IsInFlight())
244 return;
245
246 if (player->GetBattleground())
247 return;
248
249 // If the player does not match minimal level requirements for the battlefield, kick him
250 if (player->GetLevel() < m_MinLevel)
251 {
252 if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)
253 m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10;
254 return;
255 }
256
257 // Check if player is not already in war
258 if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
259 return;
260
261 m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
264}
265
267{
268 if (Creature* creature = SpawnCreature(entry, pos))
269 StalkerGuid = creature->GetGUID();
270 else
271 TC_LOG_ERROR("bg.battlefield", "Battlefield::InitStalker: Could not spawn Stalker (Creature entry {}), zone messages will be unavailable!", entry);
272}
273
275{
276 ZoneScript::ProcessEvent(target, eventId, invoker);
277
278 if (invoker)
279 {
280 if (GameObject* gameobject = invoker->ToGameObject())
281 {
282 if (gameobject->GetGoType() == GAMEOBJECT_TYPE_CONTROL_ZONE)
283 {
284 if (!ControlZoneHandlers.contains(gameobject->GetEntry()))
285 return;
286
287 auto controlzone = gameobject->GetGOInfo()->controlZone;
289 if (eventId == controlzone.CaptureEventAlliance)
290 handler.HandleCaptureEventAlliance(gameobject);
291 else if (eventId == controlzone.CaptureEventHorde)
292 handler.HandleCaptureEventHorde(gameobject);
293 else if (eventId == controlzone.ContestedEventAlliance)
294 handler.HandleContestedEventAlliance(gameobject);
295 else if (eventId == controlzone.ContestedEventHorde)
296 handler.HandleContestedEventHorde(gameobject);
297 else if (eventId == controlzone.NeutralEventAlliance)
298 handler.HandleNeutralEventAlliance(gameobject);
299 else if (eventId == controlzone.NeutralEventHorde)
300 handler.HandleNeutralEventHorde(gameobject);
301 else if (eventId == controlzone.ProgressEventAlliance)
302 handler.HandleProgressEventAlliance(gameobject);
303 else if (eventId == controlzone.ProgressEventHorde)
304 handler.HandleProgressEventHorde(gameobject);
305 }
306 }
307 }
308}
309
311{
312 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
313 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
314 if (Player* player = ObjectAccessor::FindPlayer(*itr))
315 if (player->isAFK())
317}
318
320{
321 if (Player* player = ObjectAccessor::FindPlayer(guid))
322 if (player->GetZoneId() == GetZoneId())
323 player->TeleportTo(KickPosition);
324}
325
327{
328 if (m_isActive)
329 return;
330
331 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
332 {
333 m_PlayersInWar[team].clear();
334 m_Groups[team].clear();
335 }
336
338 m_isActive = true;
339
342
344}
345
346void Battlefield::EndBattle(bool endByTimer)
347{
348 if (!m_isActive)
349 return;
350
351 m_isActive = false;
352
353 m_StartGrouping = false;
354
355 if (!endByTimer)
357
358 // Reset battlefield timer
360
361 OnBattleEnd(endByTimer);
362}
363
368
370{
371 return m_players[player->GetTeamId()].find(player->GetGUID()) != m_players[player->GetTeamId()].end();
372}
373
374// Called in Battlefield::InvitePlayerToQueue
376{
377 // Add player in queue
378 m_PlayersInQueue[player->GetTeamId()].insert(player->GetGUID());
379}
380
381// Called in WorldSession::HandleBfExitRequest
383{
384 // Remove player from queue
385 m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
386}
387
388// Called in WorldSession::HandleHearthAndResurrect
390{
391 // Player leaving Wintergrasp, teleport to Dalaran.
392 // ToDo: confirm teleport destination.
393 player->TeleportTo(571, 5804.1499f, 624.7710f, 647.7670f, 1.6400f);
394}
395
396// Called in Battlefield::InvitePlayerToWar
398{
399 if (!IsWarTime())
400 return;
401
403 {
404 m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID());
405 m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
406
407 if (player->isAFK())
408 player->ToggleAFK();
409
410 OnPlayerJoinWar(player); //for scripting
411 }
412}
413
415{
416 if (spellId > 0)
417 {
418 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
419 if (Player* player = ObjectAccessor::FindPlayer(*itr))
420 player->CastSpell(player, uint32(spellId), true);
421 }
422 else
423 {
424 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
425 if (Player* player = ObjectAccessor::FindPlayer(*itr))
426 player->RemoveAuraFromStack(uint32(-spellId));
427 }
428}
429
431{
432 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
433 for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
434 if (Player* player = ObjectAccessor::FindPlayer(*itr))
435 player->SendDirectMessage(data);
436}
437
439{
440 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
441 for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
443 player->SendDirectMessage(data);
444}
445
447{
448 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
449 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
450 if (Player* player = ObjectAccessor::FindPlayer(*itr))
451 player->SendDirectMessage(data);
452}
453
454void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
455{
456 if (Creature* stalker = GetCreature(StalkerGuid))
457 sCreatureTextMgr->SendChat(stalker, id, target);
458}
459
461{
462 sBattlefieldMgr->AddZone(zoneId, this);
463}
464
466{
467 creature->CombatStop();
468 creature->SetReactState(REACT_PASSIVE);
470 creature->SetUninteractible(true);
471 creature->DisappearAndDie();
472 creature->SetVisible(false);
473}
474
475void Battlefield::ShowNpc(Creature* creature, bool aggressive)
476{
477 creature->SetVisible(true);
479 creature->SetUninteractible(false);
480 if (!creature->IsAlive())
481 creature->Respawn(true);
482 if (aggressive)
484 else
485 {
487 creature->SetReactState(REACT_PASSIVE);
488 }
489}
490
491// ****************************************************
492// ******************* Group System *******************
493// ****************************************************
495{
496 for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
497 if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
498 if (!group->IsFull())
499 return group;
500
501 return nullptr;
502}
503
505{
506 for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
507 if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
508 if (group->IsMember(guid))
509 return group;
510
511 return nullptr;
512}
513
515{
516 if (!player->IsInWorld())
517 return false;
518
519 if (Group* group = player->GetGroup())
520 group->RemoveMember(player->GetGUID());
521
522 Group* group = GetFreeBfRaid(player->GetTeamId());
523 if (!group)
524 {
525 group = new Group;
526 group->SetBattlefieldGroup(this);
527 group->Create(player);
528 sGroupMgr->AddGroup(group);
529 m_Groups[player->GetTeamId()].insert(group->GetGUID());
530 }
531 else if (group->IsMember(player->GetGUID()))
532 {
533 uint8 subgroup = group->GetMemberGroup(player->GetGUID());
534 player->SetBattlegroundOrBattlefieldRaid(group, subgroup);
535 }
536 else
537 group->AddMember(player);
538
539 return true;
540}
541
542//***************End of Group System*******************
543
544//*****************************************************
545//***************Spirit Guide System*******************
546//*****************************************************
547
548//--------------------
549//-Battlefield Method-
550//--------------------
552{
553 m_GraveyardList.resize(number);
554}
555
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:{} does not exist.", id);
564 }
565 else
566 TC_LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:{} could not be found.", id);
567
568 return nullptr;
569}
570
572{
573 BfGraveyard* closestGY = nullptr;
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 sObjectMgr->GetWorldSafeLoc(closestGY->GetGraveyardId());
593
594 return nullptr;
595}
596
597// ----------------------
598// - BfGraveyard Method -
599// ----------------------
606
607BfGraveyard::~BfGraveyard() = default;
608
609void BfGraveyard::Initialize(TeamId startControl, uint32 graveyardId)
610{
611 m_ControlTeam = startControl;
612 m_GraveyardId = graveyardId;
613}
614
616{
617 if (!spirit)
618 {
619 TC_LOG_ERROR("bg.battlefield", "BfGraveyard::SetSpirit: Invalid Spirit.");
620 return;
621 }
622
623 m_SpiritGuide[team] = spirit->GetGUID();
625}
626
628{
629 WorldSafeLocsEntry const* safeLoc = sObjectMgr->GetWorldSafeLoc(m_GraveyardId);
630 return player->GetDistance2d(safeLoc->Loc.GetPositionX(), safeLoc->Loc.GetPositionY());
631}
632
633// For changing graveyard control
635{
636 // Guide switching
637 // Note: Visiblity changes are made by phasing
638 /*if (m_SpiritGuide[1 - team])
639 m_SpiritGuide[1 - team]->SetVisible(false);
640 if (m_SpiritGuide[team])
641 m_SpiritGuide[team]->SetVisible(true);*/
642
643 if (Creature* spiritHealer = m_Bf->GetCreature(m_SpiritGuide[team]))
644 spiritHealer->SummonGraveyardTeleporter();
645
646 m_ControlTeam = team;
647}
648
650{
652 return false;
653
656 return false;
657
658 return (m_SpiritGuide[TEAM_ALLIANCE] == guid || m_SpiritGuide[TEAM_HORDE] == guid);
659}
660
661// *******************************************************
662// *************** End Spirit Guide system ***************
663// *******************************************************
664// ********************** Misc ***************************
665// *******************************************************
666
668{
669 if (!sObjectMgr->GetCreatureTemplate(entry))
670 {
671 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry {} does not exist.", entry);
672 return nullptr;
673 }
674
675 Creature* creature = Creature::CreateCreature(entry, m_Map, pos);
676 if (!creature)
677 {
678 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: {}", entry);
679 return nullptr;
680 }
681
682 creature->SetHomePosition(pos);
683
684 // Set creature in world
685 m_Map->AddToMap(creature);
686 creature->setActive(true);
687 creature->SetFarVisible(true);
688
689 return creature;
690}
691
692// Method for spawning gameobject on map
694{
695 if (!sObjectMgr->GetGameObjectTemplate(entry))
696 {
697 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: GameObject template {} not found in database! Battlefield not created!", entry);
698 return nullptr;
699 }
700
701 // Create gameobject
702 GameObject* go = GameObject::CreateGameObject(entry, m_Map, pos, rot, 255, GO_STATE_READY);
703 if (!go)
704 {
705 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Could not create gameobject template {}! Battlefield has not been created!", entry);
706 return nullptr;
707 }
708
709 // Add to world
710 m_Map->AddToMap(go);
711 go->setActive(true);
712 go->SetFarVisible(true);
713
714 return go;
715}
716
718{
719 if (!m_Map)
720 return nullptr;
721 return m_Map->GetCreature(guid);
722}
723
725{
726 if (!m_Map)
727 return nullptr;
728 return m_Map->GetGameObject(guid);
729}
730
731// *******************************************************
732// ******************* CapturePoint **********************
733// *******************************************************
734
738
740
#define sBattlefieldMgr
#define sCreatureTextMgr
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint64_t uint64
Definition Define.h:153
uint32_t uint32
Definition Define.h:154
#define sGroupMgr
Definition GroupMgr.h:66
#define TC_LOG_ERROR(filterType__, message__,...)
Definition Log.h:182
uint64 MAKE_PAIR64(uint32 l, uint32 h)
#define sObjectMgr
Definition ObjectMgr.h:1873
@ GAMEOBJECT_TYPE_CONTROL_ZONE
@ TEAM_NEUTRAL
@ TEAM_ALLIANCE
@ TEAM_HORDE
constexpr TeamId GetOtherTeam(TeamId team)
uint8 constexpr PVP_TEAMS_COUNT
@ GO_STATE_READY
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_FLAG_NON_ATTACKABLE
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool IsInWorld() const
Definition BaseEntity.h:158
BattlefieldControlZoneHandler(Battlefield *bf)
uint32 m_Timer
uint32 m_MapId
GameObject * SpawnGameObject(uint32 entry, Position const &pos, QuaternionData const &rot)
void ProcessEvent(WorldObject *target, uint32 eventId, WorldObject *invoker) override
GraveyardVect m_GraveyardList
GameObject * GetGameObject(ObjectGuid guid)
void BroadcastPacketToWar(WorldPacket const *data) const
void ShowNpc(Creature *creature, bool aggressive)
Creature * GetCreature(ObjectGuid guid)
void DoPlaySoundToAll(uint32 SoundID)
uint32 m_MaxPlayer
ObjectGuid StalkerGuid
Creature * SpawnCreature(uint32 entry, Position const &pos)
void BroadcastPacketToZone(WorldPacket const *data) const
uint32 m_NoWarBattleTime
virtual ~Battlefield()
Destructor.
void EndBattle(bool endByTimer)
virtual void OnBattleEnd(bool)
Called at the end of battle.
uint32 m_BattleTime
uint32 GetZoneId() const
bool IsWarTime() const
Return true if battle is start, false if battle is not started.
uint32 m_ZoneId
void InitStalker(uint32 entry, Position const &pos)
uint32 m_TypeId
uint32 m_BattleId
void InvitePlayersInQueueToWar()
Invite all players in queue to join battle on battle start.
virtual void SendRemoveWorldStates(Player *)
uint32 m_StartGroupingTimer
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 KickPlayerFromBattlefield(ObjectGuid guid)
Kick player from battlefield and teleport him to kick-point location.
void InvitePlayerToQueue(Player *player)
void RegisterZone(uint32 zoneid)
void SetDefenderTeam(TeamId team)
TeamId m_DefenderTeam
void InvitePlayerToWar(Player *player)
uint32 m_uiKickAfkPlayersTimer
void PlayerAcceptInviteToWar(Player *player)
void BroadcastPacketToQueue(WorldPacket const *data) const
void SendWarning(uint8 id, WorldObject const *target=nullptr)
Group * GetFreeBfRaid(TeamId TeamId)
Find a not full battlefield group, if there is no, create one.
void StartBattle()
virtual void OnPlayerJoinWar(Player *)
Called when a player accept to join the battle.
uint32 m_TimeForAcceptInvite
BfGraveyard * GetGraveyardById(uint32 id) const
virtual void OnBattleStart()
Called on start.
GuidUnorderedSet m_PlayersInWar[PVP_TEAMS_COUNT]
uint64 GetQueueId() const
void InvitePlayersInZoneToWar()
Invite all players in zone to join battle on battle start.
void HideNpc(Creature *creature)
PlayerTimerMap m_PlayersWillBeKick[PVP_TEAMS_COUNT]
uint32 m_RestartAfterCrash
TeamId GetAttackerTeam() const
uint32 m_MinLevel
GuidUnorderedSet m_PlayersInQueue[PVP_TEAMS_COUNT]
bool AddOrSetPlayerToCorrectBfGroup(Player *player)
Force player to join a battlefield group.
void KickAfkPlayers()
void PlayerAskToLeave(Player *player)
void TeamCastSpell(TeamId team, int32 spellId)
uint32 m_MinPlayer
virtual void OnPlayerLeaveZone(Player *)
Called when a player leave battlefield zone.
void PlayerAcceptInviteToQueue(Player *player)
Group * GetGroupPlayer(ObjectGuid guid, TeamId TeamId)
Return battlefield group where player is.
uint32 m_uiKickDontAcceptTimer
ControlZoneHandlerMap ControlZoneHandlers
GuidUnorderedSet m_Groups[PVP_TEAMS_COUNT]
virtual void OnStartGrouping()
Called x minutes before battle start when player in zone are invite to join queue.
bool m_StartGrouping
WorldLocation KickPosition
virtual void OnPlayerLeaveWar(Player *)
Called when a player leave the battle.
PlayerTimerMap m_InvitedPlayers[PVP_TEAMS_COUNT]
bool HasPlayer(Player *player) const
void SetGraveyardNumber(uint32 number)
void AskToLeaveQueue(Player *player)
Battlefield(Map *map)
Constructor.
WorldSafeLocsEntry const * GetClosestGraveyard(Player *player)
void HandlePlayerLeaveZone(Player *player, uint32 zone)
Called when player (player) leave the zone.
virtual void OnPlayerEnterZone(Player *)
Called when a player enter in battlefield zone.
GuidUnorderedSet m_players[PVP_TEAMS_COUNT]
void HandlePlayerEnterZone(Player *player, uint32 zone)
Called when player (player) enter in zone.
ObjectGuid m_SpiritGuide[PVP_TEAMS_COUNT]
BfGraveyard(Battlefield *bf)
virtual ~BfGraveyard()
bool HasNpc(ObjectGuid guid)
uint32 m_GraveyardId
void GiveControlTo(TeamId team)
Battlefield * m_Bf
TeamId m_ControlTeam
void SetSpirit(Creature *spirit, TeamId team)
uint32 GetGraveyardId() const
void Initialize(TeamId startcontrol, uint32 gy)
float GetDistance(Player *player)
virtual void HandleNeutralEventHorde(GameObject *controlZone)
Definition ZoneScript.h:58
virtual void HandleProgressEventAlliance(GameObject *controlZone)
Definition ZoneScript.h:57
virtual void HandleContestedEventAlliance(GameObject *controlZone)
Definition ZoneScript.h:55
virtual void HandleNeutralEventAlliance(GameObject *controlZone)
Definition ZoneScript.h:59
virtual void HandleCaptureEventHorde(GameObject *controlZone)
Definition ZoneScript.h:52
virtual void HandleProgressEventHorde(GameObject *controlZone)
Definition ZoneScript.h:56
virtual void HandleContestedEventHorde(GameObject *controlZone)
Definition ZoneScript.h:54
virtual void HandleCaptureEventAlliance(GameObject *controlZone)
Definition ZoneScript.h:53
void SetHomePosition(float x, float y, float z, float o)
Definition Creature.h:394
void Respawn(bool force=false)
static Creature * CreateCreature(uint32 entry, Map *map, Position const &pos, uint32 vehId=0)
void SetReactState(ReactStates st)
Definition Creature.h:180
void DisappearAndDie()
Definition Creature.h:95
static GameObject * CreateGameObject(uint32 entry, Map *map, Position const &pos, QuaternionData const &rotation, uint32 animProgress, GOState goState, uint32 artKit=0)
Definition Group.h:209
uint8 GetMemberGroup(ObjectGuid guid) const
Definition Group.cpp:1703
void SetBattlefieldGroup(Battlefield *bf)
Definition Group.cpp:1716
bool AddMember(Player *player)
Definition Group.cpp:424
ObjectGuid GetGUID() const
Definition Group.cpp:1623
bool RemoveMember(ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Group.cpp:547
bool IsMember(ObjectGuid guid) const
Definition Group.cpp:1655
bool Create(Player *leader)
Definition Group.cpp:141
Definition Map.h:227
bool AddToMap(T *)
Definition Map.cpp:527
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3588
uint32 GetId() const
Definition Map.cpp:3288
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3578
static ObjectGuid const Empty
Definition ObjectGuid.h:314
GameObject * ToGameObject()
Definition Object.h:131
uint32 GetEntry() const
Definition Object.h:89
TeamId GetTeamId() const
Definition Player.h:2407
bool TeleportTo(uint32 mapid, float x, float y, float z, float orientation, TeleportToOptions options=TELE_TO_NONE, Optional< uint32 > instanceId={}, uint32 teleportSpellId=0)
Definition Player.cpp:1181
Battleground * GetBattleground() const
Definition Player.cpp:25650
void ToggleAFK()
Definition Player.cpp:1143
Group * GetGroup(Optional< uint8 > partyIndex)
Definition Player.h:2781
bool isAFK() const
Definition Player.h:1267
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition Player.cpp:26689
void SetVisible(bool x)
Definition Unit.cpp:8787
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition Unit.cpp:6031
bool IsAlive() const
Definition Unit.h:1205
void SetUninteractible(bool apply)
Definition Unit.cpp:8583
bool IsInFlight() const
Definition Unit.h:1042
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:861
uint8 GetLevel() const
Definition Unit.h:769
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:862
void setActive(bool isActiveObject)
Definition Object.cpp:274
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:448
void SetFarVisible(bool on)
Definition Object.cpp:325
virtual void ProcessEvent(WorldObject *obj, uint32 eventId, WorldObject *invoker)
Definition ZoneScript.h:103
time_t GetGameTime()
Definition GameTime.cpp:52
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
TC_GAME_API Player * FindConnectedPlayer(ObjectGuid const &)
constexpr float GetPositionX() const
Definition Position.h:87
constexpr float GetPositionY() const
Definition Position.h:88
WorldLocation Loc
Definition ObjectMgr.h:835