diff --git a/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs b/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs
index a65764c413..d4a93c2b56 100644
--- a/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs
+++ b/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs
@@ -5,7 +5,9 @@ using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototy
namespace Content.Server.Explosion.Components;
///
-/// Component that provides entities with explosion resistance.
+/// Component that provides entities with explosion resistance.
+/// By default this is applied when worn, but to solely protect the entity itself and
+/// not the wearer use worn: false.
///
///
/// This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
@@ -21,6 +23,20 @@ public sealed partial class ExplosionResistanceComponent : Component
[DataField("damageCoefficient")]
public float DamageCoefficient = 1;
+ ///
+ /// When true, resistances will be applied to the entity wearing this item.
+ /// When false, only this entity will get th resistance.
+ ///
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public bool Worn = true;
+
+ ///
+ /// Examine string for explosion resistance.
+ /// Passed value from 0 to 100.
+ ///
+ [DataField, ViewVariables(VVAccess.ReadWrite)]
+ public LocId Examine = "explosion-resistance-coefficient-value";
+
///
/// Modifiers specific to each explosion type for more customizability.
///
diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs
index 1941ff9d16..e48d9f145e 100644
--- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs
+++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.Processing.cs
@@ -389,7 +389,13 @@ public sealed partial class ExplosionSystem
private void GetEntitiesToDamage(EntityUid uid, DamageSpecifier originalDamage, string prototype)
{
_toDamage.Clear();
- _toDamage.Add((uid, GetDamage(uid, prototype, originalDamage)));
+
+ // don't raise BeforeExplodeEvent if the entity is completely immune to explosions
+ var thisDamage = GetDamage(uid, prototype, originalDamage);
+ if (!thisDamage.Any())
+ return;
+
+ _toDamage.Add((uid, thisDamage));
for (var i = 0; i < _toDamage.Count; i++)
{
diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
index a246b94085..9df735ff6a 100644
--- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
+++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
@@ -132,7 +132,8 @@ public sealed partial class ExplosionSystem : EntitySystem
private void RelayedResistance(EntityUid uid, ExplosionResistanceComponent component,
InventoryRelayedEvent args)
{
- OnGetResistance(uid, component, ref args.Args);
+ if (component.Worn)
+ OnGetResistance(uid, component, ref args.Args);
}
private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, ref GetExplosionResistanceEvent args)
@@ -378,9 +379,9 @@ public sealed partial class ExplosionSystem : EntitySystem
private void OnArmorExamine(EntityUid uid, ExplosionResistanceComponent component, ref ArmorExamineEvent args)
{
+ var value = MathF.Round((1f - component.DamageCoefficient) * 100, 1);
+
args.Msg.PushNewline();
- args.Msg.AddMarkup(Loc.GetString("explosion-resistance-coefficient-value",
- ("value", MathF.Round((1f - component.DamageCoefficient) * 100, 1))
- ));
+ args.Msg.AddMarkup(Loc.GetString(component.Examine, ("value", value)));
}
}
diff --git a/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
index efb3734962..9bc49165ee 100644
--- a/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
+++ b/Content.Server/Storage/EntitySystems/EntityStorageSystem.cs
@@ -102,11 +102,7 @@ public sealed class EntityStorageSystem : SharedEntityStorageSystem
private void OnExploded(Entity ent, ref BeforeExplodeEvent args)
{
- if (ent.Comp.ExplosionDamageCoefficient <= 0)
- return;
-
args.Contents.AddRange(ent.Comp.Contents.ContainedEntities);
- args.DamageCoefficient *= ent.Comp.ExplosionDamageCoefficient;
}
protected override void TakeGas(EntityUid uid, SharedEntityStorageComponent component)
diff --git a/Content.Shared/Storage/Components/SharedEntityStorageComponent.cs b/Content.Shared/Storage/Components/SharedEntityStorageComponent.cs
index e70c59c9d6..b4cd18f4d5 100644
--- a/Content.Shared/Storage/Components/SharedEntityStorageComponent.cs
+++ b/Content.Shared/Storage/Components/SharedEntityStorageComponent.cs
@@ -124,12 +124,6 @@ public abstract partial class SharedEntityStorageComponent : Component
///
[ViewVariables]
public Container Contents = default!;
-
- ///
- /// Multiplier for explosion damage that gets applied to contained entities.
- ///
- [DataField]
- public float ExplosionDamageCoefficient = 1;
}
[Serializable, NetSerializable]
diff --git a/Content.Shared/Storage/SharedStorageComponent.cs b/Content.Shared/Storage/SharedStorageComponent.cs
deleted file mode 100644
index e69de29bb2..0000000000
diff --git a/Resources/Locale/en-US/explosions/explosion-resistance.ftl b/Resources/Locale/en-US/explosions/explosion-resistance.ftl
index 26fb74346d..6ebb406b9a 100644
--- a/Resources/Locale/en-US/explosions/explosion-resistance.ftl
+++ b/Resources/Locale/en-US/explosions/explosion-resistance.ftl
@@ -1 +1,2 @@
explosion-resistance-coefficient-value = - [color=orange]Explosion[/color] damage reduced by [color=lightblue]{$value}%[/color].
+explosion-resistance-contents-coefficient-value = - [color=orange]Explosion[/color] damage [color=white]to contents[/color] reduced by [color=lightblue]{$value}%[/color].
diff --git a/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml b/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml
index b8792211a2..867bbc1076 100644
--- a/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml
+++ b/Resources/Prototypes/Entities/Clothing/Back/backpacks.yml
@@ -1,5 +1,5 @@
- type: entity
- parent: Clothing
+ parent: [Clothing, ContentsExplosionResistanceBase]
id: ClothingBackpack
name: backpack
description: You wear this on your back and put items into it.
@@ -28,6 +28,8 @@
# to prevent bag open/honk spam
- type: UseDelay
delay: 0.5
+ - type: ExplosionResistance
+ damageCoefficient: 0.9
- type: entity
parent: ClothingBackpack
diff --git a/Resources/Prototypes/Entities/Clothing/Back/duffel.yml b/Resources/Prototypes/Entities/Clothing/Back/duffel.yml
index ca1281eb9d..2ac53effe6 100644
--- a/Resources/Prototypes/Entities/Clothing/Back/duffel.yml
+++ b/Resources/Prototypes/Entities/Clothing/Back/duffel.yml
@@ -165,6 +165,8 @@
components:
- type: Sprite
sprite: Clothing/Back/Duffels/syndicate.rsi
+ - type: ExplosionResistance
+ damageCoefficient: 0.1
- type: entity
parent: ClothingBackpackDuffelSyndicate
diff --git a/Resources/Prototypes/Entities/Clothing/Belt/belts.yml b/Resources/Prototypes/Entities/Clothing/Belt/belts.yml
index fb27fc676c..0375980d64 100644
--- a/Resources/Prototypes/Entities/Clothing/Belt/belts.yml
+++ b/Resources/Prototypes/Entities/Clothing/Belt/belts.yml
@@ -511,7 +511,7 @@
sprite: Clothing/Belt/salvagewebbing.rsi
- type: entity
- parent: ClothingBeltStorageBase
+ parent: [ClothingBeltStorageBase, ContentsExplosionResistanceBase]
id: ClothingBeltMilitaryWebbing
name: chest rig
description: A set of tactical webbing worn by Syndicate boarding parties.
@@ -520,9 +520,11 @@
sprite: Clothing/Belt/militarywebbing.rsi
- type: Clothing
sprite: Clothing/Belt/militarywebbing.rsi
+ - type: ExplosionResistance
+ damageCoefficient: 0.5
- type: entity
- parent: ClothingBeltStorageBase
+ parent: ClothingBeltMilitaryWebbing
id: ClothingBeltMilitaryWebbingMed
name: medical chest rig
description: A set of tactical webbing worn by Gorlex Marauder medic operatives.
diff --git a/Resources/Prototypes/Entities/Clothing/base_clothing.yml b/Resources/Prototypes/Entities/Clothing/base_clothing.yml
index df22b9b40d..04609381cb 100644
--- a/Resources/Prototypes/Entities/Clothing/base_clothing.yml
+++ b/Resources/Prototypes/Entities/Clothing/base_clothing.yml
@@ -29,3 +29,16 @@
- type: ContainerContainer
containers:
item: !type:ContainerSlot
+
+# a piece of clothing that has explosion resistance *for its contents*, not the wearer
+- type: entity
+ abstract: true
+ id: ContentsExplosionResistanceBase
+ components:
+ - type: ExplosionResistance
+ worn: true # only apply to the clothing itself and items inside, not the wearer
+ examine: explosion-resistance-contents-coefficient-value
+ # to show explosion resistance examine
+ - type: GroupExamine
+ - type: Armor
+ modifiers: {}