1 | /* |
---|
2 | * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> |
---|
3 | * |
---|
4 | * Thanks to the original authors: MaNGOS <http://www.mangosproject.org/> |
---|
5 | * |
---|
6 | * This program is free software; you can redistribute it and/or modify |
---|
7 | * it under the terms of the GNU General Public License as published by |
---|
8 | * the Free Software Foundation; either version 2 of the License, or |
---|
9 | * (at your option) any later version. |
---|
10 | * |
---|
11 | * This program is distributed in the hope that it will be useful, |
---|
12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
14 | * GNU General Public License for more details. |
---|
15 | * |
---|
16 | * You should have received a copy of the GNU General Public License |
---|
17 | * along with this program; if not, write to the Free Software |
---|
18 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
---|
19 | */ |
---|
20 | |
---|
21 | #ifndef __BATTLEGROUND_H |
---|
22 | #define __BATTLEGROUND_H |
---|
23 | |
---|
24 | #include "Common.h" |
---|
25 | #include "WorldPacket.h" |
---|
26 | #include "WorldSession.h" |
---|
27 | #include "Opcodes.h" |
---|
28 | #include "ObjectMgr.h" |
---|
29 | #include "BattleGroundMgr.h" |
---|
30 | #include "SharedDefines.h" |
---|
31 | |
---|
32 | enum BattleGroundSounds |
---|
33 | { |
---|
34 | SOUND_HORDE_WINS = 8454, |
---|
35 | SOUND_ALLIANCE_WINS = 8455, |
---|
36 | SOUND_BG_START = 3439, |
---|
37 | SOUND_BG_START_L70ETC = 11803, |
---|
38 | }; |
---|
39 | |
---|
40 | enum BattleGroundQuests |
---|
41 | { |
---|
42 | SPELL_WS_QUEST_REWARD = 43483, |
---|
43 | SPELL_AB_QUEST_REWARD = 43484, |
---|
44 | SPELL_AV_QUEST_REWARD = 43475, |
---|
45 | SPELL_AV_QUEST_KILLED_BOSS = 23658, |
---|
46 | SPELL_EY_QUEST_REWARD = 43477, |
---|
47 | SPELL_AB_QUEST_REWARD_4_BASES = 24061, |
---|
48 | SPELL_AB_QUEST_REWARD_5_BASES = 24064 |
---|
49 | }; |
---|
50 | |
---|
51 | enum BattleGroundMarks |
---|
52 | { |
---|
53 | SPELL_WS_MARK_LOSER = 24950, |
---|
54 | SPELL_WS_MARK_WINNER = 24951, |
---|
55 | SPELL_AB_MARK_LOSER = 24952, |
---|
56 | SPELL_AB_MARK_WINNER = 24953, |
---|
57 | SPELL_AV_MARK_LOSER = 24954, |
---|
58 | SPELL_AV_MARK_WINNER = 24955, |
---|
59 | ITEM_EY_MARK_OF_HONOR = 29024 |
---|
60 | }; |
---|
61 | |
---|
62 | enum BattleGroundMarksCount |
---|
63 | { |
---|
64 | ITEM_WINNER_COUNT = 3, |
---|
65 | ITEM_LOSER_COUNT = 1 |
---|
66 | }; |
---|
67 | |
---|
68 | enum BattleGroundSpells |
---|
69 | { |
---|
70 | SPELL_WAITING_FOR_RESURRECT = 2584, // Waiting to Resurrect |
---|
71 | SPELL_SPIRIT_HEAL_CHANNEL = 22011, // Spirit Heal Channel |
---|
72 | SPELL_SPIRIT_HEAL = 22012, // Spirit Heal |
---|
73 | SPELL_RESURRECTION_VISUAL = 24171, // Resurrection Impact Visual |
---|
74 | SPELL_ARENA_PREPARATION = 32727, // use this one, 32728 not correct |
---|
75 | SPELL_ALLIANCE_GOLD_FLAG = 32724, |
---|
76 | SPELL_ALLIANCE_GREEN_FLAG = 32725, |
---|
77 | SPELL_HORDE_GOLD_FLAG = 35774, |
---|
78 | SPELL_HORDE_GREEN_FLAG = 35775, |
---|
79 | SPELL_PREPARATION = 44521, // Preparation |
---|
80 | SPELL_SPIRIT_HEAL_MANA = 44535, // Spirit Heal |
---|
81 | SPELL_RECENTLY_DROPPED_FLAG = 42792, // Recently Dropped Flag |
---|
82 | SPELL_AURA_PLAYER_INACTIVE = 43681 // Inactive |
---|
83 | }; |
---|
84 | |
---|
85 | enum BattleGroundTimeIntervals |
---|
86 | { |
---|
87 | RESURRECTION_INTERVAL = 30000, // ms |
---|
88 | REMIND_INTERVAL = 30000, // ms |
---|
89 | INVITE_ACCEPT_WAIT_TIME = 120000, // ms |
---|
90 | TIME_TO_AUTOREMOVE = 120000, // ms |
---|
91 | MAX_OFFLINE_TIME = 300000, // ms |
---|
92 | START_DELAY0 = 120000, // ms |
---|
93 | START_DELAY1 = 60000, // ms |
---|
94 | START_DELAY2 = 30000, // ms |
---|
95 | START_DELAY3 = 15000, // ms used only in arena |
---|
96 | RESPAWN_ONE_DAY = 86400, // secs |
---|
97 | RESPAWN_IMMEDIATELY = 0, // secs |
---|
98 | BUFF_RESPAWN_TIME = 180 // secs |
---|
99 | }; |
---|
100 | |
---|
101 | enum BattleGroundBuffObjects |
---|
102 | { |
---|
103 | BG_OBJECTID_SPEEDBUFF_ENTRY = 179871, |
---|
104 | BG_OBJECTID_REGENBUFF_ENTRY = 179904, |
---|
105 | BG_OBJECTID_BERSERKERBUFF_ENTRY = 179905 |
---|
106 | }; |
---|
107 | |
---|
108 | const uint32 Buff_Entries[3] = { BG_OBJECTID_SPEEDBUFF_ENTRY, BG_OBJECTID_REGENBUFF_ENTRY, BG_OBJECTID_BERSERKERBUFF_ENTRY }; |
---|
109 | |
---|
110 | enum BattleGroundStatus |
---|
111 | { |
---|
112 | STATUS_NONE = 0, |
---|
113 | STATUS_WAIT_QUEUE = 1, |
---|
114 | STATUS_WAIT_JOIN = 2, |
---|
115 | STATUS_IN_PROGRESS = 3, |
---|
116 | STATUS_WAIT_LEAVE = 4 // custom |
---|
117 | }; |
---|
118 | |
---|
119 | struct BattleGroundPlayer |
---|
120 | { |
---|
121 | uint32 LastOnlineTime; // for tracking and removing offline players from queue after 5 minutes |
---|
122 | uint32 Team; // Player's team |
---|
123 | }; |
---|
124 | |
---|
125 | struct BattleGroundObjectInfo |
---|
126 | { |
---|
127 | BattleGroundObjectInfo() : object(NULL), timer(0), spellid(0) {} |
---|
128 | |
---|
129 | GameObject *object; |
---|
130 | int32 timer; |
---|
131 | uint32 spellid; |
---|
132 | }; |
---|
133 | |
---|
134 | #define MAX_QUEUED_PLAYERS_MAP 7 |
---|
135 | |
---|
136 | enum BattleGroundTypeId |
---|
137 | { |
---|
138 | BATTLEGROUND_AV = 1, |
---|
139 | BATTLEGROUND_WS = 2, |
---|
140 | BATTLEGROUND_AB = 3, |
---|
141 | BATTLEGROUND_NA = 4, |
---|
142 | BATTLEGROUND_BE = 5, |
---|
143 | BATTLEGROUND_AA = 6, |
---|
144 | BATTLEGROUND_EY = 7, |
---|
145 | BATTLEGROUND_RL = 8 |
---|
146 | }; |
---|
147 | |
---|
148 | // handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time |
---|
149 | enum BattleGroundQueueTypeId |
---|
150 | { |
---|
151 | BATTLEGROUND_QUEUE_AV = 1, |
---|
152 | BATTLEGROUND_QUEUE_WS = 2, |
---|
153 | BATTLEGROUND_QUEUE_AB = 3, |
---|
154 | BATTLEGROUND_QUEUE_EY = 4, |
---|
155 | BATTLEGROUND_QUEUE_2v2 = 5, |
---|
156 | BATTLEGROUND_QUEUE_3v3 = 6, |
---|
157 | BATTLEGROUND_QUEUE_5v5 = 7, |
---|
158 | }; |
---|
159 | |
---|
160 | enum ScoreType |
---|
161 | { |
---|
162 | SCORE_KILLING_BLOWS = 1, |
---|
163 | SCORE_DEATHS = 2, |
---|
164 | SCORE_HONORABLE_KILLS = 3, |
---|
165 | SCORE_BONUS_HONOR = 4, |
---|
166 | //EY, but in MSG_PVP_LOG_DATA opcode! |
---|
167 | SCORE_DAMAGE_DONE = 5, |
---|
168 | SCORE_HEALING_DONE = 6, |
---|
169 | //WS |
---|
170 | SCORE_FLAG_CAPTURES = 7, |
---|
171 | SCORE_FLAG_RETURNS = 8, |
---|
172 | //AB |
---|
173 | SCORE_BASES_ASSAULTED = 9, |
---|
174 | SCORE_BASES_DEFENDED = 10, |
---|
175 | //AV |
---|
176 | SCORE_GRAVEYARDS_ASSAULTED = 11, |
---|
177 | SCORE_GRAVEYARDS_DEFENDED = 12, |
---|
178 | SCORE_TOWERS_ASSAULTED = 13, |
---|
179 | SCORE_TOWERS_DEFENDED = 14, |
---|
180 | SCORE_MINES_CAPTURED = 15, |
---|
181 | SCORE_LEADERS_KILLED = 16, |
---|
182 | SCORE_SECONDARY_OBJECTIVES = 17 |
---|
183 | // TODO : implement them |
---|
184 | }; |
---|
185 | |
---|
186 | enum ArenaType |
---|
187 | { |
---|
188 | ARENA_TYPE_2v2 = 2, |
---|
189 | ARENA_TYPE_3v3 = 3, |
---|
190 | ARENA_TYPE_5v5 = 5 |
---|
191 | }; |
---|
192 | |
---|
193 | enum BattleGroundType |
---|
194 | { |
---|
195 | TYPE_BATTLEGROUND = 3, |
---|
196 | TYPE_ARENA = 4 |
---|
197 | }; |
---|
198 | |
---|
199 | enum BattleGroundWinner |
---|
200 | { |
---|
201 | WINNER_HORDE = 0, |
---|
202 | WINNER_ALLIANCE = 1, |
---|
203 | WINNER_NONE = 2 |
---|
204 | }; |
---|
205 | |
---|
206 | enum BattleGroundTeamId |
---|
207 | { |
---|
208 | BG_TEAM_ALLIANCE = 0, |
---|
209 | BG_TEAM_HORDE = 1 |
---|
210 | }; |
---|
211 | |
---|
212 | enum BattleGroundJoinError |
---|
213 | { |
---|
214 | BG_JOIN_ERR_OK = 0, |
---|
215 | BG_JOIN_ERR_OFFLINE_MEMBER = 1, |
---|
216 | BG_JOIN_ERR_GROUP_TOO_MANY = 2, |
---|
217 | BG_JOIN_ERR_MIXED_FACTION = 3, |
---|
218 | BG_JOIN_ERR_MIXED_LEVELS = 4, |
---|
219 | BG_JOIN_ERR_MIXED_ARENATEAM = 5, |
---|
220 | BG_JOIN_ERR_GROUP_MEMBER_ALREADY_IN_QUEUE = 6, |
---|
221 | BG_JOIN_ERR_GROUP_DESERTER = 7, |
---|
222 | BG_JOIN_ERR_ALL_QUEUES_USED = 8, |
---|
223 | BG_JOIN_ERR_GROUP_NOT_ENOUGH = 9 |
---|
224 | }; |
---|
225 | |
---|
226 | class BattleGroundScore |
---|
227 | { |
---|
228 | public: |
---|
229 | BattleGroundScore() : KillingBlows(0), HonorableKills(0), Deaths(0), DamageDone(0), HealingDone(0), BonusHonor(0) {}; |
---|
230 | virtual ~BattleGroundScore() //virtual destructor is used when deleting score from scores map |
---|
231 | { |
---|
232 | }; |
---|
233 | uint32 KillingBlows; |
---|
234 | uint32 Deaths; |
---|
235 | uint32 HonorableKills; |
---|
236 | uint32 BonusHonor; |
---|
237 | uint32 DamageDone; |
---|
238 | uint32 HealingDone; |
---|
239 | }; |
---|
240 | |
---|
241 | enum BGHonorMode |
---|
242 | { |
---|
243 | BG_NORMAL = 0, |
---|
244 | BG_HOLIDAY, |
---|
245 | BG_HONOR_MODE_NUM |
---|
246 | }; |
---|
247 | |
---|
248 | /* |
---|
249 | This class is used to: |
---|
250 | 1. Add player to battleground |
---|
251 | 2. Remove player from battleground |
---|
252 | 3. some certain cases, same for all battlegrounds |
---|
253 | 4. It has properties same for all battlegrounds |
---|
254 | */ |
---|
255 | class BattleGround |
---|
256 | { |
---|
257 | friend class BattleGroundMgr; |
---|
258 | |
---|
259 | public: |
---|
260 | /* Construction */ |
---|
261 | BattleGround(); |
---|
262 | virtual ~BattleGround(); |
---|
263 | virtual void Update(time_t diff); // must be implemented in BG subclass of BG specific update code, but must in begginning call parent version |
---|
264 | virtual bool SetupBattleGround() // must be implemented in BG subclass |
---|
265 | { |
---|
266 | return true; |
---|
267 | } |
---|
268 | void Reset(); // resets all common properties for battlegrounds |
---|
269 | virtual void ResetBGSubclass() // must be implemented in BG subclass |
---|
270 | { |
---|
271 | } |
---|
272 | |
---|
273 | /* Battleground */ |
---|
274 | // Get methods: |
---|
275 | char const* GetName() const { return m_Name; } |
---|
276 | uint32 GetTypeID() const { return m_TypeID; } |
---|
277 | uint32 GetQueueType() const { return m_Queue_type; } |
---|
278 | uint32 GetInstanceID() const { return m_InstanceID; } |
---|
279 | uint32 GetStatus() const { return m_Status; } |
---|
280 | uint32 GetStartTime() const { return m_StartTime; } |
---|
281 | uint32 GetEndTime() const { return m_EndTime; } |
---|
282 | uint32 GetLastResurrectTime() const { return m_LastResurrectTime; } |
---|
283 | uint32 GetMaxPlayers() const { return m_MaxPlayers; } |
---|
284 | uint32 GetMinPlayers() const { return m_MinPlayers; } |
---|
285 | |
---|
286 | uint32 GetMinLevel() const { return m_LevelMin; } |
---|
287 | uint32 GetMaxLevel() const { return m_LevelMax; } |
---|
288 | |
---|
289 | uint32 GetMaxPlayersPerTeam() const { return m_MaxPlayersPerTeam; } |
---|
290 | uint32 GetMinPlayersPerTeam() const { return m_MinPlayersPerTeam; } |
---|
291 | |
---|
292 | int GetStartDelayTime() const { return m_StartDelayTime; } |
---|
293 | uint8 GetArenaType() const { return m_ArenaType; } |
---|
294 | uint8 GetWinner() const { return m_Winner; } |
---|
295 | uint32 GetBattlemasterEntry() const; |
---|
296 | |
---|
297 | // Set methods: |
---|
298 | void SetName(char const* Name) { m_Name = Name; } |
---|
299 | void SetTypeID(uint32 TypeID) { m_TypeID = TypeID; } |
---|
300 | void SetQueueType(uint32 ID) { m_Queue_type = ID; } |
---|
301 | void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; } |
---|
302 | void SetStatus(uint32 Status) { m_Status = Status; } |
---|
303 | void SetStartTime(uint32 Time) { m_StartTime = Time; } |
---|
304 | void SetEndTime(uint32 Time) { m_EndTime = Time; } |
---|
305 | void SetLastResurrectTime(uint32 Time) { m_LastResurrectTime = Time; } |
---|
306 | void SetMaxPlayers(uint32 MaxPlayers) { m_MaxPlayers = MaxPlayers; } |
---|
307 | void SetMinPlayers(uint32 MinPlayers) { m_MinPlayers = MinPlayers; } |
---|
308 | void SetLevelRange(uint32 min, uint32 max) { m_LevelMin = min; m_LevelMax = max; } |
---|
309 | void SetRated(bool state) { m_IsRated = state; } |
---|
310 | void SetArenaType(uint8 type) { m_ArenaType = type; } |
---|
311 | void SetArenaorBGType(bool _isArena) { m_IsArena = _isArena; } |
---|
312 | void SetWinner(uint8 winner) { m_Winner = winner; } |
---|
313 | |
---|
314 | void ModifyStartDelayTime(int diff) { m_StartDelayTime -= diff; } |
---|
315 | void SetStartDelayTime(int Time) { m_StartDelayTime = Time; } |
---|
316 | |
---|
317 | void SetMaxPlayersPerTeam(uint32 MaxPlayers) { m_MaxPlayersPerTeam = MaxPlayers; } |
---|
318 | void SetMinPlayersPerTeam(uint32 MinPlayers) { m_MinPlayersPerTeam = MinPlayers; } |
---|
319 | |
---|
320 | void AddToBGFreeSlotQueue(); //this queue will be useful when more battlegrounds instances will be available |
---|
321 | void RemoveFromBGFreeSlotQueue(); //this method could delete whole BG instance, if another free is available |
---|
322 | |
---|
323 | void DecreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? --m_InvitedAlliance : --m_InvitedHorde; } |
---|
324 | void IncreaseInvitedCount(uint32 team) { (team == ALLIANCE) ? ++m_InvitedAlliance : ++m_InvitedHorde; } |
---|
325 | uint32 GetInvitedCount(uint32 team) const |
---|
326 | { |
---|
327 | if( team == ALLIANCE ) |
---|
328 | return m_InvitedAlliance; |
---|
329 | else |
---|
330 | return m_InvitedHorde; |
---|
331 | } |
---|
332 | bool HasFreeSlotsForTeam(uint32 Team) const; |
---|
333 | bool HasFreeSlots() const; |
---|
334 | uint32 GetFreeSlotsForTeam(uint32 Team) const; |
---|
335 | |
---|
336 | bool isArena() const { return m_IsArena; } |
---|
337 | bool isBattleGround() const { return !m_IsArena; } |
---|
338 | bool isRated() const { return m_IsRated; } |
---|
339 | |
---|
340 | typedef std::map<uint64, BattleGroundPlayer> BattleGroundPlayerMap; |
---|
341 | BattleGroundPlayerMap const& GetPlayers() const { return m_Players; } |
---|
342 | uint32 GetPlayersSize() const { return m_Players.size(); } |
---|
343 | uint32 GetRemovedPlayersSize() const { return m_RemovedPlayers.size(); } |
---|
344 | |
---|
345 | std::map<uint64, BattleGroundScore*>::const_iterator GetPlayerScoresBegin() const { return m_PlayerScores.begin(); } |
---|
346 | std::map<uint64, BattleGroundScore*>::const_iterator GetPlayerScoresEnd() const { return m_PlayerScores.end(); } |
---|
347 | uint32 GetPlayerScoresSize() const { return m_PlayerScores.size(); } |
---|
348 | |
---|
349 | uint32 GetReviveQueueSize() const { return m_ReviveQueue.size(); } |
---|
350 | |
---|
351 | void AddPlayerToResurrectQueue(uint64 npc_guid, uint64 player_guid); |
---|
352 | void RemovePlayerFromResurrectQueue(uint64 player_guid); |
---|
353 | |
---|
354 | void StartBattleGround(); |
---|
355 | |
---|
356 | /* Location */ |
---|
357 | void SetMapId(uint32 MapID) { m_MapId = MapID; } |
---|
358 | uint32 GetMapId() const { return m_MapId; } |
---|
359 | |
---|
360 | void SetTeamStartLoc(uint32 TeamID, float X, float Y, float Z, float O); |
---|
361 | void GetTeamStartLoc(uint32 TeamID, float &X, float &Y, float &Z, float &O) const |
---|
362 | { |
---|
363 | uint8 idx = GetTeamIndexByTeamId(TeamID); |
---|
364 | X = m_TeamStartLocX[idx]; |
---|
365 | Y = m_TeamStartLocY[idx]; |
---|
366 | Z = m_TeamStartLocZ[idx]; |
---|
367 | O = m_TeamStartLocO[idx]; |
---|
368 | } |
---|
369 | |
---|
370 | /* Packet Transfer */ |
---|
371 | // method that should fill worldpacket with actual world states (not yet implemented for all battlegrounds!) |
---|
372 | virtual void FillInitialWorldStates(WorldPacket& /*data*/) {} |
---|
373 | void SendPacketToTeam(uint32 TeamID, WorldPacket *packet, Player *sender = NULL, bool self = true); |
---|
374 | void SendPacketToAll(WorldPacket *packet); |
---|
375 | void PlaySoundToTeam(uint32 SoundID, uint32 TeamID); |
---|
376 | void PlaySoundToAll(uint32 SoundID); |
---|
377 | void CastSpellOnTeam(uint32 SpellID, uint32 TeamID); |
---|
378 | void RewardHonorToTeam(uint32 Honor, uint32 TeamID); |
---|
379 | void RewardReputationToTeam(uint32 faction_id, uint32 Reputation, uint32 TeamID); |
---|
380 | void RewardMark(Player *plr,uint32 count); |
---|
381 | void SendRewardMarkByMail(Player *plr,uint32 mark, uint32 count); |
---|
382 | void RewardQuest(Player *plr); |
---|
383 | void UpdateWorldState(uint32 Field, uint32 Value); |
---|
384 | void UpdateWorldStateForPlayer(uint32 Field, uint32 Value, Player *Source); |
---|
385 | void EndBattleGround(uint32 winner); |
---|
386 | void BlockMovement(Player *plr); |
---|
387 | |
---|
388 | void SendMessageToAll(char const* text); |
---|
389 | void SendMessageToAll(int32 entry); |
---|
390 | |
---|
391 | /* Raid Group */ |
---|
392 | Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; } |
---|
393 | void SetBgRaid(uint32 TeamID, Group *bg_raid) |
---|
394 | { |
---|
395 | Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; |
---|
396 | if(old_raid) old_raid->SetBattlegroundGroup(NULL); |
---|
397 | if(bg_raid) bg_raid->SetBattlegroundGroup(this); |
---|
398 | old_raid = bg_raid; |
---|
399 | } |
---|
400 | |
---|
401 | virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); |
---|
402 | |
---|
403 | uint8 GetTeamIndexByTeamId(uint32 Team) const { return Team == ALLIANCE ? BG_TEAM_ALLIANCE : BG_TEAM_HORDE; } |
---|
404 | uint32 GetPlayersCountByTeam(uint32 Team) const { return m_PlayersCount[GetTeamIndexByTeamId(Team)]; } |
---|
405 | uint32 GetAlivePlayersCountByTeam(uint32 Team) const; // used in arenas to correctly handle death in spirit of redemption / last stand etc. (killer = killed) cases |
---|
406 | void UpdatePlayersCountByTeam(uint32 Team, bool remove) |
---|
407 | { |
---|
408 | if(remove) |
---|
409 | --m_PlayersCount[GetTeamIndexByTeamId(Team)]; |
---|
410 | else |
---|
411 | ++m_PlayersCount[GetTeamIndexByTeamId(Team)]; |
---|
412 | } |
---|
413 | |
---|
414 | // used for rated arena battles |
---|
415 | void SetArenaTeamIdForTeam(uint32 Team, uint32 ArenaTeamId) { m_ArenaTeamIds[GetTeamIndexByTeamId(Team)] = ArenaTeamId; } |
---|
416 | uint32 GetArenaTeamIdForTeam(uint32 Team) const { return m_ArenaTeamIds[GetTeamIndexByTeamId(Team)]; } |
---|
417 | void SetArenaTeamRatingChangeForTeam(uint32 Team, int32 RatingChange) { m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)] = RatingChange; } |
---|
418 | int32 GetArenaTeamRatingChangeForTeam(uint32 Team) const { return m_ArenaTeamRatingChanges[GetTeamIndexByTeamId(Team)]; } |
---|
419 | |
---|
420 | /* Triggers handle */ |
---|
421 | // must be implemented in BG subclass |
---|
422 | virtual void HandleAreaTrigger(Player* /*Source*/, uint32 /*Trigger*/) {} |
---|
423 | // must be implemented in BG subclass if need AND call base class generic code |
---|
424 | virtual void HandleKillPlayer(Player *player, Player *killer); |
---|
425 | |
---|
426 | /* Battleground events */ |
---|
427 | /* these functions will return true event is possible, but false if player is bugger */ |
---|
428 | virtual void EventPlayerDroppedFlag(Player* /*player*/) {} |
---|
429 | virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {} |
---|
430 | virtual void EventPlayerCapturedFlag(Player* /*player*/) {} |
---|
431 | |
---|
432 | /* Death related */ |
---|
433 | virtual WorldSafeLocsEntry const* GetClosestGraveYard(float /*x*/, float /*y*/, float /*z*/, uint32 /*team*/) { return NULL; } |
---|
434 | |
---|
435 | virtual void AddPlayer(Player *plr); // must be implemented in BG subclass |
---|
436 | |
---|
437 | virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); |
---|
438 | // can be extended in in BG subclass |
---|
439 | |
---|
440 | void HandleTriggerBuff(uint64 const& go_guid); |
---|
441 | void SetHoliday(bool is_holiday); |
---|
442 | |
---|
443 | // TODO: make this protected: |
---|
444 | typedef std::vector<uint64> BGObjects; |
---|
445 | typedef std::vector<uint64> BGCreatures; |
---|
446 | BGObjects m_BgObjects; |
---|
447 | BGCreatures m_BgCreatures; |
---|
448 | void SpawnBGObject(uint32 type, uint32 respawntime); |
---|
449 | 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); |
---|
450 | // void SpawnBGCreature(uint32 type, uint32 respawntime); |
---|
451 | Creature* AddCreature(uint32 entry, uint32 type, uint32 teamval, float x, float y, float z, float o, uint32 respawntime = 0); |
---|
452 | bool DelCreature(uint32 type); |
---|
453 | bool DelObject(uint32 type); |
---|
454 | bool AddSpiritGuide(uint32 type, float x, float y, float z, float o, uint32 team); |
---|
455 | |
---|
456 | void DoorOpen(uint32 type); |
---|
457 | void DoorClose(uint32 type); |
---|
458 | const char *GetTrinityString(int32 entry); |
---|
459 | |
---|
460 | virtual bool HandlePlayerUnderMap(Player * plr) {return false;} |
---|
461 | |
---|
462 | // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player |
---|
463 | uint32 GetPlayerTeam(uint64 guid); |
---|
464 | |
---|
465 | void SetDeleteThis() {m_SetDeleteThis = true;} |
---|
466 | |
---|
467 | protected: |
---|
468 | //this method is called, when BG cannot spawn its own spirit guide, or something is wrong, It correctly ends BattleGround |
---|
469 | void EndNow(); |
---|
470 | |
---|
471 | /* Scorekeeping */ |
---|
472 | // Player scores |
---|
473 | std::map<uint64, BattleGroundScore*> m_PlayerScores; |
---|
474 | // must be implemented in BG subclass |
---|
475 | virtual void RemovePlayer(Player * /*player*/, uint64 /*guid*/) {} |
---|
476 | |
---|
477 | /* Player lists, those need to be accessible by inherited classes */ |
---|
478 | BattleGroundPlayerMap m_Players; |
---|
479 | // Spirit Guide guid + Player list GUIDS |
---|
480 | std::map<uint64, std::vector<uint64> > m_ReviveQueue; |
---|
481 | |
---|
482 | /* |
---|
483 | this is important variable used for invitation messages |
---|
484 | */ |
---|
485 | uint8 m_Events; |
---|
486 | |
---|
487 | bool m_BuffChange; |
---|
488 | |
---|
489 | BGHonorMode m_HonorMode; |
---|
490 | private: |
---|
491 | /* Battleground */ |
---|
492 | uint32 m_TypeID; //Battleground type, defined in enum BattleGroundTypeId |
---|
493 | uint32 m_InstanceID; //BattleGround Instance's GUID! |
---|
494 | uint32 m_Status; |
---|
495 | uint32 m_StartTime; |
---|
496 | uint32 m_EndTime; |
---|
497 | uint32 m_LastResurrectTime; |
---|
498 | uint32 m_Queue_type; |
---|
499 | uint8 m_ArenaType; // 2=2v2, 3=3v3, 5=5v5 |
---|
500 | bool m_InBGFreeSlotQueue; // used to make sure that BG is only once inserted into the BattleGroundMgr.BGFreeSlotQueue[bgTypeId] deque |
---|
501 | bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave |
---|
502 | // this variable is not used .... it can be found in many other ways... but to store it in BG object instance is useless |
---|
503 | //uint8 m_BattleGroundType; // 3=BG, 4=arena |
---|
504 | //instead of uint8 (in previous line) is bool used |
---|
505 | bool m_IsArena; |
---|
506 | uint8 m_Winner; // 0=alliance, 1=horde, 2=none |
---|
507 | int32 m_StartDelayTime; |
---|
508 | bool m_IsRated; // is this battle rated? |
---|
509 | bool m_PrematureCountDown; |
---|
510 | uint32 m_PrematureCountDownTimer; |
---|
511 | char const *m_Name; |
---|
512 | |
---|
513 | /* Player lists */ |
---|
514 | std::vector<uint64> m_ResurrectQueue; // Player GUID |
---|
515 | std::map<uint64, uint8> m_RemovedPlayers; // uint8 is remove type (0 - bgqueue, 1 - bg, 2 - resurrect queue) |
---|
516 | |
---|
517 | /* 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 */ |
---|
518 | /* Invited counters will be changed only when removing already invited player from queue, removing player from battleground and inviting player to BG */ |
---|
519 | /* Invited players counters*/ |
---|
520 | uint32 m_InvitedAlliance; |
---|
521 | uint32 m_InvitedHorde; |
---|
522 | |
---|
523 | /* Raid Group */ |
---|
524 | Group *m_BgRaids[2]; // 0 - alliance, 1 - horde |
---|
525 | |
---|
526 | /* Players count by team */ |
---|
527 | uint32 m_PlayersCount[2]; |
---|
528 | |
---|
529 | /* Arena team ids by team */ |
---|
530 | uint32 m_ArenaTeamIds[2]; |
---|
531 | |
---|
532 | int32 m_ArenaTeamRatingChanges[2]; |
---|
533 | |
---|
534 | /* Limits */ |
---|
535 | uint32 m_LevelMin; |
---|
536 | uint32 m_LevelMax; |
---|
537 | uint32 m_MaxPlayersPerTeam; |
---|
538 | uint32 m_MaxPlayers; |
---|
539 | uint32 m_MinPlayersPerTeam; |
---|
540 | uint32 m_MinPlayers; |
---|
541 | |
---|
542 | /* Location */ |
---|
543 | uint32 m_MapId; |
---|
544 | float m_TeamStartLocX[2]; |
---|
545 | float m_TeamStartLocY[2]; |
---|
546 | float m_TeamStartLocZ[2]; |
---|
547 | float m_TeamStartLocO[2]; |
---|
548 | }; |
---|
549 | #endif |
---|