TrinityCore
Loading...
Searching...
No Matches
drustvar_chapter_1_the_final_effigy.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 "CreatureAI.h"
19#include "CreatureAIImpl.h"
20#include "ObjectAccessor.h"
21#include "PhasingHandler.h"
22#include "Player.h"
23#include "ScriptMgr.h"
24#include "ScriptedCreature.h"
25#include "SpellAuras.h"
26#include "SpellScript.h"
27#include "TemporarySummon.h"
28
46
47// EventID: 59332
49{
50public:
51 event_listen_to_helenas_story() : EventScript("event_listen_to_helenas_story") {}
52
53 void OnTrigger(WorldObject* /*object*/, WorldObject* invoker, uint32 /*eventId*/) override
54 {
55 if (Player* player = invoker->ToPlayer())
56 {
57 player->CastSpell(player, SPELL_TAKE_A_SEAT_CURSED);
58
59 if (Creature* helenaObject = player->FindNearestCreatureWithOptions(25.0f, { .CreatureId = NPC_HELENA_GENTLE_HUMAN, .IgnorePhases = true }))
60 helenaObject->SummonPersonalClone(helenaObject->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
61 }
62 }
63};
64
65constexpr Position HelenaPetSummonPos = { 181.513885f, 1987.2222f, 101.9137f, 1.667730f };
66
67// 124953 - Helena Gentle
69{
71
72 void JustAppeared() override
73 {
74 _oocScheduler.Schedule(0ms, [this](TaskContext& context)
75 {
76 if (Creature* hexboundSnarler = me->FindNearestCreatureWithOptions(50.0f, { .CreatureId = NPC_HEXBOUND_SNARLER, .StringId = "HelenaSummon", .IsAlive = FindCreatureAliveState::Alive }))
77 {
78 if (!hexboundSnarler->IsInCombat())
79 _hexboundSnarlerGuid = hexboundSnarler->GetGUID();
80 else
81 context.Repeat(1s);
82 }
83 else
85 });
86 }
87
88 void Reset() override
89 {
90 _halfLifeTriggered = false;
91 _events.Reset();
93 }
94
95 void JustEngagedWith(Unit* who) override
96 {
100
102
104 hexboundSnarler->AI()->AttackStart(who);
105 }
106
107 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
108 {
109 if (!_halfLifeTriggered && me->HealthBelowPctDamaged(50, damage))
110 {
112 _halfLifeTriggered = true;
113 }
114 }
115
116 void EnterEvadeMode(EvadeReason /*why*/) override
117 {
118 me->DespawnOrUnsummon(0ms, 1min);
119
121 hexboundSnarler->DespawnOrUnsummon();
122 }
123
124 void JustDied(Unit* /*killer*/) override
125 {
127 }
128
129 void UpdateAI(uint32 diff) override
130 {
131 if (!UpdateVictim())
132 {
133 _oocScheduler.Update(diff);
134 return;
135 }
136
137 _events.Update(diff);
138
140 return;
141
142 while (uint32 eventId = _events.ExecuteEvent())
143 {
144 switch (eventId)
145 {
149 break;
152 {
153 hexboundSnarler->SetAIAnimKitId(0);
154 hexboundSnarler->PlayOneShotAnimKitId(1099);
156 }
157 break;
160 {
161 hexboundSnarler->SetImmuneToAll(false);
162 hexboundSnarler->SetUninteractible(false);
163 hexboundSnarler->SetReactState(REACT_AGGRESSIVE);
164 }
165 break;
166 default:
167 break;
168 }
169 }
170 }
171
173 {
175 {
176 me->CastSpell(hexboundSnarler, SPELL_HELENA_EMPOWERING);
177
178 _hexboundSnarlerGuid = hexboundSnarler->GetGUID();
179 hexboundSnarler->SetScriptStringId("HelenaSummon");
180 hexboundSnarler->SetAIAnimKitId(730);
181 hexboundSnarler->SetReactState(REACT_PASSIVE);
182 hexboundSnarler->SetImmuneToAll(true);
183 hexboundSnarler->SetUninteractible(true);
184 }
185 }
186
187private:
192};
193
200
201// 254558 - Cancel Deathcurse
222
223// Scene 2131
225{
226public:
227 scene_drustvar_cleanse_fallhaven() : SceneScript("scene_drustvar_cleanse_fallhaven") {}
228
229 void OnSceneComplete(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
230 {
232 CloneCyril(player);
233 }
234
235 void OnSceneCancel(Player* player, uint32 /*sceneInstanceID*/, SceneTemplate const* /*sceneTemplate*/) override
236 {
238 CloneCyril(player);
239 }
240
241 void CloneCyril(Player* player) const
242 {
243 if (Creature* cyrilObject = player->FindNearestCreatureWithOptions(25.0f, { .CreatureId = NPC_CYRIL_WHITE_CURSED, .IgnorePhases = true }))
244 cyrilObject->SummonPersonalClone(cyrilObject->GetPosition(), TEMPSUMMON_MANUAL_DESPAWN, 0s, 0, 0, player);
245 }
246};
247
uint32_t uint32
Definition Define.h:154
@ TEMPSUMMON_MANUAL_DESPAWN
#define RegisterCreatureAI(ai_name)
Definition ScriptMgr.h:1392
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_REMOVE_AURA_2
@ 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)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:276
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
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 Reset()
Definition EventMap.cpp:25
Player * ToPlayer()
Definition Object.h:126
static bool OnConditionChange(WorldObject *object, bool updateVisibility=true)
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
Spell * GetSpell() const
TaskScheduler & CancelAll()
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
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
Creature * FindNearestCreatureWithOptions(float range, FindCreatureOptions const &options) const
Definition Object.cpp:1526
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 OnTrigger(WorldObject *, WorldObject *invoker, uint32) override
event_listen_to_helenas_story()
void OnSceneComplete(Player *player, uint32, SceneTemplate const *) override
void OnSceneCancel(Player *player, uint32, SceneTemplate const *) override
void AddSC_drustvar_chapter_1_the_final_effigy()
constexpr Position HelenaPetSummonPos
TC_GAME_API Creature * GetCreature(WorldObject const &u, ObjectGuid const &guid)
TriggerCastFlags TriggerFlags
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override