Skip to content

Commit

Permalink
Most actions cannot be used while incapacitated (tgstation#73513)
Browse files Browse the repository at this point in the history
## About The Pull Request

Fixes tgstation#39775
The `TRAIT_INCAPACITATED` trait is intended to block you from acting but
does not inherently block actions. Actions only check for "conscious",
"has available hands", "immobile", or "lying down".
Most actions still _can't_ be used while incapacitated. This is because
most actions are spells, most spells have invocations, and you can't
talk while you are incapacitated. This is silly.

I have resolved this by adding a new flag which blocks actions while
incapacitated. This is somewhat redundant with "conscious" because most
sources of that also make you incapacitated but not _always_, you might
want the specificity.

I have tried to be discerning about where this flag is applied, it is
not in all cases (for instance you can still swallow implanted pills
while incapacitated and such), but it's not only possible but I can't
really avoid implementing this without it being a balance change in
_some_ cases,

Actions this effects are things such as:
Xenomorph Tail Sweep, Lesser Magic Missile (cult constucts), Heretic
Shadow Cloak, the Smoke spell in general, Conjuring (but not firing)
Infinite Guns, Mime spells

Times when these actions will no longer be available but were previously
are such times as when the mob is:
Stamina Crit, Stunned, Paralysis, and Time Stopped.

## Why It's Good For The Game

The incapacitated trait is applied by effects which should block acting
but still permits several actions which logically would be prevented.
This fortunately hasn't come up too often due to the high ratio of
actions with invocations, but it feels bad to stun someone and then have
them still able to perform an action they logically wouldn't be able to
take while stunned.
This is especially egregious in the case of Time Stop (the only way to
stun a lot of the mobs effected by this) but that's a rare pick on a
rare antagonist and would also rarely be used on these mobs, so a bit of
an edge case.

## Changelog

:cl:
fix: Many spell-like abilities which could be stunned, paralysed, or
frozen in time now cannot be.
/:cl:
  • Loading branch information
Jacquerel authored Feb 20, 2023
1 parent 09fda8f commit 296ca23
Show file tree
Hide file tree
Showing 26 changed files with 36 additions and 27 deletions.
2 changes: 2 additions & 0 deletions code/__DEFINES/actions.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#define AB_CHECK_LYING (1<<2)
///Action button checks if user is conscious
#define AB_CHECK_CONSCIOUS (1<<3)
///Action button checks if user is incapacitated
#define AB_CHECK_INCAPACITATED (1<<4)

DEFINE_BITFIELD(check_flags, list(
"CHECK IF HANDS BLOCKED" = AB_CHECK_HANDS_BLOCKED,
Expand Down
7 changes: 7 additions & 0 deletions code/datums/actions/action.dm
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@
// so that our button icon updates when relevant
if(check_flags & AB_CHECK_CONSCIOUS)
RegisterSignal(owner, COMSIG_MOB_STATCHANGE, PROC_REF(update_status_on_signal))
if(check_flags & AB_CHECK_INCAPACITATED)
RegisterSignal(owner, SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED), PROC_REF(update_status_on_signal))
if(check_flags & AB_CHECK_IMMOBILE)
RegisterSignal(owner, SIGNAL_ADDTRAIT(TRAIT_IMMOBILIZED), PROC_REF(update_status_on_signal))
if(check_flags & AB_CHECK_HANDS_BLOCKED)
Expand Down Expand Up @@ -127,6 +129,7 @@
COMSIG_MOB_STATCHANGE,
SIGNAL_ADDTRAIT(TRAIT_HANDS_BLOCKED),
SIGNAL_ADDTRAIT(TRAIT_IMMOBILIZED),
SIGNAL_ADDTRAIT(TRAIT_INCAPACITATED),
))

if(target == owner)
Expand Down Expand Up @@ -157,6 +160,10 @@
if (feedback)
owner.balloon_alert(owner, "can't move!")
return FALSE
if((check_flags & AB_CHECK_INCAPACITATED) && HAS_TRAIT(owner, TRAIT_INCAPACITATED))
if (feedback)
owner.balloon_alert(owner, "incapacitated!")
return FALSE
if((check_flags & AB_CHECK_LYING) && isliving(owner))
var/mob/living/action_owner = owner
if(action_owner.body_position == LYING_DOWN)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/actions/item_action.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//Presets for item actions
/datum/action/item_action
name = "Item Action"
check_flags = AB_CHECK_HANDS_BLOCKED|AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_INCAPACITATED|AB_CHECK_HANDS_BLOCKED|AB_CHECK_CONSCIOUS
button_icon_state = null

