mirror of
https://gitcode.com/GitHub_Trending/az/azerothcore-wotlk.git
synced 2026-10-10 07:06:38 +08:00
fix(Scripts/OnyxiasLair): Keep Onyxian Whelps unattackable during their spawn-in (#27842)
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user