From f1a22b367d494f065acce5501307843bf554be50 Mon Sep 17 00:00:00 2001 From: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Date: Thu, 16 May 2024 21:46:03 +0000 Subject: [PATCH] Changes how lube crawling works and fixes a bug with snails (#83238) ## About The Pull Request This partially reverts https://github.com/tgstation/tgstation/pull/76336 - Just for slimepeople since it's the only one that felt important to be tied to species. Snails are currently pretty fast when they are crawling around, but on top of that they are also able to get their legs replaced to become 3x faster than normal humans while resting. It's a little silly, and I thought I should fix it. I also changed the element itself to be easier for admins to edit, giving them control over time and wet flags, and made it work a little better. Instead of being hardcoded to listen to carbons and to register every step to check if they are resting, calling add/remove movespeed modifier every single time they move, we are told whether they have to be resting, and update when they get up/lie down. This has an extra bonus that admins can control whether or not they want to make simple/basic animals have to rest to lube things (like cats). ## Why It's Good For The Game Closes https://github.com/tgstation/tgstation/issues/78417 Makes the lube spitting element that (primarily) snails use into a more general thing that can be used by admins or other contributors that want to make things wet thing as they walk for some time. Also no insanely fast snails anymore. ## Changelog :cl: fix: Snails no longer move at normal speed while resting. fix: Snails can no longer get insane speed from getting their legs replaced. fix: Humans don't become immensely slow when getting a Snail leg. admin: lube walking element is now much easier to mess with to fit however you want to use it for. /:cl: --- code/datums/elements/lube_walking.dm | 61 +++++++++++++++++++ code/datums/elements/snail_crawl.dm | 35 ----------- .../modules/deathmatch/deathmatch_modifier.dm | 2 +- code/modules/mob/living/basic/clown/clown.dm | 2 +- .../carbon/human/species_types/snail.dm | 9 ++- code/modules/movespeed/modifiers/innate.dm | 4 ++ .../bodyparts/species_parts/misc_bodyparts.dm | 2 - tgstation.dme | 2 +- 8 files changed, 75 insertions(+), 42 deletions(-) create mode 100644 code/datums/elements/lube_walking.dm delete mode 100644 code/datums/elements/snail_crawl.dm diff --git a/code/datums/elements/lube_walking.dm b/code/datums/elements/lube_walking.dm new file mode 100644 index 00000000000..8ab6b2b7602 --- /dev/null +++ b/code/datums/elements/lube_walking.dm @@ -0,0 +1,61 @@ +/** + * # lube_walking + * + * Makes a mob cause a turf to get wet as they walk, requires lying down. + * Has configurable args for wet flags, time, and resting requirements. + */ +/datum/element/lube_walking + element_flags = ELEMENT_BESPOKE | ELEMENT_DETACH_ON_HOST_DESTROY + argument_hash_start_idx = 2 + ///The wet flags that we make each tile we are affecting slippery with. + var/wet_flags + ///The minimum amount of time any tile we wet will be wet for. + var/min_time_wet_for + ///Boolean on whether the mob has to be 'resting' for the element to properly affect tiles. + ///Used to exclude simple animals that you don't expect to lie down. + var/require_resting + +/datum/element/lube_walking/Attach(atom/movable/target, wet_flags = TURF_WET_LUBE, min_time_wet_for = 2 SECONDS, require_resting = FALSE) + . = ..() + if(!ismovable(target)) + return ELEMENT_INCOMPATIBLE + src.wet_flags = wet_flags + src.min_time_wet_for = min_time_wet_for + src.require_resting = require_resting + + if(require_resting) + if(!isliving(target)) + stack_trace("lube_walking Element was added onto [target] with require_resting set on, which only works on living mobs.") + return ELEMENT_INCOMPATIBLE + var/mob/living/living_target = target + RegisterSignal(living_target, COMSIG_LIVING_RESTING, PROC_REF(on_resting_changed)) + if(living_target.resting) //theyre resting as the element was added, so let them start lubricating. + on_resting_changed(living_target, new_resting = TRUE) + else + RegisterSignal(target, COMSIG_MOVABLE_MOVED, PROC_REF(lubricate)) + +/datum/element/lube_walking/Detach(mob/living/carbon/target) + . = ..() + UnregisterSignal(target, list(COMSIG_LIVING_RESTING, COMSIG_MOVABLE_MOVED)) + if(istype(target)) + target.remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) + +///Called when a living mob changes their resting state with require_resting on, giving them their movement speed and ability. +/datum/element/lube_walking/proc/on_resting_changed(mob/snail, new_resting, silent, instant) + SIGNAL_HANDLER + + if(new_resting && lubricate(snail)) + snail.add_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) + RegisterSignal(snail, COMSIG_MOVABLE_MOVED, PROC_REF(lubricate)) + else + snail.remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) + UnregisterSignal(snail, COMSIG_MOVABLE_MOVED) + +/datum/element/lube_walking/proc/lubricate(atom/movable/snail) + SIGNAL_HANDLER + + var/turf/open/turf_standing_on = get_turf(snail) + if(!istype(turf_standing_on)) + return FALSE + turf_standing_on.MakeSlippery(wet_flags, min_wet_time = min_time_wet_for) + return TRUE diff --git a/code/datums/elements/snail_crawl.dm b/code/datums/elements/snail_crawl.dm deleted file mode 100644 index d0fac629e49..00000000000 --- a/code/datums/elements/snail_crawl.dm +++ /dev/null @@ -1,35 +0,0 @@ -/datum/element/snailcrawl - element_flags = ELEMENT_DETACH_ON_HOST_DESTROY - -/datum/element/snailcrawl/Attach(datum/target) - . = ..() - if(!ismovable(target)) - return ELEMENT_INCOMPATIBLE - var/P - if(iscarbon(target)) - P = PROC_REF(snail_crawl) - else - P = PROC_REF(lubricate) - RegisterSignal(target, COMSIG_MOVABLE_MOVED, P) - -/datum/element/snailcrawl/Detach(mob/living/carbon/target) - . = ..() - UnregisterSignal(target, COMSIG_MOVABLE_MOVED) - if(istype(target)) - target.remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) - -/datum/element/snailcrawl/proc/snail_crawl(mob/living/carbon/snail) - SIGNAL_HANDLER - - if(snail.resting && !snail.buckled && lubricate(snail)) - snail.add_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) - else - snail.remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) - -/datum/element/snailcrawl/proc/lubricate(atom/movable/snail) - SIGNAL_HANDLER - - var/turf/open/OT = get_turf(snail) - if(istype(OT)) - OT.MakeSlippery(TURF_WET_LUBE, 20) - return TRUE diff --git a/code/modules/deathmatch/deathmatch_modifier.dm b/code/modules/deathmatch/deathmatch_modifier.dm index 5037b3c3ae3..127700b734f 100644 --- a/code/modules/deathmatch/deathmatch_modifier.dm +++ b/code/modules/deathmatch/deathmatch_modifier.dm @@ -149,7 +149,7 @@ blacklisted_modifiers = list(/datum/deathmatch_modifier/no_gravity) /datum/deathmatch_modifier/snail_crawl/apply(mob/living/carbon/player, datum/deathmatch_lobby/lobby) - player.AddElement(/datum/element/snailcrawl) + player.AddElement(/datum/element/lube_walking, require_resting = TRUE) /datum/deathmatch_modifier/blinking_and_breathing name = "Manual Blinking/Breathing" diff --git a/code/modules/mob/living/basic/clown/clown.dm b/code/modules/mob/living/basic/clown/clown.dm index a1a7014b263..9e8f6950525 100644 --- a/code/modules/mob/living/basic/clown/clown.dm +++ b/code/modules/mob/living/basic/clown/clown.dm @@ -88,7 +88,7 @@ /mob/living/basic/clown/lube/Initialize(mapload) . = ..() - AddElement(/datum/element/snailcrawl) + AddElement(/datum/element/lube_walking) /mob/living/basic/clown/honkling name = "Honkling" diff --git a/code/modules/mob/living/carbon/human/species_types/snail.dm b/code/modules/mob/living/carbon/human/species_types/snail.dm index 93d88a3a777..053953e2a83 100644 --- a/code/modules/mob/living/carbon/human/species_types/snail.dm +++ b/code/modules/mob/living/carbon/human/species_types/snail.dm @@ -26,6 +26,9 @@ BODY_ZONE_R_LEG = /obj/item/bodypart/leg/right/snail ) + ///Multiplier for the speed we give them. Positive numbers make it move slower, negative numbers make it move faster. + var/snail_speed_mod = 6 + /datum/species/snail/prepare_human_for_preview(mob/living/carbon/human/human) human.dna.features["mcolor"] = COLOR_BEIGE human.update_body(is_creating = TRUE) @@ -88,11 +91,13 @@ if(!istype(bag, /obj/item/storage/backpack/snail)) if(new_snailperson.dropItemToGround(bag)) //returns TRUE even if its null new_snailperson.equip_to_slot_or_del(new /obj/item/storage/backpack/snail(new_snailperson), ITEM_SLOT_BACK) - new_snailperson.AddElement(/datum/element/snailcrawl) + new_snailperson.AddElement(/datum/element/lube_walking, require_resting = TRUE) + new_snailperson.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/snail, multiplicative_slowdown = snail_speed_mod) /datum/species/snail/on_species_loss(mob/living/carbon/former_snailperson, datum/species/new_species, pref_load) . = ..() - former_snailperson.RemoveElement(/datum/element/snailcrawl) + former_snailperson.remove_movespeed_modifier(/datum/movespeed_modifier/snail) + former_snailperson.RemoveElement(/datum/element/lube_walking, require_resting = TRUE) var/obj/item/storage/backpack/bag = former_snailperson.get_item_by_slot(ITEM_SLOT_BACK) if(istype(bag, /obj/item/storage/backpack/snail)) bag.emptyStorage() diff --git a/code/modules/movespeed/modifiers/innate.dm b/code/modules/movespeed/modifiers/innate.dm index 2a55b9db4d7..94a3f7a2e79 100644 --- a/code/modules/movespeed/modifiers/innate.dm +++ b/code/modules/movespeed/modifiers/innate.dm @@ -6,6 +6,10 @@ multiplicative_slowdown = 2 flags = IGNORE_NOSLOW +/datum/movespeed_modifier/snail + movetypes = ~FLYING + variable = TRUE + /datum/movespeed_modifier/bodypart movetypes = ~FLYING variable = TRUE diff --git a/code/modules/surgery/bodyparts/species_parts/misc_bodyparts.dm b/code/modules/surgery/bodyparts/species_parts/misc_bodyparts.dm index dc18395e37d..2730bc362c7 100644 --- a/code/modules/surgery/bodyparts/species_parts/misc_bodyparts.dm +++ b/code/modules/surgery/bodyparts/species_parts/misc_bodyparts.dm @@ -36,7 +36,6 @@ unarmed_damage_low = 1 unarmed_damage_high = 2 //snails are soft and squishy burn_modifier = 2 - speed_modifier = 3 //disgustingly slow biological_state = (BIO_FLESH|BIO_BLOODED) /obj/item/bodypart/leg/right/snail @@ -44,7 +43,6 @@ unarmed_damage_low = 1 unarmed_damage_high = 2 //snails are soft and squishy burn_modifier = 2 - speed_modifier = 3 //disgustingly slow biological_state = (BIO_FLESH|BIO_BLOODED) ///ABDUCTOR diff --git a/tgstation.dme b/tgstation.dme index e16b9441919..2914a33ea38 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -1452,6 +1452,7 @@ #include "code\datums\elements\light_eater.dm" #include "code\datums\elements\living_limb_initialiser.dm" #include "code\datums\elements\loomable.dm" +#include "code\datums\elements\lube_walking.dm" #include "code\datums\elements\mirage_border.dm" #include "code\datums\elements\mob_access.dm" #include "code\datums\elements\mob_grabber.dm" @@ -1486,7 +1487,6 @@ #include "code\datums\elements\simple_flying.dm" #include "code\datums\elements\skill_reward.dm" #include "code\datums\elements\skittish.dm" -#include "code\datums\elements\snail_crawl.dm" #include "code\datums\elements\soft_landing.dm" #include "code\datums\elements\spooky.dm" #include "code\datums\elements\squish.dm"