diff --git a/Subsurface/Source/Characters/AI/HumanAIController.cs b/Subsurface/Source/Characters/AI/HumanAIController.cs index 55f64059b..b0dc59834 100644 --- a/Subsurface/Source/Characters/AI/HumanAIController.cs +++ b/Subsurface/Source/Characters/AI/HumanAIController.cs @@ -12,10 +12,7 @@ namespace Barotrauma const float UpdateObjectiveInterval = 0.5f; private AIObjectiveManager objectiveManager; - - private IndoorsSteeringManager indoorsSteeringManager; - private SteeringManager outdoorsSteeringManager; - + private AITarget selectedAiTarget; private float updateObjectiveTimer; @@ -34,8 +31,7 @@ namespace Barotrauma public HumanAIController(Character c) : base(c) { - indoorsSteeringManager = new IndoorsSteeringManager(this, true); - outdoorsSteeringManager = new SteeringManager(this); + steeringManager = new IndoorsSteeringManager(this, true); objectiveManager = new AIObjectiveManager(c); objectiveManager.AddObjective(new AIObjectiveFindSafety(c)); @@ -48,7 +44,7 @@ namespace Barotrauma { Character.ClearInputs(); - steeringManager = Character.AnimController.CurrentHull == null ? outdoorsSteeringManager : indoorsSteeringManager; + //steeringManager = Character.AnimController.CurrentHull == null ? outdoorsSteeringManager : indoorsSteeringManager; if (updateObjectiveTimer>0.0f) { diff --git a/Subsurface/Source/Characters/AI/ISteerable.cs b/Subsurface/Source/Characters/AI/ISteerable.cs index efafca9d9..561d363f8 100644 --- a/Subsurface/Source/Characters/AI/ISteerable.cs +++ b/Subsurface/Source/Characters/AI/ISteerable.cs @@ -21,5 +21,7 @@ namespace Barotrauma get; } + + } } diff --git a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs index 4c1f53109..d4b0f0b95 100644 --- a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs @@ -72,7 +72,13 @@ namespace Barotrauma if (findPathTimer > 0.0f) return Vector2.Zero; currentTarget = target; - currentPath = pathFinder.FindPath(host.SimPosition, target); + Vector2 pos = host.SimPosition; + if (character!=null && character.Submarine==null) + { + pos -= Submarine.Loaded.SimPosition; + } + + currentPath = pathFinder.FindPath(pos, target); findPathTimer = Rand.Range(1.0f,1.2f); @@ -95,7 +101,13 @@ namespace Barotrauma float allowedDistance = character.AnimController.InWater ? 1.0f : 0.6f; if (currentPath.CurrentNode!=null && currentPath.CurrentNode.SimPosition.Y > character.SimPosition.Y+1.0f) allowedDistance*=0.5f; - currentPath.CheckProgress(host.SimPosition, allowedDistance); + Vector2 pos = host.SimPosition; + if (character != null && character.Submarine == null) + { + pos -= Submarine.Loaded.SimPosition; + } + + currentPath.CheckProgress(pos, allowedDistance); if (currentPath.CurrentNode == null) return Vector2.Zero; @@ -104,7 +116,7 @@ namespace Barotrauma // return currentPath.PrevNode.SimPosition - host.SimPosition; //} - return currentPath.CurrentNode.SimPosition - host.SimPosition; + return currentPath.CurrentNode.SimPosition - pos; } private void CheckDoorsInPath() diff --git a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs index c8a38af87..d1f771847 100644 --- a/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs +++ b/Subsurface/Source/Characters/AI/Objectives/AIObjectiveGoTo.cs @@ -76,7 +76,11 @@ namespace Barotrauma //if character is outside the sub and target isn't, transform the position if (character.Submarine == null && target.Submarine != null) { - currTargetPos += target.Submarine.SimPosition; + //currTargetPos += target.Submarine.SimPosition; + } + else if (target.Submarine==null) + { + currTargetPos -= Submarine.Loaded.SimPosition; } } diff --git a/Subsurface/Source/Characters/AI/PathFinder.cs b/Subsurface/Source/Characters/AI/PathFinder.cs index f76c31ba4..8f0c0d99a 100644 --- a/Subsurface/Source/Characters/AI/PathFinder.cs +++ b/Subsurface/Source/Characters/AI/PathFinder.cs @@ -103,10 +103,10 @@ namespace Barotrauma Vector2 nodePos = node.Position; //if node waypoint is one of submarine waypoints outside the sub, transform position - if (node.Waypoint != null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull == null) - { - nodePos -= node.Waypoint.Submarine.Position; - } + //if (node.Waypoint != null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull == null) + //{ + // nodePos -= node.Waypoint.Submarine.Position; + //} float dist = System.Math.Abs(start.X-nodePos.X)+ System.Math.Abs(start.Y - nodePos.Y)*10.0f + @@ -135,10 +135,10 @@ namespace Barotrauma Vector2 nodePos = node.Position; //if node waypoint is one of submarine waypoints outside the sub, transform position - if (node.Waypoint!=null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull==null) - { - nodePos -= node.Waypoint.Submarine.Position; - } + //if (node.Waypoint!=null && node.Waypoint.Submarine != null && node.Waypoint.CurrentHull==null) + //{ + // nodePos -= node.Waypoint.Submarine.Position; + //} float dist = Vector2.Distance(end, nodePos); if (dist < closestDist || endNode == null) diff --git a/Subsurface_Solution.v12.suo b/Subsurface_Solution.v12.suo index 4f23039e9..3f194edd7 100644 Binary files a/Subsurface_Solution.v12.suo and b/Subsurface_Solution.v12.suo differ