[9290] Some cleanups in realmd, no functional changes
[getmangos.git] / src / game / BattleGround.h
blobda7523ac88a3760b563734362b6d57f9ddd1b183
1 /*
2 * Copyright (C) 2005-2010 MaNGOS <http://getmangos.com/>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
19 #ifndef __BATTLEGROUND_H
20 #define __BATTLEGROUND_H
22 #include "Common.h"
23 #include "SharedDefines.h"
25 // magic event-numbers
26 #define BG_EVENT_NONE 255
27 // those generic events should get a high event id
28 #define BG_EVENT_DOOR 254
29 // only arena event
30 // cause this buff apears 90sec after start in every bg i implement it here
31 #define ARENA_BUFF_EVENT 252
34 class Creature;
35 class GameObject;
36 class Group;
37 class Player;
38 class WorldPacket;
39 class BattleGroundMap;
41 struct PvPDifficultyEntry;
42 struct WorldSafeLocsEntry;
44 struct BattleGroundEventIdx
46 uint8 event1;
47 uint8 event2;
50 enum BattleGroundSounds
52 SOUND_HORDE_WINS = 8454,
53 SOUND_ALLIANCE_WINS = 8455,
54 SOUND_BG_START = 3439
57 enum BattleGroundQuests
59 SPELL_WS_QUEST_REWARD = 43483,
60 SPELL_AB_QUEST_REWARD = 43484,
61 SPELL_AV_QUEST_REWARD = 43475,
62 SPELL_AV_QUEST_KILLED_BOSS = 23658,
63 SPELL_EY_QUEST_REWARD = 43477,
64 SPELL_AB_QUEST_REWARD_4_BASES = 24061,
65 SPELL_AB_QUEST_REWARD_5_BASES = 24064
68 enum BattleGroundMarks
70 SPELL_WS_MARK_LOSER = 24950,
71 SPELL_WS_MARK_WINNER = 24951,
72 SPELL_AB_MARK_LOSER = 24952,
73 SPELL_AB_MARK_WINNER = 24953,
74 SPELL_AV_MARK_LOSER = 24954,
75 SPELL_AV_MARK_WINNER = 24955,
76 ITEM_EY_MARK_OF_HONOR = 29024
79 enum BattleGroundMarksCount
81 ITEM_WINNER_COUNT = 3,
82 ITEM_LOSER_COUNT = 1
85 enum BattleGroundSpells
87 SPELL_ARENA_PREPARATION = 32727, // use this one, 32728 not correct
88 SPELL_ALLIANCE_GOLD_FLAG = 32724,
89 SPELL_ALLIANCE_GREEN_FLAG = 32725,
90 SPELL_HORDE_GOLD_FLAG = 35774,
91 SPELL_HORDE_GREEN_FLAG = 35775,
92 SPELL_PREPARATION = 44521, // Preparation
93 SPELL_RECENTLY_DROPPED_FLAG = 42792, // Recently Dropped Flag
94 SPELL_AURA_PLAYER_INACTIVE = 43681 // Inactive
97 enum BattleGroundTimeIntervals
99 RESURRECTION_INTERVAL = 30000, // ms
100 //REMIND_INTERVAL = 10000, // ms
101 INVITATION_REMIND_TIME = 20000, // ms
102 INVITE_ACCEPT_WAIT_TIME = 40000, // ms
103 TIME_TO_AUTOREMOVE = 120000, // ms
104 MAX_OFFLINE_TIME = 300, // secs
105 RESPAWN_ONE_DAY = 86400, // secs
106 RESPAWN_IMMEDIATELY = 0, // secs
107 BUFF_RESPAWN_TIME = 180, // secs
108 ARENA_SPAWN_BUFF_OBJECTS = 90000, // ms - 90sec after start
111 enum BattleGroundStartTimeIntervals
113 BG_START_DELAY_2M = 120000, // ms (2 minutes)
114 BG_START_DELAY_1M = 60000, // ms (1 minute)
115 BG_START_DELAY_30S = 30000, // ms (30 seconds)
116 BG_START_DELAY_15S = 15000, // ms (15 seconds) Used only in arena
117 BG_START_DELAY_NONE = 0, // ms
120 enum BattleGroundBuffObjects
122 BG_OBJECTID_SPEEDBUFF_ENTRY = 179871,
123 BG_OBJECTID_REGENBUFF_ENTRY = 179904,
124 BG_OBJECTID_BERSERKERBUFF_ENTRY = 179905
127 const uint32 Buff_Entries[3] = { BG_OBJECTID_SPEEDBUFF_ENTRY, BG_OBJECTID_REGENBUFF_ENTRY, BG_OBJECTID_BERSERKERBUFF_ENTRY };
129 enum BattleGroundStatus
131 STATUS_NONE = 0, // first status, should mean bg is not instance
132 STATUS_WAIT_QUEUE = 1, // means bg is empty and waiting for queue
133 STATUS_WAIT_JOIN = 2, // this means, that BG has already started and it is waiting for more players
134 STATUS_IN_PROGRESS = 3, // means bg is running
135 STATUS_WAIT_LEAVE = 4 // means some faction has won BG and it is ending
138 struct BattleGroundPlayer
140 time_t OfflineRemoveTime; // for tracking and removing offline players from queue after 5 minutes
141 uint32 Team; // Player's team
144 struct BattleGroundObjectInfo
146 BattleGroundObjectInfo() : object(NULL), timer(0), spellid(0) {}
148 GameObject *object;
149 int32 timer;
150 uint32 spellid;
153 // handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time
154 enum BattleGroundQueueTypeId
156 BATTLEGROUND_QUEUE_NONE = 0,
157 BATTLEGROUND_QUEUE_AV = 1,
158 BATTLEGROUND_QUEUE_WS = 2,
159 BATTLEGROUND_QUEUE_AB = 3,
160 BATTLEGROUND_QUEUE_EY = 4,
161 BATTLEGROUND_QUEUE_SA = 5,
162 BATTLEGROUND_QUEUE_IC = 6,
163 BATTLEGROUND_QUEUE_2v2 = 7,
164 BATTLEGROUND_QUEUE_3v3 = 8,
165 BATTLEGROUND_QUEUE_5v5 = 9
167 #define MAX_BATTLEGROUND_QUEUE_TYPES 10
169 enum ScoreType
171 SCORE_KILLING_BLOWS = 1,
172 SCORE_DEATHS = 2,
173 SCORE_HONORABLE_KILLS = 3,
174 SCORE_BONUS_HONOR = 4,
175 //EY, but in MSG_PVP_LOG_DATA opcode!
176 SCORE_DAMAGE_DONE = 5,
177 SCORE_HEALING_DONE = 6,
178 //WS
179 SCORE_FLAG_CAPTURES = 7,
180 SCORE_FLAG_RETURNS = 8,
181 //AB
182 SCORE_BASES_ASSAULTED = 9,
183 SCORE_BASES_DEFENDED = 10,
184 //AV
185 SCORE_GRAVEYARDS_ASSAULTED = 11,
186 SCORE_GRAVEYARDS_DEFENDED = 12,
187 SCORE_TOWERS_ASSAULTED = 13,
188 SCORE_TOWERS_DEFENDED = 14,
189 SCORE_SECONDARY_OBJECTIVES = 15
192 enum ArenaType
194 ARENA_TYPE_2v2 = 2,
195 ARENA_TYPE_3v3 = 3,
196 ARENA_TYPE_5v5 = 5
199 enum BattleGroundType
201 TYPE_BATTLEGROUND = 3,
202 TYPE_ARENA = 4
205 enum BattleGroundWinner
207 WINNER_HORDE = 0,
208 WINNER_ALLIANCE = 1,
209 WINNER_NONE = 2
212 enum BattleGroundTeamId
214 BG_TEAM_ALLIANCE = 0,
215 BG_TEAM_HORDE = 1
217 #define BG_TEAMS_COUNT 2
219 enum BattleGroundStartingEvents
221 BG_STARTING_EVENT_NONE = 0x00,
222 BG_STARTING_EVENT_1 = 0x01,
223 BG_STARTING_EVENT_2 = 0x02,
224 BG_STARTING_EVENT_3 = 0x04,
225 BG_STARTING_EVENT_4 = 0x08
228 enum BattleGroundStartingEventsIds
230 BG_STARTING_EVENT_FIRST = 0,
231 BG_STARTING_EVENT_SECOND = 1,
232 BG_STARTING_EVENT_THIRD = 2,
233 BG_STARTING_EVENT_FOURTH = 3
235 #define BG_STARTING_EVENT_COUNT 4
237 enum BattleGroundJoinError
239 BG_JOIN_ERR_OK = 0,
240 BG_JOIN_ERR_OFFLINE_MEMBER = 1,
241 BG_JOIN_ERR_GROUP_TOO_MANY = 2,
242 BG_JOIN_ERR_MIXED_FACTION = 3,
243 BG_JOIN_ERR_MIXED_LEVELS = 4,
244 BG_JOIN_ERR_MIXED_ARENATEAM = 5,
245 BG_JOIN_ERR_GROUP_MEMBER_ALREADY_IN_QUEUE = 6,
246 BG_JOIN_ERR_GROUP_DESERTER = 7,
247 BG_JOIN_ERR_ALL_QUEUES_USED = 8,
248 BG_JOIN_ERR_GROUP_NOT_ENOUGH = 9
251 class BattleGroundScore
253 public:
254 BattleGroundScore() : KillingBlows(0), Deaths(0), HonorableKills(0),
255 BonusHonor(0), DamageDone(0), HealingDone(0)
257 virtual ~BattleGroundScore() {} //virtual destructor is used when deleting score from scores map
259 uint32 KillingBlows;
260 uint32 Deaths;
261 uint32 HonorableKills;
262 uint32 BonusHonor;
263 uint32 DamageDone;
264 uint32 HealingDone;
268 This class is used to:
269 1. Add player to battleground
270 2. Remove player from battleground
271 3. some certain cases, same for all battlegrounds
272 4. It has properties same for all battlegrounds
274 class BattleGround
276 friend class BattleGroundMgr;
278 public:
279 /* Construction */
280 BattleGround();
281 /*BattleGround(const BattleGround& bg);*/
282 virtual ~BattleGround();
283 virtual void Update(uint32 diff); // must be implemented in BG subclass of BG specific update code, but must in begginning call parent version
284 virtual bool SetupBattleGround() // must be implemented in BG subclass
286 return true;
288 virtual void Reset(); // resets all common properties for battlegrounds, must be implemented and called in BG subclass
289 virtual void StartingEventCloseDoors() {}
290 virtual void StartingEventOpenDoors() {}
292 /* achievement req. */
293 virtual bool IsAllNodesConrolledByTeam(uint32 /*team*/) const { return false; }
294 bool IsTeamScoreInRange(uint32 team, uint32 minScore, uint32 maxScore) const;
296 /* Battleground */
297 // Get methods:
298 char const* GetName() const { return m_Name; }
299 BattleGroundTypeId GetTypeID() const { return m_TypeID; }
300 BattleGroundBracketId GetBracketId() const { return m_BracketId; }
301 uint32 GetInstanceID() const { return m_InstanceID; }
302 BattleGroundStatus GetStatus() const { return m_Status; }
303 uint32 GetClientInstanceID() const { return m_ClientInstanceID; }
304 uint32 GetStartTime() const { return m_StartTime; }
305 uint32 GetEndTime() const { return m_EndTime; }
306 uint32 GetMaxPlayers() const { return m_MaxPlayers; }
307 uint32 GetMinPlayers() const { return m_MinPlayers; }
309 uint32 GetMinLevel() const { return m_LevelMin; }
310 uint32 GetMaxLevel() const { return m_LevelMax; }
312 uint32 GetMaxPlayersPerTeam() const { return m_MaxPlayersPerTeam; }
313 uint32 GetMinPlayersPerTeam() const { return m_MinPlayersPerTeam; }
315 int32 GetStartDelayTime() const { return m_StartDelayTime; }
316 uint8 GetArenaType() const { return m_ArenaType; }
317 uint8 GetWinner() const { return m_Winner; }
318 uint32 GetBattlemasterEntry() const;
319 uint32 GetBonusHonorFromKill(uint32 kills) const;
321 // Set methods:
322 void SetName(char const* Name) { m_Name = Name; }
323 void SetTypeID(BattleGroundTypeId TypeID) { m_TypeID = TypeID; }
324 //here we can count minlevel and maxlevel for players
325 void SetBracket(PvPDifficultyEntry const* bracketEntry);
326 void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; }
327 void SetStatus(BattleGroundStatus Status) { m_Status = Status; }
328 void SetClientInstanceID(uint32 InstanceID) { m_ClientInstanceID = InstanceID; }
329 void SetStartTime(uint32 Time) { m_StartTime = Time; }
330 void SetEndTime(uint32 Time) { m_EndTime = Time; }
331 void SetMaxPlayers(uint32 MaxPlayers) { m_MaxPlayers = MaxPlayers; }
332 void SetMinPlayers(uint32 MinPlayers) { m_MinPlayers = MinPlayers; }
333 void SetLevelRange(uint32 min, uint32 max) { m_LevelMin = min; m_LevelMax = max; }
334 void SetRated(bool state) { m_IsRated = state; }
335 void SetArenaType(uint8 type) { m_ArenaType = type; }
336 void SetArenaorBGType(bool _isArena) { m_IsArena = _isArena; }
337 void SetWinner(uint8 winner) { m_Winner = winner; }
339 void ModifyStartDelayTime(int diff) { m_StartDelayTime -= diff; }
340 void SetStartDelayTime(int Time) { m_StartDelayTime = Time; }
342 void SetMaxPlayersPerTeam(uint32 MaxPlayers) { m_MaxPlayersPerTeam = MaxPlayers; }
343 void SetMinPlayersPerTeam(uint32 MinPlayers) { m_MinPlayersPerTeam = MinPlayers; }
345 void AddToBGFreeSlotQueue(); //this queue will be useful when more battlegrounds instances will be available
346 void RemoveFromBGFreeSlotQueue(); //this method could delete whole BG instance, if another free is available
348 void DecreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; }
349 void IncreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; }
350 uint32 GetInvitedCount(uint32 team) const
352 if (team == ALLIANCE)
353 return m_InvitedAlliance;
354 else
355 return m_InvitedHorde;
357 bool HasFreeSlots() const;
358 uint32 GetFreeSlotsForTeam(uint32 Team) const;
360 bool isArena() const { return m_IsArena; }
361 bool isBattleGround() const { return !m_IsArena; }
362 bool isRated() const { return m_IsRated; }
364 typedef std::map<uint64, BattleGroundPlayer> BattleGroundPlayerMap;
365 BattleGroundPlayerMap const& GetPlayers() const { return m_Players; }
366 uint32 GetPlayersSize() const { return m_Players.size(); }
368 typedef std::map<uint64, BattleGroundScore*> BattleGroundScoreMap;
369 BattleGroundScoreMap::const_iterator GetPlayerScoresBegin() const { return m_PlayerScores.begin(); }
370 BattleGroundScoreMap::const_iterator GetPlayerScoresEnd() const { return m_PlayerScores.end(); }
371 uint32 GetPlayerScoresSize() const { return m_PlayerScores.size(); }
373 void StartBattleGround();
375 /* Location */
376 void SetMapId(uint32 MapID) { m_MapId = MapID; }
377 uint32 GetMapId() const { return m_MapId; }
379 /* Map pointers */
380 void SetBgMap(BattleGroundMap* map) { m_Map = map; }
381 BattleGroundMap* GetBgMap()
383 ASSERT(m_Map);
384 return m_Map;
387 void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O);
388 void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const
390 BattleGroundTeamId idx = GetTeamIndexByTeamId(TeamID);
391 X = m_TeamStartLocX[idx];
392 Y = m_TeamStartLocY[idx];
393 Z = m_TeamStartLocZ[idx];
394 O = m_TeamStartLocO[idx];
397 /* Packet Transfer */
398 // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!)
399 virtual void FillInitialWorldStates(WorldPacket& /*data*/) {}
400 void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender = NULL, bool self = true);
401 void SendPacketToAll(WorldPacket *packet);
403 template<class Do>
404 void BroadcastWorker(Do& _do);
406 void PlaySoundToTeam(uint32 SoundID, uint32 TeamID);
407 void PlaySoundToAll(uint32 SoundID);
408 void CastSpellOnTeam(uint32 SpellID, uint32 TeamID);
409 void RewardHonorToTeam(uint32 Honor, uint32 TeamID);
410 void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID);
411 void RewardMark(Player *plr,uint32 count);
412 void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count);
413 void RewardItem(Player *plr, uint32 item_id, uint32 count);
414 void RewardQuestComplete(Player *plr);
415 void RewardSpellCast(Player *plr, uint32 spell_id);
416 void UpdateWorldState(uint32 Field, uint32 Value);
417 void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source);
418 void EndBattleGround(uint32 winner);
419 void BlockMovement(Player *plr);
421 void SendMessageToAll(int32 entry, ChatMsg type, Player const* source = NULL);
422 void SendYellToAll(int32 entry, uint32 language, uint64 const& guid);
423 void PSendMessageToAll(int32 entry, ChatMsg type, Player const* source, ... );
425 // specialized version with 2 string id args
426 void SendMessage2ToAll(int32 entry, ChatMsg type, Player const* source, int32 strId1 = 0, int32 strId2 = 0);
427 void SendYell2ToAll(int32 entry, uint32 language, uint64 const& guid, int32 arg1, int32 arg2);
429 /* Raid Group */
430 Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; }
431 void SetBgRaid(uint32 TeamID, Group *bg_raid);
433 virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
435 static BattleGroundTeamId GetTeamIndexByTeamId(uint32 Team) { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; }
436 uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; }
437 uint32 GetAlivePlayersCountByTeam(uint32 Team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases
438 void UpdatePlayersCountByTeam(uint32 Team, bool remove)
440 if (remove)
441 --m_PlayersCount[GetTeamIndexByTeamId(Team)];
442 else
443 ++m_PlayersCount[GetTeamIndexByTeamId(Team)];
446 // used for rated arena battles
447 void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; }
448 uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; }
449 void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; }
450 int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; }
451 void CheckArenaWinConditions();
453 /* Triggers handle */
454 // must be implemented in BG subclass
455 virtual void HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) {}
456 // must be implemented in BG subclass if need AND call base class generic code
457 virtual void HandleKillPlayer(Player *player, Player *killer);
458 virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/) { return; };
460 /* Battleground events */
461 virtual void EventPlayerDroppedFlag(Player* /*player*/) {}
462 virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {}
463 virtual void EventPlayerCapturedFlag(Player* /*player*/) {}
464 void EventPlayerLoggedIn(Player* player, uint64 plr_guid);
465 void EventPlayerLoggedOut(Player* player);
467 /* Death related */
468 virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
470 virtual void AddPlayer(Player *plr); // must be implemented in BG subclass
472 void AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid, uint32 team);
474 virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket);
475 // can be extended in in BG subclass
477 /* event related */
478 // called when a creature gets added to map (NOTE: only triggered if
479 // a player activates the cell of the creature)
480 void OnObjectDBLoad(Creature* /*creature*/);
481 void OnObjectDBLoad(GameObject* /*obj*/);
482 // (de-)spawns creatures and gameobjects from an event
483 void SpawnEvent(uint8 event1, uint8 event2, bool spawn);
484 bool IsActiveEvent(uint8 event1, uint8 event2)
486 if (m_ActiveEvents.find(event1) == m_ActiveEvents.end())
487 return false;
488 return m_ActiveEvents[event1] == event2;
490 uint64 GetSingleCreatureGuid(uint8 event1, uint8 event2);
492 void OpenDoorEvent(uint8 event1, uint8 event2 = 0);
493 bool IsDoor(uint8 event1, uint8 event2);
495 void HandleTriggerBuff(uint64 const& go_guid);
497 // TODO: make this protected:
498 typedef std::vector<uint64> BGObjects;
499 typedef std::vector<uint64> BGCreatures;
500 // TODO drop m_BGObjects
501 BGObjects m_BgObjects;
502 void SpawnBGObject(uint64 const& guid, uint32 respawntime);
503 bool AddObject(uint32 type, uint32 entry, float x, float y, float z, float o, float rotation0, float rotation1, float rotation2, float rotation3, uint32 respawnTime = 0);
504 void SpawnBGCreature(uint64 const& guid, uint32 respawntime);
505 bool DelObject(uint32 type);
507 void DoorOpen(uint64 const& guid);
508 void DoorClose(uint64 const& guid);
510 virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; }
512 // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player
513 uint32 GetPlayerTeam(uint64 guid);
514 uint32 GetOtherTeam(uint32 teamId){ return (teamId) ? ((teamId == ALLIANCE) ? HORDE : ALLIANCE) : 0; }
515 bool IsPlayerInBattleGround(uint64 guid);
517 void SetDeleteThis() {m_SetDeleteThis = true;}
519 /* virtual score-array - get's used in bg-subclasses */
520 int32 m_TeamScores[BG_TEAMS_COUNT];
522 struct EventObjects
524 BGObjects gameobjects;
525 BGCreatures creatures;
528 // cause we create it dynamicly i use a map - to avoid resizing when
529 // using vector - also it contains 2*events concatenated with PAIR32
530 // this is needed to avoid overhead of a 2dimensional std::map
531 std::map<uint32, EventObjects> m_EventObjects;
532 // this must be filled first in BattleGroundXY::Reset().. else
533 // creatures will get added wrong
534 // door-events are automaticly added - but _ALL_ other must be in this vector
535 std::map<uint8, uint8> m_ActiveEvents;
538 protected:
539 //this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends BattleGround
540 void EndNow();
541 void PlayerAddedToBGCheckIfBGIsRunning(Player* plr);
543 /* Scorekeeping */
545 BattleGroundScoreMap m_PlayerScores; // Player scores
546 // must be implemented in BG subclass
547 virtual void RemovePlayer(Player * /*player*/, uint64 /*guid*/) {}
549 /* Player lists, those need to be accessible by inherited classes */
550 BattleGroundPlayerMap m_Players;
553 these are important variables used for starting messages
555 uint8 m_Events;
556 BattleGroundStartTimeIntervals m_StartDelayTimes[BG_STARTING_EVENT_COUNT];
557 //this must be filled in constructors!
558 uint32 m_StartMessageIds[BG_STARTING_EVENT_COUNT];
560 bool m_BuffChange;
562 private:
563 /* Battleground */
564 BattleGroundTypeId m_TypeID;
565 uint32 m_InstanceID; //BattleGround Instance's GUID!
566 BattleGroundStatus m_Status;
567 uint32 m_ClientInstanceID; //the instance-id which is sent to the client and without any other internal use
568 uint32 m_StartTime;
569 bool m_ArenaBuffSpawned; // to cache if arenabuff event is started (cause bool is faster than checking IsActiveEvent)
570 int32 m_EndTime; // it is set to 120000 when bg is ending and it decreases itself
571 BattleGroundBracketId m_BracketId;
572 uint8 m_ArenaType; // 2=2v2, 3=3v3, 5=5v5
573 bool m_InBGFreeSlotQueue; // used to make sure that BG is only once inserted into the BattleGroundMgr.BGFreeSlotQueue[bgTypeId] deque
574 bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave
575 bool m_IsArena;
576 uint8 m_Winner; // 0=alliance, 1=horde, 2=none
577 int32 m_StartDelayTime;
578 bool m_IsRated; // is this battle rated?
579 bool m_PrematureCountDown;
580 uint32 m_PrematureCountDownTimer;
581 char const *m_Name;
583 /* Player lists */
584 std::vector<uint64> m_ResurrectQueue; // Player GUID
585 std::deque<uint64> m_OfflineQueue; // Player GUID
587 /* Invited counters are useful for player invitation to BG - do not allow, if BG is started to one faction to have 2 more players than another faction */
588 /* Invited counters will be changed only when removing already invited player from queue, removing player from battleground and inviting player to BG */
589 /* Invited players counters*/
590 uint32 m_InvitedAlliance;
591 uint32 m_InvitedHorde;
593 /* Raid Group */
594 Group *m_BgRaids[BG_TEAMS_COUNT]; // 0 - alliance, 1 - horde
596 /* Players count by team */
597 uint32 m_PlayersCount[BG_TEAMS_COUNT];
599 /* Arena team ids by team */
600 uint32 m_ArenaTeamIds[BG_TEAMS_COUNT];
602 int32 m_ArenaTeamRatingChanges[BG_TEAMS_COUNT];
604 /* Limits */
605 uint32 m_LevelMin;
606 uint32 m_LevelMax;
607 uint32 m_MaxPlayersPerTeam;
608 uint32 m_MaxPlayers;
609 uint32 m_MinPlayersPerTeam;
610 uint32 m_MinPlayers;
612 /* Start location */
613 uint32 m_MapId;
614 BattleGroundMap* m_Map;
615 float m_TeamStartLocX[BG_TEAMS_COUNT];
616 float m_TeamStartLocY[BG_TEAMS_COUNT];
617 float m_TeamStartLocZ[BG_TEAMS_COUNT];
618 float m_TeamStartLocO[BG_TEAMS_COUNT];
620 #endif