TrinityCore
Loading...
Searching...
No Matches
boss_thekal.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 "zulgurub.h"
19#include "CellImpl.h"
20#include "GridNotifiersImpl.h"
21#include "InstanceScript.h"
22#include "MotionMaster.h"
23#include "ObjectAccessor.h"
24#include "ScriptedCreature.h"
25#include "ScriptMgr.h"
26
34
36{
37 SPELL_RESURRECT = 24173, // ToDo: find out how this should be used
39
40 // High Priest Thekal
41 // Phase 1
44 // Phase 2
48 SPELL_CHARGE = 24193,
50
51 // Zealot Lor'Khan
52 SPELL_SHIELD = 20545,
56
57 // Zealot Zath
60 SPELL_GOUGE = 12540,
61 SPELL_KICK = 15614,
62 SPELL_BLIND = 21060,
63
65};
66
80
82{
84 PHASE_TWO = 2
85};
86
87// Resurrection is handled by the main boss' script, dispatching resurrection as needed
93
94float const DamageIncrease = 40.0f;
95float const DamageDecrease = 100.f / (1.f + DamageIncrease / 100.f) - 100.f;
96
97struct boss_thekal : public BossAI
98{
99 boss_thekal(Creature* creature) : BossAI(creature, DATA_THEKAL)
100 {
101 Initialize();
102 }
103
105 {
106 _enraged = false;
107 _isThekalDead = false;
108 _isLorkhanDead = false;
109 _isZathDead = false;
111 _isChangingPhase = false;
112 }
113
114 void EnterEvadeMode(EvadeReason why) override
115 {
116 if (!_EnterEvadeMode(why))
117 return;
120 Reset();
121 }
122
134
135 void JustDied(Unit* /*killer*/) override
136 {
137 _JustDied();
139
140 // Adds are still feign-deathing, so kill them when the encounter is over
141 if (Creature* creature = instance->GetCreature(DATA_LORKHAN))
142 creature->KillSelf();
143 if (Creature* creature = instance->GetCreature(DATA_ZATH))
144 creature->KillSelf();
147 }
148
156
157 void SetData(uint32 type, uint32 data) override
158 {
159 if (type == DATA_FAKE_DEATH)
160 {
161 // A mob died
162 switch (data)
163 {
165 _isThekalDead = true;
166 break;
168 _isLorkhanDead = true;
169 break;
170 case NPC_ZEALOT_ZATH:
171 _isZathDead = true;
172 break;
173 default:
174 return;
175 }
176
178 {
180 events.Reset();
182 }
183 else
184 {
185 // Start resurrection timer if not already started, otherwise ignore
187 {
190 }
191 }
192 }
193 else if (type == DATA_RESURRECTED)
194 {
195 Creature* creature = nullptr;
196 if (data == NPC_HIGH_PRIEST_THEKAL)
197 creature = me;
198 else if (data == NPC_ZEALOT_LORKHAN)
199 creature = instance->GetCreature(DATA_LORKHAN);
200 else if (data == NPC_ZEALOT_ZATH)
201 creature = instance->GetCreature(DATA_ZATH);
202
203 // Resurrect
204 if (creature)
205 {
207 creature->SetFullHealth();
208 creature->SetImmuneToPC(false, true);
209 creature->SetImmuneToNPC(false, true);
210 }
211 }
212 }
213
214 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
215 {
216 if (damage >= me->GetHealth() && events.IsInPhase(PHASE_ONE))
217 {
220 me->SetImmuneToPC(true, true);
221 me->SetImmuneToNPC(true, true);
223 events.DelayEvents(10s);
225 damage = 0;
226 }
227 else if (events.IsInPhase(PHASE_TWO) && !_enraged && me->HealthBelowPct(10))
228 {
231 _enraged = true;
232 }
233 }
234
235 void UpdateAI(uint32 diff) override
236 {
237 events.Update(diff);
238
240 return;
241
242 while (uint32 eventId = events.ExecuteEvent())
243 {
244 switch (eventId)
245 {
249 break;
250 case EVENT_SILENCE:
253 break;
255 {
256 // If only one or two of the three mobs were killed, resurrect them
258
259 if (_isThekalDead)
260 {
263 _isThekalDead = false;
264 }
265
266 if (_isLorkhanDead)
267 {
268 if (Creature* lorkhan = instance->GetCreature(DATA_LORKHAN))
269 {
270 lorkhan->AI()->DoCastSelf(SPELL_RESURRECT_VISUAL);
271 SetData(DATA_RESURRECTED, lorkhan->GetEntry());
272 }
273 _isLorkhanDead = false;
274 }
275
276 if (_isZathDead)
277 {
279 {
280 zath->AI()->DoCastSelf(SPELL_RESURRECT_VISUAL);
281 SetData(DATA_RESURRECTED, zath->GetEntry());
282 }
283 _isZathDead = false;
284 }
285 break;
286 }
288 _isChangingPhase = true;
291 me->SetFullHealth();
294 break;
298 break;
300 {
301 // Trigger phase change
302 _isChangingPhase = false;
312 break;
313 }
314 case EVENT_FORCEPUNCH:
317 break;
318 case EVENT_CHARGE:
319 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 0.f, true))
320 {
322 AttackStart(target);
323 DoCast(target, SPELL_CHARGE);
324 }
326 break;
330 break;
331 default:
332 break;
333 }
334 }
335
337 return;
338
339 if (!UpdateVictim())
340 return;
341
343 }
344
345private:
352};
353
361
362// Find which one of the three creatures Lor'Khan should heal (self, Thekal or Zath)
364{
365 public:
366 LorKhanSelectTargetToHeal(Unit const* reference, float range) : _reference(reference), _range(range), _hp(0) { }
367
368 bool operator()(Unit* object)
369 {
370 if (object->GetTypeId() != TYPEID_UNIT || !object->IsAlive() || !object->IsInCombat())
371 return false;
372
373 if (object->ToCreature()->GetEntry() != NPC_HIGH_PRIEST_THEKAL && object->GetEntry() != NPC_ZEALOT_LORKHAN && object->GetEntry() != NPC_ZEALOT_ZATH)
374 return false;
375
376 // Don't allow to heal a target that is waiting for resurrection
378 return false;
379
380 if ((object->GetMaxHealth() - object->GetHealth() > _hp) && _reference->IsWithinDistInMap(object, _range))
381 {
382 _hp = object->GetMaxHealth() - object->GetHealth();
383 return true;
384 }
385
386 return false;
387 }
388
389 private:
391 float const _range;
393};
394
395// Zealot Lor'Khan
397{
398 npc_zealot_lorkhan(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
399
406
407 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
408 {
409 if (damage >= me->GetHealth())
410 {
413 me->SetImmuneToPC(true, true);
414 me->SetImmuneToNPC(true, true);
416 me->AttackStop();
418 thekal->AI()->SetData(DATA_FAKE_DEATH, me->GetEntry());
419 _events.DelayEvents(10s);
420 damage = 0;
421 }
422 }
423
431
432 void UpdateAI(uint32 diff) override
433 {
434 _events.Update(diff);
435
437 return;
438
439 if (uint32 eventId = _events.ExecuteEvent())
440 {
441 switch (eventId)
442 {
443 case EVENT_SHIELD:
446 break;
447 case EVENT_BLOODLUST:
450 break;
452 {
453 Unit* target = nullptr;
454 LorKhanSelectTargetToHeal check(me, 100.0f);
456 Cell::VisitAllObjects(me, searcher, 100.0f);
457
458 if (target)
459 DoCast(target, SPELL_GREATERHEAL);
460
462 break;
463 }
464 case EVENT_DISARM:
467 break;
468 default:
469 break;
470 }
471 }
472
473 if (!UpdateVictim())
474 return;
475
477 }
478
479private:
482};
483
492
493// Zealot Zath
495{
496 npc_zealot_zath(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
497
504
505 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
506 {
507 if (damage >= me->GetHealth())
508 {
511 me->SetImmuneToPC(true, true);
512 me->SetImmuneToNPC(true, true);
514 me->AttackStop();
516 thekal->AI()->SetData(DATA_FAKE_DEATH, me->GetEntry());
517 _events.DelayEvents(10s);
518 damage = 0;
519 }
520 }
521
530
531 void UpdateAI(uint32 diff) override
532 {
533 _events.Update(diff);
534
535 if (uint32 eventId = _events.ExecuteEvent())
536 {
537 switch (eventId)
538 {
542 break;
546 break;
547 case EVENT_GOUGE:
549 if (GetThreat(me->GetVictim()))
552 break;
553 case EVENT_KICK:
556 break;
557 case EVENT_BLIND:
560 break;
561 default:
562 break;
563 }
564 }
565
566 if (!UpdateVictim())
567 return;
568
570 }
571
572private:
575};
576
uint32_t uint32
Definition Define.h:133
@ DONE
@ TYPEID_UNIT
Definition ObjectGuid.h:38
Spells
Definition PlayerAI.cpp:32
@ EVENT_CHARGE
@ UNIT_FLAG_IMMUNE_TO_NPC
@ UNIT_FLAG_IMMUNE_TO_PC
@ UNIT_MOD_DAMAGE_MAINHAND
Definition Unit.h:180
@ UNIT_STATE_EVADE
Definition Unit.h:242
@ UNIT_STATE_ROOT
Definition Unit.h:230
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
@ TOTAL_PCT
Definition Unit.h:146
@ TALK_TIGER_PHASE
@ TALK_DEATH
@ TALK_FAKE_DEATH
@ TALK_FRENZY
ZathEvents
@ EVENT_SINISTER_STRIKE
@ EVENT_BLIND
@ EVENT_GOUGE
@ EVENT_SWEEPING_STRIKES
@ EVENT_KICK
void AddSC_boss_thekal()
@ SPELL_RESURRECT_VISUAL
@ SPELL_BLOODLUST
@ SPELL_CHARGE
@ SPELL_SILENCE
@ SPELL_KICK
@ SPELL_BLIND
@ SPELL_TIGER_FORM
@ SPELL_FORCEPUNCH
@ SPELL_GREATERHEAL
@ SPELL_RESURRECT
@ SPELL_MORTALCLEAVE
@ SPELL_FRENZY
@ SPELL_GOUGE
@ SPELL_PERMANENT_FEIGN_DEATH
@ SPELL_SUMMONTIGERS
@ SPELL_SWEEPINGSTRIKES
@ SPELL_SHIELD
@ SPELL_DISARM
@ SPELL_SINISTERSTRIKE
@ PHASE_ONE
@ PHASE_TWO
ThekalEvents
@ EVENT_SUMMONTIGERS
@ EVENT_CHANGE_PHASE_3
@ EVENT_RESURRECT_TIMER
@ EVENT_FORCEPUNCH
@ EVENT_CHANGE_PHASE_2
@ EVENT_SPELL_CHARGE
@ EVENT_CHANGE_PHASE_1
@ EVENT_MORTALCLEAVE
@ EVENT_SILENCE
float const DamageIncrease
float const DamageDecrease
LorkhanEvents
@ EVENT_DISARM
@ EVENT_SHIELD
@ EVENT_BLOODLUST
@ EVENT_GREATER_HEAL
Data
@ DATA_RESURRECTED
@ DATA_FAKE_DEATH
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
EventMap events
bool _EnterEvadeMode(EvadeReason why=EVADE_REASON_OTHER)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetImmuneToPC(bool apply) override
Definition Creature.h:129
void SetImmuneToNPC(bool apply) override
Definition Creature.h:132
void Update(uint32 time)
Definition EventMap.h:67
void DelayEvents(Milliseconds delay)
Definition EventMap.cpp:95
EventId ExecuteEvent()
Definition EventMap.cpp:73
bool IsInPhase(PhaseIndex phase) const
Definition EventMap.h:236
void SetPhase(PhaseIndex phase)
Definition EventMap.cpp:28
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
void Reset()
Definition EventMap.cpp:21
virtual bool SetBossState(uint32 id, EncounterState state)
Creature * GetCreature(uint32 type)
LorKhanSelectTargetToHeal(Unit const *reference, float range)
bool operator()(Unit *object)
void MoveTargetedHome()
static Creature * ToCreature(Object *o)
Definition Object.h:186
TypeID GetTypeId() const
Definition Object.h:93
uint32 GetEntry() const
Definition Object.h:81
void DoMeleeAttackIfReady()
Definition UnitAI.cpp:54
SpellCastResult DoCastSelf(uint32 spellId, CastSpellExtraArgs const &args={})
Definition UnitAI.h:241
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 SetFullHealth()
Definition Unit.h:927
void SetControlled(bool apply, UnitState state)
Definition Unit.cpp:11256
void ApplyStatPctModifier(UnitMods unitMod, UnitModifierPctType modifierType, float amount)
Definition Unit.cpp:9042
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
uint32 GetMaxHealth() const
Definition Unit.h:914
bool IsAlive() const
Definition Unit.h:1234
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
void AddUnitState(uint32 f)
Definition Unit.h:875
bool HealthBelowPct(int32 pct) const
Definition Unit.h:917
uint32 GetHealth() const
Definition Unit.h:913
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3784
Unit * GetVictim() const
Definition Unit.h:859
bool HasUnitState(const uint32 f) const
Definition Unit.h:876
void RemoveAllAuras()
Definition Unit.cpp:4157
bool AttackStop()
Definition Unit.cpp:5645
bool IsInCombat() const
Definition Unit.h:1144
void RemoveUnitFlag(UnitFlags flags)
Definition Unit.h:955
bool IsWithinDistInMap(WorldObject const *obj, float dist2compare, bool is3D=true, bool incOwnRadius=true, bool incTargetRadius=true) const
Definition Object.cpp:1192
static void VisitAllObjects(WorldObject const *obj, T &visitor, float radius, bool dont_load=true)
Definition CellImpl.h:192
void AttackStart(Unit *) override
float GetThreat(Unit const *victim, Unit const *who=nullptr)
void ModifyThreatByPercent(Unit *victim, int32 pct, Unit *who=nullptr)
void ResetThreatList(Unit *who=nullptr)
void EnterEvadeMode(EvadeReason why) override
void JustEngagedWith(Unit *who) override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void Reset() override
void JustDied(Unit *) override
bool _isResurrectTimerActive
boss_thekal(Creature *creature)
bool _isChangingPhase
void Initialize()
void SetData(uint32 type, uint32 data) override
void UpdateAI(uint32 diff) override
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void JustEngagedWith(Unit *) override
npc_zealot_lorkhan(Creature *creature)
void Reset() override
InstanceScript * _instance
void JustEngagedWith(Unit *) override
void UpdateAI(uint32 diff) override
InstanceScript * _instance
npc_zealot_zath(Creature *creature)
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void Reset() override
@ NPC_ZEALOT_ZATH
Definition zulgurub.h:53
@ NPC_HIGH_PRIEST_THEKAL
Definition zulgurub.h:55
@ NPC_ZEALOT_LORKHAN
Definition zulgurub.h:52
#define RegisterZulGurubCreatureAI(ai_name)
Definition zulgurub.h:91
@ DATA_LORKHAN
Definition zulgurub.h:40
@ DATA_THEKAL
Definition zulgurub.h:34
@ DATA_ZATH
Definition zulgurub.h:41