Stunned Status and Knockdown Meth fix. (#39547)
* Init Commit * Remove unused code, fix stun visuals bug * Update Content.Shared/Stunnable/SharedStunSystem.cs * Some initial changes * first batch of changes * Commit * One line cleanup * KnockdownStatusEffect ain't worth it. * Fix 2 bugs * Fixes * Remove that actually, * Maybe this? * Meff fix * Meff fix * alert cleanup and API * I expect update loops to be at the top. * Fix LOC * Address review * Address review x 2 * Merg my PR * Fix * Update Content.Shared/Alert/AlertsSystem.cs webedit Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com> * FIX THAT TEST FAIL!!!! * Me when I forget to actually give you alerts * Push * Tests are not failing locally why are they dying on github??? * Fix test fails (real) --------- Co-authored-by: Princess Cheeseballs <66055347+Pronana@users.noreply.github.com> Co-authored-by: ScarKy0 <106310278+ScarKy0@users.noreply.github.com> Co-authored-by: Perry Fraser <perryprog@users.noreply.github.com>
This commit is contained in:
committed by
GitHub
parent
abff932ca8
commit
141d903125
@@ -69,6 +69,7 @@ public sealed partial class GenericStatusEffect : EntityEffect
|
||||
|
||||
public enum StatusEffectMetabolismType
|
||||
{
|
||||
Update,
|
||||
Add,
|
||||
Remove,
|
||||
Set
|
||||
|
||||
@@ -0,0 +1,99 @@
|
||||
using Content.Shared.Stunnable;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Shared.EntityEffects.Effects.StatusEffects;
|
||||
|
||||
/// <summary>
|
||||
/// Changes the knockdown timer on an entity or causes knockdown.
|
||||
/// </summary>
|
||||
[UsedImplicitly]
|
||||
public sealed partial class ModifyKnockdown : EntityEffect
|
||||
{
|
||||
/// <summary>
|
||||
/// Should we only affect those with crawler component? Note if this is false, it will paralyze non-crawler's instead.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool Crawling;
|
||||
|
||||
/// <summary>
|
||||
/// Should we drop items when we fall?
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool Drop;
|
||||
|
||||
/// <summary>
|
||||
/// Time for which knockdown should be applied. Behaviour changes according to <see cref="StatusEffectMetabolismType"/>.
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public TimeSpan Time = TimeSpan.FromSeconds(0.5);
|
||||
|
||||
/// <summary>
|
||||
/// Should this effect add the status effect, remove time from it, or set its cooldown?
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public StatusEffectMetabolismType Type = StatusEffectMetabolismType.Add;
|
||||
|
||||
/// <summary>
|
||||
/// Should this effect add knockdown?, remove time from it?, or set its cooldown?
|
||||
/// </summary>
|
||||
[DataField]
|
||||
public bool Refresh = true;
|
||||
|
||||
/// <inheritdoc />
|
||||
public override void Effect(EntityEffectBaseArgs args)
|
||||
{
|
||||
var stunSys = args.EntityManager.EntitySysManager.GetEntitySystem<SharedStunSystem>();
|
||||
|
||||
var time = Time;
|
||||
if (args is EntityEffectReagentArgs reagentArgs)
|
||||
time *= reagentArgs.Scale.Float();
|
||||
|
||||
switch (Type)
|
||||
{
|
||||
case StatusEffectMetabolismType.Update:
|
||||
if (Crawling)
|
||||
{
|
||||
stunSys.TryCrawling(args.TargetEntity, time, drop: Drop);
|
||||
}
|
||||
else
|
||||
{
|
||||
stunSys.TryKnockdown(args.TargetEntity, time, drop: Drop);
|
||||
}
|
||||
break;
|
||||
case StatusEffectMetabolismType.Add:
|
||||
if (Crawling)
|
||||
{
|
||||
stunSys.TryCrawling(args.TargetEntity, time, false, drop: Drop);
|
||||
}
|
||||
else
|
||||
{
|
||||
stunSys.TryKnockdown(args.TargetEntity, time, false, drop: Drop);
|
||||
}
|
||||
break;
|
||||
case StatusEffectMetabolismType.Remove:
|
||||
stunSys.AddKnockdownTime(args.TargetEntity, -time);
|
||||
break;
|
||||
case StatusEffectMetabolismType.Set:
|
||||
if (Crawling)
|
||||
{
|
||||
stunSys.TryCrawling(args.TargetEntity, time, drop: Drop);
|
||||
}
|
||||
else
|
||||
{
|
||||
stunSys.TryKnockdown(args.TargetEntity, time, drop: Drop);
|
||||
}
|
||||
stunSys.SetKnockdownTime(args.TargetEntity, time);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override string? ReagentEffectGuidebookText(IPrototypeManager prototype, IEntitySystemManager entSys)
|
||||
=> Loc.GetString(
|
||||
"reagent-effect-guidebook-knockdown",
|
||||
("chance", Probability),
|
||||
("type", Type),
|
||||
("time", Time.TotalSeconds)
|
||||
);
|
||||
}
|
||||
@@ -25,12 +25,6 @@ public sealed partial class ModifyStatusEffect : EntityEffect
|
||||
[DataField]
|
||||
public float Delay = 0f;
|
||||
|
||||
/// <remarks>
|
||||
/// true - refresh status effect time (update to greater value), false - accumulate status effect time.
|
||||
/// </remarks>
|
||||
[DataField]
|
||||
public bool Refresh = true;
|
||||
|
||||
/// <summary>
|
||||
/// Should this effect add the status effect, remove time from it, or set its cooldown?
|
||||
/// </summary>
|
||||
@@ -49,11 +43,11 @@ public sealed partial class ModifyStatusEffect : EntityEffect
|
||||
var duration = TimeSpan.FromSeconds(time);
|
||||
switch (Type)
|
||||
{
|
||||
case StatusEffectMetabolismType.Update:
|
||||
statusSys.TryUpdateStatusEffectDuration(args.TargetEntity, EffectProto, duration, Delay > 0 ? TimeSpan.FromSeconds(Delay) : null);
|
||||
break;
|
||||
case StatusEffectMetabolismType.Add:
|
||||
if (Refresh)
|
||||
statusSys.TryUpdateStatusEffectDuration(args.TargetEntity, EffectProto, duration, Delay > 0 ? TimeSpan.FromSeconds(Delay) : null);
|
||||
else
|
||||
statusSys.TryAddStatusEffectDuration(args.TargetEntity, EffectProto, duration, Delay > 0 ? TimeSpan.FromSeconds(Delay) : null);
|
||||
statusSys.TryAddStatusEffectDuration(args.TargetEntity, EffectProto, duration, Delay > 0 ? TimeSpan.FromSeconds(Delay) : null);
|
||||
break;
|
||||
case StatusEffectMetabolismType.Remove:
|
||||
statusSys.TryAddTime(args.TargetEntity, EffectProto, -duration);
|
||||
|
||||
@@ -95,7 +95,7 @@ public abstract partial class SharedStunSystem
|
||||
|
||||
private void OnRejuvenate(Entity<KnockedDownComponent> entity, ref RejuvenateEvent args)
|
||||
{
|
||||
SetKnockdownTime(entity, GameTiming.CurTime);
|
||||
SetKnockdownNextUpdate((entity, entity), GameTiming.CurTime);
|
||||
|
||||
if (entity.Comp.AutoStand)
|
||||
RemComp<KnockedDownComponent>(entity);
|
||||
@@ -156,6 +156,19 @@ public abstract partial class SharedStunSystem
|
||||
DirtyField(entity, entity.Comp, nameof(KnockedDownComponent.DoAfterId));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the time left of the knockdown timer to the inputted value.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity who's knockdown time we're updating.</param>
|
||||
/// <param name="time">The time we're updating with.</param>
|
||||
public void SetKnockdownTime(Entity<KnockedDownComponent?> entity, TimeSpan time)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp, false))
|
||||
return;
|
||||
|
||||
SetKnockdownNextUpdate(entity, GameTiming.CurTime + time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Updates the knockdown timer of a knocked down entity with a given inputted time, then dirties the time.
|
||||
/// </summary>
|
||||
@@ -170,18 +183,6 @@ public abstract partial class SharedStunSystem
|
||||
AddKnockdownTime(entity, time);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets the next update datafield of an entity's <see cref="KnockedDownComponent"/> to a specific time.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity whose timer we're updating</param>
|
||||
/// <param name="time">The exact time we're setting the next update to.</param>
|
||||
public void SetKnockdownTime(Entity<KnockedDownComponent> entity, TimeSpan time)
|
||||
{
|
||||
entity.Comp.NextUpdate = time;
|
||||
DirtyField(entity, entity.Comp, nameof(KnockedDownComponent.NextUpdate));
|
||||
Alerts.ShowAlert(entity.Owner, KnockdownAlert, null, (GameTiming.CurTime, entity.Comp.NextUpdate));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Refreshes the amount of time an entity is knocked down to the inputted time, if it is greater than
|
||||
/// the current time left.
|
||||
@@ -195,7 +196,7 @@ public abstract partial class SharedStunSystem
|
||||
|
||||
var knockedTime = GameTiming.CurTime + time;
|
||||
if (entity.Comp.NextUpdate < knockedTime)
|
||||
SetKnockdownTime((entity, entity.Comp), knockedTime);
|
||||
SetKnockdownNextUpdate((entity, entity.Comp), knockedTime);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -210,19 +211,35 @@ public abstract partial class SharedStunSystem
|
||||
|
||||
if (entity.Comp.NextUpdate < GameTiming.CurTime)
|
||||
{
|
||||
SetKnockdownTime((entity, entity.Comp), GameTiming.CurTime + time);
|
||||
SetKnockdownNextUpdate((entity, entity.Comp), GameTiming.CurTime + time);
|
||||
return;
|
||||
}
|
||||
|
||||
entity.Comp.NextUpdate += time;
|
||||
DirtyField(entity, entity.Comp, nameof(KnockedDownComponent.NextUpdate));
|
||||
Alerts.ShowAlert(entity.Owner, KnockdownAlert, null, (GameTiming.CurTime, entity.Comp.NextUpdate));
|
||||
SetKnockdownNextUpdate((entity, entity.Comp), entity.Comp.NextUpdate + time);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region Knockdown Logic
|
||||
|
||||
/// <summary>
|
||||
/// Sets the next update datafield of an entity's <see cref="KnockedDownComponent"/> to a specific time.
|
||||
/// </summary>
|
||||
/// <param name="entity">Entity whose timer we're updating</param>
|
||||
/// <param name="time">The exact time we're setting the next update to.</param>
|
||||
private void SetKnockdownNextUpdate(Entity<KnockedDownComponent?> entity, TimeSpan time)
|
||||
{
|
||||
if (!Resolve(entity, ref entity.Comp, false))
|
||||
return;
|
||||
|
||||
if (GameTiming.CurTime > time)
|
||||
time = GameTiming.CurTime;
|
||||
|
||||
entity.Comp.NextUpdate = time;
|
||||
DirtyField(entity, entity.Comp, nameof(KnockedDownComponent.NextUpdate));
|
||||
Alerts.UpdateAlert(entity.Owner, KnockdownAlert, null, entity.Comp.NextUpdate);
|
||||
}
|
||||
|
||||
private void HandleToggleKnockdown(ICommonSession? session)
|
||||
{
|
||||
if (session is not { } playerSession)
|
||||
|
||||
@@ -104,6 +104,10 @@ reagent-effect-guidebook-even-health-change =
|
||||
|
||||
reagent-effect-guidebook-status-effect =
|
||||
{ $type ->
|
||||
[update]{ $chance ->
|
||||
[1] Causes
|
||||
*[other] cause
|
||||
} {LOC($key)} for at least {NATURALFIXED($time, 3)} {MANY("second", $time)} without accumulation
|
||||
[add] { $chance ->
|
||||
[1] Causes
|
||||
*[other] cause
|
||||
@@ -134,6 +138,26 @@ reagent-effect-guidebook-status-effect-delay =
|
||||
} {NATURALFIXED($time, 3)} {MANY("second", $time)} of {LOC($key)}
|
||||
} after a {NATURALFIXED($delay, 3)} second delay
|
||||
|
||||
reagent-effect-guidebook-knockdown =
|
||||
{ $type ->
|
||||
[update]{ $chance ->
|
||||
[1] Causes
|
||||
*[other] cause
|
||||
} {LOC($key)} for at least {NATURALFIXED($time, 3)} {MANY("second", $time)} without accumulation
|
||||
[add] { $chance ->
|
||||
[1] Causes
|
||||
*[other] cause
|
||||
} knockdown for at least {NATURALFIXED($time, 3)} {MANY("second", $time)} with accumulation
|
||||
*[set] { $chance ->
|
||||
[1] Causes
|
||||
*[other] cause
|
||||
} knockdown for at least {NATURALFIXED($time, 3)} {MANY("second", $time)} without accumulation
|
||||
[remove]{ $chance ->
|
||||
[1] Removes
|
||||
*[other] remove
|
||||
} {NATURALFIXED($time, 3)} {MANY("second", $time)} of knockdown
|
||||
}
|
||||
|
||||
reagent-effect-guidebook-set-solution-temperature-effect =
|
||||
{ $chance ->
|
||||
[1] Sets
|
||||
|
||||
@@ -34,7 +34,6 @@
|
||||
min: 10
|
||||
type: Add
|
||||
time: 5
|
||||
refresh: false
|
||||
- !type:PopupMessage
|
||||
type: Local
|
||||
messages:
|
||||
|
||||
@@ -114,7 +114,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
time: 5
|
||||
type: Add
|
||||
refresh: false
|
||||
Drink:
|
||||
effects:
|
||||
- !type:GenericStatusEffect
|
||||
|
||||
@@ -372,7 +372,7 @@
|
||||
shouldHave: false
|
||||
effectProto: StatusEffectForcedSleeping
|
||||
time: 3
|
||||
type: Add
|
||||
type: Update
|
||||
- !type:HealthChange
|
||||
conditions:
|
||||
- !type:ReagentThreshold
|
||||
@@ -412,7 +412,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
type: Add
|
||||
time: 15
|
||||
refresh: false
|
||||
- !type:Drunk
|
||||
boozePower: 15
|
||||
- !type:PopupMessage
|
||||
@@ -452,7 +451,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
type: Add
|
||||
time: 500
|
||||
refresh: false
|
||||
- !type:Drunk
|
||||
boozePower: 500
|
||||
conditions:
|
||||
|
||||
@@ -89,7 +89,6 @@
|
||||
effectProto: StatusEffectDrowsiness
|
||||
time: 1.5
|
||||
type: Add
|
||||
refresh: false
|
||||
- !type:HealthChange
|
||||
damage:
|
||||
types:
|
||||
@@ -364,12 +363,11 @@
|
||||
min: 1
|
||||
reagent: Histamine
|
||||
amount: 4
|
||||
- !type:GenericStatusEffect
|
||||
key: Stun
|
||||
- !type:ModifyStatusEffect
|
||||
effectProto: StatusEffectStunned
|
||||
time: 0.75
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
key: KnockedDown
|
||||
- !type:ModifyKnockdown
|
||||
time: 0.75
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
@@ -744,12 +742,11 @@
|
||||
damage:
|
||||
types:
|
||||
Poison: 2
|
||||
- !type:GenericStatusEffect
|
||||
key: Stun
|
||||
- !type:ModifyStatusEffect
|
||||
effectProto: StatusEffectStunned
|
||||
time: 3.0
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
key: KnockedDown
|
||||
- !type:ModifyKnockdown
|
||||
time: 3.0
|
||||
type: Remove
|
||||
- !type:ModifyStatusEffect
|
||||
@@ -1354,7 +1351,6 @@
|
||||
min: 30
|
||||
type: Add
|
||||
time: 8
|
||||
refresh: false
|
||||
- !type:GenericStatusEffect
|
||||
key: Jitter
|
||||
time: 2.0
|
||||
@@ -1416,7 +1412,6 @@
|
||||
effectProto: StatusEffectDrowsiness
|
||||
time: 4
|
||||
type: Add
|
||||
refresh: false
|
||||
- !type:GenericStatusEffect
|
||||
key: Jitter
|
||||
time: 4.0
|
||||
|
||||
@@ -33,12 +33,11 @@
|
||||
key: Stutter
|
||||
component: StutteringAccent
|
||||
- !type:Jitter
|
||||
- !type:GenericStatusEffect
|
||||
key: Stun
|
||||
- !type:ModifyStatusEffect
|
||||
effectProto: StatusEffectStunned
|
||||
time: 3
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
key: KnockedDown
|
||||
- !type:ModifyKnockdown
|
||||
time: 3
|
||||
type: Remove
|
||||
- !type:ModifyStatusEffect
|
||||
@@ -82,12 +81,11 @@
|
||||
Poison: 2 # this is added to the base damage of the meth.
|
||||
Asphyxiation: 2
|
||||
- !type:Jitter
|
||||
- !type:GenericStatusEffect
|
||||
key: Stun
|
||||
- !type:ModifyStatusEffect
|
||||
effectProto: StatusEffectStunned
|
||||
time: 1
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
key: KnockedDown
|
||||
- !type:ModifyKnockdown
|
||||
time: 1
|
||||
type: Remove
|
||||
- !type:ModifyStatusEffect
|
||||
@@ -142,12 +140,11 @@
|
||||
min: 1
|
||||
reagent: ChloralHydrate
|
||||
amount: -10
|
||||
- !type:GenericStatusEffect
|
||||
key: Stun
|
||||
- !type:ModifyStatusEffect
|
||||
effectProto: StatusEffectStunned
|
||||
time: 3
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
key: KnockedDown
|
||||
- !type:ModifyKnockdown
|
||||
time: 3
|
||||
type: Remove
|
||||
- !type:GenericStatusEffect
|
||||
@@ -205,7 +202,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
time: 16
|
||||
type: Add
|
||||
refresh: false
|
||||
|
||||
- type: reagent
|
||||
id: Nicotine
|
||||
@@ -243,7 +239,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
time: 10
|
||||
type: Add
|
||||
refresh: false
|
||||
- !type:ChemVomit # Vomiting is a symptom of brain damage
|
||||
probability: 0.05
|
||||
- !type:Drunk # Headaches and slurring are major symptoms of brain damage, this is close enough
|
||||
@@ -264,7 +259,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
type: Add
|
||||
time: 5
|
||||
refresh: false
|
||||
|
||||
- type: reagent
|
||||
id: Bananadine
|
||||
@@ -281,7 +275,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
type: Add
|
||||
time: 5
|
||||
refresh: false
|
||||
|
||||
# Probably replace this one with sleeping chem when putting someone in a comatose state is easier
|
||||
- type: reagent
|
||||
@@ -325,7 +318,6 @@
|
||||
component: Muted
|
||||
type: Add
|
||||
time: 10
|
||||
refresh: false
|
||||
|
||||
- type: reagent
|
||||
id: NorepinephricAcid
|
||||
@@ -477,4 +469,3 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
type: Add
|
||||
time: 5
|
||||
refresh: false
|
||||
|
||||
@@ -74,7 +74,6 @@
|
||||
effectProto: StatusEffectDrowsiness
|
||||
time: 4
|
||||
type: Add
|
||||
refresh: false
|
||||
- !type:HealthChange
|
||||
conditions:
|
||||
- !type:ReagentThreshold
|
||||
@@ -359,7 +358,6 @@
|
||||
effectProto: StatusEffectSeeingRainbow
|
||||
type: Add
|
||||
time: 10
|
||||
refresh: false
|
||||
# TODO: PROPER hallucinations
|
||||
|
||||
- type: reagent
|
||||
|
||||
Reference in New Issue
Block a user