Scripts/Guards: Fix infinite loop in npc_air_force_bots
Port From (https://github.com/TrinityCore/TrinityCore/commit/98863659bb308f87f2b344e0c7f3b72985d8c5c4)
This commit is contained in:
@@ -463,6 +463,10 @@ namespace Scripts.World.NpcSpecial
|
||||
[Script]
|
||||
class npc_air_force_bots : ScriptedAI
|
||||
{
|
||||
SpawnAssociation SpawnAssoc;
|
||||
ObjectGuid SpawnedGUID;
|
||||
List<ObjectGuid> inLineOfSightSinceLastUpdate = new();
|
||||
|
||||
public npc_air_force_bots(Creature creature) : base(creature)
|
||||
{
|
||||
SpawnAssoc = null;
|
||||
@@ -492,9 +496,6 @@ namespace Scripts.World.NpcSpecial
|
||||
}
|
||||
}
|
||||
|
||||
SpawnAssociation SpawnAssoc;
|
||||
ObjectGuid SpawnedGUID;
|
||||
|
||||
public override void Reset() { }
|
||||
|
||||
Creature SummonGuard()
|
||||
@@ -521,6 +522,13 @@ namespace Scripts.World.NpcSpecial
|
||||
return null;
|
||||
}
|
||||
|
||||
public void UpdateAI(uint diff)
|
||||
{
|
||||
base.UpdateAI(diff);
|
||||
|
||||
inLineOfSightSinceLastUpdate.Clear();
|
||||
}
|
||||
|
||||
public override void MoveInLineOfSight(Unit who)
|
||||
{
|
||||
if (SpawnAssoc == null)
|
||||
@@ -544,6 +552,12 @@ namespace Scripts.World.NpcSpecial
|
||||
{
|
||||
case SpawnType.AlarmBot:
|
||||
{
|
||||
// handle only 1 change for world update for each target
|
||||
if (inLineOfSightSinceLastUpdate.Contains(who.GetGUID()))
|
||||
return;
|
||||
|
||||
inLineOfSightSinceLastUpdate.Add(who.GetGUID());
|
||||
|
||||
if (!who.IsWithinDistInMap(me, Misc.RangeGuardsMark))
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user