diff --git a/code/__defines/mobs.dm b/code/__defines/mobs.dm index eeb718185a6..d7959254d44 100644 --- a/code/__defines/mobs.dm +++ b/code/__defines/mobs.dm @@ -480,3 +480,19 @@ #define HEIGHT_CLASS_TALL 190 #define HEIGHT_CLASS_HUGE 240 #define HEIGHT_CLASS_GIGANTIC 300 + +#define MOB_IS_INCAPACITATED(incapacitation_flags)\ +(\ + ((incapacitation_flags & INCAPACITATION_STUNNED) && stunned) ||\ + ((incapacitation_flags & INCAPACITATION_FORCELYING) && (weakened || resting)) ||\ + ((incapacitation_flags & INCAPACITATION_KNOCKOUT) && (stat || paralysis || sleeping || (status_flags & FAKEDEATH))) ||\ + ((incapacitation_flags & INCAPACITATION_RESTRAINED) && restrained())\ + ? TRUE :\ + (\ + ((incapacitation_flags & (INCAPACITATION_BUCKLED_PARTIALLY|INCAPACITATION_BUCKLED_FULLY))) ?\ + (\ + (buckled_to() >= PARTIALLY_BUCKLED && (incapacitation_flags & INCAPACITATION_BUCKLED_PARTIALLY)) || (buckled_to() == FULLY_BUCKLED && (incapacitation_flags & INCAPACITATION_BUCKLED_FULLY)) ?\ + TRUE : FALSE\ + ) : FALSE\ + )\ +) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index b84b1b7fb51..c47b69769e4 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1,3 +1,7 @@ +#define UNBUCKLED 0 +#define PARTIALLY_BUCKLED 1 +#define FULLY_BUCKLED 2 + /mob/Destroy()//This makes sure that mobs with clients/keys are not just deleted from the game. mob_list -= src dead_mob_list -= src @@ -282,9 +286,6 @@ /mob/proc/Life() return -#define UNBUCKLED 0 -#define PARTIALLY_BUCKLED 1 -#define FULLY_BUCKLED 2 /mob/proc/buckled_to() // Preliminary work for a future buckle rewrite, // where one might be fully restrained (like an elecrical chair), or merely secured (shuttle chair, keeping you safe but not otherwise restrained from acting) @@ -293,11 +294,12 @@ return restrained() ? FULLY_BUCKLED : PARTIALLY_BUCKLED /mob/proc/is_physically_disabled() - return incapacitated(INCAPACITATION_DISABLED) + return MOB_IS_INCAPACITATED(INCAPACITATION_DISABLED) /mob/proc/cannot_stand() - return incapacitated(INCAPACITATION_KNOCKDOWN) + return MOB_IS_INCAPACITATED(INCAPACITATION_KNOCKDOWN) +// Inside this file, you should use MOB_IS_INCAPACITATED for performance reasons /mob/proc/incapacitated(var/incapacitation_flags = INCAPACITATION_DEFAULT) if ((incapacitation_flags & INCAPACITATION_STUNNED) && stunned) @@ -321,10 +323,6 @@ return 0 -#undef UNBUCKLED -#undef PARTIALLY_BUCKLED -#undef FULLY_BUCKLED - /mob/proc/restrained() return @@ -865,8 +863,8 @@ canmove = 0 lying = 0 else - lying = incapacitated(INCAPACITATION_KNOCKDOWN) - canmove = !incapacitated(INCAPACITATION_KNOCKOUT) + lying = MOB_IS_INCAPACITATED(INCAPACITATION_KNOCKDOWN) + canmove = !MOB_IS_INCAPACITATED(INCAPACITATION_KNOCKOUT) if(lying) density = 0 @@ -1433,3 +1431,7 @@ /mob/proc/get_actions_for_statpanel() var/list/data = list() return data + +#undef UNBUCKLED +#undef PARTIALLY_BUCKLED +#undef FULLY_BUCKLED diff --git a/html/changelogs/FluffyGhost-shave_process_mobs.yml b/html/changelogs/FluffyGhost-shave_process_mobs.yml new file mode 100644 index 00000000000..4d7be3634ba --- /dev/null +++ b/html/changelogs/FluffyGhost-shave_process_mobs.yml @@ -0,0 +1,41 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: FluffyGhost + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - rscadd: "Added a mob incapactitation check define, to be used inside mobs for often called procs (update_canmove, cannot_stand for now, which are called very often, 510k times in 10 minutes)."