From fa73fe010079466564f6c55418fb7ad79af7af50 Mon Sep 17 00:00:00 2001 From: Matt Atlas Date: Tue, 14 Jun 2022 00:51:18 +0200 Subject: [PATCH] Crawling now works with WASD. (#14277) --- code/game/turfs/turf.dm | 54 ------------------- .../mob/living/carbon/human/human_movement.dm | 3 ++ code/modules/mob/mob.dm | 4 +- code/modules/mob/mob_movement.dm | 32 +++++++++-- html/changelogs/mattatlas-crawling.yml | 41 ++++++++++++++ 5 files changed, 76 insertions(+), 58 deletions(-) create mode 100644 html/changelogs/mattatlas-crawling.yml diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 1d7570dada0..5bf7ef1eff3 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -478,60 +478,6 @@ var/const/enterloopsanity = 100 L.Add(t) return L -// CRAWLING + MOVING STUFF -/turf/MouseDrop_T(atom/movable/O as mob|obj, mob/user as mob) - var/turf/T = get_turf(user) - var/area/A = T.loc - if((istype(A) && !(A.has_gravity())) || (istype(T,/turf/space))) - return - if(istype(O, /obj/screen)) - return - if(user.restrained() || user.stat || user.incapacitated(INCAPACITATION_KNOCKOUT) || !user.lying) - return - if((!(istype(O, /atom/movable)) || O.anchored || !Adjacent(user) || !Adjacent(O) || !user.Adjacent(O))) - return - if(!isturf(O.loc) || !isturf(user.loc)) - return - if(isanimal(user) && O != user) - return - - var/tally = 0 - - if(ishuman(user)) - var/mob/living/carbon/human/H = user - - var/obj/item/organ/external/rhand = H.organs_by_name[BP_R_HAND] - tally += limbCheck(rhand) - - var/obj/item/organ/external/lhand = H.organs_by_name[BP_L_HAND] - tally += limbCheck(lhand) - - var/obj/item/organ/external/rfoot = H.organs_by_name[BP_R_FOOT] - tally += limbCheck(rfoot) - - var/obj/item/organ/external/lfoot = H.organs_by_name[BP_L_FOOT] - tally += limbCheck(lfoot) - - if(tally >= 120) - to_chat(user, SPAN_NOTICE("You're too injured to do this!")) - return - - var/finaltime = 25 + (5 * (user.weakened * 1.5)) - if(tally >= 45) // If you have this much missing, you'll crawl slower. - finaltime += tally - - if(do_after(user, finaltime) && !user.stat) - step_towards(O, src) - -// Checks status of limb, returns an amount to -/turf/proc/limbCheck(var/obj/item/organ/external/limb) - if(!limb) // Limb is null, thus missing. Add 3 seconds. - return 30 - else if(!limb.is_usable() || limb.is_broken()) // You can't use the limb, but it's still there to manoevre yourself - return 15 - else - return 0 - /turf/proc/is_wall() return FALSE diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index 12e7aba99e2..9496fdebe0a 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -4,6 +4,9 @@ if(species.slowdown) tally = species.slowdown + if(lying) //Crawling, it's slower + tally += (8 + ((weakened * 3) + (confused * 2))) + tally += get_pulling_movement_delay() if (istype(loc, /turf/space) || isopenturf(loc)) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index d3795f9594d..c57699ac1f6 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -222,6 +222,8 @@ return 0 /mob/proc/movement_delay() + if(lying) //Crawling, it's slower + . += (8 + ((weakened * 3) + (confused * 2))) . = get_pulling_movement_delay() /mob/proc/get_pulling_movement_delay() @@ -943,7 +945,7 @@ lying = 0 else lying = incapacitated(INCAPACITATION_KNOCKDOWN) - canmove = !incapacitated(INCAPACITATION_DISABLED) + canmove = !incapacitated(INCAPACITATION_KNOCKOUT) if(lying) density = 0 diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index a35267211bf..45e75d74686 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -245,9 +245,6 @@ if(!mob.canmove || mob.paralysis) return - //if(istype(mob.loc, /turf/space) || (mob.flags & NOGRAV)) - // if(!mob.Process_Spacemove(0)) return 0 - if(!mob.lastarea) mob.lastarea = get_area(mob.loc) @@ -323,6 +320,12 @@ move_delay += tally + if(mob_is_human && mob.lying) + var/mob/living/carbon/human/H = mob + var/crawl_tally = H.get_crawl_tally() + if(crawl_tally >= 120) + return FALSE + var/tickcomp = 0 //moved this out here so we can use it for vehicles if(config.Tickcomp) // move_delay -= 1.3 //~added to the tickcomp calculation below @@ -375,6 +378,29 @@ var/atom/O = mob.loc return O.relaymove(mob, direct) +/mob/living/carbon/human/proc/get_crawl_tally() + var/obj/item/organ/external/rhand = organs_by_name[BP_R_HAND] + . += limb_check(rhand) + + var/obj/item/organ/external/lhand = organs_by_name[BP_L_HAND] + . += limb_check(lhand) + + var/obj/item/organ/external/rfoot = organs_by_name[BP_R_FOOT] + . += limb_check(rfoot) + + var/obj/item/organ/external/lfoot = organs_by_name[BP_L_FOOT] + . += limb_check(lfoot) + +// Checks status of limb, returns an amount to +/mob/living/carbon/human/proc/limb_check(var/obj/item/organ/external/limb) + if(!limb) // Limb is null, thus missing. + return 30 + else if(!limb.is_usable() || limb.is_broken()) // You can't use the limb, but it's still there to maneuvre yourself + return 15 + else + return 0 + + /mob/proc/SelfMove(turf/n, direct) return Move(n, direct) diff --git a/html/changelogs/mattatlas-crawling.yml b/html/changelogs/mattatlas-crawling.yml new file mode 100644 index 00000000000..6fbbf6234d5 --- /dev/null +++ b/html/changelogs/mattatlas-crawling.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: MattAtlas + +# 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: "You can now crawl while lying down simply by using WASD. You no longer crawl by clickdropping your sprite on turfs."