TrinityCore
Loading...
Searching...
No Matches
boss_zuljin.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 * Timers requires to be revisited
20 * SAY_INTRO is NYI, Zul'jin should say it when player opens Malacrass' door
21 * Berserk requires additional research. Is it really used?
22 * SPELL_ENERGY_STORM doesn't get removed on phase end
23 * Damage of spell 43150 doesn't increase
24 * SPELL_OVERPOWER should be used after the target dodges (?)
25 */
26
27#include "ScriptMgr.h"
28#include "InstanceScript.h"
29#include "MotionMaster.h"
30#include "ObjectAccessor.h"
31#include "ScriptedCreature.h"
32#include "SpellAuraEffects.h"
33#include "SpellInfo.h"
34#include "SpellScript.h"
35#include "zulaman.h"
36
57
59{
60 // Troll Form
63
64 // Bear Form
67
68 // Eagle Form
71
72 // Lynx Form
75
76 // Dragonhawk Form
80
81 // All forms
83
84 // Spirits
89
90 // Transforms
95
96 // Feather Vortex
101
102 // Scripts
106
107 // Misc
111
144
152
161
169
175
176static Position const CenterPos = { 120.172f, 706.444f, 45.111374f, 0.0f };
177
185
193
201
202// 23863 - Zul'jin
203struct boss_zuljin : public BossAI
204{
207
208 void Reset() override
209 {
210 _Reset();
212 _healthCheck = 80;
213 _rushCounter = urand(4, 10);
215 _isInTransition = false;
216 }
217
218 void JustEngagedWith(Unit* who) override
219 {
221
223
225 }
226
227 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
228 {
229 // Let creature finish current transition
230 if (_isInTransition)
231 return;
232
234 {
235 _isInTransition = true;
237 }
238 }
239
240 void MovementInform(uint32 type, uint32 pointId) override
241 {
242 if (type == POINT_MOTION_TYPE && pointId == POINT_CENTER)
244 }
245
246 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
247 {
248 switch (spellInfo->Id)
249 {
255 break;
256 default:
257 break;
258 }
259 }
260
261 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
262 {
263 switch (spellInfo->Id)
264 {
268 {
270 }
271 else
272 {
273 _rushCounter = urand(4, 10);
275 }
276 break;
277 case SPELL_CLAW_RAGE:
278 if (target->IsPlayer())
279 {
280 _clawRageVictimGUID = target->GetGUID();
281 me->GetThreatManager().AddThreat(target->ToUnit(), 50000000.0f, nullptr, true, true);
282 }
283 break;
284 }
285 }
286
287 void DoAction(int32 action) override
288 {
289 if (action == ACTION_CLEAR_FIXATE)
291 me->GetThreatManager().AddThreat(target, -50000000.0f, nullptr, true, true);
292 }
293
324
325 void OnSpellCast(SpellInfo const* spell) override
326 {
327 switch (spell->Id)
328 {
331 break;
332 case SPELL_BERSERK:
334 break;
335 default:
336 break;
337 }
338 }
339
340 void EnterEvadeMode(EvadeReason /*why*/) override
341 {
342 for (uint32 spiritId : SpiritData)
343 if (Creature* spirit = instance->GetCreature(spiritId))
344 spirit->AI()->DoAction(ACTION_CANCEL_SPIRIT_DRAINED);
345
348 }
349
350 void KilledUnit(Unit* /*victim*/) override
351 {
352 Talk(SAY_SLAY);
353 }
354
355 void JustDied(Unit* /*killer*/) override
356 {
357 // Last spirit, needs to be handled here
358 if (Creature* spirit = instance->GetCreature(ZuljinPhases[_phase - 1].spiritId))
359 spirit->AI()->DoAction(ACTION_INTERRUPT_SPIRIT_DRAIN);
360
361 _JustDied();
362
365 }
366
367 void UpdateAI(uint32 diff) override
368 {
369 if (!UpdateVictim())
370 return;
371
372 events.Update(diff);
373
375 return;
376
377 while (uint32 eventId = events.ExecuteEvent())
378 {
379 switch (eventId)
380 {
381 // Troll Form
382 case EVENT_WHIRLWIND:
384 events.Repeat(10s, 20s);
385 break;
387 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 80.0f, true))
389 events.Repeat(10s, 20s);
390 break;
391
392 // Bear Form
395 events.Repeat(20s);
396 break;
397 case EVENT_OVERPOWER:
398 // Cast as triggered, otherwise it will not work
400 events.Repeat(10s, 15s);
401 break;
402
403 // Eagle Form
406 break;
409 break;
410
411 // Lynx Form
412 case EVENT_CLAW_RAGE:
413 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 80.0f, true))
414 DoCast(target, SPELL_CLAW_RAGE);
415 events.Repeat(15s, 20s);
416 break;
417 case EVENT_LYNX_RUSH:
418 // For unknown reason Lynx Rush sequence works only if init spell was casted as triggered, but make sure we don't use it if Claw Rage is active
421 events.Repeat(20s, 25s);
422 break;
423
424 // Dragonhawk Form
427 events.Repeat(10s, 15s);
428 break;
431 events.Repeat(5s, 10s);
432 break;
434 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 80.0f, true))
436 events.Repeat(10s, 15s);
437 break;
438
439 // All forms
440 case EVENT_BERSERK:
442 break;
443
444 // Transition
446 {
447 if (_phase == PHASE_EAGLE)
448 {
451 }
452
453 _healthCheck -= 20;
454 Talk(ZuljinPhases[_phase].sayId);
455 me->RemoveAurasDueToSpell(ZuljinPhases[_phase - 1].spiritSpellId);
458
460 break;
461 }
463 {
464 if (Creature* spirit = instance->GetCreature(ZuljinPhases[_phase - 1].spiritId))
465 spirit->AI()->DoAction(ACTION_INTERRUPT_SPIRIT_DRAIN);
466
467 if (Creature* spirit = instance->GetCreature(ZuljinPhases[_phase].spiritId))
468 {
469 me->SetFacingToObject(spirit);
470 Talk(ZuljinPhases[_phase].emoteId);
471 spirit->AI()->DoAction(ACTION_CAST_SPIRIT_DRAIN);
472 }
474 break;
475 }
477 DoCastSelf(ZuljinPhases[_phase].spiritSpellId);
478 break;
480 {
481 ++_phase;
482
484
487
488 if (_phase != PHASE_EAGLE)
490
491 _isInTransition = false;
492 break;
493 }
494 default:
495 break;
496 }
497
499 return;
500 }
501
503 }
504
505private:
512};
513
514// 24136 - Feather Vortex
516{
517 npc_zuljin_vortex(Creature* creature) : ScriptedAI(creature) { }
518
519 void JustAppeared() override
520 {
522 // DoCastSelf(SPELL_DREAM_FOG);
523
525 .Schedule(2s, [this](TaskContext /*task*/)
526 {
530 })
531 .Schedule(3s, [this](TaskContext /*task*/)
532 {
535 });
536 }
537
539 {
540 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 100.0f, true))
541 {
543 AddThreat(target, 1000000.0f);
544 AttackStart(target);
545 }
546 }
547
548 void SpellHitTarget(WorldObject* target, SpellInfo const* spellInfo) override
549 {
550 if (spellInfo->Id == SPELL_CYCLONE_EFFECT && target == me->GetVictim())
552 }
553
554 void UpdateAI(uint32 diff) override
555 {
556 UpdateVictim();
557
558 _scheduler.Update(diff);
559 }
560
561private:
563};
564
565// 23877 - Amani Lynx Spirit
566// 23878 - Amani Bear Spirit
567// 23879 - Amani Dragonhawk Spirit
568// 23880 - Amani Eagle Spirit
570{
571 npc_zuljin_spirit(Creature* creature) : ScriptedAI(creature) { }
572
573 void DoAction(int32 action) override
574 {
575 switch (action)
576 {
579 break;
583 break;
586 break;
587 }
588 }
589
590 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
591 {
592 if (spellInfo->Id == SPELL_INCINERATE_BLUE)
593 {
595
596 _scheduler.Schedule(13s, [this](TaskContext /*task*/)
597 {
600
601 _scheduler.Schedule(5s, [this](TaskContext /*task*/)
602 {
604 });
605 });
606 }
607 }
608
609 void UpdateAI(uint32 diff) override
610 {
611 _scheduler.Update(diff);
612 }
613
614private:
616};
617
618// 42577 - Zap
620{
622
623 bool Validate(SpellInfo const* /*spellInfo*/) override
624 {
626 }
627
628 void HandleScript(SpellEffIndex /*effIndex*/)
629 {
631 }
632
637};
638
639// 42583 - Claw Rage
641{
643
644 bool Validate(SpellInfo const* /*spellInfo*/) override
645 {
647 }
648
653
658};
659
660// 43149 - Claw Rage
662{
664
665 bool Validate(SpellInfo const* spellInfo) override
666 {
667 return ValidateSpellInfo({ spellInfo->GetEffect(EFFECT_0).TriggerSpell });
668 }
669
670 void OnPeriodic(AuraEffect const* aurEff)
671 {
673
674 Unit* target = GetTarget();
675 Unit* victim = target->GetVictim();
676 if (victim)
677 {
678 uint32 triggerSpell = aurEff->GetSpellEffectInfo().TriggerSpell;
679 target->CastSpell(victim, triggerSpell, true);
680 }
681 }
682
683 void AfterRemove(AuraEffect const* /*aurEff*/, AuraEffectHandleModes /*mode*/)
684 {
685 if (Creature* target = GetTarget()->ToCreature())
686 target->AI()->DoAction(ACTION_CLEAR_FIXATE);
687 }
688
694};
695
696// 43152 - Lynx Rush
698{
700
701 bool Validate(SpellInfo const* /*spellInfo*/) override
702 {
704 }
705
706 void HandleDummy(SpellEffIndex /*effIndex*/)
707 {
708 if (Creature* caster = GetCaster()->ToCreature())
709 if (Unit* target = caster->AI()->SelectTarget(SelectTargetMethod::Random, 0, 80.0f, true))
710 caster->CastSpell(target, SPELL_LYNX_RUSH_DAMAGE, true);
711 }
712
717};
718
@ EQUIP_UNEQUIP
Definition CreatureAI.h:76
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ POINT_MOTION_TYPE
uint32 urand(uint32 min, uint32 max)
Definition Random.cpp:42
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
SpellEffIndex
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
AuraEffectHandleModes
@ AURA_EFFECT_HANDLE_REAL
@ SPELL_AURA_PERIODIC_TRIGGER_SPELL
#define SpellEffectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
#define SpellCastFn(F)
#define AuraEffectRemoveFn(F, I, N, M)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:235
DamageEffectType
Definition Unit.h:352
ZuljinPhases
@ PHASE_EAGLE
@ PHASE_TROLL
@ PHASE_DRAGONHAWK
@ PHASE_LYNX
@ PHASE_BEAR
ZuljinSpells
@ SPELL_SPIRIT_DRAIN
@ SPELL_CYCLONE_VISUAL
@ SPELL_SHAPE_OF_THE_EAGLE
@ SPELL_GRIEVOUS_THROW
@ SPELL_SHAPE_OF_THE_LYNX
@ SPELL_CREEPING_PARALYSIS
@ SPELL_CLAW_RAGE
@ SPELL_INCINERATE_BLUE
@ SPELL_SPIRIT_REALM
@ SPELL_FLAME_BREATH
@ SPELL_LYNX_RUSH
@ SPELL_ENERGY_STORM
@ SPELL_SHAPE_OF_THE_BEAR
@ SPELL_SPIRIT_FADE
@ SPELL_FLAME_WHIRL
@ SPELL_SPIRIT_DRAINED
@ SPELL_OVERPOWER
@ SPELL_CYCLONE
@ SPELL_CYCLONE_EFFECT
@ SPELL_LYNX_RUSH_DAMAGE
@ SPELL_BALL_OF_ENERGY
@ SPELL_SHAPE_OF_THE_DRAGONHAWK
@ SPELL_BERSERK
@ SPELL_DREAM_FOG
@ SPELL_WHIRLWIND
@ SPELL_ZAP_DAMAGE
@ SPELL_PILLAR_OF_FIRE
@ SPELL_SUMMON_CYCLONE
@ SPELL_CLAW_RAGE_PERIODIC
ZuljinEvents
@ EVENT_CREEPING_PARALYSIS
@ EVENT_TRANSITION_4
@ EVENT_FLAME_BREATH
@ EVENT_OVERPOWER
@ EVENT_WHIRLWIND
@ EVENT_PILLAR_OF_FIRE
@ EVENT_CLAW_RAGE
@ EVENT_TRANSITION_1
@ EVENT_ENERGY_STORM
@ EVENT_BERSERK
@ EVENT_GRIEVOUS_THROW
@ EVENT_LYNX_RUSH
@ EVENT_TRANSITION_2
@ EVENT_SUMMON_CYCLONE
@ EVENT_TRANSITION_3
@ EVENT_FLAME_WHIRL
void AddSC_boss_zuljin()
ZuljinActions
@ ACTION_CANCEL_SPIRIT_DRAINED
@ ACTION_INTERRUPT_SPIRIT_DRAIN
@ ACTION_CAST_SPIRIT_DRAIN
@ ACTION_CLEAR_FIXATE
ZuljinTexts
@ SAY_DEATH
@ EMOTE_LYNX_SPIRIT
@ EMOTE_EAGLE_SPIRIT
@ SAY_AGGRO
@ EMOTE_FADE_AWAY
@ EMOTE_DRAGONHAWK_SPIRIT
@ SAY_TRANSFORM_TO_LYNX
@ EMOTE_BEAR_SPIRIT
@ SAY_TRANSFORM_TO_DRAGONHAWK
@ SAY_TRANSFORM_TO_BEAR
@ SAY_SLAY
@ SAY_FIRE_BREATH
@ SAY_BERSERK
@ SAY_INTRO
@ SAY_TRANSFORM_TO_EAGLE
static Position const CenterPos
static constexpr uint32 SpiritData[]
ZuljinMisc
@ POINT_CENTER
@ NPC_FEATHER_VORTEX
ZuljinEventGroups
@ EVENT_GROUP_LYNX_PHASE
@ EVENT_GROUP_TROLL_PHASE
@ EVENT_GROUP_BEAR_PHASE
@ EVENT_GROUP_EAGLE_PHASE
SpellEffectInfo const & GetSpellEffectInfo() const
void PreventDefaultAction()
HookList< EffectApplyHandler > AfterEffectRemove
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
InstanceScript *const instance
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat(Creature *creature=nullptr)
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:82
void SetReactState(ReactStates st)
Definition Creature.h:119
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void CancelEventGroup(GroupIndex group)
Definition EventMap.cpp:165
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Creature * GetCreature(uint32 type)
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
bool IsPlayer() const
Definition Object.h:179
static Unit * ToUnit(Object *o)
Definition Object.h:192
static ObjectGuid GetGUID(Object const *o)
Definition Object.h:78
uint32 TriggerSpell
Definition SpellInfo.h:228
uint32 Id
Definition SpellInfo.h:289
SpellEffectInfo const & GetEffect(SpellEffIndex index) const
Definition SpellInfo.h:483
HookList< CastHandler > AfterCast
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
void DespawnEntry(uint32 entry)
TaskScheduler & Schedule(std::chrono::duration< _Rep, _Period > const &time, task_handler_t const &task)
TaskScheduler & Update(success_t const &callback=EmptyCallback)
void AddThreat(Unit *target, float amount, SpellInfo const *spell=nullptr, bool ignoreModifiers=false, bool ignoreRedirects=false)
== AFFECT MY THREAT LIST ==
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
ThreatManager & GetThreatManager()
Definition Unit.h:1155
void InterruptNonMeleeSpells(bool withDelayed, uint32 spellid=0, bool withInstant=true)
Definition Unit.cpp:3093
MotionMaster * GetMotionMaster()
Definition Unit.h:1667
bool HasAura(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, ObjectGuid itemCasterGUID=ObjectGuid::Empty, uint8 reqEffMask=0) const
Definition Unit.cpp:4535
void SetFacingToObject(WorldObject const *object, bool force=true, uint32 movementId=EVENT_FACE)
Definition Unit.cpp:13259
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
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:918
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2832
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
void AfterRemove(AuraEffect const *, AuraEffectHandleModes)
bool Validate(SpellInfo const *spellInfo) override
PrepareAuraScript(spell_zuljin_claw_rage_periodic)
void OnPeriodic(AuraEffect const *aurEff)
void Register() override
bool Validate(SpellInfo const *) override
PrepareSpellScript(spell_zuljin_claw_rage)
void Register() override
void HandleDummy(SpellEffIndex)
bool Validate(SpellInfo const *) override
PrepareSpellScript(spell_zuljin_lynx_rush)
void Register() override
bool Validate(SpellInfo const *) override
PrepareSpellScript(spell_zuljin_zap)
void HandleScript(SpellEffIndex)
TC_GAME_API Unit * GetUnit(WorldObject const &, ObjectGuid const &guid)
uint8 phaseGroup
uint32 spiritSpellId
uint32 spiritId
void SetEquipmentSlots(bool loadDefault, int32 mainHand=EQUIP_NO_CHANGE, int32 offHand=EQUIP_NO_CHANGE, int32 ranged=EQUIP_NO_CHANGE)
void AttackStart(Unit *) override
void ResetThreatList(Unit *who=nullptr)
void AddThreat(Unit *victim, float amount, Unit *who=nullptr)
void JustEngagedWith(Unit *who) override
void DoAction(int32 action) override
void EnterEvadeMode(EvadeReason) override
void JustDied(Unit *) override
void Reset() override
uint8 _currentRushCount
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
boss_zuljin(Creature *creature)
void UpdateAI(uint32 diff) override
ObjectGuid _clawRageVictimGUID
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void OnSpellCast(SpellInfo const *spell) override
void ScheduleEventsForPhase()
void MovementInform(uint32 type, uint32 pointId) override
void KilledUnit(Unit *) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
TaskScheduler _scheduler
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
npc_zuljin_spirit(Creature *creature)
void DoAction(int32 action) override
void SpellHitTarget(WorldObject *target, SpellInfo const *spellInfo) override
void UpdateAI(uint32 diff) override
TaskScheduler _scheduler
npc_zuljin_vortex(Creature *creature)
void JustAppeared() override
@ BOSS_ZULJIN
Definition zulaman.h:33
@ DATA_EAGLE_SPIRIT
Definition zulaman.h:42
@ DATA_BEAR_SPIRIT
Definition zulaman.h:41
@ DATA_DRAGONHAWK_SPIRIT
Definition zulaman.h:44
@ DATA_LYNX_SPIRIT
Definition zulaman.h:43
#define RegisterZulAmanCreatureAI(ai_name)
Definition zulaman.h:94