diff options
Diffstat (limited to 'src/game/BattleGround.h')
-rw-r--r-- | src/game/BattleGround.h | 195 |
1 files changed, 114 insertions, 81 deletions
diff --git a/src/game/BattleGround.h b/src/game/BattleGround.h index 411bbaf6211..ea691dc9750 100644 --- a/src/game/BattleGround.h +++ b/src/game/BattleGround.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,13 +22,16 @@ #define __BATTLEGROUND_H #include "Common.h" -#include "WorldPacket.h" -#include "WorldSession.h" -#include "Opcodes.h" -#include "ObjectMgr.h" -#include "BattleGroundMgr.h" #include "SharedDefines.h" +class Creature; +class GameObject; +class Group; +class Player; +class WorldPacket; + +struct WorldSafeLocsEntry; + enum BattleGroundSounds { SOUND_HORDE_WINS = 8454, @@ -83,19 +86,25 @@ enum BattleGroundTimeIntervals { RESURRECTION_INTERVAL = 30000, // ms REMIND_INTERVAL = 30000, // ms + INVITATION_REMIND_TIME = 60000, // ms INVITE_ACCEPT_WAIT_TIME = 80000, // ms TIME_TO_AUTOREMOVE = 120000, // ms MAX_OFFLINE_TIME = 300000, // ms - START_DELAY0 = 120000, // ms - START_DELAY1 = 60000, // ms - START_DELAY2 = 30000, // ms - START_DELAY3 = 15000, // ms used only in arena RESPAWN_ONE_DAY = 86400, // secs RESPAWN_IMMEDIATELY = 0, // secs BUFF_RESPAWN_TIME = 180, // secs BG_HONOR_SCORE_TICKS = 330 // points }; +enum BattleGroundStartTimeIntervals +{ + BG_START_DELAY_2M = 120000, // ms (2 minutes) + BG_START_DELAY_1M = 60000, // ms (1 minute) + BG_START_DELAY_30S = 30000, // ms (30 seconds) + BG_START_DELAY_15S = 15000, // ms (15 seconds) Used only in arena + BG_START_DELAY_NONE = 0, // ms +}; + enum BattleGroundBuffObjects { BG_OBJECTID_SPEEDBUFF_ENTRY = 179871, @@ -107,11 +116,11 @@ const uint32 Buff_Entries[3] = { BG_OBJECTID_SPEEDBUFF_ENTRY, BG_OBJECTID_REGENB enum BattleGroundStatus { - STATUS_NONE = 0, - STATUS_WAIT_QUEUE = 1, - STATUS_WAIT_JOIN = 2, - STATUS_IN_PROGRESS = 3, - STATUS_WAIT_LEAVE = 4 // custom + STATUS_NONE = 0, // first status, should mean bg is not instance + STATUS_WAIT_QUEUE = 1, // means bg is empty and waiting for queue + STATUS_WAIT_JOIN = 2, // this means, that BG has already started and it is waiting for more players + STATUS_IN_PROGRESS = 3, // means bg is running + STATUS_WAIT_LEAVE = 4 // means some faction has won BG and it is ending }; struct BattleGroundPlayer @@ -129,31 +138,33 @@ struct BattleGroundObjectInfo uint32 spellid; }; -#define MAX_QUEUED_PLAYERS_MAP 7 - -enum BattleGroundTypeId +// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time +enum BattleGroundQueueTypeId { - BATTLEGROUND_AV = 1, - BATTLEGROUND_WS = 2, - BATTLEGROUND_AB = 3, - BATTLEGROUND_NA = 4, - BATTLEGROUND_BE = 5, - BATTLEGROUND_AA = 6, - BATTLEGROUND_EY = 7, - BATTLEGROUND_RL = 8 + BATTLEGROUND_QUEUE_NONE = 0, + BATTLEGROUND_QUEUE_AV = 1, + BATTLEGROUND_QUEUE_WS = 2, + BATTLEGROUND_QUEUE_AB = 3, + BATTLEGROUND_QUEUE_EY = 4, + BATTLEGROUND_QUEUE_SA = 5, + BATTLEGROUND_QUEUE_2v2 = 6, + BATTLEGROUND_QUEUE_3v3 = 7, + BATTLEGROUND_QUEUE_5v5 = 8 }; +#define MAX_BATTLEGROUND_QUEUE_TYPES 9 -// handle the queue types and bg types separately to enable joining queue for different sized arenas at the same time -enum BattleGroundQueueTypeId +enum BGQueueIdBasedOnLevel // queue_id for level ranges { - BATTLEGROUND_QUEUE_AV = 1, - BATTLEGROUND_QUEUE_WS = 2, - BATTLEGROUND_QUEUE_AB = 3, - BATTLEGROUND_QUEUE_EY = 4, - BATTLEGROUND_QUEUE_2v2 = 5, - BATTLEGROUND_QUEUE_3v3 = 6, - BATTLEGROUND_QUEUE_5v5 = 7, + QUEUE_ID_MAX_LEVEL_19 = 0, + QUEUE_ID_MAX_LEVEL_29 = 1, + QUEUE_ID_MAX_LEVEL_39 = 2, + QUEUE_ID_MAX_LEVEL_49 = 3, + QUEUE_ID_MAX_LEVEL_59 = 4, + QUEUE_ID_MAX_LEVEL_69 = 5, + QUEUE_ID_MAX_LEVEL_79 = 6, + QUEUE_ID_MAX_LEVEL_80 = 7 }; +#define MAX_BATTLEGROUND_QUEUES 8 enum ScoreType { @@ -206,6 +217,25 @@ enum BattleGroundTeamId BG_TEAM_ALLIANCE = 0, BG_TEAM_HORDE = 1 }; +#define BG_TEAMS_COUNT 2 + +enum BattleGroundStartingEvents +{ + BG_STARTING_EVENT_NONE = 0x00, + BG_STARTING_EVENT_1 = 0x01, + BG_STARTING_EVENT_2 = 0x02, + BG_STARTING_EVENT_3 = 0x04, + BG_STARTING_EVENT_4 = 0x08 +}; + +enum BattleGroundStartingEventsIds +{ + BG_STARTING_EVENT_FIRST = 0, + BG_STARTING_EVENT_SECOND = 1, + BG_STARTING_EVENT_THIRD = 2, + BG_STARTING_EVENT_FOURTH = 3 +}; +#define BG_STARTING_EVENT_COUNT 4 enum BattleGroundJoinError { @@ -224,10 +254,11 @@ enum BattleGroundJoinError class BattleGroundScore { public: - BattleGroundScore() : KillingBlows(0), HonorableKills(0), Deaths(0), DamageDone(0), HealingDone(0), BonusHonor(0) {}; - virtual ~BattleGroundScore() //virtual destructor is used when deleting score from scores map - { - }; + BattleGroundScore() : KillingBlows(0), Deaths(0), HonorableKills(0), + BonusHonor(0), DamageDone(0), HealingDone(0) + {} + virtual ~BattleGroundScore() {} //virtual destructor is used when deleting score from scores map + uint32 KillingBlows; uint32 Deaths; uint32 HonorableKills; @@ -259,23 +290,22 @@ class BattleGround BattleGround(); /*BattleGround(const BattleGround& bg);*/ virtual ~BattleGround(); - virtual void Update(time_t diff); // must be implemented in BG subclass of BG specific update code, but must in begginning call parent version + virtual void Update(uint32 diff); // must be implemented in BG subclass of BG specific update code, but must in begginning call parent version virtual bool SetupBattleGround() // must be implemented in BG subclass { return true; } - void Reset(); // resets all common properties for battlegrounds - virtual void ResetBGSubclass() // must be implemented in BG subclass - { - } + virtual void Reset(); // resets all common properties for battlegrounds, must be implemented and called in BG subclass + virtual void StartingEventCloseDoors() {} + virtual void StartingEventOpenDoors() {} /* Battleground */ // Get methods: char const* GetName() const { return m_Name; } - uint32 GetTypeID() const { return m_TypeID; } - uint32 GetQueueType() const { return m_Queue_type; } + BattleGroundTypeId GetTypeID() const { return m_TypeID; } + BGQueueIdBasedOnLevel GetQueueId() const { return m_QueueId; } uint32 GetInstanceID() const { return m_InstanceID; } - uint32 GetStatus() const { return m_Status; } + BattleGroundStatus GetStatus() const { return m_Status; } uint32 GetStartTime() const { return m_StartTime; } uint32 GetEndTime() const { return m_EndTime; } uint32 GetLastResurrectTime() const { return m_LastResurrectTime; } @@ -288,17 +318,23 @@ class BattleGround uint32 GetMaxPlayersPerTeam() const { return m_MaxPlayersPerTeam; } uint32 GetMinPlayersPerTeam() const { return m_MinPlayersPerTeam; } - int GetStartDelayTime() const { return m_StartDelayTime; } + int32 GetStartDelayTime() const { return m_StartDelayTime; } uint8 GetArenaType() const { return m_ArenaType; } uint8 GetWinner() const { return m_Winner; } uint32 GetBattlemasterEntry() const; // Set methods: void SetName(char const* Name) { m_Name = Name; } - void SetTypeID(uint32 TypeID) { m_TypeID = TypeID; } - void SetQueueType(uint32 ID) { m_Queue_type = ID; } + void SetTypeID(BattleGroundTypeId TypeID) { m_TypeID = TypeID; } + //here we can count minlevel and maxlevel for players + void SetQueueId(BGQueueIdBasedOnLevel ID) + { + m_QueueId = ID; + uint8 diff = (m_TypeID == BATTLEGROUND_AV) ? 1 : 0; + this->SetLevelRange((ID + 1) * 10 + diff, (ID + 2) * 10 - ((diff + 1) % 2)); + } void SetInstanceID(uint32 InstanceID) { m_InstanceID = InstanceID; } - void SetStatus(uint32 Status) { m_Status = Status; } + void SetStatus(BattleGroundStatus Status) { m_Status = Status; } void SetStartTime(uint32 Time) { m_StartTime = Time; } void SetEndTime(uint32 Time) { m_EndTime = Time; } void SetLastResurrectTime(uint32 Time) { m_LastResurrectTime = Time; } @@ -328,7 +364,6 @@ class BattleGround else return m_InvitedHorde; } - bool HasFreeSlotsForTeam(uint32 Team) const; bool HasFreeSlots() const; uint32 GetFreeSlotsForTeam(uint32 Team) const; @@ -387,18 +422,13 @@ class BattleGround void EndBattleGround(uint32 winner); void BlockMovement(Player *plr); - void SendMessageToAll(char const* text); - void SendMessageToAll(int32 entry); + void SendMessageToAll(char const* text, uint8 type); + void SendMessageToAll(int32 entry, uint8 type); + void PSendMessageToAll(int32 entry, uint8 type, ... ); /* Raid Group */ Group *GetBgRaid(uint32 TeamID) const { return TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; } - void SetBgRaid(uint32 TeamID, Group *bg_raid) - { - Group* &old_raid = TeamID == ALLIANCE ? m_BgRaids[BG_TEAM_ALLIANCE] : m_BgRaids[BG_TEAM_HORDE]; - if(old_raid) old_raid->SetBattlegroundGroup(NULL); - if(bg_raid) bg_raid->SetBattlegroundGroup(this); - old_raid = bg_raid; - } + void SetBgRaid(uint32 TeamID, Group *bg_raid); virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value); @@ -427,16 +457,17 @@ class BattleGround virtual void HandleKillUnit(Creature* /*unit*/, Player* /*killer*/); /* Battleground events */ - /* these functions will return true event is possible, but false if player is bugger */ virtual void EventPlayerDroppedFlag(Player* /*player*/) {} virtual void EventPlayerClickedOnFlag(Player* /*player*/, GameObject* /*target_obj*/) {} virtual void EventPlayerCapturedFlag(Player* /*player*/) {} /* Death related */ - virtual WorldSafeLocsEntry const* GetClosestGraveYard(float /*x*/, float /*y*/, float /*z*/, uint32 /*team*/) { return NULL; } + virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player); virtual void AddPlayer(Player *plr); // must be implemented in BG subclass + void AddOrSetPlayerToCorrectBgGroup(Player *plr, uint64 plr_guid, uint32 team); + virtual void RemovePlayerAtLeave(uint64 guid, bool Transport, bool SendPacket); // can be extended in in BG subclass @@ -461,10 +492,12 @@ class BattleGround void DoorClose(uint32 type); const char *GetTrinityString(int32 entry); - virtual bool HandlePlayerUnderMap(Player * plr) {return false;} + virtual bool HandlePlayerUnderMap(Player * /*plr*/) { return false; } // since arenas can be AvA or Hvh, we have to get the "temporary" team of a player uint32 GetPlayerTeam(uint64 guid); + bool IsPlayerInBattleGround(uint64 guid); + void PlayerRelogin(Player* plr); void SetDeleteThis() {m_SetDeleteThis = true;} @@ -484,28 +517,28 @@ class BattleGround std::map<uint64, std::vector<uint64> > m_ReviveQueue; /* - this is important variable used for invitation messages + these are important variables used for starting messages */ uint8 m_Events; + BattleGroundStartTimeIntervals m_StartDelayTimes[BG_STARTING_EVENT_COUNT]; + //this must be filled in constructors! + uint32 m_StartMessageIds[BG_STARTING_EVENT_COUNT]; bool m_BuffChange; BGHonorMode m_HonorMode; private: /* Battleground */ - uint32 m_TypeID; //Battleground type, defined in enum BattleGroundTypeId + BattleGroundTypeId m_TypeID; uint32 m_InstanceID; //BattleGround Instance's GUID! - uint32 m_Status; + BattleGroundStatus m_Status; uint32 m_StartTime; uint32 m_EndTime; uint32 m_LastResurrectTime; - uint32 m_Queue_type; + BGQueueIdBasedOnLevel m_QueueId; uint8 m_ArenaType; // 2=2v2, 3=3v3, 5=5v5 bool m_InBGFreeSlotQueue; // used to make sure that BG is only once inserted into the BattleGroundMgr.BGFreeSlotQueue[bgTypeId] deque bool m_SetDeleteThis; // used for safe deletion of the bg after end / all players leave - // this variable is not used .... it can be found in many other ways... but to store it in BG object instance is useless - //uint8 m_BattleGroundType; // 3=BG, 4=arena - //instead of uint8 (in previous line) is bool used bool m_IsArena; uint8 m_Winner; // 0=alliance, 1=horde, 2=none int32 m_StartDelayTime; @@ -525,15 +558,15 @@ class BattleGround uint32 m_InvitedHorde; /* Raid Group */ - Group *m_BgRaids[2]; // 0 - alliance, 1 - horde + Group *m_BgRaids[BG_TEAMS_COUNT]; // 0 - alliance, 1 - horde /* Players count by team */ - uint32 m_PlayersCount[2]; + uint32 m_PlayersCount[BG_TEAMS_COUNT]; /* Arena team ids by team */ - uint32 m_ArenaTeamIds[2]; + uint32 m_ArenaTeamIds[BG_TEAMS_COUNT]; - int32 m_ArenaTeamRatingChanges[2]; + int32 m_ArenaTeamRatingChanges[BG_TEAMS_COUNT]; /* Limits */ uint32 m_LevelMin; @@ -543,12 +576,12 @@ class BattleGround uint32 m_MinPlayersPerTeam; uint32 m_MinPlayers; - /* Location */ + /* Start location */ uint32 m_MapId; - float m_TeamStartLocX[2]; - float m_TeamStartLocY[2]; - float m_TeamStartLocZ[2]; - float m_TeamStartLocO[2]; + float m_TeamStartLocX[BG_TEAMS_COUNT]; + float m_TeamStartLocY[BG_TEAMS_COUNT]; + float m_TeamStartLocZ[BG_TEAMS_COUNT]; + float m_TeamStartLocO[BG_TEAMS_COUNT]; }; #endif |