[9581] Fixed apply damage reduction to melee/ranged damage.
[getmangos.git] / src / game / BattleGroundAB.h
blobd41526c68ad300bb819be51bd887b77ea20e1360
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
18 #ifndef __BATTLEGROUNDAB_H
19 #define __BATTLEGROUNDAB_H
21 class BattleGround;
23 enum BG_AB_WorldStates
25 BG_AB_OP_OCCUPIED_BASES_HORDE = 1778,
26 BG_AB_OP_OCCUPIED_BASES_ALLY = 1779,
27 BG_AB_OP_RESOURCES_ALLY = 1776,
28 BG_AB_OP_RESOURCES_HORDE = 1777,
29 BG_AB_OP_RESOURCES_MAX = 1780,
30 BG_AB_OP_RESOURCES_WARNING = 1955
32 BG_AB_OP_STABLE_ICON = 1842, //Stable map icon (NONE)
33 BG_AB_OP_STABLE_STATE_ALIENCE = 1767, //Stable map state (ALIENCE)
34 BG_AB_OP_STABLE_STATE_HORDE = 1768, //Stable map state (HORDE)
35 BG_AB_OP_STABLE_STATE_CON_ALI = 1769, //Stable map state (CON ALIENCE)
36 BG_AB_OP_STABLE_STATE_CON_HOR = 1770, //Stable map state (CON HORDE)
37 BG_AB_OP_FARM_ICON = 1845, //Farm map icon (NONE)
38 BG_AB_OP_FARM_STATE_ALIENCE = 1772, //Farm state (ALIENCE)
39 BG_AB_OP_FARM_STATE_HORDE = 1773, //Farm state (HORDE)
40 BG_AB_OP_FARM_STATE_CON_ALI = 1774, //Farm state (CON ALIENCE)
41 BG_AB_OP_FARM_STATE_CON_HOR = 1775, //Farm state (CON HORDE)
43 BG_AB_OP_BLACKSMITH_ICON = 1846, //Blacksmith map icon (NONE)
44 BG_AB_OP_BLACKSMITH_STATE_ALIENCE = 1782, //Blacksmith map state (ALIENCE)
45 BG_AB_OP_BLACKSMITH_STATE_HORDE = 1783, //Blacksmith map state (HORDE)
46 BG_AB_OP_BLACKSMITH_STATE_CON_ALI = 1784, //Blacksmith map state (CON ALIENCE)
47 BG_AB_OP_BLACKSMITH_STATE_CON_HOR = 1785, //Blacksmith map state (CON HORDE)
48 BG_AB_OP_LUMBERMILL_ICON = 1844, //Lumber Mill map icon (NONE)
49 BG_AB_OP_LUMBERMILL_STATE_ALIENCE = 1792, //Lumber Mill map state (ALIENCE)
50 BG_AB_OP_LUMBERMILL_STATE_HORDE = 1793, //Lumber Mill map state (HORDE)
51 BG_AB_OP_LUMBERMILL_STATE_CON_ALI = 1794, //Lumber Mill map state (CON ALIENCE)
52 BG_AB_OP_LUMBERMILL_STATE_CON_HOR = 1795, //Lumber Mill map state (CON HORDE)
53 BG_AB_OP_GOLDMINE_ICON = 1843, //Gold Mine map icon (NONE)
54 BG_AB_OP_GOLDMINE_STATE_ALIENCE = 1787, //Gold Mine map state (ALIENCE)
55 BG_AB_OP_GOLDMINE_STATE_HORDE = 1788, //Gold Mine map state (HORDE)
56 BG_AB_OP_GOLDMINE_STATE_CON_ALI = 1789, //Gold Mine map state (CON ALIENCE
57 BG_AB_OP_GOLDMINE_STATE_CON_HOR = 1790, //Gold Mine map state (CON HORDE)
61 const uint32 BG_AB_OP_NODESTATES[5] = {1767, 1782, 1772, 1792, 1787};
63 const uint32 BG_AB_OP_NODEICONS[5] = {1842, 1846, 1845, 1844, 1843};
65 enum BG_AB_ObjectType
67 // TODO drop them (pool-system should be used for this)
68 //buffs
69 BG_AB_OBJECT_SPEEDBUFF_STABLES = 1,
70 BG_AB_OBJECT_REGENBUFF_STABLES = 2,
71 BG_AB_OBJECT_BERSERKBUFF_STABLES = 3,
72 BG_AB_OBJECT_SPEEDBUFF_BLACKSMITH = 4,
73 BG_AB_OBJECT_REGENBUFF_BLACKSMITH = 5,
74 BG_AB_OBJECT_BERSERKBUFF_BLACKSMITH = 6,
75 BG_AB_OBJECT_SPEEDBUFF_FARM = 7,
76 BG_AB_OBJECT_REGENBUFF_FARM = 8,
77 BG_AB_OBJECT_BERSERKBUFF_FARM = 9,
78 BG_AB_OBJECT_SPEEDBUFF_LUMBER_MILL = 10,
79 BG_AB_OBJECT_REGENBUFF_LUMBER_MILL = 11,
80 BG_AB_OBJECT_BERSERKBUFF_LUMBER_MILL = 12,
81 BG_AB_OBJECT_SPEEDBUFF_GOLD_MINE = 13,
82 BG_AB_OBJECT_REGENBUFF_GOLD_MINE = 14,
83 BG_AB_OBJECT_BERSERKBUFF_GOLD_MINE = 15,
84 BG_AB_OBJECT_MAX = 16,
88 /* node events */
89 // node-events are just event1=BG_AB_Nodes, event2=BG_AB_NodeStatus
90 // so we don't need to define the constants here :)
92 enum BG_AB_Timers
94 BG_AB_FLAG_CAPTURING_TIME = 60000,
97 enum BG_AB_Score
99 BG_AB_WARNING_NEAR_VICTORY_SCORE = 1400,
100 BG_AB_MAX_TEAM_SCORE = 1600
103 /* do NOT change the order, else wrong behaviour */
104 enum BG_AB_Nodes
106 BG_AB_NODE_STABLES = 0,
107 BG_AB_NODE_BLACKSMITH = 1,
108 BG_AB_NODE_FARM = 2,
109 BG_AB_NODE_LUMBER_MILL = 3,
110 BG_AB_NODE_GOLD_MINE = 4,
111 BG_AB_NODES_ERROR = 255
114 #define BG_AB_NODES_MAX 5
116 enum BG_AB_NodeStatus
118 BG_AB_NODE_TYPE_NEUTRAL = 0,
119 BG_AB_NODE_TYPE_CONTESTED = 1,
120 BG_AB_NODE_STATUS_ALLY_CONTESTED = 1,
121 BG_AB_NODE_STATUS_HORDE_CONTESTED = 2,
122 BG_AB_NODE_TYPE_OCCUPIED = 3,
123 BG_AB_NODE_STATUS_ALLY_OCCUPIED = 3,
124 BG_AB_NODE_STATUS_HORDE_OCCUPIED = 4
127 enum BG_AB_Sounds
129 BG_AB_SOUND_NODE_CLAIMED = 8192,
130 BG_AB_SOUND_NODE_CAPTURED_ALLIANCE = 8173,
131 BG_AB_SOUND_NODE_CAPTURED_HORDE = 8213,
132 BG_AB_SOUND_NODE_ASSAULTED_ALLIANCE = 8212,
133 BG_AB_SOUND_NODE_ASSAULTED_HORDE = 8174,
134 BG_AB_SOUND_NEAR_VICTORY = 8456
137 #define BG_AB_NotABBGWeekendHonorTicks 330
138 #define BG_AB_ABBGWeekendHonorTicks 200
139 #define BG_AB_NotABBGWeekendReputationTicks 200
140 #define BG_AB_ABBGWeekendReputationTicks 150
142 // Tick intervals and given points: case 0,1,2,3,4,5 captured nodes
143 const uint32 BG_AB_TickIntervals[6] = {0, 12000, 9000, 6000, 3000, 1000};
144 const uint32 BG_AB_TickPoints[6] = {0, 10, 10, 10, 10, 30};
146 // WorldSafeLocs ids for 5 nodes, and for ally, and horde starting location
147 const uint32 BG_AB_GraveyardIds[7] = {895, 894, 893, 897, 896, 898, 899};
149 // x, y, z, o
150 const float BG_AB_BuffPositions[BG_AB_NODES_MAX][4] = {
151 {1185.71f, 1185.24f, -56.36f, 2.56f}, // stables
152 {990.75f, 1008.18f, -42.60f, 2.43f}, // blacksmith
153 {817.66f, 843.34f, -56.54f, 3.01f}, // farm
154 {807.46f, 1189.16f, 11.92f, 5.44f}, // lumber mill
155 {1146.62f, 816.94f, -98.49f, 6.14f} // gold mine
158 struct BG_AB_BannerTimer
160 uint32 timer;
161 uint8 type;
162 uint8 teamIndex;
165 class BattleGroundABScore : public BattleGroundScore
167 public:
168 BattleGroundABScore(): BasesAssaulted(0), BasesDefended(0) {};
169 virtual ~BattleGroundABScore() {};
170 uint32 BasesAssaulted;
171 uint32 BasesDefended;
174 class BattleGroundAB : public BattleGround
176 friend class BattleGroundMgr;
178 public:
179 BattleGroundAB();
180 ~BattleGroundAB();
182 void Update(uint32 diff);
183 void AddPlayer(Player *plr);
184 virtual void StartingEventCloseDoors();
185 virtual void StartingEventOpenDoors();
186 void RemovePlayer(Player *plr,uint64 guid);
187 void HandleAreaTrigger(Player *Source, uint32 Trigger);
188 virtual bool SetupBattleGround();
189 virtual void Reset();
190 void EndBattleGround(uint32 winner);
191 virtual WorldSafeLocsEntry const* GetClosestGraveYard(Player* player);
193 /* Scorekeeping */
194 virtual void UpdatePlayerScore(Player *Source, uint32 type, uint32 value);
196 virtual void FillInitialWorldStates(WorldPacket& data);
198 /* Nodes occupying */
199 virtual void EventPlayerClickedOnFlag(Player *source, GameObject* target_obj);
201 /* achievement req. */
202 bool IsAllNodesConrolledByTeam(uint32 team) const; // overwrited
203 bool IsTeamScores500Disadvantage(uint32 team) const { return m_TeamScores500Disadvantage[GetTeamIndexByTeamId(team)]; }
204 private:
205 /* Gameobject spawning/despawning */
206 void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay);
207 void _DelBanner(uint8 node, uint8 type, uint8 teamIndex);
208 void _SendNodeUpdate(uint8 node);
210 /* Creature spawning/despawning */
211 // TODO: working, scripted peons spawning
212 void _NodeOccupied(uint8 node,Team team);
214 int32 _GetNodeNameId(uint8 node);
216 /* Nodes info:
217 0: neutral
218 1: ally contested
219 2: horde contested
220 3: ally occupied
221 4: horde occupied */
222 uint8 m_Nodes[BG_AB_NODES_MAX];
223 uint8 m_prevNodes[BG_AB_NODES_MAX]; // used for performant wordlstate-updating
224 BG_AB_BannerTimer m_BannerTimers[BG_AB_NODES_MAX];
225 uint32 m_NodeTimers[BG_AB_NODES_MAX];
226 uint32 m_lastTick[BG_TEAMS_COUNT];
227 uint32 m_HonorScoreTics[BG_TEAMS_COUNT];
228 uint32 m_ReputationScoreTics[BG_TEAMS_COUNT];
229 bool m_IsInformedNearVictory;
230 uint32 m_HonorTics;
231 uint32 m_ReputationTics;
232 // need for achievements
233 bool m_TeamScores500Disadvantage[BG_TEAMS_COUNT];
235 #endif