aboutsummaryrefslogtreecommitdiff
path: root/src/server/scripts/Battlefield/BattlefieldTB.h
blob: 5abc463fed03db19db5d5500e1642c5e6f7e03a5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
/*
* This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
*
* 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 the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/

#ifndef BATTLEFIELD_TB_
#define BATTLEFIELD_TB_

#include "Battlefield.h"

class BattlefieldTB;
class TolBaradCapturePoint;

enum TolBaradInfo
{
    BATTLEFIELD_TB_MAPID = 732, // Tol Barad
    BATTLEFIELD_TB_ZONEID = 5095, // Tol Barad
};

enum TolBaradData
{
    BATTLEFIELD_TB_DATA_TOWERS_INTACT,
    BATTLEFIELD_TB_DATA_MAX,
};

enum TolBaradSpells
{
    // Quest completion
    SPELL_VICTORY_ALLIANCE = 94665,
    SPELL_VICTORY_HORDE = 94763,

    // Rewards
    SPELL_REWARD_VICTORY_ALLIANCE = 89789,
    SPELL_REWARD_VICTORY_HORDE = 89791,
    SPELL_REWARD_DEFEAT = 89793,

    SPELL_REWARD_TOWER_INTACT = 89794,
    SPELL_REWARD_TOWER_DAMAGED = 89795,
    SPELL_REWARD_TOWER_DESTROYED = 89796,

    // Player buffs
    SPELL_TB_SLOW_FALL = 88473,
    SPELL_TB_VETERAN = 84655,
    SPELL_TOWER_ATTACK_BONUS = 82629,
    SPELL_TB_SPIRITUAL_IMMUNITY = 95332,

    // Vehicle
    SPELL_THICK_LAYER_OF_RUST = 95330,
    SPELL_RIDE_TOL_BARAD_VEHICLE = 84754,
    SPELL_DEPLOY_SIEGE_MODE = 84974,
    SPELL_SIEGE_CANNON_AURA = 85167, // aura, periodically triggers spell 85122
//  SPELL_SIEGE_CANNON_EFFECT = 85122, // targets random
//  SPELL_SIEGE_CANNON_DAMAGE = 85125,
    SPELL_LEAVE_SIEGE_MODE = 85078,

    SPELL_TOWER_RANGE_FINDER_PERIODIC = 85671,
    SPELL_TOWER_RANGE_FINDER = 84979,

    // Teleportation spells
    SPELL_TB_THE_HOLE_TELEPORT = 89035,
    SPELL_TB_D_BLOCK_TELEPORT = 89037,
    SPELL_TB_CURSED_DEPTHS_TELEPORT = 89038,
};

enum TolBaradNpcs
{
    // Cursed Depths area
    NPC_TOLBARAD_CAPTIVE_SPIRIT                     = 47531,
    NPC_TOLBARAD_CELLBLOCK_OOZE                     = 47534,
    NPC_TOLBARAD_ARCHMAGE_GALUS                     = 47537,
    NPC_TOLBARAD_GHASTLY_CONVICT                    = 47590,

    // D-Block area
    NPC_TOLBARAD_SHIVARRA_DESTROYER                 = 47540,
    NPC_TOLBARAD_CELL_WATCHER                       = 47542,
    NPC_TOLBARAD_SVARNOS                            = 47544,
    NPC_TOLBARAD_JAILED_WRATHGUARD                  = 47548,
    NPC_TOLBARAD_IMPRISONED_IMP                     = 47549,

    // The Hole area
    NPC_TOLBARAD_WARDEN_SILVA                       = 48036,
    NPC_TOLBARAD_WARDEN_GUARD                       = 47561,
    NPC_TOLBARAD_IMPRISONED_WORKER                  = 47550,
    NPC_TOLBARAD_EXILED_MAGE                        = 47552,

    // Other
    NPC_CROCOLISK                                   = 47591,
    NPC_PROBLIM                                     = 47593,

    // Graveyard spirits
    NPC_TB_GY_SPIRIT_BARADIN_HOLD_A                 = 45066,
    NPC_TB_GY_SPIRIT_BARADIN_HOLD_H                 = 45067,
    NPC_TB_GY_SPIRIT_IRONCLAD_GARRISON_A            = 45068,
    NPC_TB_GY_SPIRIT_WARDENS_VIGIL_A                = 45069,
    NPC_TB_GY_SPIRIT_EAST_SPIRE_A                   = 45070,
    NPC_TB_GY_SPIRIT_SOUTH_SPIRE_A                  = 45071,
    NPC_TB_GY_SPIRIT_WEST_SPIRE_A                   = 45072,
    NPC_TB_GY_SPIRIT_SLAGWORKS_A                    = 45073,
    NPC_TB_GY_SPIRIT_IRONCLAD_GARRISON_H            = 45074,
    NPC_TB_GY_SPIRIT_WARDENS_VIGIL_H                = 45075,
    NPC_TB_GY_SPIRIT_SLAGWORKS_H                    = 45076,
    NPC_TB_GY_SPIRIT_WEST_SPIRE_H                   = 45077,
    NPC_TB_GY_SPIRIT_EAST_SPIRE_H                   = 45078,
    NPC_TB_GY_SPIRIT_SOUTH_SPIRE_H                  = 45079,

    // Stalker, dummies
    NPC_DEBUG_ANNOUNCER = 43679,
    NPC_TOWER_RANGE_FINDER = 45492,
    NPC_TOWER_CANNON_TARGET = 45561,
    NPC_SIEGE_ENGINE_TURRET = 45564,
};

enum TolBaradGOs
{
    // Towers
    GO_WEST_SPIRE = 204588,
    GO_EAST_SPIRE = 204589,
    GO_SOUTH_SPIRE = 204590,

    GO_CAPTURE_POINT_NORTH_A_DEFENDING          = 205068,
    GO_CAPTURE_POINT_NORTH_H_DEFENDING          = 205096,
    GO_CAPTURE_POINT_EAST_A_DEFENDING           = 205138,
    GO_CAPTURE_POINT_EAST_H_DEFENDING           = 205139,
    GO_CAPTURE_POINT_WEST_A_DEFENDING           = 205101,
    GO_CAPTURE_POINT_WEST_H_DEFENDING           = 205103,

    // Entrance gates and instance door
    GO_TOLBARAD_GATES = 206598,
    GO_TOLBARAD_DOOR = 206576,

    // Other
    GO_TB_MEETING_STONE = 206668,

    GO_TB_INSTANCE_VISUAL_1 = 207746,
    GO_TB_INSTANCE_VISUAL_2 = 207747,
    GO_TB_INSTANCE_VISUAL_3 = 210114,
    GO_TB_INSTANCE_VISUAL_4 = 210115,
};

enum TolBaradGOArtKit
{
    TB_GO_ARTKIT_FLAG_NONE = 0,
    TB_GO_ARTKIT_FLAG_HORDE = 1,
    TB_GO_ARTKIT_FLAG_ALLIANCE = 2,
};

enum TolBaradText
{
    // DEBUG Announcer
    TB_TEXT_EAST_SPIRE_DAMAGED              = 1,
    TB_TEXT_EAST_SPIRE_DESTROYED            = 2,
    TB_TEXT_WEST_SPIRE_DAMAGED              = 3,
    TB_TEXT_WEST_SPIRE_DESTROYED            = 4,
    TB_TEXT_SOUTH_SPIRE_DAMAGED             = 5,
    TB_TEXT_SOUTH_SPIRE_DESTROYED           = 6,
    TB_TEXT_GARRISON_ALLIANCE_GAINED        = 7,
    TB_TEXT_GARRISON_ALLIANCE_LOST          = 8,
    TB_TEXT_GARRISON_HORDE_GAINED           = 9,
    TB_TEXT_GARRISON_HORDE_LOST             = 10,
    TB_TEXT_VIGIL_ALLIANCE_GAINED           = 11,
    TB_TEXT_VIGIL_ALLIANCE_LOST             = 12,
    TB_TEXT_VIGIL_HORDE_GAINED              = 13,
    TB_TEXT_VIGIL_HORDE_LOST                = 14,
    TB_TEXT_SLAGWORKS_ALLIANCE_GAINED       = 15,
    TB_TEXT_SLAGWORKS_ALLIANCE_LOST         = 16,
    TB_TEXT_SLAGWORKS_HORDE_GAINED          = 17,
    TB_TEXT_SLAGWORKS_HORDE_LOST            = 18,
    TB_TEXT_FORTRESS_DEFEND_ALLIANCE        = 19,
    TB_TEXT_FORTRESS_DEFEND_HORDE           = 20,
    TB_TEXT_FORTRESS_CAPTURE_ALLIANCE       = 21,
    TB_TEXT_FORTRESS_CAPTURE_HORDE          = 22,
    TB_TEXT_VEHICLE_OUTSIDE_WARNING         = 23,
    TB_TEXT_PREPARATIONS_IN_5_MIN           = 24,
    TB_TEXT_PREPARATIONS_IN_2_MIN           = 25,
    TB_TEXT_PREPARATIONS_IN_1_MIN           = 26,
};

enum TolBaradEvent
{
    EVENT_COUNT_CAPTURED_BASE = 1,
};

const uint32 TBFactions[PVP_TEAMS_COUNT] = { 1610, 1732 };

// Stalker
Position const TolBaradDebugAnnouncerPos = { -1234.25f, 961.903f, 159.4913f, 0.0f };

// Quest Infantry NPCs
enum TBQuestInfantryEntry
{
    NPC_ALLIANCE_WARRIOR_INFANTRY = 47599,
    NPC_ALLIANCE_PALADIN_INFANTRY = 47600,
    NPC_ALLIANCE_HUNTER_INFANTRY = 47595,
    NPC_ALLIANCE_MAGE_INFANTRY = 47598,

    NPC_HORDE_DRUID_INFANTRY = 47607,
    NPC_HORDE_MAGE_INFANTRY = 47608,
    NPC_HORDE_ROGUE_INFANTRY = 47609,
    NPC_HORDE_SHAMAN_INFANTRY = 47610,
};

uint32 const TB_QUEST_INFANTRY[PVP_TEAMS_COUNT][4] =
{
    { NPC_HORDE_DRUID_INFANTRY, NPC_HORDE_MAGE_INFANTRY, NPC_HORDE_ROGUE_INFANTRY, NPC_HORDE_SHAMAN_INFANTRY },
    { NPC_ALLIANCE_WARRIOR_INFANTRY, NPC_ALLIANCE_PALADIN_INFANTRY, NPC_ALLIANCE_HUNTER_INFANTRY, NPC_ALLIANCE_MAGE_INFANTRY },
};

uint8 const TB_QUEST_INFANTRY_MAX = 37;
Position const TBQuestInfantrySpawnData[TB_QUEST_INFANTRY_MAX] =
{
    { -930.4685f, 1020.178f, 121.5658f, 0.1537642f  },
    { -831.5157f, 975.816f,  121.5255f, 5.022717f   },
    { -837.0773f, 943.9008f, 121.5055f, 5.461119f   },
    { -839.1646f, 1024.046f, 121.5505f, 4.782219f   },
    { -881.283f,  1033.25f,  121.5243f, 0.0f        },
    { -883.038f,  924.955f,  121.5243f, 0.0f        },
    { -883.913f,  978.059f,  121.5243f, 3.388291f   },
    { -883.6224f, 950.8459f, 121.5122f, 0.8307042f  },
    { -895.181f,  1015.2f,   121.5505f, 2.652318f   },
    { -943.4023f, 961.7462f, 121.5658f, 5.258394f   },
    { -958.649f,  926.877f,  121.5243f, 0.0f        },
    { -959.743f,  1029.09f,  121.5243f, 0.0f        },
    { -964.6652f, 978.5373f, 121.5257f, 0.02025719f },
    { -1407.14f,  721.42f,   123.5033f, 0.0f        },
    { -1414.46f,  671.66f,   123.5043f, 0.0f        },
    { -1431.7f,   623.073f,  123.5043f, 0.0f        },
    { -1434.162f, 655.8566f, 123.5051f, 4.84886f    },
    { -1445.19f,  739.729f,  123.5457f, 5.767949f   },
    { -1460.954f, 718.418f,  123.6453f, 5.178094f   },
    { -1462.48f,  694.378f,  123.5463f, 0.3441857f  },
    { -1372.23f,  683.707f,  123.5043f, 0.0f        },
    { -1479.46f,  635.799f,  123.5043f, 0.0f        },
    { -1491.259f, 734.5692f, 123.4525f, 1.529741f   },
    { -1509.024f, 688.8625f, 123.5463f, 6.243045f   },
    { -1419.311f, 1310.25f,  133.8389f, 0.0f        },
    { -1444.24f,  1266.439f, 133.8229f, 0.0f        },
    { -1450.569f, 1337.351f, 133.914f,  0.0f        },
    { -1479.819f, 1331.34f,  153.2f,    0.0f        },
    { -1497.62f,  1276.429f, 133.6676f, 3.147845f   },
    { -1498.37f,  1379.689f, 133.827f,  0.0f        },
    { -1499.97f,  1232.87f,  133.8239f, 0.0f        },
    { -1505.7f,   1261.99f,  133.7089f, 0.6167698f  },
    { -1531.84f,  1316.569f, 153.2f,    0.0f        },
    { -1533.141f, 1267.66f,  133.836f,  0.0f        },
    { -1547.59f,  1300.21f,  133.7094f, 1.908187f   },
    { -1563.3f,   1325.79f,  133.6673f, 0.0f        },
};

// Guard NPCs
enum TBGuardEntry
{
    NPC_BARADIN_GUARD                       = 51165,
    NPC_HELLSCREAMS_SENTRY                  = 51166,
};

uint8 const TB_GUARDS_MAX = 8;
Position const GuardNPCSpawns[TB_GUARDS_MAX] =
{
//  { -837.3768f, 1196.082f, 114.2994f, 3.036873f },
//  { -762.118f,  1195.259f, 107.2007f, 3.036873f },
//  { -837.809f,  1179.842f, 114.1356f, 3.159046f },
//  { -762.5504f, 1179.019f, 107.2137f, 3.159046f },
    { -1272.951f, 964.8854f, 119.5782f, 3.193953f },
    { -1274.394f, 997.6511f, 119.5743f, 3.193953f },
    { -1248.226f, 1018.476f, 119.8113f, 1.605703f },
    { -1218.948f, 943.5695f, 119.5994f, 4.625123f },
    { -1195.417f, 965.5364f, 119.8113f, 0.0f },
    { -1220.832f, 1018.497f, 119.8113f, 1.605703f },
    { -1196.151f, 999.5121f, 119.5966f, 0.0f },
    { -1249.304f, 942.9063f, 119.5782f, 4.625123f },
};

enum TBFactionNPCEntry
{
    // Guards
    NPC_BARADIN_GUARD_1 = 47324,
    NPC_BARADIN_GUARD_2 = 47325,
    NPC_BARADIN_GRUNT_1 = 47335,
    NPC_BARADIN_GRUNT_2 = 47336,

    // Questgivers
    NPC_SERGEANT_PARKER = 48066, // Everytime
    NPC_COMMANDER_STEVENS = 48039, // One of these three
    NPC_2ND_LIEUTENANT_WANSWORTH = 48061,
    NPC_MARSHAL_FALLOWS = 48074,

    NPC_COMMANDER_ZANOTH = 48069, // Everytime!
    NPC_STAFF_SERGEANT_LAZGAR = 48062, // One of these three
    NPC_DRILLMASTER_RAZGOTH = 48070,
    NPC_PRIVATE_GARNOTH = 48071,

    // Portal summoners
    NPC_MAVEN_ZARA = 50173,
    NPC_RHAGHA = 50167,
};

struct TBFactionNPCInfo
{
    Position pos;
    uint32 entryAlliance;
    uint32 entryHorde;
};

uint8 const TB_FACTION_NPC_MAX = 4;
TBFactionNPCInfo const FactionNPCSpawns[TB_FACTION_NPC_MAX] =
{
    { { -1259.356f, 1057.108f, 107.0786f, 4.956735f }, NPC_BARADIN_GUARD_1, NPC_BARADIN_GRUNT_1 },
    { { -1254.174f, 1061.094f, 107.0772f, 5.445427f }, NPC_BARADIN_GUARD_2, NPC_BARADIN_GRUNT_2 },
    { { -1256.365f, 1058.47f, 107.0776f, 2.216568f }, NPC_MAVEN_ZARA, NPC_RHAGHA },
    { { -1231.38f, 985.681f, 121.2403f, 0.6108652f }, NPC_SERGEANT_PARKER, NPC_COMMANDER_ZANOTH },
};

// Questing
enum TBQuesting
{
    CELLBLOCK_THE_HOLE          = 0, // The Hole area
    CELLBLOCK_D_BLOCK           = 1, // D-Block area
    CELLBLOCK_CURSED_DEPTHS     = 2, // Cursed Depths area
    CELLBLOCK_MAX               = 3,
    CELLBLOCK_NONE,

    AREA_THE_HOLE = 5659,
    AREA_D_BLOCK = 5657,
    AREA_CURSED_DEPTHS = 5658,

    GO_GATE_TO_THE_HOLE                     = 206845,
    GO_GATE_D_BLOCK                         = 206844,
    GO_CURSED_DEPTHS_GATE                   = 206843,

    GO_CRATE_OF_CELLBLOCK_RATIONS           = 206996,
    GO_CURSED_SHACKLES                      = 206905,
    GO_DUSTY_PRISON_JOURNAL                 = 206890,
};

Position const RandomQuestgiverPos = { -1228.93f, 975.038f, 121.7153f, 5.969026f };

struct TBQuestAreaInfo
{
    uint32 entry;
    uint32 teleportSpell;
};
TBQuestAreaInfo const TBQuestAreas[CELLBLOCK_MAX] =
{
    { AREA_THE_HOLE, SPELL_TB_THE_HOLE_TELEPORT },
    { AREA_D_BLOCK, SPELL_TB_D_BLOCK_TELEPORT },
    { AREA_CURSED_DEPTHS, SPELL_TB_CURSED_DEPTHS_TELEPORT },
};
uint32 const RandomQuestgivers[PVP_TEAMS_COUNT][CELLBLOCK_MAX] =
{
    { NPC_MARSHAL_FALLOWS, NPC_2ND_LIEUTENANT_WANSWORTH, NPC_COMMANDER_STEVENS },
    { NPC_DRILLMASTER_RAZGOTH, NPC_STAFF_SERGEANT_LAZGAR, NPC_PRIVATE_GARNOTH },
};

// Capture Points
enum TBCapturePointId
{
    TB_BASE_IRONCLAD_GARRISON = 0,
    TB_BASE_WARDENS_VIGIL = 1,
    TB_BASE_SLAGWORKS = 2,
    TB_BASE_COUNT = 3,
};

struct TBCapturePointSpawnData
{
    Position pos;
    TBCapturePointId id;
    uint32 entryFlagPole[2];
    uint32 wsControlled[2];
    uint32 wsCapturing[2];
    uint32 wsNeutral;
    uint32 textGained[2];
    uint32 textLost[2];
};

TBCapturePointSpawnData const TBCapturePoints[TB_BASE_COUNT] =
{
    { { -896.96f, 979.497f, 121.441f, 3.124123f }, TB_BASE_IRONCLAD_GARRISON, { GO_CAPTURE_POINT_NORTH_A_DEFENDING, GO_CAPTURE_POINT_NORTH_H_DEFENDING }, { WS_BATTLEFIELD_TB_GARRISON_ALLIANCE_CONTROLLED, WS_BATTLEFIELD_TB_GARRISON_HORDE_CONTROLLED }, { WS_BATTLEFIELD_TB_GARRISON_ALLIANCE_CAPTURING, WS_BATTLEFIELD_TB_GARRISON_HORDE_CAPTURING }, WS_BATTLEFIELD_TB_GARRISON_NEUTRAL, { TB_TEXT_GARRISON_ALLIANCE_GAINED, TB_TEXT_GARRISON_HORDE_GAINED }, { TB_TEXT_GARRISON_ALLIANCE_LOST, TB_TEXT_GARRISON_HORDE_LOST } },
    { { -1492.34f, 1309.87f, 152.961f, 5.462882f }, TB_BASE_WARDENS_VIGIL, { GO_CAPTURE_POINT_WEST_A_DEFENDING, GO_CAPTURE_POINT_WEST_H_DEFENDING }, { WS_BATTLEFIELD_TB_VIGIL_ALLIANCE_CONTROLLED, WS_BATTLEFIELD_TB_VIGIL_HORDE_CONTROLLED }, { WS_BATTLEFIELD_TB_VIGIL_ALLIANCE_CAPTURING, WS_BATTLEFIELD_TB_VIGIL_HORDE_CAPTURING }, WS_BATTLEFIELD_TB_VIGIL_NEUTRAL, { TB_TEXT_VIGIL_ALLIANCE_GAINED, TB_TEXT_VIGIL_HORDE_GAINED }, { TB_TEXT_VIGIL_ALLIANCE_LOST, TB_TEXT_VIGIL_HORDE_LOST } },
    { { -1437.f, 685.556f, 123.421f, 0.802851f }, TB_BASE_SLAGWORKS, { GO_CAPTURE_POINT_EAST_A_DEFENDING, GO_CAPTURE_POINT_EAST_H_DEFENDING }, { WS_BATTLEFIELD_TB_SLAGWORKS_ALLIANCE_CONTROLLED, WS_BATTLEFIELD_TB_SLAGWORKS_HORDE_CONTROLLED }, { WS_BATTLEFIELD_TB_SLAGWORKS_ALLIANCE_CAPTURING, WS_BATTLEFIELD_TB_SLAGWORKS_HORDE_CAPTURING }, WS_BATTLEFIELD_TB_SLAGWORKS_NEUTRAL, { TB_TEXT_SLAGWORKS_ALLIANCE_GAINED, TB_TEXT_SLAGWORKS_HORDE_GAINED }, { TB_TEXT_SLAGWORKS_ALLIANCE_LOST, TB_TEXT_SLAGWORKS_HORDE_LOST } },
};

// Towers
enum TBTowerId
{
    TB_TOWER_EAST_SPIRE = 0,
    TB_TOWER_SOUTH_SPIRE = 1,
    TB_TOWER_WEST_SPIRE = 2,
    TB_TOWERS_COUNT = 3,
};

struct TBTowerInfo
{
    Position pos;
    uint32 entry;
    uint32 textDamaged;
    uint32 textDestroyed;
    uint32 wsIntact[PVP_TEAMS_COUNT];
    uint32 wsDamaged[PVP_TEAMS_COUNT];
    uint32 wsDestroyed;
};

TBTowerInfo const TBTowers[TB_TOWERS_COUNT] =
{
    { { -1013.279f, 529.5382f, 146.427f, 1.97222f }, GO_EAST_SPIRE, TB_TEXT_EAST_SPIRE_DAMAGED, TB_TEXT_EAST_SPIRE_DESTROYED, { WS_BATTLEFIELD_TB_EAST_INTACT_ALLIANCE, WS_BATTLEFIELD_TB_EAST_INTACT_HORDE }, { WS_BATTLEFIELD_TB_EAST_DAMAGED_ALLIANCE, WS_BATTLEFIELD_TB_EAST_DAMAGED_HORDE }, WS_BATTLEFIELD_TB_EAST_DESTROYED_NEUTRAL },
    { { -1618.91f, 954.5417f, 168.601f, 0.06981169f }, GO_SOUTH_SPIRE, TB_TEXT_SOUTH_SPIRE_DAMAGED, TB_TEXT_SOUTH_SPIRE_DESTROYED, { WS_BATTLEFIELD_TB_SOUTH_INTACT_ALLIANCE, WS_BATTLEFIELD_TB_SOUTH_INTACT_HORDE }, { WS_BATTLEFIELD_TB_SOUTH_DAMAGED_ALLIANCE, WS_BATTLEFIELD_TB_SOUTH_DAMAGED_HORDE }, WS_BATTLEFIELD_TB_SOUTH_DESTROYED_NEUTRAL },
    { { -950.4097f, 1469.101f, 176.596f, 4.180066f }, GO_WEST_SPIRE, TB_TEXT_WEST_SPIRE_DAMAGED, TB_TEXT_WEST_SPIRE_DESTROYED, { WS_BATTLEFIELD_TB_WEST_INTACT_ALLIANCE, WS_BATTLEFIELD_TB_WEST_INTACT_HORDE }, { WS_BATTLEFIELD_TB_WEST_DAMAGED_ALLIANCE, WS_BATTLEFIELD_TB_WEST_DAMAGED_HORDE }, WS_BATTLEFIELD_TB_WEST_DESTROYED_NEUTRAL },
};

// Vehicles
enum TBVehicles
{
    NPC_ABANDONED_SIEGE_ENGINE = 45344,
};

int8 const TB_ABANDONED_SIEGE_ENGINE_COUNT = 6;
Position const TBAbandonedSiegeEngineSpawnData[TB_ABANDONED_SIEGE_ENGINE_COUNT] =
{
    { -1106.57f, 1196.34f, 121.8023f, 0.4014257f },
    { -1108.52f, 1111.33f, 121.2783f, 1.37881f },
    { -1213.01f, 782.236f, 121.4473f, 1.675516f },
    { -1258.26f, 780.497f, 122.4413f, 1.48353f },
    { -1438.3f, 1095.24f, 121.1363f, 5.288348f },
    { -1442.3f, 1141.07f, 123.6323f, 4.24115f },
};

// Banners
enum TBFactionBannerEntry
{
    GO_BARADINS_WARDEN_BANNER = 207391, // Alliance banner
    GO_HELLSCREAM_REACH_BANNER = 207400, // Horde banner
};

uint32 const TBBannerEntry[PVP_TEAMS_COUNT] = { GO_BARADINS_WARDEN_BANNER, GO_HELLSCREAM_REACH_BANNER };

uint8 const TB_BANNER_MAX = 23;
Position const TBBanners[TB_BANNER_MAX] =
{
    { -987.6129f, 963.9861f, 121.4506f, 2.617989f },
    { -988.118f, 993.0087f, 121.6746f, 3.612838f },
    { -1195.941f, 964.342f, 119.728f, 0.8901166f },
    { -1196.892f, 1000.957f, 119.8211f, 5.445428f },
    { -1198.236f, 1081.898f, 120.2007f, 1.06465f },
    { -1089.337f, 1157.161f, 120.2749f, 3.036838f },
    { -1090.033f, 1143.476f, 120.2656f, 3.036838f },
    { -1217.495f, 944.0261f, 119.4949f, 1.989672f },
    { -1219.226f, 1018.168f, 119.728f, 2.251473f },
    { -1210.319f, 1081.885f, 120.2396f, 2.007128f },
    { -1226.903f, 786.7656f, 119.4592f, 1.553341f },
    { -1228.464f, 979.7379f, 119.3814f, 0.03490625f },
    { -1239.668f, 786.7899f, 119.4271f, 1.553341f },
    { -1250.262f, 1017.887f, 119.728f, 0.8377575f },
    { -1250.693f, 943.4496f, 119.4949f, 5.305802f },
    { -1272.29f, 963.5208f, 119.4949f, 2.617989f },
    { -1273.997f, 998.7934f, 119.4884f, 3.665196f },
    { -1378.363f, 725.0087f, 124.2978f, 1.326448f },
    { -1401.97f, 747.0972f, 123.2302f, 0.2443456f },
    { -1421.953f, 1263.559f, 133.6141f, 5.009095f },
    { -1446.497f, 1238.964f, 133.7601f, 5.969027f },
    { -1488.908f, 1118.747f, 124.9255f, 6.248279f },
    { -1488.533f, 1131.608f, 124.6363f, 6.248279f },
};

// Portals
enum TBPortalEntry
{
    TB_PORTAL_ALLIANCE = 208227, // Portal to Stormwind
    TB_PORTAL_HORDE = 208226, // Portal to Orgrimmar
};

uint32 const TBPortalEntry[PVP_TEAMS_COUNT] = { TB_PORTAL_ALLIANCE, TB_PORTAL_HORDE };

uint8 const TB_PORTAL_MAX = 2;
Position const TBPortals[TB_PORTAL_MAX] =
{
    { -598.7656f, 1377.974f, 21.91898f, 0.0f },
    { -1257.729f, 1060.365f, 106.9938f, 5.462882f },
};

/* ################### *
 * Tol Barad graveyard *
 * ################### */

