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
|
/*
* 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/>.
*/
#include "AreaTrigger.h"
#include "AreaTriggerAI.h"
#include "GameObject.h"
#include "InstanceScript.h"
#include "Map.h"
#include "MotionMaster.h"
#include "ObjectAccessor.h"
#include "PhasingHandler.h"
#include "Player.h"
#include "ScriptedCreature.h"
#include "ScriptMgr.h"
#include "SpellScript.h"
#include "TaskScheduler.h"
#include "auchindoun.h"
enum AuchindounSpells
{
SPELL_HALO_HEAL = 157795,
SPELL_TUULANI_UNLOCK_VISUAL = 160415,
SPELL_GRIMRAIL_DEPOT_SCENE = 178747,
SPELL_GRIMRAIL_DEPOT_SELECTOR = 178800,
SPELL_GRIMRAIL_DEPOT_TELEPORT = 178799,
SPELL_GRIMRAIL_DEPOT_REMOVE_AURA = 178746
// SPELL_INSTANCE_BOOTSTRAPPER = 171344 // This spell appears in a lot of sniffs, but the purpose is unknown
};
enum AuchindounActions
{
ACTION_TUULANI_INTRO = 1,
ACTION_TUULANI_BREAK_BARRIER,
ACTION_AUCHENAI_DEFENDER_TALK
};
enum AuchindounTexts
{
// Auchenai Defender
SAY_NYAMI_AWAITS = 0,
// Soulbinder Tuulani
SAY_WELCOME_1 = 0,
SAY_WELCOME_2 = 1,
SAY_WELCOME_3 = 2,
SAY_BREAK_BARRIER_1 = 3,
SAY_BREAK_BARRIER_2 = 4,
SAY_HEROES_SOULS = 5
};
enum AuchindounMisc
{
// Waypoint
PATH_BARRIER = 7924800,
PATH_MOVE_TO_BOSS = 7924801,
POINT_TALK = 2,
POINT_BARRIER = 8,
POINT_SOULS = 5,
// Spawngroups
SPAWNGROUP_TUULANI_IMPRISONED = 1264
};
// 9973 - Areatrigger
class at_auchindoun_entrance : public OnlyOnceAreaTriggerScript
{
public:
at_auchindoun_entrance() : OnlyOnceAreaTriggerScript("at_auchindoun_entrance") { }
bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
{
if (InstanceScript* instance = player->GetInstanceScript())
{
if (Creature* tuulani = instance->GetCreature(DATA_SOULBINDER_TUULANI))
tuulani->AI()->DoAction(ACTION_TUULANI_INTRO);
}
return true;
}
};
// 10072 - Areatrigger
class at_auchindoun_auchenai_defender_intro : public OnlyOnceAreaTriggerScript
{
public:
at_auchindoun_auchenai_defender_intro() : OnlyOnceAreaTriggerScript("at_auchindoun_auchenai_defender_intro") { }
bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
{
if (Creature* auchenaiDefender = player->FindNearestCreatureWithOptions(30.0f, { .StringId = "npc_auchenai_defender_intro" }))
auchenaiDefender->AI()->DoAction(ACTION_AUCHENAI_DEFENDER_TALK);
return true;
}
};
// 9974 - Areatrigger
// Not OnlyOnce because players can trigger this AT before Tuulani reaches the barrier
class at_auchindoun_barrier : public AreaTriggerScript
{
public:
at_auchindoun_barrier() : AreaTriggerScript("at_auchindoun_barrier") { }
bool OnTrigger(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
{
if (InstanceScript* instance = player->GetInstanceScript())
{
if (Creature* tuulani = instance->GetCreature(DATA_SOULBINDER_TUULANI))
tuulani->AI()->DoAction(ACTION_TUULANI_BREAK_BARRIER);
}
return true;
}
};
// 10280 - Areatrigger
class at_auchindoun_soulbinder_nyami_scene : public OnlyOnceAreaTriggerScript
{
public:
at_auchindoun_soulbinder_nyami_scene() : OnlyOnceAreaTriggerScript("at_auchindoun_soulbinder_nyami_scene") { }
bool TryHandleOnce(Player* player, AreaTriggerEntry const* /*areaTrigger*/) override
{
player->CastSpell(player, SPELL_GRIMRAIL_DEPOT_SELECTOR, true);
if (InstanceScript* instance = player->GetInstanceScript())
{
if (Creature* tuulani = instance->GetCreature(DATA_SOULBINDER_TUULANI))
tuulani->DespawnOrUnsummon();
}
return true;
}
};
// 77693 - Auchenai Defender
struct npc_auchindoun_auchenai_defender : public ScriptedAI
{
npc_auchindoun_auchenai_defender(Creature* creature) : ScriptedAI(creature) { }
void DoAction(int32 action) override
{
if (action == ACTION_AUCHENAI_DEFENDER_TALK)
{
me->SetStandState(UNIT_STAND_STATE_STAND);
_scheduler.Schedule(1s + 300ms, [this](TaskContext /*task*/)
{
me->SetFacingTo(3.8194849f);
Talk(SAY_NYAMI_AWAITS);
});
}
}
void UpdateAI(uint32 diff) override
{
_scheduler.Update(diff);
}
private:
TaskScheduler _scheduler;
};
// 79248 - Soulbinder Tuulani
struct npc_auchindoun_soulbinder_tuulani : public ScriptedAI
{
npc_auchindoun_soulbinder_tuulani(Creature* creature) : ScriptedAI(creature), _isAtBarrier(false), _actionStarted(false) { }
void DoAction(int32 action) override
{
if (action == ACTION_TUULANI_INTRO)
{
Talk(SAY_WELCOME_1);
_scheduler.Schedule(4s + 300ms, [this](TaskContext task)
{
Talk(SAY_WELCOME_2);
task.Schedule(6s, [this](TaskContext /*task*/)
{
me->GetMotionMaster()->MovePath(PATH_BARRIER, false);
});
});
}
else if (action == ACTION_TUULANI_BREAK_BARRIER)
{
if (!_isAtBarrier || _actionStarted)
return;
_actionStarted = true;
Talk(SAY_BREAK_BARRIER_1);
_scheduler.Schedule(3s, [this](TaskContext task)
{
DoCast(SPELL_TUULANI_UNLOCK_VISUAL);
task.Schedule(4s, [this](TaskContext task)
{
if (GameObject* holyBarrier = me->GetInstanceScript()->GetGameObject(DATA_HOLY_BARRIER))
holyBarrier->SetGoState(GO_STATE_ACTIVE);
task.Schedule(2s + 300ms, [this](TaskContext task)
{
Talk(SAY_BREAK_BARRIER_2);
task.Schedule(1s + 300ms, [this](TaskContext /*task*/)
{
me->GetMotionMaster()->MovePath(PATH_MOVE_TO_BOSS, false);
});
});
});
});
}
}
void WaypointReached(uint32 waypointId, uint32 pathId) override
{
if (pathId == PATH_BARRIER)
{
switch (waypointId)
{
case POINT_TALK:
{
_scheduler.Schedule(500ms, [this](TaskContext /*task*/)
{
Talk(SAY_WELCOME_3);
});
break;
}
case POINT_BARRIER:
{
_isAtBarrier = true;
break;
}
default:
break;
}
}
else if (pathId == PATH_MOVE_TO_BOSS)
{
if (waypointId == POINT_SOULS)
{
_scheduler.Schedule(500ms, [this](TaskContext /*task*/)
{
me->SetFacingTo(1.727875f);
Talk(SAY_HEROES_SOULS);
});
}
}
}
void UpdateAI(uint32 diff) override
{
_scheduler.Update(diff);
}
private:
TaskScheduler _scheduler;
bool _isAtBarrier;
bool _actionStarted;
};
// 155647 - NPC Reaction
struct at_auchindoun_npc_reaction : AreaTriggerAI
{
at_auchindoun_npc_reaction(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
void OnUnitEnter(Unit* unit) override
{
if (!unit->IsCreature() || unit->GetEmoteState() == EMOTE_STATE_READY1H_ALLOW_MOVEMENT || unit->GetEntry() == NPC_SOULBINDER_TUULANI)
return;
_scheduler.Schedule(1500ms, [this, unitGUID = unit->GetGUID()](TaskContext task)
{
Creature* auchenaiDefender = ObjectAccessor::GetCreature(*at, unitGUID);
if (!auchenaiDefender)
return;
if (Unit* caster = at->GetCaster())
auchenaiDefender->SetFacingToObject(caster);
auchenaiDefender->HandleEmoteCommand(EMOTE_ONESHOT_SALUTE);
task.Schedule(4s, [this, unitGUID](TaskContext /*task*/)
{
Creature* auchenaiDefender = ObjectAccessor::GetCreature(*at, unitGUID);
if (!auchenaiDefender)
return;
auchenaiDefender->SetFacingTo(auchenaiDefender->GetHomePosition().GetOrientation());
});
});
}
void OnUpdate(uint32 diff) override
{
_scheduler.Update(diff);
}
private:
TaskScheduler _scheduler;
};
// 157762 - Halo
class spell_auchindoun_halo : public SpellScript
{
bool Validate(SpellInfo const* /*spellInfo*/) override
{
return ValidateSpellInfo({ SPELL_HALO_HEAL });
}
void HandleHit(SpellEffIndex /*effIndex*/) const
{
if (!GetHitUnit()->IsCreature())
return;
GetCaster()->CastSpell(GetHitUnit(), SPELL_HALO_HEAL, true);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_auchindoun_halo::HandleHit, EFFECT_0, SPELL_EFFECT_DUMMY);
}
};
// 178800 - Grimrail Depot
class spell_auchindoun_grimrail_depot_scene_selector : public SpellScript
{
void HandleDummy(SpellEffIndex /*effIndex*/) const
{
GetCaster()->CastSpell(GetHitUnit(), SPELL_GRIMRAIL_DEPOT_SCENE, true);
// GetCaster()->CastSpell(GetHitUnit(), SPELL_INSTANCE_BOOTSTRAPPER, false);
}
void HandleEvent(SpellEffIndex /*effIndex*/) const
{
if (InstanceScript* instance = GetCaster()->GetInstanceScript())
instance->SendEncounterUnit(ENCOUNTER_FRAME_PHASE_SHIFT_CHANGED, nullptr);
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_auchindoun_grimrail_depot_scene_selector::HandleDummy, EFFECT_0, SPELL_EFFECT_SCRIPT_EFFECT);
OnEffectHit += SpellEffectFn(spell_auchindoun_grimrail_depot_scene_selector::HandleEvent, EFFECT_1, SPELL_EFFECT_SEND_EVENT);
}
};
// 178747 - Grimrail Depot
class scene_auchindoun_soulbinder_nyami : public SceneScript
{
public:
scene_auchindoun_soulbinder_nyami() : SceneScript("scene_auchindoun_soulbinder_nyami") { }
static void HandleScene(Player* player)
{
player->ClearUnitState(UNIT_STATE_ROOT);
player->CastSpell(player, SPELL_GRIMRAIL_DEPOT_TELEPORT, true);
player->CastSpell(player, SPELL_GRIMRAIL_DEPOT_REMOVE_AURA, TRIGGERED_FULL_MASK);
PhasingHandler::OnConditionChange(player);
Map* map = player->GetMap();
if (!map->IsSpawnGroupActive(SPAWNGROUP_TUULANI_IMPRISONED))
map->SpawnGroupSpawn(SPAWNGROUP_TUULANI_IMPRISONED);
}
void OnSceneStart(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
{
player->AddUnitState(UNIT_STATE_ROOT);
}
void OnSceneComplete(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
{
HandleScene(player);
}
void OnSceneCancel(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
{
HandleScene(player);
}
};
void AddSC_auchindoun()
{
new at_auchindoun_entrance();
new at_auchindoun_auchenai_defender_intro();
new at_auchindoun_barrier();
new at_auchindoun_soulbinder_nyami_scene();
RegisterAuchindounCreatureAI(npc_auchindoun_auchenai_defender);
RegisterAuchindounCreatureAI(npc_auchindoun_soulbinder_tuulani);
RegisterAreaTriggerAI(at_auchindoun_npc_reaction);
RegisterSpellScript(spell_auchindoun_halo);
RegisterSpellScript(spell_auchindoun_grimrail_depot_scene_selector);
new scene_auchindoun_soulbinder_nyami();
}
|