- 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

View File

@@ -27,7 +27,14 @@ namespace Barotrauma
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)
{

View File

@@ -85,7 +85,7 @@
<!-- head to body -->
<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 -->
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>

View File

@@ -93,7 +93,7 @@
<!-- head to body -->
<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 -->
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>

View File

@@ -94,9 +94,9 @@
<!-- head to body -->
<joint limb1="0" limb1anchor="-10,-10" limb2="1" limb2anchor="-3,28" lowerlimit="0" upperlimit="10" canbesevered="true"/>
<!-- 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 -->
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>

View File

@@ -556,7 +556,7 @@ namespace Barotrauma
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
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)
{
//only one limb left, the character is now full eaten

View File

@@ -1,4 +1,5 @@
using FarseerPhysics;
using Barotrauma.Networking;
using FarseerPhysics;
using FarseerPhysics.Dynamics;
using FarseerPhysics.Dynamics.Contacts;
using FarseerPhysics.Dynamics.Joints;
@@ -388,7 +389,7 @@ namespace Barotrauma
limb2Pos = ConvertUnits.ToSimUnits(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)
{
@@ -522,6 +523,11 @@ namespace Barotrauma
public void SeverLimbJoint(LimbJoint limbJoint)
{
if (!limbJoint.CanBeSevered)
{
return;
}
limbJoint.IsSevered = true;
limbJoint.Enabled = false;
@@ -536,6 +542,11 @@ namespace Barotrauma
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)