diff --git a/Barotrauma/BarotraumaClient/ClientSource/Characters/Attack.cs b/Barotrauma/BarotraumaClient/ClientSource/Characters/Attack.cs index 890be7cb1..a350ef029 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Characters/Attack.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Characters/Attack.cs @@ -42,7 +42,7 @@ namespace Barotrauma if (sound != null) { - SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, ignoreMuffling: sound.IgnoreMuffling); + SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, ignoreMuffling: sound.IgnoreMuffling, freqMult: sound.GetRandomFrequencyMultiplier()); } } } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaClient/ClientSource/Characters/Health/CharacterHealth.cs index ac3cbf968..05903b126 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Characters/Health/CharacterHealth.cs @@ -32,12 +32,6 @@ namespace Barotrauma public static Sprite DamageOverlay => DamageOverlayPrefab.Prefabs.ActivePrefab.DamageOverlay; - private readonly static LocalizedString[] strengthTexts = new LocalizedString[] - { - TextManager.Get("AfflictionStrengthLow"), - TextManager.Get("AfflictionStrengthMedium"), - TextManager.Get("AfflictionStrengthHigh") - }; private Point screenResolution; @@ -1065,7 +1059,7 @@ namespace Barotrauma private readonly List statusIcons = new List(); private readonly Dictionary statusIconVisibleTime = new Dictionary(); - private float hideStatusIconDelay = 5.0f; + private const float HideStatusIconDelay = 5.0f; public void UpdateStatusHUD(float deltaTime) { @@ -1148,7 +1142,7 @@ namespace Barotrauma CanBeFocused = false }; } - if (afflictionPrefab.HideIconAfterDelay && statusIconVisibleTime[afflictionPrefab] > hideStatusIconDelay) + if (afflictionPrefab.HideIconAfterDelay && statusIconVisibleTime[afflictionPrefab] > HideStatusIconDelay) { matchingIcon.RectTransform.Parent = hiddenAfflictionIconContainer.RectTransform; } @@ -1179,6 +1173,7 @@ namespace Barotrauma hiddenAfflictionHoverArea = Rectangle.Union(hiddenAfflictionHoverArea, child.Rect); } + afflictionIconContainer.Visible = true; hiddenAfflictionIconContainer.Visible = showHiddenAfflictionsButton.Rect.Contains(PlayerInput.MousePosition) || (hiddenAfflictionIconContainer.Visible && hiddenAfflictionHoverArea.Contains(PlayerInput.MousePosition)); @@ -1203,6 +1198,7 @@ namespace Barotrauma } else { + afflictionIconContainer.Visible = hiddenAfflictionIconContainer.Visible = false; if (Vitality > 0.0f) { float currHealth = healthWindowHealthBar.BarSize; @@ -1531,8 +1527,7 @@ namespace Barotrauma Point nameDims = new Point(afflictionName.Rect.Width, (int)(GUIStyle.LargeFont.Size * 1.5f)); - afflictionStrength.Text = strengthTexts[ - MathHelper.Clamp((int)Math.Floor((affliction.Strength / affliction.Prefab.MaxStrength) * strengthTexts.Length), 0, strengthTexts.Length - 1)]; + afflictionStrength.Text = affliction.GetStrengthText(); Vector2 strengthDims = GUIStyle.SubHeadingFont.MeasureString(afflictionStrength.Text); @@ -1662,8 +1657,7 @@ namespace Barotrauma var strengthText = labelContainer.GetChildByUserData("strength") as GUITextBlock; - strengthText.Text = strengthTexts[ - MathHelper.Clamp((int)Math.Floor((affliction.Strength / affliction.Prefab.MaxStrength) * strengthTexts.Length), 0, strengthTexts.Length - 1)]; + strengthText.Text = affliction.GetStrengthText(); strengthText.TextColor = Color.Lerp(GUIStyle.Orange, GUIStyle.Red, affliction.Strength / affliction.Prefab.MaxStrength); diff --git a/Barotrauma/BarotraumaClient/ClientSource/GUI/MedicalClinicUI.cs b/Barotrauma/BarotraumaClient/ClientSource/GUI/MedicalClinicUI.cs index 6e7e2e637..6f5272743 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/GUI/MedicalClinicUI.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/GUI/MedicalClinicUI.cs @@ -858,9 +858,9 @@ namespace Barotrauma GUITextBlock prefabBlock = new GUITextBlock(new RectTransform(new Vector2(0.5f, 1f), topTextLayout.RectTransform), prefab.Name, font: GUIStyle.SubHeadingFont); - Color textColor = Color.Lerp(GUIStyle.Orange, GUIStyle.Red, (int)affliction.AfflictionSeverity / 2f); + Color textColor = Color.Lerp(GUIStyle.Orange, GUIStyle.Red, affliction.Strength / affliction.Prefab.MaxStrength); - LocalizedString vitalityText = TextManager.GetWithVariable("medicalclinic.vitalitydifference", "[amount]", (-affliction.Strength).ToString()); + LocalizedString vitalityText = affliction.VitalityDecrease == 0 ? string.Empty : TextManager.GetWithVariable("medicalclinic.vitalitydifference", "[amount]", (-affliction.VitalityDecrease).ToString()); GUITextBlock vitalityBlock = new GUITextBlock(new RectTransform(new Vector2(0.25f, 1f), topTextLayout.RectTransform), vitalityText, textAlignment: Alignment.Center) { TextColor = textColor, @@ -869,7 +869,7 @@ namespace Barotrauma AutoScaleHorizontal = true }; - LocalizedString severityText = TextManager.Get($"AfflictionStrength{affliction.AfflictionSeverity}"); + LocalizedString severityText = Affliction.GetStrengthText(affliction.Strength, affliction.Prefab.MaxStrength); GUITextBlock severityBlock = new GUITextBlock(new RectTransform(new Vector2(0.25f, 1f), topTextLayout.RectTransform), severityText, textAlignment: Alignment.Center, font: GUIStyle.SubHeadingFont) { TextColor = textColor, diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/RangedWeapon.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/RangedWeapon.cs index 8a605499d..fd8f360eb 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/RangedWeapon.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Holdable/RangedWeapon.cs @@ -114,8 +114,8 @@ namespace Barotrauma.Items.Components { if (chargeSound != null) { - chargeSoundChannel = SoundPlayer.PlaySound(chargeSound.Sound, item.WorldPosition, chargeSound.Volume, chargeSound.Range, ignoreMuffling: chargeSound.IgnoreMuffling); - if (chargeSoundChannel != null) chargeSoundChannel.Looping = true; + chargeSoundChannel = SoundPlayer.PlaySound(chargeSound.Sound, item.WorldPosition, chargeSound.Volume, chargeSound.Range, ignoreMuffling: chargeSound.IgnoreMuffling, freqMult: chargeSound.GetRandomFrequencyMultiplier()); + if (chargeSoundChannel != null) { chargeSoundChannel.Looping = true; } } } else if (chargeSoundChannel != null) diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Turret.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Turret.cs index a5395e8e0..701a5474e 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Turret.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Components/Turret.cs @@ -212,14 +212,14 @@ namespace Barotrauma.Items.Components { if (moveSoundChannel == null && startMoveSound != null) { - moveSoundChannel = SoundPlayer.PlaySound(startMoveSound.Sound, item.WorldPosition, startMoveSound.Volume, startMoveSound.Range, ignoreMuffling: startMoveSound.IgnoreMuffling); + moveSoundChannel = SoundPlayer.PlaySound(startMoveSound.Sound, item.WorldPosition, startMoveSound.Volume, startMoveSound.Range, ignoreMuffling: startMoveSound.IgnoreMuffling, freqMult: startMoveSound.GetRandomFrequencyMultiplier()); } else if (moveSoundChannel == null || !moveSoundChannel.IsPlaying) { if (moveSound != null) { moveSoundChannel.FadeOutAndDispose(); - moveSoundChannel = SoundPlayer.PlaySound(moveSound.Sound, item.WorldPosition, moveSound.Volume, moveSound.Range, ignoreMuffling: moveSound.IgnoreMuffling); + moveSoundChannel = SoundPlayer.PlaySound(moveSound.Sound, item.WorldPosition, moveSound.Volume, moveSound.Range, ignoreMuffling: moveSound.IgnoreMuffling, freqMult: moveSound.GetRandomFrequencyMultiplier()); if (moveSoundChannel != null) moveSoundChannel.Looping = true; } } @@ -231,7 +231,7 @@ namespace Barotrauma.Items.Components if (endMoveSound != null && moveSoundChannel.Sound != endMoveSound.Sound) { moveSoundChannel.FadeOutAndDispose(); - moveSoundChannel = SoundPlayer.PlaySound(endMoveSound.Sound, item.WorldPosition, endMoveSound.Volume, endMoveSound.Range, ignoreMuffling: endMoveSound.IgnoreMuffling); + moveSoundChannel = SoundPlayer.PlaySound(endMoveSound.Sound, item.WorldPosition, endMoveSound.Volume, endMoveSound.Range, ignoreMuffling: endMoveSound.IgnoreMuffling, freqMult: endMoveSound.GetRandomFrequencyMultiplier()); if (moveSoundChannel != null) moveSoundChannel.Looping = false; } else if (!moveSoundChannel.IsPlaying) @@ -260,7 +260,7 @@ namespace Barotrauma.Items.Components { if (chargeSound != null) { - chargeSoundChannel = SoundPlayer.PlaySound(chargeSound.Sound, item.WorldPosition, chargeSound.Volume, chargeSound.Range, ignoreMuffling: chargeSound.IgnoreMuffling); + chargeSoundChannel = SoundPlayer.PlaySound(chargeSound.Sound, item.WorldPosition, chargeSound.Volume, chargeSound.Range, ignoreMuffling: chargeSound.IgnoreMuffling, freqMult: chargeSound.GetRandomFrequencyMultiplier()); if (chargeSoundChannel != null) chargeSoundChannel.Looping = true; } } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Items/Inventory.cs b/Barotrauma/BarotraumaClient/ClientSource/Items/Inventory.cs index d0a4414a1..0694c838a 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Items/Inventory.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Items/Inventory.cs @@ -1616,7 +1616,9 @@ namespace Barotrauma } else { - var containedItem = itemContainer.Inventory.slots[Math.Max(itemContainer.ContainedStateIndicatorSlot, 0)].FirstOrDefault(); + + int targetSlot = Math.Max(itemContainer.ContainedStateIndicatorSlot, 0); + var containedItem = itemContainer.Inventory.slots[targetSlot].FirstOrDefault(); containedState = itemContainer.Inventory.Capacity == 1 || itemContainer.ContainedStateIndicatorSlot > -1 ? (containedItem == null ? 0.0f : containedItem.Condition / containedItem.MaxCondition) : @@ -1624,10 +1626,10 @@ namespace Barotrauma if (containedItem != null && (itemContainer.Inventory.Capacity == 1 || itemContainer.HasSubContainers)) { - int maxStackSize = Math.Min(containedItem.Prefab.MaxStackSize, itemContainer.GetMaxStackSize(0)); + int maxStackSize = Math.Min(containedItem.Prefab.MaxStackSize, itemContainer.GetMaxStackSize(targetSlot)); if (maxStackSize > 1 || containedItem.Prefab.HideConditionBar) { - containedState = itemContainer.Inventory.slots[0].Items.Count / (float)maxStackSize; + containedState = itemContainer.Inventory.slots[targetSlot].Items.Count / (float)maxStackSize; } } } diff --git a/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelObjects/LevelObject.cs b/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelObjects/LevelObject.cs index ce1348882..f5fc36a94 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelObjects/LevelObject.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Map/Levels/LevelObjects/LevelObject.cs @@ -226,7 +226,7 @@ namespace Barotrauma { if (SoundChannels[i] == null || !SoundChannels[i].IsPlaying) { - SoundChannels[i] = roundSound.Sound.Play(roundSound.Volume, roundSound.Range, soundPos); + SoundChannels[i] = roundSound.Sound.Play(roundSound.Volume, roundSound.Range, roundSound.GetRandomFrequencyMultiplier(), soundPos); } SoundChannels[i].Position = new Vector3(soundPos.X, soundPos.Y, 0.0f); } diff --git a/Barotrauma/BarotraumaClient/ClientSource/PlayerInput.cs b/Barotrauma/BarotraumaClient/ClientSource/PlayerInput.cs index 5b09b97aa..23c90ff23 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/PlayerInput.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/PlayerInput.cs @@ -59,6 +59,7 @@ namespace Barotrauma switch (MouseButton) { case MouseButton.None: + if (Key == Keys.None) { return false; } return PlayerInput.KeyDown(Key); case MouseButton.PrimaryMouse: return PlayerInput.PrimaryMouseButtonHeld(); @@ -88,6 +89,7 @@ namespace Barotrauma switch (MouseButton) { case MouseButton.None: + if (Key == Keys.None) { return false; } return PlayerInput.KeyHit(Key); case MouseButton.PrimaryMouse: return PlayerInput.PrimaryMouseButtonClicked(); diff --git a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs index c8366b171..a1417adcd 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Screens/SubEditorScreen.cs @@ -208,7 +208,7 @@ namespace Barotrauma private GUIFrame wiringToolPanel; - private DateTime editorSelectedTime; + private Option editorSelectedTime; private GUIImage previewImage; private GUILayoutGroup previewImageButtonHolder; @@ -1391,7 +1391,7 @@ namespace Barotrauma if (backedUpSubInfo != null) { name = backedUpSubInfo.Name; } subNameLabel.Text = ToolBox.LimitString(name, subNameLabel.Font, subNameLabel.Rect.Width); - editorSelectedTime = DateTime.Now; + editorSelectedTime = Option.Some(DateTime.Now); GUI.ForceMouseOn(null); SetMode(Mode.Default); @@ -1540,9 +1540,13 @@ namespace Barotrauma autoSaveLabel?.Parent?.RemoveChild(autoSaveLabel); autoSaveLabel = null; - TimeSpan timeInEditor = DateTime.Now - editorSelectedTime; #if USE_STEAM - SteamAchievementManager.IncrementStat("hoursineditor".ToIdentifier(), (float)timeInEditor.TotalHours); + if (editorSelectedTime.TryUnwrap(out DateTime selectedTime)) + { + TimeSpan timeInEditor = DateTime.Now - selectedTime; + SteamAchievementManager.IncrementStat("hoursineditor".ToIdentifier(), (float)timeInEditor.TotalHours); + editorSelectedTime = Option.None(); + } #endif GUI.ForceMouseOn(null); diff --git a/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs b/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs index 86fb3e0f8..9927c01b8 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/StatusEffects/StatusEffect.cs @@ -140,7 +140,7 @@ namespace Barotrauma GameAnalyticsManager.AddErrorEventOnce("StatusEffect.ApplyProjSpecific:SoundNull1" + Environment.StackTrace.CleanupStackTrace(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg); return; } - soundChannel = SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, hullGuess: hull, ignoreMuffling: sound.IgnoreMuffling); + soundChannel = SoundPlayer.PlaySound(sound.Sound, worldPosition, sound.Volume, sound.Range, hullGuess: hull, ignoreMuffling: sound.IgnoreMuffling, freqMult: sound.GetRandomFrequencyMultiplier()); ignoreMuffling = sound.IgnoreMuffling; if (soundChannel != null) { soundChannel.Looping = loopSound; } } @@ -167,7 +167,7 @@ namespace Barotrauma GameAnalyticsManager.AddErrorEventOnce("StatusEffect.ApplyProjSpecific:SoundNull2" + Environment.StackTrace.CleanupStackTrace(), GameAnalyticsManager.ErrorSeverity.Error, errorMsg); return; } - soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, worldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: hull, ignoreMuffling: selectedSound.IgnoreMuffling); + soundChannel = SoundPlayer.PlaySound(selectedSound.Sound, worldPosition, selectedSound.Volume, selectedSound.Range, hullGuess: hull, ignoreMuffling: selectedSound.IgnoreMuffling, freqMult: selectedSound.GetRandomFrequencyMultiplier()); ignoreMuffling = selectedSound.IgnoreMuffling; if (soundChannel != null) { soundChannel.Looping = loopSound; } } diff --git a/Barotrauma/BarotraumaClient/LinuxClient.csproj b/Barotrauma/BarotraumaClient/LinuxClient.csproj index 92a7c8a82..01ebb078b 100644 --- a/Barotrauma/BarotraumaClient/LinuxClient.csproj +++ b/Barotrauma/BarotraumaClient/LinuxClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.20.4.0 + 0.20.6.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/MacClient.csproj b/Barotrauma/BarotraumaClient/MacClient.csproj index 2a8218f30..81a1c286d 100644 --- a/Barotrauma/BarotraumaClient/MacClient.csproj +++ b/Barotrauma/BarotraumaClient/MacClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.20.4.0 + 0.20.6.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaClient/WindowsClient.csproj b/Barotrauma/BarotraumaClient/WindowsClient.csproj index 77fedbce5..c425d7591 100644 --- a/Barotrauma/BarotraumaClient/WindowsClient.csproj +++ b/Barotrauma/BarotraumaClient/WindowsClient.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma - 0.20.4.0 + 0.20.6.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 Barotrauma diff --git a/Barotrauma/BarotraumaServer/LinuxServer.csproj b/Barotrauma/BarotraumaServer/LinuxServer.csproj index 38f6eccc6..1b57d0a81 100644 --- a/Barotrauma/BarotraumaServer/LinuxServer.csproj +++ b/Barotrauma/BarotraumaServer/LinuxServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.20.4.0 + 0.20.6.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/MacServer.csproj b/Barotrauma/BarotraumaServer/MacServer.csproj index 56a08b7b4..f9fb6ebfa 100644 --- a/Barotrauma/BarotraumaServer/MacServer.csproj +++ b/Barotrauma/BarotraumaServer/MacServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.20.4.0 + 0.20.6.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaServer/WindowsServer.csproj b/Barotrauma/BarotraumaServer/WindowsServer.csproj index 575b0e435..21f441326 100644 --- a/Barotrauma/BarotraumaServer/WindowsServer.csproj +++ b/Barotrauma/BarotraumaServer/WindowsServer.csproj @@ -6,7 +6,7 @@ Barotrauma FakeFish, Undertow Games Barotrauma Dedicated Server - 0.20.4.0 + 0.20.6.0 Copyright © FakeFish 2018-2022 AnyCPU;x64 DedicatedServer diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs index caad557b6..5238017dc 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Character.cs @@ -2182,8 +2182,6 @@ namespace Barotrauma private AttackTargetData currentAttackTarget; public void SetAttackTarget(Limb attackLimb, IDamageable damageTarget, Vector2 attackPos) { - DebugConsole.NewMessage($"SetAttackTarget {this.ToString()}: " + (damageTarget?.ToString() ?? null)); - currentAttackTarget = new AttackTargetData() { AttackLimb = attackLimb, diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/Affliction.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/Affliction.cs index a1a28bd20..e51a8acd3 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/Affliction.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/Affliction.cs @@ -71,6 +71,13 @@ namespace Barotrauma /// public Character Source; + private readonly static LocalizedString[] strengthTexts = new LocalizedString[] + { + TextManager.Get("AfflictionStrengthLow"), + TextManager.Get("AfflictionStrengthMedium"), + TextManager.Get("AfflictionStrengthHigh") + }; + public Affliction(AfflictionPrefab prefab, float strength) { #if CLIENT @@ -89,6 +96,7 @@ namespace Barotrauma } } + public void Serialize(XElement element) { SerializableProperty.SerializeProperties(this, element); @@ -108,6 +116,17 @@ namespace Barotrauma public override string ToString() => Prefab == null ? "Affliction (Invalid)" : $"Affliction ({Prefab.Name})"; + public LocalizedString GetStrengthText() + { + return GetStrengthText(Strength, Prefab.MaxStrength); + } + + public static LocalizedString GetStrengthText(float strength, float maxStrength) + { + return strengthTexts[ + MathHelper.Clamp((int)Math.Floor(strength / maxStrength * strengthTexts.Length), 0, strengthTexts.Length - 1)]; + } + public AfflictionPrefab.Effect GetActiveEffect() => Prefab.GetActiveEffect(Strength); public float GetVitalityDecrease(CharacterHealth characterHealth) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/AfflictionBleeding.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/AfflictionBleeding.cs index f6da0bfd1..44643c736 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/AfflictionBleeding.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/Afflictions/AfflictionBleeding.cs @@ -10,7 +10,8 @@ public override void Update(CharacterHealth characterHealth, Limb targetLimb, float deltaTime) { base.Update(characterHealth, targetLimb, deltaTime); - characterHealth.BloodlossAmount += Strength * (1.0f / 60.0f) * deltaTime; + float bloodlossResistance = GetResistance(characterHealth.BloodlossAffliction.Identifier); + characterHealth.BloodlossAmount += Strength * (1.0f - bloodlossResistance) / 60.0f * deltaTime; if (Source != null) { characterHealth.BloodlossAffliction.Source = Source; diff --git a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs index a4774e7a0..8e5d0bbfd 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Characters/Health/CharacterHealth.cs @@ -880,17 +880,19 @@ namespace Barotrauma { if (!Character.NeedsOxygen) { return; } + float oxygenlowResistance = GetResistance(oxygenLowAffliction.Prefab); float prevOxygen = OxygenAmount; if (IsUnconscious) { + //clamp above 0.1 (no amount of oxygen low resistance should keep the character alive indefinitely) + float decreaseSpeed = Math.Max(0.1f, 1f - oxygenlowResistance); //the character dies of oxygen deprivation in 100 seconds after losing consciousness - OxygenAmount = MathHelper.Clamp(OxygenAmount - 1.0f * deltaTime, -100.0f, 100.0f); + OxygenAmount = MathHelper.Clamp(OxygenAmount - decreaseSpeed * deltaTime, -100.0f, 100.0f); } else { float decreaseSpeed = -5.0f; float increaseSpeed = 10.0f; - float oxygenlowResistance = GetResistance(oxygenLowAffliction.Prefab); decreaseSpeed *= (1f - oxygenlowResistance); increaseSpeed *= (1f + oxygenlowResistance); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/EventAction.cs b/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/EventAction.cs index c0fc93a5b..b570a750d 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/EventAction.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Events/EventActions/EventAction.cs @@ -40,7 +40,8 @@ namespace Barotrauma DebugConsole.ThrowError($"Error in event prefab \"{scriptedEvent.Prefab.Identifier}\". Status effect configured as a sub action (text: \"{Text}\"). Please configure status effects as child elements of a StatusEffectAction."); continue; } - Actions.Add(Instantiate(scriptedEvent, e)); + var action = Instantiate(scriptedEvent, e); + if (action != null) { Actions.Add(action); } } } @@ -149,6 +150,10 @@ namespace Barotrauma ConstructorInfo constructor = actionType.GetConstructor(new[] { typeof(ScriptedEvent), typeof(ContentXElement) }); try { + if (constructor == null) + { + throw new Exception($"Error in scripted event \"{scriptedEvent.Prefab.Identifier}\" - could not find a constructor for the EventAction \"{actionType}\"."); + } return constructor.Invoke(new object[] { scriptedEvent, element }) as EventAction; } catch (Exception ex) diff --git a/Barotrauma/BarotraumaShared/SharedSource/GameSession/MedicalClinic.cs b/Barotrauma/BarotraumaShared/SharedSource/GameSession/MedicalClinic.cs index 2d25da2dc..2b40e6304 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/GameSession/MedicalClinic.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/GameSession/MedicalClinic.cs @@ -57,42 +57,18 @@ namespace Barotrauma [NetworkSerialize] public ushort Strength; + [NetworkSerialize] + public int VitalityDecrease; + [NetworkSerialize] public ushort Price; - public AfflictionSeverity AfflictionSeverity + public void SetAffliction(Affliction affliction, CharacterHealth characterHealth) { - get - { - if (Prefab is null) { return AfflictionSeverity.Low; } - - float normalizedStrength = Strength / Prefab.MaxStrength; - - // lesser than 0.1 - if (normalizedStrength <= 0.1) - { - return AfflictionSeverity.Low; - } - - // between 0.1 and 0.5 - if (normalizedStrength is > 0.1f and < 0.5f) - { - return AfflictionSeverity.Medium; - } - - // greater than 0.5 - return AfflictionSeverity.High; - } - } - - public Affliction Affliction - { - set - { - Identifier = value.Identifier; - Strength = (ushort)Math.Ceiling(value.Strength); - Price = (ushort)(value.Prefab.BaseHealCost + Strength * value.Prefab.HealCostMultiplier); - } + Identifier = affliction.Identifier; + Strength = (ushort)Math.Ceiling(affliction.Strength); + Price = (ushort)(affliction.Prefab.BaseHealCost + Strength * affliction.Prefab.HealCostMultiplier); + VitalityDecrease = (int)affliction.GetVitalityDecrease(characterHealth); } private AfflictionPrefab? cachedPrefab; @@ -306,7 +282,8 @@ namespace Barotrauma } else { - newAffliction = new NetAffliction { Affliction = affliction }; + newAffliction = new NetAffliction(); + newAffliction.SetAffliction(affliction, health); newAffliction.Price = (ushort)GetAdjustedPrice(newAffliction.Price); } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/Holdable.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/Holdable.cs index 9572b9953..c2b5630bc 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/Holdable.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Holdable/Holdable.cs @@ -681,11 +681,10 @@ namespace Barotrauma.Items.Components return false; } Vector2 attachPos = GetAttachPosition(character, useWorldCoordinates: true); - Structure attachTarget = Structure.GetAttachTarget(attachPos); - + Submarine attachSubmarine = Structure.GetAttachTarget(attachPos)?.Submarine ?? item.Submarine; int maxAttachableCount = (int)character.Info.GetSavedStatValue(StatTypes.MaxAttachableCount, item.Prefab.Identifier); int currentlyAttachedCount = Item.ItemList.Count( - i => i.Submarine == attachTarget?.Submarine && i.GetComponent() is Holdable holdable && holdable.Attached && i.Prefab.Identifier == item.Prefab.Identifier); + i => i.Submarine == attachSubmarine && i.GetComponent() is Holdable holdable && holdable.Attached && i.Prefab.Identifier == item.Prefab.Identifier); if (maxAttachableCount == 0) { #if CLIENT diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs index e355ccb14..88db0df19 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Components/Power/Powered.cs @@ -206,7 +206,7 @@ namespace Barotrauma.Items.Components { if (!powerOnSoundPlayed && powerOnSound != null) { - SoundPlayer.PlaySound(powerOnSound.Sound, item.WorldPosition, powerOnSound.Volume, powerOnSound.Range, hullGuess: item.CurrentHull, ignoreMuffling: powerOnSound.IgnoreMuffling); + SoundPlayer.PlaySound(powerOnSound.Sound, item.WorldPosition, powerOnSound.Volume, powerOnSound.Range, hullGuess: item.CurrentHull, ignoreMuffling: powerOnSound.IgnoreMuffling, freqMult: powerOnSound.GetRandomFrequencyMultiplier()); powerOnSoundPlayed = true; } } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs index a5020cff3..bed7cc150 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Items/Item.cs @@ -3402,6 +3402,20 @@ namespace Barotrauma item.PurchasedNewSwap = false; } + Version savedVersion = submarine?.Info.GameVersion; + if (element.Document?.Root != null && element.Document.Root.Name.ToString().Equals("gamesession", StringComparison.OrdinalIgnoreCase)) + { + //character inventories are loaded from the game session file - use the version number of the saved game session instead of the sub + //(the sub may have already been saved and up-to-date, even though the character inventories aren't) + savedVersion = new Version(element.Document.Root.GetAttributeString("version", "0.0.0.0")); + } + + float prevCondition = item.condition; + if (savedVersion != null) + { + SerializableProperty.UpgradeGameVersion(item, item.Prefab.ConfigElement, savedVersion); + } + if (element.GetAttribute("conditionpercentage") != null) { item.condition = element.GetAttributeFloat("conditionpercentage", 100.0f) / 100.0f * item.MaxCondition; @@ -3413,7 +3427,7 @@ namespace Barotrauma //if the item was in full condition considering the unmodified health //(not taking possible HealthMultipliers added by mods into account), //make sure it stays in full condition - bool wasFullCondition = item.condition >= item.Prefab.Health; + bool wasFullCondition = prevCondition >= item.Prefab.Health; if (wasFullCondition) { item.condition = item.MaxCondition; @@ -3424,19 +3438,6 @@ namespace Barotrauma item.RecalculateConditionValues(); item.SetActiveSprite(); - Version savedVersion = submarine?.Info.GameVersion; - if (element.Document?.Root != null && element.Document.Root.Name.ToString().Equals("gamesession", StringComparison.OrdinalIgnoreCase)) - { - //character inventories are loaded from the game session file - use the version number of the saved game session instead of the sub - //(the sub may have already been saved and up-to-date, even though the character inventories aren't) - savedVersion = new Version(element.Document.Root.GetAttributeString("version", "0.0.0.0")); - } - - if (savedVersion != null) - { - SerializableProperty.UpgradeGameVersion(item, item.Prefab.ConfigElement, savedVersion); - } - foreach (ItemComponent component in item.components) { if (component.Parent != null) { component.IsActive = component.Parent.IsActive; } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs index 58f800b98..44dc572d2 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Explosion.cs @@ -360,18 +360,21 @@ namespace Barotrauma } } - AbilityAttackData attackData = new AbilityAttackData(Attack, c, attacker); - if (attackData.Afflictions != null) + if (attack.Afflictions.Any() || attack.Stun > 0.0f) { - modifiedAfflictions.AddRange(attackData.Afflictions); - } + AbilityAttackData attackData = new AbilityAttackData(Attack, c, attacker); + if (attackData.Afflictions != null) + { + modifiedAfflictions.AddRange(attackData.Afflictions); + } - //use a position slightly from the limb's position towards the explosion - //ensures that the attack hits the correct limb and that the direction of the hit can be determined correctly in the AddDamage methods - Vector2 dir = worldPosition - limb.WorldPosition; - Vector2 hitPos = limb.WorldPosition + (dir.LengthSquared() <= 0.001f ? Rand.Vector(1.0f) : Vector2.Normalize(dir)) * 0.01f; - AttackResult attackResult = c.AddDamage(hitPos, modifiedAfflictions, attack.Stun * distFactor, false, attacker: attacker, damageMultiplier: attack.DamageMultiplier * attackData.DamageMultiplier); - damages.Add(limb, attackResult.Damage); + //use a position slightly from the limb's position towards the explosion + //ensures that the attack hits the correct limb and that the direction of the hit can be determined correctly in the AddDamage methods + Vector2 dir = worldPosition - limb.WorldPosition; + Vector2 hitPos = limb.WorldPosition + (dir.LengthSquared() <= 0.001f ? Rand.Vector(1.0f) : Vector2.Normalize(dir)) * 0.01f; + AttackResult attackResult = c.AddDamage(hitPos, modifiedAfflictions, attack.Stun * distFactor, false, attacker: attacker, damageMultiplier: attack.DamageMultiplier * attackData.DamageMultiplier); + damages.Add(limb, attackResult.Damage); + } if (attack.StatusEffects != null && attack.StatusEffects.Any()) { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs index 46adf35e2..a0edc5b26 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Map/Levels/Level.cs @@ -2539,7 +2539,8 @@ namespace Barotrauma levelResources.Add((itemPrefab, commonnessInfo)); } else if (itemPrefab.LevelQuantity.TryGetValue(GenerationParams.Identifier, out var fixedQuantityResourceInfo) || - itemPrefab.LevelQuantity.TryGetValue(Identifier.Empty, out fixedQuantityResourceInfo)) + itemPrefab.LevelQuantity.TryGetValue(LevelData.Biome.Identifier, out fixedQuantityResourceInfo) || + itemPrefab.LevelQuantity.TryGetValue(Identifier.Empty, out fixedQuantityResourceInfo)) { fixedResources.Add((itemPrefab, fixedQuantityResourceInfo)); } diff --git a/Barotrauma/BarotraumaShared/changelog.txt b/Barotrauma/BarotraumaShared/changelog.txt index 9bc167c06..b137ab06e 100644 --- a/Barotrauma/BarotraumaShared/changelog.txt +++ b/Barotrauma/BarotraumaShared/changelog.txt @@ -1,3 +1,35 @@ +--------------------------------------------------------------------------------------------------------- +v0.20.6.0 +--------------------------------------------------------------------------------------------------------- + +Unstable only: +- Fixed scripted events looping and repeating some parts. +- Depth charges don't explode when taking damage until they've been launched. +- Fixed Acid Grenade quality doing nothing. +- Fixed Acid Grenades not working in detonators. +- Fixed genetic materials being too abundant with the "Blackmarket Genes" talent. +- Fixed affliction icons overlapping with the inventory when grabbing someone or when a health interface is open. +- Fixed scrap cannon's firing particle effect triggering without ammo. +- Fixed scrap cannon barrel position. +- Fixed messed up depleted fuel SMG magazine sprite. + +Bugfixes: +- Fixed portable pump's per-sub limit not working if you attach them at a spot with no background wall. +- Fixed oxygenlow resistance not affecting the time it takes to die in an unconscious state. +- Fixed bloodloss resistance not affecting how fast bleeding causes bloodloss. +- Fixed numpad keys toggling the chat when the Chat key is bind to nothing. +- Fixed piezo crystals no longer spawning in the Great Sea. + +Modding: +- Fixed sound's frequency multiplier not working in many cases (status effects, specific item sounds like turret movement sounds). + +--------------------------------------------------------------------------------------------------------- +v0.20.5.0 +--------------------------------------------------------------------------------------------------------- + +Unstable only: +- Fixed crashing when you enter the 2nd outpost. + --------------------------------------------------------------------------------------------------------- v0.20.4.0 ---------------------------------------------------------------------------------------------------------