anegostudios / VintageStory-Issues

Vintage Story's public issue tracker for reporting bugs, crashes and the like
46 stars 16 forks source link

Tamed locust crashing when attempting to teleport to player #1876

Closed G3rste closed 2 years ago

G3rste commented 2 years ago

Game Version: 1.16.5
Platform: Windows Modded: No SP/MP: Multiplayer

Description

The issue arises with tamed locusts. The error arises during the execution of AiTaskSeekEntity. It looks like the path finder did not succeed in finding a way to the entity the pet locust wanted to attack. This triggers the Taskmanagers OnNoPath Method which then loops through all Aitasks and executes their personal OnNoPath Methods. This leads to the OnNoPath Method of the AiTaskStayCloseToEntity being executed. This task isnt even running at this very moment and might therefore not be initialized correctly (my guess is the targetentity still being null, maybe due to the player being offline)

How to reproduce

I sadly do not have a way of consistently reproducing this. my guess is that it happens when a tamed locust tries to teleport to its owner altough the owner is offline.

Expected behavior

As the OnNoPath method of the locust teleports the locust to their owner, I would assume that this should only be executed if the AiTaskStayCloseToEntity is being active at the moment.

Screenshots

-

Logs

12.4.2022 01:32:19 [Fatal] System.NullReferenceException: Object reference not set to an instance of an object.
   at Vintagestory.GameContent.AiTaskStayCloseToEntity.findDecentTeleportPos()
   at Vintagestory.GameContent.AiTaskStayCloseToEntity.tryTeleport()
   at Vintagestory.GameContent.AiTaskManager.OnNoPath(Vec3d target)
   at Vintagestory.API.Common.EntityAgent.OnNoPath(Vec3d target)
   at Vintagestory.Essentials.WaypointsTraverser.NavigateTo(Vec3d target, Single movingSpeed, Single targetDistance, Action OnGoalReached, Action OnStuck, Boolean giveUpWhenNoPath, Int32 searchDepth, Boolean allowReachAlmost)
   at Vintagestory.GameContent.AiTaskSeekEntity.ContinueExecute(Single dt)
   at Vintagestory.GameContent.AiTaskManager.OnGameTick(Single dt)
   at Vintagestory.GameContent.EntityBehaviorTaskAI.OnGameTick(Single deltaTime)
   at Vintagestory.API.Common.Entities.Entity.OnGameTick(Single dt)
   at Vintagestory.API.Common.EntityAgent.OnGameTick(Single dt)
   at Vintagestory.GameContent.EntityLocust.OnGameTick(Single dt)
   at Vintagestory.Server.ServerSystemEntitySimulation.TickEntities(Single dt)
   at Vintagestory.Server.ServerSystemEntitySimulation.OnServerTick(Single dt)
   at Vintagestory.Server.ServerMain.Process()
12.4.2022 01:32:19 [Fatal] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
   at System.ThrowHelper.ThrowArgumentOutOfRangeException(ExceptionArgument argument, ExceptionResource resource)
   at Vintagestory.Essentials.WaypointsTraverser.OnGameTick(Single dt)
   at Vintagestory.GameContent.EntityBehaviorTaskAI.OnGameTick(Single deltaTime)
   at Vintagestory.API.Common.Entities.Entity.OnGameTick(Single dt)
   at Vintagestory.API.Common.EntityAgent.OnGameTick(Single dt)
   at Vintagestory.GameContent.EntityLocust.OnGameTick(Single dt)
   at Vintagestory.Server.ServerSystemEntitySimulation.TickEntities(Single dt)
   at Vintagestory.Server.ServerSystemEntitySimulation.OnServerTick(Single dt)
   at Vintagestory.Server.ServerMain.Process()
G3rste commented 2 years ago

Has been fixed: https://github.com/anegostudios/vsessentialsmod/blob/master/Entity/AI/Task/TasksImpl/AiTaskStayCloseToEntity.cs#L159