Files
tbd-station-14/Content.Shared/Damage/Systems/SharedGodmodeSystem.cs
BramvanZijp cf14cb3eb5 The long overdue downfall of stun meta - Stamina resists on Nukie & ERT Suits. (#35580)
* Add stamina damage resistance

* Probably starting a civil war within the community.

* Tweak some values, my chart was outdated.

* Tone down the values

* Allow a way to bypass the resistances, which forks downstream can use.

* Apply suggestions from code review

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>

* Comment out the changes to non-deathsquad suits.

* minor text fix e

* review

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
Co-authored-by: SlamBamActionman <slambamactionman@gmail.com>
Co-authored-by: Milon <milonpl.git@proton.me>
2025-04-14 17:27:26 +02:00

86 lines
2.7 KiB
C#

using Content.Shared.Damage.Components;
using Content.Shared.Damage.Events;
using Content.Shared.Rejuvenate;
using Content.Shared.Slippery;
using Content.Shared.StatusEffect;
namespace Content.Shared.Damage.Systems;
public abstract class SharedGodmodeSystem : EntitySystem
{
[Dependency] private readonly DamageableSystem _damageable = default!;
public override void Initialize()
{
base.Initialize();
SubscribeLocalEvent<GodmodeComponent, BeforeDamageChangedEvent>(OnBeforeDamageChanged);
SubscribeLocalEvent<GodmodeComponent, BeforeStatusEffectAddedEvent>(OnBeforeStatusEffect);
SubscribeLocalEvent<GodmodeComponent, BeforeStaminaDamageEvent>(OnBeforeStaminaDamage);
SubscribeLocalEvent<GodmodeComponent, SlipAttemptEvent>(OnSlipAttempt);
}
private void OnSlipAttempt(EntityUid uid, GodmodeComponent component, SlipAttemptEvent args)
{
args.NoSlip = true;
}
private void OnBeforeDamageChanged(EntityUid uid, GodmodeComponent component, ref BeforeDamageChangedEvent args)
{
args.Cancelled = true;
}
private void OnBeforeStatusEffect(EntityUid uid, GodmodeComponent component, ref BeforeStatusEffectAddedEvent args)
{
args.Cancelled = true;
}
private void OnBeforeStaminaDamage(EntityUid uid, GodmodeComponent component, ref BeforeStaminaDamageEvent args)
{
args.Cancelled = true;
}
public virtual void EnableGodmode(EntityUid uid, GodmodeComponent? godmode = null)
{
godmode ??= EnsureComp<GodmodeComponent>(uid);
if (TryComp<DamageableComponent>(uid, out var damageable))
{
godmode.OldDamage = new DamageSpecifier(damageable.Damage);
}
// Rejuv to cover other stuff
RaiseLocalEvent(uid, new RejuvenateEvent());
}
public virtual void DisableGodmode(EntityUid uid, GodmodeComponent? godmode = null)
{
if (!Resolve(uid, ref godmode, false))
return;
if (TryComp<DamageableComponent>(uid, out var damageable) && godmode.OldDamage != null)
{
_damageable.SetDamage(uid, damageable, godmode.OldDamage);
}
RemComp<GodmodeComponent>(uid);
}
/// <summary>
/// Toggles godmode for a given entity.
/// </summary>
/// <param name="uid">The entity to toggle godmode for.</param>
/// <returns>true if enabled, false if disabled.</returns>
public bool ToggleGodmode(EntityUid uid)
{
if (TryComp<GodmodeComponent>(uid, out var godmode))
{
DisableGodmode(uid, godmode);
return false;
}
EnableGodmode(uid, godmode);
return true;
}
}