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->InArena() || player->GetBattleground())
247 {
248 m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
249 return;
250 }
251
252 // If the player does not match minimal level requirements for the battlefield, kick him
253 if (player->GetLevel() < m_MinLevel)
254 {
255 if (m_PlayersWillBeKick[player->GetTeamId()].count(player->GetGUID()) == 0)
256 m_PlayersWillBeKick[player->GetTeamId()][player->GetGUID()] = GameTime::GetGameTime() + 10;
257 return;
258 }
259
260 // Check if player is not already in war
261 if (m_PlayersInWar[player->GetTeamId()].count(player->GetGUID()) || m_InvitedPlayers[player->GetTeamId()].count(player->GetGUID()))
262 return;
263
264 m_PlayersWillBeKick[player->GetTeamId()].erase(player->GetGUID());
267}
268
270{
271 if (Creature* creature = SpawnCreature(entry, pos))
272 StalkerGuid = creature->GetGUID();
273 else
274 TC_LOG_ERROR("bg.battlefield", "Battlefield::InitStalker: Could not spawn Stalker (Creature entry {}), zone messages will be unavailable!", entry);
275}
276
278{
279 ZoneScript::ProcessEvent(target, eventId, invoker);
280
281 if (invoker)
282 {
283 if (GameObject* gameobject = invoker->ToGameObject())
284 {
285 if (gameobject->GetGoType() == GAMEOBJECT_TYPE_CONTROL_ZONE)
286 {
287 if (!ControlZoneHandlers.contains(gameobject->GetEntry()))
288 return;
289
290 auto controlzone = gameobject->GetGOInfo()->controlZone;
292 if (eventId == controlzone.CaptureEventAlliance)
293 handler.HandleCaptureEventAlliance(gameobject);
294 else if (eventId == controlzone.CaptureEventHorde)
295 handler.HandleCaptureEventHorde(gameobject);
296 else if (eventId == controlzone.ContestedEventAlliance)
297 handler.HandleContestedEventAlliance(gameobject);
298 else if (eventId == controlzone.ContestedEventHorde)
299 handler.HandleContestedEventHorde(gameobject);
300 else if (eventId == controlzone.NeutralEventAlliance)
301 handler.HandleNeutralEventAlliance(gameobject);
302 else if (eventId == controlzone.NeutralEventHorde)
303 handler.HandleNeutralEventHorde(gameobject);
304 else if (eventId == controlzone.ProgressEventAlliance)
305 handler.HandleProgressEventAlliance(gameobject);
306 else if (eventId == controlzone.ProgressEventHorde)
307 handler.HandleProgressEventHorde(gameobject);
308 }
309 }
310 }
311}
312
314{
315 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
316 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
317 if (Player* player = ObjectAccessor::FindPlayer(*itr))
318 if (player->isAFK())
320}
321
323{
324 if (Player* player = ObjectAccessor::FindPlayer(guid))
325 if (player->GetZoneId() == GetZoneId())
326 player->TeleportTo(KickPosition);
327}
328
330{
331 if (m_isActive)
332 return;
333
334 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
335 {
336 m_PlayersInWar[team].clear();
337 m_Groups[team].clear();
338 }
339
341 m_isActive = true;
342
345
347}
348
349void Battlefield::EndBattle(bool endByTimer)
350{
351 if (!m_isActive)
352 return;
353
354 m_isActive = false;
355
356 m_StartGrouping = false;
357
358 if (!endByTimer)
360
361 // Reset battlefield timer
363
364 OnBattleEnd(endByTimer);
365}
366
371
373{
374 return m_players[player->GetTeamId()].find(player->GetGUID()) != m_players[player->GetTeamId()].end();
375}
376
377// Called in Battlefield::InvitePlayerToQueue
379{
380 // Add player in queue
381 m_PlayersInQueue[player->GetTeamId()].insert(player->GetGUID());
382}
383
384// Called in WorldSession::HandleBfExitRequest
386{
387 // Remove player from queue
388 m_PlayersInQueue[player->GetTeamId()].erase(player->GetGUID());
389}
390
391// Called in WorldSession::HandleHearthAndResurrect
393{
394 // Player leaving Wintergrasp, teleport to Dalaran.
395 // ToDo: confirm teleport destination.
396 player->TeleportTo(571, 5804.1499f, 624.7710f, 647.7670f, 1.6400f);
397}
398
399// Called in Battlefield::InvitePlayerToWar
401{
402 if (!IsWarTime())
403 return;
404
406 {
407 m_PlayersInWar[player->GetTeamId()].insert(player->GetGUID());
408 m_InvitedPlayers[player->GetTeamId()].erase(player->GetGUID());
409
410 if (player->isAFK())
411 player->ToggleAFK();
412
413 OnPlayerJoinWar(player); //for scripting
414 }
415}
416
418{
419 if (spellId > 0)
420 {
421 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
422 if (Player* player = ObjectAccessor::FindPlayer(*itr))
423 player->CastSpell(player, uint32(spellId), true);
424 }
425 else
426 {
427 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
428 if (Player* player = ObjectAccessor::FindPlayer(*itr))
429 player->RemoveAuraFromStack(uint32(-spellId));
430 }
431}
432
434{
435 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
436 for (auto itr = m_players[team].begin(); itr != m_players[team].end(); ++itr)
437 if (Player* player = ObjectAccessor::FindPlayer(*itr))
438 player->SendDirectMessage(data);
439}
440
442{
443 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
444 for (auto itr = m_PlayersInQueue[team].begin(); itr != m_PlayersInQueue[team].end(); ++itr)
446 player->SendDirectMessage(data);
447}
448
450{
451 for (uint8 team = 0; team < PVP_TEAMS_COUNT; ++team)
452 for (auto itr = m_PlayersInWar[team].begin(); itr != m_PlayersInWar[team].end(); ++itr)
453 if (Player* player = ObjectAccessor::FindPlayer(*itr))
454 player->SendDirectMessage(data);
455}
456
457void Battlefield::SendWarning(uint8 id, WorldObject const* target /*= nullptr*/)
458{
459 if (Creature* stalker = GetCreature(StalkerGuid))
460 sCreatureTextMgr->SendChat(stalker, id, target);
461}
462
464{
465 sBattlefieldMgr->AddZone(zoneId, this);
466}
467
469{
470 creature->CombatStop();
471 creature->SetReactState(REACT_PASSIVE);
473 creature->SetUninteractible(true);
474 creature->DisappearAndDie();
475 creature->SetVisible(false);
476}
477
478void Battlefield::ShowNpc(Creature* creature, bool aggressive)
479{
480 creature->SetVisible(true);
482 creature->SetUninteractible(false);
483 if (!creature->IsAlive())
484 creature->Respawn(true);
485 if (aggressive)
487 else
488 {
490 creature->SetReactState(REACT_PASSIVE);
491 }
492}
493
494// ****************************************************
495// ******************* Group System *******************
496// ****************************************************
498{
499 for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
500 if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
501 if (!group->IsFull())
502 return group;
503
504 return nullptr;
505}
506
508{
509 for (auto itr = m_Groups[TeamId].begin(); itr != m_Groups[TeamId].end(); ++itr)
510 if (Group* group = sGroupMgr->GetGroupByGUID(*itr))
511 if (group->IsMember(guid))
512 return group;
513
514 return nullptr;
515}
516
518{
519 if (!player->IsInWorld())
520 return false;
521
522 if (Group* group = player->GetGroup())
523 group->RemoveMember(player->GetGUID());
524
525 Group* group = GetFreeBfRaid(player->GetTeamId());
526 if (!group)
527 {
528 group = new Group;
529 group->SetBattlefieldGroup(this);
530 group->Create(player);
531 sGroupMgr->AddGroup(group);
532 m_Groups[player->GetTeamId()].insert(group->GetGUID());
533 }
534 else if (group->IsMember(player->GetGUID()))
535 {
536 uint8 subgroup = group->GetMemberGroup(player->GetGUID());
537 player->SetBattlegroundOrBattlefieldRaid(group, subgroup);
538 }
539 else
540 group->AddMember(player);
541
542 return true;
543}
544
545//***************End of Group System*******************
546
547//*****************************************************
548//***************Spirit Guide System*******************
549//*****************************************************
550
551//--------------------
552//-Battlefield Method-
553//--------------------
555{
556 m_GraveyardList.resize(number);
557}
558
560{
561 if (id < m_GraveyardList.size())
562 {
563 if (BfGraveyard* graveyard = m_GraveyardList.at(id))
564 return graveyard;
565 else
566 TC_LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:{} does not exist.", id);
567 }
568 else
569 TC_LOG_ERROR("bg.battlefield", "Battlefield::GetGraveyardById Id:{} could not be found.", id);
570
571 return nullptr;
572}
573
575{
576 BfGraveyard* closestGY = nullptr;
577 float maxdist = -1;
578 for (uint8 i = 0; i < m_GraveyardList.size(); i++)
579 {
580 if (m_GraveyardList[i])
581 {
582 if (m_GraveyardList[i]->GetControlTeamId() != player->GetTeamId())
583 continue;
584
585 float dist = m_GraveyardList[i]->GetDistance(player);
586 if (dist < maxdist || maxdist < 0)
587 {
588 closestGY = m_GraveyardList[i];
589 maxdist = dist;
590 }
591 }
592 }
593
594 if (closestGY)
595 return sObjectMgr->GetWorldSafeLoc(closestGY->GetGraveyardId());
596
597 return nullptr;
598}
599
600// ----------------------
601// - BfGraveyard Method -
602// ----------------------
604{
605 m_Bf = battlefield;
606 m_GraveyardId = 0;
608}
609
610void BfGraveyard::Initialize(TeamId startControl, uint32 graveyardId)
611{
612 m_ControlTeam = startControl;
613 m_GraveyardId = graveyardId;
614}
615
617{
618 if (!spirit)
619 {
620 TC_LOG_ERROR("bg.battlefield", "BfGraveyard::SetSpirit: Invalid Spirit.");
621 return;
622 }
623
624 m_SpiritGuide[team] = spirit->GetGUID();
626}
627
629{
630 WorldSafeLocsEntry const* safeLoc = sObjectMgr->GetWorldSafeLoc(m_GraveyardId);
631 return player->GetDistance2d(safeLoc->Loc.GetPositionX(), safeLoc->Loc.GetPositionY());
632}
633
634// For changing graveyard control
636{
637 // Guide switching
638 // Note: Visiblity changes are made by phasing
639 /*if (m_SpiritGuide[1 - team])
640 m_SpiritGuide[1 - team]->SetVisible(false);
641 if (m_SpiritGuide[team])
642 m_SpiritGuide[team]->SetVisible(true);*/
643
644 if (Creature* spiritHealer = m_Bf->GetCreature(m_SpiritGuide[team]))
645 spiritHealer->SummonGraveyardTeleporter();
646
647 m_ControlTeam = team;
648}
649
651{
653 return false;
654
657 return false;
658
659 return (m_SpiritGuide[TEAM_ALLIANCE] == guid || m_SpiritGuide[TEAM_HORDE] == guid);
660}
661
662// *******************************************************
663// *************** End Spirit Guide system ***************
664// *******************************************************
665// ********************** Misc ***************************
666// *******************************************************
667
669{
670 if (!sObjectMgr->GetCreatureTemplate(entry))
671 {
672 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: entry {} does not exist.", entry);
673 return nullptr;
674 }
675
676 Creature* creature = Creature::CreateCreature(entry, m_Map, pos);
677 if (!creature)
678 {
679 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnCreature: Can't create creature entry: {}", entry);
680 return nullptr;
681 }
682
683 creature->SetHomePosition(pos);
684
685 // Set creature in world
686 m_Map->AddToMap(creature);
687 creature->setActive(true);
688 creature->SetFarVisible(true);
689
690 return creature;
691}
692
693// Method for spawning gameobject on map
695{
696 if (!sObjectMgr->GetGameObjectTemplate(entry))
697 {
698 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: GameObject template {} not found in database! Battlefield not created!", entry);
699 return nullptr;
700 }
701
702 // Create gameobject
703 GameObject* go = GameObject::CreateGameObject(entry, m_Map, pos, rot, 255, GO_STATE_READY);
704 if (!go)
705 {
706 TC_LOG_ERROR("bg.battlefield", "Battlefield::SpawnGameObject: Could not create gameobject template {}! Battlefield has not been created!", entry);
707 return nullptr;
708 }
709
710 // Add to world
711 m_Map->AddToMap(go);
712 go->setActive(true);
713 go->SetFarVisible(true);
714
715 return go;
716}
717
719{
720 if (!m_Map)
721 return nullptr;
722 return m_Map->GetCreature(guid);
723}
724
726{
727 if (!m_Map)
728 return nullptr;
729 return m_Map->GetGameObject(guid);
730}
731
732// *******************************************************
733// ******************* CapturePoint **********************
734// *******************************************************
735
739
#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:190
uint64 MAKE_PAIR64(uint32 l, uint32 h)
#define sObjectMgr
Definition ObjectMgr.h:1885
@ 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)
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:386
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:174
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:205
uint8 GetMemberGroup(ObjectGuid guid) const
Definition Group.cpp:1733
void SetBattlefieldGroup(Battlefield *bf)
Definition Group.cpp:1746
bool AddMember(Player *player)
Definition Group.cpp:424
ObjectGuid GetGUID() const
Definition Group.cpp:1653
bool RemoveMember(ObjectGuid guid, RemoveMethod method=GROUP_REMOVEMETHOD_DEFAULT, ObjectGuid kicker=ObjectGuid::Empty, const char *reason=nullptr)
Definition Group.cpp:566
bool IsMember(ObjectGuid guid) const
Definition Group.cpp:1685
bool Create(Player *leader)
Definition Group.cpp:141
Definition Map.h:225
bool AddToMap(T *)
Definition Map.cpp:517
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3552
uint32 GetId() const
Definition Map.cpp:3257
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
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:2424
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:1226
Battleground * GetBattleground() const
Definition Player.cpp:25719
void ToggleAFK()
Definition Player.cpp:1188
bool InArena() const
Definition Player.cpp:25849
Group * GetGroup(Optional< uint8 > partyIndex)
Definition Player.h:2796
bool isAFK() const
Definition Player.h:1283
void SetBattlegroundOrBattlefieldRaid(Group *group, int8 subgroup=-1)
Definition Player.cpp:26748
void SetVisible(bool x)
Definition Unit.cpp:8768
void CombatStop(bool includingCast=false, bool mutualPvP=true, bool(*unitFilter)(Unit const *otherUnit)=nullptr)
Definition Unit.cpp:6012
bool IsAlive() const
Definition Unit.h:1185
void SetUninteractible(bool apply)
Definition Unit.cpp:8564
bool IsInFlight() const
Definition Unit.h:1027
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:846
uint8 GetLevel() const
Definition Unit.h:757
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:847
void setActive(bool isActiveObject)
Definition Object.cpp:276
float GetDistance2d(WorldObject const *obj) const
Definition Object.cpp:450
void SetFarVisible(bool on)
Definition Object.cpp:327
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:836