]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
make fire not burn through hardsuits (#27161)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Thu, 9 May 2024 07:12:48 +0000 (07:12 +0000)
committerGitHub <noreply@github.com>
Thu, 9 May 2024 07:12:48 +0000 (00:12 -0700)
* 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>
Content.Server/Atmos/EntitySystems/FlammableSystem.cs
Content.Shared/Atmos/GetFireProtectionEvent.cs [new file with mode: 0644]
Content.Shared/Clothing/Components/FireProtectionComponent.cs [new file with mode: 0644]
Content.Shared/Clothing/EntitySystems/FireProtectionSystem.cs [new file with mode: 0644]
Resources/Prototypes/Entities/Clothing/Head/base_clothinghead.yml
Resources/Prototypes/Entities/Clothing/Head/hardsuit-helmets.yml
Resources/Prototypes/Entities/Clothing/Head/helmets.yml
Resources/Prototypes/Entities/Clothing/OuterClothing/base_clothingouter.yml
Resources/Prototypes/Entities/Clothing/OuterClothing/hardsuits.yml
Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml

index c569997ffed45242304cd6415a64be39ee88c7fb..732f57e22dc5f7cfa1619e1c6d04b56c455c906c 100644 (file)
@@ -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<InventoryComponent> _inventoryQuery;
         private EntityQuery<PhysicsComponent> _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<InventoryComponent>();
             _physicsQuery = GetEntityQuery<PhysicsComponent>();
 
             SubscribeLocalEvent<FlammableComponent, MapInitEvent>(OnMapInit);
@@ -432,13 +436,20 @@ namespace Content.Server.Atmos.EntitySystems
                         continue;
                     }
 
-                    EnsureComp<IgnitionSourceComponent>(uid);
-                    _ignitionSourceSystem.SetIgnited(uid);
+                    var source = EnsureComp<IgnitionSourceComponent>(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 (file)
index 0000000..e243295
--- /dev/null
@@ -0,0 +1,33 @@
+using Content.Shared.Inventory;
+
+namespace Content.Shared.Atmos;
+
+/// <summary>
+/// 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.
+/// </summary>
+[ByRefEvent]
+public sealed class GetFireProtectionEvent : EntityEventArgs, IInventoryRelayEvent
+{
+    public SlotFlags TargetSlots { get; } = ~SlotFlags.POCKET;
+
+    /// <summary>
+    /// What to multiply the fire damage by.
+    /// If this is 0 then it's ignored
+    /// </summary>
+    public float Multiplier;
+
+    public GetFireProtectionEvent()
+    {
+        Multiplier = 1f;
+    }
+
+    /// <summary>
+    /// Reduce fire damage taken by a percentage.
+    /// </summary>
+    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 (file)
index 0000000..cafa6e5
--- /dev/null
@@ -0,0 +1,17 @@
+using Content.Shared.Clothing.EntitySystems;
+
+namespace Content.Shared.Clothing.Components;
+
+/// <summary>
+/// Makes this clothing reduce fire damage when worn.
+/// </summary>
+[RegisterComponent, Access(typeof(FireProtectionSystem))]
+public sealed partial class FireProtectionComponent : Component
+{
+    /// <summary>
+    /// Percentage to reduce fire damage by, subtracted not multiplicative.
+    /// 0.25 means 25% less fire damage.
+    /// </summary>
+    [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 (file)
index 0000000..6f80bc0
--- /dev/null
@@ -0,0 +1,23 @@
+using Content.Shared.Atmos;
+using Content.Shared.Clothing.Components;
+using Content.Shared.Inventory;
+
+namespace Content.Shared.Clothing.EntitySystems;
+
+/// <summary>
+/// Handles reducing fire damage when wearing clothing with <see cref="FireProtectionComponent"/>.
+/// </summary>
+public sealed class FireProtectionSystem : EntitySystem
+{
+    public override void Initialize()
+    {
+        base.Initialize();
+
+        SubscribeLocalEvent<FireProtectionComponent, InventoryRelayedEvent<GetFireProtectionEvent>>(OnGetProtection);
+    }
+
+    private void OnGetProtection(Entity<FireProtectionComponent> ent, ref InventoryRelayedEvent<GetFireProtectionEvent> args)
+    {
+        args.Args.Reduce(ent.Comp.Reduction);
+    }
+}
index e1e5ddc11fa11f109a42ebaf9e0d2a9633d56812..e19217686f459e25deec9863cecd7fb72b162a23 100644 (file)
     lowPressureMultiplier: 1000
   - type: TemperatureProtection
     coefficient: 0.1
+  - type: FireProtection
+    reduction: 0.2
   - type: Armor
     modifiers:
       coefficients:
index 453f3d12679137b7c13307345ef89c0039bb3ecb..072dd53d9ae1561a67052f27ee751ff53ea1f233 100644 (file)
     lowPressureMultiplier: 1000
   - type: TemperatureProtection
     coefficient: 0.005
+  - type: FireProtection
+    reduction: 0.2
   - type: Armor
     modifiers:
       coefficients:
index 88070b430fd8d1a0d6fc2ee738e47ce4c01a2232..720e52ee588329ec2e0b1a45337dd1606526b624 100644 (file)
   - type: IngestionBlocker
   - type: TemperatureProtection
     coefficient: 0.005
+  - type: FireProtection
+    reduction: 0.15 # not fully sealed so less protection
   - type: IdentityBlocker
   - type: Tag
     tags:
   - type: IngestionBlocker
   - type: TemperatureProtection
     coefficient: 0.005
+  - type: FireProtection
+    reduction: 0.2
   - type: PressureProtection
     highPressureMultiplier: 0.25
     lowPressureMultiplier: 1000
index 16b287917b5f2733031b8766ebb29832cf32b733..1ccecd52c4942d930266ad7a8fa45b8c0321b8c1 100644 (file)
     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
index f04548072ea11e550a658c047d0687a937f312b6..1f69f7efb32b818ab408d014139a7578d866d45a 100644 (file)
@@ -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
     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:
index cc6f0131adf59cb84c5fc7377e04aa5a07d3fa02..f9ea337764df65014b8e61cf0b143e94bcb3f92c 100644 (file)
     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
     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