- fractal guardians have higher impact tolerance to stop them from killing themselves by slamming at the walls
- enemies use pathfinding when inside the sub and handle platforms/stairs better
This commit is contained in:
@@ -25,6 +25,8 @@ namespace Barotrauma
|
||||
//negative values = escapes targets of this type
|
||||
private float attackRooms, attackHumans, attackWeaker, attackStronger;
|
||||
|
||||
private SteeringManager outsideSteering, insideSteering;
|
||||
|
||||
private float updateTargetsTimer;
|
||||
|
||||
private float raycastTimer;
|
||||
@@ -88,7 +90,10 @@ namespace Barotrauma
|
||||
|
||||
attackWhenProvoked = ToolBox.GetAttributeBool(aiElement, "attackwhenprovoked", false);
|
||||
|
||||
steeringManager = new SteeringManager(this);
|
||||
outsideSteering = new SteeringManager(this);
|
||||
insideSteering = new IndoorsSteeringManager(this, false);
|
||||
|
||||
steeringManager = outsideSteering;
|
||||
|
||||
state = AiState.None;
|
||||
}
|
||||
@@ -133,7 +138,9 @@ namespace Barotrauma
|
||||
state = (targetValue > 0.0f) ? AiState.Attack : AiState.Escape;
|
||||
}
|
||||
//if (coolDownTimer >= 0.0f) return;
|
||||
}
|
||||
}
|
||||
|
||||
steeringManager = Character.Submarine == null ? outsideSteering : insideSteering;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
@@ -210,7 +217,7 @@ namespace Barotrauma
|
||||
raycastTimer = RaycastInterval;
|
||||
}
|
||||
|
||||
steeringManager.SteeringAvoid(deltaTime, 1.0f);
|
||||
//steeringManager.SteeringAvoid(deltaTime, 1.0f);
|
||||
steeringManager.SteeringSeek(attackSimPosition);
|
||||
|
||||
//check if any of the limbs is close enough to attack the target
|
||||
@@ -252,6 +259,12 @@ namespace Barotrauma
|
||||
private void GetTargetEntity()
|
||||
{
|
||||
targetEntity = null;
|
||||
|
||||
if (Character.AnimController.CurrentHull != null)
|
||||
{
|
||||
wallAttackPos = Vector2.Zero;
|
||||
return;
|
||||
}
|
||||
|
||||
//check if there's a wall between the target and the Character
|
||||
Vector2 rayStart = Character.SimPosition;
|
||||
@@ -274,7 +287,7 @@ namespace Barotrauma
|
||||
if (wall == null)
|
||||
{
|
||||
wallAttackPos = Submarine.LastPickedPosition;
|
||||
if (selectedAiTarget.Entity.Submarine!=null) wallAttackPos -= ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position);
|
||||
if (selectedAiTarget.Entity.Submarine!=null && Character.Submarine == null) wallAttackPos -= ConvertUnits.ToSimUnits(selectedAiTarget.Entity.Submarine.Position);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -370,7 +383,6 @@ namespace Barotrauma
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
if (dist < limb.attack.Range)
|
||||
{
|
||||
attackTimer += deltaTime;
|
||||
@@ -413,6 +425,8 @@ namespace Barotrauma
|
||||
}
|
||||
distanceAccumulator = 0.0f;
|
||||
|
||||
wallAttackPos = Vector2.Zero;
|
||||
|
||||
selectedAiTarget = null;
|
||||
selectedTargetMemory = null;
|
||||
targetValue = 0.0f;
|
||||
|
||||
@@ -73,7 +73,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
if (inWater)
|
||||
if (inWater || RefLimb.inWater)
|
||||
{
|
||||
UpdateSineAnim(deltaTime);
|
||||
}
|
||||
@@ -83,7 +83,7 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
if (mirror)
|
||||
if (mirror || !inWater)
|
||||
{
|
||||
if (!character.IsNetworkPlayer)
|
||||
{
|
||||
@@ -278,28 +278,44 @@ namespace Barotrauma
|
||||
//out whether the ragdoll is standing on ground
|
||||
float closestFraction = 1;
|
||||
//Structure closestStructure = null;
|
||||
|
||||
GameMain.World.RayCast((fixture, point, normal, fraction) =>
|
||||
{
|
||||
//other limbs and bodies with no collision detection are ignored
|
||||
if (fixture == null ||
|
||||
fixture.CollisionCategories == Physics.CollisionCharacter ||
|
||||
fixture.CollisionCategories == Physics.CollisionNone ||
|
||||
fixture.CollisionCategories == Physics.CollisionItem) return -1;
|
||||
|
||||
Structure structure = fixture.Body.UserData as Structure;
|
||||
if (structure != null)
|
||||
switch (fixture.CollisionCategories)
|
||||
{
|
||||
if (structure.StairDirection != Direction.None && (stairs == null)) return -1;
|
||||
if (structure.IsPlatform && (IgnorePlatforms || stairs != null)) return -1;
|
||||
case Physics.CollisionStairs:
|
||||
if (inWater && TargetMovement.Y < 0.5f) return -1;
|
||||
Structure structure = fixture.Body.UserData as Structure;
|
||||
if (stairs == null && structure != null)
|
||||
{
|
||||
if (LowestLimb.SimPosition.Y < structure.SimPosition.Y)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
else
|
||||
{
|
||||
stairs = structure;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case Physics.CollisionPlatform:
|
||||
Structure platform = fixture.Body.UserData as Structure;
|
||||
if (IgnorePlatforms || LowestLimb.Position.Y < platform.Rect.Y) return -1;
|
||||
break;
|
||||
case Physics.CollisionWall:
|
||||
break;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
|
||||
onGround = true;
|
||||
if (fraction < closestFraction)
|
||||
{
|
||||
closestFraction = fraction;
|
||||
}
|
||||
onFloorTimer = 0.05f;
|
||||
|
||||
if (fraction < closestFraction) closestFraction = fraction;
|
||||
return 1;
|
||||
}
|
||||
, rayStart, rayEnd);
|
||||
return closestFraction;
|
||||
} , rayStart, rayEnd);
|
||||
|
||||
//the ragdoll "stays on ground" for 50 millisecs after separation
|
||||
if (onFloorTimer <= 0.0f)
|
||||
|
||||
Reference in New Issue
Block a user