diff --git a/Content.Shared/_DV/CCVars/DCCVars.cs b/Content.Shared/_DV/CCVars/DCCVars.cs index 059f16732d..0f4acb5fb7 100644 --- a/Content.Shared/_DV/CCVars/DCCVars.cs +++ b/Content.Shared/_DV/CCVars/DCCVars.cs @@ -161,4 +161,13 @@ public sealed class DCCVars /// public static readonly CVarDef EnableBacktoBack = CVarDef.Create("game.disable_preset_test", false, CVar.SERVERONLY); + + /* Laying down combat */ + + /// + /// Modifier to apply to all melee attacks when laying down. + /// Don't increase this above 1... + /// + public static readonly CVarDef LayingDownMeleeMod = + CVarDef.Create("game.laying_down_melee_mod", 0.25f, CVar.REPLICATED); } diff --git a/Content.Shared/_DV/Standing/LayingDownCombatSystem.cs b/Content.Shared/_DV/Standing/LayingDownCombatSystem.cs new file mode 100644 index 0000000000..4853f8c156 --- /dev/null +++ b/Content.Shared/_DV/Standing/LayingDownCombatSystem.cs @@ -0,0 +1,47 @@ +using Content.Shared._DV.CCVars; +using Content.Shared._White.Standing; +using Content.Shared.Damage; +using Content.Shared.Damage.Prototypes; +using Content.Shared.Standing; +using Content.Shared.Weapons.Melee.Events; +using Robust.Shared.Configuration; +using Robust.Shared.Prototypes; + +namespace Content.Shared._DV.Standing; + +/// +/// Prevents shooting and makes melee weaker while you are laying down (R) +/// +public sealed class LayingDownCombatSystem : EntitySystem +{ + [Dependency] private readonly IConfigurationManager _cfg = default!; + [Dependency] private readonly IPrototypeManager _proto = default!; + [Dependency] private readonly StandingStateSystem _standing = default!; + + private DamageModifierSet _meleeMod = new(); + + public override void Initialize() + { + base.Initialize(); + + // subscribe to LayingDownComponent instead of StandingState so it only applies to mobs that can lie down on keypress + SubscribeLocalEvent(OnGetMeleeDamage); + + Subs.CVar(_cfg, DCCVars.LayingDownMeleeMod, mod => + { + _meleeMod.Coefficients.Clear(); + foreach (var proto in _proto.EnumeratePrototypes()) + { + _meleeMod.Coefficients.Add(proto.ID, mod); + } + }, true); + } + + private void OnGetMeleeDamage(Entity ent, ref GetMeleeDamageEvent args) + { + if (!_standing.IsDown(ent)) + return; + + args.Modifiers.Add(_meleeMod); + } +}