From cd92046966cf2537b664223a43853d33a6d351d3 Mon Sep 17 00:00:00 2001 From: deltanedas <39013340+deltanedas@users.noreply.github.com> Date: Thu, 9 May 2024 07:12:48 +0000 Subject: [PATCH] make fire not burn through hardsuits (#27161) * add FireProtection system and event * minor optimisation + make flammable use fire protection event * add fire protection values to some things, nerf firesuit heat resistance * bruh * unrevert laser nerfs, make elite hardsuit fully fireproof --------- Co-authored-by: deltanedas <@deltanedas:kde.org> --- .../Atmos/EntitySystems/FlammableSystem.cs | 17 ++++++++-- .../Atmos/GetFireProtectionEvent.cs | 33 +++++++++++++++++++ .../Components/FireProtectionComponent.cs | 17 ++++++++++ .../EntitySystems/FireProtectionSystem.cs | 23 +++++++++++++ .../Clothing/Head/base_clothinghead.yml | 2 ++ .../Clothing/Head/hardsuit-helmets.yml | 2 ++ .../Entities/Clothing/Head/helmets.yml | 4 +++ .../OuterClothing/base_clothingouter.yml | 4 ++- .../Clothing/OuterClothing/hardsuits.yml | 7 ++-- .../Entities/Clothing/OuterClothing/suits.yml | 12 ++++--- 10 files changed, 109 insertions(+), 12 deletions(-) create mode 100644 Content.Shared/Atmos/GetFireProtectionEvent.cs create mode 100644 Content.Shared/Clothing/Components/FireProtectionComponent.cs create mode 100644 Content.Shared/Clothing/EntitySystems/FireProtectionSystem.cs diff --git a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs index c569997ffe..732f57e22d 100644 --- a/Content.Server/Atmos/EntitySystems/FlammableSystem.cs +++ b/Content.Server/Atmos/EntitySystems/FlammableSystem.cs @@ -12,6 +12,7 @@ using Content.Shared.Atmos.Components; using Content.Shared.Damage; using Content.Shared.Database; using Content.Shared.Interaction; +using Content.Shared.Inventory; using Content.Shared.Physics; using Content.Shared.Popups; using Content.Shared.Projectiles; @@ -41,12 +42,14 @@ namespace Content.Server.Atmos.EntitySystems [Dependency] private readonly AlertsSystem _alertsSystem = default!; [Dependency] private readonly FixtureSystem _fixture = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!; + [Dependency] private readonly InventorySystem _inventory = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly UseDelaySystem _useDelay = default!; [Dependency] private readonly AudioSystem _audio = default!; [Dependency] private readonly IRobustRandom _random = default!; + private EntityQuery _inventoryQuery; private EntityQuery _physicsQuery; // This should probably be moved to the component, requires a rewrite, all fires tick at the same time @@ -60,6 +63,7 @@ namespace Content.Server.Atmos.EntitySystems { UpdatesAfter.Add(typeof(AtmosphereSystem)); + _inventoryQuery = GetEntityQuery(); _physicsQuery = GetEntityQuery(); SubscribeLocalEvent(OnMapInit); @@ -432,13 +436,20 @@ namespace Content.Server.Atmos.EntitySystems continue; } - EnsureComp(uid); - _ignitionSourceSystem.SetIgnited(uid); + var source = EnsureComp(uid); + _ignitionSourceSystem.SetIgnited((uid, source)); if (TryComp(uid, out TemperatureComponent? temp)) _temperatureSystem.ChangeHeat(uid, 12500 * flammable.FireStacks, false, temp); - _damageableSystem.TryChangeDamage(uid, flammable.Damage * flammable.FireStacks, interruptsDoAfters: false); + var ev = new GetFireProtectionEvent(); + // let the thing on fire handle it + RaiseLocalEvent(uid, ref ev); + // and whatever it's wearing + if (_inventoryQuery.TryComp(uid, out var inv)) + _inventory.RelayEvent((uid, inv), ref ev); + + _damageableSystem.TryChangeDamage(uid, flammable.Damage * flammable.FireStacks * ev.Multiplier, interruptsDoAfters: false); AdjustFireStacks(uid, flammable.FirestackFade * (flammable.Resisting ? 10f : 1f), flammable); } diff --git a/Content.Shared/Atmos/GetFireProtectionEvent.cs b/Content.Shared/Atmos/GetFireProtectionEvent.cs new file mode 100644 index 0000000000..e243295449 --- /dev/null +++ b/Content.Shared/Atmos/GetFireProtectionEvent.cs @@ -0,0 +1,33 @@ +using Content.Shared.Inventory; + +namespace Content.Shared.Atmos; + +/// +/// Raised on a burning entity to check its fire protection. +/// Damage taken is multiplied by the final amount, but not temperature. +/// TemperatureProtection is needed for that. +/// +[ByRefEvent] +public sealed class GetFireProtectionEvent : EntityEventArgs, IInventoryRelayEvent +{ + public SlotFlags TargetSlots { get; } = ~SlotFlags.POCKET; + + /// + /// What to multiply the fire damage by. + /// If this is 0 then it's ignored + /// + public float Multiplier; + + public GetFireProtectionEvent() + { + Multiplier = 1f; + } + + /// + /// Reduce fire damage taken by a percentage. + /// + public void Reduce(float by) + { + Multiplier -= by; + } +} diff --git a/Content.Shared/Clothing/Components/FireProtectionComponent.cs b/Content.Shared/Clothing/Components/FireProtectionComponent.cs new file mode 100644 index 0000000000..cafa6e5359 --- /dev/null +++ b/Content.Shared/Clothing/Components/FireProtectionComponent.cs @@ -0,0 +1,17 @@ +using Content.Shared.Clothing.EntitySystems; + +namespace Content.Shared.Clothing.Components; + +/// +/// Makes this clothing reduce fire damage when worn. +/// +[RegisterComponent, Access(typeof(FireProtectionSystem))] +public sealed partial class FireProtectionComponent : Component +{ + /// + /// Percentage to reduce fire damage by, subtracted not multiplicative. + /// 0.25 means 25% less fire damage. + /// + [DataField(required: true)] + public float Reduction; +} diff --git a/Content.Shared/Clothing/EntitySystems/FireProtectionSystem.cs b/Content.Shared/Clothing/EntitySystems/FireProtectionSystem.cs new file mode 100644 index 0000000000..6f80bc0588 --- /dev/null +++ b/Content.Shared/Clothing/EntitySystems/FireProtectionSystem.cs @@ -0,0 +1,23 @@ +using Content.Shared.Atmos; +using Content.Shared.Clothing.Components; +using Content.Shared.Inventory; + +namespace Content.Shared.Clothing.EntitySystems; + +/// +/// Handles reducing fire damage when wearing clothing with . +/// +public sealed class FireProtectionSystem : EntitySystem +{ + public override void Initialize() + { + base.Initialize(); + + SubscribeLocalEvent>(OnGetProtection); + } + + private void OnGetProtection(Entity ent, ref InventoryRelayedEvent args) + { + args.Args.Reduce(ent.Comp.Reduction); + } +} diff --git a/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml b/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml index e1e5ddc11f..e19217686f 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml @@ -163,6 +163,8 @@ lowPressureMultiplier: 1000 - type: TemperatureProtection coefficient: 0.1 + - type: FireProtection + reduction: 0.2 - type: Armor modifiers: coefficients: diff --git a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml index 453f3d1267..072dd53d9a 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml @@ -417,6 +417,8 @@ lowPressureMultiplier: 1000 - type: TemperatureProtection coefficient: 0.005 + - type: FireProtection + reduction: 0.2 - type: Armor modifiers: coefficients: diff --git a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml index 88070b430f..720e52ee58 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml @@ -224,6 +224,8 @@ - type: IngestionBlocker - type: TemperatureProtection coefficient: 0.005 + - type: FireProtection + reduction: 0.15 # not fully sealed so less protection - type: IdentityBlocker - type: Tag tags: @@ -248,6 +250,8 @@ - type: IngestionBlocker - type: TemperatureProtection coefficient: 0.005 + - type: FireProtection + reduction: 0.2 - type: PressureProtection highPressureMultiplier: 0.25 lowPressureMultiplier: 1000 diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml index 16b287917b..1ccecd52c4 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml @@ -109,7 +109,9 @@ highPressureMultiplier: 0.3 lowPressureMultiplier: 1000 - type: TemperatureProtection - coefficient: 0.001 # yes it needs to be this low, fires are fucking deadly apparently!!!! + coefficient: 0.01 + - type: FireProtection + reduction: 0.75 # almost perfectly sealed, atmos firesuit is better - type: ClothingSpeedModifier walkModifier: 0.4 sprintModifier: 0.6 diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml index f04548072e..1f69f7efb3 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml @@ -52,9 +52,8 @@ Blunt: 0.9 Slash: 0.9 Piercing: 0.9 - Heat: 0.2 + Heat: 0.8 Radiation: 0.5 - Caustic: 0.5 - type: ClothingSpeedModifier walkModifier: 0.7 sprintModifier: 0.7 @@ -76,8 +75,6 @@ - type: PressureProtection highPressureMultiplier: 0.04 lowPressureMultiplier: 1000 - - type: TemperatureProtection - coefficient: 0.01 - type: ExplosionResistance damageCoefficient: 0.5 - type: Armor @@ -545,6 +542,8 @@ coefficient: 0.001 - type: ExplosionResistance damageCoefficient: 0.2 + - type: FireProtection + reduction: 0.8 # perfect protection like atmos firesuit for pyro tf2 ops - type: Armor modifiers: coefficients: diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml index cc6f0131ad..f9ea337764 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml @@ -54,12 +54,14 @@ highPressureMultiplier: 0.04 - type: TemperatureProtection coefficient: 0.005 + - type: FireProtection + reduction: 0.65 # doesnt have a full seal so not as good - type: Armor modifiers: coefficients: Slash: 0.9 - Heat: 0.3 - Cold: 0.2 + Heat: 0.8 + Cold: 0.8 - type: ClothingSpeedModifier walkModifier: 0.8 sprintModifier: 0.7 @@ -83,12 +85,14 @@ lowPressureMultiplier: 1000 - type: TemperatureProtection coefficient: 0.001 + - type: FireProtection + reduction: 0.8 # atmos firesuit offers best protection, hardsuits are a little vulnerable - type: Armor modifiers: coefficients: Slash: 0.9 - Heat: 0.3 - Cold: 0.2 + Heat: 0.8 + Cold: 0.8 - type: ClothingSpeedModifier walkModifier: 0.8 sprintModifier: 0.8