public enum StatusEffectMetabolismType
{
+ Update,
Add,
Remove,
Set
--- /dev/null
+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)
+ );
+}
[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>
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);
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);
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>
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.
var knockedTime = GameTiming.CurTime + time;
if (entity.Comp.NextUpdate < knockedTime)
- SetKnockdownTime((entity, entity.Comp), knockedTime);
+ SetKnockdownNextUpdate((entity, entity.Comp), knockedTime);
}
/// <summary>
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)
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
} {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
min: 10
type: Add
time: 5
- refresh: false
- !type:PopupMessage
type: Local
messages:
effectProto: StatusEffectSeeingRainbow
time: 5
type: Add
- refresh: false
Drink:
effects:
- !type:GenericStatusEffect
shouldHave: false
effectProto: StatusEffectForcedSleeping
time: 3
- type: Add
+ type: Update
- !type:HealthChange
conditions:
- !type:ReagentThreshold
effectProto: StatusEffectSeeingRainbow
type: Add
time: 15
- refresh: false
- !type:Drunk
boozePower: 15
- !type:PopupMessage
effectProto: StatusEffectSeeingRainbow
type: Add
time: 500
- refresh: false
- !type:Drunk
boozePower: 500
conditions:
effectProto: StatusEffectDrowsiness
time: 1.5
type: Add
- refresh: false
- !type:HealthChange
damage:
types:
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
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
min: 30
type: Add
time: 8
- refresh: false
- !type:GenericStatusEffect
key: Jitter
time: 2.0
effectProto: StatusEffectDrowsiness
time: 4
type: Add
- refresh: false
- !type:GenericStatusEffect
key: Jitter
time: 4.0
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
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
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
effectProto: StatusEffectSeeingRainbow
time: 16
type: Add
- refresh: false
- type: reagent
id: Nicotine
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
effectProto: StatusEffectSeeingRainbow
type: Add
time: 5
- refresh: false
- type: reagent
id: Bananadine
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
component: Muted
type: Add
time: 10
- refresh: false
- type: reagent
id: NorepinephricAcid
effectProto: StatusEffectSeeingRainbow
type: Add
time: 5
- refresh: false
effectProto: StatusEffectDrowsiness
time: 4
type: Add
- refresh: false
- !type:HealthChange
conditions:
- !type:ReagentThreshold
effectProto: StatusEffectSeeingRainbow
type: Add
time: 10
- refresh: false
# TODO: PROPER hallucinations
- type: reagent