TrinityCore
Loading...
Searching...
No Matches
boss_keleseth.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/*
19 * Combat timers requires to be revisited
20 */
21
22#include "ScriptMgr.h"
23#include "InstanceScript.h"
24#include "ObjectAccessor.h"
25#include "ScriptedCreature.h"
26#include "SpellAuraEffects.h"
27#include "SpellScript.h"
28#include "TemporarySummon.h"
29#include "utgarde_keep.h"
30
32{
33 // Prince Keleseth
40
41 // Vrykul Skeleton
42 EMOTE_RISES = 0
43};
44
46{
47 // Prince Keleseth
50
51 // Vrykul Skeleton
57
58 // Frost Tomb
60
61 // Scripts
63};
64
79
87
88// 23953 - Prince Keleseth
89struct boss_keleseth : public BossAI
90{
92
93 void Reset() override
94 {
95 _Reset();
96
97 _onTheRocks = true;
98 }
99
100 void JustEngagedWith(Unit* who) override
101 {
103
105
109
111 me->CallForHelp(50.0f);
112 }
113
115 {
116 std::vector<Creature*> skeletons;
118 for (Creature* skeleton : skeletons)
119 skeleton->AI()->DoAction(ACTION_INSTAKILL_SELF);
120 }
121
122 // Do not engage or despawn summons, killed by spells
123 void JustSummoned(Creature* /*summon*/) override { }
124
125 void SetData(uint32 data, uint32 value) override
126 {
127 if (data == DATA_ON_THE_ROCKS)
128 _onTheRocks = value != 0;
129 }
130
131 uint32 GetData(uint32 data) const override
132 {
133 if (data == DATA_ON_THE_ROCKS)
134 return _onTheRocks;
135
136 return 0;
137 }
138
139 void EnterEvadeMode(EvadeReason why) override
140 {
143 }
144
145 void KilledUnit(Unit* /*victim*/) override
146 {
147 Talk(SAY_SLAY);
148 }
149
150 void JustDied(Unit* /*killer*/) override
151 {
152 _JustDied();
155 }
156
157 void UpdateAI(uint32 diff) override
158 {
159 if (!UpdateVictim())
160 return;
161
162 events.Update(diff);
163
165 return;
166
167 while (uint32 eventId = events.ExecuteEvent())
168 {
169 switch (eventId)
170 {
173 events.Repeat(2s, 3s);
174 break;
175 case EVENT_FROST_TOMB:
176 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true, true, -SPELL_FROST_TOMB_CHANNEL))
177 {
178 Talk(SAY_FROST_TOMB, target);
179 Talk(EMOTE_FROST_TOMB, target);
180 DoCast(target, SPELL_FROST_TOMB);
181 }
182 events.Repeat(14s, 19s);
183 break;
187 break;
188 default:
189 break;
190 }
191
193 return;
194 }
195
197 }
198
199private:
201};
202
203// 23970 - Vrykul Skeleton
205{
206 npc_vrykul_skeleton(Creature* creature) : ScriptedAI(creature) { }
207
208 void InitializeAI() override
209 {
210 me->SetCorpseDelay(15, true);
211 }
212
213 void JustAppeared() override
214 {
216 }
217
218 void JustEngagedWith(Unit* /*who*/) override
219 {
221 if (IsHeroic())
223 }
224
225 void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
226 {
227 // Creature is unkillable by default. But allow to kill self with spell
228 if (damage >= me->GetHealth() && attacker != me)
229 {
230 damage = me->GetHealth() - 1;
231
232 // There are some issues with pets
233 // they will still attack. I would say it is a PetAI bug
235 {
239
240 _events.Reset();
242 }
243 }
244 }
245
246 void DoAction(int32 action) override
247 {
248 if (action == ACTION_INSTAKILL_SELF)
249 {
252 me->KillSelf();
253 }
254 }
255
256 void UpdateAI(uint32 diff) override
257 {
258 if (!UpdateVictim())
259 {
260 _events.Update(diff);
261
262 while (uint32 eventId = _events.ExecuteEvent())
263 {
264 switch (eventId)
265 {
266 case EVENT_ATTACK:
268 break;
269 default:
270 break;
271 }
272 }
273 return;
274 }
275
276 _events.Update(diff);
277
279 return;
280
281 while (uint32 eventId = _events.ExecuteEvent())
282 {
283 switch (eventId)
284 {
285 case EVENT_DECREPIFY:
287 _events.Repeat(1s, 5s);
288 break;
289 case EVENT_BONE_ARMOR:
291 if (roll_chance_i(50))
293 _events.Repeat(20s, 30s);
294 break;
302 break;
306 if (IsHeroic())
308 break;
309 default:
310 break;
311 }
312
314 return;
315 }
316
318 }
319
320private:
322};
323
324// 23965 - Frost Tomb
326{
327 npc_frost_tomb(Creature* creature) : ScriptedAI(creature), _isKilled(false), _instance(creature->GetInstanceScript()) { }
328
329 void InitializeAI() override
330 {
332 }
333
334 void JustAppeared() override
335 {
336 if (TempSummon* summon = me->ToTempSummon())
337 if (Unit* summoner = summon->GetSummonerUnit())
339 }
340
341 void DamageTaken(Unit* /*who*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
342 {
343 if (damage >= me->GetHealth())
344 {
345 damage = me->GetHealth() -1;
346
347 if (_isKilled)
348 return;
349
350 _isKilled = true;
351
352 _scheduler.Schedule(0s, [this](TaskContext task)
353 {
354 switch (task.GetRepeatCounter())
355 {
356 case 0:
357 if (Creature* keleseth = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_PRINCE_KELESETH)))
358 keleseth->AI()->SetData(DATA_ON_THE_ROCKS, false);
359 me->InterruptNonMeleeSpells(false);
360 task.Repeat(1s);
361 break;
362 case 1:
363 me->SetUnitFlag(UNIT_FLAG_UNINTERACTIBLE);
364 task.Repeat(1s);
365 break;
366 case 2:
367 me->DespawnOrUnsummon();
368 break;
369 default:
370 break;
371 }
372 });
373 }
374 }
375
376 void UpdateAI(uint32 diff) override
377 {
378 _scheduler.Update(diff);
379 }
380
381private:
385};
386
387// 42672 - Frost Tomb
408
409// 48400 - Frost Tomb
411{
413
414 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
415 {
416 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEATH)
417 if (Unit* caster = GetCaster())
418 if (caster->IsAlive())
419 if (Creature* creature = caster->ToCreature())
420 creature->DespawnOrUnsummon(1s);
421 }
422
427};
428
430{
431 public:
432 achievement_on_the_rocks() : AchievementCriteriaScript("achievement_on_the_rocks") { }
433
434 bool OnCheck(Player* /*source*/, Unit* target) override
435 {
436 // todo: migrate to worldstate 3895 (worldstateexpression 6312)
437 return target && target->GetAI() && target->GetAI()->GetData(DATA_ON_THE_ROCKS);
438 }
439};
440
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
bool roll_chance_i(int chance)
Definition Random.h:59
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
@ EFFECT_1
@ EFFECT_0
@ AURA_REMOVE_BY_DEATH
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELL_AURA_MOD_STUN
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STAND_STATE_DEAD
Definition UnitDefines.h:41
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:34
@ UNIT_FLAG_UNINTERACTIBLE
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
KelesethEvents
@ EVENT_ATTACK
@ EVENT_FROST_TOMB
@ EVENT_DECREPIFY
@ EVENT_RESURRECT_2
@ EVENT_SUMMON_SKELETONS
@ EVENT_BONE_ARMOR
@ EVENT_RESURRECT_1
@ EVENT_SHADOW_BOLT
KelesethTexts
@ SAY_DEATH
@ EMOTE_FROST_TOMB
@ SAY_AGGRO
@ EMOTE_RISES
@ SAY_FROST_TOMB
@ SAY_SLAY
@ SAY_SUMMON_SKELETONS
KelesethMisc
@ DATA_ON_THE_ROCKS
@ SUMMON_GROUP_SKELETONS
@ ACTION_INSTAKILL_SELF
@ NPC_SKELETON
void AddSC_boss_keleseth()
KelesethSpells
@ SPELL_SHADOW_FISSURE
@ SPELL_FROST_TOMB
@ SPELL_FROST_TOMB_CHANNEL
@ SPELL_INSTAKILL_SELF
@ SPELL_SHADOW_BOLT
@ SPELL_DECREPIFY
@ SPELL_BONE_ARMOR
@ SPELL_FROST_TOMB_SUMMON
@ SPELL_FULL_HEAL
uint32 GetTickNumber() const
AuraApplication const * GetTargetApplication() const
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetCaster() const
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
virtual void EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
void CallForHelp(float fRadius)
void SetReactState(ReactStates st)
Definition Creature.h:119
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:89
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
static Creature * ToCreature(Object *o)
Definition Object.h:186
TaskScheduler::repeated_t GetRepeatCounter() const
Returns the repeat counter which increases every time the task is repeated.
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
virtual uint32 GetData(uint32) const
Definition UnitAI.h:155
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:166
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:96
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:106
Definition Unit.h:769
void KillSelf(bool durabilityLoss=true)
Definition Unit.h:1023
bool HasUnitFlag(UnitFlags flags) const
Definition Unit.h:953
TempSummon * ToTempSummon()
Definition Unit.h:1794
UnitAI * GetAI() const
Definition Unit.h:800
uint32 GetHealth() const
Definition Unit.h:913
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
void SetStandState(UnitStandStateType state)
Definition Unit.cpp:10363
void SetUnitFlag(UnitFlags flags)
Definition Unit.h:954
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:955
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:2082
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
bool OnCheck(Player *, Unit *target) override
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
PrepareAuraScript(spell_keleseth_frost_tomb_channel)
void OnPeriodic(AuraEffect const *aurEff)
bool Validate(SpellInfo const *) override
PrepareAuraScript(spell_keleseth_frost_tomb_periodic)
@ DATA_PRINCE_KELESETH
bool IsHeroic() const
void UpdateAI(uint32 diff) override
void JustSummoned(Creature *) override
void KilledUnit(Unit *) override
void SetData(uint32 data, uint32 value) override
void Reset() override
void EnterEvadeMode(EvadeReason why) override
void JustEngagedWith(Unit *who) override
uint32 GetData(uint32 data) const override
void JustDied(Unit *) override
boss_keleseth(Creature *creature)
InstanceScript * _instance
void JustAppeared() override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void UpdateAI(uint32 diff) override
TaskScheduler _scheduler
void InitializeAI() override
npc_frost_tomb(Creature *creature)
void JustEngagedWith(Unit *) override
void DamageTaken(Unit *attacker, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustAppeared() override
void InitializeAI() override
void UpdateAI(uint32 diff) override
void DoAction(int32 action) override
npc_vrykul_skeleton(Creature *creature)
#define RegisterUtgardeKeepCreatureAI(ai_name)