EnemyAIController tweaking:
- removed the "distance accumulator" which was used to make characters reset their attack target if they haven't moved enough within a specific interval. The intention was to make characters less likely to get stuck but it seems to cause more problems than it solves. - more frequent target updates - characters can target entities they're previously targeted from further away (even if the target isn't within range anymore)
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
<!-- spike/tentacle thingy -->
|
||||
<limb id = "13" width="10" height="30" mass = "6" attackpriority="2" flip="true" pullpos="0.0,25.0">
|
||||
<sprite texture="Content/Characters/Husk/DivingSuit.png" sourcerect="110,76,18,52" depth="0.05" origin="0.5,0.5"/>
|
||||
<attack range="70" duration="0.2" bleedingdamage="0.5" damage="10" stun="0.5" torque="-50" damagetype="slash" targetforce="10">
|
||||
<attack range="70" duration="0.2" bleedingdamage="0.5" damage="10" stun="0.5" force="1" torque="-50" damagetype="slash" targetforce="10">
|
||||
<StatusEffect type="OnUse" target="Character" HuskInfectionState="0.01" disabledeltatime="true"/>
|
||||
<StatusEffect type="OnUse" target="This" Health="1.0" disabledeltatime="true"/>
|
||||
</attack>
|
||||
@@ -110,6 +110,6 @@
|
||||
|
||||
<ai attackhumans="500" attackrooms="5.0" attackweaker="50" attackstronger="-30"
|
||||
sight="0.5" hearing="1.0"
|
||||
attackcooldown="5.0"/>
|
||||
attackcooldown="1.0"/>
|
||||
</Character>
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ namespace Barotrauma
|
||||
|
||||
class EnemyAIController : AIController
|
||||
{
|
||||
private const float UpdateTargetsInterval = 5.0f;
|
||||
private const float UpdateTargetsInterval = 0.5f;
|
||||
|
||||
private const float RaycastInterval = 1.0f;
|
||||
|
||||
@@ -32,7 +32,6 @@ namespace Barotrauma
|
||||
private float raycastTimer;
|
||||
|
||||
private Vector2 prevPosition;
|
||||
private float distanceAccumulator;
|
||||
|
||||
//a timer for attacks such as biting that last for a specific amount of time
|
||||
//the duration is determined by the attackDuration of the attacking limb
|
||||
@@ -108,8 +107,6 @@ namespace Barotrauma
|
||||
|
||||
public override void Update(float deltaTime)
|
||||
{
|
||||
UpdateDistanceAccumulator();
|
||||
|
||||
bool ignorePlatforms = (-Character.AnimController.TargetMovement.Y > Math.Abs(Character.AnimController.TargetMovement.X));
|
||||
|
||||
if (steeringManager is IndoorsSteeringManager)
|
||||
@@ -187,14 +184,6 @@ namespace Barotrauma
|
||||
|
||||
coolDownTimer -= deltaTime;
|
||||
}
|
||||
|
||||
private void UpdateDistanceAccumulator()
|
||||
{
|
||||
Limb limb = Character.AnimController.Limbs[0];
|
||||
distanceAccumulator += (limb.SimPosition - prevPosition).Length();
|
||||
|
||||
prevPosition = limb.body.SimPosition;
|
||||
}
|
||||
|
||||
private void UpdateAttack(float deltaTime)
|
||||
{
|
||||
@@ -214,6 +203,11 @@ namespace Barotrauma
|
||||
if (selectedAiTarget.Entity != null && Character.Submarine==null && selectedAiTarget.Entity.Submarine != null) attackSimPosition += ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position);
|
||||
}
|
||||
|
||||
if (Math.Abs(Character.AnimController.movement.X) > 0.1f && !Character.AnimController.InWater)
|
||||
{
|
||||
Character.AnimController.TargetDir = Character.SimPosition.X < attackSimPosition.X ? Direction.Right : Direction.Left;
|
||||
}
|
||||
|
||||
if (coolDownTimer>0.0f)
|
||||
{
|
||||
UpdateCoolDown(attackSimPosition, deltaTime);
|
||||
@@ -374,15 +368,6 @@ namespace Barotrauma
|
||||
//sight/hearing range
|
||||
public void UpdateTargets(Character character)
|
||||
{
|
||||
if (distanceAccumulator<5.0f && Rand.Range(1,3)==1)
|
||||
{
|
||||
selectedAiTarget = null;
|
||||
character.AnimController.TargetMovement = -character.AnimController.TargetMovement;
|
||||
state = AiState.None;
|
||||
return;
|
||||
}
|
||||
distanceAccumulator = 0.0f;
|
||||
|
||||
wallAttackPos = Vector2.Zero;
|
||||
|
||||
selectedAiTarget = null;
|
||||
@@ -423,13 +408,11 @@ namespace Barotrauma
|
||||
valueModifier = attackRooms;
|
||||
}
|
||||
|
||||
dist = Vector2.Distance(
|
||||
character.WorldPosition,
|
||||
target.WorldPosition);
|
||||
dist = Vector2.Distance(character.WorldPosition, target.WorldPosition);
|
||||
|
||||
//if the target has been within range earlier, the character will notice it more easily
|
||||
//(i.e. remember where the target was)
|
||||
if (targetMemories.ContainsKey(target)) dist *= 0.5f;
|
||||
if (targetMemories.ContainsKey(target)) dist *= 0.1f;
|
||||
|
||||
//ignore target if it's too far to see or hear
|
||||
if (dist > target.SightRange * sight && dist > target.SoundRange * hearing) continue;
|
||||
|
||||
Reference in New Issue
Block a user