enum TBGraveyardAreaId
{
    // Tol Barad
    TB_GY_BARADIN_HOLD = 1789,
    TB_GY_IRONCLAD_GARRISON = 1783,
    TB_GY_WARDENS_VIGIL = 1785,
    TB_GY_SLAGWORKS = 1787,
    TB_GY_WEST_SPIRE = 1784,
    TB_GY_SOUTH_SPIRE = 1786,
    TB_GY_EAST_SPIRE = 1788,
    BATTLEFIELD_TB_GRAVEYARD_MAX = 7,

    // Tol Barad Peninsula
    TBP_GY_ALLIANCE_DAILY = 1808,
    TBP_GY_HORDE_DAILY = 1807,
};

struct TBGraveyardInfo
{
    Position pos;
    uint32 phaseId;
    uint32 gyid;
    uint32 spiritEntry[PVP_TEAMS_COUNT];
    bool defenderControls;
};

TBGraveyardInfo const TBGraveyards[BATTLEFIELD_TB_GRAVEYARD_MAX] =
{
    { { -1247.42f, 981.25f, 155.35f, 6.28f }, 128, TB_GY_BARADIN_HOLD, { NPC_TB_GY_SPIRIT_BARADIN_HOLD_A, NPC_TB_GY_SPIRIT_BARADIN_HOLD_H }, true },
    { { -974.28f, 1089.47f, 132.99f, 5.90f }, 64, TB_GY_IRONCLAD_GARRISON, { NPC_TB_GY_SPIRIT_IRONCLAD_GARRISON_A, NPC_TB_GY_SPIRIT_IRONCLAD_GARRISON_H }, false },
    { { -1570.44f, 1167.57f, 159.50f, 2.20f }, 64, TB_GY_WARDENS_VIGIL, { NPC_TB_GY_SPIRIT_WARDENS_VIGIL_A, NPC_TB_GY_SPIRIT_WARDENS_VIGIL_H }, false },
    { { -1343.32f, 565.24f, 139.04f, 1.66f }, 64, TB_GY_SLAGWORKS, { NPC_TB_GY_SPIRIT_SLAGWORKS_A, NPC_TB_GY_SPIRIT_SLAGWORKS_H }, false },
    { { -1052.02f, 1494.05f, 191.41f, 4.13f }, 64, TB_GY_WEST_SPIRE, { NPC_TB_GY_SPIRIT_WEST_SPIRE_A, NPC_TB_GY_SPIRIT_WEST_SPIRE_H }, false },
    { { -1603.34f, 874.29f, 193.69f, 5.27f }, 64, TB_GY_SOUTH_SPIRE, { NPC_TB_GY_SPIRIT_SOUTH_SPIRE_A, NPC_TB_GY_SPIRIT_SOUTH_SPIRE_H }, false },
    { { -943.66f, 572.36f, 157.54f, 1.74f }, 64, TB_GY_EAST_SPIRE, { NPC_TB_GY_SPIRIT_EAST_SPIRE_A, NPC_TB_GY_SPIRIT_EAST_SPIRE_H }, false },
};

