Progress on making creatures eat each other, waists of humanoid characters can't be severed from the torso because they're used to anchor colliders to dead characters
This commit is contained in:
@@ -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" canbesevered="true"/>
|
||||
<joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,7" lowerlimit="-10" upperlimit="10"/>
|
||||
|
||||
<!-- body to left arm -->
|
||||
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
impacttolerance="7.5">
|
||||
|
||||
<collider height="80" radius="15"/>
|
||||
<collider height="40" radius="15"/>
|
||||
<collider height="40" radius="15"/>
|
||||
|
||||
<!-- head -->
|
||||
<limb id = "0" radius="13" mass = "6" type="Head" attackpriority="2">
|
||||
@@ -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" canbesevered="true"/>
|
||||
<joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,7" lowerlimit="-10" upperlimit="10"/>
|
||||
|
||||
<!-- body to left arm -->
|
||||
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>
|
||||
|
||||
@@ -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" canbesevered="true"/>
|
||||
<joint limb1="0" limb1anchor="35,-8" limb2="13" limb2anchor="30,0" lowerlimit="-40" upperlimit="0"/>
|
||||
|
||||
<joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,15" lowerlimit="30" upperlimit="60" canbesevered="true"/>
|
||||
<joint limb1="1" limb1anchor="0,-17" limb2="12" limb2anchor="0,15" lowerlimit="30" upperlimit="60"/>
|
||||
|
||||
<!-- body to left arm -->
|
||||
<joint limb1="1" limb1anchor="-3,14" limb2="2" limb2anchor="0,12"/>
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
attackpriorityrooms="50.0"
|
||||
attackpriorityweaker="60"
|
||||
attackprioritystronger="-70"
|
||||
eatpriority="65"
|
||||
attackcooldown="1.0"
|
||||
sight="0.5"
|
||||
hearing="1.0"
|
||||
@@ -31,7 +32,7 @@
|
||||
<collider radius="60"/>
|
||||
|
||||
<!-- head -->
|
||||
<limb id = "0" radius="30" height="86" mass = "6" type="Head" flip="true" steerforce="1.0" armorsector="0.0,180.0" armor="10.0">
|
||||
<limb id = "0" radius="30" height="86" mass = "6" type="Head" flip="true" steerforce="1.0" armorsector="0.0,180.0" armor="10.0" mouthpos="30,88">
|
||||
<sprite texture="Content/Characters/Mantis/mantis.png" sourcerect="0,0,101,168" depth="0.02" origin="0.4,0.53"/>
|
||||
</limb>
|
||||
|
||||
|
||||
@@ -80,6 +80,7 @@ namespace Barotrauma
|
||||
attackHumans = ToolBox.GetAttributeFloat(aiElement, 0.0f, "attackhumans", "attackpriorityhumans") / 100.0f;
|
||||
attackWeaker = ToolBox.GetAttributeFloat(aiElement, 0.0f, "attackweaker", "attackpriorityweaker") / 100.0f;
|
||||
attackStronger = ToolBox.GetAttributeFloat(aiElement, 0.0f, "attackstronger", "attackprioritystronger") / 100.0f;
|
||||
eatDeadPriority = ToolBox.GetAttributeFloat(aiElement, "eatpriority", 0.0f) / 100.0f;
|
||||
|
||||
combatStrength = ToolBox.GetAttributeFloat(aiElement, "combatstrength", 1.0f);
|
||||
|
||||
@@ -171,7 +172,7 @@ namespace Barotrauma
|
||||
UpdateAttack(deltaTime);
|
||||
break;
|
||||
case AIState.Eat:
|
||||
|
||||
UpdateEating(deltaTime);
|
||||
break;
|
||||
case AIState.Escape:
|
||||
run = true;
|
||||
@@ -417,7 +418,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateEat(float deltaTime)
|
||||
private void UpdateEating(float deltaTime)
|
||||
{
|
||||
if (selectedAiTarget == null)
|
||||
{
|
||||
@@ -425,11 +426,59 @@ namespace Barotrauma
|
||||
return;
|
||||
}
|
||||
|
||||
var head = Character.AnimController.GetLimb(LimbType.Head);
|
||||
if (head == null) head = Character.AnimController.MainLimb;
|
||||
Limb mouthLimb = Array.Find(Character.AnimController.Limbs, l => l != null && l.MouthPos.HasValue);
|
||||
if (mouthLimb == null) mouthLimb = Character.AnimController.GetLimb(LimbType.Head);
|
||||
|
||||
if (mouthLimb == null)
|
||||
{
|
||||
DebugConsole.ThrowError("Character \"" + Character.SpeciesName + "\" failed to eat a target (a head or a limb with a mouthpos required)");
|
||||
state = AIState.None;
|
||||
return;
|
||||
}
|
||||
|
||||
Vector2 mouthPos = mouthLimb.SimPosition;
|
||||
if (mouthLimb.MouthPos.HasValue)
|
||||
{
|
||||
float cos = (float)Math.Cos(mouthLimb.Rotation);
|
||||
float sin = (float)Math.Sin(mouthLimb.Rotation);
|
||||
|
||||
mouthPos += new Vector2(
|
||||
mouthLimb.MouthPos.Value.X * cos - mouthLimb.MouthPos.Value.Y * sin,
|
||||
mouthLimb.MouthPos.Value.X * sin + mouthLimb.MouthPos.Value.Y * cos);
|
||||
}
|
||||
|
||||
|
||||
Vector2 attackSimPosition = Character.Submarine == null ? ConvertUnits.ToSimUnits(selectedAiTarget.WorldPosition) : selectedAiTarget.SimPosition;
|
||||
steeringManager.SteeringSeek(attackSimPosition - (head.SimPosition - SimPosition), 3);
|
||||
steeringManager.SteeringSeek(attackSimPosition + (mouthPos - SimPosition), 3);
|
||||
|
||||
Vector2 limbDiff = attackSimPosition - mouthPos;
|
||||
float limbDist = limbDiff.Length();
|
||||
if (limbDist < 1.0f)
|
||||
{
|
||||
Character targetCharacter = selectedAiTarget.Entity as Character;
|
||||
//targetCharacter.AnimController.MainLimb.body.ApplyForce(-limbDiff * targetCharacter.AnimController.Mass * (float)(Math.Sin(Timing.TotalTime)+1.0f));
|
||||
|
||||
targetCharacter.AnimController.MainLimb.MoveToPos(
|
||||
mouthPos,
|
||||
(float)(Math.Sin(Timing.TotalTime) + 10.0f));
|
||||
steeringManager.SteeringManual(deltaTime, limbDiff);
|
||||
|
||||
Character.AnimController.Collider.ApplyForce(limbDiff * mouthLimb.Mass * 50.0f, mouthPos);
|
||||
mouthLimb.body.ApplyForce(limbDiff * mouthLimb.Mass * 50.0f * (float)(Math.Sin(Timing.TotalTime) + 1.0f));
|
||||
//eatingLimb.pullJoint.Enabled = true;
|
||||
//eatingLimb.pullJoint.WorldAnchorB = attackSimPosition;
|
||||
|
||||
if (Rand.Range(0.0f, 60.0f) < 1.0f)
|
||||
{
|
||||
targetCharacter.AnimController.MainLimb.AddDamage(targetCharacter.SimPosition, DamageType.None, Rand.Range(10.0f, 25.0f), 10.0f, false);
|
||||
}
|
||||
}
|
||||
else if (limbDist < 2.0f)
|
||||
{
|
||||
steeringManager.SteeringManual(deltaTime, limbDiff);
|
||||
Character.AnimController.Collider.ApplyForce(limbDiff * mouthLimb.Mass * 50.0f, mouthPos);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//goes through all the AItargets, evaluates how preferable it is to attack the target,
|
||||
|
||||
@@ -502,9 +502,9 @@ namespace Barotrauma
|
||||
{
|
||||
Limb limb = (Limb)f1.Body.UserData;
|
||||
|
||||
if (impact > 3.0f && limb.HitSound != null && limb.soundTimer <= 0.0f)
|
||||
if (impact > 3.0f && limb.HitSound != null && limb.SoundTimer <= 0.0f)
|
||||
{
|
||||
limb.soundTimer = Limb.SoundInterval;
|
||||
limb.SoundTimer = Limb.SoundInterval;
|
||||
limb.HitSound.Play(volume, impact * 100.0f, limb.WorldPosition);
|
||||
}
|
||||
}
|
||||
@@ -675,6 +675,8 @@ namespace Barotrauma
|
||||
foreach (Limb limb in Limbs)
|
||||
{
|
||||
if (limb == null || limb.IsSevered) continue;
|
||||
|
||||
limb.Dir = Dir;
|
||||
|
||||
if (limb.sprite != null)
|
||||
{
|
||||
@@ -683,12 +685,13 @@ namespace Barotrauma
|
||||
limb.sprite.Origin = spriteOrigin;
|
||||
}
|
||||
|
||||
limb.Dir = Dir;
|
||||
|
||||
/*if (limb.LightSource != null)
|
||||
|
||||
if (limb.MouthPos.HasValue)
|
||||
{
|
||||
limb.LightSource.FlipX();
|
||||
}*/
|
||||
limb.MouthPos = new Vector2(
|
||||
-limb.MouthPos.Value.X,
|
||||
limb.MouthPos.Value.Y);
|
||||
}
|
||||
|
||||
if (limb.pullJoint != null)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user