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