fix(Scripts/OnyxiasLair): Keep Onyxian Whelps unattackable during their spawn-in (#27842)

This commit is contained in:
Andrew
2026-09-27 13:34:17 -03:00
committed by GitHub
parent 38da081b6b
commit 8c7ab7b0c6
2 changed files with 22 additions and 1 deletions
@@ -0,0 +1,2 @@
-- Onyxian Whelp: UNIT_FLAG_NON_ATTACKABLE until its spawn-in ends (cleared by npc_onyxian_whelp)
UPDATE `creature_template` SET `unit_flags` = `unit_flags` | 2, `VerifiedBuild` = 69933 WHERE `entry` IN (11262, 36566);
@@ -705,7 +705,14 @@ struct npc_onyxian_whelp : public ScriptedAI
scheduler.Schedule(500ms, [this](TaskContext context)
{
if (Unit* target = me->SelectNearestTarget(300.0f))
me->RemoveUnitFlag(UNIT_FLAG_NON_ATTACKABLE);
// A whelp that aggroed during its spawn-in goes for the victim it picked then
Unit* target = me->IsEngaged() ? me->GetThreatMgr().GetCurrentVictim() : nullptr;
if (!target)
target = me->SelectNearestTarget(300.0f);
if (target)
{
AttackStart(target);
DoZoneInCombat();
@@ -720,6 +727,18 @@ struct npc_onyxian_whelp : public ScriptedAI
});
}
// While UNIT_FLAG_NON_ATTACKABLE (from the template) is set, whelps may aggro but only take a target and attack once it clears
void AttackStart(Unit* who) override
{
if (me->HasUnitFlag(UNIT_FLAG_NON_ATTACKABLE))
{
me->EngageWithTarget(who);
return;
}
ScriptedAI::AttackStart(who);
}
void JustDied(Unit* /*killer*/) override
{
me->DespawnOrUnsummon(4s);