Some tweaks to make enemy attacks less likely to miss:

- Option to select which limbs attack force is applied to (e.g. husks and crawlers now lunge forward when attacking).
- Enemies attack towards the closest limb of their target instead of the main limb.
This commit is contained in:
Joonas Rikkonen
2017-06-14 20:38:16 +03:00
parent 242da11e3f
commit 06e23ffe6d
7 changed files with 63 additions and 11 deletions
@@ -221,6 +221,21 @@ namespace Barotrauma
if (selectedAiTarget.Entity != null && Character.Submarine == null && selectedAiTarget.Entity.Submarine != null) attackSimPosition += ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position);
}
else if (selectedAiTarget.Entity is Character)
{
//target the closest limb if the target is a character
float closestDist = Vector2.DistanceSquared(selectedAiTarget.SimPosition, SimPosition);
foreach (Limb limb in ((Character)selectedAiTarget.Entity).AnimController.Limbs)
{
if (limb == null) continue;
float dist = Vector2.DistanceSquared(limb.SimPosition, SimPosition);
if (dist < closestDist)
{
closestDist = dist;
attackSimPosition = limb.SimPosition;
}
}
}
if (Math.Abs(Character.AnimController.movement.X) > 0.1f && !Character.AnimController.InWater)
{