Files
wwdpublic/Content.Shared/Movement/Pulling/Components/PullerComponent.cs
Tirochora 1156acd2f4 No More Instant Grab Combos (#2199)
<!--
This is a semi-strict format, you can add/remove sections as needed but
the order/format should be kept the same
Remove these comments before submitting
-->

<!--
Explain this PR in as much detail as applicable

Some example prompts to consider:
How might this affect the game? The codebase?
What might be some alternatives to this?
How/Who does this benefit/hurt [the game/codebase]?
-->

So, as it stands before this PR, somebody could do a combo like, say,
the judo throw, by ctrl-clicking and then instantly rightclicking,
throwing somebody else to the ground within the blink of an eye. With
this PR, that shouldn't happen - grabbing follows the same rules as
attacking (either punching or shoving), and uses the same cooldown.

---

<!--
A list of everything you have to do before this PR is "complete"
You probably won't have to complete everything before merging but it's
good to leave future references
-->

- [x] Grabbing people puts your unarmed attacks on cooldown
- [x] Unarmed attacking someone puts your grab on cooldown

---

<!--
This is default collapsed, readers click to expand it and see all your
media
The PR media section can get very large at times, so this is a good way
to keep it clean
The title is written using HTML tags
The title must be within the <summary> tags or you won't see it
-->

<details><summary><h1>Media</h1></summary>
<p>

https://github.com/user-attachments/assets/22d4eadb-2ec1-4e6c-9ad3-dbdd36c6f3cd

</p>
</details>

---

<!--
You can add an author after the `🆑` to change the name that appears
in the changelog (ex: `🆑 Death`)
Leaving it blank will default to your GitHub display name
This includes all available types for the changelog
-->

🆑
- tweak: grabbing somebody mid-combo now obeys the same laws as every
other attack, so no more instant judo throws

---------

Co-authored-by: VMSolidus <evilexecutive@gmail.com>
2025-07-20 13:18:01 +10:00

152 lines
4.7 KiB
C#

using Content.Shared._Goobstation.MartialArts;
using Content.Shared._Goobstation.TableSlam; // Goobstation - Table Slam
using Content.Shared.Alert;
using Content.Shared.Movement.Pulling.Systems;
using Robust.Shared.GameStates;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Shared.Movement.Pulling.Components;
/// <summary>
/// Specifies an entity as being able to pull another entity with <see cref="PullableComponent"/>
/// </summary>
[RegisterComponent, NetworkedComponent, AutoGenerateComponentState(true)]
[Access(typeof(PullingSystem), typeof(TableSlamSystem), typeof(SharedMartialArtsSystem))] // Goobstation - Table Slam
public sealed partial class PullerComponent : Component
{
/// <summary>
/// Next time the puller change where they are pulling the target towards.
/// </summary>
[DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoNetworkedField, Access(Other = AccessPermissions.ReadWriteExecute)]
public TimeSpan NextPushTargetChange;
[DataField, AutoNetworkedField, Access(Other = AccessPermissions.ReadWriteExecute)]
public TimeSpan NextPushStop;
[DataField]
public TimeSpan PushChangeCooldown = TimeSpan.FromSeconds(0.1f), PushDuration = TimeSpan.FromSeconds(5f);
// Before changing how this is updated, please see SharedPullerSystem.RefreshMovementSpeed
public float WalkSpeedModifier => Pulling == default ? 1.0f : 0.95f;
public float SprintSpeedModifier => Pulling == default ? 1.0f : 0.95f;
/// <summary>
/// Entity currently being pulled/pushed if applicable.
/// </summary>
[AutoNetworkedField, DataField]
public EntityUid? Pulling;
/// <summary>
/// The position the entity is currently being pulled towards.
/// </summary>
[AutoNetworkedField, DataField]
public EntityCoordinates? PushingTowards;
/// <summary>
/// Does this entity need hands to be able to pull something?
/// </summary>
[DataField]
public bool NeedsHands = true;
/// <summary>
/// The maximum acceleration of pushing, in meters per second squared.
/// </summary>
[DataField]
public float PushAcceleration = 0.3f;
/// <summary>
/// The maximum speed to which the pulled entity may be accelerated relative to the push direction, in meters per second.
/// </summary>
[DataField]
public float MaxPushSpeed = 1.2f;
/// <summary>
/// The maximum distance between the puller and the point towards which the puller may attempt to pull it, in meters.
/// </summary>
[DataField]
public float MaxPushRange = 2f;
[DataField]
public ProtoId<AlertPrototype> PullingAlert = "Pulling";
// Goobstation start
// Added Grab variables
[DataField]
public Dictionary<GrabStage, short> PullingAlertSeverity = new()
{
{ GrabStage.No, 0 },
{ GrabStage.Soft, 1 },
{ GrabStage.Hard, 2 },
{ GrabStage.Suffocate, 3 },
};
[DataField, AutoNetworkedField]
public GrabStage GrabStage = GrabStage.No;
[DataField, AutoNetworkedField]
public GrabStageDirection GrabStageDirection = GrabStageDirection.Increase;
[AutoNetworkedField]
public TimeSpan NextStageChange;
[DataField]
public TimeSpan StageChangeCooldown = TimeSpan.FromSeconds(1.5f);
[AutoNetworkedField]
public TimeSpan WhenCanThrow;
/// <summary>
/// After initiating / upgrading to a hard combat grab, how long should you have to keep somebody grabbed to be able to throw them.
/// </summary>
[DataField]
public TimeSpan ThrowDelayOnGrab = TimeSpan.FromSeconds(2f);
[DataField]
public Dictionary<GrabStage, float> EscapeChances = new()
{
{ GrabStage.No, 1f },
{ GrabStage.Soft, 0.4f }, // WD EDIT
{ GrabStage.Hard, 0.2f }, // WD EDIT
{ GrabStage.Suffocate, 0.1f },
};
[DataField]
public float SuffocateGrabStaminaDamage = 10f;
[DataField]
public float GrabThrowDamageModifier = 2f;
[ViewVariables]
public List<EntityUid> GrabVirtualItems = new();
[ViewVariables]
public Dictionary<GrabStage, int> GrabVirtualItemStageCount = new()
{
{ GrabStage.Suffocate, 1 },
};
[DataField]
public float StaminaDamageOnThrown = 100f;
[DataField]
public float GrabThrownSpeed = 7f;
[DataField]
public float ThrowingDistance = 4f;
[DataField]
public float SoftGrabSpeedModifier = 0.9f;
[DataField]
public float HardGrabSpeedModifier = 0.7f;
[DataField]
public float ChokeGrabSpeedModifier = 0.4f;
// Goobstation end
}
public sealed partial class StopPullingAlertEvent : BaseAlertEvent;