(aea5053bf) Fix wall target position not updated when the submarine moves. Fix latchontoai attach positions and distance checks. Detaching should also work both when the characters can get in and when the submarine velocity is enough to detach the characters. Still not synced, but re-enabled for testing.
This commit is contained in:
@@ -288,7 +288,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
var targetingPriority = UpdateTargets(Character);
|
||||
UpdateTargets(Character, out TargetingPriority targetingPriority);
|
||||
updateTargetsTimer = UpdateTargetsInterval;
|
||||
|
||||
if (SelectedAiTarget == null)
|
||||
@@ -299,7 +299,7 @@ namespace Barotrauma
|
||||
{
|
||||
State = AIState.Escape;
|
||||
}
|
||||
else
|
||||
else if (targetingPriority != null)
|
||||
{
|
||||
State = targetingPriority.State;
|
||||
}
|
||||
@@ -472,7 +472,10 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
UpdateWallTarget();
|
||||
if (!IsProperlyLatched)
|
||||
{
|
||||
UpdateWallTarget();
|
||||
}
|
||||
raycastTimer = RaycastInterval;
|
||||
}
|
||||
|
||||
@@ -496,6 +499,10 @@ namespace Barotrauma
|
||||
if (wallTarget != null)
|
||||
{
|
||||
attackWorldPos = wallTarget.Position;
|
||||
if (wallTarget.Structure.Submarine != null)
|
||||
{
|
||||
attackWorldPos += wallTarget.Structure.Submarine.Position;
|
||||
}
|
||||
attackSimPos = ConvertUnits.ToSimUnits(attackWorldPos);
|
||||
}
|
||||
else
|
||||
@@ -839,12 +846,7 @@ namespace Barotrauma
|
||||
attachTargetNormal = new Vector2(Math.Sign(WorldPosition.X - wall.WorldPosition.X), 0.0f);
|
||||
sectionPos.X += (wall.BodyWidth <= 0.0f ? wall.Rect.Width : wall.BodyWidth) / 2 * attachTargetNormal.X;
|
||||
}
|
||||
|
||||
latchOntoAI?.SetAttachTarget(wall.Submarine.PhysicsBody.FarseerBody, wall.Submarine, sectionPos, attachTargetNormal);
|
||||
if (wall.Submarine != null)
|
||||
{
|
||||
sectionPos += wall.Submarine.Position;
|
||||
}
|
||||
latchOntoAI?.SetAttachTarget(wall.Submarine.PhysicsBody.FarseerBody, wall.Submarine, ConvertUnits.ToSimUnits(sectionPos), attachTargetNormal);
|
||||
wallTarget = new WallTarget(sectionPos, wall, sectionIndex);
|
||||
}
|
||||
}
|
||||
@@ -967,18 +969,27 @@ namespace Barotrauma
|
||||
steeringManager.SteeringSeek(attackSimPosition - (mouthPos - SimPosition));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#endregion
|
||||
|
||||
#region Targeting
|
||||
|
||||
private bool IsProperlyLatched => latchOntoAI != null && latchOntoAI.IsAttached && SelectedAiTarget?.Entity == wallTarget?.Structure;
|
||||
|
||||
//goes through all the AItargets, evaluates how preferable it is to attack the target,
|
||||
//whether the Character can see/hear the target and chooses the most preferable target within
|
||||
//sight/hearing range
|
||||
public TargetingPriority UpdateTargets(Character character)
|
||||
public AITarget UpdateTargets(Character character, out TargetingPriority priority)
|
||||
{
|
||||
if (IsProperlyLatched)
|
||||
{
|
||||
// If attached to a valid target, just keep the target.
|
||||
// Priority not used in this case.
|
||||
priority = null;
|
||||
return SelectedAiTarget;
|
||||
}
|
||||
AITarget newTarget = null;
|
||||
TargetingPriority targetingPriority = null;
|
||||
priority = null;
|
||||
selectedTargetMemory = null;
|
||||
targetValue = 0.0f;
|
||||
|
||||
@@ -1177,7 +1188,7 @@ namespace Barotrauma
|
||||
{
|
||||
newTarget = target;
|
||||
selectedTargetMemory = targetMemory;
|
||||
targetingPriority = targetingPriorities[targetingTag];
|
||||
priority = targetingPriorities[targetingTag];
|
||||
targetValue = valueModifier;
|
||||
}
|
||||
}
|
||||
@@ -1187,7 +1198,7 @@ namespace Barotrauma
|
||||
{
|
||||
wallTarget = null;
|
||||
}
|
||||
return targetingPriority;
|
||||
return SelectedAiTarget;
|
||||
}
|
||||
|
||||
private AITargetMemory GetTargetMemory(AITarget target)
|
||||
|
||||
@@ -193,7 +193,7 @@ namespace Barotrauma
|
||||
// is not attached or is attached to something else
|
||||
if (!IsAttached || IsAttached && attachJoints[0].BodyB == attachTargetBody)
|
||||
{
|
||||
if (Vector2.DistanceSquared(ConvertUnits.ToDisplayUnits(transformedAttachPos), enemyAI.AttackingLimb.WorldPosition) < enemyAI.AttackingLimb.attack.Range * enemyAI.AttackingLimb.attack.Range)
|
||||
if (Vector2.DistanceSquared(ConvertUnits.ToDisplayUnits(transformedAttachPos), enemyAI.AttackingLimb.WorldPosition) < enemyAI.AttackingLimb.attack.DamageRange * enemyAI.AttackingLimb.attack.DamageRange)
|
||||
{
|
||||
AttachToBody(character.AnimController.Collider, attachLimb, attachTargetBody, transformedAttachPos);
|
||||
}
|
||||
|
||||
@@ -528,7 +528,7 @@ namespace Barotrauma
|
||||
}
|
||||
else
|
||||
{
|
||||
// If the attack is aimed to a character but hits a structure, the hit is blocked.
|
||||
// If there is nothing between, the hit is successful
|
||||
wasHit = structureBody == null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user