/datum/action/item_action/New(Target)
Expand Down
2 changes: 1 addition & 1 deletion code/datums/actions/items/stealth_box.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
/datum/action/item_action/agent_box
name = "Deploy Box"
desc = "Find inner peace, here, in the box."
check_flags = AB_CHECK_HANDS_BLOCKED|AB_CHECK_IMMOBILE|AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_INCAPACITATED|AB_CHECK_HANDS_BLOCKED|AB_CHECK_IMMOBILE|AB_CHECK_CONSCIOUS
background_icon_state = "bg_agent"
overlay_icon_state = "bg_agent_border"
button_icon = 'icons/mob/actions/actions_items.dmi'
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/cult/cult_comms.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
overlay_icon_state = "bg_demon_border"

buttontooltipstyle = "cult"
check_flags = AB_CHECK_HANDS_BLOCKED|AB_CHECK_IMMOBILE|AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_INCAPACITATED|AB_CHECK_HANDS_BLOCKED|AB_CHECK_IMMOBILE|AB_CHECK_CONSCIOUS
ranged_mousepointer = 'icons/effects/mouse_pointers/cult_target.dmi'

/datum/action/innate/cult/IsAvailable(feedback = FALSE)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
overlay_icon_state = "bg_heretic_border"
button_icon_state = "shield"
ranged_mousepointer = 'icons/effects/mouse_pointers/throw_target.dmi'
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_INCAPACITATED|AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED

school = SCHOOL_FORBIDDEN
cooldown_time = 5 SECONDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
name = "Grand Ritual"
desc = "Provides direction to a nexus of power, then draws a rune in that location for completing the Grand Ritual. \
The ritual process will take longer each time it is completed."
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED | AB_CHECK_HANDS_BLOCKED
background_icon_state = "bg_spell"
button_icon = 'icons/mob/actions/actions_cult.dmi'
button_icon_state = "draw"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/clothing/chameleon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@

/datum/action/item_action/chameleon/change
name = "Chameleon Change"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_INCAPACITATED|AB_CHECK_HANDS_BLOCKED
var/list/chameleon_blacklist = list() //This is a typecache
var/list/chameleon_list = list()
var/chameleon_type = null
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
button_icon_state = "lay_eggs"
background_icon_state = "bg_alien"
overlay_icon_state = "bg_alien_border"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED
///How long it takes for a broodmother to lay eggs.
var/egg_lay_time = 12 SECONDS
///The type of egg we create
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
button_icon_state = "lay_web"
background_icon_state = "bg_alien"
overlay_icon_state = "bg_alien_border"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED
cooldown_time = 0 SECONDS
/// How long it takes to lay a web
var/webbing_time = 4 SECONDS
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
overlay_icon_state = "bg_alien_border"
button_icon = 'icons/mob/actions/actions_animal.dmi'
button_icon_state = "wrap_0"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED
click_to_activate = TRUE
ranged_mousepointer = 'icons/effects/mouse_pointers/wrap_target.dmi'
/// The time it takes to wrap something.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/alien/adult/alien_powers.dm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Doesn't work on other aliens/AI.*/
overlay_icon_state = "bg_alien_border"
button_icon = 'icons/mob/actions/actions_xeno.dmi'
button_icon_state = "spell_default"
check_flags = AB_CHECK_IMMOBILE|AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_IMMOBILE | AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED
melee_cooldown_time = 0 SECONDS

/// How much plasma this action uses.
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/hostile/goose.dm
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@

/datum/action/cooldown/vomit
name = "Vomit"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED
button_icon_state = "vomit"
button_icon = 'icons/mob/simple/animal.dmi'
cooldown_time = 250
Expand Down
6 changes: 3 additions & 3 deletions code/modules/mob/living/simple_animal/hostile/ooze.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
overlay_icon_state = "bg_hive_border"
button_icon = 'icons/mob/actions/actions_slime.dmi'
button_icon_state = "consume"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_IMMOBILE
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_IMMOBILE|AB_CHECK_INCAPACITATED
///The mob thats being consumed by this creature
var/mob/living/vored_mob

Expand Down Expand Up @@ -303,7 +303,7 @@
overlay_icon_state = "bg_hive_border"
button_icon = 'icons/mob/actions/actions_slime.dmi'
button_icon_state = "globules"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_INCAPACITATED
cooldown_time = 5 SECONDS
click_to_activate = TRUE

Expand Down Expand Up @@ -419,7 +419,7 @@
overlay_icon_state = "bg_hive_border"
button_icon = 'icons/mob/actions/actions_slime.dmi'
button_icon_state = "gel_cocoon"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_IMMOBILE
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_IMMOBILE|AB_CHECK_INCAPACITATED
cooldown_time = 10 SECONDS

