(b99c0ef39) Fix the enemies not selecting another attack if they cannot reach the target.

This commit is contained in:
Joonas Rikkonen
2019-04-01 14:26:01 +03:00
parent 7971d8d3a7
commit 7e67c20ccd
6 changed files with 64 additions and 116 deletions
@@ -72,7 +72,7 @@ namespace Barotrauma
private void CreateSettingsFrame() private void CreateSettingsFrame()
{ {
settingsFrame = new GUIFrame(new RectTransform(new Vector2(0.8f, 0.8f), GUI.Canvas, Anchor.Center)); settingsFrame = new GUIFrame(new RectTransform(new Point(1024, 768), GUI.Canvas, Anchor.Center));
var settingsFramePadding = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), settingsFrame.RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.05f) }, style: null); var settingsFramePadding = new GUIFrame(new RectTransform(new Vector2(0.95f, 0.9f), settingsFrame.RectTransform, Anchor.TopCenter) { RelativeOffset = new Vector2(0.0f, 0.05f) }, style: null);
@@ -85,12 +85,13 @@ namespace Barotrauma
var generalLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), leftPanel.RectTransform, Anchor.TopLeft)); var generalLayoutGroup = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 1.0f), leftPanel.RectTransform, Anchor.TopLeft));
new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), generalLayoutGroup.RectTransform), TextManager.Get("ContentPackages")); //new GUITextBlock(new RectTransform(new Vector2(1.0f, 0.05f), generalLayoutGroup.RectTransform), TextManager.Get("ContentPackages"));
var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.75f), generalLayoutGroup.RectTransform)) var contentPackageList = new GUIListBox(new RectTransform(new Vector2(1.0f, 0.75f), generalLayoutGroup.RectTransform))
{ {
CanBeFocused = false CanBeFocused = false
}; };
foreach (ContentPackage contentPackage in ContentPackage.List) foreach (ContentPackage contentPackage in ContentPackage.List)
{ {
var tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.067f), contentPackageList.Content.RectTransform, minSize: new Point(0, 15)), contentPackage.Name) var tickBox = new GUITickBox(new RectTransform(new Vector2(1.0f, 0.067f), contentPackageList.Content.RectTransform, minSize: new Point(0, 15)), contentPackage.Name)
@@ -611,9 +612,8 @@ namespace Barotrauma
for (int i = 0; i < inputNames.Length; i++) for (int i = 0; i < inputNames.Length; i++)
{ {
var inputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), inputFrame.RectTransform)) { Stretch = true, IsHorizontal = true, RelativeSpacing = 0.05f }; var inputContainer = new GUILayoutGroup(new RectTransform(new Vector2(1.0f, 0.06f), inputFrame.RectTransform)) { Stretch = true, IsHorizontal = true, RelativeSpacing = 0.05f };
new GUITextBlock(new RectTransform(new Vector2(0.3f, 1.0f), inputContainer.RectTransform, Anchor.TopLeft) { MinSize = new Point(150, 0) }, new GUITextBlock(new RectTransform(new Vector2(0.25f, 1.0f), inputContainer.RectTransform, Anchor.TopLeft), TextManager.Get("InputType." + ((InputType)i)) + ": ", font: GUI.SmallFont) { ForceUpperCase = true };
TextManager.Get("InputType." + ((InputType)i)) + ": ", font: GUI.SmallFont) { ForceUpperCase = true }; var keyBox = new GUITextBox(new RectTransform(new Vector2(1.0f, 1.0f), inputContainer.RectTransform),
var keyBox = new GUITextBox(new RectTransform(new Vector2(0.7f, 1.0f), inputContainer.RectTransform),
text: keyMapping[i].ToString(), font: GUI.SmallFont) text: keyMapping[i].ToString(), font: GUI.SmallFont)
{ {
UserData = i UserData = i
@@ -641,7 +641,7 @@ namespace Barotrauma
new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null); new GUIFrame(new RectTransform(new Vector2(1.0f, 0.02f), generalLayoutGroup.RectTransform), style: null);
new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft), new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomLeft),
TextManager.Get("Cancel"), style: "GUIButtonLarge") TextManager.Get("Cancel"))
{ {
IgnoreLayoutGroups = true, IgnoreLayoutGroups = true,
OnClicked = (x, y) => OnClicked = (x, y) =>
@@ -657,7 +657,7 @@ namespace Barotrauma
}; };
applyButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomRight), applyButton = new GUIButton(new RectTransform(new Vector2(0.4f, 1.0f), buttonArea.RectTransform, Anchor.BottomRight),
TextManager.Get("ApplySettingsButton"), style: "GUIButtonLarge") TextManager.Get("ApplySettingsButton"))
{ {
IgnoreLayoutGroups = true, IgnoreLayoutGroups = true,
Enabled = false Enabled = false
@@ -51,7 +51,7 @@ namespace Barotrauma
new GUIImage(new RectTransform(new Vector2(0.35f, 0.2f), Frame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.05f, 0.05f) }, new GUIImage(new RectTransform(new Vector2(0.35f, 0.2f), Frame.RectTransform, Anchor.BottomRight) { RelativeOffset = new Vector2(0.05f, 0.05f) },
style: "TitleText"); style: "TitleText");
buttonsParent = new GUILayoutGroup(new RectTransform(new Vector2(0.3f, 0.85f), parent: Frame.RectTransform, anchor: Anchor.BottomLeft, pivot: Pivot.BottomLeft) buttonsParent = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 0.85f), parent: Frame.RectTransform, anchor: Anchor.BottomLeft, pivot: Pivot.BottomLeft)
{ {
AbsoluteOffset = new Point(50, 0) AbsoluteOffset = new Point(50, 0)
}) })
@@ -61,7 +61,7 @@ namespace Barotrauma
}; };
// === CAMPAIGN // === CAMPAIGN
var campaignHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 1.0f), parent: buttonsParent.RectTransform) { RelativeOffset = new Vector2(0.1f, 0.0f) }, isHorizontal: true); var campaignHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), parent: buttonsParent.RectTransform) { RelativeOffset = new Vector2(0.1f, 0.0f) }, isHorizontal: true);
new GUIImage(new RectTransform(new Vector2(0.2f, 0.7f), campaignHolder.RectTransform), "MainMenuCampaignIcon") new GUIImage(new RectTransform(new Vector2(0.2f, 0.7f), campaignHolder.RectTransform), "MainMenuCampaignIcon")
{ {
@@ -107,7 +107,7 @@ namespace Barotrauma
}; };
// === MULTIPLAYER // === MULTIPLAYER
var multiplayerHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 1.0f), parent: buttonsParent.RectTransform) { RelativeOffset = new Vector2(0.05f, 0.0f) }, isHorizontal: true); var multiplayerHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), parent: buttonsParent.RectTransform) { RelativeOffset = new Vector2(0.05f, 0.0f) }, isHorizontal: true);
new GUIImage(new RectTransform(new Vector2(0.2f, 0.7f), multiplayerHolder.RectTransform), "MainMenuMultiplayerIcon") new GUIImage(new RectTransform(new Vector2(0.2f, 0.7f), multiplayerHolder.RectTransform), "MainMenuMultiplayerIcon")
{ {
@@ -152,7 +152,7 @@ namespace Barotrauma
}; };
// === CUSTOMIZE // === CUSTOMIZE
var customizeHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 1.0f), parent: buttonsParent.RectTransform) { RelativeOffset = new Vector2(0.15f, 0.0f) }, isHorizontal: true); var customizeHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 1.0f), parent: buttonsParent.RectTransform) { RelativeOffset = new Vector2(0.15f, 0.0f) }, isHorizontal: true);
new GUIImage(new RectTransform(new Vector2(0.2f, 0.7f), customizeHolder.RectTransform), "MainMenuCustomizeIcon") new GUIImage(new RectTransform(new Vector2(0.2f, 0.7f), customizeHolder.RectTransform), "MainMenuCustomizeIcon")
{ {
@@ -209,7 +209,7 @@ namespace Barotrauma
} }
// === OPTION // === OPTION
var optionHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.9f, 0.5f), parent: buttonsParent.RectTransform), isHorizontal: true); var optionHolder = new GUILayoutGroup(new RectTransform(new Vector2(0.5f, 0.5f), parent: buttonsParent.RectTransform), isHorizontal: true);
new GUIImage(new RectTransform(new Vector2(0.15f, 0.6f), optionHolder.RectTransform), "MainMenuOptionIcon") new GUIImage(new RectTransform(new Vector2(0.15f, 0.6f), optionHolder.RectTransform), "MainMenuOptionIcon")
{ {
@@ -219,7 +219,7 @@ namespace Barotrauma
//spacing //spacing
new GUIFrame(new RectTransform(new Vector2(0.01f, 0.0f), optionHolder.RectTransform), style: null); new GUIFrame(new RectTransform(new Vector2(0.01f, 0.0f), optionHolder.RectTransform), style: null);
var optionButtons = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 1.0f), parent: optionHolder.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.15f) }); var optionButtons = new GUILayoutGroup(new RectTransform(new Vector2(0.55f, 1.0f), parent: optionHolder.RectTransform) { RelativeOffset = new Vector2(0.0f, 0.15f) });
var optionList = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.15f), parent: optionButtons.RectTransform)) var optionList = new GUILayoutGroup(new RectTransform(new Vector2(0.8f, 0.15f), parent: optionButtons.RectTransform))
{ {
@@ -241,7 +241,7 @@ namespace Barotrauma
//debug button for quickly starting a new round //debug button for quickly starting a new round
#if DEBUG #if DEBUG
new GUIButton(new RectTransform(new Vector2(0.8f, 0.1f), buttonsParent.RectTransform, Anchor.TopLeft, Pivot.BottomLeft) { AbsoluteOffset = new Point(0, -40) }, new GUIButton(new RectTransform(new Vector2(0.5f, 0.1f), buttonsParent.RectTransform, Anchor.TopLeft, Pivot.BottomLeft) { AbsoluteOffset = new Point(0, -40) },
"Quickstart (dev)", style: "GUIButtonLarge", color: Color.Red) "Quickstart (dev)", style: "GUIButtonLarge", color: Color.Red)
{ {
IgnoreLayoutGroups = true, IgnoreLayoutGroups = true,
@@ -255,7 +255,7 @@ namespace Barotrauma
#endif #endif
var minButtonSize = new Point(120, 20); var minButtonSize = new Point(120, 20);
var maxButtonSize = new Point(480, 80); var maxButtonSize = new Point(240, 40);
/*new GUIButton(new RectTransform(new Vector2(1.0f, 0.1f), buttonsParent.RectTransform), TextManager.Get("TutorialButton"), style: "GUIButtonLarge") /*new GUIButton(new RectTransform(new Vector2(1.0f, 0.1f), buttonsParent.RectTransform), TextManager.Get("TutorialButton"), style: "GUIButtonLarge")
{ {
@@ -270,21 +270,16 @@ namespace Barotrauma
SetupButtons(buttons); SetupButtons(buttons);
buttons.ForEach(b => b.TextBlock.SetTextPos());*/ buttons.ForEach(b => b.TextBlock.SetTextPos());*/
var relativeSize = new Vector2(0.6f, 0.5f); var relativeSize = new Vector2(0.5f, 0.5f);
var minSize = new Point(600, 400); var minSize = new Point(600, 400);
var maxSize = new Point(2000, 1500); var maxSize = new Point(900, 600);
var anchor = Anchor.CenterRight; var anchor = Anchor.Center;
var pivot = Pivot.CenterRight; var pivot = Pivot.Center;
Vector2 relativeSpacing = new Vector2(0.05f, 0.0f);
menuTabs = new GUIFrame[Enum.GetValues(typeof(Tab)).Length + 1]; menuTabs = new GUIFrame[Enum.GetValues(typeof(Tab)).Length + 1];
menuTabs[(int)Tab.Settings] = new GUIFrame(new RectTransform(new Vector2(relativeSize.X, 0.8f), GUI.Canvas, anchor, pivot, minSize, maxSize) { RelativeOffset = relativeSpacing }, menuTabs[(int)Tab.NewGame] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize));
style: null);
menuTabs[(int)Tab.NewGame] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize) { RelativeOffset = relativeSpacing });
var paddedNewGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[(int)Tab.NewGame].RectTransform, Anchor.Center), style: null); var paddedNewGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[(int)Tab.NewGame].RectTransform, Anchor.Center), style: null);
menuTabs[(int)Tab.LoadGame] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize) { RelativeOffset = relativeSpacing }); menuTabs[(int)Tab.LoadGame] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize));
var paddedLoadGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[(int)Tab.LoadGame].RectTransform, Anchor.Center), style: null); var paddedLoadGame = new GUIFrame(new RectTransform(new Vector2(0.9f, 0.9f), menuTabs[(int)Tab.LoadGame].RectTransform, Anchor.Center), style: null);
campaignSetupUI = new CampaignSetupUI(false, paddedNewGame, paddedLoadGame, Submarine.SavedSubmarines) campaignSetupUI = new CampaignSetupUI(false, paddedNewGame, paddedLoadGame, Submarine.SavedSubmarines)
@@ -295,13 +290,13 @@ namespace Barotrauma
var hostServerScale = new Vector2(0.7f, 1.0f); var hostServerScale = new Vector2(0.7f, 1.0f);
menuTabs[(int)Tab.HostServer] = new GUIFrame(new RectTransform( menuTabs[(int)Tab.HostServer] = new GUIFrame(new RectTransform(
Vector2.Multiply(relativeSize, hostServerScale), GUI.Canvas, anchor, pivot, minSize.Multiply(hostServerScale), maxSize.Multiply(hostServerScale)) { RelativeOffset = relativeSpacing }); Vector2.Multiply(relativeSize, hostServerScale), GUI.Canvas, anchor, pivot, minSize.Multiply(hostServerScale), maxSize.Multiply(hostServerScale)));
CreateHostServerFields(); CreateHostServerFields();
//---------------------------------------------------------------------- //----------------------------------------------------------------------
menuTabs[(int)Tab.Tutorials] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize) { RelativeOffset = relativeSpacing }); menuTabs[(int)Tab.Tutorials] = new GUIFrame(new RectTransform(relativeSize, GUI.Canvas, anchor, pivot, minSize, maxSize));
//PLACEHOLDER //PLACEHOLDER
var tutorialList = new GUIListBox( var tutorialList = new GUIListBox(
@@ -382,7 +377,6 @@ namespace Barotrauma
return false; return false;
} }
GameMain.Config.ResetSettingsFrame();
selectedTab = (Tab)obj; selectedTab = (Tab)obj;
switch (selectedTab) switch (selectedTab)
@@ -395,9 +389,8 @@ namespace Barotrauma
campaignSetupUI.UpdateLoadMenu(); campaignSetupUI.UpdateLoadMenu();
break; break;
case Tab.Settings: case Tab.Settings:
menuTabs[(int)Tab.Settings].RectTransform.ClearChildren(); GameMain.Config.ResetSettingsFrame();
GameMain.Config.SettingsFrame.RectTransform.Parent = menuTabs[(int)Tab.Settings].RectTransform; menuTabs[(int)Tab.Settings] = GameMain.Config.SettingsFrame;
GameMain.Config.SettingsFrame.RectTransform.RelativeSize = Vector2.One;
break; break;
case Tab.JoinServer: case Tab.JoinServer:
GameMain.ServerListScreen.Select(); GameMain.ServerListScreen.Select();
@@ -494,15 +494,7 @@ namespace Barotrauma.Networking
} }
else else
{ {
var defaultPerms = PermissionPreset.List.Find(p => p.Name == "None"); newClient.SetPermissions(ClientPermissions.None, new List<DebugConsole.Command>());
if (defaultPerms != null)
{
newClient.SetPermissions(defaultPerms.Permissions, defaultPerms.PermittedCommands);
}
else
{
newClient.SetPermissions(ClientPermissions.None, new List<DebugConsole.Command>());
}
} }
} }
@@ -337,56 +337,37 @@ namespace Barotrauma.Networking
continue; continue;
} }
string permissionsStr = clientElement.GetAttributeString("permissions", "");
ClientPermissions permissions = Networking.ClientPermissions.None; ClientPermissions permissions = Networking.ClientPermissions.None;
List<DebugConsole.Command> permittedCommands = new List<DebugConsole.Command>(); if (permissionsStr.ToLowerInvariant() == "all")
if (clientElement.Attribute("preset") == null)
{ {
string permissionsStr = clientElement.GetAttributeString("permissions", ""); foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions)))
if (permissionsStr.ToLowerInvariant() == "all")
{ {
foreach (ClientPermissions permission in Enum.GetValues(typeof(ClientPermissions))) permissions |= permission;
{
permissions |= permission;
}
}
else if (!Enum.TryParse(permissionsStr, out permissions))
{
DebugConsole.ThrowError("Error in " + ClientPermissionsFile + " - \"" + permissionsStr + "\" is not a valid client permission.");
continue;
}
if (permissions.HasFlag(Networking.ClientPermissions.ConsoleCommands))
{
foreach (XElement commandElement in clientElement.Elements())
{
if (commandElement.Name.ToString().ToLowerInvariant() != "command") continue;
string commandName = commandElement.GetAttributeString("name", "");
DebugConsole.Command command = DebugConsole.FindCommand(commandName);
if (command == null)
{
DebugConsole.ThrowError("Error in " + ClientPermissionsFile + " - \"" + commandName + "\" is not a valid console command.");
continue;
}
permittedCommands.Add(command);
}
} }
} }
else else if (!Enum.TryParse(permissionsStr, out permissions))
{ {
string presetName = clientElement.GetAttributeString("preset", ""); DebugConsole.ThrowError("Error in " + ClientPermissionsFile + " - \"" + permissionsStr + "\" is not a valid client permission.");
PermissionPreset preset = PermissionPreset.List.Find(p => p.Name == presetName); continue;
if (preset == null) }
List<DebugConsole.Command> permittedCommands = new List<DebugConsole.Command>();
if (permissions.HasFlag(Networking.ClientPermissions.ConsoleCommands))
{
foreach (XElement commandElement in clientElement.Elements())
{ {
DebugConsole.ThrowError("Failed to restore saved permissions to the client \"" + clientName + "\". Permission preset \"" + presetName + "\" not found."); if (commandElement.Name.ToString().ToLowerInvariant() != "command") continue;
return;
} string commandName = commandElement.GetAttributeString("name", "");
else DebugConsole.Command command = DebugConsole.FindCommand(commandName);
{ if (command == null)
permissions = preset.Permissions; {
permittedCommands = preset.PermittedCommands.ToList(); DebugConsole.ThrowError("Error in " + ClientPermissionsFile + " - \"" + commandName + "\" is not a valid console command.");
continue;
}
permittedCommands.Add(command);
} }
} }
@@ -459,14 +440,9 @@ namespace Barotrauma.Networking
foreach (SavedClientPermission clientPermission in ClientPermissions) foreach (SavedClientPermission clientPermission in ClientPermissions)
{ {
var matchingPreset = PermissionPreset.List.Find(p => p.MatchesPermissions(clientPermission.Permissions, clientPermission.PermittedCommands));
if (matchingPreset != null && matchingPreset.Name == "None")
{
continue;
}
XElement clientElement = new XElement("Client", XElement clientElement = new XElement("Client",
new XAttribute("name", clientPermission.Name)); new XAttribute("name", clientPermission.Name),
new XAttribute("permissions", clientPermission.Permissions.ToString()));
if (clientPermission.SteamID > 0) if (clientPermission.SteamID > 0)
{ {
@@ -477,21 +453,14 @@ namespace Barotrauma.Networking
clientElement.Add(new XAttribute("ip", clientPermission.IP)); clientElement.Add(new XAttribute("ip", clientPermission.IP));
} }
if (matchingPreset == null) if (clientPermission.Permissions.HasFlag(Barotrauma.Networking.ClientPermissions.ConsoleCommands))
{ {
clientElement.Add(new XAttribute("permissions", clientPermission.Permissions.ToString())); foreach (DebugConsole.Command command in clientPermission.PermittedCommands)
if (clientPermission.Permissions.HasFlag(Networking.ClientPermissions.ConsoleCommands))
{ {
foreach (DebugConsole.Command command in clientPermission.PermittedCommands) clientElement.Add(new XElement("command", new XAttribute("name", command.names[0])));
{
clientElement.Add(new XElement("command", new XAttribute("name", command.names[0])));
}
} }
} }
else
{
clientElement.Add(new XAttribute("preset", matchingPreset.Name));
}
doc.Root.Add(clientElement); doc.Root.Add(clientElement);
} }
@@ -13,13 +13,6 @@
<Command name="autorestart"/> <Command name="autorestart"/>
<Command name="autorestartinterval"/> <Command name="autorestartinterval"/>
<Command name="autorestarttimer"/> <Command name="autorestarttimer"/>
<Command name="botcount"/>
<Command name="botspawnmode"/>
<Command name="gamemode"/>
<Command name="sub"/>
<Command name="shuttle"/>
<Command name="water"/>
<Command name="fire"/>
<Command name="difficulty"/> <Command name="difficulty"/>
<Command name="kick"/> <Command name="kick"/>
<Command name="kickid"/> <Command name="kickid"/>
@@ -35,8 +28,6 @@
<Command name="autorestart"/> <Command name="autorestart"/>
<Command name="autorestartinterval"/> <Command name="autorestartinterval"/>
<Command name="autorestarttimer"/> <Command name="autorestarttimer"/>
<Command name="botcount"/>
<Command name="botspawnmode"/>
<Command name="difficulty"/> <Command name="difficulty"/>
<Command name="kick"/> <Command name="kick"/>
<Command name="kickid"/> <Command name="kickid"/>
@@ -631,8 +631,7 @@ namespace Barotrauma
else else
{ {
// If the secondary cooldown is defined and expired, check if we can switch the attack // If the secondary cooldown is defined and expired, check if we can switch the attack
var previousLimb = AttackingLimb; var newLimb = GetAttackLimb(attackWorldPos, AttackingLimb);
var newLimb = GetAttackLimb(attackWorldPos, previousLimb);
if (newLimb != null) if (newLimb != null)
{ {
// Attack with the new limb // Attack with the new limb
@@ -680,8 +679,7 @@ namespace Barotrauma
else else
{ {
// If the secondary cooldown is defined and expired, check if we can switch the attack // If the secondary cooldown is defined and expired, check if we can switch the attack
var previousLimb = AttackingLimb; var newLimb = GetAttackLimb(attackWorldPos, AttackingLimb);
var newLimb = GetAttackLimb(attackWorldPos, previousLimb);
if (newLimb != null) if (newLimb != null)
{ {
// Attack with the new limb // Attack with the new limb
@@ -725,6 +723,11 @@ namespace Barotrauma
// Check that we can reach the target // Check that we can reach the target
distance = Vector2.Distance(AttackingLimb.WorldPosition, attackWorldPos); distance = Vector2.Distance(AttackingLimb.WorldPosition, attackWorldPos);
canAttack = distance < AttackingLimb.attack.Range; canAttack = distance < AttackingLimb.attack.Range;
if (!canAttack && !IsCoolDownRunning)
{
// If not, reset the attacking limb, if the cooldown is not running
AttackingLimb = null;
}
} }
// If the attacking limb is a hand or claw, for example, using it as the steering limb can end in the result where the character circles around the target. For example the Hammerhead steering with the claws when it should use the torso. // If the attacking limb is a hand or claw, for example, using it as the steering limb can end in the result where the character circles around the target. For example the Hammerhead steering with the claws when it should use the torso.