From 5a9b681c134f3b6a25d41e331ad6c3d8e65a0d47 Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Mon, 8 Apr 2019 19:17:35 +0300 Subject: [PATCH] (8c99939f6) Fix bots dropping from ladders if there is a non-ladder node in the path (Especially on Typhon). The distance check was incorrect, but after correcting it, I decided that it probably causes more issues than it solves. If there is one node in the path that is not in the current ladder, but the node after that is, we can just follow the path to the node that is on the ladders. Remove an unnecessary IgnorePlatforms assignment. It's handled in the HumanAIController. --- .../Source/GameSession/CrewManager.cs | 3 +++ .../Characters/AI/IndoorsSteeringManager.cs | 21 +++++++------------ .../BarotraumaShared/Source/PlayerInput.cs | 10 --------- 3 files changed, 11 insertions(+), 23 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index 1a7eaf05b..6b9d55aee 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -276,6 +276,9 @@ namespace Barotrauma characterInfos.Add(characterInfo); } + characterInfos.Add(characterInfo); + } + /// /// Remove the character from the crew (and crew menus). /// diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs index 6c3d6ba8a..da327ea2d 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/IndoorsSteeringManager.cs @@ -77,8 +77,6 @@ namespace Barotrauma { var node = currentPath.Nodes[index]; if (node == null) { return false; } - // Only applied if the node is close enough to the current node. - if (Vector2.DistanceSquared(currentPath.CurrentNode.WorldPosition, node.WorldPosition) > 100) { return false; } return node.Ladders != null; } return false; @@ -108,10 +106,9 @@ namespace Barotrauma { var node = currentPath.Nodes[index]; if (node == null) { return false; } - // Only applied if the node is close enough to the current node. - if (Vector2.DistanceSquared(currentPath.CurrentNode.WorldPosition, node.WorldPosition) > 100) { return false; } nextLadder = node.Ladders; - return nextLadder != null && nextLadder == currentLadder; + bool isSame = nextLadder != null && nextLadder == currentLadder; + return isSame; } return false; } @@ -227,7 +224,7 @@ namespace Barotrauma } //only humanoids can climb ladders - if (character.AnimController is HumanoidAnimController && InLadders && IsNextLadderSameAsCurrent) + if (character.AnimController is HumanoidAnimController && IsNextLadderSameAsCurrent) { if (character.SelectedConstruction != currentPath.CurrentNode.Ladders.Item && currentPath.CurrentNode.Ladders.Item.IsInsideTrigger(character.WorldPosition)) @@ -240,9 +237,9 @@ namespace Barotrauma if (character.IsClimbing) { Vector2 diff = currentPath.CurrentNode.SimPosition - pos; - bool nextLadderSamesCurrent = IsNextLadderSameAsCurrent; + bool nextLadderSameAsCurrent = IsNextLadderSameAsCurrent; - if (nextLadderSamesCurrent) + if (nextLadderSameAsCurrent) { //climbing ladders -> don't move horizontally diff.X = 0.0f; @@ -257,17 +254,17 @@ namespace Barotrauma diff.Y = Math.Max(diff.Y, 1.0f); } - bool aboveFloor = heightFromFloor > 0.0f && heightFromFloor < collider.height * 1.5f; + bool aboveFloor = heightFromFloor > 0 && heightFromFloor < collider.height * 1.5f; if (aboveFloor || IsNextNodeLadder) { - if (!nextLadderSamesCurrent) + if (!nextLadderSameAsCurrent) { character.AnimController.Anim = AnimController.Animation.None; } currentPath.SkipToNextNode(); } } - else if (nextLadderSamesCurrent) + else if (nextLadderSameAsCurrent) { //if the current node is below the character and the next one is above (or vice versa) //and both are on ladders, we can skip directly to the next one @@ -277,8 +274,6 @@ namespace Barotrauma currentPath.SkipToNextNode(); } } - - character.AnimController.IgnorePlatforms = false; return diff; } else if (character.AnimController.InWater) diff --git a/Barotrauma/BarotraumaShared/Source/PlayerInput.cs b/Barotrauma/BarotraumaShared/Source/PlayerInput.cs index 21475b092..a10a8c412 100644 --- a/Barotrauma/BarotraumaShared/Source/PlayerInput.cs +++ b/Barotrauma/BarotraumaShared/Source/PlayerInput.cs @@ -145,16 +145,6 @@ namespace Barotrauma } #endif - public void SetState() - { - hit = binding.IsHit(); - if (hit) hitQueue = true; - - held = binding.IsDown(); - if (held) heldQueue = true; - } -#endif - public bool Hit { get