/* ####################### *
 * Tol Barad capture point *
 * ####################### */

class TolBaradCapturePoint : public BattlefieldControlZoneHandler
{
    public:
        TolBaradCapturePoint(BattlefieldTB* battlefield, TBCapturePointSpawnData const& data);

        void HandleContestedEventHorde([[maybe_unused]] GameObject* controlZone) override;
        void HandleContestedEventAlliance([[maybe_unused]] GameObject* controlZone) override;
        void HandleProgressEventHorde([[maybe_unused]] GameObject* controlZone) override;
        void HandleProgressEventAlliance([[maybe_unused]] GameObject* controlZone) override;
        void HandleNeutralEventHorde([[maybe_unused]] GameObject* controlZone) override;
        void HandleNeutralEventAlliance([[maybe_unused]] GameObject* controlZone) override;
        void HandleNeutralEvent([[maybe_unused]] GameObject* controlZone) override;

        uint32 GetWorldStateHordeControlled() const { return _worldstateHordeControlled; }
        uint32 GetWorldStateAllianceControlled() const { return _worldstateAllianceControlled; }

    private:
        uint32 _textIdHordeCaptured;
        uint32 _textIdAllianceCaptured;
        uint32 _textIdHordeLost;
        uint32 _textIdAllianceLost;
        uint32 _worldstateHordeControlled;
        uint32 _worldstateAllianceControlled;
        uint32 _worldstateHordeCapturing;
        uint32 _worldstateAllianceCapturing;
        uint32 _worldstateNeutral;
};

