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>
This commit is contained in:
deltanedas
2024-05-09 07:12:48 +00:00
committed by GitHub
parent b96ed726f1
commit cd92046966
10 changed files with 109 additions and 12 deletions

View File

@@ -12,6 +12,7 @@ using Content.Shared.Atmos.Components;
using Content.Shared.Damage; using Content.Shared.Damage;
using Content.Shared.Database; using Content.Shared.Database;
using Content.Shared.Interaction; using Content.Shared.Interaction;
using Content.Shared.Inventory;
using Content.Shared.Physics; using Content.Shared.Physics;
using Content.Shared.Popups; using Content.Shared.Popups;
using Content.Shared.Projectiles; using Content.Shared.Projectiles;
@@ -41,12 +42,14 @@ namespace Content.Server.Atmos.EntitySystems
[Dependency] private readonly AlertsSystem _alertsSystem = default!; [Dependency] private readonly AlertsSystem _alertsSystem = default!;
[Dependency] private readonly FixtureSystem _fixture = default!; [Dependency] private readonly FixtureSystem _fixture = default!;
[Dependency] private readonly IAdminLogManager _adminLogger = default!; [Dependency] private readonly IAdminLogManager _adminLogger = default!;
[Dependency] private readonly InventorySystem _inventory = default!;
[Dependency] private readonly SharedAppearanceSystem _appearance = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!;
[Dependency] private readonly SharedPopupSystem _popup = default!; [Dependency] private readonly SharedPopupSystem _popup = default!;
[Dependency] private readonly UseDelaySystem _useDelay = default!; [Dependency] private readonly UseDelaySystem _useDelay = default!;
[Dependency] private readonly AudioSystem _audio = default!; [Dependency] private readonly AudioSystem _audio = default!;
[Dependency] private readonly IRobustRandom _random = default!; [Dependency] private readonly IRobustRandom _random = default!;
private EntityQuery<InventoryComponent> _inventoryQuery;
private EntityQuery<PhysicsComponent> _physicsQuery; private EntityQuery<PhysicsComponent> _physicsQuery;
// This should probably be moved to the component, requires a rewrite, all fires tick at the same time // 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)); UpdatesAfter.Add(typeof(AtmosphereSystem));
_inventoryQuery = GetEntityQuery<InventoryComponent>();
_physicsQuery = GetEntityQuery<PhysicsComponent>(); _physicsQuery = GetEntityQuery<PhysicsComponent>();
SubscribeLocalEvent<FlammableComponent, MapInitEvent>(OnMapInit); SubscribeLocalEvent<FlammableComponent, MapInitEvent>(OnMapInit);
@@ -432,13 +436,20 @@ namespace Content.Server.Atmos.EntitySystems
continue; continue;
} }
EnsureComp<IgnitionSourceComponent>(uid); var source = EnsureComp<IgnitionSourceComponent>(uid);
_ignitionSourceSystem.SetIgnited(uid); _ignitionSourceSystem.SetIgnited((uid, source));
if (TryComp(uid, out TemperatureComponent? temp)) if (TryComp(uid, out TemperatureComponent? temp))
_temperatureSystem.ChangeHeat(uid, 12500 * flammable.FireStacks, false, 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); AdjustFireStacks(uid, flammable.FirestackFade * (flammable.Resisting ? 10f : 1f), flammable);
} }

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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);
}
}

View File

@@ -163,6 +163,8 @@
lowPressureMultiplier: 1000 lowPressureMultiplier: 1000
- type: TemperatureProtection - type: TemperatureProtection
coefficient: 0.1 coefficient: 0.1
- type: FireProtection
reduction: 0.2
- type: Armor - type: Armor
modifiers: modifiers:
coefficients: coefficients:

View File

@@ -417,6 +417,8 @@
lowPressureMultiplier: 1000 lowPressureMultiplier: 1000
- type: TemperatureProtection - type: TemperatureProtection
coefficient: 0.005 coefficient: 0.005
- type: FireProtection
reduction: 0.2
- type: Armor - type: Armor
modifiers: modifiers:
coefficients: coefficients:

