(a0156ed0f) Fixed characters running more slowly when their torso is in a different hull than the feet (for example in Humpback's bilge). Happened because the surfaceY value (water level) in empty hulls is at the bottom of the hull, and in this case the character was partially below the bottom, which got interpreted as being waist-deep in water.

This commit is contained in:
Joonas Rikkonen
2019-04-29 21:07:13 +03:00
parent 2be015f6f6
commit 8f94ee1eed
2 changed files with 5 additions and 1 deletions

View File

@@ -1056,6 +1056,8 @@ namespace Barotrauma
private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure;
private bool IsProperlyLatchedOnSub => LatchOntoAI != null && LatchOntoAI.IsAttachedToSub && SelectedAiTarget?.Entity == wallTarget?.Structure;
//goes through all the AItargets, evaluates how preferable it is to attack the target,
//whether the Character can see/hear the target and chooses the most preferable target within
//sight/hearing range

View File

@@ -550,9 +550,11 @@ namespace Barotrauma
float slowdownAmount = 0.0f;
if (currentHull != null)
{
//TODO: take into account that the feet aren't necessarily in CurrentHull
//full slowdown (1.5f) when water is up to the torso
surfaceY = ConvertUnits.ToSimUnits(currentHull.Surface);
slowdownAmount = MathHelper.Clamp((surfaceY - colliderPos.Y) / TorsoPosition.Value, 0.0f, 1.0f) * 1.5f;
float bottomPos = Math.Max(colliderPos.Y, currentHull.Rect.Y - currentHull.Rect.Height);
slowdownAmount = MathHelper.Clamp((surfaceY - bottomPos) / TorsoPosition.Value, 0.0f, 1.0f) * 1.5f;
}
float maxSpeed = Math.Max(TargetMovement.Length() - slowdownAmount, 1.0f);