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
57 SPELL_FRENZY = 44779,
59
60 // Jan'alai - Combat - Bomb Sequence
66
67 // Fire Bomb
71
72 // Amani'shi Hatcher
74
75 // Dragonhawk Egg
77
78 // Amani Dragonhawk Hatchling
80
81 // Scripts
89};
90
106
119
129
130static constexpr std::string_view EggsStringIdR = "JanalaiEggsR";
131static constexpr std::string_view EggsStringIdL = "JanalaiEggsL";
132
133static constexpr Position UpstairsPointR = { -55.058910f, 1147.5952f, 18.705223f, 0.0f };
134static constexpr Position UpstairsPointL = { -55.047302f, 1153.5929f, 18.705204f, 0.0f };
135static constexpr Position HatchEggsPointR = { -34.438860f, 1104.4828f, 18.711473f, 0.0f };
136static constexpr Position 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 = FindCreatureAliveState::Alive }) == 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, false))
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 }
321
322private:
325};
326
327// 23920 - Fire Bomb (Zul'Aman)
329{
331
332 void InitializeAI() override
333 {
335 }
336
337 void DoAction(int32 action) override
338 {
339 if (action == ACTION_EXPLODE_BOMB)
340 {
343 me->DespawnOrUnsummon(3600ms);
344 }
345 }
346
347 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
348 {
349 if (spellInfo->Id == SPELL_FIRE_BOMB_MISSILE)
351 }
352};
353
354// 23818 - Amani'shi Hatcher
355// 24504 - Amani'shi Hatcher
357{
359
387
392
393 void Reset() override
394 {
396 }
397
399 {
400 return GetClosestCreatureWithOptions(me, 200.0f, { .StringId = _eggsStringIdA, .IsAlive = FindCreatureAliveState::Alive }) == nullptr;
401 }
402
404 {
405 return GetClosestCreatureWithOptions(me, 200.0f, { .StringId = _eggsStringIdB, .IsAlive = FindCreatureAliveState::Alive }) == nullptr;
406 }
407
409 {
410 return me->FindNearestCreature(_otherHatcherId, 200.0f, true) != nullptr;
411 }
412
413 void MovementInform(uint32 type, uint32 id) override
414 {
415 if (type == POINT_MOTION_TYPE)
416 {
417 switch (id)
418 {
419 case POINT_UPSTAIRS:
420 _scheduler.Schedule(2s, [this](TaskContext const& /*task*/)
421 {
422 // Verified: If own eggs were hatched, move to the side with unhatched eggs. Yes, both hatchers move to the same side
423 if (!AreEggsHatchedA())
425 else
427 });
428 break;
429 case POINT_HATCH_EGGS:
430 _scheduler.Schedule(1s, [this](TaskContext& task)
431 {
432 // Verified: If eggs from the both sides are hatched, stay and continue to cast Hatch Eggs spell
433 // Verified: If own eggs were hatched, other hatcher's eggs were not hatched and other hatcher is dead, move to hatch his eggs
434 // Not verified: If own eggs were hatched, other hatcher's eggs were not hatched and other hatcher is alive, what should happen?
436 {
438 return;
439 }
440
442 task.Repeat(5s);
443 });
444 break;
445 case POINT_BACKUP:
446 _scheduler.Schedule(1s, [this](TaskContext& task)
447 {
449 task.Repeat(5s);
450 });
451 break;
452 }
453 }
454 }
455
456 void UpdateAI(uint32 diff) override
457 {
458 UpdateVictim();
459
460 _scheduler.Update(diff);
461 }
462
463private:
468 std::string_view _eggsStringIdA;
469 std::string_view _eggsStringIdB;
471};
472
473// 23817 - Dragonhawk Egg
475{
477
478 void InitializeAI() override
479 {
480 me->SetCorpseDelay(3, true);
481 }
482
483 void SpellHit(WorldObject* /*caster*/, SpellInfo const* spellInfo) override
484 {
485 if (spellInfo->Id == SPELL_HATCH_EGGS || spellInfo->Id == SPELL_HATCH_ALL_EGGS)
487 }
488};
489
490// 23598 - Amani Dragonhawk Hatchling
492{
493 npc_amani_dragonhawk_hatchling(Creature* creature) : ScriptedAI(creature), _instance(creature->GetInstanceScript()) { }
494
495 void InitializeAI() override
496 {
497 me->SetCorpseDelay(4, true);
499 }
500
501 void JustAppeared() override
502 {
504
506 janalai->AI()->JustSummoned(me);
507 }
508
509 void Reset() override
510 {
512 }
513
514 void JustEngagedWith(Unit* /*who*/) override
515 {
516 _scheduler.Schedule(5s, 10s, [this](TaskContext& task)
517 {
519 task.Repeat(5s, 10s);
520 });
521 }
522
523 void UpdateAI(uint32 diff) override
524 {
525 if (!UpdateVictim())
526 return;
527
528 _scheduler.Update(diff);
529 }
530
531private:
534};
535
536// 43096 - Summon All Players
538{
539 bool Validate(SpellInfo const* /*spellInfo*/) override
540 {
542 }
543
544 void HandleDummy(SpellEffIndex /*effIndex*/)
545 {
546 // Guessed value. Patch 2.4.0 (2008-03-25): Will now only teleport players to him if they are too far away.
547 if (!GetCaster()->IsWithinDist(GetHitUnit(), 30.0f, false))
549 }
550
555};
556
557// 43140 - Flame Breath
559{
560 void SummonFlamePatch(AuraEffect const* aurEff) const
561 {
562 if (aurEff->GetTickNumber() > 9)
563 return;
564
565 Unit* target = GetTarget();
566 Position dest = target->GetPosition();
567 target->MovePositionToFirstCollision(dest, (aurEff->GetTickNumber() + 1) * 4.0f, Facing - target->GetOrientation());
568
569 target->CastSpell(dest, SPELL_FLAME_BREATH_GROUND, true);
570 }
571
576
577public:
578 float Facing = 0.0f;
579};
580
582{
583 void InitOrientation(SpellEffIndex /*effIndex*/) const
584 {
585 if (Aura* aura = GetHitAura())
587 script->Facing = GetCaster()->GetAbsoluteAngle(GetHitDest());
588 }
589
594};
595
596// 42621 - Fire Bomb
598{
599 bool Validate(SpellInfo const* /*spellInfo*/) override
600 {
602 }
603
604 void OnPeriodic(AuraEffect const* aurEff)
605 {
606 uint8 index = -1;
607 uint32 tick = aurEff->GetTickNumber();
608
609 if (tick)
610 {
611 if (tick < 10)
612 index = tick / 5;
613 else
614 index = tick / 10 + 1;
615
616 if (index < 6)
618 else
619 Remove();
620 }
621 }
622
627};
628
629// 42471 - Hatch Eggs
631{
632 void FilterTargets(std::list<WorldObject*>& targets)
633 {
634 if (Creature* caster = GetCaster()->ToCreature())
635 {
636 targets.remove_if([caster](WorldObject const* target)
637 {
638 return !caster->IsWithinDist(target, 50.0f);
639 });
640
642 }
643 }
644
649};
650
uint8_t uint8
Definition Define.h:156
int32_t int32
Definition Define.h:150
uint32_t uint32
Definition Define.h:154
@ POINT_MOTION_TYPE
#define RegisterSpellAndAuraScriptPair(script_1, script_2)
Definition ScriptMgr.h:1381
#define RegisterSpellScript(spell_script)
Definition ScriptMgr.h:1383
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_APPLY_AURA
@ TARGET_UNIT_SRC_AREA_ENTRY
@ SPELL_AURA_PERIODIC_DUMMY
#define SpellEffectFn(F, I, N)
#define SpellObjectAreaTargetSelectFn(F, I, N)
#define AuraEffectPeriodicFn(F, I, N)
EvadeReason
@ REACT_PASSIVE
@ REACT_AGGRESSIVE
DamageEffectType
@ UNIT_STATE_CASTING
Definition Unit.h:290
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_FLAME_BREATH_GROUND
@ 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 constexpr Position UpstairsPointL
static constexpr Position HatchEggsPointR
void AddSC_boss_janalai()
static constexpr std::array< uint32, 6 > SummonFireBombSpells
static constexpr Position HatchEggsPointL
static constexpr Position UpstairsPointR
JanalaiMisc
@ NPC_AMANISHI_HATCHER_L
@ ACTION_EXPLODE_BOMB
@ SPAWN_GROUP_EGGS
@ POINT_HATCH_EGGS
@ POINT_UPSTAIRS
@ NPC_DRAGONHAWK_EGG
@ NPC_FIRE_BOMB
@ NPC_AMANISHI_HATCHER_R
@ POINT_BACKUP
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
uint32 GetTickNumber() const
HookList< EffectPeriodicHandler > OnEffectPeriodic
Unit * GetTarget() const
void JustEngagedWith(Unit *who) override
void _DespawnAtEvade(Seconds delayToRespawn=30s, Creature *who=nullptr)
SummonList summons
EventMap events
void DoZoneInCombat()
Definition CreatureAI.h:169
bool UpdateVictim()
Creature *const me
Definition CreatureAI.h:63
void SetReactState(ReactStates st)
Definition Creature.h:180
void DespawnOrUnsummon(Milliseconds timeToDespawn=0s, Seconds forceRespawnTime=0s)
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 RescheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:56
void CancelEvent(EventId eventId)
Definition EventMap.cpp:156
void ScheduleEvent(EventId eventId, Milliseconds time, GroupIndex group=0u, PhaseIndex phase=0u)
Definition EventMap.cpp:40
Creature * GetCreature(uint32 type)
bool SpawnGroupSpawn(uint32 groupId, bool ignoreRespawn=false, bool force=false, std::vector< WorldObject * > *spawnedObjects=nullptr)
Definition Map.cpp:2360
void MovePoint(uint32 id, Position const &pos, bool generatePath=true, Optional< float > finalOrient={}, Optional< float > speed={}, MovementWalkRunSpeedSelectionMode speedSelectionMode=MovementWalkRunSpeedSelectionMode::Default, Optional< float > closeEnoughDistance={}, Optional< MovementFadeObject > fadeObject={}, Scripting::v2::ActionResultSetter< MovementStopReason > &&scriptResult={})
uint32 GetEntry() const
Definition Object.h:89
uint32 const Id
Definition SpellInfo.h:328
static bool ValidateSpellInfo(std::initializer_list< uint32 > spellIds)
WorldLocation * GetHitDest() const
Aura * GetHitAura(bool dynObjAura=false, bool withRemoved=false) const
Unit * GetCaster() const
Unit * GetHitUnit() const
HookList< EffectHandler > OnEffectHitTarget
HookList< ObjectAreaTargetSelectHandler > OnObjectAreaTargetSelect
void Summon(Creature const *summon)
TaskContext & Repeat(TaskScheduler::duration_t duration)
TaskScheduler & CancelAll()
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
virtual void InitializeAI()
Definition UnitAI.cpp:35
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
SpellCastResult DoCast(uint32 spellId)
Definition UnitAI.cpp:81
Definition Unit.h:647
MotionMaster * GetMotionMaster()
Definition Unit.h:1750
bool IsAlive() const
Definition Unit.h:1205
bool HealthBelowPctDamaged(float pct, uint32 damage) const
Definition Unit.h:805
bool HasUnitState(const uint32 f) const
Definition Unit.h:755
void RemoveAurasDueToSpell(uint32 spellId, ObjectGuid casterGUID=ObjectGuid::Empty, uint32 reqEffMask=0, AuraRemoveMode removeMode=AURA_REMOVE_BY_DEFAULT)
Definition Unit.cpp:3992
Map * GetMap() const
Definition Object.h:411
SpellCastResult CastSpell(CastSpellTargetArg const &targets, uint32 spellId, CastSpellExtraArgs const &args={ })
Definition Object.cpp:2222
Creature * FindNearestCreature(uint32 entry, float range, bool alive=true) const
Definition Object.cpp:1522
void MovePositionToFirstCollision(Position &pos, float dist, float angle) const
Definition Object.cpp:2833
bool Validate(SpellInfo const *) override
void OnPeriodic(AuraEffect const *aurEff)
void SummonFlamePatch(AuraEffect const *aurEff) const
void InitOrientation(SpellEffIndex) const
void FilterTargets(std::list< WorldObject * > &targets)
bool Validate(SpellInfo const *) override
void RandomResize(C &container, std::size_t requestedSize)
Definition Containers.h:67
float GetAbsoluteAngle(float x, float y) const
Definition Position.h:136
constexpr void GetPosition(float &x, float &y) const
Definition Position.h:92
constexpr float GetOrientation() const
Definition Position.h:90
ScriptedAI(Creature *creature, uint32 scriptId=0) noexcept
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
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:114