- Enemies wander randomly if they can't find a path to a selected attack target.

- Enemies don't select hulls as targets if they're already inside.
- FishAnimController updates the walking animation even if the character is not moving (otherwise the character would just fall down if TargetMovement is zero).
- Eating anim tweaking.
This commit is contained in:
Joonas Rikkonen
2017-06-30 17:28:52 +03:00
parent bb91c8ce75
commit 3981b4efa3
3 changed files with 17 additions and 19 deletions

View File

@@ -25,7 +25,7 @@
<collider radius="50" height="320"/>
<!-- head -->
<limb id = "0" radius="12" height="100" type="Head" steerforce="1.0" mouthpos="20,0">
<limb id = "0" radius="12" height="100" type="Head" steerforce="1.0" mouthpos="20,50">
<sprite texture="Content/Characters/Tigerthresher/tigerthresher.png" sourcerect="371,15,66,136" depth="0.02" origin ="0.5,0.5"/>
<damagedsprite texture="Content/Characters/Tigerthresher/damagedtigerthresher.png" sourcerect="371,15,66,136" origin ="0.5,0.5"/>
</limb>

View File

@@ -362,9 +362,18 @@ namespace Barotrauma
if (steeringManager is IndoorsSteeringManager)
{
var indoorsSteering = (IndoorsSteeringManager)steeringManager;
if (indoorsSteering.CurrentPath != null && (indoorsSteering.CurrentPath.Finished || indoorsSteering.CurrentPath.Unreachable))
if (indoorsSteering.CurrentPath != null)
{
steeringManager.SteeringManual(deltaTime, attackSimPosition - attackLimb.SimPosition);
if (indoorsSteering.CurrentPath.Unreachable)
{
//wander around randomly and decrease the priority faster if no path is found
if (selectedTargetMemory != null) selectedTargetMemory.Priority -= deltaTime * 10.0f;
steeringManager.SteeringWander();
}
else if (indoorsSteering.CurrentPath.Finished)
{
steeringManager.SteeringManual(deltaTime, attackSimPosition - attackLimb.SimPosition);
}
}
}
@@ -525,6 +534,8 @@ namespace Barotrauma
//pull the target character to the position of the mouth
//(+ make the force fluctuate to waggle the character a bit)
targetCharacter.AnimController.MainLimb.MoveToPos(mouthPos, (float)(Math.Sin(eatTimer) + 10.0f));
targetCharacter.AnimController.MainLimb.body.SmoothRotate(mouthLimb.Rotation);
targetCharacter.AnimController.Collider.MoveToPos(mouthPos, (float)(Math.Sin(eatTimer) + 10.0f));
//pull the character's mouth to the target character (again with a fluctuating force)
float pullStrength = (float)(Math.Sin(eatTimer) * Math.Max(Math.Sin(eatTimer * 0.5f), 0.0f));
@@ -632,8 +643,8 @@ namespace Barotrauma
IDamageable targetDamageable = target.Entity as IDamageable;
if (targetDamageable != null && targetDamageable.Health <= 0.0f) continue;
//skip the target if it's the room the Character is inside of
if (character.AnimController.CurrentHull != null && character.AnimController.CurrentHull == target.Entity as Hull) continue;
//skip the target if it's a room and the character is already inside a sub
if (character.AnimController.CurrentHull != null && target.Entity is Hull) continue;
valueModifier = attackRooms;
}
@@ -701,7 +712,6 @@ namespace Barotrauma
//have a corresponding AItarget or whose priority is 0.0f
private void UpdateTargetMemories()
{
List<AITarget> toBeRemoved = new List<AITarget>();
foreach(KeyValuePair<AITarget, AITargetMemory> memory in targetMemories)
{
@@ -724,7 +734,7 @@ namespace Barotrauma
Vector2 pos = Character.WorldPosition;
pos.Y = -pos.Y;
if (selectedAiTarget!=null)
if (selectedAiTarget!=null && selectedAiTarget.Entity != null)
{
GUI.DrawLine(spriteBatch, pos, new Vector2(selectedAiTarget.WorldPosition.X, -selectedAiTarget.WorldPosition.Y), Color.Red);
@@ -734,10 +744,7 @@ namespace Barotrauma
}
GUI.Font.DrawString(spriteBatch, targetValue.ToString(), pos - Vector2.UnitY*20.0f, Color.Red);
}
if (selectedAiTarget != null)
{
GUI.DrawLine(spriteBatch,
new Vector2(Character.DrawPosition.X, -Character.DrawPosition.Y),
new Vector2(selectedAiTarget.WorldPosition.X, -selectedAiTarget.WorldPosition.Y), Color.Red);

View File

@@ -213,14 +213,6 @@ namespace Barotrauma
Vector2 pullPos = Limbs[i].pullJoint == null ? Limbs[i].SimPosition : Limbs[i].pullJoint.WorldAnchorA;
Limbs[i].body.ApplyForce(movement * Limbs[i].SteerForce * Limbs[i].Mass, pullPos);
/*if (Limbs[i] == MainLimb) continue;
float dist = (MainLimb.SimPosition - Limbs[i].SimPosition).Length();
Vector2 limbPos = MainLimb.SimPosition - Vector2.Normalize(movement) * dist;
Limbs[i].body.ApplyForce(((limbPos - Limbs[i].SimPosition) * 3.0f - Limbs[i].LinearVelocity * 3.0f) * Limbs[i].Mass);*/
}
Collider.LinearVelocity = Vector2.Lerp(Collider.LinearVelocity, movement, 0.5f);
@@ -231,7 +223,6 @@ namespace Barotrauma
void UpdateWalkAnim(float deltaTime)
{
movement = MathUtils.SmoothStep(movement, TargetMovement * walkSpeed, 0.2f);
if (movement == Vector2.Zero) return;
float mainLimbHeight, mainLimbAngle;
if (MainLimb.type == LimbType.Torso)