nerf melee when laying down (#3173)

* nerf combat when laying down

* remove shooting prevention

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas 2025-03-12 00:26:19 +00:00 committed by GitHub
parent d0ea05ac67
commit e6353f7a25
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 56 additions and 0 deletions

View File

@ -161,4 +161,13 @@ public sealed class DCCVars
/// </summary>
public static readonly CVarDef<bool> EnableBacktoBack =
CVarDef.Create("game.disable_preset_test", false, CVar.SERVERONLY);
/* Laying down combat */
/// <summary>
/// Modifier to apply to all melee attacks when laying down.
/// Don't increase this above 1...
/// </summary>
public static readonly CVarDef<float> LayingDownMeleeMod =
CVarDef.Create("game.laying_down_melee_mod", 0.25f, CVar.REPLICATED);
}

View File

@ -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;
/// <summary>
/// Prevents shooting and makes melee weaker while you are laying down (R)
/// </summary>
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<LayingDownComponent, GetMeleeDamageEvent>(OnGetMeleeDamage);
Subs.CVar(_cfg, DCCVars.LayingDownMeleeMod, mod =>
{
_meleeMod.Coefficients.Clear();
foreach (var proto in _proto.EnumeratePrototypes<DamageTypePrototype>())
{
_meleeMod.Coefficients.Add(proto.ID, mod);
}
}, true);
}
private void OnGetMeleeDamage(Entity<LayingDownComponent> ent, ref GetMeleeDamageEvent args)
{
if (!_standing.IsDown(ent))
return;
args.Modifiers.Add(_meleeMod);
}
}