/* ##################### *
 * Tol Barad battlefield *
 * ##################### */

class BattlefieldTB : public Battlefield
{
    public:
        using Battlefield::Battlefield;
        ~BattlefieldTB();

        void OnStartGrouping() override;
        void OnBattleStart() override;
        void OnBattleEnd(bool endByTimer) override;

        void OnPlayerEnterZone(Player* player) override;
        void OnPlayerLeaveZone(Player* player) override;

        void OnPlayerJoinWar(Player* player) override;
        void OnPlayerLeaveWar(Player* player) override;

        bool Update(uint32 diff) override;

        void OnCreatureCreate(Creature* creature) override;
        //void OnCreatureRemove(Creature* creature) override;

        void OnGameObjectCreate(GameObject* go) override;

        void UpdateCapturedBaseCount();
        //void UpdatedDestroyedTowerCount(TeamId team);

        //void DoCompleteOrIncrementAchievement(uint32 achievement, Player* player, uint8 incrementNumber = 1) override;

        bool SetupBattlefield() override;

        void HandleKill(Player* killer, Unit* victim) override;
        //void OnUnitDeath(Unit* unit) override;
        void PromotePlayer(Player* killer);
        void RemoveAurasFromPlayer(Player* player);

        void ProcessEvent(WorldObject* obj, uint32 eventId, WorldObject* invoker) override;

        void TowerDamaged(TBTowerId tbTowerId);
        void TowerDestroyed(TBTowerId tbTowerId);

        // returns the graveyardId in the specified area.
        //uint8 GetSpiritGraveyardId(uint32 areaId) const;

        void UpdateNPCsAndGameObjects();
        void CreateCapturePoints();

    protected:
        // Minutes till battle preparation warnings
        bool warnedFiveMinutes;
        bool warnedTwoMinutes;
        bool warnedOneMinute;

        bool updatedNPCAndObjects;
        uint32 m_updateObjectsTimer;

        uint32 m_BonusTime;

        GuidSet BattleInactiveNPCs;
        GuidSet BattleInactiveGOs;

        GuidSet TemporaryNPCs;
        GuidSet TemporaryGOs;

        GuidSet Towers;

        uint8 m_iCellblockRandom;

        ObjectGuid TBGatesGUID;
        ObjectGuid TBDoorGUID;

        ObjectGuid m_gateToTheHoleGUID;
        ObjectGuid m_gateDBlockGUID;
        ObjectGuid m_gateCursedDepthsGUID;
};

#endif