TrinityCore
Loading...
Searching...
No Matches
auchindoun.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 "GameObject.h"
21#include "InstanceScript.h"
22#include "Map.h"
23#include "MotionMaster.h"
24#include "ObjectAccessor.h"
25#include "PhasingHandler.h"
26#include "Player.h"
27#include "ScriptedCreature.h"
28#include "ScriptMgr.h"
29#include "SpellScript.h"
30#include "TaskScheduler.h"
31#include "auchindoun.h"
32
34{
41
42 // SPELL_INSTANCE_BOOTSTRAPPER = 171344 // This spell appears in a lot of sniffs, but the purpose is unknown
43};
44
51
53{
54 // Auchenai Defender
56
57 // Soulbinder Tuulani
64};
65
67{
68 // Waypoint
69 PATH_BARRIER = 7924800,
71
74
76
77 // Spawngroups
79};
80
81// 9973 - Areatrigger
83{
84public:
85 at_auchindoun_entrance() : OnlyOnceAreaTriggerScript("at_auchindoun_entrance") { }
86
87 bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
88 {
89 if (InstanceScript* instance = player->GetInstanceScript())
90 {
91 if (Creature* tuulani = instance->GetCreature(DATA_SOULBINDER_TUULANI))
92 tuulani->AI()->DoAction(ACTION_TUULANI_INTRO);
93 }
94 return true;
95 }
96};
97
98// 10072 - Areatrigger
100{
101public:
102 at_auchindoun_auchenai_defender_intro() : OnlyOnceAreaTriggerScript("at_auchindoun_auchenai_defender_intro") { }
103
104 bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
105 {
106 if (Creature* auchenaiDefender = player->FindNearestCreatureWithOptions(30.0f, { .StringId = "npc_auchenai_defender_intro" }))
107 auchenaiDefender->AI()->DoAction(ACTION_AUCHENAI_DEFENDER_TALK);
108
109 return true;
110 }
111};
112
113// 9974 - Areatrigger
114// Not OnlyOnce because players can trigger this AT before Tuulani reaches the barrier
116{
117public:
118 at_auchindoun_barrier() : AreaTriggerScript("at_auchindoun_barrier") { }
119
120 bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
121 {
122 if (InstanceScript* instance = player->GetInstanceScript())
123 {
124 if (Creature* tuulani = instance->GetCreature(DATA_SOULBINDER_TUULANI))
125 tuulani->AI()->DoAction(ACTION_TUULANI_BREAK_BARRIER);
126 }
127 return true;
128 }
129};
130
131// 10280 - Areatrigger
133{
134public:
135 at_auchindoun_soulbinder_nyami_scene() : OnlyOnceAreaTriggerScript("at_auchindoun_soulbinder_nyami_scene") { }
136
137 bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
138 {
139 player->CastSpell(player, SPELL_GRIMRAIL_DEPOT_SELECTOR, true);
140
141 if (InstanceScript* instance = player->GetInstanceScript())
142 {
143 if (Creature* tuulani = instance->GetCreature(DATA_SOULBINDER_TUULANI))
144 tuulani->DespawnOrUnsummon();
145 }
146 return true;
147 }
148};
149
150// 77693 - Auchenai Defender
152{
154
155 void DoAction(int32 action) override
156 {
157 if (action == ACTION_AUCHENAI_DEFENDER_TALK)
158 {
160
161 _scheduler.Schedule(1s + 300ms, [this](TaskContext const& /*task*/)
162 {
163 me->SetFacingTo(3.8194849f);
165 });
166 }
167 }
168
169 void UpdateAI(uint32 diff) override
170 {
171 _scheduler.Update(diff);
172 }
173
174private:
176};
177
178// 79248 - Soulbinder Tuulani
180{
182
183 void DoAction(int32 action) override
184 {
185 if (action == ACTION_TUULANI_INTRO)
186 {
188
189 _scheduler.Schedule(4s + 300ms, [this](TaskContext& task)
190 {
192
193 task.Schedule(6s, [this](TaskContext const& /*task*/)
194 {
195 me->GetMotionMaster()->MovePath(PATH_BARRIER, false);
196 });
197 });
198 }
199 else if (action == ACTION_TUULANI_BREAK_BARRIER)
200 {
202 return;
203
204 _actionStarted = true;
205
207
208 _scheduler.Schedule(3s, [this](TaskContext& task)
209 {
211
212 task.Schedule(4s, [this](TaskContext& task)
213 {
215 holyBarrier->SetGoState(GO_STATE_ACTIVE);
216
217 task.Schedule(2s + 300ms, [this](TaskContext& task)
218 {
220
221 task.Schedule(1s + 300ms, [this](TaskContext const& /*task*/)
222 {
223 me->GetMotionMaster()->MovePath(PATH_MOVE_TO_BOSS, false);
224 });
225 });
226 });
227 });
228 }
229 }
230
231 void WaypointReached(uint32 waypointId, uint32 pathId) override
232 {
233 if (pathId == PATH_BARRIER)
234 {
235 switch (waypointId)
236 {
237 case POINT_TALK:
238 {
239 _scheduler.Schedule(500ms, [this](TaskContext const& /*task*/)
240 {
242 });
243 break;
244 }
245 case POINT_BARRIER:
246 {
247 _isAtBarrier = true;
248 break;
249 }
250 default:
251 break;
252 }
253 }
254 else if (pathId == PATH_MOVE_TO_BOSS)
255 {
256 if (waypointId == POINT_SOULS)
257 {
258 _scheduler.Schedule(500ms, [this](TaskContext const& /*task*/)
259 {
260 me->SetFacingTo(1.727875f);
262 });
263 }
264 }
265 }
266
267 void UpdateAI(uint32 diff) override
268 {
269 _scheduler.Update(diff);
270 }
271
272private:
276};
277
278// 155647 - NPC Reaction
280{
281 at_auchindoun_npc_reaction(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
282
283 void OnUnitEnter(Unit* unit) override
284 {
286 return;
287
288 _scheduler.Schedule(1500ms, [this, unitGUID = unit->GetGUID()](TaskContext& task)
289 {
290 Creature* auchenaiDefender = ObjectAccessor::GetCreature(*at, unitGUID);
291 if (!auchenaiDefender)
292 return;
293
294 if (Unit* caster = at->GetCaster())
295 auchenaiDefender->SetFacingToObject(caster);
296 auchenaiDefender->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
297
298 task.Schedule(4s, [this, unitGUID](TaskContext const& /*task*/)
299 {
300 Creature* auchenaiDefender = ObjectAccessor::GetCreature(*at, unitGUID);
301 if (!auchenaiDefender)
302 return;
303
304 auchenaiDefender->SetFacingTo(auchenaiDefender->GetHomePosition().GetOrientation());
305 });
306 });
307 }
308
309 void OnUpdate(uint32 diff) override
310 {
311 _scheduler.Update(diff);
312 }
313
314private:
316};
317
318// 157762 - Halo
320{
321 bool Validate(SpellInfo const* /*spellInfo*/) override
322 {
324 }
325
326 void HandleHit(SpellEffIndex /*effIndex*/) const
327 {
328 if (!GetHitUnit()->IsCreature())
329 return;
330
332 }
333
338};
339
340// 178800 - Grimrail Depot
342{
343 void HandleDummy(SpellEffIndex /*effIndex*/) const
344 {
346 // GetCaster()->CastSpell(GetHitUnit(), SPELL_INSTANCE_BOOTSTRAPPER, false);
347 }
348
349 void HandleEvent(SpellEffIndex /*effIndex*/) const
350 {
351 if (InstanceScript* instance = GetCaster()->GetInstanceScript())
352 instance->SendEncounterUnit(ENCOUNTER_FRAME_PHASE_SHIFT_CHANGED, nullptr);
353 }
354
360};
361
362// 178747 - Grimrail Depot
364{
365public:
366 scene_auchindoun_soulbinder_nyami() : SceneScript("scene_auchindoun_soulbinder_nyami") { }
367
379
380 void OnSceneStart(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
381 {
383 }
384
385 void OnSceneComplete(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
386 {
387 HandleScene(player);
388 }
389
390 void OnSceneCancel(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
391 {
392 HandleScene(player);
393 }
394};
395
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ ENCOUNTER_FRAME_PHASE_SHIFT_CHANGED
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ EMOTE_STATE_READY1H_ALLOW_MOVEMENT
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ SPELL_EFFECT_SEND_EVENT
@ GO_STATE_ACTIVE
@ TRIGGERED_FULL_MASK
Used when doing CastSpell with triggered == true.
#define SpellEffectFn(F, I, N)
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:42
@ UNIT_STATE_ROOT
Definition Unit.h:271
void AddSC_auchindoun()
AuchindounSpells
@ SPELL_GRIMRAIL_DEPOT_REMOVE_AURA
@ SPELL_TUULANI_UNLOCK_VISUAL
@ SPELL_GRIMRAIL_DEPOT_SELECTOR
@ SPELL_HALO_HEAL
@ SPELL_GRIMRAIL_DEPOT_TELEPORT
@ SPELL_GRIMRAIL_DEPOT_SCENE
AuchindounActions
@ ACTION_TUULANI_BREAK_BARRIER
@ ACTION_TUULANI_INTRO
@ ACTION_AUCHENAI_DEFENDER_TALK
AuchindounMisc
@ POINT_BARRIER
@ PATH_BARRIER
@ PATH_MOVE_TO_BOSS
@ POINT_TALK
@ POINT_SOULS
@ SPAWNGROUP_TUULANI_IMPRISONED
AuchindounTexts
@ SAY_WELCOME_2
@ SAY_NYAMI_AWAITS
@ SAY_WELCOME_3
@ SAY_WELCOME_1
@ SAY_BREAK_BARRIER_2
@ SAY_HEROES_SOULS
@ SAY_BREAK_BARRIER_1
#define RegisterAuchindounCreatureAI(ai_name)
Definition auchindoun.h:64
@ DATA_HOLY_BARRIER
Definition auchindoun.h:39
@ DATA_SOULBINDER_TUULANI
Definition auchindoun.h:36
@ NPC_SOULBINDER_TUULANI
Definition auchindoun.h:50
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool IsCreature() const
Definition BaseEntity.h:172
Creature *const me
Definition CreatureAI.h:63
GameObject * GetGameObject(uint32 type)
Definition Map.h:225
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2350
bool IsSpawnGroupActive(uint32 groupId) const
Definition Map.cpp:2476
uint32 GetEntry() const
Definition Object.h:89
static bool OnConditionChange(WorldObject *object, bool updateVisibility=true)
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
HookList< EffectHandler > OnEffectHit
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
TaskContext & Schedule(TaskScheduler::duration_t time, TaskScheduler::task_handler_t task)
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
void ClearUnitState(uint32 f)
Definition Unit.h:744
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition Unit.cpp:10731
Emote GetEmoteState() const
Definition Unit.h:864
MotionMaster * GetMotionMaster()
Definition Unit.h:1723
void AddUnitState(uint32 f)
Definition Unit.h:742
void SetFacingTo(float const ori, bool force=true)
Definition Unit.cpp:13289
Map * GetMap() const
Definition Object.h:411
Creature * FindNearestCreatureWithOptions(float range, FindCreatureOptions const &options) const
Definition Object.cpp:1526
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2217
bool TryHandleOnce(Player *player, AreaTriggerEntry const *) override
bool OnTrigger(Player *player, AreaTriggerEntry const *) override
bool TryHandleOnce(Player *player, AreaTriggerEntry const *) override
bool TryHandleOnce(Player *player, AreaTriggerEntry const *) override
static void HandleScene(Player *player)
void OnSceneCancel(Player *player, uint32, SceneTemplate const *) override
void OnSceneComplete(Player *player, uint32, SceneTemplate const *) override
void OnSceneStart(Player *player, uint32, SceneTemplate const *) override
void HandleHit(SpellEffIndex) const
bool Validate(SpellInfo const *) override
void Register() override
void OnUpdate(uint32 diff) override
at_auchindoun_npc_reaction(AreaTrigger *areatrigger)
void OnUnitEnter(Unit *unit) override
void DoAction(int32 action) override
void UpdateAI(uint32 diff) override
npc_auchindoun_auchenai_defender(Creature *creature)
npc_auchindoun_soulbinder_tuulani(Creature *creature)
void WaypointReached(uint32 waypointId, uint32 pathId) override
void DoAction(int32 action) override
void UpdateAI(uint32 diff) override