TrinityCore
Loading...
Searching...
No Matches
battleground_deephaul_ravine.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#include "AreaTrigger.h"
19#include "AreaTriggerAI.h"
20#include "Battleground.h"
21#include "BattlegroundScript.h"
22#include "GameObject.h"
23#include "Language.h"
24#include "Map.h"
25#include "MotionMaster.h"
26#include "ObjectAccessor.h"
27#include "Player.h"
28#include "ScriptedCreature.h"
29#include "ScriptMgr.h"
30#include "SpellScript.h"
31#include "TaskScheduler.h"
32#include "TemporarySummon.h"
33#include "Vehicle.h"
34#include <queue>
35
37{
38 namespace Actions
39 {
40 static constexpr uint32 CaptureMineCart = 1;
41 static constexpr uint32 ConsumeBuff = 2;
42 static constexpr uint32 AllianceCartAppearedInitial = 3;
43 static constexpr uint32 HordeCartAppearedInitial = 4;
44 static constexpr uint32 CommanderStartIntro = 5;
45 }
46
47 namespace AreaTriggers
48 {
49 static constexpr uint32 CapturePointAlliance = 30;
50 static constexpr uint32 CapturePointHorde = 31;
51
52 static constexpr uint32 RuneOfFrequency = 33926;
53 static constexpr uint32 BerserkerBuff = 21077;
54 static constexpr uint32 HealingBuff = 21076;
55 }
56
57 namespace BroadcastTexts
58 {
59 static constexpr uint32 CrystalCapturedAlliance = 18375;
60 static constexpr uint32 CrystalCapturedHorde = 18384;
61
62 static constexpr uint32 AllianceControlMineCart = 60441; // copied from Silvershard Mines
63 static constexpr uint32 HordeControlMineCart = 60442; // copied from Silvershard Mines
64
65 static constexpr uint32 AllianceCaptureMineCart = 59689; // copied from Silvershard Mines
66 static constexpr uint32 HordeCaptureMineCart = 59690; // copied from Silvershard Mines
67
68 static constexpr uint32 FlagDropped = 18361;
69 }
70
71 namespace Creatures
72 {
73 static constexpr uint32 MineCartEast = 214690;
74 static constexpr uint32 MineCartWest = 217346;
75 static constexpr uint32 GenericBunny = 214731;
76
77 static constexpr uint32 ForemanUzjax = 224086;
78 static constexpr uint32 Ruffious = 224087;
79
80 static constexpr uint32 EarthenMineCartHorde = 211155;
81 static constexpr uint32 EarthenMineCartAlliance = 211271;
82 }
83
84 namespace CreatureTexts
85 {
86 static constexpr uint8 Intro1 = 0;
87 static constexpr uint8 Intro2 = 1;
88 static constexpr uint8 CrystalSpawn = 2;
89 static constexpr uint8 CartSpawn = 3;
90 static constexpr uint8 Lost = 4;
91 static constexpr uint8 Win = 5;
92 }
93
94 namespace Events
95 {
96 static constexpr uint32 ProgressEventHordeWest = 88514;
97 static constexpr uint32 ProgressEventAllianceWest = 88515;
98 static constexpr uint32 ProgressEventHordeEast = 88510;
99 static constexpr uint32 ProgressEventAllianceEast = 88511;
100
101 static constexpr uint32 BattlegroundStarted = 35912;
102 }
103
104 namespace GameObjects
105 {
106 static constexpr uint32 DeephaulCrystal = 422413; // Flag
107
108 static constexpr uint32 EarthenworksStartingGateX = 437274;
109 static constexpr uint32 WaterworksStartingGateX = 446147;
110 }
111
112 namespace PathIds
113 {
114 static constexpr int32 EastCart = 214690 * 100;
115 static constexpr int32 WestCart = 217346 * 100;
116
117 namespace Ruffious
118 {
119 static constexpr uint32 Path1 = 224087 * 100;
120 static constexpr uint32 Path2 = 224087 * 100 + 1;
121 static constexpr uint32 Path3 = 224087 * 100 + 2;
122 static constexpr uint32 Path4 = 224087 * 100 + 3;
123 }
124
125 namespace ForemanUzjax
126 {
127 static constexpr uint32 Path1 = 224086 * 100;
128 static constexpr uint32 Path2 = 224086 * 100 + 1;
129 static constexpr uint32 Path3 = 224086 * 100 + 2;
130 static constexpr uint32 Path4 = 224086 * 100 + 3;
131 }
132 }
133
134 namespace Positions
135 {
136 static constexpr Position WestMineCartSpawn = { 4250.3647f, -2751.066f, 239.46973f, static_cast<float>(M_PI) };
137 static constexpr Position EastMineCartSpawn = { 3875.0f, -3150.0f, 240.2913f, 0.0f };
138
139 static constexpr std::array<Position, 5> EarthenMineCartsHorde =
140 {{
141 { 4179.265625f, -2788.0712890625f, 240.7358856201171875f, 4.05515289306640625f },
142 { 4163.166015625f, -2809.192626953125f, 240.86444091796875f, 4.05515289306640625f },
143 { 4171.251953125f, -2798.54345703125f, 240.8136138916015625f, 4.05515289306640625f },
144 { 4175.2255859375f, -2793.239501953125f, 240.7935028076171875f, 4.091466903686523437f },
145 { 4167.109375f, -2803.795166015625f, 240.978973388671875f, 4.05515289306640625f }
146 }};
147
148 static constexpr std::array<Position, 5> EarthenMineCartsAlliance =
149 {{
150 { 3949.052978515625f, -3106.71875f, 240.960845947265625f, 4.05515289306640625f },
151 { 3961.213623046875f, -3090.671875f, 241.0115814208984375f, 4.05515289306640625f },
152 { 3957.064208984375f, -3095.954833984375f, 240.8014068603515625f, 4.05515289306640625f },
153 { 3965.46875f, -3084.96533203125f, 240.85400390625f, 4.068012237548828125f },
154 { 3953.146728515625f, -3101.30029296875f, 240.928680419921875f, 4.05515289306640625f },
155 }};
156 }
157
158 namespace PvpStats
159 {
160 static constexpr int32 FlagCaptures = 1020;
161 static constexpr int32 CartsControlled = 1021;
162 }
163
164 namespace Sounds
165 {
166 static constexpr uint32 PvpFlagTakenAlliance = 8174;
167 static constexpr uint32 PvpFlagTakenHorde = 8212;
168 static constexpr uint32 PvpFlagCapturedAlliance = 8173;
169 static constexpr uint32 PvpFlagCapturedHorde = 8213;
170 }
171
172 namespace Spells
173 {
174 static constexpr uint32 DeephaulCrystal = 434339;
175
176 static constexpr uint32 ControlVisualHorde = 430220;
177 static constexpr uint32 ControlVisualNeutral = 430178;
178 static constexpr uint32 ControlVisualAlliance = 430221;
179
180 static constexpr uint32 CartControlCapturePointUnitEast = 430211;
181 static constexpr uint32 CartControlCapturePointUnitWest = 430216;
182
183 static constexpr uint32 CartCap = 430207;
184
185 static constexpr uint32 DefendingCartAura = 128646;
186
187 static constexpr uint32 Restoration = 296575;
188 static constexpr uint32 Berserking = 296576;
189 static constexpr uint32 RuneOfFrequency = 422968;
190
191 static constexpr uint32 CartExhaustion = 456466;
192
193 static constexpr uint32 RecentlyDroppedFlag = 50327;
194 }
195
196 namespace WorldStates
197 {
198 static constexpr int32 FlagEnabled = 25412; // when this is 3, the flag is spawned
199
200 static constexpr int32 HordeTeamScore = 24959;
201 static constexpr int32 AllianceTeamScore = 24958;
202
203 static constexpr int32 MaxTeamScore = 24960;
204
205 static constexpr int32 BattleBegun = 7852;
206
207 static constexpr int32 AllianceControlsEastMineCart = 25415;
208 static constexpr int32 HordeControlsEastMineCart = 25414;
209
210 static constexpr int32 AllianceControlsWestMineCart = 25421;
211 static constexpr int32 HordeControlsWestMineCart = 25420;
212
215
216 /*
217 * 1; on reset; dropped
218 * 2; when taken
219 */
220 static constexpr int32 HordeFlagState = 1546;
221 /*
222 * 1; on reset; dropped
223 * 2; when taken
224 */
225 static constexpr int32 AllianceFlagState = 1545;
226
227 // WSE: 12385, "(WorldState(6954) + WorldState(6955)) == 1")
228 // values might be swapped, they are not send to client
229 // See SilvershardMines
230 static constexpr int32 AllianceCapturedCart = 6954;
231 static constexpr int32 HordeCapturedCart = 6955;
232
233 namespace Values
234 {
235 static constexpr int32 FlagClaimed = 2; // On Player
236 static constexpr int32 FlagUnclaimed = 1; // Not on player (in base, dropped, respawning)
237 }
238 }
239}
240
242{
244
255
256 void OnStart() override
257 {
259 _scheduler.Schedule(15s, [&](TaskContext const&)
260 {
262 });
263
265
266 _scheduler.Schedule(2s, [&](TaskContext& context)
267 {
268 uint32 const underAllianceControl = std::ranges::count_if(DeephaulRavine::WorldStates::AllianceControlWorldStates, [&](int32 worldState)
269 {
270 return battlegroundMap->GetWorldStateValue(worldState) == 1;
271 });
272
273 uint32 const underHordeControl = std::ranges::count_if(DeephaulRavine::WorldStates::HordeControlWorldStates, [&](int32 worldState)
274 {
275 return battlegroundMap->GetWorldStateValue(worldState) == 1;
276 });
277
279
280 uint32 const hordeScoreToAdd = std::min<uint32>(maxTeamScore - battleground->GetTeamScore(TEAM_HORDE), underHordeControl * 3);
281 uint32 const allianceScoreToAdd = std::min<uint32>(maxTeamScore - battleground->GetTeamScore(TEAM_ALLIANCE), underAllianceControl * 3);
282
283 battleground->AddPoint(HORDE, hordeScoreToAdd);
284 battleground->AddPoint(ALLIANCE, allianceScoreToAdd);
285
287
288 if (!CheckWinner())
289 context.Repeat();
290 });
291
292 _scheduler.Schedule(5s, [&](TaskContext& context)
293 {
295 context.Repeat();
296 });
297
298 for (ObjectGuid const& guid : _doorGUIDs)
299 {
300 if (GameObject* gameobject = battlegroundMap->GetGameObject(guid))
301 {
302 gameobject->UseDoorOrButton();
303 gameobject->DespawnOrUnsummon(3s);
304 }
305 }
306
308 }
309
310 void OnPrepareStage3() override
311 {
313
314 _scheduler.Schedule(2s, [&](TaskContext const&)
315 {
317 });
318
319 _scheduler.Schedule(15s, [&](TaskContext const&)
320 {
321 DoForLeaders([&](Creature const* creature)
322 {
324 });
325 });
326 }
327
328 void OnUpdate(uint32 diff) override
329 {
331 _scheduler.Update(diff);
332 }
333
334 void OnGameObjectCreate(GameObject* gameobject) override
335 {
337
338 switch (gameobject->GetEntry())
339 {
341 _flagGUID = gameobject->GetGUID();
342 break;
345 _doorGUIDs.emplace_back(gameobject->GetGUID());
346 break;
347 default:
348 break;
349 }
350 }
351
352 bool CanCaptureFlag(AreaTrigger* areaTrigger, Player* player) override
353 {
354 Team const team = battleground->GetPlayerTeam(player->GetGUID());
355 TeamId const teamId = Battleground::GetTeamIndexByTeamId(team);
356
357 if (areaTrigger->GetGUID() != _capturePointAreaTriggers[teamId])
358 return false;
359
361 return player->GetGUID() == flag->GetFlagCarrierGUID();
362
363 return false;
364 }
365
388
389 void OnFlagStateChange(GameObject* flagInBase, FlagState oldValue, FlagState newValue, Player* player) override
390 {
391 BattlegroundScript::OnFlagStateChange(flagInBase, oldValue, newValue, player);
392
393 switch (newValue)
394 {
395 case FlagState::Taken:
401 break;
403 if (player->GetBGTeam() == ALLIANCE)
405 else
410 break;
414
416 {
417 DoForLeaders([&](Creature const* creature)
418 {
419 creature->AI()->Talk(DeephaulRavine::CreatureTexts::CrystalSpawn);
420 });
421 });
422 break;
426 break;
427 default:
428 break;
429 }
430 }
431
432 void DoAction(uint32 actionId, WorldObject* source, WorldObject* target) override
433 {
434 BattlegroundScript::DoAction(actionId, source, target);
435
436 switch (actionId)
437 {
439 HandleMineCartCaptured();
440 break;
442 HandleConsumeBuff(Object::ToAreaTrigger(source), Object::ToPlayer(target));
443 break;
446 break;
449 break;
450 default:
451 break;
452 }
453 }
454
455 void HandleConsumeBuff(AreaTrigger* trigger, Player* player)
456 {
457 if (!trigger || !player)
458 return;
459
460 switch (trigger->GetCreateProperties()->Template->Id.Id)
461 {
463 player->CastSpell(player, DeephaulRavine::Spells::Berserking, true);
464 break;
467 break;
469 player->CastSpell(player, DeephaulRavine::Spells::Restoration, true);
470 break;
471 default:
472 break;
473 }
474
475 AreaTriggerCreatePropertiesId const createPropertiesId = trigger->GetCreateProperties()->Id;
476 Position pos = trigger->GetPosition();
477
478 _scheduler.Schedule(90s, [&, createPropertiesId, pos](TaskContext const&)
479 {
480 if (Creature* genericBunny = battlegroundMap->GetCreature(_genericBunnyGUID))
481 AreaTrigger::CreateAreaTrigger(createPropertiesId, pos, -1, genericBunny, nullptr);
482 });
483
484 trigger->Remove();
485 }
486
487 void OnCreatureCreate(Creature* creature) override
488 {
490
491 switch (creature->GetEntry())
492 {
494 _genericBunnyGUID = creature->GetGUID();
495 break;
497 _leaderGUIDs[TEAM_HORDE] = creature->GetGUID();
498 break;
500 _leaderGUIDs[TEAM_ALLIANCE] = creature->GetGUID();
501 break;
502 default:
503 break;
504 }
505 }
506
507 void OnCreatureRemove(Creature* creature) override
508 {
509 switch (creature->GetEntry())
510 {
512 _allianceDespawnedMineCarts.push(creature->GetPosition());
513 break;
515 _hordeDespawnedMineCarts.push(creature->GetPosition());
516 break;
517 default:
518 break;
519 }
520 }
521
540
541 void OnAreaTriggerCreate(AreaTrigger* areaTrigger) override
542 {
544 if (!areaTrigger->IsStaticSpawn())
545 return;
546
547 switch (areaTrigger->GetEntry())
548 {
550 _capturePointAreaTriggers[TEAM_ALLIANCE] = areaTrigger->GetGUID();
551 break;
553 _capturePointAreaTriggers[TEAM_HORDE] = areaTrigger->GetGUID();
554 break;
555 default:
556 break;
557 }
558 }
559
560 void HandleProgressEvent(GameObject const* controlZone, Team team, uint32 controlVisualSpell, uint32 textId, ChatMsg msgType) const
561 {
562 if (!controlZone)
563 return;
564
565 Creature* mineCart = Object::ToCreature(controlZone->GetOwner());
566 if (!mineCart)
567 return;
568
572 mineCart->CastSpell(mineCart, controlVisualSpell, true);
573 UpdateCartWorldStates(controlZone);
574 battleground->SendBroadcastText(textId, msgType, controlZone);
575
576 for (ObjectGuid const& guid : *controlZone->GetInsidePlayers())
577 if (Player* player = ObjectAccessor::FindPlayer(guid))
578 if (player->GetBGTeam() == team)
579 battleground->UpdatePvpStat(player, DeephaulRavine::PvpStats::CartsControlled, 1);
580 }
581
583 {
584 _cartsReached++;
585 if (_cartsReached != 2)
586 return;
587
588 for (ObjectGuid const& cartGUID : _cartGUIDs)
589 {
590 if (Creature* creature = battlegroundMap->GetCreature(cartGUID))
591 {
592 GameObject* controlZone = nullptr;
594 controlZone = creature->GetGameObject(DeephaulRavine::Spells::CartControlCapturePointUnitEast);
596 controlZone = creature->GetGameObject(DeephaulRavine::Spells::CartControlCapturePointUnitWest);
597
598 if (controlZone)
599 {
600 uint32 const scoreToAdd = std::min<uint32>(1500 - battleground->GetTeamScore(controlZone->GetControllingTeam()), 100);
601 if (controlZone->GetControllingTeam() == TEAM_HORDE)
602 {
603 if (battlegroundMap->GetWorldStateValue(DeephaulRavine::WorldStates::HordeCapturedCart) != 1)
604 UpdateWorldState(DeephaulRavine::WorldStates::HordeCapturedCart, 1, true);
605
606 battleground->SendBroadcastText(DeephaulRavine::BroadcastTexts::HordeCaptureMineCart, CHAT_MSG_BG_SYSTEM_HORDE, creature);
607 if (battleground->GetStatus() != STATUS_WAIT_LEAVE)
608 battleground->AddPoint(HORDE, scoreToAdd);
609 }
610 else if (controlZone->GetControllingTeam() == TEAM_ALLIANCE)
611 {
612 if (battlegroundMap->GetWorldStateValue(DeephaulRavine::WorldStates::AllianceCapturedCart) != 1)
613 UpdateWorldState(DeephaulRavine::WorldStates::AllianceCapturedCart, 1, true);
614
616 if (battleground->GetStatus() != STATUS_WAIT_LEAVE)
617 battleground->AddPoint(ALLIANCE, scoreToAdd);
618 }
619 }
620
621 creature->DespawnOrUnsummon();
622 }
623 }
624
629
630 CheckWinner();
631
632 _scheduler.Schedule(2s, [&](TaskContext const&)
633 {
634 SpawnMineCarts();
635 });
636 }
637
639 {
640 _cartsReached = 0;
641
642 // both mine carts spawn with Neutral aura; while they are controlled by their faction, this gets overriden a few moments later
644 {
645 _cartGUIDs[0] = creature->GetGUID();
646
647 creature->CastSpell(creature, DeephaulRavine::Spells::CartControlCapturePointUnitEast, true);
648 creature->CastSpell(creature, DeephaulRavine::Spells::ControlVisualNeutral, true);
649 creature->CastSpell(creature, DeephaulRavine::Spells::DefendingCartAura, true);
650 creature->GetMotionMaster()->MovePath(DeephaulRavine::PathIds::EastCart, false);
651
654 }
655
657 {
658 _cartGUIDs[1] = creature->GetGUID();
659
660 creature->CastSpell(creature, DeephaulRavine::Spells::CartControlCapturePointUnitWest, true);
661 creature->CastSpell(creature, DeephaulRavine::Spells::ControlVisualNeutral, true);
662 creature->CastSpell(creature, DeephaulRavine::Spells::DefendingCartAura, true);
663 creature->GetMotionMaster()->MovePath(DeephaulRavine::PathIds::WestCart, false);
664
667 }
668
669 DoForLeaders([&](Creature const* creature)
670 {
672 });
673 }
674
675 void SendTeamScores() const
676 {
677 UpdateWorldState(DeephaulRavine::WorldStates::HordeTeamScore, battleground->GetTeamScore(TEAM_HORDE));
678 UpdateWorldState(DeephaulRavine::WorldStates::AllianceTeamScore, battleground->GetTeamScore(TEAM_ALLIANCE));
679 }
680
681 void UpdateCartWorldStates(GameObject const* controlZone) const
682 {
683 if (!controlZone)
684 return;
685
686 Creature const* creature = Object::ToCreature(controlZone->GetOwner());
687 if (!creature)
688 return;
689
690 TeamId const controllingTeam = controlZone->GetControllingTeam();
691
692 switch (creature->GetEntry())
693 {
696 UpdateWorldState(DeephaulRavine::WorldStates::HordeControlsEastMineCart, controllingTeam == TEAM_HORDE);
697 break;
700 UpdateWorldState(DeephaulRavine::WorldStates::HordeControlsWestMineCart, controllingTeam == TEAM_HORDE);
701 break;
702 default:
703 break;
704 }
705 }
706
707 bool CheckWinner() const
708 {
709 uint32 const hordeScore = battleground->GetTeamScore(TEAM_HORDE);
710 uint32 const allianceScore = battleground->GetTeamScore(TEAM_ALLIANCE);
711 uint32 const maxScore = static_cast<uint32>(battlegroundMap->GetWorldStateValue(DeephaulRavine::WorldStates::MaxTeamScore));
712
713 if (hordeScore >= maxScore || allianceScore >= maxScore)
714 {
715 SendTeamScores();
716
717 if (hordeScore >= maxScore && allianceScore >= maxScore)
718 {
719 battleground->EndBattleground(TEAM_OTHER);
720 return true;
721 }
722
723 if (hordeScore >= maxScore)
724 {
725 battleground->EndBattleground(HORDE);
726 if (Creature const* uzjax = battlegroundMap->GetCreature(_leaderGUIDs[TEAM_HORDE]))
727 uzjax->AI()->Talk(DeephaulRavine::CreatureTexts::Win);
728 if (Creature const* ruffious = battlegroundMap->GetCreature(_leaderGUIDs[TEAM_ALLIANCE]))
729 ruffious->AI()->Talk(DeephaulRavine::CreatureTexts::Lost);
730 return true;
731 }
732
733 if (allianceScore >= maxScore)
734 {
735 battleground->EndBattleground(ALLIANCE);
736 if (Creature const* uzjax = battlegroundMap->GetCreature(_leaderGUIDs[TEAM_HORDE]))
737 uzjax->AI()->Talk(DeephaulRavine::CreatureTexts::Lost);
738 if (Creature const* ruffious = battlegroundMap->GetCreature(_leaderGUIDs[TEAM_ALLIANCE]))
739 ruffious->AI()->Talk(DeephaulRavine::CreatureTexts::Win);
740 return true;
741 }
742 }
743
744 return false;
745 }
746
747 template <std::invocable<Creature*> Action>
748 void DoForLeaders(Action const& fn) const
749 {
750 for (ObjectGuid const& guid : _leaderGUIDs)
751 if (Creature* creature = battlegroundMap->GetCreature(guid))
752 fn(creature);
753 }
754
756 {
757 size_t allianceDespawnedMineCartCount = _allianceDespawnedMineCarts.size();
758 size_t hordeDespawnedMineCartCount = _hordeDespawnedMineCarts.size();
759
760 while (allianceDespawnedMineCartCount > 0 && !_hordeDespawnedMineCarts.empty())
761 {
762 --allianceDespawnedMineCartCount;
763 Position pos = _hordeDespawnedMineCarts.front();
764 _hordeDespawnedMineCarts.pop();
765 battlegroundMap->SummonCreature(DeephaulRavine::Creatures::EarthenMineCartHorde, pos);
766 }
767
768 while (hordeDespawnedMineCartCount > 0 && !_allianceDespawnedMineCarts.empty())
769 {
770 --hordeDespawnedMineCartCount;
771 Position pos = _allianceDespawnedMineCarts.front();
772 _allianceDespawnedMineCarts.pop();
773 battlegroundMap->SummonCreature(DeephaulRavine::Creatures::EarthenMineCartAlliance, pos);
774 }
775 }
776
777private:
781 std::array<ObjectGuid, 2> _cartGUIDs;
782 std::array<ObjectGuid, 2> _controlZoneGUIDs;
783 std::array<ObjectGuid, 2> _capturePointAreaTriggers;
785 std::array<ObjectGuid, 2> _leaderGUIDs; // Foreman Uzjax & Ruffious
786
787 std::queue<Position> _hordeDespawnedMineCarts;
788 std::queue<Position> _allianceDespawnedMineCarts;
789
791};
792
793// 214690 - Mine Cart
794// 217346 - Mine Cart
796{
797public:
798 explicit npc_bg_deephaul_cavern_mine_cart(Creature* creature) : ScriptedAI(creature) { }
799
823
824 void WaypointPathEnded(uint32 nodeId, uint32 pathId) override
825 {
826 ScriptedAI::WaypointPathEnded(nodeId, pathId);
827
828 switch (pathId)
829 {
832 OnCapture();
833 break;
834 default:
835 break;
836 }
837 }
838
843};
844
845// 430207 - Cart Cap
847{
848 void HandleScript(SpellEffIndex /*effIndex*/) const
849 {
850 Creature* hitCreature = GetHitCreature();
851 if (!hitCreature)
852 return;
853
854 if (ZoneScript* zoneScript = hitCreature->GetZoneScript())
855 zoneScript->DoAction(DeephaulRavine::Actions::CaptureMineCart, hitCreature, hitCreature);
856 }
857
862};
863
864// 211271 - Earthen Mine Cart
865// 211155 - Earthen Mine Cart
867{
868public:
870
871 void OnSpellClick(Unit* clicker, bool spellClickHandled) override
872 {
873 ScriptedAI::OnSpellClick(clicker, spellClickHandled);
874
875 if (!spellClickHandled)
876 return;
877
879 }
880};
881
882// 211153 - Earthen Mine Cart
884{
885public:
887 {
888 }
889
890 static constexpr int32 Path1 = 211153 * 100;
891 static constexpr int32 Path2 = 211153 * 100 + 1;
892 static constexpr int32 Path3 = 211153 * 100 + 2;
893
894 void JustAppeared() override
895 {
897 _scheduler.Schedule(1500ms, [&](TaskContext const&)
898 {
899 // teleport packet sends same x & y for some reason
900 // teleport and movement start at same time
901 me->NearTeleportTo({ 4160.4297f, -2812.3852f, 240.29422f });
902 me->GetMotionMaster()->MovePath(Path1, false);
903 });
904 }
905
906 void UpdateAI(uint32 diff) override
907 {
908 _scheduler.Update(diff);
909 }
910
911 void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
912 {
913 switch (pathId)
914 {
915 case Path1:
916 _scheduler.Schedule(500ms, [&](TaskContext const&)
917 {
918 if (Vehicle* vehicle = me->GetVehicleKit())
919 vehicle->RemoveAllPassengers();
920 me->GetMotionMaster()->MovePath(Path2, false);
921 });
922 break;
923 case Path2:
924 _scheduler.Schedule(1s, [&](TaskContext const&)
925 {
926 me->GetMotionMaster()->MovePath(Path3, false);
927 });
928 break;
929 case Path3:
931 break;
932 default:
933 break;
934 }
935 }
936
937private:
939};
940
941// 211270 - Earthen Mine Cart
943{
944public:
946 {
947 }
948
949 static constexpr int32 Path1 = 211270 * 100;
950 static constexpr int32 Path2 = 211270 * 100 + 1;
951
952 void JustAppeared() override
953 {
955 _scheduler.Schedule(1500ms, [&](TaskContext const&)
956 {
957 // teleport packet sends same x & y for some reason
958 // teleport and movement start at same time
959 me->NearTeleportTo({ 3968.5852f, -3080.5815f, 240.14261f, 0.0f });
960 me->GetMotionMaster()->MovePath(Path1, false);
961 });
962 }
963
964 void UpdateAI(uint32 diff) override
965 {
966 _scheduler.Update(diff);
967 }
968
969 void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
970 {
971 switch (pathId)
972 {
973 case Path1:
974 _scheduler.Schedule(500ms, [&](TaskContext const&)
975 {
976 if (Vehicle* vehicle = me->GetVehicleKit())
977 {
978 for (auto const& [_, seat] : vehicle->Seats)
979 {
980 if (Unit* passenger = ObjectAccessor::GetUnit(*me, seat.Passenger.Guid))
981 {
982 passenger->CastSpell(passenger, DeephaulRavine::Spells::CartExhaustion, true);
983 passenger->_ExitVehicle();
984 }
985 }
986 }
987 me->GetMotionMaster()->MovePath(Path2, false);
988 });
989 break;
990 case Path2:
991 _scheduler.Schedule(1s, [&](TaskContext const&)
992 {
994 });
995 break;
996 default:
997 break;
998 }
999 }
1000
1001private:
1003};
1004
1005// 21076 - PvP Rune Rejuv Visual (New)
1006// 21077 - PvP Rune Berserking Visual (New)
1007// 33926 - PvP Rune Cooldown Visual (New)
1009{
1010 explicit at_bg_deephaul_ravine_buff(AreaTrigger* areaTrigger) : AreaTriggerAI(areaTrigger) { }
1011
1012 void OnUnitEnter(Unit* unit) override
1013 {
1014 if (Player* player = unit->ToPlayer())
1015 if (ZoneScript* zonescript = at->GetZoneScript())
1016 zonescript->DoAction(DeephaulRavine::Actions::ConsumeBuff, at, player);
1017 }
1018};
1019
1020// 224087 - Ruffious
1021// 224086 - Foreman Uzjax
1022template<uint32 Path1, uint32 Path2, uint32 Path3, uint32 Path4>
1024{
1025public:
1026 explicit npc_bg_deephaul_ravine_commander(Creature* creature) : ScriptedAI(creature) { }
1027
1028 void JustAppeared() override
1029 {
1031 me->SetHover(true);
1032 me->SetDisableGravity(true);
1033 }
1034
1035 void DoAction(int32 actionId) override
1036 {
1038 {
1040 me->GetMotionMaster()->MovePath(Path1, false);
1041 }
1042 }
1043
1044 void UpdateAI(uint32 diff) override
1045 {
1047 _scheduler.Update(diff);
1048 }
1049
1050 void WaypointPathEnded(uint32 /*nodeId*/, uint32 pathId) override
1051 {
1052 switch (pathId)
1053 {
1054 case Path1:
1055 _scheduler.Schedule(10s, [this](TaskContext const&)
1056 {
1057 me->GetMotionMaster()->MovePath(Path2, false);
1059 });
1060 break;
1061 case Path2:
1062 _scheduler.Schedule(3s, [this](TaskContext const&)
1063 {
1064 me->GetMotionMaster()->MovePath(Path3, false);
1065 });
1066 break;
1067 case Path3:
1068 _scheduler.Schedule(5s, [this](TaskContext const&)
1069 {
1070 me->GetMotionMaster()->MovePath(Path4, false);
1071 });
1072 break;
1073 default:
1074 break;
1075 }
1076 }
1077
1078private:
1080};
1081
1082// 424383 - Earthen Mine Cart Ride
1083// 424166 - Earthen Mine Cart Ride
1085{
1086 void OnApply(AuraEffect const* /*auraEffect*/, AuraEffectHandleModes /*mode*/) const
1087 {
1088 // instantly remove this aura
1090 }
1091
1096};
1097
@ STATUS_WAIT_LEAVE
#define M_PI
Definition Common.h:118
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
FlagState
Definition GameObject.h:46
@ LANG_BG_DR_CRYSTAL_TAKEN_TUTORIAL
Definition Language.h:1222
@ LANG_BG_DR_CRYSTAL_TAKEN
Definition Language.h:1221
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:434
Spells
Definition PlayerAI.cpp:32
#define RegisterBattlegroundMapScript(script_name, mapId)
Definition ScriptMgr.h:1447
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ TEAM_ALLIANCE
@ TEAM_HORDE
@ SPELL_EFFECT_SCRIPT_EFFECT
@ TEAM_OTHER
@ ALLIANCE
@ HORDE
ChatMsg
@ CHAT_MSG_BG_SYSTEM_ALLIANCE
@ CHAT_MSG_RAID_BOSS_EMOTE
@ CHAT_MSG_BG_SYSTEM_HORDE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_DUMMY
#define SpellEffectFn(F, I, N)
#define AuraEffectApplyFn(F, I, N, M)
Creatures
void AddSC_battleground_deephaul_ravine()
Action
Sounds
AreaTrigger *const at
AreaTriggerCreatePropertiesId Id
AreaTriggerTemplate const * Template
bool IsStaticSpawn() const
static AreaTrigger * CreateAreaTrigger(AreaTriggerCreatePropertiesId areaTriggerCreatePropertiesId, Position const &pos, int32 duration, Unit *caster, Unit *target, SpellCastVisual spellVisual={ 0, 0 }, SpellInfo const *spellInfo=nullptr, Spell *spell=nullptr, AuraEffect const *aurEff=nullptr)
AreaTriggerCreateProperties const * GetCreateProperties() const
HookList< EffectApplyHandler > AfterEffectApply
Aura * GetAura() const
Unit * GetTarget() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
Battleground * battleground
void TriggerGameEvent(uint32 gameEventId, WorldObject *source=nullptr, WorldObject *target=nullptr) override
BattlegroundMap * battlegroundMap
virtual void OnUpdate(uint32 diff)
virtual void OnPrepareStage3()
void UpdateWorldState(int32 worldStateId, int32 value, bool hidden=false) const
void PlaySoundToAll(uint32 SoundID)
uint32 GetTeamScore(TeamId teamId) const
void SendMessageToAll(uint32 entry, ChatMsg type, Player const *source=nullptr)
static TeamId GetTeamIndexByTeamId(Team team)
void SendBroadcastText(uint32 id, ChatMsg msgType, WorldObject const *target=nullptr)
void AddPoint(Team team, uint32 points=1)
Team GetPlayerTeam(ObjectGuid guid) const
void UpdatePvpStat(Player *player, uint32 pvpStatId, uint32 value)
virtual void WaypointPathEnded(uint32, uint32)
Definition CreatureAI.h:224
virtual void OnSpellClick(Unit *, bool)
Definition CreatureAI.h:230
virtual void JustAppeared()
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
CreatureAI * AI() const
Definition Creature.h:228
GameObjectTemplate const * GetGOInfo() const
Definition GameObject.h:203
GuidUnorderedSet const * GetInsidePlayers() const
TeamId GetControllingTeam() const
TempSummon * SummonCreature(uint32 entry, Position const &pos, SummonPropertiesEntry const *properties=nullptr, Milliseconds duration=0ms, WorldObject *summoner=nullptr, uint32 spellId=0, uint32 vehId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty, SmoothPhasingInfo const *smoothPhasingInfo=nullptr)
Definition Object.cpp:1186
int32 GetWorldStateValue(int32 worldStateId) const
Definition Map.cpp:427
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3552
void MovePath(uint32 pathId, bool repeatable, Optional< Milliseconds > duration={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< std::pair< Milliseconds, Milliseconds > > waitTimeRangeAtPathEnd={}, Optional< float > wanderDistanceAtPathEnds={}, Optional< bool > followPathBackwardsFromEndToStart={}, Optional< bool > exactSplinePath={}, bool generatePath=true, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
Player * ToPlayer()
Definition Object.h:126
AreaTrigger * ToAreaTrigger()
Definition Object.h:146
GameObject * ToGameObject()
Definition Object.h:131
uint32 GetEntry() const
Definition Object.h:89
Creature * ToCreature()
Definition Object.h:121
Team GetBGTeam() const
Definition Player.cpp:24358
Creature * GetHitCreature() const
HookList< EffectHandler > OnEffectHitTarget
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
WorldObject * GetSummoner() const
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
Definition Unit.h:635
void EnterVehicle(Unit *base, int8 seatId=-1)
Definition Unit.cpp:12749
void RemoveAura(AuraApplicationMap::iterator &i, AuraRemoveMode mode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3828
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
bool SetHover(bool enable, bool updateAnimTier=true)
Definition Unit.cpp:13577
TempSummon * ToTempSummon()
Definition Unit.h:1828
bool SetDisableGravity(bool disable, bool updateAnimTier=true)
Definition Unit.cpp:13361
void NearTeleportTo(TeleportLocation const &target, bool casting=false)
Definition Unit.cpp:12958
Vehicle * GetVehicleKit() const
Definition Unit.h:1782
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
TempSummon * SummonCreature(uint32 entry, Position const &pos, TempSummonType despawnType=TEMPSUMMON_MANUAL_DESPAWN, Milliseconds despawnTime=0s, uint32 vehId=0, uint32 spellId=0, ObjectGuid privateObjectOwner=ObjectGuid::Empty)
Definition Object.cpp:1398
Unit * GetOwner() const
Definition Object.cpp:1598
ZoneScript * GetZoneScript() const
Definition Object.h:417
virtual void DoAction(uint32 actionId, WorldObject *source=nullptr, WorldObject *target=nullptr)
Definition ZoneScript.h:104
virtual void OnCaptureFlag(AreaTrigger *areaTrigger, Player *player)
Definition ZoneScript.h:109
virtual void OnFlagStateChange(GameObject *flagInBase, FlagState oldValue, FlagState newValue, Player *player)
Definition ZoneScript.h:106
virtual void OnAreaTriggerCreate(AreaTrigger *areaTrigger)
Definition ZoneScript.h:82
virtual void OnCreatureCreate(Creature *)
Definition ZoneScript.h:76
virtual void ProcessEvent(WorldObject *obj, uint32 eventId, WorldObject *invoker)
Definition ZoneScript.h:103
virtual void OnGameObjectCreate(GameObject *)
Definition ZoneScript.h:79
void WaypointPathEnded(uint32 nodeId, uint32 pathId) override
void WaypointPathEnded(uint32, uint32 pathId) override
void OnSpellClick(Unit *clicker, bool spellClickHandled) override
void OnApply(AuraEffect const *, AuraEffectHandleModes) const
static constexpr uint32 CommanderStartIntro
static constexpr uint32 CaptureMineCart
static constexpr uint32 AllianceCartAppearedInitial
static constexpr uint32 HordeCartAppearedInitial
static constexpr uint32 EarthenMineCartAlliance
static constexpr uint32 EarthenMineCartHorde
static constexpr uint32 BattlegroundStarted
static constexpr uint32 ProgressEventAllianceEast
static constexpr uint32 ProgressEventHordeWest
static constexpr uint32 ProgressEventAllianceWest
static constexpr uint32 ProgressEventHordeEast
static constexpr uint32 EarthenworksStartingGateX
static constexpr std::array< Position, 5 > EarthenMineCartsHorde
static constexpr Position WestMineCartSpawn
static constexpr Position EastMineCartSpawn
static constexpr std::array< Position, 5 > EarthenMineCartsAlliance
static constexpr uint32 PvpFlagTakenAlliance
static constexpr uint32 PvpFlagCapturedHorde
static constexpr uint32 PvpFlagTakenHorde
static constexpr uint32 PvpFlagCapturedAlliance
static constexpr uint32 CartControlCapturePointUnitWest
static constexpr uint32 RuneOfFrequency
static constexpr uint32 ControlVisualNeutral
static constexpr uint32 ControlVisualAlliance
static constexpr uint32 RecentlyDroppedFlag
static constexpr uint32 CartControlCapturePointUnitEast
static constexpr uint32 DefendingCartAura
static constexpr uint32 DeephaulCrystal
static constexpr uint32 ControlVisualHorde
static constexpr int32 AllianceControlsWestMineCart
static constexpr std::array< int32, 2 > HordeControlWorldStates
static constexpr int32 AllianceControlsEastMineCart
static constexpr std::array< int32, 2 > AllianceControlWorldStates
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
struct GameObjectTemplate::@197::@235 newflag
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
virtual void UpdateAI(uint32 diff) override
at_bg_deephaul_ravine_buff(AreaTrigger *areaTrigger)
void OnCreatureRemove(Creature *creature) override
std::array< ObjectGuid, 2 > _controlZoneGUIDs
void OnCaptureFlag(AreaTrigger *areaTrigger, Player *player) override
void OnFlagStateChange(GameObject *flagInBase, FlagState oldValue, FlagState newValue, Player *player) override
void OnCreatureCreate(Creature *creature) override
void UpdateCartWorldStates(GameObject const *controlZone) const
std::array< ObjectGuid, 2 > _capturePointAreaTriggers
void DoAction(uint32 actionId, WorldObject *source, WorldObject *target) override
void ProcessEvent(WorldObject *obj, uint32 eventId, WorldObject *invoker) override
bool CanCaptureFlag(AreaTrigger *areaTrigger, Player *player) override
void OnGameObjectCreate(GameObject *gameobject) override
void HandleConsumeBuff(AreaTrigger *trigger, Player *player)
void HandleProgressEvent(GameObject const *controlZone, Team team, uint32 controlVisualSpell, uint32 textId, ChatMsg msgType) const
void DoForLeaders(Action const &fn) const
void OnAreaTriggerCreate(AreaTrigger *areaTrigger) override