diff --git a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs index aeaf5feb9..a377b7ca9 100644 --- a/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs +++ b/Subsurface/Source/Characters/AI/IndoorsSteeringManager.cs @@ -90,7 +90,9 @@ namespace Barotrauma var collider = character.AnimController.Collider; //if not in water and the waypoint is between the top and bottom of the collider, no need to move vertically - if (!character.AnimController.InWater && diff.Y < collider.height / 2 + collider.radius) + if (!character.AnimController.InWater && + character.AnimController.Anim != AnimController.Animation.Climbing && + diff.Y < collider.height / 2 + collider.radius) { diff.Y = 0.0f; } @@ -162,20 +164,31 @@ namespace Barotrauma if (character.AnimController.Anim == AnimController.Animation.Climbing) { - float x = currentPath.CurrentNode.SimPosition.X - pos.X; - float y = (currentPath.CurrentNode.SimPosition.Y) - pos.Y; + Vector2 diff = currentPath.CurrentNode.SimPosition - pos; - if (Math.Abs(x) < Math.Abs(y) * 10.0f) + if (currentPath.CurrentNode.Ladders != null) { - x = 0.0f; - } - else if (hull != null) - { - if (character.AnimController.GetColliderBottom().Y < hull.Rect.Y - hull.Rect.Height + 10.0f) x = 0.0f; + //climbing ladders -> don't move horizontally + diff.X = 0.0f; + + //at the same height as the waypoint + if (currentPath.CurrentNode.SimPosition.Y > colliderBottom.Y && + currentPath.CurrentNode.SimPosition.Y < colliderBottom.Y + collider.height + collider.radius * 2) + { + float heightFromFloor = character.AnimController.GetColliderBottom().Y - character.AnimController.FloorY; + + //we can safely skip to the next waypoint if the character is at a safe height above the floor, + //or if the next waypoint in the path is also on ladders + if ((heightFromFloor > 0.0f && heightFromFloor < collider.height) || + (currentPath.NextNode != null && currentPath.NextNode.Ladders != null)) + { + currentPath.SkipToNextNode(); + } + } } character.AnimController.IgnorePlatforms = false; - return new Vector2(x,y); + return diff; } return currentPath.CurrentNode.SimPosition - pos; diff --git a/Subsurface/Source/Characters/AI/PathFinder.cs b/Subsurface/Source/Characters/AI/PathFinder.cs index 90b8639ed..45dd9a4c5 100644 --- a/Subsurface/Source/Characters/AI/PathFinder.cs +++ b/Subsurface/Source/Characters/AI/PathFinder.cs @@ -172,7 +172,7 @@ namespace Barotrauma start, node.Waypoint.SimPosition, null, Physics.CollisionWall | Physics.CollisionLevel | Physics.CollisionStairs | Physics.CollisionPlatform); - if (body != null && body.UserData is Structure) continue; + if (body != null && body.UserData is Structure && !((Structure)body.UserData).IsPlatform) continue; } closestDist = dist; diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs index 4b1d15c29..d6e56fa69 100644 --- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs @@ -691,6 +691,9 @@ namespace Barotrauma IgnorePlatforms = true; Vector2 tempTargetMovement = TargetMovement; + + tempTargetMovement.Y = Math.Min(tempTargetMovement.Y, 1.0f); + movement = MathUtils.SmoothStep(movement, tempTargetMovement, 0.3f); Limb leftFoot = GetLimb(LimbType.LeftFoot); @@ -717,15 +720,15 @@ namespace Barotrauma { ladderSimPos += character.SelectedConstruction.Submarine.SimPosition - currentHull.Submarine.SimPosition; } - - - + MoveLimb(head, new Vector2(ladderSimPos.X - 0.27f * Dir, collider.SimPosition.Y + 0.7f), 10.5f); MoveLimb(torso, new Vector2(ladderSimPos.X - 0.27f * Dir, collider.SimPosition.Y+0.5f), 10.5f); MoveLimb(waist, new Vector2(ladderSimPos.X - 0.35f * Dir, collider.SimPosition.Y+0.4f), 10.5f); collider.MoveToPos(new Vector2(ladderSimPos.X - 0.2f * Dir, collider.SimPosition.Y), 10.5f); - + + bool slide = targetMovement.Y < -1.1f; + Vector2 handPos = new Vector2( ladderSimPos.X, collider.SimPosition.Y + 0.6f + movement.Y * 0.1f - ladderSimPos.Y); @@ -734,12 +737,12 @@ namespace Barotrauma MoveLimb(leftHand, new Vector2(handPos.X, - MathUtils.Round(handPos.Y - stepHeight, stepHeight * 2.0f) + stepHeight + ladderSimPos.Y), + (slide ? handPos.Y : MathUtils.Round(handPos.Y - stepHeight, stepHeight * 2.0f) + stepHeight) + ladderSimPos.Y), 5.2f); MoveLimb(rightHand, new Vector2(handPos.X, - MathUtils.Round(handPos.Y, stepHeight * 2.0f) + ladderSimPos.Y), + (slide ? handPos.Y : MathUtils.Round(handPos.Y, stepHeight * 2.0f)) + ladderSimPos.Y), 5.2f); leftHand.body.ApplyTorque(Dir * 2.0f); @@ -753,12 +756,12 @@ namespace Barotrauma MoveLimb(leftFoot, new Vector2(footPos.X, - MathUtils.Round(footPos.Y + stepHeight, stepHeight * 2.0f) - stepHeight + ladderSimPos.Y), + (slide ? footPos.Y : MathUtils.Round(footPos.Y + stepHeight, stepHeight * 2.0f) - stepHeight) + ladderSimPos.Y), 15.5f, true); MoveLimb(rightFoot, new Vector2(footPos.X, - MathUtils.Round(footPos.Y, stepHeight * 2.0f) + ladderSimPos.Y), + (slide ? footPos.Y : MathUtils.Round(footPos.Y, stepHeight * 2.0f)) + ladderSimPos.Y), 15.5f, true); //apply torque to the legs to make the knees bend diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index a6690aec9..8c0d962e3 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -459,9 +459,12 @@ namespace Barotrauma { if (!character.IsNetworkPlayer || GameMain.Server != null) { - character.AddDamage(CauseOfDeath.Damage, impact - 8.0f, null); - if (impact > 8.0f) SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, collider); - strongestImpact = Math.Max(strongestImpact, impact - 8.0f); + if (impact > 8.0f) + { + character.AddDamage(CauseOfDeath.Damage, impact - 8.0f, null); + SoundPlayer.PlayDamageSound(DamageSoundType.LimbBlunt, strongestImpact, collider); + strongestImpact = Math.Max(strongestImpact, impact - 8.0f); + } } diff --git a/Subsurface/Source/Items/Components/Projectile.cs b/Subsurface/Source/Items/Components/Projectile.cs index 06571e940..c525bb5a1 100644 --- a/Subsurface/Source/Items/Components/Projectile.cs +++ b/Subsurface/Source/Items/Components/Projectile.cs @@ -49,19 +49,11 @@ namespace Barotrauma.Items.Components { IgnoredBodies = new List(); - //launchImpulse = ToolBox.GetAttributeFloat(element, "launchimpulse", 10.0f); - //characterUsable = ToolBox.GetAttributeBool(element, "characterusable", false); - foreach (XElement subElement in element.Elements()) { if (subElement.Name.ToString().ToLowerInvariant() != "attack") continue; attack = new Attack(subElement); } - - //bleedingDamage = ToolBox.GetAttributeFloat(element, "bleedingdamage", 0.0f); - //bluntDamage = ToolBox.GetAttributeFloat(element, "bluntdamage", 0.0f); - - //doesStick = ToolBox.GetAttributeBool(element, "doesstick", false); } public override bool Use(float deltaTime, Character character = null) @@ -150,6 +142,11 @@ namespace Barotrauma.Items.Components { if (IgnoredBodies.Contains(f2.Body)) return false; + if (f2.CollisionCategories == Physics.CollisionCharacter && !(f2.Body.UserData is Limb)) + { + return false; + } + AttackResult attackResult = new AttackResult(0.0f, 0.0f); if (attack != null) { diff --git a/Subsurface/Source/Physics/Physics.cs b/Subsurface/Source/Physics/Physics.cs index 69fa6f870..e63b97173 100644 --- a/Subsurface/Source/Physics/Physics.cs +++ b/Subsurface/Source/Physics/Physics.cs @@ -6,8 +6,6 @@ namespace Barotrauma { static class Physics { - private static double alpha; - public const Category CollisionNone = Category.None; public const Category CollisionAll = Category.All; public const Category CollisionWall = Category.Cat1;