TrinityCore
Loading...
Searching...
No Matches
arena_dalaran_sewers.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 "Battleground.h"
19#include "BattlegroundScript.h"
20#include "Creature.h"
21#include "Duration.h"
22#include "EventMap.h"
23#include "GameObject.h"
24#include "Map.h"
25#include "ObjectAccessor.h"
26#include "Player.h"
27#include "ScriptMgr.h"
28#include "SpellAuraEffects.h"
29#include "SpellInfo.h"
30#include "SpellMgr.h"
31#include "SpellScript.h"
32#include "TaskScheduler.h"
33
35{
36 namespace Creatures
37 {
38 static constexpr uint32 WaterSpout = 28567;
39 }
40
41 namespace Events
42 {
43 static constexpr uint32 WaterfallWarning = 1;
44 static constexpr uint32 WaterfallOn = 2;
45 static constexpr uint32 WaterfallOff = 3;
46 static constexpr uint32 WaterfallKnockBack = 4;
47 }
48
49 namespace GameObjects
50 {
51 static constexpr uint32 Door01 = 192642;
52 static constexpr uint32 Door02 = 192643;
53
54 static constexpr uint32 WaterCollision = 194395;
55 static constexpr uint32 Waterfall = 191877;
56 }
57
58 namespace MapIds
59 {
60 static constexpr uint32 DalaranSewers = 617;
61 }
62
63 namespace Spells
64 {
65 static constexpr uint32 PipeFlushKnockbackSearchTrigger = 96539;
66 static constexpr uint32 DalaranSewersPetTeleport = 254013;
67 static constexpr uint32 WaterSpout = 58873; // Knock back
68 static constexpr uint32 Flush = 57405;
69
70 static constexpr uint32 WarlockDemonicCircle = 48018;
71 }
72
73 namespace StringIds
74 {
75 static constexpr std::string_view WaterSpoutPipe = "arena_dalaran_sewers_water_spout_pipe";
76 static constexpr std::string_view WaterSpoutCenter = "arena_dalaran_sewers_water_spout_center";
77 }
78
79 namespace Timers
80 {
81 static constexpr Seconds Waterfall = 30s;
82 static constexpr Seconds WaterfallWarningDuration = 5s;
83 static constexpr Seconds WaterfallDuration = 30s;
84 static constexpr Milliseconds WaterfallKnockBack = 1500ms;
85 }
86}
87
89{
91
92 void OnUpdate(uint32 diff) override
93 {
95
97 return;
98
99 _events.Update(diff);
100 _scheduler.Update(diff);
101
102 while (uint32 eventId = _events.ExecuteEvent())
103 {
104 switch (eventId)
105 {
107 // Add the water
109 go->UseDoorOrButton();
111 break;
113 // Active collision and start knockback timer
115 go->UseDoorOrButton();
118 break;
120 // Remove collision and water
122 go->ResetDoorOrButton();
124 go->ResetDoorOrButton();
127 break;
129 // Repeat knock back while the waterfall still active
131 waterSpout->CastSpell(waterSpout, DalaranSewers::Spells::WaterSpout, true);
133 break;
134 default:
135 break;
136 }
137 }
138 }
139
140 void OnStart() override
141 {
143
144 for (ObjectGuid const& guid : _doorGUIDs)
145 {
146 if (GameObject* door = battlegroundMap->GetGameObject(guid))
147 {
148 door->UseDoorOrButton();
149 door->DespawnOrUnsummon(5s);
150 }
151 }
152
154
155 // Remove collision and water
157 go->ResetDoorOrButton();
159 go->ResetDoorOrButton();
160
161 for (const auto& [playerGuid, _] : battleground->GetPlayers())
162 if (Player* player = ObjectAccessor::FindPlayer(playerGuid))
163 player->RemoveAurasDueToSpell(DalaranSewers::Spells::WarlockDemonicCircle);
164
165 _scheduler.Schedule(6s, [&](TaskContext const&)
166 {
167 for (ObjectGuid const& guid : _waterSpoutEntranceGUIDs)
168 {
169 if (Creature* creature = battlegroundMap->GetCreature(guid))
170 {
171 creature->CastSpell(nullptr, DalaranSewers::Spells::Flush, CastSpellExtraArgsInit{
173 });
176 });
177 }
178 }
179 });
180 }
181
182 void OnCreatureCreate(Creature* creature) override
183 {
184 switch (creature->GetEntry())
185 {
188 _waterSpoutEntranceGUIDs.push_back(creature->GetGUID());
190 _waterSpoutCenterGUID = creature->GetGUID();
191 break;
192 default:
193 break;
194 }
195 }
196
197 void OnGameObjectCreate(GameObject* gameobject) override
198 {
199 switch (gameobject->GetEntry())
200 {
203 _doorGUIDs.push_back(gameobject->GetGUID());
204 break;
206 _waterCollisionGUID = gameobject->GetGUID();
207 break;
209 _waterfallGUID = gameobject->GetGUID();
210 break;
211 default:
212 break;
213 }
214 }
215
216private:
221
224
226};
227
229{
230public:
231 at_ds_pipe_knockback() : AreaTriggerScript("at_ds_pipe_knockback") { }
232
233 static void Trigger(Player* player)
234 {
235 if (Battleground const* battleground = player->GetBattleground())
236 {
237 if (battleground->GetStatus() != STATUS_IN_PROGRESS)
238 return;
239
240 // Remove effects of Demonic Circle Summon
243 }
244 }
245
246 bool OnTrigger(Player* player, AreaTriggerEntry const* /*trigger*/) override
247 {
248 Trigger(player);
249 return true;
250 }
251
252 bool OnExit(Player* player, AreaTriggerEntry const* /*trigger*/) override
253 {
254 Trigger(player);
255 return true;
256 }
257};
258
259// 96538 - Pipe Flush Knockback Search Effect
261{
262 bool Validate(SpellInfo const* spellInfo) override
263 {
264 return ValidateSpellInfo({
265 static_cast<uint32>(spellInfo->GetEffect(EFFECT_0).CalcValueAsInt())
266 });
267 }
268
269 void HandleDummy(SpellEffIndex /*effIndex*/) const
270 {
271 GetCaster()->CastSpell(nullptr, GetSpellInfo()->GetEffect(EFFECT_0).CalcValueAsInt(), CastSpellExtraArgsInit
272 {
274 });
275 }
276
281};
282
283// 61698 - Flush - Knockback effect (SERVERSIDE)
285{
286 void HandleDummy(SpellEffIndex /*effIndex*/) const
287 {
288 static constexpr float SpeedXY = 30.0f;
289 static constexpr float SpeedZ = 19.0f;
290
291 Unit* caster = GetCaster();
292 Unit const* target = GetHitUnit();
293 caster->KnockbackFrom(target->GetPosition(), SpeedXY, SpeedZ);
294 }
295
300};
301
@ STATUS_IN_PROGRESS
uint32_t uint32
Definition Define.h:154
std::chrono::milliseconds Milliseconds
Milliseconds shorthand typedef.
Definition Duration.h:24
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
std::vector< ObjectGuid > GuidVector
Definition ObjectGuid.h:434
Spells
Definition PlayerAI.cpp:32
#define RegisterBattlegroundMapScript(script_name, mapId)
Definition ScriptMgr.h:1447
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ TRIGGERED_IGNORE_CAST_IN_PROGRESS
Will not check if a current cast is in progress.
@ TRIGGERED_DONT_REPORT_CAST_ERROR
Will return SPELL_FAILED_DONT_REPORT in CheckCast functions.
#define SpellEffectFn(F, I, N)
Creatures
void AddSC_arena_dalaran_sewers()
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
Battleground * battleground
BattlegroundMap * battlegroundMap
virtual void OnUpdate(uint32 diff)
BattlegroundPlayerMap const & GetPlayers() const
BattlegroundStatus GetStatus() const
bool HasStringId(std::string_view id) const
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void CancelEvent(uint32 eventId)
Definition EventMap.cpp:135
GameObject * GetGameObject(ObjectGuid const &guid)
Definition Map.cpp:3552
Creature * GetCreature(ObjectGuid const &guid)
Definition Map.cpp:3542
uint32 GetEntry() const
Definition Object.h:89
Battleground * GetBattleground() const
Definition Player.cpp:25719
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:588
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
SpellInfo const * GetSpellInfo() const
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
Definition Unit.h:635
void KnockbackFrom(Position const &origin, float speedXY, float speedZ, float angle=M_PI, Movement::SpellEffectExtraData const *spellEffectExtraData=nullptr)
Definition Unit.cpp:12491
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
bool OnExit(Player *player, AreaTriggerEntry const *) override
static void Trigger(Player *player)
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
static constexpr uint32 WaterSpout
static constexpr uint32 WaterfallOff
static constexpr uint32 WaterfallOn
static constexpr uint32 WaterfallWarning
static constexpr uint32 WaterfallKnockBack
static constexpr uint32 Waterfall
static constexpr uint32 Door02
static constexpr uint32 WaterCollision
static constexpr uint32 Door01
static constexpr uint32 DalaranSewers
static constexpr uint32 WarlockDemonicCircle
static constexpr uint32 DalaranSewersPetTeleport
static constexpr uint32 PipeFlushKnockbackSearchTrigger
static constexpr uint32 WaterSpout
static constexpr uint32 Flush
static constexpr std::string_view WaterSpoutCenter
static constexpr std::string_view WaterSpoutPipe
static constexpr Seconds WaterfallDuration
static constexpr Seconds WaterfallWarningDuration
static constexpr Milliseconds WaterfallKnockBack
static constexpr Seconds Waterfall
TC_GAME_API Player * FindPlayer(ObjectGuid const &)
TriggerCastFlags TriggerFlags
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
void OnGameObjectCreate(GameObject *gameobject) override
void OnUpdate(uint32 diff) override
void OnCreatureCreate(Creature *creature) override
arena_dalaran_sewers(BattlegroundMap *map)