/datum/action/cooldown/gel_cocoon/Activate(atom/target)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/living/simple_animal/hostile/regalrat.dm
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@
/datum/action/cooldown/domain
name = "Rat King's Domain"
desc = "Corrupts this area to be more suitable for your rat army."
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_INCAPACITATED
cooldown_time = 6 SECONDS
melee_cooldown_time = 0 SECONDS
button_icon = 'icons/mob/actions/actions_animal.dmi'
Expand Down Expand Up @@ -237,7 +237,7 @@
/datum/action/cooldown/riot
name = "Raise Army"
desc = "Raise an army out of the hordes of mice and pests crawling around the maintenance shafts."
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_INCAPACITATED
button_icon = 'icons/mob/actions/actions_animal.dmi'
button_icon_state = "riot"
background_icon_state = "bg_clock"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@
overlay_icon_state = "bg_changeling_border"
button_icon = 'icons/mob/actions/actions_animal.dmi'
button_icon_state = "regurgitate"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_INCAPACITATED
melee_cooldown_time = 0 SECONDS
click_to_activate = TRUE

Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/simple_animal/hostile/vatbeast.dm
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
overlay_icon_state = "bg_revenant_border"
button_icon = 'icons/mob/actions/actions_animal.dmi'
button_icon_state = "tentacle_slap"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_INCAPACITATED
cooldown_time = 12 SECONDS
melee_cooldown_time = 0 SECONDS
click_to_activate = TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/power/singularity/emitter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
auto.Grant(buckled_mob, src)

/datum/action/innate/proto_emitter
check_flags = AB_CHECK_HANDS_BLOCKED | AB_CHECK_IMMOBILE | AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_HANDS_BLOCKED | AB_CHECK_IMMOBILE | AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED
///Stores the emitter the user is currently buckled on
var/obj/machinery/power/emitter/prototype/proto_emitter
///Stores the mob instance that is buckled to the emitter
Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/spell.dm
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
button_icon_state = "spell_default"
overlay_icon_state = "bg_spell_border"
active_overlay_icon_state = "bg_spell_border_active_red"
check_flags = AB_CHECK_CONSCIOUS
check_flags = AB_CHECK_CONSCIOUS | AB_CHECK_INCAPACITATED
panel = "Spells"
melee_cooldown_time = 0 SECONDS

Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/spell_types/conjure/invisible_chair.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
overlay_icon_state = "bg_mime_border"
button_icon = 'icons/mob/actions/actions_mime.dmi'
button_icon_state = "invisible_chair"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED|AB_CHECK_INCAPACITATED
panel = "Mime"
sound = null

Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/spell_types/conjure/invisible_wall.dm
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
overlay_icon_state = "bg_mime_border"
button_icon = 'icons/mob/actions/actions_mime.dmi'
button_icon_state = "invisible_wall"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED|AB_CHECK_INCAPACITATED
panel = "Mime"
sound = null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
overlay_icon_state = "bg_mime_border"
button_icon = 'icons/mob/actions/actions_mime.dmi'
button_icon_state = "invisible_box"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED|AB_CHECK_INCAPACITATED
panel = "Mime"
sound = null

Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/spell_types/pointed/finger_guns.dm
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
overlay_icon_state = "bg_mime_border"
button_icon = 'icons/mob/actions/actions_mime.dmi'
button_icon_state = "finger_guns0"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED|AB_CHECK_INCAPACITATED
panel = "Mime"
sound = null

Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/spell_types/self/forcewall.dm
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
overlay_icon_state = "bg_mime_border"
button_icon = 'icons/mob/actions/actions_mime.dmi'
button_icon_state = "invisible_blockade"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED|AB_CHECK_INCAPACITATED
panel = "Mime"
sound = null

Expand Down
2 changes: 1 addition & 1 deletion code/modules/spells/spell_types/touch/_touch.dm
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
* (generally) inadvisable unless you know what you're doing
*/
/datum/action/cooldown/spell/touch
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_HANDS_BLOCKED|AB_CHECK_INCAPACITATED
sound = 'sound/items/welder.ogg'
invocation = "High Five!"
invocation_type = INVOCATION_SHOUT
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
///hud action for starting and stopping flight
/datum/action/innate/flight
name = "Toggle Flight"
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_IMMOBILE
check_flags = AB_CHECK_CONSCIOUS|AB_CHECK_IMMOBILE|AB_CHECK_INCAPACITATED
button_icon = 'icons/mob/actions/actions_items.dmi'
button_icon_state = "flight"

Expand Down

0 comments on commit 296ca23

Please sign in to comment.