diff --git a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs index c39220035..eb6f9cdfe 100644 --- a/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs +++ b/Subsurface/Source/Characters/Animation/HumanoidAnimController.cs @@ -915,22 +915,31 @@ namespace Barotrauma Limb leftHand = GetLimb(LimbType.LeftHand); Limb rightHand = GetLimb(LimbType.RightHand); + //only grab with one hand when swimming leftHand.Disabled = true; - rightHand.Disabled = true; + if (!inWater) rightHand.Disabled = true; for (int i = 0; i < 2; i++ ) { - LimbType type = i == 0 ? rightHandTarget : leftHandTarget; + LimbType type = i == 0 ? leftHandTarget: rightHandTarget; Limb targetLimb = target.AnimController.GetLimb(type); - Limb pullLimb = GetLimb(i == 0 ? LimbType.RightHand : LimbType.LeftHand); + Limb pullLimb = GetLimb(i == 0 ?LimbType.LeftHand: LimbType.RightHand); - pullLimb.pullJoint.Enabled = true; - pullLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition; - pullLimb.pullJoint.MaxForce = 500.0f; + if (i==1 && inWater) + { + targetLimb.pullJoint.Enabled = false; + } + else + { + pullLimb.pullJoint.Enabled = true; + pullLimb.pullJoint.WorldAnchorB = targetLimb.SimPosition; + pullLimb.pullJoint.MaxForce = 100.0f; + + targetLimb.pullJoint.Enabled = true; + targetLimb.pullJoint.WorldAnchorB = pullLimb.SimPosition; + } - targetLimb.pullJoint.Enabled = true; - targetLimb.pullJoint.WorldAnchorB = pullLimb.SimPosition; } @@ -1142,8 +1151,8 @@ namespace Barotrauma case LimbType.LeftArm: case LimbType.RightHand: case LimbType.RightArm: - mirror = true; - flipAngle = true; + mirror = !inWater; + flipAngle = !inWater; break; case LimbType.LeftThigh: case LimbType.LeftLeg: diff --git a/Subsurface/Source/Characters/Animation/Ragdoll.cs b/Subsurface/Source/Characters/Animation/Ragdoll.cs index ca0916238..658f3ec99 100644 --- a/Subsurface/Source/Characters/Animation/Ragdoll.cs +++ b/Subsurface/Source/Characters/Animation/Ragdoll.cs @@ -706,7 +706,7 @@ namespace Barotrauma limbHull.WaveVel[n] = Math.Min(impulse.Y * 1.0f, 5.0f); StrongestImpact = ((impulse.Length() * 0.5f) - limb.impactTolerance); } - } + } } limb.Update(deltaTime); @@ -719,46 +719,35 @@ namespace Barotrauma foreach (Limb limb in Limbs) { - if (limb==refLimb) - { - if (lerp) - { - limb.body.TargetPosition = simPosition; - } - else - { - limb.body.SetTransform(simPosition, limb.Rotation); - } - continue; - } - - //check visibility from the new position of RefLimb to the new position of this limb Vector2 movePos = limb.SimPosition + moveAmount; TrySetLimbPosition(limb, simPosition, movePos, lerp); - - } } protected void TrySetLimbPosition(Limb limb, Vector2 original, Vector2 simPosition, bool lerp = false) { - if (original == simPosition) return; - - Body body = Submarine.CheckVisibility(original, simPosition); Vector2 movePos = simPosition; - //if there's something in between the limbs - if (body != null) + if (original != simPosition) { - //move the limb close to the position where the raycast hit something - movePos = original + ((simPosition - original) * Submarine.LastPickedFraction * 0.9f); + Body body = Submarine.CheckVisibility(original, simPosition); + + + //if there's something in between the limbs + if (body != null) + { + //move the limb close to the position where the raycast hit something + movePos = original + ((simPosition - original) * Submarine.LastPickedFraction * 0.9f); + } } - if (lerp) + if (lerp) { limb.body.TargetPosition = movePos; + limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, movePos) < 10.0f); + } else { @@ -868,21 +857,7 @@ namespace Barotrauma { System.Diagnostics.Debug.WriteLine("reset ragdoll limb positions"); - if (this is HumanoidAnimController) - { - foreach (Limb limb in Limbs) - { - if (limb != refLimb) limb.body.TargetPosition = limb.body.SimPosition + diff; - limb.body.MoveToTargetPosition(Vector2.Distance(limb.SimPosition, limb.body.TargetPosition) < 10.0f); - - limb.body.LinearVelocity = Vector2.Zero; - limb.body.AngularVelocity = 0.0f; - } - } - else - { - SetPosition(refLimb.body.TargetPosition); - } + SetPosition(refLimb.body.TargetPosition, true); } } diff --git a/Subsurface/Source/Characters/CharacterHUD.cs b/Subsurface/Source/Characters/CharacterHUD.cs index 3c7b9c839..26e43405c 100644 --- a/Subsurface/Source/Characters/CharacterHUD.cs +++ b/Subsurface/Source/Characters/CharacterHUD.cs @@ -99,7 +99,7 @@ namespace Barotrauma limb.pullJoint.Enabled = false; } - new NetworkEvent(NetworkEventType.SelectCharacter, Character.Controlled.ID, true, Character.Controlled.SelectedCharacter); + new NetworkEvent(NetworkEventType.SelectCharacter, Character.Controlled.ID, true, Character.Controlled.SelectedCharacter.ID); return true; }; diff --git a/Subsurface/Source/Items/Item.cs b/Subsurface/Source/Items/Item.cs index df8dc53dd..3592f75e1 100644 --- a/Subsurface/Source/Items/Item.cs +++ b/Subsurface/Source/Items/Item.cs @@ -747,11 +747,17 @@ namespace Barotrauma private bool OnCollision(Fixture f1, Fixture f2, Contact contact) { + if (GameMain.Client != null) return true; + Vector2 normal = contact.Manifold.LocalNormal; float impact = Vector2.Dot(f1.Body.LinearVelocity, -normal); - if (ImpactTolerance > 0.0f && impact > ImpactTolerance) ApplyStatusEffects(ActionType.OnImpact, 1.0f); + if (ImpactTolerance > 0.0f && impact > ImpactTolerance) + { + ApplyStatusEffects(ActionType.OnImpact, 1.0f); + new NetworkEvent(NetworkEventType.ApplyStatusEffect, this.ID, false, ActionType.OnImpact); + } var containedItems = ContainedItems; if (containedItems != null) @@ -1566,6 +1572,12 @@ namespace Barotrauma bool sent = components[componentIndex].FillNetworkData(type, message); if (sent) components[componentIndex].NetworkUpdateSent = true; return sent; + case NetworkEventType.ApplyStatusEffect: + + ActionType actionType = (ActionType)data; + message.WriteRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length, (int)actionType); + + return true; case NetworkEventType.UpdateProperty: var allProperties = GetProperties(); @@ -1658,6 +1670,15 @@ namespace Barotrauma components[componentIndex].NetworkUpdateSent = true; components[componentIndex].ReadNetworkData(type, message, sendingTime); + break; + case NetworkEventType.ApplyStatusEffect: + + ActionType actionType = (ActionType)message.ReadRangedInteger(0, Enum.GetValues(typeof(ActionType)).Length); + + data = actionType; + + ApplyStatusEffects(actionType, 1.0f); + break; case NetworkEventType.UpdateProperty: string propertyName = ""; diff --git a/Subsurface/Source/Map/Levels/Level.cs b/Subsurface/Source/Map/Levels/Level.cs index 36760a5d3..53f8c12c6 100644 --- a/Subsurface/Source/Map/Levels/Level.cs +++ b/Subsurface/Source/Map/Levels/Level.cs @@ -340,6 +340,8 @@ namespace Barotrauma //couldn't find a place for a cave -> abort if (tries >= maxTries) break; + if (!caveCells.Any()) continue; + usedCaveCells.AddRange(caveCells); List caveSolidCells;