- Fixed creatures being able to sever non-severable limb joints (which caused syncing issues when the waist->torso joint of a humanoid was severed).

- The server creates an entity event when a joint is severed.
- Made joints severable by default.
This commit is contained in:
Joonas Rikkonen
2017-09-21 17:50:24 +03:00
parent dd86b5745a
commit 8c3c689596
6 changed files with 26 additions and 8 deletions
@@ -27,7 +27,14 @@ namespace Barotrauma
if (GameMain.DebugDraw) if (GameMain.DebugDraw)
{ {
if (!body.Awake) color = Color.Blue; if (!body.Enabled)
{
color = Color.Gray;
}
else if (!body.Awake)
{
color = Color.Blue;
}
if (targetPosition != null) if (targetPosition != null)
{ {
@@ -85,7 +85,7 @@
<!-- head to body --> <!-- head to body -->
<joint limb1="0" limb1anchor="0,-7" limb2="1" limb2anchor="-1,26" lowerlimit="-90" upperlimit="45" canbesevered="true"/> <joint limb1="0" limb1anchor="0,-7" limb2="1" limb2anchor="-1,26" lowerlimit="-90" upperlimit="45" canbesevered="true"/>
<joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,7" lowerlimit="-10" upperlimit="10"/> <joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,7" lowerlimit="-10" upperlimit="10" canbesevered="false"/>
<!-- body to left arm --> <!-- body to left arm -->
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/> <joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>
@@ -93,7 +93,7 @@
<!-- head to body --> <!-- head to body -->
<joint limb1="0" limb1anchor="0,-7" limb2="1" limb2anchor="-1,26" lowerlimit="-90" upperlimit="45" canbesevered="true"/> <joint limb1="0" limb1anchor="0,-7" limb2="1" limb2anchor="-1,26" lowerlimit="-90" upperlimit="45" canbesevered="true"/>
<joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,7" lowerlimit="-10" upperlimit="10"/> <joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,7" lowerlimit="-10" upperlimit="10" canbesevered="false"/>
<!-- body to left arm --> <!-- body to left arm -->
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/> <joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>
@@ -94,9 +94,9 @@
<!-- head to body --> <!-- head to body -->
<joint limb1="0" limb1anchor="-10,-10" limb2="1" limb2anchor="-3,28" lowerlimit="0" upperlimit="10" canbesevered="true"/> <joint limb1="0" limb1anchor="-10,-10" limb2="1" limb2anchor="-3,28" lowerlimit="0" upperlimit="10" canbesevered="true"/>
<!-- spike to head --> <!-- spike to head -->
<joint limb1="0" limb1anchor="35,-8" limb2="13" limb2anchor="30,0" lowerlimit="-40" upperlimit="0"/> <joint limb1="0" limb1anchor="35,-8" limb2="13" limb2anchor="30,0" lowerlimit="-40" upperlimit="0" canbesevered="false"/>
<joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,15" lowerlimit="30" upperlimit="60"/> <joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,15" lowerlimit="30" upperlimit="60" canbesevered="false"/>
<!-- body to left arm --> <!-- body to left arm -->
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/> <joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>
@@ -556,7 +556,7 @@ namespace Barotrauma
targetCharacter.AnimController.MainLimb.AddDamage(targetCharacter.SimPosition, DamageType.None, Rand.Range(10.0f, 25.0f), 10.0f, false); targetCharacter.AnimController.MainLimb.AddDamage(targetCharacter.SimPosition, DamageType.None, Rand.Range(10.0f, 25.0f), 10.0f, false);
//keep severing joints until there is only one limb left //keep severing joints until there is only one limb left
LimbJoint[] nonSeveredJoints = Array.FindAll(targetCharacter.AnimController.LimbJoints, l => !l.IsSevered); LimbJoint[] nonSeveredJoints = Array.FindAll(targetCharacter.AnimController.LimbJoints, l => !l.IsSevered && l.CanBeSevered);
if (nonSeveredJoints.Length == 0) if (nonSeveredJoints.Length == 0)
{ {
//only one limb left, the character is now full eaten //only one limb left, the character is now full eaten
@@ -1,4 +1,5 @@
using FarseerPhysics; using Barotrauma.Networking;
using FarseerPhysics;
using FarseerPhysics.Dynamics; using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts; using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Dynamics.Joints; using FarseerPhysics.Dynamics.Joints;
@@ -388,7 +389,7 @@ namespace Barotrauma
limb2Pos = ConvertUnits.ToSimUnits(limb2Pos); limb2Pos = ConvertUnits.ToSimUnits(limb2Pos);
LimbJoint joint = new LimbJoint(Limbs[limb1ID], Limbs[limb2ID], limb1Pos, limb2Pos); LimbJoint joint = new LimbJoint(Limbs[limb1ID], Limbs[limb2ID], limb1Pos, limb2Pos);
joint.CanBeSevered = ToolBox.GetAttributeBool(subElement, "canbesevered", false); joint.CanBeSevered = ToolBox.GetAttributeBool(subElement, "canbesevered", true);
if (subElement.Attribute("lowerlimit") != null) if (subElement.Attribute("lowerlimit") != null)
{ {
@@ -522,6 +523,11 @@ namespace Barotrauma
public void SeverLimbJoint(LimbJoint limbJoint) public void SeverLimbJoint(LimbJoint limbJoint)
{ {
if (!limbJoint.CanBeSevered)
{
return;
}
limbJoint.IsSevered = true; limbJoint.IsSevered = true;
limbJoint.Enabled = false; limbJoint.Enabled = false;
@@ -536,6 +542,11 @@ namespace Barotrauma
limb.IsSevered = true; limb.IsSevered = true;
} }
} }
if (GameMain.Server != null)
{
GameMain.Server.CreateEntityEvent(character, new object[] { NetEntityEvent.Type.Status });
}
} }
private void GetConnectedLimbs(List<Limb> connectedLimbs, List<LimbJoint> checkedJoints, Limb limb) private void GetConnectedLimbs(List<Limb> connectedLimbs, List<LimbJoint> checkedJoints, Limb limb)