]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Bomb suit explosion resistance (#15732)
authorSlava0135 <40753025+Slava0135@users.noreply.github.com>
Wed, 3 May 2023 05:23:07 +0000 (08:23 +0300)
committerGitHub <noreply@github.com>
Wed, 3 May 2023 05:23:07 +0000 (15:23 +1000)
Content.Server/Armor/ArmorSystem.cs
Content.Server/Explosion/Components/ExplosionResistanceComponent.cs
Content.Server/Explosion/EntitySystems/ExplosionSystem.cs
Resources/Locale/en-US/explosions/explosion-resistance.ftl [new file with mode: 0644]
Resources/Prototypes/Entities/Clothing/Head/helmets.yml
Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml

index 97166e4fa85ea2b92a8bb6963666e069525dbe67..a03b29fb9a9dead9c0a7a8a37cf210afab4b0890 100644 (file)
@@ -79,6 +79,9 @@ namespace Content.Server.Armor
 
             var examineMarkup = GetArmorExamine(armorModifiers);
 
+            var ev = new ArmorExamineEvent(examineMarkup);
+            RaiseLocalEvent(uid, ref ev);
+
             _examine.AddDetailedExamineVerb(args, component, examineMarkup, Loc.GetString("armor-examinable-verb-text"), "/Textures/Interface/VerbIcons/dot.svg.192dpi.png", Loc.GetString("armor-examinable-verb-message"));
         }
 
@@ -110,3 +113,6 @@ namespace Content.Server.Armor
         }
     }
 }
+
+[ByRefEvent]
+public record struct ArmorExamineEvent(FormattedMessage Msg);
index 8f6307faa618befd76baa6982cc4e9a4b44f7e88..ed30479690fd2249d8bfc557de5071efe86aaa10 100644 (file)
@@ -22,9 +22,9 @@ public sealed class ExplosionResistanceComponent : Component
     public float DamageCoefficient = 1;
 
     /// <summary>
-    ///     Like <see cref="GlobalResistance"/>, but specified specific to each explosion type for more customizability.
+    ///     Modifiers specific to each explosion type for more customizability.
     /// </summary>
     [ViewVariables(VVAccess.ReadWrite)]
-    [DataField("resistances", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<float, ExplosionPrototype>))]
-    public Dictionary<string, float> Resistances = new();
+    [DataField("modifiers", customTypeSerializer: typeof(PrototypeIdDictionarySerializer<float, ExplosionPrototype>))]
+    public Dictionary<string, float> Modifiers = new();
 }
index bd821f293706dd19a37b6e263f7399f5e09945a2..1cc42ccf47feeffc0e755423570ee7240b3867f3 100644 (file)
@@ -80,6 +80,8 @@ public sealed partial class ExplosionSystem : EntitySystem
 
         SubscribeLocalEvent<RoundRestartCleanupEvent>(OnReset);
 
+        SubscribeLocalEvent<ExplosionResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
+
         // Handled by ExplosionSystem.Processing.cs
         SubscribeLocalEvent<MapChangedEvent>(OnMapChanged);
 
@@ -93,7 +95,7 @@ public sealed partial class ExplosionSystem : EntitySystem
     private void OnReset(RoundRestartCleanupEvent ev)
     {
         _explosionQueue.Clear();
-        if (_activeExplosion !=null)
+        if (_activeExplosion != null)
             QueueDel(_activeExplosion.VisualEnt);
         _activeExplosion = null;
         _nodeGroupSystem.PauseUpdating = false;
@@ -111,8 +113,8 @@ public sealed partial class ExplosionSystem : EntitySystem
     private void OnGetResistance(EntityUid uid, ExplosionResistanceComponent component, GetExplosionResistanceEvent args)
     {
         args.DamageCoefficient *= component.DamageCoefficient;
-        if (component.Resistances.TryGetValue(args.ExplotionPrototype, out var resistance))
-            args.DamageCoefficient *= resistance;
+        if (component.Modifiers.TryGetValue(args.ExplotionPrototype, out var modifier))
+            args.DamageCoefficient *= modifier;
     }
 
     /// <summary>
@@ -204,7 +206,7 @@ public sealed partial class ExplosionSystem : EntitySystem
             return MathF.Cbrt(3 * totalIntensity / (slope * MathF.PI));
         }
 
-        return r0 * (MathF.Sqrt(12 * totalIntensity/ v0 - 3) / 6 + 0.5f);
+        return r0 * (MathF.Sqrt(12 * totalIntensity / v0 - 3) / 6 + 0.5f);
     }
 
     /// <summary>
@@ -348,4 +350,12 @@ public sealed partial class ExplosionSystem : EntitySystem
                 _recoilSystem.KickCamera(uid, -delta.Normalized * effect);
         }
     }
+
+    private void OnArmorExamine(EntityUid uid, ExplosionResistanceComponent component, ref ArmorExamineEvent args)
+    {
+        args.Msg.PushNewline();
+        args.Msg.AddMarkup(Loc.GetString("explosion-resistance-coefficient-value",
+            ("value", MathF.Round((1f - component.DamageCoefficient) * 100, 1))
+            ));
+    }
 }
diff --git a/Resources/Locale/en-US/explosions/explosion-resistance.ftl b/Resources/Locale/en-US/explosions/explosion-resistance.ftl
new file mode 100644 (file)
index 0000000..26fb743
--- /dev/null
@@ -0,0 +1 @@
+explosion-resistance-coefficient-value = - [color=orange]Explosion[/color] damage reduced by [color=lightblue]{$value}%[/color].
index 92a42e8636498a669e273418c1b26e9bc588bca6..a86e690dacab8c964688f937ea789a04239c84bf 100644 (file)
@@ -10,7 +10,7 @@
     sprite: Clothing/Head/Helmets/bombsuit.rsi
   - type: IngestionBlocker
   - type: ExplosionResistance
-    resistance: 0.25 # +0.65 from body -> 90%
+    damageCoefficient: 0.5
   - type: Armor
     modifiers:
       coefficients:
index 8254b3e91dbbe881e946465214c37b8bdc8553e7..49edbfa493dc1a1ef93756804a76fbeafbb8a893 100644 (file)
@@ -8,7 +8,7 @@
     sprite: Clothing/OuterClothing/Suits/bombsuit.rsi
   - type: Clothing
     sprite: Clothing/OuterClothing/Suits/bombsuit.rsi
-  - type: Armor #explosion damage ignores "normal" armor, see ExplosionResistance.
+  - type: Armor
     modifiers:
       coefficients:
         Blunt: 0.5
@@ -16,7 +16,7 @@
         Piercing: 0.9
         Heat: 0.75
   - type: ExplosionResistance
-    damageCoefficient: 0.65
+    damageCoefficient: 0.2
   - type: GroupExamine
   - type: Tag
     tags: