fix(Scripts/ZulAman): Fix Amani Hatcher behaviour (#20687)

This commit is contained in:
Andrew
2024-11-24 07:56:18 -03:00
committed by GitHub
parent cbcee46a82
commit c5876bff6f
3 changed files with 61 additions and 9 deletions
+11
View File
@@ -62,6 +62,17 @@ void CreatureAI::Talk(uint8 id, WorldObject const* target /*= nullptr*/, Millise
} }
} }
/**
* @brief Returns the summoner creature/object, if the creature is a temporary summon.
*/
WorldObject* CreatureAI::GetSummoner() const
{
if (TempSummon* summon = me->ToTempSummon())
return summon->GetSummoner();
return nullptr;
}
inline bool IsValidCombatTarget(Creature* source, Player* target) inline bool IsValidCombatTarget(Creature* source, Player* target)
{ {
if (target->IsGameMaster()) if (target->IsGameMaster())
+2
View File
@@ -96,6 +96,8 @@ public:
void Talk(uint8 id, WorldObject const* whisperTarget = nullptr, Milliseconds delay = 0s); void Talk(uint8 id, WorldObject const* whisperTarget = nullptr, Milliseconds delay = 0s);
void Talk(uint8 id, Milliseconds delay) { Talk(id, nullptr, delay); } void Talk(uint8 id, Milliseconds delay) { Talk(id, nullptr, delay); }
WorldObject* GetSummoner() const;
explicit CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), _negateBoundary(false), m_MoveInLineOfSight_locked(false) { } explicit CreatureAI(Creature* creature) : UnitAI(creature), me(creature), _boundary(nullptr), _negateBoundary(false), m_MoveInLineOfSight_locked(false) { }
~CreatureAI() override {} ~CreatureAI() override {}
@@ -109,8 +109,9 @@ enum HatchActions
enum Misc enum Misc
{ {
MAX_BOMB_COUNT = 40, MAX_BOMB_COUNT = 40,
SCHEDULER_GROUP_HATCHING = 1, GROUP_ENRAGE = 1,
GROUP_ENRAGE = 1 GROUP_HATCHING = 2,
DATA_ALL_EGGS_HATCHED = 0
}; };
struct boss_janalai : public BossAI struct boss_janalai : public BossAI
@@ -146,6 +147,8 @@ struct boss_janalai : public BossAI
}); });
me->m_Events.KillAllEvents(false); me->m_Events.KillAllEvents(false);
_sideHatched[0] = false;
_sideHatched[1] = false;
} }
void JustDied(Unit* killer) override void JustDied(Unit* killer) override
@@ -184,11 +187,33 @@ struct boss_janalai : public BossAI
ScheduleTimedEvent(30s, [&]{ ScheduleTimedEvent(30s, [&]{
StartBombing(); StartBombing();
}, 20s, 40s); }, 20s, 40s);
ScheduleTimedEvent(10s, [&]{
scheduler.Schedule(10s, GROUP_HATCHING, [this](TaskContext context)
{
if (_sideHatched[0] && _sideHatched[1])
return;
Talk(SAY_SUMMON_HATCHER); Talk(SAY_SUMMON_HATCHER);
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[0][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[1][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000); if (_sideHatched[0] && !_sideHatched[1])
}, 90s); {
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[1][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[1][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
}
else if (!_sideHatched[0] && _sideHatched[1])
{
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[0][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[0][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
}
else
{
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[0][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
me->SummonCreature(NPC_AMANI_HATCHER, hatcherway[1][0], TEMPSUMMON_CORPSE_TIMED_DESPAWN, 10000);
}
context.Repeat(90s);
});
ScheduleTimedEvent(8s, [&]{ ScheduleTimedEvent(8s, [&]{
if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0)) if (Unit* target = SelectTarget(SelectTargetMethod::Random, 0))
{ {
@@ -215,6 +240,12 @@ struct boss_janalai : public BossAI
}, 10min); }, 10min);
} }
void SetData(uint32 index, uint32 data) override
{
if (index == DATA_ALL_EGGS_HATCHED)
_sideHatched[data] = true;
}
bool HatchAllEggs(uint32 hatchAction) bool HatchAllEggs(uint32 hatchAction)
{ {
std::list<Creature* > eggList; std::list<Creature* > eggList;
@@ -337,6 +368,7 @@ struct boss_janalai : public BossAI
private: private:
bool _isBombing; bool _isBombing;
bool _isFlameBreathing; bool _isFlameBreathing;
bool _sideHatched[2];
}; };
struct npc_janalai_hatcher : public ScriptedAI struct npc_janalai_hatcher : public ScriptedAI
@@ -349,6 +381,7 @@ struct npc_janalai_hatcher : public ScriptedAI
scheduler.CancelAll(); scheduler.CancelAll();
_side = (me->GetPositionY() < 1150); _side = (me->GetPositionY() < 1150);
_waypoint = 0; _waypoint = 0;
_repeatCount = 1;
_isHatching = false; _isHatching = false;
me->GetMotionMaster()->Clear(); me->GetMotionMaster()->Clear();
me->GetMotionMaster()->MovePoint(0, hatcherway[_side][0]); me->GetMotionMaster()->MovePoint(0, hatcherway[_side][0]);
@@ -360,19 +393,24 @@ struct npc_janalai_hatcher : public ScriptedAI
{ {
_isHatching = true; _isHatching = true;
scheduler.Schedule(1500ms, SCHEDULER_GROUP_HATCHING, [this](TaskContext context) scheduler.Schedule(1500ms, [this](TaskContext context)
{ {
me->CastCustomSpell(SPELL_HATCH_EGG_ALL, SPELLVALUE_MAX_TARGETS, context.GetRepeatCounter() + 1); me->CastCustomSpell(SPELL_HATCH_EGG_ALL, SPELLVALUE_MAX_TARGETS, _repeatCount);
++_repeatCount;
if (me->FindNearestCreature(NPC_EGG, 100.0f)) if (me->FindNearestCreature(NPC_EGG, 100.0f))
context.Repeat(4s); context.Repeat(4s);
else else
{ {
if (WorldObject* summoner = GetSummoner())
if (Creature* janalai = summoner->ToCreature())
janalai->AI()->SetData(DATA_ALL_EGGS_HATCHED, _side);
_side = _side ? 0 : 1; _side = _side ? 0 : 1;
_isHatching = false; _isHatching = false;
_waypoint = 3; _waypoint = 3;
MoveToNewWaypoint(_waypoint); MoveToNewWaypoint(_waypoint);
context.CancelGroup(SCHEDULER_GROUP_HATCHING);
} }
}); });
} }
@@ -407,6 +445,7 @@ struct npc_janalai_hatcher : public ScriptedAI
private: private:
uint8 _side; uint8 _side;
uint8 _waypoint; uint8 _waypoint;
uint32 _repeatCount;
bool _isHatching; bool _isHatching;
}; };