Add stamina and mob damage playtest modifiers (#35599)

* Add stamina and mob damage playtest modifiers

* Fix typo

* Add FTL

* Review fixes

* Update Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs

---------

Co-authored-by: slarticodefast <161409025+slarticodefast@users.noreply.github.com>
This commit is contained in:
SlamBamActionman
2025-03-21 00:01:35 +01:00
committed by GitHub
parent 09901e6551
commit 85a6ac90ba
6 changed files with 38 additions and 0 deletions

View File

@@ -77,4 +77,18 @@ public sealed partial class CCVars
public static readonly CVarDef<float> PlaytestExplosionDamageModifier =
CVarDef.Create("playtest.explosion_damage_modifier", 1f, CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// Scales the damage dealt to mobs in the game (i.e. entities with MobStateComponent).
/// </summary>
[CVarControl(AdminFlags.VarEdit)]
public static readonly CVarDef<float> PlaytestMobDamageModifier =
CVarDef.Create("playtest.mob_damage_modifier", 1f, CVar.SERVER | CVar.REPLICATED);
/// <summary>
/// Scales the stamina damage dealt the game.
/// </summary>
[CVarControl(AdminFlags.VarEdit)]
public static readonly CVarDef<float> PlaytestStaminaDamageModifier =
CVarDef.Create("playtest.stamina_damage_modifier", 1f, CVar.SERVER | CVar.REPLICATED);
}

View File

@@ -40,6 +40,7 @@ namespace Content.Shared.Damage
public float UniversalExplosionDamageModifier { get; private set; } = 1f;
public float UniversalThrownDamageModifier { get; private set; } = 1f;
public float UniversalTopicalsHealModifier { get; private set; } = 1f;
public float UniversalMobDamageModifier { get; private set; } = 1f;
public override void Initialize()
{
@@ -82,6 +83,7 @@ namespace Content.Shared.Damage
Subs.CVar(_config, CCVars.PlaytestExplosionDamageModifier, value => UniversalExplosionDamageModifier = value, true);
Subs.CVar(_config, CCVars.PlaytestThrownDamageModifier, value => UniversalThrownDamageModifier = value, true);
Subs.CVar(_config, CCVars.PlaytestTopicalsHealModifier, value => UniversalTopicalsHealModifier = value, true);
Subs.CVar(_config, CCVars.PlaytestMobDamageModifier, value => UniversalMobDamageModifier = value, true);
}
/// <summary>

View File

@@ -1,6 +1,7 @@
using System.Linq;
using Content.Shared.Administration.Logs;
using Content.Shared.Alert;
using Content.Shared.CCVar;
using Content.Shared.CombatMode;
using Content.Shared.Damage.Components;
using Content.Shared.Damage.Events;
@@ -17,6 +18,7 @@ using Content.Shared.Weapons.Melee.Events;
using JetBrains.Annotations;
using Robust.Shared.Audio;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Configuration;
using Robust.Shared.Network;
using Robust.Shared.Player;
using Robust.Shared.Random;
@@ -34,12 +36,15 @@ public sealed partial class StaminaSystem : EntitySystem
[Dependency] private readonly SharedColorFlashEffectSystem _color = default!;
[Dependency] private readonly SharedStunSystem _stunSystem = default!;
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly IConfigurationManager _config = default!;
/// <summary>
/// How much of a buffer is there between the stun duration and when stuns can be re-applied.
/// </summary>
private static readonly TimeSpan StamCritBufferTime = TimeSpan.FromSeconds(3f);
public float UniversalStaminaDamageModifier { get; private set; } = 1f;
public override void Initialize()
{
base.Initialize();
@@ -58,6 +63,8 @@ public sealed partial class StaminaSystem : EntitySystem
SubscribeLocalEvent<StaminaDamageOnCollideComponent, ThrowDoHitEvent>(OnThrowHit);
SubscribeLocalEvent<StaminaDamageOnHitComponent, MeleeHitEvent>(OnMeleeHit);
Subs.CVar(_config, CCVars.PlaytestStaminaDamageModifier, value => UniversalStaminaDamageModifier = value, true);
}
private void OnStamHandleState(EntityUid uid, StaminaComponent component, ref AfterAutoHandleStateEvent args)
@@ -243,6 +250,8 @@ public sealed partial class StaminaSystem : EntitySystem
if (ev.Cancelled)
return;
value = UniversalStaminaDamageModifier * value;
// Have we already reached the point of max stamina damage?
if (component.Critical)
return;

View File

@@ -1,6 +1,7 @@
using Content.Shared.Bed.Sleep;
using Content.Shared.Buckle.Components;
using Content.Shared.CombatMode.Pacification;
using Content.Shared.Damage;
using Content.Shared.Damage.ForceSay;
using Content.Shared.Emoting;
using Content.Shared.Hands;
@@ -44,6 +45,7 @@ public partial class MobStateSystem
SubscribeLocalEvent<MobStateComponent, TryingToSleepEvent>(OnSleepAttempt);
SubscribeLocalEvent<MobStateComponent, CombatModeShouldHandInteractEvent>(OnCombatModeShouldHandInteract);
SubscribeLocalEvent<MobStateComponent, AttemptPacifiedAttackEvent>(OnAttemptPacifiedAttack);
SubscribeLocalEvent<MobStateComponent, DamageModifyEvent>(OnDamageModify);
SubscribeLocalEvent<MobStateComponent, UnbuckleAttemptEvent>(OnUnbuckleAttempt);
}
@@ -186,5 +188,10 @@ public partial class MobStateSystem
args.Cancelled = true;
}
private void OnDamageModify(Entity<MobStateComponent> ent, ref DamageModifyEvent args)
{
args.Damage *= _damageable.UniversalMobDamageModifier;
}
#endregion
}

View File

@@ -1,5 +1,6 @@
using Content.Shared.ActionBlocker;
using Content.Shared.Administration.Logs;
using Content.Shared.Damage;
using Content.Shared.Mobs.Components;
using Content.Shared.Standing;
using Robust.Shared.Physics.Systems;
@@ -16,6 +17,7 @@ public partial class MobStateSystem : EntitySystem
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly ILogManager _logManager = default!;
[Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly DamageableSystem _damageable = default!;
private ISawmill _sawmill = default!;
private EntityQuery<MobStateComponent> _mobStateQuery;

View File

@@ -27,3 +27,7 @@ changecvar-simple-playtest_reagent_heal_modifier = Multiplier affecting reagent
changecvar-full-playtest_reagent_heal_modifier = Multiplier affecting all healing done by reagents.
changecvar-simple-playtest_explosion_damage_modifier = Multiplier affecting explosion damage.
changecvar-full-playtest_explosion_damage_modifier = Multiplier affecting all damage dealt by explosives.
changecvar-simple-playtest_stamina_damage_modifier = Multiplier affecting stamina damage.
changecvar-full-playtest_stamina_damage_modifier = Multiplier affecting all stamina damage dealt.
changecvar-simple-playtest_mob_damage_modifier = Multiplier affecting all damage dealt to mobs.
changecvar-full-playtest_mob_damage_modifier = Multiplier affecting all damage dealt to entities with MobStateComponent.