Skip to content

Commit

Permalink
Mirror: Fix SCRAM implant not working while cuffed. Incidentally fix …
Browse files Browse the repository at this point in the history
…freedom implant working while dead/crit (#266)

## Mirror of PR #25978: [Fix SCRAM implant not working while cuffed.
Incidentally fix freedom implant working while
dead/crit](space-wizards/space-station-14#25978)
from <img src="https://avatars.githubusercontent.com/u/10567778?v=4"
alt="space-wizards" width="22"/>
[space-wizards](https://github.com/space-wizards)/[space-station-14](https://github.com/space-wizards/space-station-14)

###### `22e9d6562f21bdd4f0962d6e3b6fcdd81bb4c253`

PR opened by <img
src="https://avatars.githubusercontent.com/u/32041239?v=4"
width="16"/><a href="https://github.com/nikthechampiongr">
nikthechampiongr</a> at 2024-03-10 19:33:05 UTC

---

PR changed 13 files with 142 additions and 3 deletions.

The PR had the following labels:
- Status: Needs Review


---

<details open="true"><summary><h1>Original Body</h1></summary>

> fixes #25662 
> 
> <!-- Please read these guidelines before opening your PR:
https://docs.spacestation14.io/en/getting-started/pr-guideline -->
> <!-- The text between the arrows are comments - they will not be
visible on your PR. -->
> 
> ## About the PR
> <!-- What did you change in this PR? -->
> This pr makes it so you can use the SCRAM implant while cuffed. Also
fixes the freedom implant working while you are in crit, or even dead.
> 
> ## Why / Balance
> <!-- Why was it changed? Link any discussions or issues here. Please
discuss how this would affect game balance. -->
> The implant is made so you can escape horrible situations. It should
as such work while in crit.
> 
> ## Technical details
> <!-- If this is a code change, summarize at high level how your new
code works. This makes it easier to review. -->
> ActionBlockers now has a specific check to see if someone is
conscious. It is also used in the Interaction check now. Actions can now
use that check if the bool is set. The bool is now set for the freedom
and SCRAM! implant actions. Additionally the SCRAM! action now ignores
whether the user can interact in order to be able to use it while
cuffed.
> 
> ## Media
> <!-- 
> PRs which make ingame changes (adding clothing, items, new features,
etc) are required to have media attached that showcase the changes.
> Small fixes/refactors are exempt.
> Any media may be used in SS14 progress reports, with clear credit
given.
> 
> If you're unsure whether your PR will require media, ask a maintainer.
> 
> Check the box below to confirm that you have in fact seen this (put an
X in the brackets, like [X]):
> -->
> 
> - [x] I have added screenshots/videos to this PR showcasing its
changes ingame, **or** this PR does not require an ingame showcase
> 
> ## Breaking changes
> <!--
> List any breaking changes, including namespace, public
class/method/field changes, prototype renames; and provide instructions
for fixing them. This will be pasted in #codebase-changes.
> -->
> 
> **Changelog**
> <!--
> Make players aware of new features and changes that could affect how
they play the game by adding a Changelog entry. Please read the
Changelog guidelines located at:
https://docs.spacestation14.io/en/getting-started/pr-guideline#changelog
> -->
> 
> <!--
> Make sure to take this Changelog template out of the comment block in
order for it to show up.
> 🆑
> - add: Added fun!
> - remove: Removed fun!
> - tweak: Changed fun!
> - fix: Fixed fun!
> -->
> 🆑
> fix: You can now use the SCRAM! implant while cuffed.
> fix: The freedom implant can no longer be used while in crit, or dead.


</details>

Co-authored-by: SimpleStation14 <Unknown>
  • Loading branch information
SimpleStation14 authored May 12, 2024
1 parent 6465a43 commit 151b5e1
Show file tree
Hide file tree
Showing 13 changed files with 142 additions and 3 deletions.
1 change: 1 addition & 0 deletions Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ private void BaseHandleState<T>(EntityUid uid, BaseActionComponent component, Ba
component.Container = EnsureEntity<T>(state.Container, uid);
component.EntityIcon = EnsureEntity<T>(state.EntityIcon, uid);
component.CheckCanInteract = state.CheckCanInteract;
component.CheckConsciousness = state.CheckConsciousness;
component.ClientExclusive = state.ClientExclusive;
component.Priority = state.Priority;
component.AttachedEntity = EnsureEntity<T>(state.AttachedEntity, uid);
Expand Down
8 changes: 8 additions & 0 deletions Content.Server/Bed/Sleep/SleepingSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
using Content.Shared.Examine;
using Content.Shared.IdentityManagement;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Slippery;
Expand Down Expand Up @@ -45,6 +46,7 @@ public override void Initialize()
SubscribeLocalEvent<SleepingComponent, InteractHandEvent>(OnInteractHand);
SubscribeLocalEvent<SleepingComponent, ExaminedEvent>(OnExamined);
SubscribeLocalEvent<SleepingComponent, SlipAttemptEvent>(OnSlip);
SubscribeLocalEvent<SleepingComponent, ConsciousAttemptEvent>(OnConsciousAttempt);
SubscribeLocalEvent<ForcedSleepingComponent, ComponentInit>(OnInit);
}

Expand Down Expand Up @@ -173,6 +175,12 @@ private void OnSlip(EntityUid uid, SleepingComponent component, SlipAttemptEvent
args.Cancel();
}

private void OnConsciousAttempt(EntityUid uid, SleepingComponent component, ConsciousAttemptEvent args)
{
args.Cancel();
}


private void OnInit(EntityUid uid, ForcedSleepingComponent component, ComponentInit args)
{
TrySleeping(uid);
Expand Down
21 changes: 21 additions & 0 deletions Content.Shared/ActionBlocker/ActionBlockerSystem.cs
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
using Content.Shared.Bed.Sleep;
using Content.Shared.Body.Events;
using Content.Shared.DragDrop;
using Content.Shared.Emoting;
using Content.Shared.Hands;
using Content.Shared.Interaction;
using Content.Shared.Interaction.Events;
using Content.Shared.Item;
using Content.Shared.Mobs;
using Content.Shared.Mobs.Components;
using Content.Shared.Movement.Components;
using Content.Shared.Movement.Events;
using Content.Shared.Speech;
Expand Down Expand Up @@ -67,6 +70,9 @@ public bool UpdateCanMove(EntityUid uid, InputMoverComponent? component = null)
/// <returns></returns>
public bool CanInteract(EntityUid user, EntityUid? target)
{
if (!CanConsciouslyPerformAction(user))
return false;

var ev = new InteractionAttemptEvent(user, target);
RaiseLocalEvent(user, ev);

Expand Down Expand Up @@ -98,6 +104,21 @@ public bool CanUseHeldEntity(EntityUid user)
return !ev.Cancelled;
}


/// <summary>
/// Whether a user conscious to perform an action.
/// </summary>
/// <remarks>
/// This should be used when you want a much more permissive check than <see cref="CanInteract"/>
/// </remarks>
public bool CanConsciouslyPerformAction(EntityUid user)
{
var ev = new ConsciousAttemptEvent(user);
RaiseLocalEvent(user, ev);

return !ev.Cancelled;
}

public bool CanThrow(EntityUid user, EntityUid itemUid)
{
var ev = new ThrowAttemptEvent(user, itemUid);
Expand Down
11 changes: 10 additions & 1 deletion Content.Shared/Actions/BaseActionComponent.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Robust.Shared.Audio;
using Content.Shared.Mobs;
using Robust.Shared.Audio;
using Robust.Shared.Serialization;
using Robust.Shared.Utility;

Expand Down Expand Up @@ -118,6 +119,12 @@ public EntityUid? EntityIcon
/// </summary>
[DataField("checkCanInteract")] public bool CheckCanInteract = true;

/// <summary>
/// Whether to check if the user is conscious or not. Can be used instead of <see cref="CheckCanInteract"/>
/// for a more permissive check.
/// </summary>
[DataField] public bool CheckConsciousness = true;

/// <summary>
/// If true, this will cause the action to only execute locally without ever notifying the server.
/// </summary>
Expand Down Expand Up @@ -177,6 +184,7 @@ public abstract class BaseActionComponentState : ComponentState
public NetEntity? Container;
public NetEntity? EntityIcon;
public bool CheckCanInteract;
public bool CheckConsciousness;
public bool ClientExclusive;
public int Priority;
public NetEntity? AttachedEntity;
Expand Down Expand Up @@ -204,6 +212,7 @@ protected BaseActionComponentState(BaseActionComponent component, IEntityManager
MaxCharges = component.MaxCharges;
RenewCharges = component.RenewCharges;
CheckCanInteract = component.CheckCanInteract;
CheckConsciousness = component.CheckConsciousness;
ClientExclusive = component.ClientExclusive;
Priority = component.Priority;
AutoPopulate = component.AutoPopulate;
Expand Down
4 changes: 4 additions & 0 deletions Content.Shared/Actions/SharedActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
using Content.Shared.Interaction;
using Content.Shared.Inventory.Events;
using Content.Shared.Mind;
using Content.Shared.Mobs.Components;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.GameStates;
Expand Down Expand Up @@ -370,6 +371,9 @@ private void OnActionRequest(RequestPerformActionEvent ev, EntitySessionEventArg

BaseActionEvent? performEvent = null;

if (action.CheckConsciousness && !_actionBlockerSystem.CanConsciouslyPerformAction(user))
return;

// Validate request by checking action blockers and the like:
switch (action)
{
Expand Down
8 changes: 8 additions & 0 deletions Content.Shared/Interaction/Events/InteractionAttemptEvent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,14 @@ public InteractionAttemptEvent(EntityUid uid, EntityUid? target)
public EntityUid? Target { get; }
}

/// <summary>
/// Raised to determine whether an entity is conscious to perform an action.
/// </summary>
public sealed class ConsciousAttemptEvent(EntityUid Uid) : CancellableEntityEventArgs
{
public EntityUid Uid { get; } = Uid;
}

/// <summary>
/// Event raised directed at the target entity of an interaction to see if the user is allowed to perform some
/// generic interaction.
Expand Down
2 changes: 1 addition & 1 deletion Content.Shared/Mobs/Systems/MobStateSystem.Subscribers.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ private void SubscribeEvents()
SubscribeLocalEvent<MobStateComponent, ChangeDirectionAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, UseAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, AttackAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, InteractionAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, ConsciousAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, ThrowAttemptEvent>(CheckAct);
SubscribeLocalEvent<MobStateComponent, SpeakAttemptEvent>(OnSpeakAttempt);
SubscribeLocalEvent<MobStateComponent, IsEquippingAttemptEvent>(OnEquipAttempt);
Expand Down
5 changes: 4 additions & 1 deletion Resources/Prototypes/Actions/crit.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Actions added to mobs in crit.
# Actions added to mobs in crit.
- type: entity
id: ActionCritSuccumb
name: Succumb
Expand All @@ -8,6 +8,7 @@
- type: InstantAction
itemIconStyle: NoItem
checkCanInteract: false
checkConsciousness: false
icon:
sprite: Mobs/Ghosts/ghost_human.rsi
state: icon
Expand All @@ -22,6 +23,7 @@
- type: InstantAction
itemIconStyle: NoItem
checkCanInteract: false
checkConsciousness: false
icon:
sprite: Interface/Actions/actions_crit.rsi
state: fakedeath
Expand All @@ -37,6 +39,7 @@
- type: InstantAction
itemIconStyle: NoItem
checkCanInteract: false
checkConsciousness: false
icon:
sprite: Interface/Actions/actions_crit.rsi
state: lastwords
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Actions/diona.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
state: brain
event: !type:GibActionEvent {}
checkCanInteract: false
checkConsciousness: false

- type: entity
id: DionaReformAction
Expand Down
9 changes: 9 additions & 0 deletions Resources/Prototypes/Actions/types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
components:
- type: InstantAction
checkCanInteract: false
checkConsciousness: false
icon: Interface/Actions/zombie-turn.png
event: !type:ZombifySelfActionEvent

Expand Down Expand Up @@ -66,6 +67,7 @@
components:
- type: InstantAction
checkCanInteract: false
checkConsciousness: false
itemIconStyle: BigAction
priority: -20
icon:
Expand All @@ -82,6 +84,7 @@
components:
- type: InstantAction
checkCanInteract: false
checkConsciousness: false
itemIconStyle: BigAction
priority: -20
icon:
Expand Down Expand Up @@ -143,6 +146,7 @@
noSpawn: true
components:
- type: InstantAction
checkCanInteract: false
charges: 2
useDelay: 5
itemIconStyle: BigAction
Expand Down Expand Up @@ -186,6 +190,7 @@
components:
- type: InstantAction
checkCanInteract: false
checkConsciousness: false
icon: Interface/Actions/harmOff.png
iconOn: Interface/Actions/harm.png
event: !type:ToggleCombatActionEvent
Expand Down Expand Up @@ -256,6 +261,7 @@
- type: InstantAction
clientExclusive: true
checkCanInteract: false
checkConsciousness: false
temporary: true
icon: { sprite: Objects/Tools/multitool.rsi, state: icon }
event: !type:ClearAllOverlaysEvent
Expand All @@ -279,6 +285,7 @@
components:
- type: InstantAction
checkCanInteract: false
checkConsciousness: false
icon: { sprite: Clothing/Head/Hats/pyjamasyndicatered.rsi, state: icon }
event: !type:SleepActionEvent

Expand All @@ -291,6 +298,7 @@
- type: InstantAction
icon: { sprite: Clothing/Head/Hats/pyjamasyndicatered.rsi, state: icon }
checkCanInteract: false
checkConsciousness: false
event: !type:WakeActionEvent

- type: entity
Expand Down Expand Up @@ -328,6 +336,7 @@
event: !type:ToggleEyesActionEvent
useDelay: 1 # so u cant give yourself and observers eyestrain by rapidly spamming the action
checkCanInteract: false
checkConsciousness: false

- type: entity
id: ActionToggleWagging
Expand Down
1 change: 1 addition & 0 deletions Resources/Prototypes/Entities/Mobs/Player/guardian.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,3 +253,4 @@
event: !type:GuardianToggleActionEvent
useDelay: 2
checkCanInteract: false
checkConsciousness: false
2 changes: 2 additions & 0 deletions Resources/Prototypes/Entities/Objects/Fun/pai.yml
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,7 @@
components:
- type: InstantAction
checkCanInteract: false
checkConsciousness: false
icon: Interface/Actions/pai-midi.png
event: !type:OpenUiActionEvent
key: enum.InstrumentUiKey.Key
Expand All @@ -150,6 +151,7 @@
components:
- type: InstantAction
checkCanInteract: false
checkConsciousness: false
icon: { sprite: Interface/Actions/pai-map.rsi, state: icon }
event: !type:OpenUiActionEvent
key: enum.StationMapUiKey.Key
Loading

0 comments on commit 151b5e1

Please sign in to comment.