TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
BattlegroundAB.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
3  * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
4  *
5  * This program is free software; you can redistribute it and/or modify it
6  * under the terms of the GNU General Public License as published by the
7  * Free Software Foundation; either version 2 of the License, or (at your
8  * option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful, but WITHOUT
11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
13  * more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef __BATTLEGROUNDAB_H
20 #define __BATTLEGROUNDAB_H
21 
22 #include "Battleground.h"
23 #include "BattlegroundScore.h"
24 #include "Object.h"
25 
27 {
34 /*
35  BG_AB_OP_STABLE_ICON = 1842, //Stable map icon (NONE)
36  BG_AB_OP_STABLE_STATE_ALIENCE = 1767, //Stable map state (ALIENCE)
37  BG_AB_OP_STABLE_STATE_HORDE = 1768, //Stable map state (HORDE)
38  BG_AB_OP_STABLE_STATE_CON_ALI = 1769, //Stable map state (CON ALIENCE)
39  BG_AB_OP_STABLE_STATE_CON_HOR = 1770, //Stable map state (CON HORDE)
40  BG_AB_OP_FARM_ICON = 1845, //Farm map icon (NONE)
41  BG_AB_OP_FARM_STATE_ALIENCE = 1772, //Farm state (ALIENCE)
42  BG_AB_OP_FARM_STATE_HORDE = 1773, //Farm state (HORDE)
43  BG_AB_OP_FARM_STATE_CON_ALI = 1774, //Farm state (CON ALIENCE)
44  BG_AB_OP_FARM_STATE_CON_HOR = 1775, //Farm state (CON HORDE)
45 
46  BG_AB_OP_BLACKSMITH_ICON = 1846, //Blacksmith map icon (NONE)
47  BG_AB_OP_BLACKSMITH_STATE_ALIENCE = 1782, //Blacksmith map state (ALIENCE)
48  BG_AB_OP_BLACKSMITH_STATE_HORDE = 1783, //Blacksmith map state (HORDE)
49  BG_AB_OP_BLACKSMITH_STATE_CON_ALI = 1784, //Blacksmith map state (CON ALIENCE)
50  BG_AB_OP_BLACKSMITH_STATE_CON_HOR = 1785, //Blacksmith map state (CON HORDE)
51  BG_AB_OP_LUMBERMILL_ICON = 1844, //Lumber Mill map icon (NONE)
52  BG_AB_OP_LUMBERMILL_STATE_ALIENCE = 1792, //Lumber Mill map state (ALIENCE)
53  BG_AB_OP_LUMBERMILL_STATE_HORDE = 1793, //Lumber Mill map state (HORDE)
54  BG_AB_OP_LUMBERMILL_STATE_CON_ALI = 1794, //Lumber Mill map state (CON ALIENCE)
55  BG_AB_OP_LUMBERMILL_STATE_CON_HOR = 1795, //Lumber Mill map state (CON HORDE)
56  BG_AB_OP_GOLDMINE_ICON = 1843, //Gold Mine map icon (NONE)
57  BG_AB_OP_GOLDMINE_STATE_ALIENCE = 1787, //Gold Mine map state (ALIENCE)
58  BG_AB_OP_GOLDMINE_STATE_HORDE = 1788, //Gold Mine map state (HORDE)
59  BG_AB_OP_GOLDMINE_STATE_CON_ALI = 1789, //Gold Mine map state (CON ALIENCE
60  BG_AB_OP_GOLDMINE_STATE_CON_HOR = 1790, //Gold Mine map state (CON HORDE)
61 */
62 };
63 
64 const uint32 BG_AB_OP_NODESTATES[5] = {1767, 1782, 1772, 1792, 1787};
65 
66 const uint32 BG_AB_OP_NODEICONS[5] = {1842, 1846, 1845, 1844, 1843};
67 
68 /* Note: code uses that these IDs follow each other */
70 {
71  BG_AB_OBJECTID_NODE_BANNER_0 = 180087, // Stables banner
72  BG_AB_OBJECTID_NODE_BANNER_1 = 180088, // Blacksmith banner
73  BG_AB_OBJECTID_NODE_BANNER_2 = 180089, // Farm banner
74  BG_AB_OBJECTID_NODE_BANNER_3 = 180090, // Lumber mill banner
75  BG_AB_OBJECTID_NODE_BANNER_4 = 180091 // Gold mine banner
76 };
77 
79 {
80  // for all 5 node points 8*5=40 objects
89  //gates
92  //buffs
109 };
110 
111 /* Object id templates from DB */
113 {
118 
122 
125 };
126 
128 {
130 };
131 
133 {
136 };
137 
138 /* do NOT change the order, else wrong behaviour */
140 {
146 
147  BG_AB_DYNAMIC_NODES_COUNT = 5, // dynamic nodes that can be captured
148 
151 
152  BG_AB_ALL_NODES_COUNT = 7 // all nodes (dynamic and static)
153 };
154 
156 {
164 };
165 
167 {
174 };
175 
177 {
180 };
181 
182 #define BG_AB_NotABBGWeekendHonorTicks 260
183 #define BG_AB_ABBGWeekendHonorTicks 160
184 #define BG_AB_NotABBGWeekendReputationTicks 160
185 #define BG_AB_ABBGWeekendReputationTicks 120
186 
187 #define AB_EVENT_START_BATTLE 9158 // Achievement: Let's Get This Done
188 
190 {
191  {1166.785f, 1200.132f, -56.70859f, 0.9075713f}, // stables
192  {977.0156f, 1046.616f, -44.80923f, -2.600541f}, // blacksmith
193  {806.1821f, 874.2723f, -55.99371f, -2.303835f}, // farm
194  {856.1419f, 1148.902f, 11.18469f, -2.303835f}, // lumber mill
195  {1146.923f, 848.1782f, -110.917f, -0.7330382f} // gold mine
196 };
197 
198 // x, y, z, o, rot0, rot1, rot2, rot3
199 const float BG_AB_DoorPositions[2][8] =
200 {
201  {1284.597f, 1281.167f, -15.97792f, 0.7068594f, 0.012957f, -0.060288f, 0.344959f, 0.93659f},
202  {708.0903f, 708.4479f, -17.8342f, -2.391099f, 0.050291f, 0.015127f, 0.929217f, -0.365784f}
203 };
204 
205 // Tick intervals and given points: case 0, 1, 2, 3, 4, 5 captured nodes
206 const uint32 BG_AB_TickIntervals[6] = {0, 12000, 9000, 6000, 3000, 1000};
207 const uint32 BG_AB_TickPoints[6] = {0, 10, 10, 10, 10, 30};
208 
209 // WorldSafeLocs ids for 5 nodes, and for ally, and horde starting location
210 const uint32 BG_AB_GraveyardIds[BG_AB_ALL_NODES_COUNT] = {895, 894, 893, 897, 896, 898, 899};
211 
212 // x, y, z, o
214 {
215  {1185.71f, 1185.24f, -56.36f, 2.56f}, // stables
216  {990.75f, 1008.18f, -42.60f, 2.43f}, // blacksmith
217  {817.66f, 843.34f, -56.54f, 3.01f}, // farm
218  {807.46f, 1189.16f, 11.92f, 5.44f}, // lumber mill
219  {1146.62f, 816.94f, -98.49f, 6.14f} // gold mine
220 };
221 
223 {
224  {1200.03f, 1171.09f, -56.47f, 5.15f}, // stables
225  {1017.43f, 960.61f, -42.95f, 4.88f}, // blacksmith
226  {833.00f, 793.00f, -57.25f, 5.27f}, // farm
227  {775.17f, 1206.40f, 15.79f, 1.90f}, // lumber mill
228  {1207.48f, 787.00f, -83.36f, 5.51f}, // gold mine
229  {1354.05f, 1275.48f, -11.30f, 4.77f}, // alliance starting base
230  {714.61f, 646.15f, -10.87f, 4.34f} // horde starting base
231 };
232 
234 {
238 };
239 
241 {
242  friend class BattlegroundAB;
243 
244  protected:
245  BattlegroundABScore(ObjectGuid playerGuid, uint32 team) : BattlegroundScore(playerGuid, team), BasesAssaulted(0), BasesDefended(0) { }
246 
247  void UpdateScore(uint32 type, uint32 value) override
248  {
249  switch (type)
250  {
253  break;
255  BasesDefended += value;
256  break;
257  default:
258  BattlegroundScore::UpdateScore(type, value);
259  break;
260  }
261  }
262 
263  void BuildObjectivesBlock(std::vector<int32>& stats) override
264  {
265  stats.push_back(BasesAssaulted);
266  stats.push_back(BasesDefended);
267  }
268 
269  uint32 GetAttr1() const final override { return BasesAssaulted; }
270  uint32 GetAttr2() const final override { return BasesDefended; }
271 
274 };
275 
277 {
278  public:
279  BattlegroundAB();
280  ~BattlegroundAB();
281 
282  void AddPlayer(Player* player) override;
283  void StartingEventCloseDoors() override;
284  void StartingEventOpenDoors() override;
285  void RemovePlayer(Player* player, ObjectGuid guid, uint32 team) override;
286  void HandleAreaTrigger(Player* source, uint32 trigger, bool entered) override;
287  bool SetupBattleground() override;
288  void Reset() override;
289  void EndBattleground(uint32 winner) override;
290  WorldSafeLocsEntry const* GetClosestGraveYard(Player* player) override;
291 
292  /* Scorekeeping */
293  bool UpdatePlayerScore(Player* player, uint32 type, uint32 value, bool doAddHonor = true) override;
294 
296 
297  /* Nodes occupying */
298  void EventPlayerClickedOnFlag(Player* source, GameObject* target_obj) override;
299 
300  /* achievement req. */
301  bool IsAllNodesControlledByTeam(uint32 team) const override;
302  bool CheckAchievementCriteriaMeet(uint32 /*criteriaId*/, Player const* /*player*/, Unit const* /*target*/ = nullptr, uint32 /*miscvalue1*/ = 0) override;
303 
304  uint32 GetPrematureWinner() override;
305  private:
306  void PostUpdateImpl(uint32 diff) override;
307  /* Gameobject spawning/despawning */
308  void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay);
309  void _DelBanner(uint8 node, uint8 type, uint8 teamIndex);
310  void _SendNodeUpdate(uint8 node);
311 
312  /* Creature spawning/despawning */
314  void _NodeOccupied(uint8 node, Team team);
315  void _NodeDeOccupied(uint8 node);
316 
317  int32 _GetNodeNameId(uint8 node);
318 
319  /* Nodes info:
320  0: neutral
321  1: ally contested
322  2: horde contested
323  3: ally occupied
324  4: horde occupied */
335  // need for achievements
337 };
338 #endif
~BattlegroundAB()
Definition: BattlegroundAB.cpp:62
BG_AB_Sounds
Definition: BattlegroundAB.h:166
Definition: BattlegroundAB.h:93
Definition: BattlegroundAB.h:28
Definition: BattlegroundAB.h:143
bool SetupBattleground() override
Definition: BattlegroundAB.cpp:570
void StartingEventCloseDoors() override
Definition: BattlegroundAB.cpp:185
Definition: BattlegroundAB.h:30
Definition: BattlegroundAB.h:84
BattlegroundAB()
Definition: BattlegroundAB.cpp:28
uint8 type
Definition: BattlegroundAB.h:236
BG_AB_Objectives
Definition: BattlegroundAB.h:176
Definition: BattlegroundAB.h:276
Definition: BattlegroundAB.h:135
Definition: BattlegroundAB.h:32
void _NodeDeOccupied(uint8 node)
Definition: BattlegroundAB.cpp:407
BG_AB_NodeObjectId
Definition: BattlegroundAB.h:69
const uint32 BG_AB_TickIntervals[6]
Definition: BattlegroundAB.h:206
uint32 BasesAssaulted
Definition: BattlegroundAB.h:272
uint32 GetAttr2() const finaloverride
Definition: BattlegroundAB.h:270
Definition: BattlegroundAB.h:121
uint32 GetPrematureWinner() override
Definition: BattlegroundAB.cpp:551
Definition: BattlegroundAB.h:144
Definition: BattlegroundAB.h:114
BG_AB_NodeStatus
Definition: BattlegroundAB.h:155
void _DelBanner(uint8 node, uint8 type, uint8 teamIndex)
Definition: BattlegroundAB.cpp:290
Definition: BattlegroundAB.h:171
Definition: BattlegroundAB.h:100
virtual void UpdateScore(uint32 type, uint32 value)
Definition: BattlegroundScore.h:65
bool m_IsInformedNearVictory
Definition: BattlegroundAB.h:332
Definition: BattlegroundAB.h:99
Definition: BattlegroundAB.h:240
Definition: BattlegroundAB.h:115
Definition: DBCStructure.h:1434
Definition: BattlegroundAB.h:74
const uint32 BG_AB_OP_NODESTATES[5]
Definition: BattlegroundAB.h:64
uint32 m_HonorTics
Definition: BattlegroundAB.h:333
void AddPlayer(Player *player) override
Definition: BattlegroundAB.cpp:222
Definition: BattlegroundAB.h:72
Definition: BattlegroundAB.h:169
BG_AB_ObjectType
Definition: BattlegroundAB.h:78
Definition: BattlegroundAB.h:116
uint32 BasesDefended
Definition: BattlegroundAB.h:273
Definition: BattlegroundAB.h:147
const uint32 BG_AB_OP_NODEICONS[5]
Definition: BattlegroundAB.h:66
Definition: BattlegroundAB.h:102
const uint32 BG_AB_GraveyardIds[BG_AB_ALL_NODES_COUNT]
Definition: BattlegroundAB.h:210
#define BG_TEAMS_COUNT
Definition: SharedDefines.h:4555
void EndBattleground(uint32 winner) override
Definition: BattlegroundAB.cpp:640
Definition: BattlegroundAB.h:104
Definition: BattlegroundAB.h:81
void EventPlayerClickedOnFlag(Player *source, GameObject *target_obj) override
Definition: BattlegroundAB.cpp:424
uint32 m_lastTick[BG_TEAMS_COUNT]
Definition: BattlegroundAB.h:329
Definition: BattlegroundAB.h:107
Definition: BattlegroundAB.h:82
Definition: BattlegroundScore.h:54
uint32 timer
Definition: BattlegroundAB.h:235
bool m_TeamScores500Disadvantage[BG_TEAMS_COUNT]
Definition: BattlegroundAB.h:336
Definition: BattlegroundAB.h:95
Team
Definition: SharedDefines.h:997
BattlegroundABScore(ObjectGuid playerGuid, uint32 team)
Definition: BattlegroundAB.h:245
void UpdateScore(uint32 type, uint32 value) override
Definition: BattlegroundAB.h:247
int32 _GetNodeNameId(uint8 node)
Definition: BattlegroundAB.cpp:302
BG_AB_ObjectTypes
Definition: BattlegroundAB.h:112
Definition: BattlegroundAB.h:141
uint8 teamIndex
Definition: BattlegroundAB.h:237
Definition: BattlegroundAB.h:163
Definition: BattlegroundAB.h:149
BG_AB_BannerTimer m_BannerTimers[BG_AB_DYNAMIC_NODES_COUNT]
Definition: BattlegroundAB.h:327
Definition: BattlegroundAB.h:124
Definition: BattlegroundAB.h:152
Definition: BattlegroundAB.h:87
const uint32 BG_AB_TickPoints[6]
Definition: BattlegroundAB.h:207
Definition: BattlegroundAB.h:233
Definition: BattlegroundScore.h:39
Definition: BattlegroundAB.h:96
int32_t int32
Definition: Define.h:146
bool IsAllNodesControlledByTeam(uint32 team) const override
Definition: BattlegroundAB.cpp:712
bool CheckAchievementCriteriaMeet(uint32, Player const *, Unit const *=nullptr, uint32=0) override
Definition: BattlegroundAB.cpp:723
BG_AB_WorldStates
Definition: BattlegroundAB.h:26
void RemovePlayer(Player *player, ObjectGuid guid, uint32 team) override
Definition: BattlegroundAB.cpp:228
Definition: BattlegroundAB.h:98
Definition: BattlegroundAB.h:119
uint32_t uint32
Definition: Define.h:150
Definition: BattlegroundAB.h:134
void _NodeOccupied(uint8 node, Team team)
Definition: BattlegroundAB.cpp:375
Definition: WorldStatePackets.h:27
uint32 m_ReputationScoreTics[BG_TEAMS_COUNT]
Definition: BattlegroundAB.h:331
Definition: GameObject.h:880
Definition: BattlegroundAB.h:120
uint32 m_NodeTimers[BG_AB_DYNAMIC_NODES_COUNT]
Definition: BattlegroundAB.h:328
uint8 m_prevNodes[BG_AB_DYNAMIC_NODES_COUNT]
Definition: BattlegroundAB.h:326
uint32 GetAttr1() const finaloverride
Definition: BattlegroundAB.h:269
Definition: BattlegroundAB.h:173
WorldSafeLocsEntry const * GetClosestGraveYard(Player *player) override
Definition: BattlegroundAB.cpp:654
Definition: BattlegroundAB.h:31
uint32 m_ReputationTics
Definition: BattlegroundAB.h:334
Definition: BattlegroundAB.h:178
BG_AB_Timers
Definition: BattlegroundAB.h:127
void BuildObjectivesBlock(std::vector< int32 > &stats) override
Definition: BattlegroundAB.h:263
uint8 m_Nodes[BG_AB_DYNAMIC_NODES_COUNT]
Definition: BattlegroundAB.h:325
Definition: BattlegroundAB.h:162
void PostUpdateImpl(uint32 diff) override
Post-update hook.
Definition: BattlegroundAB.cpp:64
const float BG_AB_DoorPositions[2][8]
Definition: BattlegroundAB.h:199
Definition: BattlegroundAB.h:97
Definition: BattlegroundAB.h:90
Definition: BattlegroundAB.h:83
Definition: BattlegroundAB.h:105
Definition: BattlegroundAB.h:33
Definition: BattlegroundAB.h:85
BG_AB_BattlegroundNodes
Definition: BattlegroundAB.h:139
bool UpdatePlayerScore(Player *player, uint32 type, uint32 value, bool doAddHonor=true) override
Definition: BattlegroundAB.cpp:693
Definition: BattlegroundAB.h:86
Definition: BattlegroundAB.h:73
Definition: BattlegroundAB.h:150
Definition: BattlegroundAB.h:160
Position const BG_AB_SpiritGuidePos[BG_AB_ALL_NODES_COUNT]
Definition: BattlegroundAB.h:222
void _CreateBanner(uint8 node, uint8 type, uint8 teamIndex, bool delay)
Definition: BattlegroundAB.cpp:268
uint8_t uint8
Definition: Define.h:152
Definition: Position.h:27
const float BG_AB_BuffPositions[BG_AB_DYNAMIC_NODES_COUNT][4]
Definition: BattlegroundAB.h:213
void Reset() override
Definition: BattlegroundAB.cpp:607
Definition: BattlegroundAB.h:91
Definition: Battleground.h:235
void FillInitialWorldStates(WorldPackets::WorldState::InitWorldStates &packet) override
Definition: BattlegroundAB.cpp:317
Definition: BattlegroundAB.h:161
Definition: BattlegroundAB.h:158
const FieldDescriptor value
Definition: descriptor.h:1522
Definition: BattlegroundAB.h:75
Position const BG_AB_NodePositions[BG_AB_DYNAMIC_NODES_COUNT]
Definition: BattlegroundAB.h:189
void _SendNodeUpdate(uint8 node)
Definition: BattlegroundAB.cpp:351
Definition: ObjectGuid.h:189
Definition: BattlegroundAB.h:71
#define const
Definition: zconf.h:217
Definition: BattlegroundAB.h:157
uint32 m_HonorScoreTics[BG_TEAMS_COUNT]
Definition: BattlegroundAB.h:330
Definition: BattlegroundAB.h:172
Definition: BattlegroundAB.h:108
Definition: BattlegroundAB.h:101
Definition: BattlegroundAB.h:145
Definition: BattlegroundAB.h:117
Definition: BattlegroundAB.h:168
Definition: BattlegroundAB.h:179
Definition: BattlegroundAB.h:29
Definition: Unit.h:1305
BG_AB_Score
Definition: BattlegroundAB.h:132
Definition: BattlegroundAB.h:94
Definition: BattlegroundAB.h:88
Definition: BattlegroundAB.h:129
Definition: BattlegroundScore.h:40
Definition: BattlegroundAB.h:142
Definition: BattlegroundAB.h:123
void StartingEventOpenDoors() override
Definition: BattlegroundAB.cpp:204
Definition: BattlegroundAB.h:170
void HandleAreaTrigger(Player *source, uint32 trigger, bool entered) override
Definition: BattlegroundAB.cpp:232
Definition: BattlegroundAB.h:103
Definition: BattlegroundAB.h:159
Definition: BattlegroundAB.h:106