From: Slava0135 <40753025+Slava0135@users.noreply.github.com> Date: Wed, 3 May 2023 05:23:07 +0000 (+0300) Subject: Bomb suit explosion resistance (#15732) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=2ab41e0f8c8eb13787f78e903e3a996cc6cef767;p=space-station-14.git Bomb suit explosion resistance (#15732) --- diff --git a/Content.Server/Armor/ArmorSystem.cs b/Content.Server/Armor/ArmorSystem.cs index 97166e4fa8..a03b29fb9a 100644 --- a/Content.Server/Armor/ArmorSystem.cs +++ b/Content.Server/Armor/ArmorSystem.cs @@ -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); diff --git a/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs b/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs index 8f6307faa6..ed30479690 100644 --- a/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs +++ b/Content.Server/Explosion/Components/ExplosionResistanceComponent.cs @@ -22,9 +22,9 @@ public sealed class ExplosionResistanceComponent : Component public float DamageCoefficient = 1; /// - /// Like , but specified specific to each explosion type for more customizability. + /// Modifiers specific to each explosion type for more customizability. /// [ViewVariables(VVAccess.ReadWrite)] - [DataField("resistances", customTypeSerializer: typeof(PrototypeIdDictionarySerializer))] - public Dictionary Resistances = new(); + [DataField("modifiers", customTypeSerializer: typeof(PrototypeIdDictionarySerializer))] + public Dictionary Modifiers = new(); } diff --git a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs index bd821f2937..1cc42ccf47 100644 --- a/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs +++ b/Content.Server/Explosion/EntitySystems/ExplosionSystem.cs @@ -80,6 +80,8 @@ public sealed partial class ExplosionSystem : EntitySystem SubscribeLocalEvent(OnReset); + SubscribeLocalEvent(OnArmorExamine); + // Handled by ExplosionSystem.Processing.cs SubscribeLocalEvent(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; } /// @@ -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); } /// @@ -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 index 0000000000..26fb74346d --- /dev/null +++ b/Resources/Locale/en-US/explosions/explosion-resistance.ftl @@ -0,0 +1 @@ +explosion-resistance-coefficient-value = - [color=orange]Explosion[/color] damage reduced by [color=lightblue]{$value}%[/color]. diff --git a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml index 92a42e8636..a86e690dac 100644 --- a/Resources/Prototypes/Entities/Clothing/Head/helmets.yml +++ b/Resources/Prototypes/Entities/Clothing/Head/helmets.yml @@ -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: diff --git a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml index 8254b3e91d..49edbfa493 100644 --- a/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml +++ b/Resources/Prototypes/Entities/Clothing/OuterClothing/suits.yml @@ -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: