Refactor incapacitated optional arguments (#63771)

This commit is contained in:
Tim
2022-01-31 00:04:07 -08:00
committed by GitHub
parent 4256fc29c1
commit be355edab5
18 changed files with 62 additions and 25 deletions
+8
View File
@@ -23,6 +23,14 @@
///hands reach out from the sides of the screen, doing damage and stunning if they hit the target
#define CURSE_GRASPING (1<<3)
//Incapacitated status effect flags
/// If the incapacitated status effect will ignore a mob in restraints (handcuffs)
#define IGNORE_RESTRAINTS (1<<0)
/// If the incapacitated status effect will ignore a mob in stasis (stasis beds)
#define IGNORE_STASIS (1<<1)
/// If the incapacitated status effect will ignore a mob being agressively grabbed
#define IGNORE_GRAB (1<<2)
// Grouped effect sources, see also code/__DEFINES/traits.dm
#define STASIS_MACHINE_EFFECT "stasis_machine"
+1 -1
View File
@@ -105,7 +105,7 @@
CtrlClickOn(A)
return
if(incapacitated(ignore_restraints = TRUE, ignore_stasis = TRUE))
if(incapacitated(IGNORE_RESTRAINTS|IGNORE_STASIS))
return
face_atom(A)
+1 -1
View File
@@ -132,7 +132,7 @@
if(world.time <= usr.next_move)
return TRUE
if(usr.incapacitated(ignore_stasis = TRUE))
if(usr.incapacitated(IGNORE_STASIS))
return TRUE
if(ismecha(usr.loc)) // stops inventory actions in a mech
return TRUE
+9 -2
View File
@@ -76,8 +76,15 @@
if((interaction_flags_atom & INTERACT_ATOM_REQUIRES_DEXTERITY) && !ISADVANCEDTOOLUSER(user))
to_chat(user, span_warning("You don't have the dexterity to do this!"))
return FALSE
if(!(interaction_flags_atom & INTERACT_ATOM_IGNORE_INCAPACITATED) && user.incapacitated((interaction_flags_atom & INTERACT_ATOM_IGNORE_RESTRAINED), !(interaction_flags_atom & INTERACT_ATOM_CHECK_GRAB)))
return FALSE
if(!(interaction_flags_atom & INTERACT_ATOM_IGNORE_INCAPACITATED))
var/ignore_flags = NONE
if(interaction_flags_atom & INTERACT_ATOM_IGNORE_RESTRAINED)
ignore_flags |= IGNORE_RESTRAINTS
if(!(interaction_flags_atom & INTERACT_ATOM_CHECK_GRAB))
ignore_flags |= IGNORE_GRAB
if(user.incapacitated(ignore_flags))
return FALSE
return TRUE
/atom/ui_status(mob/user)
+2 -2
View File
@@ -54,10 +54,10 @@
if(living_parent.body_position != STANDING_UP) // if we move while on the ground, the rider falls off
. = FALSE
// for piggybacks and (redundant?) borg riding, check if the rider is stunned/restrained
else if((ride_check_flags & RIDER_NEEDS_ARMS) && (HAS_TRAIT(rider, TRAIT_RESTRAINED) || rider.incapacitated(TRUE, TRUE)))
else if((ride_check_flags & RIDER_NEEDS_ARMS) && (HAS_TRAIT(rider, TRAIT_RESTRAINED) || rider.incapacitated(IGNORE_RESTRAINTS|IGNORE_GRAB)))
. = FALSE
// for fireman carries, check if the ridden is stunned/restrained
else if((ride_check_flags & CARRIER_NEEDS_ARM) && (HAS_TRAIT(living_parent, TRAIT_RESTRAINED) || living_parent.incapacitated(TRUE, TRUE)))
else if((ride_check_flags & CARRIER_NEEDS_ARM) && (HAS_TRAIT(living_parent, TRAIT_RESTRAINED) || living_parent.incapacitated(IGNORE_RESTRAINTS|IGNORE_GRAB)))
. = FALSE
if(. || !consequences)
+1 -1
View File
@@ -100,7 +100,7 @@
/datum/martial_art/the_sleeping_carp/on_projectile_hit(mob/living/A, obj/projectile/P, def_zone)
. = ..()
if(A.incapacitated(FALSE, TRUE)) //NO STUN
if(A.incapacitated(IGNORE_GRAB)) //NO STUN
return BULLET_ACT_HIT
if(!(A.mobility_flags & MOBILITY_USE)) //NO UNABLE TO USE
return BULLET_ACT_HIT
+1 -1
View File
@@ -636,7 +636,7 @@ GLOBAL_LIST_INIT(transit_tube_recipes, list(
/obj/item/pipe_dispenser/proc/mouse_wheeled(mob/source, atom/A, delta_x, delta_y, params)
SIGNAL_HANDLER
if(source.incapacitated(ignore_restraints = TRUE, ignore_stasis = TRUE))
if(source.incapacitated(IGNORE_RESTRAINTS|IGNORE_STASIS))
return
if(delta_y < 0)
@@ -53,7 +53,7 @@
egged = world.time + SNAKE_SPAM_TICKS
for(var/mob/living/L in alerted)
if(!L.stat)
if(!L.incapacitated(ignore_restraints = 1))
if(!L.incapacitated(IGNORE_RESTRAINTS))
L.face_atom(src)
L.do_alert_animation()
playsound(loc, 'sound/machines/chime.ogg', 50, FALSE, -5)
@@ -536,7 +536,7 @@ Congratulations! You are now trained for invasive xenobiology research!"}
/obj/item/melee/baton/abductor/proc/SleepAttack(mob/living/L,mob/living/user)
playsound(src, on_stun_sound, 50, TRUE, -1)
if(L.incapacitated(TRUE, TRUE))
if(L.incapacitated(IGNORE_RESTRAINTS|IGNORE_GRAB))
if(L.anti_magic_check(FALSE, FALSE, TRUE))
to_chat(user, span_warning("The specimen's tinfoil protection is interfering with the sleep inducement!"))
L.visible_message(span_danger("[user] tried to induced sleep in [L] with [src], but [L.p_their()] tinfoil protection [L.p_them()]!"), \
+1 -1
View File
@@ -35,7 +35,7 @@
if(!istype(user, /mob/living/simple_animal/mouse) || !isliving(loc) || !prob(mouse_control_probability))
return
var/mob/living/L = loc
if(L.incapacitated(TRUE)) //just in case
if(L.incapacitated(IGNORE_RESTRAINTS)) //just in case
return
step_towards(L, get_step(L, direction))
@@ -897,7 +897,7 @@
return ishuman(target) && target.body_position == LYING_DOWN
/mob/living/carbon/human/proc/fireman_carry(mob/living/carbon/target)
if(!can_be_firemanned(target) || incapacitated(FALSE, TRUE))
if(!can_be_firemanned(target) || incapacitated(IGNORE_GRAB))
to_chat(src, span_warning("You can't fireman carry [target] while [target.p_they()] [target.p_are()] standing!"))
return
@@ -917,7 +917,7 @@
return
//Second check to make sure they're still valid to be carried
if(!can_be_firemanned(target) || incapacitated(FALSE, TRUE) || target.buckled)
if(!can_be_firemanned(target) || incapacitated(IGNORE_GRAB) || target.buckled)
visible_message(span_warning("[src] fails to fireman carry [target]!"))
return
@@ -933,7 +933,7 @@
visible_message(span_warning("[target] fails to climb onto [src]!"))
return
if(target.incapacitated(FALSE, TRUE) || incapacitated(FALSE, TRUE))
if(target.incapacitated(IGNORE_GRAB) || incapacitated(IGNORE_GRAB))
target.visible_message(span_warning("[target] can't hang onto [src]!"))
return
@@ -143,7 +143,7 @@
/mob/living/carbon/human/proc/check_block()
if(mind)
if(mind.martial_art && prob(mind.martial_art.block_chance) && mind.martial_art.can_use(src) && throw_mode && !incapacitated(FALSE, TRUE))
if(mind.martial_art && prob(mind.martial_art.block_chance) && mind.martial_art.can_use(src) && throw_mode && !incapacitated(IGNORE_GRAB))
return TRUE
return FALSE
+26 -4
View File
@@ -437,10 +437,32 @@
to_chat(src, span_notice("You have given up life and succumbed to death."))
death()
/mob/living/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE, ignore_stasis = FALSE)
if(HAS_TRAIT(src, TRAIT_INCAPACITATED) || (!ignore_restraints && (HAS_TRAIT(src, TRAIT_RESTRAINED) || (!ignore_grab && pulledby && pulledby.grab_state >= GRAB_AGGRESSIVE))) || (!ignore_stasis && IS_IN_STASIS(src)))
/**
* Checks if a mob is incapacitated
*
* Normally being restrained, agressively grabbed, or in stasis counts as incapacitated
* unless there is a flag being used to check if it's ignored
*
* args:
* * flags (optional) bitflags that determine if special situations are exempt from being considered incapacitated
*
* bitflags: (see code/__DEFINES/status_effects.dm)
* * IGNORE_RESTRAINTS - mob in a restraint (handcuffs) is not considered incapacitated
* * IGNORE_STASIS - mob in stasis (stasis bed, etc.) is not considered incapacitated
* * IGNORE_GRAB - mob that is agressively grabbed is not considered incapacitated
**/
/mob/living/incapacitated(flags)
if(HAS_TRAIT(src, TRAIT_INCAPACITATED))
return TRUE
if(HAS_TRAIT(src, TRAIT_RESTRAINED) && !(flags & IGNORE_RESTRAINTS))
return TRUE
if(IS_IN_STASIS(src) && !(flags & IGNORE_STASIS))
return TRUE
if((pulledby && pulledby.grab_state >= GRAB_AGGRESSIVE) && !(flags & IGNORE_GRAB))
return TRUE
return FALSE
/mob/living/canUseStorage()
if (usable_hands <= 0)
return FALSE
@@ -919,7 +941,7 @@
..(pressure_difference, direction, pressure_resistance_prob_delta)
/mob/living/can_resist()
return !((next_move > world.time) || incapacitated(ignore_restraints = TRUE, ignore_stasis = TRUE))
return !((next_move > world.time) || incapacitated(IGNORE_RESTRAINTS|IGNORE_STASIS))
/mob/living/verb/resist()
set name = "Resist"
@@ -1710,7 +1732,7 @@
///Checks if the user is incapacitated or on cooldown.
/mob/living/proc/can_look_up()
return !(incapacitated(ignore_restraints = TRUE))
return !(incapacitated(IGNORE_RESTRAINTS))
/**
* look_up Changes the perspective of the mob to any openspace turf above the mob
+1 -1
View File
@@ -301,7 +301,7 @@
///Is the mob incapacitated
/mob/proc/incapacitated(ignore_restraints = FALSE, ignore_grab = FALSE, ignore_stasis = FALSE)
/mob/proc/incapacitated(flags)
return
/**
+1 -1
View File
@@ -177,7 +177,7 @@
return FALSE
if(mob.pulledby == mob.pulling && mob.pulledby.grab_state == GRAB_PASSIVE) //Don't autoresist passive grabs if we're grabbing them too.
return FALSE
if(mob.incapacitated(ignore_restraints = TRUE))
if(mob.incapacitated(IGNORE_RESTRAINTS))
COOLDOWN_START(src, move_delay, 1 SECONDS)
return TRUE
else if(HAS_TRAIT(mob, TRAIT_RESTRAINED))
+1 -1
View File
@@ -178,7 +178,7 @@
/// Called when an activated module without a device is used
/obj/item/mod/module/proc/on_select_use(atom/target)
if(mod.wearer.incapacitated(ignore_grab = TRUE))
if(mod.wearer.incapacitated(IGNORE_GRAB))
return FALSE
mod.wearer.face_atom(target)
if(!on_use())
+1 -1
View File
@@ -73,7 +73,7 @@
clear_grab()
/obj/item/mod/module/anomaly_locked/kinesis/process(delta_time)
if(!mod.wearer.client || mod.wearer.incapacitated(ignore_grab = TRUE))
if(!mod.wearer.client || mod.wearer.incapacitated(IGNORE_GRAB))
clear_grab()
return
if(!range_check(grabbed_atom))
+2 -2
View File
@@ -137,7 +137,7 @@
set category = "Object"
set src in usr
if(!usr.can_read(src) || usr.incapacitated(TRUE, TRUE) || (isobserver(usr) && !isAdminGhostAI(usr)))
if(!usr.can_read(src) || usr.incapacitated(IGNORE_RESTRAINTS|IGNORE_GRAB) || (isobserver(usr) && !isAdminGhostAI(usr)))
return
if(ishuman(usr))
var/mob/living/carbon/human/H = usr
@@ -180,7 +180,7 @@
return UI_CLOSE
if(!in_range(user, src) && !isobserver(user))
return UI_CLOSE
if(user.incapacitated(TRUE, TRUE) || (isobserver(user) && !isAdminGhostAI(user)))
if(user.incapacitated(IGNORE_RESTRAINTS|IGNORE_GRAB) || (isobserver(user) && !isAdminGhostAI(user)))
return UI_UPDATE
// Even harder to read if your blind...braile? humm
// .. or if you cannot read