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>
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
using Content.Shared.Damage.Systems;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.Dictionary;
|
||||
using Robust.Shared.GameStates;
|
||||
|
||||
namespace Content.Shared.Damage.Components;
|
||||
|
||||
/// <summary>
|
||||
/// Component that provides entities with stamina resistance.
|
||||
/// By default this is applied when worn, but to solely protect the entity itself and
|
||||
/// not the wearer use <c>worn: false</c>.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This is desirable over just using damage modifier sets, given that equipment like bomb-suits need to
|
||||
/// significantly reduce the damage, but shouldn't be silly overpowered in regular combat.
|
||||
/// </remarks>
|
||||
[NetworkedComponent, RegisterComponent, AutoGenerateComponentState]
|
||||
public sealed partial class StaminaResistanceComponent : Component
|
||||
{
|
||||
/// <summary>
|
||||
/// The stamina resistance coefficient, This fraction is multiplied into the total resistance.
|
||||
/// </summary>
|
||||
[DataField, AutoNetworkedField]
|
||||
public float DamageCoefficient = 1;
|
||||
|
||||
/// <summary>
|
||||
/// When true, resistances will be applied to the entity wearing this item.
|
||||
/// When false, only this entity will get the resistance.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool Worn = true;
|
||||
|
||||
/// <summary>
|
||||
/// Examine string for stamina resistance.
|
||||
/// Passed <c>value</c> from 0 to 100.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public LocId Examine = "stamina-resistance-coefficient-value";
|
||||
}
|
||||
12
Content.Shared/Damage/Events/BeforeStaminaDamageEvent.cs
Normal file
12
Content.Shared/Damage/Events/BeforeStaminaDamageEvent.cs
Normal file
@@ -0,0 +1,12 @@
|
||||
using Content.Shared.Inventory;
|
||||
|
||||
namespace Content.Shared.Damage.Events;
|
||||
|
||||
/// <summary>
|
||||
/// Raised before stamina damage is dealt to allow other systems to cancel or modify it.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false) : IInventoryRelayEvent
|
||||
{
|
||||
SlotFlags IInventoryRelayEvent.TargetSlots => ~SlotFlags.POCKET;
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Rejuvenate;
|
||||
using Content.Shared.Slippery;
|
||||
using Content.Shared.StatusEffect;
|
||||
|
||||
38
Content.Shared/Damage/Systems/StaminaSystem.Resistance.cs
Normal file
38
Content.Shared/Damage/Systems/StaminaSystem.Resistance.cs
Normal file
@@ -0,0 +1,38 @@
|
||||
using Content.Shared.Armor;
|
||||
using Content.Shared.Damage.Components;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Inventory;
|
||||
|
||||
namespace Content.Shared.Damage.Systems;
|
||||
|
||||
public sealed partial class StaminaSystem
|
||||
{
|
||||
private void InitializeResistance()
|
||||
{
|
||||
SubscribeLocalEvent<StaminaResistanceComponent, BeforeStaminaDamageEvent>(OnGetResistance);
|
||||
SubscribeLocalEvent<StaminaResistanceComponent, InventoryRelayedEvent<BeforeStaminaDamageEvent>>(RelayedResistance);
|
||||
SubscribeLocalEvent<StaminaResistanceComponent, ArmorExamineEvent>(OnArmorExamine);
|
||||
}
|
||||
|
||||
private void OnGetResistance(Entity<StaminaResistanceComponent> ent, ref BeforeStaminaDamageEvent args)
|
||||
{
|
||||
args.Value *= ent.Comp.DamageCoefficient;
|
||||
}
|
||||
|
||||
private void RelayedResistance(Entity<StaminaResistanceComponent> ent, ref InventoryRelayedEvent<BeforeStaminaDamageEvent> args)
|
||||
{
|
||||
if (ent.Comp.Worn)
|
||||
OnGetResistance(ent, ref args.Args);
|
||||
}
|
||||
|
||||
private void OnArmorExamine(Entity<StaminaResistanceComponent> ent, ref ArmorExamineEvent args)
|
||||
{
|
||||
var value = MathF.Round((1f - ent.Comp.DamageCoefficient) * 100, 1);
|
||||
|
||||
if (value == 0)
|
||||
return;
|
||||
|
||||
args.Msg.PushNewline();
|
||||
args.Msg.AddMarkupOrThrow(Loc.GetString(ent.Comp.Examine, ("value", value)));
|
||||
}
|
||||
}
|
||||
@@ -50,6 +50,7 @@ public sealed partial class StaminaSystem : EntitySystem
|
||||
base.Initialize();
|
||||
|
||||
InitializeModifier();
|
||||
InitializeResistance();
|
||||
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentStartup>(OnStartup);
|
||||
SubscribeLocalEvent<StaminaComponent, ComponentShutdown>(OnShutdown);
|
||||
@@ -240,7 +241,7 @@ public sealed partial class StaminaSystem : EntitySystem
|
||||
}
|
||||
|
||||
public void TakeStaminaDamage(EntityUid uid, float value, StaminaComponent? component = null,
|
||||
EntityUid? source = null, EntityUid? with = null, bool visual = true, SoundSpecifier? sound = null)
|
||||
EntityUid? source = null, EntityUid? with = null, bool visual = true, SoundSpecifier? sound = null, bool ignoreResist = false)
|
||||
{
|
||||
if (!Resolve(uid, ref component, false))
|
||||
return;
|
||||
@@ -250,6 +251,12 @@ public sealed partial class StaminaSystem : EntitySystem
|
||||
if (ev.Cancelled)
|
||||
return;
|
||||
|
||||
// Allow stamina resistance to be applied.
|
||||
if (!ignoreResist)
|
||||
{
|
||||
value = ev.Value;
|
||||
}
|
||||
|
||||
value = UniversalStaminaDamageModifier * value;
|
||||
|
||||
// Have we already reached the point of max stamina damage?
|
||||
@@ -399,9 +406,3 @@ public sealed partial class StaminaSystem : EntitySystem
|
||||
_adminLogger.Add(LogType.Stamina, LogImpact.Low, $"{ToPrettyString(uid):user} recovered from stamina crit");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Raised before stamina damage is dealt to allow other systems to cancel it.
|
||||
/// </summary>
|
||||
[ByRefEvent]
|
||||
public record struct BeforeStaminaDamageEvent(float Value, bool Cancelled = false);
|
||||
|
||||
@@ -5,6 +5,7 @@ using Content.Shared.Chemistry;
|
||||
using Content.Shared.Chemistry.Hypospray.Events;
|
||||
using Content.Shared.Climbing.Events;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Events;
|
||||
using Content.Shared.Electrocution;
|
||||
using Content.Shared.Explosion;
|
||||
using Content.Shared.Eye.Blinding.Systems;
|
||||
@@ -45,6 +46,7 @@ public partial class InventorySystem
|
||||
SubscribeLocalEvent<InventoryComponent, CoefficientQueryEvent>(RelayInventoryEvent);
|
||||
|
||||
// by-ref events
|
||||
SubscribeLocalEvent<InventoryComponent, BeforeStaminaDamageEvent>(RefRelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, GetExplosionResistanceEvent>(RefRelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, IsWeightlessEvent>(RefRelayInventoryEvent);
|
||||
SubscribeLocalEvent<InventoryComponent, GetSpeedModifierContactCapEvent>(RefRelayInventoryEvent);
|
||||
|
||||
Reference in New Issue
Block a user