View File

@@ -224,6 +224,8 @@
- type: IngestionBlocker - type: IngestionBlocker
- type: TemperatureProtection - type: TemperatureProtection
coefficient: 0.005 coefficient: 0.005
- type: FireProtection
reduction: 0.15 # not fully sealed so less protection
- type: IdentityBlocker - type: IdentityBlocker
- type: Tag - type: Tag
tags: tags:
@@ -248,6 +250,8 @@
- type: IngestionBlocker - type: IngestionBlocker
- type: TemperatureProtection - type: TemperatureProtection
coefficient: 0.005 coefficient: 0.005
- type: FireProtection
reduction: 0.2
- type: PressureProtection - type: PressureProtection
highPressureMultiplier: 0.25 highPressureMultiplier: 0.25
lowPressureMultiplier: 1000 lowPressureMultiplier: 1000

View File

@@ -109,7 +109,9 @@
highPressureMultiplier: 0.3 highPressureMultiplier: 0.3
lowPressureMultiplier: 1000 lowPressureMultiplier: 1000
- type: TemperatureProtection - 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 - type: ClothingSpeedModifier
walkModifier: 0.4 walkModifier: 0.4
sprintModifier: 0.6 sprintModifier: 0.6

View File

@@ -52,9 +52,8 @@
Blunt: 0.9 Blunt: 0.9
Slash: 0.9 Slash: 0.9
Piercing: 0.9 Piercing: 0.9
Heat: 0.2 Heat: 0.8
Radiation: 0.5 Radiation: 0.5
Caustic: 0.5
- type: ClothingSpeedModifier - type: ClothingSpeedModifier
walkModifier: 0.7 walkModifier: 0.7
sprintModifier: 0.7 sprintModifier: 0.7
@@ -76,8 +75,6 @@
- type: PressureProtection - type: PressureProtection
highPressureMultiplier: 0.04 highPressureMultiplier: 0.04
lowPressureMultiplier: 1000 lowPressureMultiplier: 1000
- type: TemperatureProtection
coefficient: 0.01
- type: ExplosionResistance - type: ExplosionResistance
damageCoefficient: 0.5 damageCoefficient: 0.5
- type: Armor - type: Armor
@@ -545,6 +542,8 @@
coefficient: 0.001 coefficient: 0.001
- type: ExplosionResistance - type: ExplosionResistance
damageCoefficient: 0.2 damageCoefficient: 0.2
- type: FireProtection
reduction: 0.8 # perfect protection like atmos firesuit for pyro tf2 ops
- type: Armor - type: Armor
modifiers: modifiers:
coefficients: coefficients:

View File

@@ -54,12 +54,14 @@
highPressureMultiplier: 0.04 highPressureMultiplier: 0.04
- type: TemperatureProtection - type: TemperatureProtection
coefficient: 0.005 coefficient: 0.005
- type: FireProtection
reduction: 0.65 # doesnt have a full seal so not as good
- type: Armor - type: Armor
modifiers: modifiers:
coefficients: coefficients:
Slash: 0.9 Slash: 0.9
Heat: 0.3 Heat: 0.8
Cold: 0.2 Cold: 0.8
- type: ClothingSpeedModifier - type: ClothingSpeedModifier
walkModifier: 0.8 walkModifier: 0.8
sprintModifier: 0.7 sprintModifier: 0.7
@@ -83,12 +85,14 @@
lowPressureMultiplier: 1000 lowPressureMultiplier: 1000
- type: TemperatureProtection - type: TemperatureProtection
coefficient: 0.001 coefficient: 0.001
- type: FireProtection
reduction: 0.8 # atmos firesuit offers best protection, hardsuits are a little vulnerable
- type: Armor - type: Armor
modifiers: modifiers:
coefficients: coefficients:
Slash: 0.9 Slash: 0.9
Heat: 0.3 Heat: 0.8
Cold: 0.2 Cold: 0.8
- type: ClothingSpeedModifier - type: ClothingSpeedModifier
walkModifier: 0.8 walkModifier: 0.8
sprintModifier: 0.8 sprintModifier: 0.8