Knockdown (#535)

* - add: Better knockdown.

* - add: Some stuff.

* - add: Ghetto alert.
This commit is contained in:
Aviu00
2024-08-01 17:49:56 +00:00
committed by GitHub
parent 5df2d4586e
commit c2fd356c5c
15 changed files with 54 additions and 27 deletions

View File

@@ -38,8 +38,9 @@ namespace Content.Shared.Alert
VeryGood,
VeryVeryGood,
MoodDead,
//WD end
CultBuffed,
Knockdown,
//WD end
PilotingShuttle,
Peckish,
Starving,

View File

@@ -4,6 +4,7 @@ using Content.Shared.Humanoid;
using Content.Shared.Mobs.Components;
using Content.Shared.Physics;
using Content.Shared.Projectiles;
using Content.Shared.Standing;
using Content.Shared.Standing.Systems;
using Content.Shared.Stunnable;
using Content.Shared.Throwing;
@@ -30,6 +31,7 @@ public abstract class SharedTentacleGun : EntitySystem
[Dependency] private readonly ITimerManager _timerManager = default!;
[Dependency] private readonly SharedStandingStateSystem _standing = default!;
[Dependency] private readonly SharedHandsSystem _handsSystem = default!;
[Dependency] private readonly SharedStunSystem _stun = default!;
public override void Initialize()
{
@@ -111,7 +113,7 @@ public abstract class SharedTentacleGun : EntitySystem
return;
}
if (!HasComp<HumanoidAppearanceComponent>(args.Embedded))
if (!TryComp<StandingStateComponent>(args.Embedded, out var standing) || !standing.CanLieDown)
{
DeleteProjectile(uid);
return;
@@ -156,6 +158,7 @@ public abstract class SharedTentacleGun : EntitySystem
private bool PullMob(ProjectileEmbedEvent args)
{
_standing.TryLieDown(args.Embedded);
_stun.TryKnockdown(args.Embedded, TimeSpan.FromSeconds(4), true);
_throwingSystem.TryThrow(args.Embedded, Transform(args.Shooter!.Value).Coordinates, 5f);

View File

@@ -10,5 +10,6 @@ public sealed partial class FlashOnTriggerComponent : Component
[DataField] public float Range = 1.0f;
[DataField] public float Duration = 8.0f;
[DataField] public float Probability = 1.0f;
[DataField] public bool ForceStun; // WD
[DataField] public float StunTime; // WD
[DataField] public float KnockdownTime; // WD
}

View File

@@ -11,6 +11,7 @@ using Content.Shared._White.Wizard.Timestop;
using Content.Shared.Buckle;
using Content.Shared.Buckle.Components;
using Content.Shared.Mobs;
using Content.Shared.Movement.Events;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Input.Binding;
using Robust.Shared.Physics;
@@ -52,6 +53,7 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
SubscribeLocalEvent<StandingStateComponent, StandingUpDoAfterEvent>(OnStandingUpDoAfter);
SubscribeLocalEvent<StandingStateComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovementSpeed);
SubscribeLocalEvent<StandingStateComponent, TileFrictionEvent>(OnTileFriction);
SubscribeLocalEvent<StandingStateComponent, SlipAttemptEvent>(OnSlipAttempt);
InitializeColliding();
@@ -98,12 +100,9 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
private void OnStandingUpDoAfter(EntityUid uid, StandingStateComponent component, StandingUpDoAfterEvent args)
{
if (args.Handled || _stun.IsParalyzed(uid)) // WD EDIT
{
if (args.Handled || args.Cancelled || HasComp<KnockedDownComponent>(uid) ||
_mobState.IsIncapacitated(uid) || !Stand(uid)) // WD EDIT
component.CurrentState = StandingState.Lying;
return;
}
Stand(uid);
}
private void OnRefreshMovementSpeed(EntityUid uid, StandingStateComponent component,
@@ -115,6 +114,12 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
args.ModifySpeed(1f, 1f);
}
private void OnTileFriction(Entity<StandingStateComponent> ent, ref TileFrictionEvent args)
{
if (IsDown(ent))
args.Modifier *= SharedStunSystem.KnockDownModifier;
}
private void OnSlipAttempt(EntityUid uid, StandingStateComponent component, SlipAttemptEvent args)
{
if (IsDown(uid))
@@ -217,6 +222,9 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
if (TryComp(uid, out BuckleComponent? buckle) && buckle.Buckled && !_buckle.TryUnbuckle(uid, uid, buckleComp: buckle)) // WD EDIT
return false;
if (standingState.CurrentState is StandingState.Lying or StandingState.GettingUp)
return true;
// This is just to avoid most callers doing this manually saving boilerplate
// 99% of the time you'll want to drop items but in some scenarios (e.g. buckling) you don't want to.
// We do this BEFORE downing because something like buckle may be blocking downing but we want to drop hand items anyway
@@ -226,9 +234,6 @@ public abstract partial class SharedStandingStateSystem : EntitySystem
RaiseLocalEvent(uid, new DropHandItemsEvent());
}
if (standingState.CurrentState is StandingState.Lying or StandingState.GettingUp)
return true;
var msg = new DownAttemptEvent();
RaiseLocalEvent(uid, msg);

View File

@@ -52,7 +52,7 @@ public abstract class SharedStunSystem : EntitySystem
SubscribeLocalEvent<KnockedDownComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<SlowedDownComponent, RefreshMovementSpeedModifiersEvent>(OnRefreshMovespeed);
SubscribeLocalEvent<KnockedDownComponent, TileFrictionEvent>(OnKnockedTileFriction);
//SubscribeLocalEvent<KnockedDownComponent, TileFrictionEvent>(OnKnockedTileFriction);
// Attempt event subscriptions.
SubscribeLocalEvent<StunnedComponent, ChangeDirectionAttemptEvent>(OnAttempt);
@@ -260,10 +260,10 @@ public abstract class SharedStunSystem : EntitySystem
args.Handled = true;
}
private void OnKnockedTileFriction(EntityUid uid, KnockedDownComponent component, ref TileFrictionEvent args)
/*private void OnKnockedTileFriction(EntityUid uid, KnockedDownComponent component, ref TileFrictionEvent args)
{
args.Modifier *= KnockDownModifier;
}
}*/
//WD EDIT START
public bool IsParalyzed(EntityUid uid)

View File

@@ -21,7 +21,7 @@ public sealed class FlashSoundSuppressionSystem : EntitySystem
args.Args.MaxRange = MathF.Min(args.Args.MaxRange, ent.Comp.MaxRange);
}
public void Stun(EntityUid target, float duration, float distance, float range)
public void Stun(EntityUid target, float stunDuration, float knockdownDuration, float distance, float range)
{
if (TryComp<FlashSoundSuppressionComponent>(target, out var suppression))
range = MathF.Min(range, suppression.MaxRange);
@@ -38,11 +38,13 @@ public sealed class FlashSoundSuppressionSystem : EntitySystem
if (distance > range)
return;
var stunTime = float.Lerp(duration, 0f, distance / range);
if (stunTime <= 0f)
return;
var knockdownTime = float.Lerp(knockdownDuration, 0f, distance / range);
if (knockdownTime > 0f)
_stunSystem.TryKnockdown(target, TimeSpan.FromSeconds(knockdownTime), true);
_stunSystem.TryParalyze(target, TimeSpan.FromSeconds(stunTime / 1000f), true);
var stunTime = float.Lerp(stunDuration, 0f, distance / range);
if (stunTime > 0f)
_stunSystem.TryStun(target, TimeSpan.FromSeconds(stunTime), true);
}
}