diff --git a/Content.Shared/Blocking/BlockingSystem.User.cs b/Content.Shared/Blocking/BlockingSystem.User.cs index 8967b91fd4..bfefaf2b92 100644 --- a/Content.Shared/Blocking/BlockingSystem.User.cs +++ b/Content.Shared/Blocking/BlockingSystem.User.cs @@ -58,10 +58,7 @@ public sealed partial class BlockingSystem private void OnDamageModified(EntityUid uid, BlockingComponent component, DamageModifyEvent args) { - _proto.TryIndex(component.PassiveBlockDamageModifer, out var passiveblockModifier); - _proto.TryIndex(component.ActiveBlockDamageModifier, out var activeBlockModifier); - - var modifier = component.IsBlocking ? activeBlockModifier : passiveblockModifier; + var modifier = component.IsBlocking ? component.ActiveBlockDamageModifier : component.PassiveBlockDamageModifer; if (modifier == null) { return; diff --git a/Content.Shared/Blocking/BlockingSystem.cs b/Content.Shared/Blocking/BlockingSystem.cs index d74e934680..3b4da9d69b 100644 --- a/Content.Shared/Blocking/BlockingSystem.cs +++ b/Content.Shared/Blocking/BlockingSystem.cs @@ -1,7 +1,9 @@ using System.Linq; using Content.Shared.Actions; using Content.Shared.Actions.ActionTypes; -using Content.Shared.Doors.Components; +using Content.Shared.Damage; +using Content.Shared.Damage.Prototypes; +using Content.Shared.Examine; using Content.Shared.Hands; using Content.Shared.Hands.Components; using Content.Shared.Hands.EntitySystems; @@ -12,11 +14,14 @@ using Content.Shared.Mobs.Components; using Content.Shared.Physics; using Content.Shared.Popups; using Content.Shared.Toggleable; +using Content.Shared.Verbs; +using Robust.Shared.Network; using Robust.Shared.Physics; using Robust.Shared.Physics.Components; using Robust.Shared.Physics.Systems; using Robust.Shared.Player; using Robust.Shared.Prototypes; +using Robust.Shared.Utility; namespace Content.Shared.Blocking; @@ -30,6 +35,8 @@ public sealed partial class BlockingSystem : EntitySystem [Dependency] private readonly SharedPopupSystem _popupSystem = default!; [Dependency] private readonly EntityLookupSystem _lookup = default!; [Dependency] private readonly SharedPhysicsSystem _physics = default!; + [Dependency] private readonly ExamineSystemShared _examine = default!; + [Dependency] private readonly INetManager _net = default!; public override void Initialize() { @@ -44,6 +51,8 @@ public sealed partial class BlockingSystem : EntitySystem SubscribeLocalEvent(OnToggleAction); SubscribeLocalEvent(OnShutdown); + + SubscribeLocalEvent>(OnVerbExamine); } private void OnEquip(EntityUid uid, BlockingComponent component, GotEquippedHandEvent args) @@ -80,7 +89,7 @@ public sealed partial class BlockingSystem : EntitySystem private void OnToggleAction(EntityUid uid, BlockingComponent component, ToggleActionEvent args) { - if(args.Handled) + if (args.Handled) return; var blockQuery = GetEntityQuery(); @@ -281,4 +290,50 @@ public sealed partial class BlockingSystem : EntitySystem component.User = null; } + private void OnVerbExamine(EntityUid uid, BlockingComponent component, GetVerbsEvent args) + { + if (!args.CanInteract || !args.CanAccess || !_net.IsServer) + return; + + var fraction = component.IsBlocking ? component.ActiveBlockFraction : component.PassiveBlockFraction; + var modifier = component.IsBlocking ? component.ActiveBlockDamageModifier : component.PassiveBlockDamageModifer; + + var msg = new FormattedMessage(); + + msg.AddMarkup(Loc.GetString("blocking-fraction", ("value", MathF.Round(fraction * 100, 1)))); + + if (modifier != null) + { + AppendCoefficients(modifier, msg); + } + + _examine.AddDetailedExamineVerb(args, component, msg, + Loc.GetString("blocking-examinable-verb-text"), + "/Textures/Interface/VerbIcons/dot.svg.192dpi.png", + Loc.GetString("blocking-examinable-verb-message") + ); + } + + private static FormattedMessage AppendCoefficients(DamageModifierSet modifiers, FormattedMessage msg) + { + foreach (var coefficient in modifiers.Coefficients) + { + msg.PushNewline(); + msg.AddMarkup(Loc.GetString("blocking-coefficient-value", + ("type", coefficient.Key), + ("value", MathF.Round(coefficient.Value * 100, 1)) + )); + } + + foreach (var flat in modifiers.FlatReduction) + { + msg.PushNewline(); + msg.AddMarkup(Loc.GetString("blocking-reduction-value", + ("type", flat.Key), + ("value", flat.Value) + )); + } + + return msg; + } } diff --git a/Content.Shared/Blocking/Components/BlockingComponent.cs b/Content.Shared/Blocking/Components/BlockingComponent.cs index dfa22d323e..b9d2e33657 100644 --- a/Content.Shared/Blocking/Components/BlockingComponent.cs +++ b/Content.Shared/Blocking/Components/BlockingComponent.cs @@ -1,4 +1,5 @@ using Content.Shared.Actions.ActionTypes; +using Content.Shared.Damage; using Robust.Shared.Audio; using Robust.Shared.Physics.Collision.Shapes; using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype; @@ -31,24 +32,22 @@ public sealed class BlockingComponent : Component /// /// The shape of the blocking fixture that will be dynamically spawned /// - [ViewVariables(VVAccess.ReadWrite)] [DataField("shape")] + [DataField("shape"), ViewVariables(VVAccess.ReadWrite)] public IPhysShape Shape = new PhysShapeCircle(0.5f); /// /// The damage modifer to use while passively blocking /// - [ViewVariables(VVAccess.ReadWrite)] - [DataField("passiveBlockModifier")] - public string PassiveBlockDamageModifer = "Metallic"; + [DataField("passiveBlockModifier", required: true)] + public DamageModifierSet PassiveBlockDamageModifer = default!; /// /// The damage modifier to use while actively blocking. /// - [ViewVariables(VVAccess.ReadWrite)] - [DataField("activeBlockModifier")] - public string ActiveBlockDamageModifier = "Metallic"; + [DataField("activeBlockModifier", required: true)] + public DamageModifierSet ActiveBlockDamageModifier = default!; - [DataField("blockingToggleActionId", customTypeSerializer:typeof(PrototypeIdSerializer))] + [DataField("blockingToggleActionId", customTypeSerializer: typeof(PrototypeIdSerializer))] public string BlockingToggleActionId = "ToggleBlock"; [DataField("blockingToggleAction")] diff --git a/Content.Shared/Blocking/Components/BlockingUserComponent.cs b/Content.Shared/Blocking/Components/BlockingUserComponent.cs index 6e53d8a6bc..7f71cefd43 100644 --- a/Content.Shared/Blocking/Components/BlockingUserComponent.cs +++ b/Content.Shared/Blocking/Components/BlockingUserComponent.cs @@ -1,5 +1,4 @@ -using Content.Shared.Damage; -using Robust.Shared.Physics; +using Robust.Shared.Physics; namespace Content.Shared.Blocking; @@ -15,14 +14,10 @@ public sealed class BlockingUserComponent : Component [DataField("blockingItem")] public EntityUid? BlockingItem; - [DataField("modifiers")] - public DamageModifierSet Modifiers = default!; - /// /// Stores the entities original bodytype /// Used so that it can be put back to what it was after anchoring /// [DataField("originalBodyType")] public BodyType OriginalBodyType; - } diff --git a/Resources/Locale/en-US/blocking/blocking-examine.ftl b/Resources/Locale/en-US/blocking/blocking-examine.ftl new file mode 100644 index 0000000000..8afc0ef08f --- /dev/null +++ b/Resources/Locale/en-US/blocking/blocking-examine.ftl @@ -0,0 +1,6 @@ +# Blocking examines +blocking-examinable-verb-text = Protection +blocking-examinable-verb-message = Examine the protection values. +blocking-fraction = It blocks [color=lightblue]{$value}%[/color] of incoming damage and: +blocking-coefficient-value = - It takes [color=lightblue]{$value}%[/color] of [color=yellow]{$type}[/color] damage. +blocking-reduction-value = - It takes [color=lightblue]{$value}[/color] less [color=yellow]{$type}[/color] damage. diff --git a/Resources/Prototypes/Damage/modifier_sets.yml b/Resources/Prototypes/Damage/modifier_sets.yml index 694191b403..6e8a8b848f 100644 --- a/Resources/Prototypes/Damage/modifier_sets.yml +++ b/Resources/Prototypes/Damage/modifier_sets.yml @@ -184,139 +184,3 @@ Cellular: 0.0 Radiation: 0.2 Caustic: 0.0 - -# Represents what a riot shield should block passively -# Each shield will probably have their own passive and active modifier sets -# Honestly it should not be too high -- type: damageModifierSet - id: PassiveRiotShieldBlock - coefficients: - Blunt: 0.9 - Slash: 0.9 - Piercing: 0.9 - Heat: 0.9 - -# Represents what a riot shield should block while active -# Should be a higher reduction because you're anchored -- type: damageModifierSet - id: ActiveRiotShieldBlock - coefficients: - Blunt: 0.8 - Slash: 0.8 - Piercing: 0.8 - Heat: 0.8 - flatReductions: - Blunt: 1 - Slash: 1 - Piercing: 1 - Heat: 1 - -- type: damageModifierSet - id: PassiveRiotLaserShieldBlock - coefficients: - Heat: 0.8 - -- type: damageModifierSet - id: ActiveRiotLaserShieldBlock - coefficients: - Heat: 0.7 - flatReductions: - Heat: 2 - -- type: damageModifierSet - id: PassiveRiotBulletShieldBlock - coefficients: - Blunt: 0.8 - Piercing: 0.8 - -- type: damageModifierSet - id: ActiveRiotBulletShieldBlock - coefficients: - Blunt: 0.7 - Piercing: 0.7 - flatReductions: - Blunt: 1.5 - Piercing: 1.5 - -#It's made from wood, so it should probably take more heat/laser damage -- type: damageModifierSet - id: PassiveBucklerBlock - coefficients: - Blunt: 0.95 - Slash: 0.95 - Piercing: 0.95 - Heat: 2 - -- type: damageModifierSet - id: ActiveBucklerBlock - coefficients: - Blunt: 0.85 - Slash: 0.85 - Piercing: 0.85 - Heat: 2 - flatReductions: - Blunt: 1 - Slash: 1 - Piercing: 1 - -#It's a really crummy shield -- type: damageModifierSet - id: PassiveMakeshiftBlock - coefficients: - Blunt: 0.95 - Slash: 0.95 - Piercing: 0.95 - Heat: 0.9 - -- type: damageModifierSet - id: ActiveMakeshiftBlock - coefficients: - Blunt: 0.85 - Slash: 0.85 - Piercing: 0.85 - Heat: 0.8 - flatReductions: - Blunt: 0.5 - Slash: 0.5 - Piercing: 0.5 - Heat: 1 - -#Clockwork generally takes more laser/heat damage -- type: damageModifierSet - id: PassiveClockworkShieldBlock - coefficients: - Blunt: 0.8 - Slash: 0.8 - Piercing: 0.8 - Heat: 1.5 - -- type: damageModifierSet - id: ActiveClockworkShieldBlock - coefficients: - Blunt: 0.7 - Slash: 0.7 - Piercing: 0.7 - Heat: 1.5 - flatReductions: - Blunt: 1 - Slash: 1 - Piercing: 1 - -#Mirror shield should reflect heat/laser eventually, but be relatively weak to everything else. -- type: damageModifierSet - id: PassiveMirrorShieldBlock - coefficients: - Blunt: 1.2 - Slash: 1.2 - Piercing: 1.2 - Heat: .7 - -- type: damageModifierSet - id: ActiveMirrorShieldBlock - coefficients: - Blunt: 1.2 - Slash: 1.2 - Piercing: 1.2 - Heat: .6 - flatReductions: - Heat: 1 diff --git a/Resources/Prototypes/Entities/Objects/Shields/shields.yml b/Resources/Prototypes/Entities/Objects/Shields/shields.yml index f6bc0d5015..4f493f4832 100644 --- a/Resources/Prototypes/Entities/Objects/Shields/shields.yml +++ b/Resources/Prototypes/Entities/Objects/Shields/shields.yml @@ -13,8 +13,23 @@ size: 100 heldPrefix: riot - type: Blocking - passiveBlockModifier: PassiveRiotShieldBlock - activeBlockModifier: ActiveRiotShieldBlock + passiveBlockModifier: + coefficients: + Blunt: 0.9 + Slash: 0.9 + Piercing: 0.9 + Heat: 0.9 + activeBlockModifier: + coefficients: + Blunt: 0.8 + Slash: 0.8 + Piercing: 0.8 + Heat: 0.8 + flatReductions: + Blunt: 1 + Slash: 1 + Piercing: 1 + Heat: 1 blockingToggleAction: name: action-name-blocking description: action-description-blocking @@ -72,8 +87,14 @@ - type: Item heldPrefix: riot_laser - type: Blocking - passiveBlockModifier: PassiveRiotLaserShieldBlock - activeBlockModifier: ActiveRiotLaserShieldBlock + passiveBlockModifier: + coefficients: + Heat: 0.8 + activeBlockModifier: + coefficients: + Heat: 0.7 + flatReductions: + Heat: 2 - type: entity name: riot bullet shield @@ -86,8 +107,17 @@ - type: Item heldPrefix: riot_bullet - type: Blocking - passiveBlockModifier: PassiveRiotBulletShieldBlock - activeBlockModifier: ActiveRiotBulletShieldBlock + passiveBlockModifier: + coefficients: + Blunt: 0.8 + Piercing: 0.8 + activeBlockModifier: + coefficients: + Blunt: 0.7 + Piercing: 0.7 + flatReductions: + Blunt: 1.5 + Piercing: 1.5 #Craftable shields @@ -102,8 +132,22 @@ - type: Item heldPrefix: buckler - type: Blocking - passiveBlockModifier: PassiveBucklerBlock - activeBlockModifier: ActiveBucklerBlock + passiveBlockModifier: + coefficients: + Blunt: 0.95 + Slash: 0.95 + Piercing: 0.95 + Heat: 2 + activeBlockModifier: + coefficients: + Blunt: 0.85 + Slash: 0.85 + Piercing: 0.85 + Heat: 2 + flatReductions: + Blunt: 1 + Slash: 1 + Piercing: 1 - type: Construction graph: WoodenBuckler node: woodenBuckler @@ -142,8 +186,23 @@ - type: Item heldPrefix: metal - type: Blocking - passiveBlockModifier: PassiveMakeshiftBlock - activeBlockModifier: ActiveMakeshiftBlock + passiveBlockModifier: + coefficients: + Blunt: 0.95 + Slash: 0.95 + Piercing: 0.95 + Heat: 0.9 + activeBlockModifier: + coefficients: + Blunt: 0.85 + Slash: 0.85 + Piercing: 0.85 + Heat: 0.8 + flatReductions: + Blunt: 0.5 + Slash: 0.5 + Piercing: 0.5 + Heat: 1 - type: Construction graph: MakeshiftShield node: makeshiftShield @@ -182,8 +241,22 @@ - type: Item heldPrefix: ratvarian - type: Blocking - passiveBlockModifier: PassiveClockworkShieldBlock - activeBlockModifier: ActiveClockworkShieldBlock + passiveBlockModifier: + coefficients: + Blunt: 0.8 + Slash: 0.8 + Piercing: 0.8 + Heat: 1.5 + activeBlockModifier: + coefficients: + Blunt: 0.7 + Slash: 0.7 + Piercing: 0.7 + Heat: 1.5 + flatReductions: + Blunt: 1 + Slash: 1 + Piercing: 1 #Have it break into brass when clock cult is in - type: entity @@ -196,9 +269,21 @@ state: mirror-icon - type: Item heldPrefix: mirror - - type: Blocking - passiveBlockModifier: PassiveMirrorShieldBlock - activeBlockModifier: ActiveMirrorShieldBlock + - type: Blocking #Mirror shield should reflect heat/laser eventually, but be relatively weak to everything else. + passiveBlockModifier: + coefficients: + Blunt: 1.2 + Slash: 1.2 + Piercing: 1.2 + Heat: .7 + activeBlockModifier: + coefficients: + Blunt: 1.2 + Slash: 1.2 + Piercing: 1.2 + Heat: .6 + flatReductions: + Heat: 1 blockSound: !type:SoundPathSpecifier path: /Audio/Effects/glass_step.ogg - type: Destructible