TrinityCore
Loading...
Searching...
No Matches
kings_rest.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 "Conversation.h"
21#include "ConversationAI.h"
22#include "GameObject.h"
23#include "GameObjectAI.h"
24#include "InstanceScript.h"
25#include "Map.h"
26#include "ScriptMgr.h"
27#include "ScriptedCreature.h"
28#include "SpellAuras.h"
29#include "SpellScript.h"
30#include "TemporarySummon.h"
31#include "Unit.h"
32#include "kings_rest.h"
33
70
71constexpr Position ShadowOfZulIntroSpawnPosition = { -944.9617f, 2646.5268f, 832.8684f, 4.716575f };
72
73// 67 - KingsRest - Trigger Intro Event with Shadow of Zul
75{
77
78 void OnUnitEnter(Unit* unit) override
79 {
80 if (!unit->IsPlayer())
81 return;
82
84 at->Remove();
85 }
86};
87
88// 7690 - Shadow of Zul - KingsRest Intro
90{
91public:
93
100
106
107 void OnCreate(Unit* /*creator*/) override
108 {
110 if (!shadowOfZul)
111 return;
112
115 }
116
121
122 void OnUpdate(uint32 diff) override
123 {
124 _events.Update(diff);
125
126 switch (_events.ExecuteEvent())
127 {
129 {
130 Creature* shadowOfZul = conversation->GetActorCreature(0);
131 if (!shadowOfZul)
132 break;
133
136
138 {
139 if (GameObject* gate = instance->GetGameObject(DATA_KINGS_REST_INTRO_DOOR))
140 {
141 gate->SetGoState(GO_STATE_ACTIVE);
142 gate->SetSpellVisualId(SPELL_VISUAL_ZUL_OPEN_GOB);
143 }
144 }
145 break;
146 }
148 {
149 Creature* shadowOfZul = conversation->GetActorCreature(0);
150 if (!shadowOfZul)
151 break;
152
154 shadowOfZul->DespawnOrUnsummon(1s);
155 break;
156 }
157 default:
158 break;
159 }
160 }
161
162private:
164};
165
170
171// 133935 - Animated Guardian
173{
175
181
182 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
183 {
184 if (!_releasedInhibitors && me->HealthBelowPctDamaged(50, damage))
185 {
186 _releasedInhibitors = true;
187 _events.DelayEvents(1200ms);
189 }
190 }
191
192 void Reset() override
193 {
194 _events.Reset();
196 _releasedInhibitors = false;
197 }
198
199 void UpdateAI(uint32 diff) override
200 {
201 if (!UpdateVictim())
202 return;
203
204 _events.Update(diff);
205
207 return;
208
209 while (uint32 eventId = _events.ExecuteEvent())
210 {
211 switch (eventId)
212 {
217 break;
218 default:
219 break;
220 }
221 }
222 }
223
224private:
228};
229
230// 270002 - Suppression Slam
232{
233 bool Validate(SpellInfo const* /*spellInfo*/) override
234 {
236 }
237
238 void HandleHit(SpellEffIndex /*effIndex*/)
239 {
240 // @TODO: visual is a bit off - requires SPELL_ATTR12_UNK11 impl
242 }
243
248};
249
250// 269935 - Bound by Shadow
266
267// 276031 - Pit of Despair
280
281constexpr Position ShadowOfZulSerpentBossEventSpawnPosition = { -1066.0365f, 2643.302f, 819.37024f, 5.028946f };
282
283// 288466 - Serpentine Seal
285{
287
288 bool OnGossipHello(Player* /*player*/) override
289 {
291 _scheduler.Schedule(3s, [this](TaskContext const&)
292 {
294 zul->SetScriptStringId("SerpentBossEvent");
295 });
296 return true;
297 }
298
299 void UpdateAI(uint32 diff) override
300 {
301 _scheduler.Update(diff);
302 }
303
304private:
306};
307
308// 137020 - Shadow of Zul
310{
312
313 void JustAppeared() override
314 {
315 if (me->HasStringId("SerpentBossEvent"))
317 }
318
320 {
321 Seconds delay = 1s;
322
323 _scheduler.Schedule(delay, [this](TaskContext const&)
324 {
326 me->CastSpell(nullptr, SPELL_ZUL_TRASH_EVENT_STATE, false);
328 if (InstanceScript* instance = me->GetInstanceScript())
329 {
330 if (GameObject* pool = instance->GetGameObject(DATA_KINGS_REST_LIQUID_POOL))
331 pool->SetGoState(GO_STATE_ACTIVE);
332 }
333 });
334
335 delay += 9s;
336
337 _scheduler.Schedule(delay, [this](TaskContext const&)
338 {
339 std::vector<WorldObject*> spawnedCreatures;
340 me->GetMap()->SpawnGroupSpawn(SPAWN_GROUP_PRE_FIRST_BOSS, false, false, &spawnedCreatures);
341 for (WorldObject* obj : spawnedCreatures)
342 {
343 Creature* creature = obj->ToCreature();
344 if (!creature)
345 continue;
346
348 }
349 });
350
351 delay += 5s;
352
353 _scheduler.Schedule(delay, [this](TaskContext const&)
354 {
356 });
357
358 delay += 1s;
359
360 _scheduler.Schedule(delay, [this](TaskContext const&)
361 {
364 });
365 }
366
367 void UpdateAI(uint32 diff) override
368 {
369 _scheduler.Update(diff);
370 }
371
372private:
374};
375
377{
379
380 void JustAppeared() override
381 {
383 }
384};
385
390
391// 134157 - Shadow-Borne Warrior
393{
395
396 void JustEngagedWith(Unit* /*who*/) override
397 {
399 }
400
401 void Reset() override
402 {
403 _events.Reset();
404 }
405
406 void UpdateAI(uint32 diff) override
407 {
408 if (!UpdateVictim())
409 return;
410
411 _events.Update(diff);
412
414 return;
415
416 while (uint32 eventId = _events.ExecuteEvent())
417 {
418 switch (eventId)
419 {
420 case EVENT_GUST_SLASH:
423 break;
424 default:
425 break;
426 }
427 }
428 }
429
430private:
432};
433
439
440// 134174 - Shadow-Borne Witch Doctor
442{
444
450
451 void Reset() override
452 {
453 _events.Reset();
454 }
455
456 void UpdateAI(uint32 diff) override
457 {
458 if (!UpdateVictim())
459 return;
460
461 _events.Update(diff);
462
464 return;
465
466 while (uint32 eventId = _events.ExecuteEvent())
467 {
468 switch (eventId)
469 {
473 break;
477 break;
478 default:
479 break;
480 }
481
483 return;
484 }
485 }
486
487private:
489};
490
496
497// 134158 - Shadow-Borne Champion
499{
501
507
508 void Reset() override
509 {
510 _events.Reset();
511 }
512
513 void UpdateAI(uint32 diff) override
514 {
515 if (!UpdateVictim())
516 return;
517
518 _events.Update(diff);
519
521 return;
522
523 while (uint32 eventId = _events.ExecuteEvent())
524 {
525 switch (eventId)
526 {
530 break;
534 break;
535 default:
536 break;
537 }
538
540 return;
541 }
542 }
543
544private:
546};
547
548// 133943 - Minion of Zul
550{
552
553 void JustAppeared() override
554 {
555 if (me->HasStringId("TempleEvent"))
557
559 }
560
561 void JustEngagedWith(Unit* /*who*/) override
562 {
564 }
565};
566
567// 17933 - Gust Slash - Areatrigger
569{
570 at_kings_rest_gust_slash(AreaTrigger* areatrigger) : AreaTriggerAI(areatrigger) { }
571
572 void OnUnitEnter(Unit* unit) override
573 {
574 if (!unit->IsPlayer())
575 return;
576
577 unit->CastSpell(nullptr, SPELL_GUST_SLASH_DAMAGE, true);
578 }
579};
580
#define DEFAULT_LOCALE
Definition Common.h:69
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
std::chrono::seconds Seconds
Seconds shorthand typedef.
Definition Duration.h:28
@ TEMPSUMMON_MANUAL_DESPAWN
#define RegisterGameObjectAI(ai_name)
Definition ScriptMgr.h:1410
#define RegisterAreaTriggerAI(ai_name)
Definition ScriptMgr.h:1428
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
#define RegisterConversationAI(ai_name)
Definition ScriptMgr.h:1437
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_SCRIPT_EFFECT
@ GO_STATE_ACTIVE
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_ENEMY_SPELL
@ SPELL_AURA_MOD_FEAR
@ SPELL_AURA_SCHOOL_ABSORB
#define SpellEffectFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
AreaTrigger *const at
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectApplyHandler > AfterEffectApply
Unit * GetCaster() const
Unit * GetTarget() const
ObjectGuid const & GetGUID() const
Definition BaseEntity.h:163
bool IsPlayer() const
Definition BaseEntity.h:173
Conversation *const conversation
Milliseconds GetLineEndTime(LocaleConstant locale, int32 lineId) const
void AddActor(int32 actorId, uint32 actorIdx, ObjectGuid const &actorGuid)
static Conversation * CreateConversation(uint32 conversationEntry, Unit *creator, Position const &pos, ObjectGuid privateObjectOwner, SpellInfo const *spellInfo=nullptr, bool autoStart=true)
Creature * GetActorCreature(uint32 actorIdx) const
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
bool HasStringId(std::string_view id) const
void SetDisplayId(uint32 displayId, bool setNative=false) override
uint32 ExecuteEvent()
Definition EventMap.cpp:77
void Update(uint32 time)
Definition EventMap.h:61
void DelayEvents(Milliseconds delay)
Definition EventMap.cpp:100
void ScheduleEvent(uint32 eventId, Milliseconds time, uint32 group=0, uint8 phase=0)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
GameObject *const me
void UseDoorOrButton(uint32 time_to_restore=0, bool alternative=false, Unit *user=nullptr)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2350
Creature * ToCreature()
Definition Object.h:121
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:180
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:89
Definition Unit.h:635
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:793
bool HasUnitState(const uint32 f) const
Definition Unit.h:743
void KillSelf(bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition Unit.h:936
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3974
Map * GetMap() const
Definition Object.h:411
InstanceScript * GetInstanceScript() const
Definition Object.cpp:396
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
void OnCreate(Unit *) override
conversation_kings_rest_intro(Conversation *conversation)
void OnUpdate(uint32 diff) override
void OnRemove(AuraEffect const *, AuraEffectHandleModes)
void OnApply(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *) override
constexpr Position ShadowOfZulIntroSpawnPosition
ShadowBorneWarriorEvent
@ EVENT_GUST_SLASH
AnimatedGuardianEvent
@ EVENT_SUPPRESSION_SLAM
KingsRestData
@ SPELL_SHADOW_BOLT_VOLLEY
@ SAY_ZUL_PRE_BOSS_EVENT_SPAWN
@ SPELL_SUPPRESSION_SLAM_DAMAGE
@ SPELL_ANCESTRAL_FURY
@ SPELL_GUST_SLASH
@ SPELL_SUPPRESSION_SLAM_SELECTOR
@ SPELL_ZUL_SUMMON_VISUAL_CHANNEL
@ NPC_SHADOW_OF_ZUL
@ SPELL_BOUND_BY_SHADOW
@ SPELL_RELEASED_INHIBITORS
@ CONV_ZUL_KINGS_REST_INTRO
@ DISPLAY_INVISIBLE_ZUL
@ SPELL_ZUL_SUMMON_VISUAL
@ SPELL_ZUL_TRASH_EVENT_STATE
@ SAY_ANIMATED_GUARDIAN_ENGAGE
@ SPELL_ZUL_SHADOWFORM
@ SPELL_VISUAL_ZUL_OPEN_GOB
@ SPELL_ZUL_DESPAWN_COSMETIC_TRASH
@ SPELL_DEATHLY_CHILL
@ SPELL_GUST_SLASH_DAMAGE
@ SPELL_MINION_OF_ZUL_FIXATE
@ SPELL_VIGILANT_DEFENSE
ShadowBorneWitchDoctorEvent
@ EVENT_SHADOW_BOLT_VOLLEY
@ EVENT_DEATHLY_CHILL
ShadowBorneChampionEvent
@ EVENT_VIGILANT_DEFENSE
@ EVENT_ANCESTRAL_FURY
constexpr Position ShadowOfZulSerpentBossEventSpawnPosition
void AddSC_kings_rest()
@ SPAWN_GROUP_PRE_FIRST_BOSS
Definition kings_rest.h:66
#define RegisterKingsRestCreatureAI(ai_name)
Definition kings_rest.h:76
@ DATA_KINGS_REST_INTRO_DOOR
Definition kings_rest.h:42
@ DATA_KINGS_REST_LIQUID_POOL
Definition kings_rest.h:43
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
at_kings_rest_gust_slash(AreaTrigger *areatrigger)
void OnUnitEnter(Unit *unit) override
at_kings_rest_trigger_intro_event_with_zul(AreaTrigger *areatrigger)
void OnUnitEnter(Unit *unit) override
void UpdateAI(uint32 diff) override
go_kings_rest_serpentine_seal(GameObject *go)
bool OnGossipHello(Player *) override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustEngagedWith(Unit *) override
npc_kings_rest_animated_guardian(Creature *creature)
void JustEngagedWith(Unit *) override
npc_kings_rest_minion_of_zul(Creature *creature)
npc_kings_rest_shadow_borne_champion(Creature *creature)
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
npc_kings_rest_shadow_borne_warrior(Creature *creature)
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
npc_kings_rest_shadow_borne_witch_doctor(Creature *creature)
npc_kings_rest_shadow_of_zul(Creature *creature)
void UpdateAI(uint32 diff) override
npc_kings_rest_temple_basic(Creature *creature)