From 440393d0cda64e1205e62c40da988fab83949c0e Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Tue, 4 Jun 2019 16:40:41 +0300 Subject: [PATCH] (87a0f7ac8) If the bot is on a different level than the target, keep running to the target. i.e. Cannot use linear distance calculation inside the sub. --- .../Source/Characters/AI/HumanAIController.cs | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index 2f176e100..8cfa6da08 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -150,7 +150,23 @@ namespace Barotrauma bool run = objectiveManager.CurrentObjective.ForceRun || objectiveManager.GetCurrentPriority() > AIObjectiveManager.RunPriority; if (ObjectiveManager.CurrentObjective is AIObjectiveGoTo goTo && goTo.Target != null) { - run = Vector2.DistanceSquared(Character.WorldPosition, goTo.Target.WorldPosition) > 300 * 300; + if (Character.CurrentHull == null) + { + run = Vector2.DistanceSquared(Character.WorldPosition, goTo.Target.WorldPosition) > 300 * 300; + } + else + { + float yDiff = goTo.Target.WorldPosition.Y - Character.WorldPosition.Y; + if (Math.Abs(yDiff) > 100) + { + run = true; + } + else + { + float xDiff = goTo.Target.WorldPosition.X - Character.WorldPosition.X; + run = Math.Abs(xDiff) > 300; + } + } } if (run) {