From 1fb558d7efe91217a7562d716e552a18ba1edfdd Mon Sep 17 00:00:00 2001 From: Joonas Rikkonen Date: Thu, 23 May 2019 15:08:27 +0300 Subject: [PATCH] (84593b8fb) Fixed: Oxygen levels of the patient on the submarine being adjusted too late --- .../BarotraumaClient/Source/DebugConsole.cs | 12 ---------- .../Source/GameSession/CrewManager.cs | 2 +- .../GameModes/Tutorials/DoctorTutorial.cs | 6 +++-- .../BarotraumaShared/SharedContent.projitems | 6 ----- .../Source/Characters/AI/HumanAIController.cs | 10 ++++----- .../AI/Objectives/AIObjectiveLoop.cs | 1 - .../AI/Objectives/AIObjectiveRescueAll.cs | 22 +++---------------- .../BarotraumaShared/Source/DebugConsole.cs | 14 +++++++++++- 8 files changed, 25 insertions(+), 48 deletions(-) diff --git a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs index f8a34fd0f..98320ab69 100644 --- a/Barotrauma/BarotraumaClient/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaClient/Source/DebugConsole.cs @@ -401,18 +401,6 @@ namespace Barotrauma GameMain.CharacterEditorScreen.Select(); })); - commands.Add(new Command("money", "", args => - { - if (args.Length == 0) { return; } - if (GameMain.GameSession.GameMode is CampaignMode campaign) - { - if (int.TryParse(args[0], out int money)) - { - campaign.Money += money; - } - } - }, isCheat: true)); - AssignRelayToServer("kick", false); AssignRelayToServer("kickid", false); AssignRelayToServer("ban", false); diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs index bf758c5ea..f85cd2475 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/CrewManager.cs @@ -1353,7 +1353,7 @@ namespace Barotrauma bool hasLeaks = Character.Controlled.CurrentHull.Submarine != null && Character.Controlled.CurrentHull.ConnectedGaps.Any(g => !g.IsRoomToRoom && g.Open > 0.0f); ToggleReportButton("reportbreach", hasLeaks); - bool hasIntruders = Character.CharacterList.Any(c => c.CurrentHull == Character.Controlled.CurrentHull && AIObjectiveFightIntruders.IsValidTarget(c, Character.Controlled)); + bool hasIntruders = Character.CharacterList.Any(c => c.CurrentHull == Character.Controlled.CurrentHull && AIObjectiveFightIntruders.IsValidTarget(Character.Controlled, c)); ToggleReportButton("reportintruders", hasIntruders); foreach (GUIComponent reportButton in reportButtonFrame.Children) diff --git a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs index ef9a5000c..186656d22 100644 --- a/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs +++ b/Barotrauma/BarotraumaClient/Source/GameSession/GameModes/Tutorials/DoctorTutorial.cs @@ -364,6 +364,10 @@ namespace Barotrauma.Tutorials { yield return new WaitForSeconds(1.0f, false); } + + subPatients[2].Oxygen = -50; + CoroutineManager.StartCoroutine(KeepPatientAlive(subPatients[2]), "KeepPatient3Alive"); + yield return new WaitForSeconds(5.0f, false); GameMain.GameSession.CrewManager.AddSinglePlayerChatMessage(radioSpeakerName, TextManager.Get("Doctor.Radio.EnteredSub"), ChatMessageType.Radio, null); @@ -376,8 +380,6 @@ namespace Barotrauma.Tutorials patient.AIController.Enabled = true; SetHighlight(patient, true); } - subPatients[2].Oxygen = -50; - CoroutineManager.StartCoroutine(KeepPatientAlive(subPatients[2]), "KeepPatient3Alive"); double subEnterTime = Timing.TotalTime; diff --git a/Barotrauma/BarotraumaShared/SharedContent.projitems b/Barotrauma/BarotraumaShared/SharedContent.projitems index 4e8cb7f62..0ae98ed44 100644 --- a/Barotrauma/BarotraumaShared/SharedContent.projitems +++ b/Barotrauma/BarotraumaShared/SharedContent.projitems @@ -454,15 +454,9 @@ PreserveNewest - - PreserveNewest - PreserveNewest - - PreserveNewest - PreserveNewest diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs index e1587cdfc..7b61861e2 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/HumanAIController.cs @@ -321,13 +321,11 @@ namespace Barotrauma if (c.CurrentHull != hull) { continue; } if (AIObjectiveRescueAll.IsValidTarget(c, Character)) { - if (AddTargets(c, Character)) + AddTargets(c, Character); + if (newOrder == null) { - if (newOrder == null) - { - var orderPrefab = Order.PrefabList.Find(o => o.AITag == "requestfirstaid"); - newOrder = new Order(orderPrefab, c.CurrentHull, null, orderGiver: Character); - } + var orderPrefab = Order.PrefabList.Find(o => o.AITag == "requestfirstaid"); + newOrder = new Order(orderPrefab, c.CurrentHull, null, orderGiver: Character); } } } diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs index 82a276ec0..1d0816dca 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveLoop.cs @@ -21,7 +21,6 @@ namespace Barotrauma public bool AddTarget(T target) { - if (character.IsDead) { return false; } if (ReportedTargets.Contains(target)) { return false; diff --git a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs index e520495bf..11d22f454 100644 --- a/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs +++ b/Barotrauma/BarotraumaShared/Source/Characters/AI/Objectives/AIObjectiveRescueAll.cs @@ -10,17 +10,7 @@ namespace Barotrauma private const float vitalityThreshold = 0.8f; private const float vitalityThresholdForOrders = 0.95f; - public static float GetVitalityThreshold(AIObjectiveManager manager) - { - if (manager == null) - { - return vitalityThreshold; - } - else - { - return manager.CurrentOrder is AIObjectiveRescueAll ? vitalityThresholdForOrders : vitalityThreshold; - } - } + public static float GetVitalityThreshold(AIObjectiveManager manager) => manager.CurrentOrder is AIObjectiveRescueAll ? vitalityThresholdForOrders : vitalityThreshold; public AIObjectiveRescueAll(Character character, AIObjectiveManager objectiveManager, float priorityModifier = 1) : base(character, objectiveManager, priorityModifier) { } @@ -45,14 +35,8 @@ namespace Barotrauma { if (target == null || target.IsDead || target.Removed) { return false; } if (!HumanAIController.IsFriendly(character, target)) { return false; } - if (character.AIController is HumanAIController humanAI) - { - if (target.Bleeding < 1 && target.Vitality / target.MaxVitality > GetVitalityThreshold(humanAI.ObjectiveManager)) { return false; } - } - else - { - if (target.Bleeding < 1 && target.Vitality / target.MaxVitality > vitalityThreshold) { return false; } - } + if (!(character.AIController is HumanAIController humanAI)) { return false; } + if (target.Bleeding < 1 && target.Vitality / target.MaxVitality > GetVitalityThreshold(humanAI.ObjectiveManager)) { return false; } if (target.Submarine == null) { return false; } if (target.Submarine.TeamID != character.Submarine.TeamID) { return false; } if (target.CurrentHull == null) { return false; } diff --git a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs index e1acbd9d4..39d8abd87 100644 --- a/Barotrauma/BarotraumaShared/Source/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/Source/DebugConsole.cs @@ -615,7 +615,7 @@ namespace Barotrauma NewMessage(Hull.EditWater ? "Water editing on" : "Water editing off", Color.White); }, isCheat: true)); - commands.Add(new Command("eventmanager", "eventmanager: Toggle event manager on/off. No new random events are created when the event manager is disabled.", (string[] args) => + commands.Add(new Command("fire|editfire", "fire/editfire: Allows putting up fires by left clicking.", (string[] args) => { Hull.EditFire = !Hull.EditFire; NewMessage(Hull.EditFire ? "Fire spawning on" : "Fire spawning off", Color.White); @@ -988,6 +988,18 @@ namespace Barotrauma #endif NewMessage("Set packet duplication to " + (int)(duplicates * 100) + "%.", Color.White); })); + + commands.Add(new Command("money", "", args => + { + if (args.Length == 0) { return; } + if (GameMain.GameSession.GameMode is CampaignMode campaign) + { + if (int.TryParse(args[0], out int money)) + { + campaign.Money += money; + } + } + }, isCheat: true)); #endif //"dummy commands" that only exist so that the server can give clients permissions to use them