Skip to content

Commit 4601f7f

Browse files
committed
Fix guard archers / immobile ranged NPCs rare null reference exception when their target breaks LoS or gets out of range
1 parent a07f0d5 commit 4601f7f

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

GameServer/ECS-Components/Actions/NpcAttackAction.cs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,10 @@ public override bool OnOutOfRangeOrNoLosRangedAttack()
4545
{
4646
GameObject oldTarget = _target;
4747
StandardMobBrain brain = _npcOwner.Brain as StandardMobBrain;
48-
brain.RemoveFromAggroList(_losCheckTarget as GameLiving);
48+
49+
if (_losCheckTarget is GameLiving livingLosCheckTarget)
50+
brain.RemoveFromAggroList(livingLosCheckTarget);
51+
4952
brain.AttackMostWanted(); // This won't immediately start the attack on the new target, but we can use `TargetObject` to start checking it.
5053
GameObject newTarget = _npcOwner.TargetObject;
5154

0 commit comments

Comments
 (0)