Scripts/Ulduar: Fix Stormcaller Brundir walking into walls (#23755)

* Scripts/Ulduar: Fix Stormcaller Brundir walking into walls

* Cleanup and fix logic + review

* Review: remove autos

(cherry picked from commit 876a848730)
This commit is contained in:
Artamedes
2019-09-06 14:09:47 -04:00
committed by Shauren
parent 0b43b43566
commit 8fbaab7337

View File

@@ -494,6 +494,9 @@ class boss_stormcaller_brundir : public CreatureScript
events.ScheduleEvent(EVENT_BERSERK, 15min);
events.ScheduleEvent(EVENT_CHAIN_LIGHTNING, 4s);
events.ScheduleEvent(EVENT_OVERLOAD, urand(60000, 120000));
if (Creature* trigger = me->FindNearestCreature(NPC_WORLD_TRIGGER, 100.0f))
m_TriggerGUID = trigger->GetGUID();
}
void DoAction(int32 action) override
@@ -625,11 +628,20 @@ class boss_stormcaller_brundir : public CreatureScript
{
float x = float(irand(-25, 25));
float y = float(irand(-25, 25));
me->GetMotionMaster()->MovePoint(0, me->GetPositionX() + x, me->GetPositionY() + y, me->GetPositionZ());
Position pos = me->GetPosition();
pos.m_positionX += x;
pos.m_positionY += y;
// Prevention to go outside the room or into the walls
if (Creature* trigger = me->FindNearestCreature(NPC_WORLD_TRIGGER, 100.0f, true))
if (me->GetDistance(trigger) >= 50.0f)
if (Creature* trigger = ObjectAccessor::GetCreature(*me, m_TriggerGUID))
{
if (pos.GetExactDist2d(trigger) >= 50.0f)
me->GetMotionMaster()->MovePoint(0, *trigger);
else
me->GetMotionMaster()->MovePoint(0, pos);
}
}
events.ScheduleEvent(EVENT_MOVE_POSITION, urand(7500, 10000));
break;
@@ -643,6 +655,9 @@ class boss_stormcaller_brundir : public CreatureScript
DoMeleeAttackIfReady();
}
private:
ObjectGuid m_TriggerGUID;
};
CreatureAI* GetAI(Creature* creature) const override