Merge branch 'master' of https://github.com/Regalis11/Barotrauma into develop

This commit is contained in:
EvilFactory
2025-04-10 10:37:09 -03:00
296 changed files with 8420 additions and 2945 deletions
@@ -54,6 +54,11 @@ namespace Barotrauma
activeEffectDirty = true;
}
}
/// <summary>
/// Armor penetration for status effects. Normally defined per attack, but that doesn't work on status effects.
/// </summary>
public float Penetration { get; set; }
private float _nonClampedStrength = -1;
public float NonClampedStrength => _nonClampedStrength > 0 ? _nonClampedStrength : _strength;
@@ -64,7 +69,7 @@ namespace Barotrauma
[Serialize(1.0f, IsPropertySaveable.Yes, description: "The probability for the affliction to be applied."), Editable(minValue: 0f, maxValue: 1f)]
public float Probability { get; set; } = 1.0f;
[Serialize(true, IsPropertySaveable.Yes, description: "Explosion damage is applied per each affected limb. Should this affliction damage be divided by the count of affected limbs (1-15) or applied in full? Default: true. Only affects explosions."), Editable]
[Serialize(true, IsPropertySaveable.Yes, description: "Explosion damage is applied per each affected limb. Should this affliction damage be divided by the count of affected limbs (1-15) or applied in full? Default: true. Only affects status effects and explosions."), Editable]
public bool DivideByLimbCount { get; set; }
[Serialize(false, IsPropertySaveable.Yes, description: "Is the damage relative to the max vitality (percentage) or absolute (normal)"), Editable]
@@ -120,6 +125,7 @@ namespace Barotrauma
Probability = source.Probability;
DivideByLimbCount = source.DivideByLimbCount;
MultiplyByMaxVitality = source.MultiplyByMaxVitality;
Penetration = source.Penetration;
}
public void Serialize(XElement element)
@@ -408,6 +414,8 @@ namespace Barotrauma
}
else
{
//force an update when a periodic effect triggers to get it to trigger client-side
characterHealth.Character.healthUpdateTimer = 0.0f;
foreach (StatusEffect statusEffect in periodicEffect.StatusEffects)
{
ApplyStatusEffect(ActionType.OnActive, statusEffect, 1.0f, characterHealth, targetLimb);
@@ -447,6 +455,17 @@ namespace Barotrauma
ApplyStatusEffect(ActionType.OnActive, statusEffect, deltaTime, characterHealth, targetLimb);
}
if (currentEffect.ConvulseAmount > 0f)
{
foreach (Limb limb in characterHealth.Character.AnimController.Limbs)
{
if (limb.IsSevered) { continue; }
if (limb.Hidden) { continue; }
float force = Rand.Value() * limb.Mass * currentEffect.ConvulseAmount;
limb.body.ApplyLinearImpulse(Rand.Vector(force), maxVelocity: Networking.NetConfig.MaxPhysicsBodyVelocity * 0.5f);
}
}
float amount = deltaTime;
if (Prefab.GrainBurst > 0)
{
@@ -321,6 +321,10 @@ namespace Barotrauma
}
var husk = Character.Create(huskedSpeciesName, character.WorldPosition, ToolBox.RandomSeed(8), huskCharacterInfo, isRemotePlayer: false, hasAi: true);
if (character.HasAbilityFlag(AbilityFlags.IgnoredByEnemyAI))
{
husk.AddAbilityFlag(AbilityFlags.IgnoredByEnemyAI);
}
if (husk.Info != null)
{
husk.Info.Character = husk;
@@ -395,13 +399,13 @@ namespace Barotrauma
public static List<Limb> AttachHuskAppendage(Character character, AfflictionPrefabHusk matchingAffliction, Identifier huskedSpeciesName, ContentXElement appendageDefinition = null, Ragdoll ragdoll = null)
{
var appendage = new List<Limb>();
var appendageLimbs = new List<Limb>();
CharacterPrefab huskPrefab = CharacterPrefab.FindBySpeciesName(huskedSpeciesName);
if (huskPrefab?.ConfigElement == null)
{
DebugConsole.ThrowError($"Failed to find the config file for the husk infected species with the species name '{huskedSpeciesName}'!",
contentPackage: matchingAffliction.ContentPackage);
return appendage;
return appendageLimbs;
}
var mainElement = huskPrefab.ConfigElement;
var element = appendageDefinition;
@@ -413,11 +417,11 @@ namespace Barotrauma
{
DebugConsole.ThrowError($"Error in '{huskPrefab.FilePath}': Failed to find a huskappendage that matches the affliction with an identifier '{matchingAffliction.Identifier}'!",
contentPackage: matchingAffliction.ContentPackage);
return appendage;
return appendageLimbs;
}
ContentPath pathToAppendage = element.GetAttributeContentPath("path") ?? ContentPath.Empty;
XDocument doc = XMLExtensions.TryLoadXml(pathToAppendage);
if (doc == null) { return appendage; }
if (doc == null) { return appendageLimbs; }
ragdoll ??= character.AnimController;
if (ragdoll.Dir < 1.0f)
{
@@ -425,13 +429,13 @@ namespace Barotrauma
}
var root = doc.Root.FromPackage(pathToAppendage.ContentPackage);
var limbElements = root.GetChildElements("limb").ToDictionary(e => e.GetAttributeString("id", null), e => e);
var limbElements = root.GetChildElements("limb").ToDictionary(e => e.GetAttributeInt("id", -1), e => e);
//the IDs may need to be offset if the character has other extra appendages (e.g. from gene splicing)
//that take up the IDs of this appendage
int idOffset = 0;
int? idOffset = null;
foreach (var jointElement in root.GetChildElements("joint"))
{
if (!limbElements.TryGetValue(jointElement.GetAttributeString("limb2", null), out ContentXElement limbElement)) { continue; }
if (!limbElements.TryGetValue(jointElement.GetAttributeInt("limb2", -1), out ContentXElement limbElement)) { continue; }
var jointParams = new RagdollParams.JointParams(jointElement, ragdoll.RagdollParams);
Limb attachLimb = null;
@@ -453,28 +457,32 @@ namespace Barotrauma
}
if (attachLimb != null)
{
jointParams.Limb1 = attachLimb.Params.ID;
//the joint attaches to a limb outside the character's normal limb count = to another part of the appendage
// -> if the appendage's IDs have been offset, we need to take that into account to attach to the correct limb
if (jointParams.Limb1 >= ragdoll.RagdollParams.Limbs.Count)
{
jointParams.Limb1 += idOffset;
}
var appendageLimbParams = new RagdollParams.LimbParams(limbElement, ragdoll.RagdollParams);
if (idOffset == 0)
idOffset ??= ragdoll.Limbs.Length - appendageLimbParams.ID;
jointParams.Limb1 = attachLimb.Params.ID;
//the joint attaches to one of the limbs we're creating = to another part of the appendage
// -> if the appendage's IDs have been offset, we need to take that into account to attach to the correct limb
if (limbElements.ContainsKey(jointParams.Limb1))
{
idOffset = ragdoll.Limbs.Length - appendageLimbParams.ID;
jointParams.Limb1 += idOffset.Value;
}
jointParams.Limb2 = appendageLimbParams.ID = ragdoll.Limbs.Length;
Limb huskAppendage = new Limb(ragdoll, character, appendageLimbParams);
if (limbElements.ContainsKey(jointParams.Limb2))
{
jointParams.Limb2 += idOffset.Value;
}
Limb huskAppendage =
//check if this joint is supposed to attach to a limb we already created
appendageLimbs.Find(limb => limb.Params.ID == appendageLimbParams.ID) ??
//if not, create a new limb
new Limb(ragdoll, character, appendageLimbParams);
huskAppendage.body.Submarine = character.Submarine;
huskAppendage.body.SetTransform(attachLimb.SimPosition, attachLimb.Rotation);
ragdoll.AddLimb(huskAppendage);
ragdoll.AddJoint(jointParams);
appendage.Add(huskAppendage);
appendageLimbs.Add(huskAppendage);
}
}
return appendage;
return appendageLimbs;
}
public static Identifier GetHuskedSpeciesName(CharacterParams character, AfflictionPrefabHusk prefab)
@@ -372,6 +372,10 @@ namespace Barotrauma
description: $"Color of the \"thermal goggles overlay\" enabled by the affliction. Only has an effect if {nameof(ThermalOverlayRange)} is larger than 0.")]
public Color ThermalOverlayColor { get; private set; }
[Serialize(0f, IsPropertySaveable.No,
description: "Multiplier for the convulsion/seizure effect on the character's ragdoll when this effect is active.")]
public float ConvulseAmount { get; private set; }
/// <summary>
/// StatType that will be applied to the affected character when the effect is active that is proportional to the effect's strength.
/// </summary>
@@ -641,6 +645,7 @@ namespace Barotrauma
public static AfflictionPrefab Stun => Prefabs[StunType];
public static AfflictionPrefab RadiationSickness => Prefabs["radiationsickness"];
public static AfflictionPrefab HuskInfection => Prefabs["huskinfection"];
public static AfflictionPrefab JovianRadiation => Prefabs["jovianradiation"];
public static readonly PrefabCollection<AfflictionPrefab> Prefabs = new PrefabCollection<AfflictionPrefab>();
@@ -657,6 +662,11 @@ namespace Barotrauma
private readonly LocalizedString defaultDescription;
public readonly ImmutableList<Description> Descriptions;
/// <summary>
/// Should the affliction's description be included in the tooltips on the affliction icons above the health bar?
/// </summary>
public readonly bool ShowDescriptionInTooltip;
/// <summary>
/// Arbitrary string that is used to identify the type of the affliction.
/// </summary>
@@ -902,6 +912,8 @@ namespace Barotrauma
{
defaultDescription = defaultDescription.Fallback(fallbackDescription);
}
ShowDescriptionInTooltip = element.GetAttributeBool(nameof(ShowDescriptionInTooltip), true);
IsBuff = element.GetAttributeBool(nameof(IsBuff), false);
AffectMachines = element.GetAttributeBool(nameof(AffectMachines), true);
@@ -939,6 +951,12 @@ namespace Barotrauma
HideIconAfterDelay = element.GetAttributeBool(nameof(HideIconAfterDelay), false);
ActivationThreshold = element.GetAttributeFloat(nameof(ActivationThreshold), 0.0f);
if (Identifier == StunType && ActivationThreshold > 0.0f)
{
ActivationThreshold = 0.0f;
DebugConsole.AddWarning($"Error in affliction prefab {Identifier}: activation threshold of the stun affliction must be 0, because the strength of the affliction represents the length of the stun and any amount of stun has an effect.");
}
ShowIconThreshold = element.GetAttributeFloat(nameof(ShowIconThreshold), Math.Max(ActivationThreshold, 0.05f));
ShowIconToOthersThreshold = element.GetAttributeFloat(nameof(ShowIconToOthersThreshold), ShowIconThreshold);
MaxStrength = element.GetAttributeFloat(nameof(MaxStrength), 100.0f);
@@ -736,6 +736,8 @@ namespace Barotrauma
afflictionsToRemove.AddRange(afflictions.Keys.Where(a => !irremovableAfflictions.Contains(a)));
foreach (var affliction in afflictionsToRemove)
{
//set strength to 0 in case the affliction needs to react to becoming inactive
affliction.Strength = 0.0f;
afflictions.Remove(affliction);
}
foreach (Affliction affliction in irremovableAfflictions)
@@ -902,6 +904,8 @@ namespace Barotrauma
affliction.Duration -= deltaTime;
if (affliction.Duration <= 0.0f)
{
//set strength to 0 in case the affliction needs to react to becoming inactive
affliction.Strength = 0.0f;
afflictionsToRemove.Add(affliction);
continue;
}