From f48dfb5862556687c0bb9ae56584f69def14930c Mon Sep 17 00:00:00 2001 From: Markus Isberg <3e849f2e5c@pm.me> Date: Tue, 13 Apr 2021 16:58:13 +0300 Subject: [PATCH] Unstable 0.1300.0.9 --- .../ClientSource/Characters/CharacterHUD.cs | 6 +-- .../ClientSource/GameSession/CrewManager.cs | 4 +- .../ClientSource/GameSession/HintManager.cs | 13 ++++-- .../ClientSource/GameSession/RoundSummary.cs | 13 +++++- .../ClientSource/GameSettings.cs | 5 +++ .../Items/Components/Machines/Sonar.cs | 7 +-- .../ClientSource/Map/Map/Map.cs | 18 +++++++- .../BarotraumaClient/LinuxClient.csproj | 2 +- Barotrauma/BarotraumaClient/MacClient.csproj | 2 +- .../BarotraumaClient/WindowsClient.csproj | 2 +- .../BarotraumaServer/LinuxServer.csproj | 2 +- Barotrauma/BarotraumaServer/MacServer.csproj | 2 +- .../BarotraumaServer/WindowsServer.csproj | 2 +- .../AI/Objectives/AIObjectiveContainItem.cs | 3 +- .../Objectives/AIObjectiveFindDivingGear.cs | 1 + .../AI/Objectives/AIObjectiveGetItem.cs | 19 ++++++++ .../AI/Objectives/AIObjectiveManager.cs | 4 ++ .../SharedSource/Characters/Character.cs | 7 ++- .../SharedSource/Characters/Limb.cs | 8 ++-- .../Events/EventActions/UnlockPathAction.cs | 2 +- .../GameSession/GameModes/CampaignMode.cs | 8 +++- .../Items/Components/Machines/Reactor.cs | 39 +++++++++++------ .../SharedSource/Map/Levels/Level.cs | 9 ++-- .../SharedSource/Map/Map/Map.cs | 1 + .../SharedSource/Map/Submarine.cs | 6 +-- .../SharedSource/Map/SubmarineInfo.cs | 43 +++++++++++++++++++ .../SharedSource/Screens/GameScreen.cs | 2 +- .../SharedSource/TextManager.cs | 17 ++++++-- .../SharedSource/Utils/MTRandom.cs | 16 +++++++ Barotrauma/BarotraumaShared/changelog.txt | 39 +++++++++++++++++ 30 files changed, 245 insertions(+), 57 deletions(-) diff --git a/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterHUD.cs b/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterHUD.cs index dfd7fc7b6..7cb31a3a8 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterHUD.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Characters/CharacterHUD.cs @@ -12,7 +12,7 @@ namespace Barotrauma { class CharacterHUD { - const float BossHealthBarDuration = 1200.0f; + const float BossHealthBarDuration = 120.0f; class BossHealthBar { @@ -615,10 +615,6 @@ namespace Barotrauma { bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 5.0f); } - else if (bossHealthBar.Character.AIController is EnemyAIController enemyAI && !enemyAI.IsTargetingPlayerTeam) - { - bossHealthBar.FadeTimer = Math.Min(bossHealthBar.FadeTimer, 60.0f); - } bossHealthBar.FadeTimer -= deltaTime; } diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs b/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs index 310378f78..5401ed350 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GameSession/CrewManager.cs @@ -3198,10 +3198,10 @@ namespace Barotrauma return characters.Where(c => Character.Controlled == null || ((includeSelf || c != Character.Controlled) && c.TeamID == Character.Controlled.TeamID)).Union(GetOrderableFriendlyNPCs()) // 1. Prioritize those who are on the same submarine than the controlled character .OrderByDescending(c => Character.Controlled == null || c.Submarine == Character.Controlled.Submarine) - // 2. Prioritize those who are already ordered to operate the item target of the new 'operate' order, or given the same maintenance order as now issued + // 2. Prioritize those who have been given the same maintenance or operate order as now issued .ThenByDescending(c => c.CurrentOrders.Any(o => o.Order != null && o.Order.Identifier == order.Identifier && - (order.Category == OrderCategory.Maintenance || (order.Category == OrderCategory.Operate && o.Order.TargetSpatialEntity == order.TargetSpatialEntity)))) + (order.Category == OrderCategory.Maintenance || order.Category == OrderCategory.Operate))) // 3. Prioritize those with the appropriate job for the order .ThenByDescending(c => order.HasAppropriateJob(c)) // 4. Prioritize bots over player controlled characters diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameSession/HintManager.cs b/Barotrauma/BarotraumaClient/ClientSource/GameSession/HintManager.cs index 8e94e385d..ec74f7590 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GameSession/HintManager.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GameSession/HintManager.cs @@ -113,14 +113,16 @@ namespace Barotrauma public static void OnSetSelectedConstruction(Character character, Item oldConstruction, Item newConstruction) { if (oldConstruction == newConstruction) { return; } + if (Character.Controlled != null && Character.Controlled == character && oldConstruction != null && oldConstruction.GetComponent() == null) { TimeStoppedInteracting = Timing.TotalTime; } - if (newConstruction != null && newConstruction.GetComponent() == null) - { - OnStartedInteracting(character, newConstruction); - } + + if (newConstruction == null) { return; } + if (newConstruction.GetComponent() != null) { return; } + if (newConstruction.GetComponent() is ConnectionPanel cp && cp.User == character) { return; } + OnStartedInteracting(character, newConstruction); } private static void OnStartedInteracting(Character character, Item item) @@ -136,6 +138,9 @@ namespace Barotrauma if (DisplayHint($"{hintIdentifierBase}.brokenitem")) { return; } } + // Don't display other item-related hints if the repair interface is displayed + if (item.Repairables.Any(r => r.ShouldDrawHUD(character))) { return; } + // onstartedinteracting.lootingisstealing if (item.Submarine?.Info?.Type == SubmarineType.Outpost && item.ContainedItems.Any(i => !i.AllowStealing)) diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameSession/RoundSummary.cs b/Barotrauma/BarotraumaClient/ClientSource/GameSession/RoundSummary.cs index f58158c45..e0211d8af 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GameSession/RoundSummary.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GameSession/RoundSummary.cs @@ -183,7 +183,8 @@ namespace Barotrauma //reputation panel ------------------------------------------------------------------------------- - if (gameMode is CampaignMode campaignMode) + var campaignMode = gameMode as CampaignMode; + if (campaignMode != null) { GUIFrame reputationframe = new GUIFrame(new RectTransform(crewFrame.RectTransform.RelativeSize, background.RectTransform, Anchor.TopCenter, minSize: crewFrame.RectTransform.MinSize)); rightPanels.Add(reputationframe); @@ -217,7 +218,14 @@ namespace Barotrauma }; List missionsToDisplay = new List(selectedMissions); - if (!selectedMissions.Any() && startLocation?.SelectedMission != null) { missionsToDisplay.Add(startLocation.SelectedMission); } + if (!selectedMissions.Any() && startLocation?.SelectedMission != null) + { + if (startLocation.SelectedMission.Locations[0] == startLocation.SelectedMission.Locations[1] || + startLocation.SelectedMission.Locations.Contains(campaignMode?.Map.SelectedLocation)) + { + missionsToDisplay.Add(startLocation.SelectedMission); + } + } if (missionsToDisplay.Any()) { @@ -461,6 +469,7 @@ namespace Barotrauma new string[] { Reputation.GetFormattedReputationText(normalizedUnlockReputation, unlockEvent.UnlockPathReputation, addColorTags: true), $"‖color:gui.orange‖{connection.LevelData.Biome.DisplayName}‖end‖" }); var unlockInfoPanel = new GUITextBlock(new RectTransform(new Vector2(0.8f, 0.0f), reputationFrame.RectTransform, Anchor.BottomCenter) { MinSize = new Point(0, GUI.IntScale(30)), AbsoluteOffset = new Point(0, GUI.IntScale(3)) }, unlockText, style: "GUIButtonRound", textAlignment: Alignment.Center, textColor: GUI.Style.TextColor, parseRichText: true); + unlockInfoPanel.Color = Color.Lerp(unlockInfoPanel.Color, Color.Black, 0.8f); if (unlockInfoPanel.TextSize.X > unlockInfoPanel.Rect.Width * 0.7f) { unlockInfoPanel.Font = GUI.SmallFont; diff --git a/Barotrauma/BarotraumaClient/ClientSource/GameSettings.cs b/Barotrauma/BarotraumaClient/ClientSource/GameSettings.cs index 8df78be6c..fbeca0143 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GameSettings.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GameSettings.cs @@ -1334,6 +1334,11 @@ namespace Barotrauma OnSelected = (tickBox) => { DisableInGameHints = tickBox.Selected; + if (!DisableInGameHints && GameMain.Config?.IgnoredHints != null) + { + // Reset the ignored hints when the hints are re-enabled (to-be-replaced by a separate button) + GameMain.Config.IgnoredHints.Clear(); + } UnsavedSettings = true; return true; } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Sonar.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Sonar.cs index d1e4b2769..7986a538b 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Sonar.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Machines/Sonar.cs @@ -705,11 +705,12 @@ namespace Barotrauma.Items.Components if (c.Params.HideInSonar) { continue; } if (!c.IsUnconscious && c.Params.DistantSonarRange > 0.0f && - c.AIController is EnemyAIController enemyAI && enemyAI.IsTargetingPlayerTeam && ((c.WorldPosition - transducerCenter) * displayScale).LengthSquared() > DisplayRadius * DisplayRadius) { - float dist = Vector2.Distance(c.WorldPosition, transducerCenter); - Vector2 targetDir = (c.WorldPosition - transducerCenter) / dist; + Vector2 targetVector = c.WorldPosition - transducerCenter; + if (targetVector.LengthSquared() > MathUtils.Pow2(c.Params.DistantSonarRange)) { continue; } + float dist = targetVector.Length(); + Vector2 targetDir = targetVector / dist; int blipCount = (int)MathHelper.Clamp(c.Mass, 50, 200); for (int i = 0; i < blipCount; i++) { diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs index 2fa61bc08..28a0f056c 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Map/Map.cs @@ -70,6 +70,8 @@ namespace Barotrauma private List tooltipRichTextData; private string prevTooltip; + private (SubmarineInfo pendingSub, float realWorldCrushDepth) pendingSubInfo; + /*private (Rectangle targetArea, string tip)? connectionTooltip; private string sanitizedConnectionTooltip; private List connectionTooltipRichTextData; @@ -855,7 +857,21 @@ namespace Barotrauma if (connection.LevelData.HasHuntingGrounds) { iconCount++; } if (connection.Locked) { iconCount++; } string tooltip = null; - var subCrushDepth = Submarine.MainSub?.RealWorldCrushDepth ?? Level.DefaultRealWorldCrushDepth; + float subCrushDepth = Level.DefaultRealWorldCrushDepth; + var currentOrPendingSub = SubmarineSelection.CurrentOrPendingSubmarine(); + if (Submarine.MainSub != null && Submarine.MainSub.Info == currentOrPendingSub) + { + subCrushDepth = Submarine.MainSub.RealWorldCrushDepth; + } + else if (currentOrPendingSub != null) + { + if (pendingSubInfo.pendingSub != currentOrPendingSub) + { + // Store the real world crush depth for the pending sub so that we don't have to calculate it again every time + pendingSubInfo = (currentOrPendingSub, currentOrPendingSub.GetRealWorldCrushDepth()); + } + subCrushDepth = pendingSubInfo.realWorldCrushDepth; + } if (GameMain.GameSession?.Campaign?.UpgradeManager != null) { var hullUpgradePrefab = UpgradePrefab.Find("increasewallhealth"); diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index 745e39e43..ab3b1bf00 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.1300.0.8 + 0.1300.0.9 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index 78c7c9186..d6bba2a26 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.1300.0.8 + 0.1300.0.9 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index ed9694508..6cadcf9de 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.1300.0.8 + 0.1300.0.9 Copyright © FakeFish 2018-2020 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index 3e96d3a1b..f2b90e174 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.1300.0.8 + 0.1300.0.9 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index 06c270aeb..4e57d6419 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.1300.0.8 + 0.1300.0.9 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 5096d88cb..6f6e5c078 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.1300.0.8 + 0.1300.0.9 Copyright © FakeFish 2018-2020 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveContainItem.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveContainItem.cs index 165e53e47..f330e61bd 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveContainItem.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveContainItem.cs @@ -141,7 +141,8 @@ namespace Barotrauma { DialogueIdentifier = "dialogcannotreachtarget", TargetName = container.Item.Name, - abortCondition = obj => !ItemToContain.IsOwnedBy(character) + abortCondition = obj => !ItemToContain.IsOwnedBy(character), + SpeakIfFails = !objectiveManager.IsCurrentOrder() }, onAbandon: () => Abandon = true, onCompleted: () => RemoveSubObjective(ref goToObjective)); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs index 3cecff6d8..9e970389e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveFindDivingGear.cs @@ -87,6 +87,7 @@ namespace Barotrauma }, onAbandon: () => { + getOxygen = null; int remainingTanks = ReportOxygenTankCount(); // Try to seek any oxygen sources. TryAddSubObjective(ref getOxygen, () => diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveGetItem.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveGetItem.cs index f055f2828..83f66b7d2 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveGetItem.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveGetItem.cs @@ -354,6 +354,7 @@ namespace Barotrauma #if DEBUG DebugConsole.NewMessage($"{character.Name}: Cannot find an item with the following identifier(s) or tag(s): {string.Join(", ", identifiersOrTags)}", Color.Yellow); #endif + SpeakCannotFind(); Abandon = true; } } @@ -415,6 +416,24 @@ namespace Barotrauma #if DEBUG DebugConsole.NewMessage($"{character.Name}: Get item failed to reach {moveToTarget}", Color.Yellow); #endif + } + + private void SpeakCannotFind() + { + // TODO: Use the item name as the variable here. + if (character.IsOnPlayerTeam && objectiveManager.CurrentOrder == objectiveManager.CurrentObjective) + { + string msg = TextManager.Get("dialogcannotreachtarget", true); + if (msg != null) + { + character.Speak(msg, identifier: "dialogcannotfinditem", minDurationBetweenSimilar: 20.0f); + } + } + } + + // TODO: remove? + private void SpeakCannotReach() + { if (character.IsOnPlayerTeam && objectiveManager.CurrentOrder == objectiveManager.CurrentObjective) { string TargetName = (moveToTarget as MapEntity)?.Name ?? (moveToTarget as Character)?.Name ?? moveToTarget.ToString(); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveManager.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveManager.cs index 5a98de2e8..efacf53b2 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/AI/Objectives/AIObjectiveManager.cs @@ -166,7 +166,11 @@ namespace Barotrauma coroutine = CoroutineManager.InvokeAfter(() => { //round ended before the coroutine finished +#if CLIENT + if (GameMain.GameSession == null || Level.Loaded == null && !(GameMain.GameSession.GameMode is TestGameMode)) { return; } +#else if (GameMain.GameSession == null || Level.Loaded == null) { return; } +#endif DelayedObjectives.Remove(objective); AddObjective(objective); callback?.Invoke(); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs index 6b4fbbf31..9367444cb 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs @@ -612,10 +612,11 @@ namespace Barotrauma set { #if CLIENT - HintManager.OnSetSelectedConstruction(this, _selectedConstruction, value); + var prevSelectedConstruction = _selectedConstruction; #endif _selectedConstruction = value; #if CLIENT + HintManager.OnSetSelectedConstruction(this, prevSelectedConstruction, _selectedConstruction); if (Controlled == this) { if (_selectedConstruction == null) @@ -3815,6 +3816,10 @@ namespace Barotrauma } } } + else + { + canBePutInOriginalInventory = inventory.CanBePut(newItem, slotIndices[0]); + } if (canBePutInOriginalInventory) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs index c16563dd1..c1e9394a4 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Limb.cs @@ -898,11 +898,11 @@ namespace Barotrauma case HitDetection.Distance: if (dist < attack.DamageRange) { - structureBody = Submarine.PickBody(simPos, attackSimPos, collisionCategory: Physics.CollisionWall | Physics.CollisionLevel, allowInsideFixture: true); - if (structureBody?.UserData as string == "ruinroom") + structureBody = Submarine.PickBody(simPos, attackSimPos, collisionCategory: Physics.CollisionWall | Physics.CollisionLevel, allowInsideFixture: true, customPredicate: + (Fixture f) => { - structureBody = null; - } + return f?.Body?.UserData as string != "ruinroom"; + }); if (damageTarget is Item i && i.GetComponent() != null) { // If the attack is aimed to an item and hits an item, it's successful. diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/UnlockPathAction.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/UnlockPathAction.cs index 14c0c9763..51ef8e0cf 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/UnlockPathAction.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/UnlockPathAction.cs @@ -31,10 +31,10 @@ namespace Barotrauma foreach (LocationConnection connection in GameMain.GameSession?.Map?.CurrentLocation?.Connections) { if (!connection.Locked) { continue; } + connection.Locked = false; #if SERVER NotifyUnlock(connection); #else - connection.Locked = false; new GUIMessageBox(string.Empty, TextManager.Get("pathunlockedgeneric"), new string[0], type: GUIMessageBox.Type.InGame, iconStyle: "UnlockPathIcon", relativeSize: new Vector2(0.3f, 0.15f), minSize: new Point(512, 128)); #endif diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs b/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs index 03185653b..a7659ef7a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/GameSession/GameModes/CampaignMode.cs @@ -115,7 +115,11 @@ namespace Barotrauma { if (Map.CurrentLocation?.SelectedMission != null) { - yield return Map.CurrentLocation.SelectedMission; + if (Map.CurrentLocation.SelectedMission.Locations[0] == Map.CurrentLocation.SelectedMission.Locations[1] || + Map.CurrentLocation.SelectedMission.Locations.Contains(Map.SelectedLocation)) + { + yield return Map.CurrentLocation.SelectedMission; + } } foreach (Mission mission in extraMissions) { @@ -279,7 +283,7 @@ namespace Barotrauma { Random rand = new MTRandom(ToolBox.StringToInt(levelData.Seed)); var huntingGroundsMissionPrefab = huntingGroundsMissionPrefabs.GetRandom(rand); - if (!Missions.Any(m => m.Prefab.Type == huntingGroundsMissionPrefab.Type)) + if (!Missions.Any(m => m.Prefab.Tags.Any(t => t.Equals("huntinggrounds", StringComparison.OrdinalIgnoreCase)))) { extraMissions.Add(huntingGroundsMissionPrefab.Instantiate(Map.SelectedConnection.Locations)); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Reactor.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Reactor.cs index 0a66e7c23..6e0073d67 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Reactor.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Machines/Reactor.cs @@ -590,8 +590,7 @@ namespace Barotrauma.Items.Components var container = item.GetComponent(); if (objective.SubObjectives.None()) { - int itemCount = item.ContainedItems.Count(i => i != null && container.ContainableItems.Any(ri => ri.MatchesItem(i))) + 1; - var containObjective = AIContainItems(container, character, objective, itemCount, equip: false, removeEmpty: true, spawnItemIfNotFound: character.TeamID == CharacterTeamType.FriendlyNPC, dropItemOnDeselected: true); + var containObjective = AIContainItems(container, character, objective, itemCount: 1, equip: true, removeEmpty: true, spawnItemIfNotFound: character.TeamID == CharacterTeamType.FriendlyNPC, dropItemOnDeselected: true); containObjective.Completed += ReportFuelRodCount; containObjective.Abandoned += ReportFuelRodCount; character.Speak(TextManager.Get("DialogReactorFuel"), null, 0.0f, "reactorfuel", 30.0f); @@ -613,19 +612,15 @@ namespace Barotrauma.Items.Components } return outOfFuel; } - else if (TooMuchFuel()) + else { - if (item.OwnInventory?.AllItems != null) + if (TooMuchFuel()) { - var container = item.GetComponent(); - foreach (Item item in item.OwnInventory.AllItemsMod) - { - if (container.ContainableItems.Any(ri => ri.MatchesItem(item))) - { - item.Drop(character); - break; - } - } + DropFuel(minCondition: 0.1f, maxCondition: 100); + } + else + { + DropFuel(minCondition: 0, maxCondition: 0); } } } @@ -692,6 +687,23 @@ namespace Barotrauma.Items.Components aiUpdateTimer = AIUpdateInterval; return false; } + + + void DropFuel(float minCondition, float maxCondition) + { + if (item.OwnInventory?.AllItems != null) + { + var container = item.GetComponent(); + foreach (Item item in item.OwnInventory.AllItemsMod) + { + if (item.ConditionPercentage <= maxCondition && item.ConditionPercentage >= minCondition) + { + item.Drop(character); + break; + } + } + } + } } public override void OnMapLoaded() @@ -735,6 +747,5 @@ namespace Barotrauma.Items.Components break; } } - } } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs index 78291bc7a..8f0249de4 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs @@ -3598,10 +3598,13 @@ namespace Barotrauma if (!(GameMain.NetworkMember?.IsClient ?? false)) { //empty the reactor - foreach (Item item in reactorContainer.Inventory.AllItems) + if (reactorContainer != null) { - if (item.NonInteractable) { continue; } - Spawner.AddToRemoveQueue(item); + foreach (Item item in reactorContainer.Inventory.AllItems) + { + if (item.NonInteractable) { continue; } + Spawner.AddToRemoveQueue(item); + } } //remove wires diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs index 5758239f9..8b68c952a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Map/Map.cs @@ -1082,6 +1082,7 @@ namespace Barotrauma int currentLocationConnection = element.GetAttributeInt("currentlocationconnection", -1); if (currentLocationConnection >= 0) { + Connections[currentLocationConnection].Locked = false; SelectLocation(Connections[currentLocationConnection].OtherLocation(CurrentLocation)); } else diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs index becbec2ad..e6e6254ee 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Submarine.cs @@ -165,10 +165,7 @@ namespace Barotrauma if (structure.Submarine != this || !structure.HasBody || structure.Indestructible) { continue; } realWorldCrushDepth = Math.Min(structure.CrushDepth, realWorldCrushDepth.Value); } - if (Info.SubmarineClass == SubmarineClass.DeepDiver) - { - realWorldCrushDepth *= 1.2f; - } + realWorldCrushDepth *= Info.GetRealWorldCrushDepthMultiplier(); } return realWorldCrushDepth.Value; } @@ -1060,6 +1057,7 @@ namespace Barotrauma } steering.MaintainPos = true; + steering.PosToMaintain = WorldPosition; steering.AutoPilot = true; #if SERVER steering.UnsentChanges = true; diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/SubmarineInfo.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/SubmarineInfo.cs index 0d3b84d90..97c714f73 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/SubmarineInfo.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/SubmarineInfo.cs @@ -464,6 +464,49 @@ namespace Barotrauma } } + /// + /// Calculated from . Can be used when the sub hasn't been loaded and we can't access . + /// + public float GetRealWorldCrushDepth() + { + if (SubmarineElement == null) { return Level.DefaultRealWorldCrushDepth; } + bool structureCrushDepthsDefined = false; + float realWorldCrushDepth = float.PositiveInfinity; + foreach (var structureElement in SubmarineElement.GetChildElements("structure")) + { + string name = structureElement.Attribute("name")?.Value ?? ""; + string identifier = structureElement.GetAttributeString("identifier", ""); + var structurePrefab = Structure.FindPrefab(name, identifier); + if (structurePrefab == null || !structurePrefab.Body) { continue; } + if (!structureCrushDepthsDefined && structureElement.Attribute("crushdepth") != null) + { + structureCrushDepthsDefined = true; + } + float structureCrushDepth = structureElement.GetAttributeFloat("crushdepth", float.PositiveInfinity); + realWorldCrushDepth = Math.Min(structureCrushDepth, realWorldCrushDepth); + } + if (!structureCrushDepthsDefined) + { + realWorldCrushDepth = Level.DefaultRealWorldCrushDepth; + } + realWorldCrushDepth *= GetRealWorldCrushDepthMultiplier(); + return realWorldCrushDepth; + } + + /// + /// Based on + /// + public float GetRealWorldCrushDepthMultiplier() + { + if (SubmarineClass == SubmarineClass.DeepDiver) + { + return 1.2f; + } + else + { + return 1.0f; + } + } //saving/loading ---------------------------------------------------- public bool SaveAs(string filePath, System.IO.MemoryStream previewImage = null) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs b/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs index ea6aa2f24..f506479fd 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs @@ -224,7 +224,7 @@ namespace Barotrauma if (Character.Controlled != null && Lights.LightManager.ViewTarget != null) { - Vector2 targetPos = Lights.LightManager.ViewTarget.DrawPosition; + Vector2 targetPos = Lights.LightManager.ViewTarget.WorldPosition; if (Lights.LightManager.ViewTarget == Character.Controlled && (CharacterHealth.OpenHealthWindow != null || CrewManager.IsCommandInterfaceOpen || ConversationAction.IsDialogOpen)) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/TextManager.cs b/Barotrauma/BarotraumaShared/SharedSource/TextManager.cs index b9ae5a165..c7aa407ea 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/TextManager.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/TextManager.cs @@ -4,6 +4,7 @@ using Barotrauma.IO; using System.Linq; using System.Text; using System.Text.RegularExpressions; +using Barotrauma.Extensions; namespace Barotrauma { @@ -202,6 +203,8 @@ namespace Barotrauma return false; } + private static readonly List availableTexts = new List(); + public static string Get(string textTag, bool returnNull = false, string fallBackTag = null, bool useEnglishAsFallBack = true) { lock (mutex) @@ -228,11 +231,19 @@ namespace Barotrauma return textTag; } #endif - + availableTexts.Clear(); foreach (TextPack textPack in textPacks[Language]) { - string text = textPack.Get(textTag); - if (text != null) { return text; } + var texts = textPack.GetAll(textTag); + if (texts != null) + { + availableTexts.AddRange(texts); + } + } + + if (availableTexts.Any()) + { + return availableTexts.GetRandom().Replace(@"\n", "\n"); } if (!string.IsNullOrEmpty(fallBackTag)) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Utils/MTRandom.cs b/Barotrauma/BarotraumaShared/SharedSource/Utils/MTRandom.cs index 8da34cff0..9b634f90a 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Utils/MTRandom.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Utils/MTRandom.cs @@ -84,6 +84,22 @@ namespace Barotrauma return retval; } + public override int Next(int minValue, int maxValue) + { + int range = maxValue - minValue; + return minValue + Next(range); + } + + public override void NextBytes(byte[] buffer) + { + throw new NotImplementedException(); + } + + public override void NextBytes(Span buffer) + { + throw new NotImplementedException(); + } + /// /// Returns a random value is greater or equal than 0 and less than maxValue /// diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt index 74a5e5b6b..e366aa5b2 100644 --- a/Barotrauma/BarotraumaShared/changelog.txt +++ b/Barotrauma/BarotraumaShared/changelog.txt @@ -1,3 +1,42 @@ +--------------------------------------------------------------------------------------------------------- +v0.1300.0.9 (unstable) +--------------------------------------------------------------------------------------------------------- + +Changes: +- Re-enabling in-game hints now resets hints previously set not be shown again. +- Reduced the stun duration of Molochs' and Hammerheads' attacks. Also add some bitewounds damage on the Molochs' attacks so that they trigger all the AI reactions and don't get treated as failed attacks. + +Fixes: +- Fixed occasional "mission mismatch" errors when entering a hunting grounds level in the multiplayer campaign. +- Fixed camera shaking/vibrating when moving at high speed. +- Fixed monsters being able to attack through ruin walls. +- Fixed overlapping vending machine & light switch in CrewModule_02. +- Fixed respawn shuttle maintaining an incorrect position after getting dispatched. +- Fixed selected mission carrying over to whichever level you choose in the campaign. +- Fixed diving suit's vision obstructing effect disappearing if you also wear a diving mask. +- Removed unnecessary extra light components from large and normal engine. +- Fixed "attempted to select a locked connection" error when a player joins mid-round after the path to the next biome has been unlocked. +- Fixed campaign map crush depth warnings being always calculated for the currently docked submarine, not taking a possible pending submarine switch into account. +- Fixed Hammerhead Spawns not targeting decoys. +- Fixed the abyss monsters not targeting "provocative" items, like flares, glowsticks, scooters etc. +- Fixed Hammerhead Matriarch constantly fleeing from divers. It's intentional that that the matriarch avoids the divers, but not as much. Now they should flee briefly only when shot by the player, making it possible for the divers to reach it (#5449). +- Fixed distant sonar waves not being visible in multiplayer. +- Fixed distant sonar waves being visible from too far away. +- Fixed the boss health bar vanishing too quickly in the multiplayer game mode. +- Fixed bots sometimes getting stuck while trying to find a safer room, if they fail to find any oxygen tanks. They should run to a safety instead. +- Fixed monsters moving weirdly in multiplayer game (only unstable). + +Modding: +- Fixed custom loading screen tips not showing up if the vanilla content package is enabled. +- Fixed crashing when loading a save where a stack contains more items than the maximum stack size for the item/container. + +Bots: +- Fixed bots reporting unnecessarily when they abort a cleaning up task (#5400). Also fixes (much more rare) unnecessary reporting with the other orders. +- Fixed some inconsistencies in the automatic crew selection logic used for assigning orders without specifying the target. +- Fixed bots putting multiple fuel rods in the reactor if there's more than one rod in the reactor (#5213). Fixed bots swapping out full fuel rods from the reactor (#5503). Both issues closely related. +- Fixed job specific autonomous objectives being broken in the sub test mode. +- Fixed bots taking items from fabricators and deconstructors (#5431). + --------------------------------------------------------------------------------------------------------- v0.1300.0.8 (unstable) ---------------------------------------------------------------------------------------------------------