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 }
196
197private:
199};
200
201// 23970 - Vrykul Skeleton
203{
204 npc_vrykul_skeleton(Creature* creature) : ScriptedAI(creature) { }
205
206 void InitializeAI() override
207 {
208 me->SetCorpseDelay(15, true);
209 }
210
211 void JustAppeared() override
212 {
214 }
215
216 void JustEngagedWith(Unit* /*who*/) override
217 {
219 if (IsHeroic())
221 }
222
223 void DamageTaken(Unit* attacker, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
224 {
225 // Creature is unkillable by default. But allow to kill self with spell
226 if (damage >= me->GetHealth() && attacker != me)
227 {
228 damage = me->GetHealth() - 1;
229
230 // There are some issues with pets
231 // they will still attack. I would say it is a PetAI bug
232 if (!me->IsUninteractible())
233 {
235 me->SetUninteractible(true);
236 me->SetCanMelee(false);
238
239 _events.Reset();
241 }
242 }
243 }
244
245 void DoAction(int32 action) override
246 {
247 if (action == ACTION_INSTAKILL_SELF)
248 {
251 me->KillSelf();
252 }
253 }
254
255 void UpdateAI(uint32 diff) override
256 {
257 if (!UpdateVictim())
258 {
259 _events.Update(diff);
260
261 while (uint32 eventId = _events.ExecuteEvent())
262 {
263 switch (eventId)
264 {
265 case EVENT_ATTACK:
267 break;
268 default:
269 break;
270 }
271 }
272 return;
273 }
274
275 _events.Update(diff);
276
278 return;
279
280 while (uint32 eventId = _events.ExecuteEvent())
281 {
282 switch (eventId)
283 {
284 case EVENT_DECREPIFY:
286 _events.Repeat(1s, 5s);
287 break;
288 case EVENT_BONE_ARMOR:
290 if (roll_chance(50))
292 _events.Repeat(20s, 30s);
293 break;
297 me->SetUninteractible(false);
298 me->SetCanMelee(true);
302 break;
306 if (IsHeroic())
308 break;
309 default:
310 break;
311 }
312
314 return;
315 }
316 }
317
318private:
320};
321
322// 23965 - Frost Tomb
324{
325 npc_frost_tomb(Creature* creature) : ScriptedAI(creature), _isKilled(false), _instance(creature->GetInstanceScript()) { }
326
327 void InitializeAI() override
328 {
330 }
331
332 void JustAppeared() override
333 {
334 if (TempSummon* summon = me->ToTempSummon())
335 if (Unit* summoner = summon->GetSummonerUnit())
337 }
338
339 void DamageTaken(Unit* /*who*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
340 {
341 if (damage >= me->GetHealth())
342 {
343 damage = me->GetHealth() -1;
344
345 if (_isKilled)
346 return;
347
348 _isKilled = true;
349
350 _scheduler.Schedule(0s, [this](TaskContext& task)
351 {
352 switch (task.GetRepeatCounter())
353 {
354 case 0:
355 if (Creature* keleseth = ObjectAccessor::GetCreature(*me, _instance->GetGuidData(DATA_PRINCE_KELESETH)))
356 keleseth->AI()->SetData(DATA_ON_THE_ROCKS, false);
357 me->InterruptNonMeleeSpells(false);
358 task.Repeat(1s);
359 break;
360 case 1:
361 me->SetUninteractible(true);
362 task.Repeat(1s);
363 break;
364 case 2:
365 me->DespawnOrUnsummon();
366 break;
367 default:
368 break;
369 }
370 });
371 }
372 }
373
374 void UpdateAI(uint32 diff) override
375 {
376 _scheduler.Update(diff);
377 }
378
379private:
383};
384
385// 42672 - Frost Tomb
387{
388 bool Validate(SpellInfo const* /*spellInfo*/) override
389 {
391 }
392
393 void OnPeriodic(AuraEffect const* aurEff)
394 {
395 if (aurEff->GetTickNumber() == 1)
397 }
398
403};
404
405// 48400 - Frost Tomb
407{
408 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
409 {
410 if (GetTargetApplication()->GetRemoveMode() != AURA_REMOVE_BY_DEATH)
411 if (Unit* caster = GetCaster())
412 if (caster->IsAlive())
413 if (Creature* creature = caster->ToCreature())
414 creature->DespawnOrUnsummon(1s);
415 }
416
421};
422
424{
425 public:
426 achievement_on_the_rocks() : AchievementCriteriaScript("achievement_on_the_rocks") { }
427
428 bool OnCheck(Player* /*source*/, Unit* target) override
429 {
430 // todo: migrate to worldstate 3895 (worldstateexpression 6312)
431 return target && target->GetAI() && target->GetAI()->GetData(DATA_ON_THE_ROCKS);
432 }
433};
434
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
bool roll_chance(float chance, PseudoRandomDistributionState &state)
Definition Random.cpp:131
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
@ EFFECT_1
@ EFFECT_0
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ AURA_REMOVE_BY_DEATH
@ SPELL_AURA_PERIODIC_DUMMY
@ SPELL_AURA_MOD_STUN
#define AuraEffectPeriodicFn(F, I, N)
#define AuraEffectRemoveFn(F, I, N, M)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STAND_STATE_DEAD
Definition UnitDefines.h:49
@ UNIT_STAND_STATE_STAND
Definition UnitDefines.h:42
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
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()
Definition CreatureAI.h:169
virtual void EnterEvadeMode(EvadeReason why=EvadeReason::Other)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetCanMelee(bool canMelee, bool fleeFromMelee=false)
void CallForHelp(float fRadius)
void SetReactState(ReactStates st)
Definition Creature.h:180
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:118
void Update(uint32 time)
Definition EventMap.h:77
void Repeat(Milliseconds time)
Definition EventMap.cpp:67
EventId ExecuteEvent()
Definition EventMap.cpp:77
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
void Reset()
Definition EventMap.cpp:25
Creature * ToCreature()
Definition Object.h:121
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
TaskScheduler::repeated_t GetRepeatCounter() const
Returns the repeat counter which increases every time the task is repeated.
TaskScheduler & Schedule(duration_t time, task_handler_t task)
TaskScheduler & Update()
Update the scheduler to the current time.
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:160
SpellCastResult DoCastVictim(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.cpp:172
Unit * SelectTarget(SelectTargetMethod targetType, uint32 offset=0, float dist=0.0f, bool playerOnly=false, bool withTank=true, int32 aura=0)
Definition UnitAI.cpp:71
virtual uint32 GetData(uint32 id) const
Definition UnitAI.h:74
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
void SetStandState(UnitStandStateType state, uint32 animKitID=0)
Definition Unit.cpp:10804
TempSummon * ToTempSummon()
Definition Unit.h:1844
UnitAI * GetAI() const
Definition Unit.h:680
void SetUninteractible(bool apply)
Definition Unit.cpp:8583
uint64 GetHealth() const
Definition Unit.h:800
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
bool IsUninteractible() const
Definition Unit.h:1067
void KillSelf(bool durabilityLoss=true, bool skipSettingDeathState=false)
Definition Unit.h:951
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
void SummonCreatureGroup(uint8 group, std::list< TempSummon * > *list=nullptr)
Definition Object.cpp:1512
bool OnCheck(Player *, Unit *target) override
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
void OnPeriodic(AuraEffect const *aurEff)
bool Validate(SpellInfo const *) override
@ 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)