(a97ef2847) AI improvements: - Fix steering issues when attacking (yet again): We still have to offset the sim positions. - Fix the steering vector when escaping from the enemy that is inside the sub. - Enemies can now navigate out from the sub, when escaping. - Fix door tag not being used when targeting items. Change the priority boosts considering doors. Should now entirely ignore the outer doors when inside and inner doors when outside. - Change the way enemies react to characters that are not in the same sub. Halve the priority when the character is not in the same hull. Add some boost to the priority when escaping.
This commit is contained in:
@@ -1522,40 +1522,14 @@ namespace Barotrauma
|
||||
outpost.MakeOutpost();
|
||||
|
||||
Point? minSize = null;
|
||||
DockingPort subPort = null;
|
||||
if (Submarine.MainSub != null)
|
||||
{
|
||||
Point subSize = Submarine.MainSub.GetDockedBorders().Size;
|
||||
Point outpostSize = outpost.GetDockedBorders().Size;
|
||||
minSize = new Point(Math.Max(subSize.X, outpostSize.X), subSize.Y + outpostSize.Y);
|
||||
|
||||
float closestDistance = float.MaxValue;
|
||||
foreach (DockingPort port in DockingPort.List)
|
||||
{
|
||||
if (port.IsHorizontal || port.Docked) { continue; }
|
||||
if (port.Item.Submarine != Submarine.MainSub) { continue; }
|
||||
//the submarine port has to be at the top of the sub
|
||||
if (port.Item.WorldPosition.Y < Submarine.MainSub.WorldPosition.Y) { continue; }
|
||||
float dist = Math.Abs(port.Item.WorldPosition.X - Submarine.MainSub.WorldPosition.X);
|
||||
if (dist < closestDistance)
|
||||
{
|
||||
subPort = port;
|
||||
closestDistance = dist;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
float subDockingPortOffset = subPort == null ? 0.0f : subPort.Item.WorldPosition.X - Submarine.MainSub.WorldPosition.X;
|
||||
//don't try to compensate if the port is very far from the sub's center of mass
|
||||
if (Math.Abs(subDockingPortOffset) > 2000.0f)
|
||||
{
|
||||
subDockingPortOffset = MathHelper.Clamp(subDockingPortOffset, -2000.0f, 2000.0f);
|
||||
string warningMsg = "Docking port very far from the sub's center of mass (submarine: " + Submarine.MainSub.Name + ", dist: " + subDockingPortOffset + "). The level generator may not be able to place the outpost so that docking is possible.";
|
||||
DebugConsole.NewMessage(warningMsg, Color.Orange);
|
||||
GameAnalyticsManager.AddErrorEventOnce("Lever.CreateOutposts:DockingPortVeryFar" + Submarine.MainSub.Name, GameAnalyticsSDK.Net.EGAErrorSeverity.Warning, warningMsg);
|
||||
}
|
||||
|
||||
outpost.SetPosition(outpost.FindSpawnPos(i == 0 ? StartPosition : EndPosition, minSize, subDockingPortOffset));
|
||||
outpost.SetPosition(outpost.FindSpawnPos(i == 0 ? StartPosition : EndPosition, minSize));
|
||||
if ((i == 0) == !Mirrored)
|
||||
{
|
||||
StartOutpost = outpost;
|
||||
|
||||
Reference in New Issue
Block a user