TrinityCore
Loading...
Searching...
No Matches
boss_janalai.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 * SAY_EVENT is NYI
21 * Boundary is NYI
22 * Purpose of SPELL_FIRE_BOMB_DUMMY is unknown
23 */
24
25#include "ScriptMgr.h"
26#include "Containers.h"
27#include "InstanceScript.h"
28#include "Map.h"
29#include "MotionMaster.h"
30#include "ScriptedCreature.h"
31#include "SpellAuraEffects.h"
32#include "SpellScript.h"
33#include "SpellInfo.h"
34#include "zulaman.h"
35
48
50{
51 // Jan'alai - Combat
56 SPELL_FRENZY = 44779,
58
59 // Jan'alai - Combat - Bomb Sequence
65
66 // Fire Bomb
70
71 // Amani'shi Hatcher
73
74 // Dragonhawk Egg
76
77 // Amani Dragonhawk Hatchling
79
80 // Scripts
88};
89
105
119
129
130static constexpr std::string_view EggsStringIdR = "JanalaiEggsR";
131static constexpr std::string_view EggsStringIdL = "JanalaiEggsL";
132
133static Position const UpstairsPointR = { -55.058910f, 1147.5952f, 18.705223f, 0.0f };
134static Position const UpstairsPointL = { -55.047302f, 1153.5929f, 18.705204f, 0.0f };
135static Position const HatchEggsPointR = { -34.438860f, 1104.4828f, 18.711473f, 0.0f };
136static Position const HatchEggsPointL = { -34.767784f, 1192.8434f, 18.711363f, 0.0f };
137
138// 23578 - Jan'alai
139struct boss_janalai : public BossAI
140{
142
143 void JustAppeared() override
144 {
146 }
147
160
161 void DamageTaken(Unit* /*attacker*/, uint32& damage, DamageEffectType /*damageType*/, SpellInfo const* /*spellInfo = nullptr*/) override
162 {
163 if (!_hasTriedToHatchEggs && me->HealthBelowPctDamaged(35, damage))
164 {
166
167 if (!AllEggsWereHatched())
169 }
170
171 if (!_hasUsedFrenzy && me->HealthBelowPctDamaged(20, damage))
172 {
173 _hasUsedFrenzy = true;
175 }
176 }
177
178 void OnSpellCast(SpellInfo const* spellInfo) override
179 {
180 switch (spellInfo->Id)
181 {
185 break;
186 case SPELL_FRENZY:
188 _hasUsedFrenzy = true;
189 break;
190 case SPELL_BERSERK:
192 break;
193 default:
194 break;
195 }
196 }
197
198 void JustSummoned(Creature* summon) override
199 {
200 summons.Summon(summon);
201
202 if (summon->GetEntry() == NPC_FIRE_BOMB)
203 DoCast(summon, SPELL_FIRE_BOMB_MISSILE, true);
204 }
205
207 {
208 return GetClosestCreatureWithOptions(me, 200.0f, { .CreatureId = NPC_DRAGONHAWK_EGG, .IsAlive = true }) == nullptr;
209 }
210
212 {
213 // Verified: He summons no hatchers if both are alive, in this case he performs no emote
214 // Not verified: What happens if only one hatcher was killed? Currently we spawn no hatchers and perform no emote
215 if (AllEggsWereHatched())
216 return;
217
218 Creature* hatcherR = me->FindNearestCreature(NPC_AMANISHI_HATCHER_R, 150.0f, true);
219 Creature* hatcherL = me->FindNearestCreature(NPC_AMANISHI_HATCHER_L, 150.0f, true);
220
221 if (hatcherR || hatcherL)
222 return;
223
227 }
228
229 void EnterEvadeMode(EvadeReason /*why*/) override
230 {
233 }
234
235 void KilledUnit(Unit* /*victim*/) override
236 {
237 Talk(SAY_SLAY);
238 }
239
240 void JustDied(Unit* /*killer*/) override
241 {
242 _JustDied();
244 }
245
246 void UpdateAI(uint32 diff) override
247 {
248 if (!UpdateVictim())
249 return;
250
251 events.Update(diff);
252
254 return;
255
256 while (uint32 eventId = events.ExecuteEvent())
257 {
258 switch (eventId)
259 {
260 // Combat
262 if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0, 50.0f, true))
263 DoCast(target, SPELL_FLAME_BREATH);
264 events.Repeat(10s, 15s);
265 break;
268 events.Repeat(90s);
269 break;
272 break;
273 case EVENT_FRENZY:
275 break;
276 case EVENT_BERSERK:
278 break;
279
280 // Combat - Fire Bomb Sequence
281 case EVENT_FIRE_BOMBS:
286 events.Repeat(30s);
287 break;
291 break;
293 {
295
296 std::vector<Creature*> triggers;
297 GetCreatureListWithOptionsInGrid(triggers, me, 100.0f, { .StringId = "JanalaiFireWallTrigger" });
298 for (Creature* trigger : triggers)
299 trigger->CastSpell(trigger, SPELL_FIRE_WALL);
300
303 break;
304 }
306 {
307 std::vector<Creature*> bombs;
309 for (Creature* bomb : bombs)
310 bomb->AI()->DoAction(ACTION_EXPLODE_BOMB);
311 break;
312 }
313 default:
314 break;
315 }
316
318 return;
319 }
320
322 }
323
324private:
327};
328
329// 23920 - Fire Bomb (Zul'Aman)
331{
333
334 void InitializeAI() override
335 {
337 }
338
339 void DoAction(int32 action) override
340 {
341 if (action == ACTION_EXPLODE_BOMB)
342 {
345 me->DespawnOrUnsummon(3600ms);
346 }
347 }
348
349 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
350 {
351 if (spellInfo->Id == SPELL_FIRE_BOMB_MISSILE)
353 }
354};
355
356// 23818 - Amani'shi Hatcher
357// 24504 - Amani'shi Hatcher
359{
361
389
394
395 void Reset() override
396 {
398 }
399
401 {
402 return GetClosestCreatureWithOptions(me, 200.0f, { .StringId = _eggsStringIdA, .IsAlive = true }) == nullptr;
403 }
404
406 {
407 return GetClosestCreatureWithOptions(me, 200.0f, { .StringId = _eggsStringIdB, .IsAlive = true }) == nullptr;
408 }
409
411 {
412 return me->FindNearestCreature(_otherHatcherId, 200.0f, true) != nullptr;
413 }
414
415 void MovementInform(uint32 type, uint32 id) override
416 {
417 if (type == POINT_MOTION_TYPE)
418 {
419 switch (id)
420 {
421 case POINT_UPSTAIRS:
422 _scheduler.Schedule(2s, [this](TaskContext /*task*/)
423 {
424 // Verified: If own eggs were hatched, move to the side with unhatched eggs. Yes, both hatchers move to the same side
425 if (!AreEggsHatchedA())
427 else
429 });
430 break;
431 case POINT_HATCH_EGGS:
432 _scheduler.Schedule(1s, [this](TaskContext task)
433 {
434 // Verified: If eggs from the both sides are hatched, stay and continue to cast Hatch Eggs spell
435 // Verified: If own eggs were hatched, other hatcher's eggs were not hatched and other hatcher is dead, move to hatch his eggs
436 // Not verified: If own eggs were hatched, other hatcher's eggs were not hatched and other hatcher is alive, what should happen?
438 {
440 return;
441 }
442
444 task.Repeat(5s);
445 });
446 break;
447 case POINT_BACKUP:
448 _scheduler.Schedule(1s, [this](TaskContext task)
449 {
451 task.Repeat(5s);
452 });
453 break;
454 }
455 }
456 }
457
458 void SetData(uint32 type, uint32 value) override
459 {
460 if (type == DATA_EGGS_TO_HATCH)
461 _eggsToHatchCount = value;
462 }
463
464 uint32 GetData(uint32 type) const override
465 {
466 if (type == DATA_EGGS_TO_HATCH)
467 return _eggsToHatchCount;
468
469 return 0;
470 }
471
472 void UpdateAI(uint32 diff) override
473 {
474 UpdateVictim();
475
476 _scheduler.Update(diff);
477 }
478
479private:
484 std::string_view _eggsStringIdA;
485 std::string_view _eggsStringIdB;
488};
489
490// 23817 - Dragonhawk Egg
492{
494
495 void InitializeAI() override
496 {
497 me->SetCorpseDelay(3, true);
498 }
499
500 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
501 {
502 if (spellInfo->Id == SPELL_HATCH_EGGS || spellInfo->Id == SPELL_HATCH_ALL_EGGS)
504 }
505};
506
507// 23598 - Amani Dragonhawk Hatchling
509{
510 npc_amani_dragonhawk_hatchling(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
511
512 void InitializeAI() override
513 {
514 me->SetCorpseDelay(4, true);
516 }
517
518 void JustAppeared() override
519 {
521
523 janalai->AI()->JustSummoned(me);
524 }
525
526 void Reset() override
527 {
529 }
530
531 void JustEngagedWith(Unit* /*who*/) override
532 {
533 _scheduler.Schedule(5s, 10s, [this](TaskContext task)
534 {
536 task.Repeat(5s, 10s);
537 });
538 }
539
540 void UpdateAI(uint32 diff) override
541 {
542 if (!UpdateVictim())
543 return;
544
545 _scheduler.Update(diff, [this]
546 {
548 });
549 }
550
551private:
554};
555
556// 43096 - Summon All Players
558{
560
561 bool Validate(SpellInfo const* /*spellInfo*/) override
562 {
564 }
565
566 void HandleDummy(SpellEffIndex /*effIndex*/)
567 {
568 // Guessed value. Patch 2.4.0 (2008-03-25): Will now only teleport players to him if they are too far away.
569 if (!GetCaster()->IsWithinDist(GetHitUnit(), 30.0f, false))
571 }
572
577};
578
579// 42621 - Fire Bomb
581{
583
584 bool Validate(SpellInfo const* /*spellInfo*/) override
585 {
587 }
588
589 void OnPeriodic(AuraEffect const* aurEff)
590 {
591 uint8 index = -1;
592 uint32 tick = aurEff->GetTickNumber();
593
594 if (tick)
595 {
596 if (tick < 10)
597 index = tick / 5;
598 else
599 index = tick / 10 + 1;
600
601 if (index < 6)
603 else
604 Remove();
605 }
606 }
607
612};
613
614// 42471 - Hatch Eggs
616{
618
619 void FilterTargets(std::list<WorldObject*>& targets)
620 {
621 if (Creature* caster = GetCaster()->ToCreature())
622 {
623 targets.remove_if([caster](WorldObject const* target)
624 {
625 return !caster->IsWithinDist(target, 50.0f);
626 });
627
628 Trinity::Containers::RandomResize(targets, caster->GetAI()->GetData(DATA_EGGS_TO_HATCH));
629 }
630 }
631
632 void HandleScript(SpellEffIndex /*effIndex*/)
633 {
634 if (Creature* target = GetHitUnit()->ToCreature())
635 if (target->AI()->GetData(DATA_EGGS_TO_HATCH) < 5)
636 target->AI()->SetData(DATA_EGGS_TO_HATCH, target->AI()->GetData(DATA_EGGS_TO_HATCH) + 1);
637 }
638
644};
645
uint8_t uint8
Definition Define.h:135
int32_t int32
Definition Define.h:129
uint32_t uint32
Definition Define.h:133
@ POINT_MOTION_TYPE
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1128
void GetCreatureListWithEntryInGrid(Container &container, WorldObject *source, uint32 entry, float maxSearchRange)
void GetCreatureListWithOptionsInGrid(Container &container, WorldObject *source, float maxSearchRange, FindCreatureOptions const &options)
Creature * GetClosestCreatureWithOptions(WorldObject *source, float maxSearchRange, FindCreatureOptions const &options)
SpellEffIndex
@ EFFECT_1
@ EFFECT_0
@ SPELL_EFFECT_DUMMY
@ SPELL_EFFECT_SCRIPT_EFFECT
@ TARGET_UNIT_SRC_AREA_ENTRY
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
@ UNIT_STATE_CASTING
Definition Unit.h:249
DamageEffectType
Definition Unit.h:366
JanalaiEvents
@ EVENT_FLAME_BREATH
@ EVENT_FIRE_BOMBS_4
@ EVENT_BERSERK
@ EVENT_FIRE_BOMBS_2
@ EVENT_FIRE_BOMBS_3
@ EVENT_FIRE_BOMBS
@ EVENT_FRENZY
@ EVENT_HATCH_ALL_EGGS
@ EVENT_SUMMON_HATCHERS
JanalaiSpells
@ SPELL_SUMMON_HATCHLING
@ SPELL_SUMMON_FIRE_BOMB_25
@ SPELL_FIRE_WALL
@ SPELL_FLAME_BREATH
@ SPELL_SUMMON_HATCHER_1
@ SPELL_SUMMON_HATCHER_2
@ SPELL_SUMMON_FIRE_BOMB_15
@ SPELL_SUMMON_ALL_PLAYERS_2
@ SPELL_FIRE_BOMB_MISSILE
@ SPELL_FIRE_BOMB_DUMMY
@ SPELL_HATCH_EGGS
@ SPELL_SUMMON_ALL_PLAYERS
@ SPELL_FRENZY
@ SPELL_FIRE_BOMB_INITIAL
@ SPELL_SUMMON_FIRE_BOMB_10
@ SPELL_SUMMON_FIRE_BOMB_20
@ SPELL_SUMMON_FIRE_BOMB_30
@ SPELL_HATCH_ALL_EGGS
@ SPELL_SUMMON_FIRE_BOMB_05
@ SPELL_BERSERK
@ SPELL_FIRE_BOMB_VISUAL
@ SPELL_FLAME_BUFFET
@ SPELL_FIRE_BOMB_DAMAGE
@ SPELL_TELEPORT_TO_CENTER
static constexpr std::string_view EggsStringIdL
static Position const UpstairsPointL
void AddSC_boss_janalai()
static constexpr std::array< uint32, 6 > SummonFireBombSpells
static Position const HatchEggsPointL
JanalaiMisc
@ NPC_AMANISHI_HATCHER_L
@ ACTION_EXPLODE_BOMB
@ SPAWN_GROUP_EGGS
@ POINT_HATCH_EGGS
@ POINT_UPSTAIRS
@ NPC_DRAGONHAWK_EGG
@ DATA_EGGS_TO_HATCH
@ NPC_FIRE_BOMB
@ NPC_AMANISHI_HATCHER_R
@ POINT_BACKUP
static Position const UpstairsPointR
JanalaiTexts
@ SAY_DEATH
@ SAY_AGGRO
@ EMOTE_FRENZY
@ SAY_FIRE_BOMBS
@ SAY_SLAY
@ SAY_SUMMON_HATCHER
@ SAY_ALL_EGGS
@ SAY_BERSERK
@ SAY_EVENT
static constexpr std::string_view EggsStringIdR
static Position const HatchEggsPointR
uint32 GetTickNumber() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
void Remove(AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
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:128
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
void SetCorpseDelay(uint32 delay, bool ignoreCorpseDecayRatio=false)
Definition Creature.h:98
void Update(uint32 time)
Definition EventMap.h:67
void Repeat(Milliseconds time)
Definition EventMap.cpp:63
EventId ExecuteEvent()
Definition EventMap.cpp:73
void RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:52
void CancelEvent(EventId eventId)
Definition EventMap.cpp:151
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:36
Creature * GetCreature(uint32 type)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:3382
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={})
uint32 GetEntry() const
Definition Object.h:81
uint32 Id
Definition SpellInfo.h:289
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void Summon(Creature const *summon)
TaskContext & Repeat(std::chrono::duration< _Rep, _Period > const &duration)
TaskScheduler & CancelAll()
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 void InitializeAI()
Definition UnitAI.cpp:36
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:783
MotionMaster * GetMotionMaster()
Definition Unit.h:1683
bool IsAlive() const
Definition Unit.h:1247
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint8 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3807
bool HasUnitState(const uint32 f) const
Definition Unit.h:890
bool HealthBelowPctDamaged(int32 pct, uint32 damage) const
Definition Unit.h:932
Map * GetMap() const
Definition Object.h:451
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2833
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:2100
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
PrepareAuraScript(spell_janalai_fire_bomb)
bool Validate(SpellInfo const *) override
void OnPeriodic(AuraEffect const *aurEff)
void FilterTargets(std::list< WorldObject * > &targets)
void HandleScript(SpellEffIndex)
PrepareSpellScript(spell_janalai_hatch_eggs)
PrepareSpellScript(spell_janalai_summon_all_players)
bool Validate(SpellInfo const *) override
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:66
ScriptedAI(Creature *creature)
void UpdateAI(uint32 diff) override
bool _hasTriedToHatchEggs
void DamageTaken(Unit *, uint32 &damage, DamageEffectType, SpellInfo const *) override
void OnSpellCast(SpellInfo const *spellInfo) override
void JustSummoned(Creature *summon) override
void JustDied(Unit *) override
void JustAppeared() override
boss_janalai(Creature *creature)
void KilledUnit(Unit *) override
bool AllEggsWereHatched()
void EnterEvadeMode(EvadeReason) override
void DoSummonHatchers()
void JustEngagedWith(Unit *who) override
npc_amani_dragonhawk_hatchling(Creature *creature)
void UpdateAI(uint32 diff) override
void JustEngagedWith(Unit *) override
void JustAppeared() override
std::string_view _eggsStringIdB
std::string_view _eggsStringIdA
void InitializeAI() override
void UpdateAI(uint32 diff) override
void MovementInform(uint32 type, uint32 id) override
TaskScheduler _scheduler
uint32 GetData(uint32 type) const override
void SetData(uint32 type, uint32 value) override
void Reset() override
npc_amanishi_hatcher(Creature *creature)
void InitializeAI() override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void SpellHit(WorldObject *, SpellInfo const *spellInfo) override
void InitializeAI() override
void DoAction(int32 action) override
@ BOSS_JANALAI
Definition zulaman.h:30
#define RegisterZulAmanCreatureAI(ai_name)
Definition zulaman.h:94