Refactor incapacitated optional arguments (#63771)

This commit is contained in:
Tim
2022-01-31 02:04:07 -06:00
committed by GitHub
parent 4256fc29c1
commit be355edab5
18 changed files with 62 additions and 25 deletions
@@ -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