From 7e09ac0036ddd651c88f6aa1c14c7bc9e958e35b Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Thu, 9 Jan 2020 18:55:16 -0800 Subject: [PATCH 01/34] datums and shit --- code/__DEFINES/movespeed_modification.dm | 10 --- code/datums/components/mood.dm | 25 ++++++-- code/datums/components/shrink.dm | 10 ++- code/modules/mob/mob_movespeed.dm | 78 +++++++++++++++++------- 4 files changed, 82 insertions(+), 41 deletions(-) diff --git a/code/__DEFINES/movespeed_modification.dm b/code/__DEFINES/movespeed_modification.dm index ae2a753f1c6..eb1d4eeba03 100644 --- a/code/__DEFINES/movespeed_modification.dm +++ b/code/__DEFINES/movespeed_modification.dm @@ -1,12 +1,3 @@ -#define MOVESPEED_DATA_INDEX_PRIORITY 1 -#define MOVESPEED_DATA_INDEX_FLAGS 2 -#define MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN 3 -#define MOVESPEED_DATA_INDEX_MOVETYPE 4 -#define MOVESPEED_DATA_INDEX_BL_MOVETYPE 5 -#define MOVESPEED_DATA_INDEX_CONFLICT 6 - -#define MOVESPEED_DATA_INDEX_MAX 6 - //flags #define IGNORE_NOSLOW (1 << 0) @@ -78,4 +69,3 @@ #define MOVESPEED_ID_DAMAGE_SLOWDOWN "DAMAGE" #define MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING "FLYING" #define MOVESPEED_ID_LENTURI "LENTURI_SLOWDOWN" - diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index 13d3cdcd589..3cfc773cfa7 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -208,30 +208,43 @@ switch(sanity) if(SANITY_INSANE to SANITY_CRAZY) setInsanityEffect(MAJOR_INSANITY_PEN) - master.add_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE, 100, override=TRUE, multiplicative_slowdown=1, movetypes=(~FLYING)) + master._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/sanity/insane, override = TRUE) sanity_level = 6 if(SANITY_CRAZY to SANITY_UNSTABLE) setInsanityEffect(MINOR_INSANITY_PEN) - master.add_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE, 100, override=TRUE, multiplicative_slowdown=0.5, movetypes=(~FLYING)) + master._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/sanity/crazy, override = TRUE) sanity_level = 5 if(SANITY_UNSTABLE to SANITY_DISTURBED) setInsanityEffect(0) - master.add_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE, 100, override=TRUE, multiplicative_slowdown=0.25, movetypes=(~FLYING)) + master._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/sanity/disturbed, override = TRUE) sanity_level = 4 if(SANITY_DISTURBED to SANITY_NEUTRAL) setInsanityEffect(0) - master.remove_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE) + master._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SANITY) sanity_level = 3 if(SANITY_NEUTRAL+1 to SANITY_GREAT+1) //shitty hack but +1 to prevent it from responding to super small differences setInsanityEffect(0) - master.remove_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE) + master._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SANITY) sanity_level = 2 if(SANITY_GREAT+1 to INFINITY) setInsanityEffect(0) - master.remove_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE) + master._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SANITY) sanity_level = 1 update_mood_icon() +/datum/movespeed_modifier/sanity + id = MOVESPEED_ID_SANITY + movetypes = (~FLYING) + +/datum/movespeed_modifier/sanity/insane + multiplicative_slowdown = 1 + +/datum/movespeed_modifier/sanity/crazy + multiplicative_slowdown = 0.5 + +/datum/movespeed_modifier/sanity/disturbed + multiplicative_slowdown = 0.25 + /datum/component/mood/proc/setInsanityEffect(newval) if(newval == insanity_effect) return diff --git a/code/datums/components/shrink.dm b/code/datums/components/shrink.dm index 48ab864c79d..7d5492e4bd2 100644 --- a/code/datums/components/shrink.dm +++ b/code/datums/components/shrink.dm @@ -14,7 +14,7 @@ parent_atom.opacity = 0 if(isliving(parent_atom)) var/mob/living/L = parent_atom - L.add_movespeed_modifier(MOVESPEED_ID_SHRINK_RAY, update=TRUE, priority=100, multiplicative_slowdown=4, movetypes=GROUND) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modification/shrink_ray) if(iscarbon(L)) var/mob/living/carbon/C = L C.unequip_everything() @@ -27,7 +27,6 @@ "Everything grows bigger!") QDEL_IN(src, shrink_time) - /datum/component/shrink/Destroy() var/atom/parent_atom = parent parent_atom.transform = parent_atom.transform.Scale(2,2) @@ -35,8 +34,13 @@ parent_atom.opacity = oldopac if(isliving(parent_atom)) var/mob/living/L = parent_atom - L.remove_movespeed_modifier(MOVESPEED_ID_SHRINK_RAY) + L._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SHRINK_RAY) if(ishuman(L)) var/mob/living/carbon/human/H = L H.physiology.damage_resistance += 100 ..() + +/datum/movespeed_modification/shrink_ray + id = MOVESPEED_ID_SHRINK_RAY + movetypes = GROUNd + multiplicative_slowdown = 4 diff --git a/code/modules/mob/mob_movespeed.dm b/code/modules/mob/mob_movespeed.dm index 60af7098853..277844e2b15 100644 --- a/code/modules/mob/mob_movespeed.dm +++ b/code/modules/mob/mob_movespeed.dm @@ -34,25 +34,40 @@ Key procs //ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE! +GLOBAL_LIST_EMPTY(movespeed_modification_cache) +/proc/get_cached_movespeed_modification(modtype) + if(!ispath(modtype, /datum/movespeed_modification)) + CRASH("[modtype] is not a movespeed modification type.") + var/datum/movespeed_modification/M = GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) + return M + ///Add a move speed modifier to a mob -/mob/proc/add_movespeed_modifier(id, update=TRUE, priority=0, flags=NONE, override=FALSE, multiplicative_slowdown=0, movetypes=ALL, blacklisted_movetypes=NONE, conflict=FALSE) - var/list/temp = list(priority, flags, multiplicative_slowdown, movetypes, blacklisted_movetypes, conflict) //build the modification list - var/resort = TRUE - if(LAZYACCESS(movespeed_modification, id)) - var/list/existing_data = movespeed_modification[id] - if(movespeed_modifier_identical_check(existing_data, temp)) +/mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modification/type_or_datum, update = TRUE, override = FALSE) + if(ispath(type_or_datum)) + type_or_datum = get_cached_movespeed_modification(type_or_datum) + if(!istype(type_or_datum)) + CRASH("Invalid modification datum") + var/oldpriority + var/datum/movespeed_modification/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) + if(existing) + if(existing == type_or_datum) //same thing don't need to touch + return TRUE + if(!override) //not overriding, do not overwrite same ID. return FALSE - if(!override) - return FALSE - if(priority == existing_data[MOVESPEED_DATA_INDEX_PRIORITY]) - resort = FALSE // We don't need to re-sort if we're replacing something already there and it's the same priority - LAZYSET(movespeed_modification, id, temp) + oldpriority = existing.priority + remove_movespeed_modifier(existing, FLASE) + LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) + var/resort = type_or_datum.priority == oldpriority if(update) update_movespeed(resort) return TRUE ///Remove a move speed modifier from a mob -/mob/proc/remove_movespeed_modifier(id, update = TRUE) +/mob/proc/_REFACTORING_remove_movespeed_modifier(datum/movespeed_modification/type_id_datum, update = TRUE) + if(ispath(type_id_datum)) + type_id_datum = get_cached_movespeed_modification(type_id_datum) + if(istype(type_id_datum)) + type_id_datum = type_id_datum.id if(!LAZYACCESS(movespeed_modification, id)) return FALSE LAZYREMOVE(movespeed_modification, id) @@ -73,7 +88,11 @@ Key procs add_movespeed_modifier(MOVESPEED_ID_ADMIN_VAREDIT, TRUE, 100, override = TRUE, multiplicative_slowdown = diff) ///Is there a movespeed modifier for this mob -/mob/proc/has_movespeed_modifier(id) +/mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) + if(ispath(datum_type_id)) + datum_type_id = get_cached_movespeed_modification(datum_type_id) + if(istype(datum_type_id)) + datum_type_id = datum_type_id.id return LAZYACCESS(movespeed_modification, id) ///Set or update the global movespeed config on a mob @@ -115,15 +134,6 @@ Key procs /mob/proc/get_movespeed_modifiers() return movespeed_modification -///Check if a movespeed modifier is identical to another -/mob/proc/movespeed_modifier_identical_check(list/mod1, list/mod2) - if(!islist(mod1) || !islist(mod2) || mod1.len < MOVESPEED_DATA_INDEX_MAX || mod2.len < MOVESPEED_DATA_INDEX_MAX) - return FALSE - for(var/i in 1 to MOVESPEED_DATA_INDEX_MAX) - if(mod1[i] != mod2[i]) - return FALSE - return TRUE - ///Calculate the total slowdown of all movespeed modifiers /mob/proc/total_multiplicative_slowdown() . = 0 @@ -164,3 +174,27 @@ Key procs assembled[our_id] = our_data movespeed_modification = assembled UNSETEMPTY(movespeed_modification) + +/** + * Movespeed modification datums. + */ + +/datum/movespeed_modification + /// Unique ID. You can never have different modifications with the same ID + var/id = "ERROR" + + /// Higher ones override lower priorities. This is NOT used for ID, ID must be unique, if it isn't unique the newer one overwrites automatically if overriding. + var/priority = 0 + var/flags = NONE + + /// Multiplicative slowdown + var/multiplicative_slowdown = 0 + + /// Movetypes this applies to + var/movetypes = ALL + + /// Movetypes this never applies to + var/blacklisted_movetypes = NONE + + /// Other modification datums this conflicts with. + var/conflicts_with From bb95b2a8704a07a6e467451467e5964faac50f1d Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Thu, 9 Jan 2020 19:13:30 -0800 Subject: [PATCH 02/34] changes --- code/datums/components/shrink.dm | 4 ++-- code/datums/elements/snail_crawl.dm | 9 +++++++-- code/game/objects/effects/mines.dm | 9 +++++++-- .../changeling/powers/strained_muscles.dm | 9 +++++++-- code/modules/mob/living/carbon/carbon.dm | 8 ++++++-- code/modules/mob/mob_movespeed.dm | 14 ++++++++------ .../xenobiology/crossbreeding/_status_effects.dm | 16 ++++++++++++---- 7 files changed, 49 insertions(+), 20 deletions(-) diff --git a/code/datums/components/shrink.dm b/code/datums/components/shrink.dm index 7d5492e4bd2..4c6d5883dde 100644 --- a/code/datums/components/shrink.dm +++ b/code/datums/components/shrink.dm @@ -14,7 +14,7 @@ parent_atom.opacity = 0 if(isliving(parent_atom)) var/mob/living/L = parent_atom - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modification/shrink_ray) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/shrink_ray) if(iscarbon(L)) var/mob/living/carbon/C = L C.unequip_everything() @@ -40,7 +40,7 @@ H.physiology.damage_resistance += 100 ..() -/datum/movespeed_modification/shrink_ray +/datum/movespeed_modifier/shrink_ray id = MOVESPEED_ID_SHRINK_RAY movetypes = GROUNd multiplicative_slowdown = 4 diff --git a/code/datums/elements/snail_crawl.dm b/code/datums/elements/snail_crawl.dm index a3ce8213387..2b24fc359fa 100644 --- a/code/datums/elements/snail_crawl.dm +++ b/code/datums/elements/snail_crawl.dm @@ -20,12 +20,17 @@ /datum/element/snailcrawl/proc/snail_crawl(mob/living/carbon/snail) if(snail.resting && !snail.buckled && lubricate(snail)) - snail.add_movespeed_modifier(MOVESPEED_ID_SNAIL_CRAWL, update=TRUE, priority=100, multiplicative_slowdown=-7, movetypes=GROUND) + snail._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) else - snail.remove_movespeed_modifier(MOVESPEED_ID_SNAIL_CRAWL) + snail._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) /datum/element/snailcrawl/proc/lubricate(atom/movable/snail) var/turf/open/OT = get_turf(snail) if(istype(OT)) OT.MakeSlippery(TURF_WET_LUBE, 20) return TRUE + +/datum/movespeed_modifier/snail_crawl + id = MOVESPEED_ID_SNAIL_CRAWL + multiplicative_slowdown = -7 + movetypes = GROUnD diff --git a/code/game/objects/effects/mines.dm b/code/game/objects/effects/mines.dm index 32998fbfd9e..4b98939b353 100644 --- a/code/game/objects/effects/mines.dm +++ b/code/game/objects/effects/mines.dm @@ -172,7 +172,12 @@ if(!victim.client || !istype(victim)) return to_chat(victim, "You feel fast!") - victim.add_movespeed_modifier(MOVESPEED_ID_YELLOW_ORB, update=TRUE, priority=100, multiplicative_slowdown=-2, blacklisted_movetypes=(FLYING|FLOATING)) + victim._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) sleep(duration) - victim.remove_movespeed_modifier(MOVESPEED_ID_YELLOW_ORB) + victim._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) to_chat(victim, "You slow down.") + +/datum/movespeed_modifier/yellow_orb + id = MOVESPEED_ID_YELLOW_ORB + multiplicative_slowdown = -2 + blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/antagonists/changeling/powers/strained_muscles.dm b/code/modules/antagonists/changeling/powers/strained_muscles.dm index 4432aa21fa0..fef709ee293 100644 --- a/code/modules/antagonists/changeling/powers/strained_muscles.dm +++ b/code/modules/antagonists/changeling/powers/strained_muscles.dm @@ -31,12 +31,12 @@ /datum/action/changeling/strained_muscles/proc/muscle_loop(mob/living/carbon/user) while(active) - user.add_movespeed_modifier(MOVESPEED_ID_CHANGELING_MUSCLES, update=TRUE, priority=100, multiplicative_slowdown=-1, blacklisted_movetypes=(FLYING|FLOATING)) + user._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) if(user.stat != CONSCIOUS || user.staminaloss >= 90) active = !active to_chat(user, "Our muscles relax without the energy to strengthen them.") user.Paralyze(40) - user.remove_movespeed_modifier(MOVESPEED_ID_CHANGELING_MUSCLES) + user._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) break stacks++ @@ -51,3 +51,8 @@ while(!active && stacks) //Damage stacks decrease fairly rapidly while not in sanic mode stacks-- sleep(20) + +/datum/movespeed_modifier/strained_muscles + id = MOVESPEED_ID_CHANGELING_MUSCLES + multiplicative_slowdown = -1 + blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index c3e13671110..d6de331c403 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -497,9 +497,13 @@ /mob/living/carbon/update_mobility() . = ..() if(!(mobility_flags & MOBILITY_STAND)) - add_movespeed_modifier(MOVESPEED_ID_CARBON_CRAWLING, TRUE, multiplicative_slowdown = CRAWLING_ADD_SLOWDOWN) + _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) else - remove_movespeed_modifier(MOVESPEED_ID_CARBON_CRAWLING, TRUE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) + +/datum/movespeed_modifier/carbon_crawling + id = MOVESPEED_ID_CARBON_CRAWLING + multiplicative_slowdown = CRAWLING_ADD_SLOWDOWN //Updates the mob's health from bodyparts and mob damage variables /mob/living/carbon/updatehealth() diff --git a/code/modules/mob/mob_movespeed.dm b/code/modules/mob/mob_movespeed.dm index 277844e2b15..bfb7de05676 100644 --- a/code/modules/mob/mob_movespeed.dm +++ b/code/modules/mob/mob_movespeed.dm @@ -35,10 +35,12 @@ Key procs //ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE! GLOBAL_LIST_EMPTY(movespeed_modification_cache) + +/// Grabs a STATIC MODIFIER datum from cache. YOU MUST NEVER EDIT THESE DATUMS, OR IT WILL AFFECT ANYTHING ELSE USING IT TOO! /proc/get_cached_movespeed_modification(modtype) - if(!ispath(modtype, /datum/movespeed_modification)) + if(!ispath(modtype, /datum/movespeed_modifier)) CRASH("[modtype] is not a movespeed modification type.") - var/datum/movespeed_modification/M = GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) + var/datum/movespeed_modifier/M = GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) return M ///Add a move speed modifier to a mob @@ -48,7 +50,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(!istype(type_or_datum)) CRASH("Invalid modification datum") var/oldpriority - var/datum/movespeed_modification/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) + var/datum/movespeed_modifier/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) if(existing) if(existing == type_or_datum) //same thing don't need to touch return TRUE @@ -68,7 +70,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) type_id_datum = get_cached_movespeed_modification(type_id_datum) if(istype(type_id_datum)) type_id_datum = type_id_datum.id - if(!LAZYACCESS(movespeed_modification, id)) + if(!LAZYACCESS(movespeed_modification, type_id_datum)) return FALSE LAZYREMOVE(movespeed_modification, id) UNSETEMPTY(movespeed_modification) @@ -93,7 +95,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) datum_type_id = get_cached_movespeed_modification(datum_type_id) if(istype(datum_type_id)) datum_type_id = datum_type_id.id - return LAZYACCESS(movespeed_modification, id) + return LAZYACCESS(movespeed_modification, datum_type_id) ///Set or update the global movespeed config on a mob /mob/proc/update_config_movespeed() @@ -179,7 +181,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) * Movespeed modification datums. */ -/datum/movespeed_modification +/datum/movespeed_modifier /// Unique ID. You can never have different modifications with the same ID var/id = "ERROR" diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm index be3276bbeb2..2fdd2e77da0 100644 --- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm +++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm @@ -185,7 +185,7 @@ alert_type = /obj/screen/alert/status_effect/bloodchill /datum/status_effect/bloodchill/on_apply() - owner.add_movespeed_modifier("bloodchilled", TRUE, 100, NONE, override = TRUE, multiplicative_slowdown = 3) + owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/bloodchill) return ..() /datum/status_effect/bloodchill/tick() @@ -193,7 +193,11 @@ owner.adjustFireLoss(2) /datum/status_effect/bloodchill/on_remove() - owner.remove_movespeed_modifier("bloodchilled") + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bloodchill) + +/datum/movespeed_modifier/bloodchill + id = "bloodchilled" + multiplicative_slowdown = 3 /datum/status_effect/bonechill id = "bonechill" @@ -201,7 +205,7 @@ alert_type = /obj/screen/alert/status_effect/bonechill /datum/status_effect/bonechill/on_apply() - owner.add_movespeed_modifier("bonechilled", TRUE, 100, NONE, override = TRUE, multiplicative_slowdown = 3) + owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/bonechill) return ..() /datum/status_effect/bonechill/tick() @@ -211,7 +215,11 @@ owner.adjust_bodytemperature(-10) /datum/status_effect/bonechill/on_remove() - owner.remove_movespeed_modifier("bonechilled") + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bonechill) + +/datum/movespeed_modifier/bonechill + id = "bonechilled" + multiplicative_slowdown = 3 /obj/screen/alert/status_effect/bonechill name = "Bonechilled" From 46451e23ea965b7908ea39f019c4dad2cb9ff592 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Fri, 10 Jan 2020 07:27:44 -0800 Subject: [PATCH 03/34] move stuff --- code/datums/components/shrink.dm | 5 - code/datums/elements/snail_crawl.dm | 5 - .../changeling/powers/strained_muscles.dm | 5 - .../_movespeed_modifier.dm} | 404 +++++++++--------- .../modules/movespeed/modifiers/components.dm | 9 + code/modules/movespeed/modifiers/innate.dm | 4 + code/modules/movespeed/modifiers/reagent.dm | 9 + .../movespeed/modifiers/status_effects.dm | 7 + .../chemistry/reagents/medicine_reagents.dm | 8 +- .../crossbreeding/_status_effects.dm | 9 - tgstation.dme | 6 +- 11 files changed, 240 insertions(+), 231 deletions(-) rename code/modules/{mob/mob_movespeed.dm => movespeed/_movespeed_modifier.dm} (96%) create mode 100644 code/modules/movespeed/modifiers/components.dm create mode 100644 code/modules/movespeed/modifiers/innate.dm create mode 100644 code/modules/movespeed/modifiers/reagent.dm create mode 100644 code/modules/movespeed/modifiers/status_effects.dm diff --git a/code/datums/components/shrink.dm b/code/datums/components/shrink.dm index 4c6d5883dde..155c27a9035 100644 --- a/code/datums/components/shrink.dm +++ b/code/datums/components/shrink.dm @@ -39,8 +39,3 @@ var/mob/living/carbon/human/H = L H.physiology.damage_resistance += 100 ..() - -/datum/movespeed_modifier/shrink_ray - id = MOVESPEED_ID_SHRINK_RAY - movetypes = GROUNd - multiplicative_slowdown = 4 diff --git a/code/datums/elements/snail_crawl.dm b/code/datums/elements/snail_crawl.dm index 2b24fc359fa..4f30524254e 100644 --- a/code/datums/elements/snail_crawl.dm +++ b/code/datums/elements/snail_crawl.dm @@ -29,8 +29,3 @@ if(istype(OT)) OT.MakeSlippery(TURF_WET_LUBE, 20) return TRUE - -/datum/movespeed_modifier/snail_crawl - id = MOVESPEED_ID_SNAIL_CRAWL - multiplicative_slowdown = -7 - movetypes = GROUnD diff --git a/code/modules/antagonists/changeling/powers/strained_muscles.dm b/code/modules/antagonists/changeling/powers/strained_muscles.dm index fef709ee293..51f1d65d383 100644 --- a/code/modules/antagonists/changeling/powers/strained_muscles.dm +++ b/code/modules/antagonists/changeling/powers/strained_muscles.dm @@ -51,8 +51,3 @@ while(!active && stacks) //Damage stacks decrease fairly rapidly while not in sanic mode stacks-- sleep(20) - -/datum/movespeed_modifier/strained_muscles - id = MOVESPEED_ID_CHANGELING_MUSCLES - multiplicative_slowdown = -1 - blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/mob/mob_movespeed.dm b/code/modules/movespeed/_movespeed_modifier.dm similarity index 96% rename from code/modules/mob/mob_movespeed.dm rename to code/modules/movespeed/_movespeed_modifier.dm index bfb7de05676..30871b1e01f 100644 --- a/code/modules/mob/mob_movespeed.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -1,202 +1,202 @@ -/*! How move speed for mobs works - -Move speed is now calculated by using a list of movespeed modifiers, which is a list itself (to avoid datum overhead) - -This gives us the ability to have multiple sources of movespeed, reliabily keep them applied and remove them when they should be - -THey can have unique sources and a bunch of extra fancy flags that control behaviour - -Previously trying to update move speed was a shot in the dark that usually meant mobs got stuck going faster or slower - -This list takes the following format - -```Current movespeed modification list format: - list( - id = list( - priority, - flags, - legacy slowdown/speedup amount, - movetype_flags - ) - ) -``` - -WHen update movespeed is called, the list of items is iterated, according to flags priority and a bunch of conditions -this spits out a final calculated value which is used as a modifer to last_move + modifier for calculating when a mob -can next move - -Key procs -* [add_movespeed_modifier](mob.html#proc/add_movespeed_modifier) -* [remove_movespeed_modifier](mob.html#proc/remove_movespeed_modifier) -* [has_movespeed_modifier](mob.html#proc/has_movespeed_modifier) -* [update_movespeed](mob.html#proc/update_movespeed) -*/ - -//ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE! - -GLOBAL_LIST_EMPTY(movespeed_modification_cache) - -/// Grabs a STATIC MODIFIER datum from cache. YOU MUST NEVER EDIT THESE DATUMS, OR IT WILL AFFECT ANYTHING ELSE USING IT TOO! -/proc/get_cached_movespeed_modification(modtype) - if(!ispath(modtype, /datum/movespeed_modifier)) - CRASH("[modtype] is not a movespeed modification type.") - var/datum/movespeed_modifier/M = GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) - return M - -///Add a move speed modifier to a mob -/mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modification/type_or_datum, update = TRUE, override = FALSE) - if(ispath(type_or_datum)) - type_or_datum = get_cached_movespeed_modification(type_or_datum) - if(!istype(type_or_datum)) - CRASH("Invalid modification datum") - var/oldpriority - var/datum/movespeed_modifier/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) - if(existing) - if(existing == type_or_datum) //same thing don't need to touch - return TRUE - if(!override) //not overriding, do not overwrite same ID. - return FALSE - oldpriority = existing.priority - remove_movespeed_modifier(existing, FLASE) - LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) - var/resort = type_or_datum.priority == oldpriority - if(update) - update_movespeed(resort) - return TRUE - -///Remove a move speed modifier from a mob -/mob/proc/_REFACTORING_remove_movespeed_modifier(datum/movespeed_modification/type_id_datum, update = TRUE) - if(ispath(type_id_datum)) - type_id_datum = get_cached_movespeed_modification(type_id_datum) - if(istype(type_id_datum)) - type_id_datum = type_id_datum.id - if(!LAZYACCESS(movespeed_modification, type_id_datum)) - return FALSE - LAZYREMOVE(movespeed_modification, id) - UNSETEMPTY(movespeed_modification) - if(update) - update_movespeed(FALSE) - return TRUE - -///Handles the special case of editing the movement var -/mob/vv_edit_var(var_name, var_value) - var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown)) - var/diff - if(slowdown_edit && isnum(cached_multiplicative_slowdown) && isnum(var_value)) - remove_movespeed_modifier(MOVESPEED_ID_ADMIN_VAREDIT) - diff = var_value - cached_multiplicative_slowdown - . = ..() - if(. && slowdown_edit && isnum(diff)) - add_movespeed_modifier(MOVESPEED_ID_ADMIN_VAREDIT, TRUE, 100, override = TRUE, multiplicative_slowdown = diff) - -///Is there a movespeed modifier for this mob -/mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) - if(ispath(datum_type_id)) - datum_type_id = get_cached_movespeed_modification(datum_type_id) - if(istype(datum_type_id)) - datum_type_id = datum_type_id.id - return LAZYACCESS(movespeed_modification, datum_type_id) - -///Set or update the global movespeed config on a mob -/mob/proc/update_config_movespeed() - add_movespeed_modifier(MOVESPEED_ID_CONFIG_SPEEDMOD, FALSE, 100, override = TRUE, multiplicative_slowdown = get_config_multiplicative_speed()) - -///Get the global config movespeed of a mob by type -/mob/proc/get_config_multiplicative_speed() - if(!islist(GLOB.mob_config_movespeed_type_lookup) || !GLOB.mob_config_movespeed_type_lookup[type]) - return 0 - else - return GLOB.mob_config_movespeed_type_lookup[type] - -///Go through the list of movespeed modifiers and calculate a final movespeed -/mob/proc/update_movespeed(resort = TRUE) - if(resort) - sort_movespeed_modlist() - . = 0 - var/list/conflict_tracker = list() - for(var/id in get_movespeed_modifiers()) - var/list/data = movespeed_modification[id] - if(!(data[MOVESPEED_DATA_INDEX_MOVETYPE] & movement_type)) // We don't affect any of these move types, skip - continue - if(data[MOVESPEED_DATA_INDEX_BL_MOVETYPE] & movement_type) // There's a movetype here that disables this modifier, skip - continue - var/conflict = data[MOVESPEED_DATA_INDEX_CONFLICT] - var/amt = data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN] - if(conflict) - // Conflicting modifiers prioritize the larger slowdown or the larger speedup - // We purposefuly don't handle mixing speedups and slowdowns on the same id - if(abs(conflict_tracker[conflict]) < abs(amt)) - conflict_tracker[conflict] = amt - else - continue - . += amt - cached_multiplicative_slowdown = . - -///Get the move speed modifiers list of the mob -/mob/proc/get_movespeed_modifiers() - return movespeed_modification - -///Calculate the total slowdown of all movespeed modifiers -/mob/proc/total_multiplicative_slowdown() - . = 0 - for(var/id in get_movespeed_modifiers()) - var/list/data = movespeed_modification[id] - . += data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN] - -///Checks if a move speed modifier is valid and not missing any data -/proc/movespeed_data_null_check(list/data) //Determines if a data list is not meaningful and should be discarded. - . = TRUE - if(data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN]) - . = FALSE - -/** - * Sort the list of move speed modifiers - * - * Verifies it too. Sorts highest priority (first applied) to lowest priority (last applied) - */ -/mob/proc/sort_movespeed_modlist() - if(!movespeed_modification) - return - var/list/assembled = list() - for(var/our_id in movespeed_modification) - var/list/our_data = movespeed_modification[our_id] - if(!islist(our_data) || (our_data.len < MOVESPEED_DATA_INDEX_PRIORITY) || movespeed_data_null_check(our_data)) - movespeed_modification -= our_id - continue - var/our_priority = our_data[MOVESPEED_DATA_INDEX_PRIORITY] - var/resolved = FALSE - for(var/their_id in assembled) - var/list/their_data = assembled[their_id] - if(their_data[MOVESPEED_DATA_INDEX_PRIORITY] < our_priority) - assembled.Insert(assembled.Find(their_id), our_id) - assembled[our_id] = our_data - resolved = TRUE - break - if(!resolved) - assembled[our_id] = our_data - movespeed_modification = assembled - UNSETEMPTY(movespeed_modification) - -/** - * Movespeed modification datums. - */ - -/datum/movespeed_modifier - /// Unique ID. You can never have different modifications with the same ID - var/id = "ERROR" - - /// Higher ones override lower priorities. This is NOT used for ID, ID must be unique, if it isn't unique the newer one overwrites automatically if overriding. - var/priority = 0 - var/flags = NONE - - /// Multiplicative slowdown - var/multiplicative_slowdown = 0 - - /// Movetypes this applies to - var/movetypes = ALL - - /// Movetypes this never applies to - var/blacklisted_movetypes = NONE - - /// Other modification datums this conflicts with. - var/conflicts_with +/** + * Movespeed modification datums. + */ + +/datum/movespeed_modifier + /// Unique ID. You can never have different modifications with the same ID + var/id = "ERROR" + + /// Higher ones override lower priorities. This is NOT used for ID, ID must be unique, if it isn't unique the newer one overwrites automatically if overriding. + var/priority = 0 + var/flags = NONE + + /// Multiplicative slowdown + var/multiplicative_slowdown = 0 + + /// Movetypes this applies to + var/movetypes = ALL + + /// Movetypes this never applies to + var/blacklisted_movetypes = NONE + + /// Other modification datums this conflicts with. + var/conflicts_with + +/*! How move speed for mobs works + +Move speed is now calculated by using a list of movespeed modifiers, which is a list itself (to avoid datum overhead) + +This gives us the ability to have multiple sources of movespeed, reliabily keep them applied and remove them when they should be + +THey can have unique sources and a bunch of extra fancy flags that control behaviour + +Previously trying to update move speed was a shot in the dark that usually meant mobs got stuck going faster or slower + +This list takes the following format + +```Current movespeed modification list format: + list( + id = list( + priority, + flags, + legacy slowdown/speedup amount, + movetype_flags + ) + ) +``` + +WHen update movespeed is called, the list of items is iterated, according to flags priority and a bunch of conditions +this spits out a final calculated value which is used as a modifer to last_move + modifier for calculating when a mob +can next move + +Key procs +* [add_movespeed_modifier](mob.html#proc/add_movespeed_modifier) +* [remove_movespeed_modifier](mob.html#proc/remove_movespeed_modifier) +* [has_movespeed_modifier](mob.html#proc/has_movespeed_modifier) +* [update_movespeed](mob.html#proc/update_movespeed) +*/ + +//ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE! + +GLOBAL_LIST_EMPTY(movespeed_modification_cache) + +/// Grabs a STATIC MODIFIER datum from cache. YOU MUST NEVER EDIT THESE DATUMS, OR IT WILL AFFECT ANYTHING ELSE USING IT TOO! +/proc/get_cached_movespeed_modification(modtype) + if(!ispath(modtype, /datum/movespeed_modifier)) + CRASH("[modtype] is not a movespeed modification type.") + var/datum/movespeed_modifier/M = GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) + return M + +///Add a move speed modifier to a mob +/mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE, override = FALSE) + if(ispath(type_or_datum)) + type_or_datum = get_cached_movespeed_modification(type_or_datum) + if(!istype(type_or_datum)) + CRASH("Invalid modification datum") + var/oldpriority + var/datum/movespeed_modifier/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) + if(existing) + if(existing == type_or_datum) //same thing don't need to touch + return TRUE + if(!override) //not overriding, do not overwrite same ID. + return FALSE + oldpriority = existing.priority + remove_movespeed_modifier(existing, FLASE) + LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) + var/resort = type_or_datum.priority == oldpriority + if(update) + update_movespeed(resort) + return TRUE + +///Remove a move speed modifier from a mob +/mob/proc/_REFACTORING_remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) + if(ispath(type_id_datum)) + type_id_datum = get_cached_movespeed_modification(type_id_datum) + if(istype(type_id_datum)) + type_id_datum = type_id_datum.id + if(!LAZYACCESS(movespeed_modification, type_id_datum)) + return FALSE + LAZYREMOVE(movespeed_modification, id) + UNSETEMPTY(movespeed_modification) + if(update) + update_movespeed(FALSE) + return TRUE + +///Handles the special case of editing the movement var +/mob/vv_edit_var(var_name, var_value) + var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown)) + var/diff + if(slowdown_edit && isnum(cached_multiplicative_slowdown) && isnum(var_value)) + remove_movespeed_modifier(MOVESPEED_ID_ADMIN_VAREDIT) + diff = var_value - cached_multiplicative_slowdown + . = ..() + if(. && slowdown_edit && isnum(diff)) + add_movespeed_modifier(MOVESPEED_ID_ADMIN_VAREDIT, TRUE, 100, override = TRUE, multiplicative_slowdown = diff) + +///Is there a movespeed modifier for this mob +/mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) + if(ispath(datum_type_id)) + datum_type_id = get_cached_movespeed_modification(datum_type_id) + if(istype(datum_type_id)) + datum_type_id = datum_type_id.id + return LAZYACCESS(movespeed_modification, datum_type_id) + +///Set or update the global movespeed config on a mob +/mob/proc/update_config_movespeed() + add_movespeed_modifier(MOVESPEED_ID_CONFIG_SPEEDMOD, FALSE, 100, override = TRUE, multiplicative_slowdown = get_config_multiplicative_speed()) + +///Get the global config movespeed of a mob by type +/mob/proc/get_config_multiplicative_speed() + if(!islist(GLOB.mob_config_movespeed_type_lookup) || !GLOB.mob_config_movespeed_type_lookup[type]) + return 0 + else + return GLOB.mob_config_movespeed_type_lookup[type] + +///Go through the list of movespeed modifiers and calculate a final movespeed +/mob/proc/update_movespeed(resort = TRUE) + if(resort) + sort_movespeed_modlist() + . = 0 + var/list/conflict_tracker = list() + for(var/id in get_movespeed_modifiers()) + var/list/data = movespeed_modification[id] + if(!(data[MOVESPEED_DATA_INDEX_MOVETYPE] & movement_type)) // We don't affect any of these move types, skip + continue + if(data[MOVESPEED_DATA_INDEX_BL_MOVETYPE] & movement_type) // There's a movetype here that disables this modifier, skip + continue + var/conflict = data[MOVESPEED_DATA_INDEX_CONFLICT] + var/amt = data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN] + if(conflict) + // Conflicting modifiers prioritize the larger slowdown or the larger speedup + // We purposefuly don't handle mixing speedups and slowdowns on the same id + if(abs(conflict_tracker[conflict]) < abs(amt)) + conflict_tracker[conflict] = amt + else + continue + . += amt + cached_multiplicative_slowdown = . + +///Get the move speed modifiers list of the mob +/mob/proc/get_movespeed_modifiers() + return movespeed_modification + +///Calculate the total slowdown of all movespeed modifiers +/mob/proc/total_multiplicative_slowdown() + . = 0 + for(var/id in get_movespeed_modifiers()) + var/list/data = movespeed_modification[id] + . += data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN] + +///Checks if a move speed modifier is valid and not missing any data +/proc/movespeed_data_null_check(list/data) //Determines if a data list is not meaningful and should be discarded. + . = TRUE + if(data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN]) + . = FALSE + +/** + * Sort the list of move speed modifiers + * + * Verifies it too. Sorts highest priority (first applied) to lowest priority (last applied) + */ +/mob/proc/sort_movespeed_modlist() + if(!movespeed_modification) + return + var/list/assembled = list() + for(var/our_id in movespeed_modification) + var/list/our_data = movespeed_modification[our_id] + if(!islist(our_data) || (our_data.len < MOVESPEED_DATA_INDEX_PRIORITY) || movespeed_data_null_check(our_data)) + movespeed_modification -= our_id + continue + var/our_priority = our_data[MOVESPEED_DATA_INDEX_PRIORITY] + var/resolved = FALSE + for(var/their_id in assembled) + var/list/their_data = assembled[their_id] + if(their_data[MOVESPEED_DATA_INDEX_PRIORITY] < our_priority) + assembled.Insert(assembled.Find(their_id), our_id) + assembled[our_id] = our_data + resolved = TRUE + break + if(!resolved) + assembled[our_id] = our_data + movespeed_modification = assembled + UNSETEMPTY(movespeed_modification) diff --git a/code/modules/movespeed/modifiers/components.dm b/code/modules/movespeed/modifiers/components.dm new file mode 100644 index 00000000000..040a7950fac --- /dev/null +++ b/code/modules/movespeed/modifiers/components.dm @@ -0,0 +1,9 @@ +/datum/movespeed_modifier/shrink_ray + id = MOVESPEED_ID_SHRINK_RAY + movetypes = GROUND + multiplicative_slowdown = 4 + +/datum/movespeed_modifier/snail_crawl + id = MOVESPEED_ID_SNAIL_CRAWL + multiplicative_slowdown = -7 + movetypes = GROUND diff --git a/code/modules/movespeed/modifiers/innate.dm b/code/modules/movespeed/modifiers/innate.dm new file mode 100644 index 00000000000..d11c51f9f80 --- /dev/null +++ b/code/modules/movespeed/modifiers/innate.dm @@ -0,0 +1,4 @@ +/datum/movespeed_modifier/strained_muscles + id = MOVESPEED_ID_CHANGELING_MUSCLES + multiplicative_slowdown = -1 + blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/movespeed/modifiers/reagent.dm b/code/modules/movespeed/modifiers/reagent.dm new file mode 100644 index 00000000000..a66b6c730ee --- /dev/null +++ b/code/modules/movespeed/modifiers/reagent.dm @@ -0,0 +1,9 @@ +/datum/movespeed_modifier/reagent/stimulants + id = "stimulants_reagent" + multiplicative_slowdown = -1 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/reagent/ephedrine + id = "ephedrine_reagent" + multiplicative_slowdown = -0.5 + blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/movespeed/modifiers/status_effects.dm b/code/modules/movespeed/modifiers/status_effects.dm new file mode 100644 index 00000000000..b4bb2b07ba6 --- /dev/null +++ b/code/modules/movespeed/modifiers/status_effects.dm @@ -0,0 +1,7 @@ +/datum/movespeed_modifier/bloodchill + id = "bloodchilled" + multiplicative_slowdown = 3 + +/datum/movespeed_modifier/bonechill + id = "bonechilled" + multiplicative_slowdown = 3 diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm index a1a915693d2..79c87e51c88 100644 --- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm @@ -422,11 +422,11 @@ /datum/reagent/medicine/ephedrine/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-0.5, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/ephedrine) ADD_TRAIT(L, TRAIT_STUNRESISTANCE, type) /datum/reagent/medicine/ephedrine/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/ephedrine) REMOVE_TRAIT(L, TRAIT_STUNRESISTANCE, type) ..() @@ -806,11 +806,11 @@ /datum/reagent/medicine/stimulants/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-1, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) ADD_TRAIT(L, TRAIT_STUNRESISTANCE, type) /datum/reagent/medicine/stimulants/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) REMOVE_TRAIT(L, TRAIT_STUNRESISTANCE, type) ..() diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm index 2fdd2e77da0..af254f6c028 100644 --- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm +++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm @@ -195,10 +195,6 @@ /datum/status_effect/bloodchill/on_remove() owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bloodchill) -/datum/movespeed_modifier/bloodchill - id = "bloodchilled" - multiplicative_slowdown = 3 - /datum/status_effect/bonechill id = "bonechill" duration = 80 @@ -216,11 +212,6 @@ /datum/status_effect/bonechill/on_remove() owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bonechill) - -/datum/movespeed_modifier/bonechill - id = "bonechilled" - multiplicative_slowdown = 3 - /obj/screen/alert/status_effect/bonechill name = "Bonechilled" desc = "You feel a shiver down your spine after hearing the haunting noise of bone rattling. You'll move slower and get frostbite for a while!" diff --git a/tgstation.dme b/tgstation.dme index ca23a270dfb..e550eeec980 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2022,7 +2022,6 @@ #include "code\modules\mob\mob_defines.dm" #include "code\modules\mob\mob_helpers.dm" #include "code\modules\mob\mob_movement.dm" -#include "code\modules\mob\mob_movespeed.dm" #include "code\modules\mob\mob_transformation_simple.dm" #include "code\modules\mob\say.dm" #include "code\modules\mob\status_procs.dm" @@ -2379,6 +2378,11 @@ #include "code\modules\modular_computers\hardware\printer.dm" #include "code\modules\modular_computers\hardware\recharger.dm" #include "code\modules\modular_computers\NTNet\NTNRC\conversation.dm" +#include "code\modules\movespeed\_movespeed_modifier.dm" +#include "code\modules\movespeed\modifiers\components.dm" +#include "code\modules\movespeed\modifiers\innate.dm" +#include "code\modules\movespeed\modifiers\reagent.dm" +#include "code\modules\movespeed\modifiers\status_effects.dm" #include "code\modules\ninja\__ninjaDefines.dm" #include "code\modules\ninja\energy_katana.dm" #include "code\modules\ninja\ninja_event.dm" From 75c575acef74f9853eb59edf9c018779abdf5529 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Fri, 10 Jan 2020 13:36:32 -0800 Subject: [PATCH 04/34] move some stuff add some stuff yadda yadda --- .../antagonists/slaughter/slaughter.dm | 2 +- .../mob/living/carbon/monkey/monkey.dm | 2 -- code/modules/movespeed/_movespeed_modifier.dm | 26 +++++++++---------- code/modules/movespeed/modifiers/reagent.dm | 15 +++++++++++ .../chemistry/reagents/drink_reagents.dm | 5 ++-- .../chemistry/reagents/food_reagents.dm | 4 +-- .../chemistry/reagents/medicine_reagents.dm | 4 +-- 7 files changed, 35 insertions(+), 23 deletions(-) diff --git a/code/modules/antagonists/slaughter/slaughter.dm b/code/modules/antagonists/slaughter/slaughter.dm index 4f3f49e04cd..c4fb5deb541 100644 --- a/code/modules/antagonists/slaughter/slaughter.dm +++ b/code/modules/antagonists/slaughter/slaughter.dm @@ -33,7 +33,7 @@ health = 200 healable = 0 environment_smash = ENVIRONMENT_SMASH_STRUCTURES - obj_damage = 50 + obj_damage = 5 melee_damage_lower = 30 melee_damage_upper = 30 see_in_dark = 8 diff --git a/code/modules/mob/living/carbon/monkey/monkey.dm b/code/modules/mob/living/carbon/monkey/monkey.dm index 51a1a284c54..15ae5c68270 100644 --- a/code/modules/mob/living/carbon/monkey/monkey.dm +++ b/code/modules/mob/living/carbon/monkey/monkey.dm @@ -95,8 +95,6 @@ if(changeling) stat("Chemical Storage", "[changeling.chem_charges]/[changeling.chem_storage]") stat("Absorbed DNA", changeling.absorbedcount) - return - /mob/living/carbon/monkey/verb/removeinternal() set name = "Remove Internals" diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 30871b1e01f..2df0435bfb5 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -96,7 +96,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) type_id_datum = type_id_datum.id if(!LAZYACCESS(movespeed_modification, type_id_datum)) return FALSE - LAZYREMOVE(movespeed_modification, id) + LAZYREMOVE(movespeed_modification, type_id_datum) UNSETEMPTY(movespeed_modification) if(update) update_movespeed(FALSE) @@ -139,13 +139,13 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) . = 0 var/list/conflict_tracker = list() for(var/id in get_movespeed_modifiers()) - var/list/data = movespeed_modification[id] - if(!(data[MOVESPEED_DATA_INDEX_MOVETYPE] & movement_type)) // We don't affect any of these move types, skip + var/datum/movespeed_modifier/M = movespeed_modification[id] + if(!(M.movetypes & movement_type)) // We don't affect any of these move types, skip continue - if(data[MOVESPEED_DATA_INDEX_BL_MOVETYPE] & movement_type) // There's a movetype here that disables this modifier, skip + if(M.blacklisted_movetypes & movement_type) // There's a movetype here that disables this modifier, skip continue - var/conflict = data[MOVESPEED_DATA_INDEX_CONFLICT] - var/amt = data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN] + var/conflict = M.conflict + var/amt = M.multiplicative_slowdown if(conflict) // Conflicting modifiers prioritize the larger slowdown or the larger speedup // We purposefuly don't handle mixing speedups and slowdowns on the same id @@ -183,20 +183,20 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) return var/list/assembled = list() for(var/our_id in movespeed_modification) - var/list/our_data = movespeed_modification[our_id] - if(!islist(our_data) || (our_data.len < MOVESPEED_DATA_INDEX_PRIORITY) || movespeed_data_null_check(our_data)) + var/datum/movespeed_modifier/M = movespeed_modification[our_id] + if(!istype(M) || movespeed_data_null_check(M)) movespeed_modification -= our_id continue - var/our_priority = our_data[MOVESPEED_DATA_INDEX_PRIORITY] + var/our_priority = M.priority var/resolved = FALSE for(var/their_id in assembled) - var/list/their_data = assembled[their_id] - if(their_data[MOVESPEED_DATA_INDEX_PRIORITY] < our_priority) + var/datum/movespeed_modifier/other = assembled[their_id] + if(other.priority < our_priority) assembled.Insert(assembled.Find(their_id), our_id) - assembled[our_id] = our_data + assembled[our_id] = M resolved = TRUE break if(!resolved) - assembled[our_id] = our_data + assembled[our_id] = M movespeed_modification = assembled UNSETEMPTY(movespeed_modification) diff --git a/code/modules/movespeed/modifiers/reagent.dm b/code/modules/movespeed/modifiers/reagent.dm index a66b6c730ee..90d4348486c 100644 --- a/code/modules/movespeed/modifiers/reagent.dm +++ b/code/modules/movespeed/modifiers/reagent.dm @@ -7,3 +7,18 @@ id = "ephedrine_reagent" multiplicative_slowdown = -0.5 blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/reagent/pepperspray + id = MOVESPEED_ID_PEPPER_SPRAY + multiplicative_slowdown = 0.25 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/reagent/badstims + id = "reagent_badstims" + multiplicative_slowdown = -0.35 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/reagent/monkey_energy + id = "reagent_monkey_energy" + multiplicative_slowdown = -0.35 + blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/reagents/chemistry/reagents/drink_reagents.dm b/code/modules/reagents/chemistry/reagents/drink_reagents.dm index 3f2592dfc46..b291206e370 100644 --- a/code/modules/reagents/chemistry/reagents/drink_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drink_reagents.dm @@ -556,17 +556,16 @@ /datum/reagent/consumable/monkey_energy/on_mob_metabolize(mob/living/L) ..() if(ismonkey(L)) - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-0.35, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/monkey_energy) /datum/reagent/consumable/monkey_energy/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/monkey_energy) ..() /datum/reagent/consumable/monkey_energy/overdose_process(mob/living/M) if(prob(15)) M.say(pick_list_replacements(BOOMER_FILE, "boomer"), forced = /datum/reagent/consumable/monkey_energy) ..() - return /datum/reagent/consumable/ice name = "Ice" diff --git a/code/modules/reagents/chemistry/reagents/food_reagents.dm b/code/modules/reagents/chemistry/reagents/food_reagents.dm index 017b30a369a..0159f6852ff 100755 --- a/code/modules/reagents/chemistry/reagents/food_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/food_reagents.dm @@ -293,8 +293,8 @@ victim.blind_eyes(3) // 6 seconds victim.confused = max(M.confused, 5) // 10 seconds victim.Knockdown(3 SECONDS) - victim.add_movespeed_modifier(MOVESPEED_ID_PEPPER_SPRAY, update=TRUE, priority=100, multiplicative_slowdown=0.25, blacklisted_movetypes=(FLYING|FLOATING)) - addtimer(CALLBACK(victim, /mob.proc/remove_movespeed_modifier, MOVESPEED_ID_PEPPER_SPRAY), 10 SECONDS) + victim._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/pepperspray) + addtimer(CALLBACK(victim, /mob.proc/remove_movespeed_modifier, /datum/movespeed_modifier/reagent/pepperspray), 10 SECONDS) victim.update_damage_hud() if(method == INGEST) if(!holder.has_reagent(/datum/reagent/consumable/milk)) diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm index 79c87e51c88..2115a2d8a95 100644 --- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm @@ -1348,14 +1348,14 @@ ..() ADD_TRAIT(L, TRAIT_SLEEPIMMUNE, type) ADD_TRAIT(L, TRAIT_STUNRESISTANCE, type) - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-0.35, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/badstims) L.ignore_slowdown(type) /datum/reagent/medicine/badstims/on_mob_end_metabolize(mob/living/L) ..() REMOVE_TRAIT(L, TRAIT_SLEEPIMMUNE, type) REMOVE_TRAIT(L, TRAIT_STUNRESISTANCE, type) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/badstims) L.unignore_slowdown(type) L.Dizzy(0) L.Jitter(0) From 9725ba6b571ae07bddd1775c75387ca8a74e372c Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Fri, 10 Jan 2020 14:49:59 -0800 Subject: [PATCH 05/34] variable modifiers --- .../mob/living/carbon/monkey/monkey.dm | 7 +- code/modules/mob/mob_movement.dm | 16 ++-- code/modules/movespeed/_movespeed_modifier.dm | 74 ++++++++++++++++--- code/modules/movespeed/modifiers/variable.dm | 10 +++ tgstation.dme | 1 + 5 files changed, 86 insertions(+), 22 deletions(-) create mode 100644 code/modules/movespeed/modifiers/variable.dm diff --git a/code/modules/mob/living/carbon/monkey/monkey.dm b/code/modules/mob/living/carbon/monkey/monkey.dm index 15ae5c68270..c8dd9a90e36 100644 --- a/code/modules/mob/living/carbon/monkey/monkey.dm +++ b/code/modules/mob/living/carbon/monkey/monkey.dm @@ -60,14 +60,13 @@ /mob/living/carbon/monkey/on_reagent_change() . = ..() - remove_movespeed_modifier(MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD, TRUE) var/amount if(reagents.has_reagent(/datum/reagent/medicine/morphine)) amount = -1 if(reagents.has_reagent(/datum/reagent/consumable/nuka_cola)) amount = -1 if(amount) - add_movespeed_modifier(MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = amount) + add_or_update_movespeed_modifier(/datum/movespeed_modifier/variable/monkey_reagent_speedmod, TRUE, amount) /mob/living/carbon/monkey/updatehealth() . = ..() @@ -76,14 +75,14 @@ var/health_deficiency = (maxHealth - health) if(health_deficiency >= 45) slow += (health_deficiency / 25) - add_movespeed_modifier(MOVESPEED_ID_MONKEY_HEALTH_SPEEDMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = slow) + add_or_update_movespeed_modifier(/datum/movespeed_modifier/variable/monkey_health_speedmod, TRUE, slow) /mob/living/carbon/monkey/adjust_bodytemperature(amount) . = ..() var/slow = 0 if (bodytemperature < 283.222) slow += ((283.222 - bodytemperature) / 10) * 1.75 - add_movespeed_modifier(MOVESPEED_ID_MONKEY_TEMPERATURE_SPEEDMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = slow) + add_or_update_movespeed_modifier(/datum/movespeed_modifier/variable/monkey_temperature_speedmod, TRUE, slow) /mob/living/carbon/monkey/Stat() ..() diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 98a59b851cd..4f49da4c02a 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -38,17 +38,17 @@ * Move a client in a direction * * Huge proc, has a lot of functionality - * + * * Mostly it will despatch to the mob that you are the owner of to actually move * in the physical realm - * + * * Things that stop you moving as a mob: * * world time being less than your next move_delay * * not being in a mob, or that mob not having a loc * * missing the n and direction parameters * * being in remote control of an object (calls Moveobject instead) * * being dead (it ghosts you instead) - * + * * Things that stop you moving as a mob living (why even have OO if you're just shoving it all * in the parent proc with istype checks right?): * * having incorporeal_move set (calls Process_Incorpmove() instead) @@ -68,7 +68,7 @@ * * Finally if you're pulling an object and it's dense, you are turned 180 after the move * (if you ask me, this should be at the top of the move so you don't dance around) - * + * */ /client/Move(n, direct) if(world.time < move_delay) //do not move anything ahead of this check please @@ -175,7 +175,7 @@ * Allows mobs to ignore density and phase through objects * * Called by client/Move() - * + * * The behaviour depends on the incorporeal_move value of the mob * * * INCORPOREAL_MOVE_BASIC - forceMoved to the next tile with no stop @@ -263,9 +263,9 @@ * Handles mob/living movement in space (or no gravity) * * Called by /client/Move() - * + * * return TRUE for movement or FALSE for none - * + * * You can move in space if you have a spacewalk ability */ /mob/Process_Spacemove(movement_dir = 0) @@ -443,7 +443,7 @@ /** * Toggle the move intent of the mob - * + * * triggers an update the move intent hud as well */ /mob/proc/toggle_move_intent(mob/user) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 2df0435bfb5..a9315a4f9f9 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -63,14 +63,21 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) /// Grabs a STATIC MODIFIER datum from cache. YOU MUST NEVER EDIT THESE DATUMS, OR IT WILL AFFECT ANYTHING ELSE USING IT TOO! /proc/get_cached_movespeed_modification(modtype) if(!ispath(modtype, /datum/movespeed_modifier)) - CRASH("[modtype] is not a movespeed modification type.") + CRASH("[modtype] is not a movespeed modification typepath.") + if(ispath(modtype, /datum/movespeed_modifier/variable)) + CRASH("[modtype] is a variable modifier, and can never be cached.") var/datum/movespeed_modifier/M = GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) return M -///Add a move speed modifier to a mob +///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. /mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE, override = FALSE) + var/created = FALSE if(ispath(type_or_datum)) - type_or_datum = get_cached_movespeed_modification(type_or_datum) + if(!ispath(type_or_datum, /datum/movespeed_modifier/variable)) + type_or_datum = get_cached_movespeed_modification(type_or_datum) + else + created = TRUE + type_or_datum = new type_or_datum if(!istype(type_or_datum)) CRASH("Invalid modification datum") var/oldpriority @@ -79,19 +86,24 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(existing == type_or_datum) //same thing don't need to touch return TRUE if(!override) //not overriding, do not overwrite same ID. + if(created) //make sure we clean up after ourselves. + qdel(type_or_datum) return FALSE oldpriority = existing.priority - remove_movespeed_modifier(existing, FLASE) + remove_movespeed_modifier(existing, FALSE) LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) var/resort = type_or_datum.priority == oldpriority if(update) update_movespeed(resort) return TRUE -///Remove a move speed modifier from a mob +///Remove a move speed modifier from a mob, whether static or variable. /mob/proc/_REFACTORING_remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) if(ispath(type_id_datum)) - type_id_datum = get_cached_movespeed_modification(type_id_datum) + if(!ispath(type_id_datum, /datum/movespeed_modifier/variable)) + type_id_datum = get_cached_movespeed_modification(type_id_datum) + else + type_id_datum = initial(type_id_datum.id) if(istype(type_id_datum)) type_id_datum = type_id_datum.id if(!LAZYACCESS(movespeed_modification, type_id_datum)) @@ -102,6 +114,48 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) update_movespeed(FALSE) return TRUE +/// Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. +/// Implies override. +/mob/proc/add_or_update_variable_movespeed_modifier(datum/movespeed_modifier/variable/type_id_datum, update = TRUE, multiplicative_slowdown) + /* + How this SHOULD work is: + 1. Ensures type_id_datum one way or another refers to a /variable datum. This makes sure it can't be cached. This includes if it's already in the modification list. + 2. Instantiate a new datum if type_id_datum isn't already instantiated + in the list, using the type. Obviously, wouldn't work for ID only. + 3. Add the datum if necessary using the regular add proc + 4. If any of the rest of the args are not null (see: multiplicative slowdown), modify the datum + 5. Update if necessary + */ + . = FALSE + var/modified = FALSE + var/inject = FALSE + var/datum/movespeed_modifier/variable/final + if(istext(type_id_datum)) + final = LAZYACCESS(movespeed_modification, type_id_datum) + if(!istype(final)) + CRASH("Couldn't find existing modification when only provided an ID.") + else if(ispath(type_id_datum)) + var/id = initial(type_id_datum.id) + final = LAZYACCESS(movespeed_modification, type_id_datum) + if(!istype(final)) + final = new + inject = TRUE + modified = TRUE + else if(istype(type_id_datum)) + final = type_id_datum + if(!LAZYACCESS(movespeed_modification, final.id)) + inject = TRUE + modified = TRUE + else + CRASH("Invalid modifier") + if(!isnull(multiplicative_slowdown) + final.multiplicative_slowdown = multiplicative_slowdown + modified = TRUE + if(inject) + _REFACTORING_add_movespeed_modifier(final, FALSE, TRUE) + if(update && modified) + update_movespeed(TRUE) + return TRUE + ///Handles the special case of editing the movement var /mob/vv_edit_var(var_name, var_value) var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown)) @@ -164,13 +218,13 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) /mob/proc/total_multiplicative_slowdown() . = 0 for(var/id in get_movespeed_modifiers()) - var/list/data = movespeed_modification[id] - . += data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN] + var/datum/movespeed_modifier/M = movespeed_modification[id] + . += M.multiplicative_slowdown() ///Checks if a move speed modifier is valid and not missing any data -/proc/movespeed_data_null_check(list/data) //Determines if a data list is not meaningful and should be discarded. +/proc/movespeed_data_null_check(datum/movespeed_modifier/M) //Determines if a data list is not meaningful and should be discarded. . = TRUE - if(data[MOVESPEED_DATA_INDEX_MULTIPLICATIVE_SLOWDOWN]) + if(M.multiplicative_slowdown) . = FALSE /** diff --git a/code/modules/movespeed/modifiers/variable.dm b/code/modules/movespeed/modifiers/variable.dm new file mode 100644 index 00000000000..f7836a90c9e --- /dev/null +++ b/code/modules/movespeed/modifiers/variable.dm @@ -0,0 +1,10 @@ +/datum/movespeed_modifier/variable + +/datum/movespeed_modifier/variable/monkey_reagent_speedmod + id = MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD + +/datum/movespeed_modifier/variable/monkey_health_speedmod + id = MOVESPEED_ID_MONKEY_HEALTH_SPEEDMOD + +/datum/movespeed_modifier/variable/monkey_temperature_speedmod + id = MOVESPEED_ID_MONKEY_TEMPERATURE_SPEEDMOD diff --git a/tgstation.dme b/tgstation.dme index e550eeec980..7642b2722b8 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2383,6 +2383,7 @@ #include "code\modules\movespeed\modifiers\innate.dm" #include "code\modules\movespeed\modifiers\reagent.dm" #include "code\modules\movespeed\modifiers\status_effects.dm" +#include "code\modules\movespeed\modifiers\variable.dm" #include "code\modules\ninja\__ninjaDefines.dm" #include "code\modules\ninja\energy_katana.dm" #include "code\modules\ninja\ninja_event.dm" From b3237ada7dea054c901e423bcd8fadd9b3cea4df Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Fri, 10 Jan 2020 14:51:15 -0800 Subject: [PATCH 06/34] compile --- code/modules/movespeed/_movespeed_modifier.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index a9315a4f9f9..a6d9c3972ba 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -147,7 +147,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) modified = TRUE else CRASH("Invalid modifier") - if(!isnull(multiplicative_slowdown) + if(!isnull(multiplicative_slowdown)) final.multiplicative_slowdown = multiplicative_slowdown modified = TRUE if(inject) From 935817e607d137a3b69aa9fa77bea9cf0e55188a Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 15:36:32 -0800 Subject: [PATCH 07/34] a a a a a --- code/datums/components/riding.dm | 2 +- .../antagonists/slaughter/slaughter.dm | 5 ++- code/modules/mob/living/carbon/human/human.dm | 17 +++++---- .../mob/living/carbon/human/human_movement.dm | 10 +++--- .../mob/living/carbon/human/species.dm | 11 +++--- .../mob/living/carbon/monkey/monkey.dm | 6 ++-- code/modules/mob/living/silicon/pai/pai.dm | 4 +-- code/modules/movespeed/_movespeed_modifier.dm | 27 +++++++++----- code/modules/movespeed/modifiers/mobs.dm | 35 +++++++++++++++++++ code/modules/movespeed/modifiers/reagent.dm | 28 ++++++++++++--- .../movespeed/modifiers/status_effects.dm | 19 ++++++++-- code/modules/movespeed/modifiers/variable.dm | 10 ------ .../reagents/cat2_medicine_reagents.dm | 22 ++++++------ .../chemistry/reagents/drink_reagents.dm | 4 +-- .../chemistry/reagents/drug_reagents.dm | 4 +-- .../chemistry/reagents/food_reagents.dm | 2 +- .../chemistry/reagents/medicine_reagents.dm | 4 +-- .../chemistry/reagents/other_reagents.dm | 4 +-- .../crossbreeding/_status_effects.dm | 22 ++++++------ code/modules/station_goals/dna_vault.dm | 2 -- tgstation.dme | 2 +- 21 files changed, 152 insertions(+), 88 deletions(-) create mode 100644 code/modules/movespeed/modifiers/mobs.dm delete mode 100644 code/modules/movespeed/modifiers/variable.dm diff --git a/code/datums/components/riding.dm b/code/datums/components/riding.dm index 3840845a4c4..c8c916e465a 100644 --- a/code/datums/components/riding.dm +++ b/code/datums/components/riding.dm @@ -364,4 +364,4 @@ if(rider in AM.buckled_mobs) AM.unbuckle_mob(rider) . = ..() - + diff --git a/code/modules/antagonists/slaughter/slaughter.dm b/code/modules/antagonists/slaughter/slaughter.dm index c4fb5deb541..127a5bb15a2 100644 --- a/code/modules/antagonists/slaughter/slaughter.dm +++ b/code/modules/antagonists/slaughter/slaughter.dm @@ -67,9 +67,8 @@ /mob/living/simple_animal/slaughter/phasein() . = ..() - add_movespeed_modifier(MOVESPEED_ID_SLAUGHTER, update=TRUE, priority=100, multiplicative_slowdown=-1) - addtimer(CALLBACK(src, .proc/remove_movespeed_modifier, MOVESPEED_ID_SLAUGHTER, TRUE), 6 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE) - + _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/slaughter) + addtimer(CALLBACK(src, .proc/_REFACTORING_remove_movespeed_modifier, /datum/movespeed_modifier/slaughter), 6 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE) //The loot from killing a slaughter demon - can be consumed to allow the user to blood crawl /obj/item/organ/heart/demon diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 41d82045c8f..fcedbba7d61 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1031,24 +1031,23 @@ . = ..() dna?.species.spec_updatehealth(src) if(HAS_TRAIT(src, TRAIT_IGNOREDAMAGESLOWDOWN)) - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN) - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) return var/health_deficiency = max((maxHealth - health), staminaloss) if(health_deficiency >= 40) - add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN, override = TRUE, multiplicative_slowdown = (health_deficiency / 75), blacklisted_movetypes = FLOATING|FLYING) - add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING, override = TRUE, multiplicative_slowdown = (health_deficiency / 25), movetypes = FLOATING) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) else - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN) - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) - -/mob/living/carbon/human/adjust_nutrition(var/change) //Honestly FUCK the oldcoders for putting nutrition on /mob someone else can move it up because holy hell I'd have to fix SO many typechecks +/mob/living/carbon/human/adjust_nutrition(change) //Honestly FUCK the oldcoders for putting nutrition on /mob someone else can move it up because holy hell I'd have to fix SO many typechecks if(HAS_TRAIT(src, TRAIT_NOHUNGER)) return FALSE return ..() -/mob/living/carbon/human/set_nutrition(var/change) //Seriously fuck you oldcoders. +/mob/living/carbon/human/set_nutrition(change) //Seriously fuck you oldcoders. if(HAS_TRAIT(src, TRAIT_NOHUNGER)) return FALSE return ..() diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index 7f1c7c4c2fb..fd46ad8b9f1 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -1,11 +1,11 @@ /mob/living/carbon/human/get_movespeed_modifiers() var/list/considering = ..() - . = considering + . = list() if(HAS_TRAIT(src, TRAIT_IGNORESLOWDOWN)) - for(var/id in .) - var/list/data = .[id] - if(data[MOVESPEED_DATA_INDEX_FLAGS] & IGNORE_NOSLOW) - .[id] = data + for(var/id in considering) + var/datum/movespeed_modifier/M = considering[id] + if(M.flags & IGNORE_NOSLOW) + .[id] = M /mob/living/carbon/human/slip(knockdown_amount, obj/O, lube, paralyze, forcedrop) if(HAS_TRAIT(src, TRAIT_NOSLIPALL)) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 6ae31b7febd..3f04b2df013 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1018,7 +1018,6 @@ GLOBAL_LIST_EMPTY(roundstart_races) //////// //LIFE// //////// - /datum/species/proc/handle_digestion(mob/living/carbon/human/H) if(HAS_TRAIT(src, TRAIT_NOHUNGER)) return //hunger is for BABIES @@ -1028,14 +1027,14 @@ GLOBAL_LIST_EMPTY(roundstart_races) if(H.overeatduration < 100) to_chat(H, "You feel fit again!") REMOVE_TRAIT(H, TRAIT_FAT, OBESITY) - H.remove_movespeed_modifier(MOVESPEED_ID_FAT) + H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/obesity) H.update_inv_w_uniform() H.update_inv_wear_suit() else if(H.overeatduration >= 100) to_chat(H, "You suddenly feel blubbery!") ADD_TRAIT(H, TRAIT_FAT, OBESITY) - H.add_movespeed_modifier(MOVESPEED_ID_FAT, multiplicative_slowdown = 1.5) + H._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/obesity) H.update_inv_w_uniform() H.update_inv_wear_suit() @@ -1090,13 +1089,13 @@ GLOBAL_LIST_EMPTY(roundstart_races) if(!HAS_TRAIT(H, TRAIT_NOHUNGER)) var/hungry = (500 - H.nutrition) / 5 //So overeat would be 100 and default level would be 80 if(hungry >= 70) - H.add_movespeed_modifier(MOVESPEED_ID_HUNGRY, override = TRUE, multiplicative_slowdown = (hungry / 50)) + H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/hunger, multiplicative_slowdown = (hungry / 50)) else if(isethereal(H)) var/datum/species/ethereal/E = H.dna.species if(E.get_charge(H) <= ETHEREAL_CHARGE_NORMAL) - H.add_movespeed_modifier(MOVESPEED_ID_HUNGRY, override = TRUE, multiplicative_slowdown = (1.5 * (1 - E.get_charge(H) / 100))) + H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/hunger, multiplicative_slowdown = (1.5 * (1 - E.get_charge(H) / 100))) else - H.remove_movespeed_modifier(MOVESPEED_ID_HUNGRY) + H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/hunger) switch(H.nutrition) if(NUTRITION_LEVEL_FULL to INFINITY) diff --git a/code/modules/mob/living/carbon/monkey/monkey.dm b/code/modules/mob/living/carbon/monkey/monkey.dm index c8dd9a90e36..0452cebe784 100644 --- a/code/modules/mob/living/carbon/monkey/monkey.dm +++ b/code/modules/mob/living/carbon/monkey/monkey.dm @@ -66,7 +66,7 @@ if(reagents.has_reagent(/datum/reagent/consumable/nuka_cola)) amount = -1 if(amount) - add_or_update_movespeed_modifier(/datum/movespeed_modifier/variable/monkey_reagent_speedmod, TRUE, amount) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/monkey_reagent_speedmod, TRUE, amount) /mob/living/carbon/monkey/updatehealth() . = ..() @@ -75,14 +75,14 @@ var/health_deficiency = (maxHealth - health) if(health_deficiency >= 45) slow += (health_deficiency / 25) - add_or_update_movespeed_modifier(/datum/movespeed_modifier/variable/monkey_health_speedmod, TRUE, slow) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/monkey_health_speedmod, TRUE, slow) /mob/living/carbon/monkey/adjust_bodytemperature(amount) . = ..() var/slow = 0 if (bodytemperature < 283.222) slow += ((283.222 - bodytemperature) / 10) * 1.75 - add_or_update_movespeed_modifier(/datum/movespeed_modifier/variable/monkey_temperature_speedmod, TRUE, slow) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/monkey_temperature_speedmod, TRUE, slow) /mob/living/carbon/monkey/Stat() ..() diff --git a/code/modules/mob/living/silicon/pai/pai.dm b/code/modules/mob/living/silicon/pai/pai.dm index 89a627ce9e5..bd2f9e085fd 100644 --- a/code/modules/mob/living/silicon/pai/pai.dm +++ b/code/modules/mob/living/silicon/pai/pai.dm @@ -254,9 +254,9 @@ /mob/living/silicon/pai/Process_Spacemove(movement_dir = 0) . = ..() if(!.) - add_movespeed_modifier(MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD, TRUE, 100, multiplicative_slowdown = 2) + _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk) return TRUE - remove_movespeed_modifier(MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD, TRUE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk) return TRUE /mob/living/silicon/pai/examine(mob/user) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index a6d9c3972ba..6f00153abc4 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -3,6 +3,9 @@ */ /datum/movespeed_modifier + /// Whether or not this is a variable modifier. Variable modifiers can NOT be ever auto-cached. ONLY CHECKED VIA INITIAL(), EFFECTIVELY READ ONLY (and for very good reason) + var/variable = FALSE + /// Unique ID. You can never have different modifications with the same ID var/id = "ERROR" @@ -64,16 +67,16 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) /proc/get_cached_movespeed_modification(modtype) if(!ispath(modtype, /datum/movespeed_modifier)) CRASH("[modtype] is not a movespeed modification typepath.") - if(ispath(modtype, /datum/movespeed_modifier/variable)) + var/datum/movespeed_modifier/M = modtype + if(initial(M.variable)) CRASH("[modtype] is a variable modifier, and can never be cached.") - var/datum/movespeed_modifier/M = GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) - return M + return GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) ///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. /mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE, override = FALSE) var/created = FALSE if(ispath(type_or_datum)) - if(!ispath(type_or_datum, /datum/movespeed_modifier/variable)) + if(!initial(type_or_datum.variable)) type_or_datum = get_cached_movespeed_modification(type_or_datum) else created = TRUE @@ -100,12 +103,14 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) ///Remove a move speed modifier from a mob, whether static or variable. /mob/proc/_REFACTORING_remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) if(ispath(type_id_datum)) - if(!ispath(type_id_datum, /datum/movespeed_modifier/variable)) + if(!initial(type_id_datum.variable)) type_id_datum = get_cached_movespeed_modification(type_id_datum) else type_id_datum = initial(type_id_datum.id) if(istype(type_id_datum)) type_id_datum = type_id_datum.id + if(!istext(type_id_datum)) + CRASH("Invalid ID") if(!LAZYACCESS(movespeed_modification, type_id_datum)) return FALSE LAZYREMOVE(movespeed_modification, type_id_datum) @@ -116,7 +121,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) /// Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. /// Implies override. -/mob/proc/add_or_update_variable_movespeed_modifier(datum/movespeed_modifier/variable/type_id_datum, update = TRUE, multiplicative_slowdown) +/mob/proc/add_or_update_variable_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE, multiplicative_slowdown) /* How this SHOULD work is: 1. Ensures type_id_datum one way or another refers to a /variable datum. This makes sure it can't be cached. This includes if it's already in the modification list. @@ -128,12 +133,14 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) . = FALSE var/modified = FALSE var/inject = FALSE - var/datum/movespeed_modifier/variable/final + var/datum/movespeed_modifier/final if(istext(type_id_datum)) final = LAZYACCESS(movespeed_modification, type_id_datum) if(!istype(final)) CRASH("Couldn't find existing modification when only provided an ID.") else if(ispath(type_id_datum)) + if(!initial(type_id_datum.variable)) + CRASH("Not a variable modifier") var/id = initial(type_id_datum.id) final = LAZYACCESS(movespeed_modification, type_id_datum) if(!istype(final)) @@ -141,6 +148,8 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) inject = TRUE modified = TRUE else if(istype(type_id_datum)) + if(!initial(type_id_datum.variable)) + CRASH("Not a variable modifier") final = type_id_datum if(!LAZYACCESS(movespeed_modification, final.id)) inject = TRUE @@ -198,7 +207,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) continue if(M.blacklisted_movetypes & movement_type) // There's a movetype here that disables this modifier, skip continue - var/conflict = M.conflict + var/conflict = M.conflicts_with var/amt = M.multiplicative_slowdown if(conflict) // Conflicting modifiers prioritize the larger slowdown or the larger speedup @@ -219,7 +228,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) . = 0 for(var/id in get_movespeed_modifiers()) var/datum/movespeed_modifier/M = movespeed_modification[id] - . += M.multiplicative_slowdown() + . += M.multiplicative_slowdown ///Checks if a move speed modifier is valid and not missing any data /proc/movespeed_data_null_check(datum/movespeed_modifier/M) //Determines if a data list is not meaningful and should be discarded. diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm new file mode 100644 index 00000000000..23084dc0ea2 --- /dev/null +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -0,0 +1,35 @@ +/datum/movespeed_modifier/obesity + id = MOVESPEED_ID_FAT + multiplicative_slowdown = 1.5 + +/datum/movespeed_modifier/monkey_reagent_speedmod + variable = TRUE + id = MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD + +/datum/movespeed_modifier/monkey_health_speedmod + variable = TRUE + id = MOVESPEED_ID_MONKEY_HEALTH_SPEEDMOD + +/datum/movespeed_modifier/monkey_temperature_speedmod + variable = TRUE + id = MOVESPEED_ID_MONKEY_TEMPERATURE_SPEEDMOD + +/datum/movespeed_modifier/hunger + id = MOVESPEED_ID_HUNGRY + variable = TRUE + +/datum/movespeed_modifier/slaughter + id = MOVESPEED_ID_SLAUGHTER + multiplicative_slowdown = -1 + +/datum/movespeed_modifier/damage_slowdown + id = MOVESPEED_ID_DAMAGE_SLOWDOWN + blacklisted_movetypes = FLOATING|FLYING + +/datum/movespeed_modifier/damage_slowdown_flying + id = MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING + movetypes = FLOATING + +/datum/movespeed_modifier/pai_spacewalk + id = MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD + multiplicative_slowdown = 2 diff --git a/code/modules/movespeed/modifiers/reagent.dm b/code/modules/movespeed/modifiers/reagent.dm index 90d4348486c..708925bda2b 100644 --- a/code/modules/movespeed/modifiers/reagent.dm +++ b/code/modules/movespeed/modifiers/reagent.dm @@ -1,24 +1,42 @@ +/datum/movespeed_modifier/reagent + blacklisted_movetypes = (FLYING|FLOATING) + /datum/movespeed_modifier/reagent/stimulants id = "stimulants_reagent" multiplicative_slowdown = -1 - blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/reagent/ephedrine id = "ephedrine_reagent" multiplicative_slowdown = -0.5 - blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/reagent/pepperspray id = MOVESPEED_ID_PEPPER_SPRAY multiplicative_slowdown = 0.25 - blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/reagent/badstims id = "reagent_badstims" multiplicative_slowdown = -0.35 - blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/reagent/monkey_energy id = "reagent_monkey_energy" multiplicative_slowdown = -0.35 - blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/reagent/changelinghaste + id = "reagent_changelinghaste" + multiplicative_slowdown = -2 + +/datum/movespeed_modifier/reagent/methamphetamine + id = "reagent_methamphetamine" + multiplicative_slowdown = -0.65 + +/datum/movespeed_modifier/reagent/nitryl + id = "reagent_nitryl" + multiplicative_slowdown = -0.65 + +/datum/movespeed_modifier/reagent/lenturi + id = "reagent_lenturi" + multiplicative_slowdown = 1.5 + +/datum/movespeed_modifier/reagent/nuka_cola + id = "reagent_nukacola" + multiplicative_slowdown = -0.35 diff --git a/code/modules/movespeed/modifiers/status_effects.dm b/code/modules/movespeed/modifiers/status_effects.dm index b4bb2b07ba6..de68bd78ed1 100644 --- a/code/modules/movespeed/modifiers/status_effects.dm +++ b/code/modules/movespeed/modifiers/status_effects.dm @@ -1,7 +1,22 @@ -/datum/movespeed_modifier/bloodchill +/datum/movespeed_modifier/status_effect/bloodchill id = "bloodchilled" multiplicative_slowdown = 3 -/datum/movespeed_modifier/bonechill +/datum/movespeed_modifier/status_effect/bonechill id = "bonechilled" multiplicative_slowdown = 3 + +/datum/movespeed_modifier/status_effect/lightpink + id = MOVESPEED_ID_SLIME_STATUS + multiplicative_slowdown = -0.5 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/status_effect/tarfoot + id = MOVESPEED_ID_TARFOOT + multiplicative_slowdown = 0.5 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/status_effect/sepia + variable = TRUE + id = MOVESPEED_ID_SEPIA + blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/movespeed/modifiers/variable.dm b/code/modules/movespeed/modifiers/variable.dm deleted file mode 100644 index f7836a90c9e..00000000000 --- a/code/modules/movespeed/modifiers/variable.dm +++ /dev/null @@ -1,10 +0,0 @@ -/datum/movespeed_modifier/variable - -/datum/movespeed_modifier/variable/monkey_reagent_speedmod - id = MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD - -/datum/movespeed_modifier/variable/monkey_health_speedmod - id = MOVESPEED_ID_MONKEY_HEALTH_SPEEDMOD - -/datum/movespeed_modifier/variable/monkey_temperature_speedmod - id = MOVESPEED_ID_MONKEY_TEMPERATURE_SPEEDMOD diff --git a/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm index 4fc4fca9bf2..67e57ddf168 100644 --- a/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm @@ -100,17 +100,19 @@ var/spammer = 0 /datum/reagent/medicine/C2/lenturi/on_mob_life(mob/living/carbon/M) - M.adjustFireLoss(-3 * REM) - M.adjustOrganLoss(ORGAN_SLOT_STOMACH, 0.4 * REM) - ..() - return TRUE -/datum/reagent/medicine/C2/lenturi/on_mob_metabolize(mob/living/carbon/M) - M.add_movespeed_modifier(MOVESPEED_ID_LENTURI, update=TRUE, priority=100, multiplicative_slowdown=1.50, blacklisted_movetypes=(FLYING|FLOATING)) - . = ..() -/datum/reagent/medicine/C2/lenturi/on_mob_end_metabolize(mob/living/carbon/M) - M.remove_movespeed_modifier(MOVESPEED_ID_LENTURI) + M.adjustFireLoss(-3 * REM) + M.adjustOrganLoss(ORGAN_SLOT_STOMACH, 0.4 * REM) + ..() + return TRUE + +/datum/reagent/medicine/C2/lenturi/on_mob_metabolize(mob/living/carbon/M) + M._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/lenturi) + return ..() + +/datum/reagent/medicine/C2/lenturi/on_mob_end_metabolize(mob/living/carbon/M) + M._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/lenturi) + return ..() - . = ..() /datum/reagent/medicine/C2/aiuri name = "Aiuri" description = "Used to treat burns. Does minor eye damage." diff --git a/code/modules/reagents/chemistry/reagents/drink_reagents.dm b/code/modules/reagents/chemistry/reagents/drink_reagents.dm index b291206e370..1df4e807393 100644 --- a/code/modules/reagents/chemistry/reagents/drink_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drink_reagents.dm @@ -376,10 +376,10 @@ /datum/reagent/consumable/nuka_cola/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-0.35, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/nuka_cola) /datum/reagent/consumable/nuka_cola/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nuka_cola) ..() /datum/reagent/consumable/nuka_cola/on_mob_life(mob/living/carbon/M) diff --git a/code/modules/reagents/chemistry/reagents/drug_reagents.dm b/code/modules/reagents/chemistry/reagents/drug_reagents.dm index 87c1fe954a0..9af53eff1da 100644 --- a/code/modules/reagents/chemistry/reagents/drug_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drug_reagents.dm @@ -174,10 +174,10 @@ /datum/reagent/drug/methamphetamine/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-0.65, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine) /datum/reagent/drug/methamphetamine/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine) ..() /datum/reagent/drug/methamphetamine/on_mob_life(mob/living/carbon/M) diff --git a/code/modules/reagents/chemistry/reagents/food_reagents.dm b/code/modules/reagents/chemistry/reagents/food_reagents.dm index 0159f6852ff..bd9d3286014 100755 --- a/code/modules/reagents/chemistry/reagents/food_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/food_reagents.dm @@ -294,7 +294,7 @@ victim.confused = max(M.confused, 5) // 10 seconds victim.Knockdown(3 SECONDS) victim._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/pepperspray) - addtimer(CALLBACK(victim, /mob.proc/remove_movespeed_modifier, /datum/movespeed_modifier/reagent/pepperspray), 10 SECONDS) + addtimer(CALLBACK(victim, /mob.proc/_REFACTORING_remove_movespeed_modifier, /datum/movespeed_modifier/reagent/pepperspray), 10 SECONDS) victim.update_damage_hud() if(method == INGEST) if(!holder.has_reagent(/datum/reagent/consumable/milk)) diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm index 2115a2d8a95..23cad61cc2e 100644 --- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm @@ -1038,10 +1038,10 @@ /datum/reagent/medicine/changelinghaste/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-2, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/changelinghaste) /datum/reagent/medicine/changelinghaste/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/changelinghaste) ..() /datum/reagent/medicine/changelinghaste/on_mob_life(mob/living/carbon/M) diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index 52ad85ec33a..828ea4779d1 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -1230,10 +1230,10 @@ /datum/reagent/nitryl/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-0.65, blacklisted_movetypes=(FLYING|FLOATING)) + L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) /datum/reagent/nitryl/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) ..() /////////////////////////Colorful Powder//////////////////////////// diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm index af254f6c028..cf5a55d1287 100644 --- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm +++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm @@ -185,7 +185,7 @@ alert_type = /obj/screen/alert/status_effect/bloodchill /datum/status_effect/bloodchill/on_apply() - owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/bloodchill) + owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) return ..() /datum/status_effect/bloodchill/tick() @@ -193,7 +193,7 @@ owner.adjustFireLoss(2) /datum/status_effect/bloodchill/on_remove() - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bloodchill) + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) /datum/status_effect/bonechill id = "bonechill" @@ -201,7 +201,7 @@ alert_type = /obj/screen/alert/status_effect/bonechill /datum/status_effect/bonechill/on_apply() - owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/bonechill) + owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) return ..() /datum/status_effect/bonechill/tick() @@ -211,7 +211,7 @@ owner.adjust_bodytemperature(-10) /datum/status_effect/bonechill/on_remove() - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bonechill) + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) /obj/screen/alert/status_effect/bonechill name = "Bonechilled" desc = "You feel a shiver down your spine after hearing the haunting noise of bone rattling. You'll move slower and get frostbite for a while!" @@ -365,11 +365,11 @@ datum/status_effect/rebreathing/tick() duration = 30 /datum/status_effect/tarfoot/on_apply() - owner.add_movespeed_modifier(MOVESPEED_ID_TARFOOT, update=TRUE, priority=100, multiplicative_slowdown=0.5, blacklisted_movetypes=(FLYING|FLOATING)) + owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) return ..() /datum/status_effect/tarfoot/on_remove() - owner.remove_movespeed_modifier(MOVESPEED_ID_TARFOOT) + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) /datum/status_effect/spookcookie id = "spookcookie" @@ -683,15 +683,15 @@ datum/status_effect/stabilized/blue/on_remove() /datum/status_effect/stabilized/sepia/tick() if(prob(50) && mod > -1) mod-- - owner.add_movespeed_modifier(MOVESPEED_ID_SEPIA, override = TRUE, update=TRUE, priority=100, multiplicative_slowdown=-0.5, blacklisted_movetypes=(FLYING|FLOATING)) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia, multiplicative_slowdown = -0.5) else if(mod < 1) mod++ // yeah a value of 0 does nothing but replacing the trait in place is cheaper than removing and adding repeatedly - owner.add_movespeed_modifier(MOVESPEED_ID_SEPIA, override = TRUE, update=TRUE, priority=100, multiplicative_slowdown=0, blacklisted_movetypes=(FLYING|FLOATING)) + owner.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia, multiplicative_slowdown = 0) return ..() /datum/status_effect/stabilized/sepia/on_remove() - owner.remove_movespeed_modifier(MOVESPEED_ID_SEPIA) + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia) /datum/status_effect/stabilized/cerulean id = "stabilizedcerulean" @@ -899,7 +899,7 @@ datum/status_effect/stabilized/blue/on_remove() colour = "light pink" /datum/status_effect/stabilized/lightpink/on_apply() - owner.add_movespeed_modifier(MOVESPEED_ID_SLIME_STATUS, update=TRUE, priority=100, multiplicative_slowdown=-0.5, blacklisted_movetypes=(FLYING|FLOATING)) + owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/lightpink) return ..() /datum/status_effect/stabilized/lightpink/tick() @@ -910,7 +910,7 @@ datum/status_effect/stabilized/blue/on_remove() return ..() /datum/status_effect/stabilized/lightpink/on_remove() - owner.remove_movespeed_modifier(MOVESPEED_ID_SLIME_STATUS) + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/lightpink) /datum/status_effect/stabilized/adamantine id = "stabilizedadamantine" diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm index e040ea422a4..98cafcb0bda 100644 --- a/code/modules/station_goals/dna_vault.dm +++ b/code/modules/station_goals/dna_vault.dm @@ -248,8 +248,6 @@ else return ..() - - /obj/machinery/dna_vault/proc/upgrade(mob/living/carbon/human/H,upgrade_type) if(!(upgrade_type in power_lottery[H])) return diff --git a/tgstation.dme b/tgstation.dme index 7642b2722b8..6e500d532af 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2381,9 +2381,9 @@ #include "code\modules\movespeed\_movespeed_modifier.dm" #include "code\modules\movespeed\modifiers\components.dm" #include "code\modules\movespeed\modifiers\innate.dm" +#include "code\modules\movespeed\modifiers\mobs.dm" #include "code\modules\movespeed\modifiers\reagent.dm" #include "code\modules\movespeed\modifiers\status_effects.dm" -#include "code\modules\movespeed\modifiers\variable.dm" #include "code\modules\ninja\__ninjaDefines.dm" #include "code\modules\ninja\energy_katana.dm" #include "code\modules\ninja\ninja_event.dm" From 63d54e3e4f828abcc47d9b1b665f818a38d273dc Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 22:11:29 -0800 Subject: [PATCH 08/34] PAIN --- .../configuration/entries/game_options.dm | 10 +++ code/datums/components/riding.dm | 4 +- code/datums/elements/snail_crawl.dm | 2 +- code/game/objects/items/tanks/jetpack.dm | 4 +- .../changeling/powers/strained_muscles.dm | 2 +- .../awaymissions/mission_code/Academy.dm | 2 +- code/modules/mob/living/carbon/carbon.dm | 4 +- code/modules/mob/living/carbon/human/human.dm | 2 +- .../mob/living/carbon/human/species.dm | 15 ++-- code/modules/mob/living/living.dm | 4 +- code/modules/mob/living/living_movement.dm | 25 ++---- .../simple_animal/hostile/giant_spider.dm | 4 +- .../mob/living/simple_animal/simple_animal.dm | 4 +- .../mob/living/simple_animal/slime/slime.dm | 8 +- code/modules/mob/mob.dm | 14 ++- code/modules/mob/mob_movement.dm | 4 +- code/modules/movespeed/_movespeed_modifier.dm | 30 +++---- code/modules/movespeed/modifiers/innate.dm | 14 +++ code/modules/movespeed/modifiers/items.dm | 15 ++++ code/modules/movespeed/modifiers/misc.dm | 3 + code/modules/movespeed/modifiers/mobs.dm | 90 ++++++++++++++++++- .../crossbreeding/_status_effects.dm | 2 +- code/modules/station_goals/dna_vault.dm | 2 +- code/modules/surgery/organs/augments_chest.dm | 4 +- tgstation.dme | 2 + 25 files changed, 194 insertions(+), 76 deletions(-) create mode 100644 code/modules/movespeed/modifiers/items.dm create mode 100644 code/modules/movespeed/modifiers/misc.dm diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index ac6ab78afb3..b8fa4e456dd 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -241,9 +241,19 @@ /datum/config_entry/number/movedelay/run_delay integer = FALSE +/datum/config_entry/number/movedelay/run_delay/ValidateAndSet() + . = ..() + var/datum/movespeed_modifier/config_walk_run/M = get_cached_movespeed_modifier(/datum/movespeed_modifier/config_walk_run/run) + M.sync() + /datum/config_entry/number/movedelay/walk_delay integer = FALSE +/datum/config_entry/number/movedelay/walk_delay/ValidateAndSet() + . = ..() + var/datum/movespeed_modifier/config_walk_run/M = get_cached_movespeed_modifier(/datum/movespeed_modifier/config_walk_run/walk) + M.sync() + /////////////////////////////////////////////////Outdated move delay /datum/config_entry/number/outdated_movedelay deprecated_by = /datum/config_entry/keyed_list/multiplicative_movespeed diff --git a/code/datums/components/riding.dm b/code/datums/components/riding.dm index c8c916e465a..b4248189d23 100644 --- a/code/datums/components/riding.dm +++ b/code/datums/components/riding.dm @@ -212,13 +212,13 @@ /datum/component/riding/human/vehicle_mob_unbuckle(datum/source, mob/living/M, force = FALSE) var/mob/living/carbon/human/H = parent - H.remove_movespeed_modifier(MOVESPEED_ID_HUMAN_CARRYING) + H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/human_carry) . = ..() /datum/component/riding/human/vehicle_mob_buckle(datum/source, mob/living/M, force = FALSE) . = ..() var/mob/living/carbon/human/H = parent - H.add_movespeed_modifier(MOVESPEED_ID_HUMAN_CARRYING, multiplicative_slowdown = HUMAN_CARRY_SLOWDOWN) + H._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/human_carry) /datum/component/riding/human/proc/on_host_unarmed_melee(atom/target) var/mob/living/carbon/human/H = parent diff --git a/code/datums/elements/snail_crawl.dm b/code/datums/elements/snail_crawl.dm index 4f30524254e..d8e6341e975 100644 --- a/code/datums/elements/snail_crawl.dm +++ b/code/datums/elements/snail_crawl.dm @@ -16,7 +16,7 @@ . = ..() UnregisterSignal(target, COMSIG_MOVABLE_MOVED) if(istype(target)) - target.remove_movespeed_modifier(MOVESPEED_ID_SNAIL_CRAWL) + target._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) /datum/element/snailcrawl/proc/snail_crawl(mob/living/carbon/snail) if(snail.resting && !snail.buckled && lubricate(snail)) diff --git a/code/game/objects/items/tanks/jetpack.dm b/code/game/objects/items/tanks/jetpack.dm index e44b22581c8..198fd4329a6 100644 --- a/code/game/objects/items/tanks/jetpack.dm +++ b/code/game/objects/items/tanks/jetpack.dm @@ -56,7 +56,7 @@ ion_trail.start() RegisterSignal(user, COMSIG_MOVABLE_MOVED, .proc/move_react) if(full_speed) - user.add_movespeed_modifier(MOVESPEED_ID_JETPACK, priority=100, multiplicative_slowdown=-0.5, movetypes=FLOATING, conflict=MOVE_CONFLICT_JETPACK) + user._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed) /obj/item/tank/jetpack/proc/turn_off(mob/user) on = FALSE @@ -64,7 +64,7 @@ icon_state = initial(icon_state) ion_trail.stop() UnregisterSignal(user, COMSIG_MOVABLE_MOVED) - user.remove_movespeed_modifier(MOVESPEED_ID_JETPACK) + user._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed) /obj/item/tank/jetpack/proc/move_react(mob/user) allow_thrust(0.01, user) diff --git a/code/modules/antagonists/changeling/powers/strained_muscles.dm b/code/modules/antagonists/changeling/powers/strained_muscles.dm index 51f1d65d383..cf2c73aa1a0 100644 --- a/code/modules/antagonists/changeling/powers/strained_muscles.dm +++ b/code/modules/antagonists/changeling/powers/strained_muscles.dm @@ -18,7 +18,7 @@ if(active) to_chat(user, "Our muscles tense and strengthen.") else - user.remove_movespeed_modifier(MOVESPEED_ID_CHANGELING_MUSCLES) + user._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) to_chat(user, "Our muscles relax.") if(stacks >= 10) to_chat(user, "We collapse in exhaustion.") diff --git a/code/modules/awaymissions/mission_code/Academy.dm b/code/modules/awaymissions/mission_code/Academy.dm index cebfc1641cd..833776486e2 100644 --- a/code/modules/awaymissions/mission_code/Academy.dm +++ b/code/modules/awaymissions/mission_code/Academy.dm @@ -252,7 +252,7 @@ if(6) //Cut speed T.visible_message("[user] starts moving slower!") - user.add_movespeed_modifier(MOVESPEED_ID_DIE_OF_FATE, update=TRUE, priority=100, multiplicative_slowdown=1) + user._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/die_of_fate) if(7) //Throw T.visible_message("Unseen forces throw [user]!") diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index d6de331c403..a6e3fb7ec39 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -526,9 +526,9 @@ med_hud_set_health() if(stat == SOFT_CRIT) - add_movespeed_modifier(MOVESPEED_ID_CARBON_SOFTCRIT, TRUE, multiplicative_slowdown = SOFTCRIT_ADD_SLOWDOWN) + _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit) else - remove_movespeed_modifier(MOVESPEED_ID_CARBON_SOFTCRIT, TRUE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit) /mob/living/carbon/update_stamina() var/stam = getStaminaLoss() diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index fcedbba7d61..f53689f1f04 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1018,7 +1018,7 @@ return FALSE /mob/living/carbon/human/proc/clear_shove_slowdown() - remove_movespeed_modifier(MOVESPEED_ID_SHOVE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/shove) var/active_item = get_active_held_item() if(is_type_in_typecache(active_item, GLOB.shove_disarming_types)) visible_message("[src.name] regains their grip on \the [active_item]!", "You regain your grip on \the [active_item]", null, COMBAT_MESSAGE_RANGE) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 3f04b2df013..7841c02e0e9 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -318,11 +318,10 @@ GLOBAL_LIST_EMPTY(roundstart_races) fly = new fly.Grant(C) - C.add_movespeed_modifier(MOVESPEED_ID_SPECIES, TRUE, 100, override=TRUE, multiplicative_slowdown=speedmod, movetypes=(~FLYING)) + C.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/species, multiplicative_slowdown=speedmod) SEND_SIGNAL(C, COMSIG_SPECIES_GAIN, src, old_species) - /datum/species/proc/on_species_loss(mob/living/carbon/human/C, datum/species/new_species, pref_load) if(C.dna.species.exotic_bloodtype) C.dna.blood_type = random_blood_type() @@ -354,7 +353,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) C.dna.features["wings"] = "None" C.update_body() - C.remove_movespeed_modifier(MOVESPEED_ID_SPECIES) + C._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/species) SEND_SIGNAL(C, COMSIG_SPECIES_LOSS, src) @@ -1378,8 +1377,8 @@ GLOBAL_LIST_EMPTY(roundstart_races) var/knocked_item = FALSE if(!is_type_in_typecache(target_held_item, GLOB.shove_disarming_types)) target_held_item = null - if(!target.has_movespeed_modifier(MOVESPEED_ID_SHOVE)) - target.add_movespeed_modifier(MOVESPEED_ID_SHOVE, multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH) + if(!target._REFACTORING_has_movespeed_modifier(/datum/movespeed_modifier/shove)) + target._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/shove) if(target_held_item) target.visible_message("[target.name]'s grip on \the [target_held_item] loosens!", "Your grip on \the [target_held_item] loosens!", null, COMBAT_MESSAGE_RANGE) @@ -1644,7 +1643,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold") SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "hot", /datum/mood_event/hot) - H.remove_movespeed_modifier(MOVESPEED_ID_COLD) + H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/cold) var/burn_damage var/firemodifier = H.fire_stacks / 50 @@ -1670,7 +1669,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot") SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "cold", /datum/mood_event/cold) //Sorry for the nasty oneline but I don't want to assign a variable on something run pretty frequently - H.add_movespeed_modifier(MOVESPEED_ID_COLD, override = TRUE, multiplicative_slowdown = ((BODYTEMP_COLD_DAMAGE_LIMIT - H.bodytemperature) / COLD_SLOWDOWN_FACTOR), blacklisted_movetypes = FLOATING) + H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/cold, multiplicative_slowdown = ((BODYTEMP_COLD_DAMAGE_LIMIT - H.bodytemperature) / COLD_SLOWDOWN_FACTOR)) switch(H.bodytemperature) if(200 to BODYTEMP_COLD_DAMAGE_LIMIT) H.throw_alert("temp", /obj/screen/alert/cold, 1) @@ -1684,7 +1683,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) else H.clear_alert("temp") - H.remove_movespeed_modifier(MOVESPEED_ID_COLD) + H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/cold) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold") SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot") diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index 9f6ddea959f..b5e3dbc5634 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1208,9 +1208,9 @@ if(!has_legs && has_arms < 2) limbless_slowdown += 6 - (has_arms * 3) if(limbless_slowdown) - add_movespeed_modifier(MOVESPEED_ID_LIVING_LIMBLESS, update=TRUE, priority=100, override=TRUE, multiplicative_slowdown=limbless_slowdown, movetypes=GROUND) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/limbless, multiplicative_slowdown = limbless_slowdown) else - remove_movespeed_modifier(MOVESPEED_ID_LIVING_LIMBLESS, update=TRUE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/limbless) /mob/living/proc/fall(forced) if(!(mobility_flags & MOBILITY_USE)) diff --git a/code/modules/mob/living/living_movement.dm b/code/modules/mob/living/living_movement.dm index 89ce99f58ec..8dde0fdcebb 100644 --- a/code/modules/mob/living/living_movement.dm +++ b/code/modules/mob/living/living_movement.dm @@ -26,38 +26,31 @@ return ..() /mob/living/proc/update_move_intent_slowdown() - var/mod = 0 - if(m_intent == MOVE_INTENT_WALK) - mod = CONFIG_GET(number/movedelay/walk_delay) - else - mod = CONFIG_GET(number/movedelay/run_delay) - if(!isnum(mod)) - mod = 1 - add_movespeed_modifier(MOVESPEED_ID_MOB_WALK_RUN_CONFIG_SPEED, TRUE, 100, override = TRUE, multiplicative_slowdown = mod) + _REFACTORING_add_movespeed_modifier((m_intent == MOVE_INTENT_WALK)? /datum/movespeed_modifier/config_walk_run/walk : /datum/movespeed_modifier/config_walk_run/run, override = TRUE) /mob/living/proc/update_turf_movespeed(turf/open/T) - if(isopenturf(T)) - add_movespeed_modifier(MOVESPEED_ID_LIVING_TURF_SPEEDMOD, update=TRUE, priority=100, override=TRUE, multiplicative_slowdown=T.slowdown, movetypes=GROUND) + if(istype(T)) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown, multiplicative_slowdown = T.slowdown) else - remove_movespeed_modifier(MOVESPEED_ID_LIVING_TURF_SPEEDMOD) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown) /mob/living/proc/update_pull_movespeed() if(pulling) if(isliving(pulling)) var/mob/living/L = pulling if(!slowed_by_drag || (L.mobility_flags & MOBILITY_STAND) || L.buckled || grab_state >= GRAB_AGGRESSIVE) - remove_movespeed_modifier(MOVESPEED_ID_BULKY_DRAGGING) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) return - add_movespeed_modifier(MOVESPEED_ID_BULKY_DRAGGING, multiplicative_slowdown = PULL_PRONE_SLOWDOWN) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/bulky_drag, multiplicative_slowdown = PULL_PRONE_SLOWDOWN) return if(isobj(pulling)) var/obj/structure/S = pulling if(!slowed_by_drag || !S.drag_slowdown) - remove_movespeed_modifier(MOVESPEED_ID_BULKY_DRAGGING) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) return - add_movespeed_modifier(MOVESPEED_ID_BULKY_DRAGGING, multiplicative_slowdown = S.drag_slowdown) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/bulky_drag, multiplicative_slowdown = S.drag_slowdown) return - remove_movespeed_modifier(MOVESPEED_ID_BULKY_DRAGGING) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) /mob/living/can_zFall(turf/T, levels) return ..() diff --git a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm index a0db19cd2f2..290b57438e1 100644 --- a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm +++ b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm @@ -206,10 +206,10 @@ . = ..() if(slowed_by_webs) if(!(locate(/obj/structure/spider/stickyweb) in loc)) - remove_movespeed_modifier(MOVESPEED_ID_TARANTULA_WEB) + remove_movespeed_modifier(/datum/movespeed_modifier/tarantula_web) slowed_by_webs = FALSE else if(locate(/obj/structure/spider/stickyweb) in loc) - add_movespeed_modifier(MOVESPEED_ID_TARANTULA_WEB, priority=100, multiplicative_slowdown=3) + add_movespeed_modifier(/datum/movespeed_modifier/tarantula_web) slowed_by_webs = TRUE /mob/living/simple_animal/hostile/poison/giant_spider/ice //spiders dont usually like tempatures of 140 kelvin who knew diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 0f45982d030..27ce3a64a89 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -367,8 +367,8 @@ /mob/living/simple_animal/proc/update_simplemob_varspeed() if(speed == 0) - remove_movespeed_modifier(MOVESPEED_ID_SIMPLEMOB_VARSPEED, TRUE) - add_movespeed_modifier(MOVESPEED_ID_SIMPLEMOB_VARSPEED, TRUE, 100, multiplicative_slowdown = speed, override = TRUE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/simplemob_varspeed) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/simplemob_varspeed, multiplicative_slowdown = speed) /mob/living/simple_animal/Stat() ..() diff --git a/code/modules/mob/living/simple_animal/slime/slime.dm b/code/modules/mob/living/simple_animal/slime/slime.dm index f34194de8cd..247466a4f0a 100644 --- a/code/modules/mob/living/simple_animal/slime/slime.dm +++ b/code/modules/mob/living/simple_animal/slime/slime.dm @@ -145,14 +145,14 @@ /mob/living/simple_animal/slime/on_reagent_change() . = ..() - remove_movespeed_modifier(MOVESPEED_ID_SLIME_REAGENTMOD, TRUE) + remove_movespeed_modifier(/datum/movespeed_modifier/slime_reagentmod) var/amount = 0 if(reagents.has_reagent(/datum/reagent/medicine/morphine)) // morphine slows slimes down amount = 2 if(reagents.has_reagent(/datum/reagent/consumable/frostoil)) // Frostoil also makes them move VEEERRYYYYY slow amount = 5 if(amount) - add_movespeed_modifier(MOVESPEED_ID_SLIME_REAGENTMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = amount) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/slime_reagentmod, multiplicative_slowdown = amount) /mob/living/simple_animal/slime/updatehealth() . = ..() @@ -163,7 +163,7 @@ mod += (health_deficiency / 25) if(health <= 0) mod += 2 - add_movespeed_modifier(MOVESPEED_ID_SLIME_HEALTHMOD, TRUE, 100, multiplicative_slowdown = mod, override = TRUE) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/slime_healthmod, multiplicative_slowdown = mod) update_health_hud() /mob/living/simple_animal/slime/update_health_hud() @@ -204,7 +204,7 @@ else if(bodytemperature < 283.222) mod = ((283.222 - bodytemperature) / 10) * 1.75 if(mod) - add_movespeed_modifier(MOVESPEED_ID_SLIME_TEMPMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = mod) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/slime_tempmod, multiplicative_slowdown = mod) /mob/living/simple_animal/slime/ObjBump(obj/O) if(!client && powerlevel > 0) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 9d68c3290cc..413177f8e0b 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1232,16 +1232,22 @@ /mob/setGrabState(newstate) . = ..() if(grab_state == GRAB_PASSIVE) - remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAB_STATE, update=TRUE) + _REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAB_STATE) else - add_movespeed_modifier(MOVESPEED_ID_MOB_GRAB_STATE, update=TRUE, priority=100, override=TRUE, multiplicative_slowdown=grab_state*3, blacklisted_movetypes=FLOATING) + switch(grab_state) + if(GRAB_AGGRESSIVE) + _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/aggressive) + if(GRAB_NECK) + _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/neck) + if(GRAB_KILL) + _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/kill) /mob/proc/update_equipment_speed_mods() var/speedies = equipped_speed_mods() if(!speedies) - remove_movespeed_modifier(MOVESPEED_ID_MOB_EQUIPMENT, update=TRUE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/equipment_speedmod) else - add_movespeed_modifier(MOVESPEED_ID_MOB_EQUIPMENT, update=TRUE, priority=100, override=TRUE, multiplicative_slowdown=speedies, blacklisted_movetypes=FLOATING) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/equipment_speedmod, multiplicative_slowdown = speedies) /// Gets the combined speed modification of all worn items /// Except base mob type doesnt really wear items diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 4f49da4c02a..9330926db99 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -330,9 +330,9 @@ /mob/proc/update_gravity(has_gravity, override=FALSE) var/speed_change = max(0, has_gravity - STANDARD_GRAVITY) if(!speed_change) - remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAVITY, update=TRUE) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/gravity) else - add_movespeed_modifier(MOVESPEED_ID_MOB_GRAVITY, update=TRUE, priority=100, override=TRUE, multiplicative_slowdown=speed_change, blacklisted_movetypes=FLOATING) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/gravity, multiplicative_slowdown=speed_change) //bodypart selection verbs - Cyberboss //8:repeated presses toggles through head - eyes - mouth diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 6f00153abc4..7725260c628 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -64,7 +64,7 @@ Key procs GLOBAL_LIST_EMPTY(movespeed_modification_cache) /// Grabs a STATIC MODIFIER datum from cache. YOU MUST NEVER EDIT THESE DATUMS, OR IT WILL AFFECT ANYTHING ELSE USING IT TOO! -/proc/get_cached_movespeed_modification(modtype) +/proc/get_cached_movespeed_modifier(modtype) if(!ispath(modtype, /datum/movespeed_modifier)) CRASH("[modtype] is not a movespeed modification typepath.") var/datum/movespeed_modifier/M = modtype @@ -73,13 +73,11 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) return GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) ///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. -/mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE, override = FALSE) - var/created = FALSE +/mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE) if(ispath(type_or_datum)) if(!initial(type_or_datum.variable)) - type_or_datum = get_cached_movespeed_modification(type_or_datum) + type_or_datum = get_cached_movespeed_modifier(type_or_datum) else - created = TRUE type_or_datum = new type_or_datum if(!istype(type_or_datum)) CRASH("Invalid modification datum") @@ -88,10 +86,6 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(existing) if(existing == type_or_datum) //same thing don't need to touch return TRUE - if(!override) //not overriding, do not overwrite same ID. - if(created) //make sure we clean up after ourselves. - qdel(type_or_datum) - return FALSE oldpriority = existing.priority remove_movespeed_modifier(existing, FALSE) LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) @@ -104,7 +98,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) /mob/proc/_REFACTORING_remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) if(ispath(type_id_datum)) if(!initial(type_id_datum.variable)) - type_id_datum = get_cached_movespeed_modification(type_id_datum) + type_id_datum = get_cached_movespeed_modifier(type_id_datum) else type_id_datum = initial(type_id_datum.id) if(istype(type_id_datum)) @@ -119,8 +113,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) update_movespeed(FALSE) return TRUE -/// Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. -/// Implies override. +/// Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. Implies override. Returns the modifier datum if successful /mob/proc/add_or_update_variable_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE, multiplicative_slowdown) /* How this SHOULD work is: @@ -130,7 +123,6 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) 4. If any of the rest of the args are not null (see: multiplicative slowdown), modify the datum 5. Update if necessary */ - . = FALSE var/modified = FALSE var/inject = FALSE var/datum/movespeed_modifier/final @@ -142,7 +134,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(!initial(type_id_datum.variable)) CRASH("Not a variable modifier") var/id = initial(type_id_datum.id) - final = LAZYACCESS(movespeed_modification, type_id_datum) + final = LAZYACCESS(movespeed_modification, id) if(!istype(final)) final = new inject = TRUE @@ -163,23 +155,23 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) _REFACTORING_add_movespeed_modifier(final, FALSE, TRUE) if(update && modified) update_movespeed(TRUE) - return TRUE + return final ///Handles the special case of editing the movement var /mob/vv_edit_var(var_name, var_value) var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown)) var/diff if(slowdown_edit && isnum(cached_multiplicative_slowdown) && isnum(var_value)) - remove_movespeed_modifier(MOVESPEED_ID_ADMIN_VAREDIT) + _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/admin_varedit) diff = var_value - cached_multiplicative_slowdown . = ..() if(. && slowdown_edit && isnum(diff)) - add_movespeed_modifier(MOVESPEED_ID_ADMIN_VAREDIT, TRUE, 100, override = TRUE, multiplicative_slowdown = diff) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/admin_varedit, multiplicative_slowdown = diff) ///Is there a movespeed modifier for this mob -/mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) +/mob/proc/_REFACTORING_has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) if(ispath(datum_type_id)) - datum_type_id = get_cached_movespeed_modification(datum_type_id) + datum_type_id = get_cached_movespeed_modifier(datum_type_id) if(istype(datum_type_id)) datum_type_id = datum_type_id.id return LAZYACCESS(movespeed_modification, datum_type_id) diff --git a/code/modules/movespeed/modifiers/innate.dm b/code/modules/movespeed/modifiers/innate.dm index d11c51f9f80..cd4b4601f82 100644 --- a/code/modules/movespeed/modifiers/innate.dm +++ b/code/modules/movespeed/modifiers/innate.dm @@ -2,3 +2,17 @@ id = MOVESPEED_ID_CHANGELING_MUSCLES multiplicative_slowdown = -1 blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/pai_spacewalk + id = MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD + multiplicative_slowdown = 2 + +/datum/movespeed_modifier/species + id = MOVESPEED_ID_SPECIES + movetypes = ~FLYING + variable = TRUE + +/datum/movespeed_modifier/dna_vault_speedup + id = MOVESPEED_ID_DNA_VAULT + blacklisted_movetypes = (FLYING|FLOATING) + multiplicative_slowdown = -0.4 diff --git a/code/modules/movespeed/modifiers/items.dm b/code/modules/movespeed/modifiers/items.dm new file mode 100644 index 00000000000..d1ec480b465 --- /dev/null +++ b/code/modules/movespeed/modifiers/items.dm @@ -0,0 +1,15 @@ +/datum/movespeed_modifier/jetpack + conflicts_with = MOVE_CONFLICT_JETPACK + movetypes = FLOATING + +/datum/movespeed_modifier/jetpack/cybernetic + id = MOVESPEED_ID_CYBER_THRUSTER + multiplicative_slowdown = -0.5 + +/datum/movespeed_modifier/jetpack/fullspeed + id = MOVESPEED_ID_JETPACK + multiplicative_slowdown = -0.5 + +/datum/movespeed_modifier/die_of_fate + id = MOVESPEED_ID_DIE_OF_FATE + multiplicative_slowdown = 1 diff --git a/code/modules/movespeed/modifiers/misc.dm b/code/modules/movespeed/modifiers/misc.dm new file mode 100644 index 00000000000..548b35708a7 --- /dev/null +++ b/code/modules/movespeed/modifiers/misc.dm @@ -0,0 +1,3 @@ +/datum/movespeed_modifier/admin_varedit + variable = TRUE + id = MOVESPEED_ID_ADMIN_VAREDIT diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm index 23084dc0ea2..164dc57c506 100644 --- a/code/modules/movespeed/modifiers/mobs.dm +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -30,6 +30,90 @@ id = MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING movetypes = FLOATING -/datum/movespeed_modifier/pai_spacewalk - id = MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD - multiplicative_slowdown = 2 +/datum/movespeed_modifier/equipment_speedmod + variable = TRUE + id = MOVESPEED_ID_MOB_EQUIPMENT + blacklisted_movetypes = FLOATING + +/datum/movespeed_modifier/grab_slowdown + id = MOVESPEED_ID_MOB_GRAB_STATE + blacklisted_movetypes = FLOATING + +/datum/movespeed_modifier/grab_slowdown/aggressive + multiplicative_slowdown = 3 + +/datum/movespeed_modifier/grab_slowdown/neck + multiplicative_slowdown = 6 + +/datum/movespeed_modifier/grab_slowdown/kill + multiplicative_slowdown = 9 + +/datum/movespeed_modifier/slime_reagentmod + id = MOVESPEED_ID_SLIME_REAGENTMOD + variable = TRUE + +/datum/movespeed_modifier/slime_healthmod + id = MOVESPEED_ID_SLIME_HEALTHMOD + variable = TRUE + +/datum/movespeed_modifier/config_walk_run + id = MOVESPEED_ID_MOB_WALK_RUN_CONFIG_SPEED + multiplicative_slowdown = 1 + +/datum/movespeed_modifier/config_walk_run/proc/sync() + +/datum/movespeed_modifier/config_walk_run/walk/sync() + var/mod = CONFIG_GET(number/movedelay/walk_delay) + multiplicative_slowdown = isnum(mod)? mod : initial(multiplicative_slowdown) + +/datum/movespeed_modifier/config_walk_run/run/sync() + var/mod = CONFIG_GET(number/movedelay/run_delay) + multiplicative_slowdown = isnum(mod)? mod : initial(multiplicative_slowdown) + +/datum/movespeed_modifier/turf_slowdown + id = MOVESPEED_ID_LIVING_TURF_SPEEDMOD + movetypes = GROUND + variable = TRUE + +/datum/movespeed_modifier/bulky_drag + id = MOVESPEED_ID_BULKY_DRAGGING + variable = TRUE + +/datum/movespeed_modifier/cold + id = MOVESPEED_ID_COLD + blacklisted_movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/shove + id = MOVESPEED_ID_SHOVE + multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH + +/datum/movespeed_modifier/human_carry + id = MOVESPEED_ID_HUMAN_CARRYING + multiplicative_slowdown = HUMAN_CARRY_SLOWDOWN + +/datum/movespeed_modifier/limbless + id = MOVESPEED_ID_LIVING_LIMBLESS + variable = TRUE + movetypes = GROUND + +/datum/movespeed_modifier/simplemob_varspeed + id = MOVESPEED_ID_SIMPLEMOB_VARSPEED + variable = TRUE + +/datum/movespeed_modifier/tarantula_web + id = MOVESPEED_ID_TARANTULA_WEB + multiplicative_slowdown = 3 + +/datum/movespeed_modifier/gravity + id = MOVESPEED_ID_MOB_GRAVITY + blacklisted_movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/carbon_softcrit + id = MOVESPEED_ID_CARBON_SOFTCRIT + multiplicative_slowdown = SOFTCRIT_ADD_SLOWDOWN + +/datum/movespeed_modifier/slime_tempmod + id = MOVESPEED_ID_SLIME_TEMPMOD + variable = TRUE diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm index cf5a55d1287..785a93f9e0f 100644 --- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm +++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm @@ -683,7 +683,7 @@ datum/status_effect/stabilized/blue/on_remove() /datum/status_effect/stabilized/sepia/tick() if(prob(50) && mod > -1) mod-- - owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia, multiplicative_slowdown = -0.5) + owner.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia, multiplicative_slowdown = -0.5) else if(mod < 1) mod++ // yeah a value of 0 does nothing but replacing the trait in place is cheaper than removing and adding repeatedly diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm index 98cafcb0bda..71708bc91cd 100644 --- a/code/modules/station_goals/dna_vault.dm +++ b/code/modules/station_goals/dna_vault.dm @@ -277,7 +277,7 @@ ADD_TRAIT(H, TRAIT_PIERCEIMMUNE, "dna_vault") if(VAULT_SPEED) to_chat(H, "Your legs feel faster.") - H.add_movespeed_modifier(MOVESPEED_ID_DNA_VAULT, update=TRUE, priority=100, multiplicative_slowdown=-0.4, blacklisted_movetypes=(FLYING|FLOATING)) + H._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/dna_vault_speedup) if(VAULT_QUICK) to_chat(H, "Your arms move as fast as lightning.") H.next_move_modifier = 0.5 diff --git a/code/modules/surgery/organs/augments_chest.dm b/code/modules/surgery/organs/augments_chest.dm index 69d4c8ffc2e..eb51bc15417 100644 --- a/code/modules/surgery/organs/augments_chest.dm +++ b/code/modules/surgery/organs/augments_chest.dm @@ -152,13 +152,13 @@ if(allow_thrust(0.01)) ion_trail.start() RegisterSignal(owner, COMSIG_MOVABLE_MOVED, .proc/move_react) - owner.add_movespeed_modifier(MOVESPEED_ID_CYBER_THRUSTER, priority=100, multiplicative_slowdown=-0.5, movetypes=FLOATING, conflict=MOVE_CONFLICT_JETPACK) + owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) if(!silent) to_chat(owner, "You turn your thrusters set on.") else ion_trail.stop() UnregisterSignal(owner, COMSIG_MOVABLE_MOVED) - owner.remove_movespeed_modifier(MOVESPEED_ID_CYBER_THRUSTER) + owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) if(!silent) to_chat(owner, "You turn your thrusters set off.") on = FALSE diff --git a/tgstation.dme b/tgstation.dme index 6e500d532af..d31ff93dbac 100644 --- a/tgstation.dme +++ b/tgstation.dme @@ -2381,6 +2381,8 @@ #include "code\modules\movespeed\_movespeed_modifier.dm" #include "code\modules\movespeed\modifiers\components.dm" #include "code\modules\movespeed\modifiers\innate.dm" +#include "code\modules\movespeed\modifiers\items.dm" +#include "code\modules\movespeed\modifiers\misc.dm" #include "code\modules\movespeed\modifiers\mobs.dm" #include "code\modules\movespeed\modifiers\reagent.dm" #include "code\modules\movespeed\modifiers\status_effects.dm" From ce02e45ecb275ba869f64196e370fd5664b7061a Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 22:12:07 -0800 Subject: [PATCH 09/34] get rid of refactor tags --- code/datums/components/mood.dm | 12 ++++++------ code/datums/components/riding.dm | 4 ++-- code/datums/components/shrink.dm | 4 ++-- code/datums/elements/snail_crawl.dm | 6 +++--- code/game/objects/effects/mines.dm | 4 ++-- code/game/objects/items/tanks/jetpack.dm | 4 ++-- .../changeling/powers/strained_muscles.dm | 6 +++--- .../modules/antagonists/slaughter/slaughter.dm | 4 ++-- .../awaymissions/mission_code/Academy.dm | 2 +- code/modules/mob/living/carbon/carbon.dm | 8 ++++---- code/modules/mob/living/carbon/human/human.dm | 10 +++++----- .../modules/mob/living/carbon/human/species.dm | 16 ++++++++-------- code/modules/mob/living/living.dm | 2 +- code/modules/mob/living/living_movement.dm | 10 +++++----- code/modules/mob/living/silicon/pai/pai.dm | 4 ++-- .../mob/living/simple_animal/simple_animal.dm | 2 +- code/modules/mob/mob.dm | 10 +++++----- code/modules/mob/mob_movement.dm | 2 +- code/modules/movespeed/_movespeed_modifier.dm | 10 +++++----- .../reagents/cat2_medicine_reagents.dm | 4 ++-- .../chemistry/reagents/drink_reagents.dm | 8 ++++---- .../chemistry/reagents/drug_reagents.dm | 4 ++-- .../chemistry/reagents/food_reagents.dm | 4 ++-- .../chemistry/reagents/medicine_reagents.dm | 16 ++++++++-------- .../chemistry/reagents/other_reagents.dm | 4 ++-- .../crossbreeding/_status_effects.dm | 18 +++++++++--------- code/modules/station_goals/dna_vault.dm | 2 +- code/modules/surgery/organs/augments_chest.dm | 4 ++-- 28 files changed, 92 insertions(+), 92 deletions(-) diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index 3cfc773cfa7..42ce42434db 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -208,27 +208,27 @@ switch(sanity) if(SANITY_INSANE to SANITY_CRAZY) setInsanityEffect(MAJOR_INSANITY_PEN) - master._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/sanity/insane, override = TRUE) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/insane, override = TRUE) sanity_level = 6 if(SANITY_CRAZY to SANITY_UNSTABLE) setInsanityEffect(MINOR_INSANITY_PEN) - master._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/sanity/crazy, override = TRUE) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/crazy, override = TRUE) sanity_level = 5 if(SANITY_UNSTABLE to SANITY_DISTURBED) setInsanityEffect(0) - master._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/sanity/disturbed, override = TRUE) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/disturbed, override = TRUE) sanity_level = 4 if(SANITY_DISTURBED to SANITY_NEUTRAL) setInsanityEffect(0) - master._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SANITY) + master.remove_movespeed_modifier(MOVESPEED_ID_SANITY) sanity_level = 3 if(SANITY_NEUTRAL+1 to SANITY_GREAT+1) //shitty hack but +1 to prevent it from responding to super small differences setInsanityEffect(0) - master._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SANITY) + master.remove_movespeed_modifier(MOVESPEED_ID_SANITY) sanity_level = 2 if(SANITY_GREAT+1 to INFINITY) setInsanityEffect(0) - master._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SANITY) + master.remove_movespeed_modifier(MOVESPEED_ID_SANITY) sanity_level = 1 update_mood_icon() diff --git a/code/datums/components/riding.dm b/code/datums/components/riding.dm index b4248189d23..05629e8ae54 100644 --- a/code/datums/components/riding.dm +++ b/code/datums/components/riding.dm @@ -212,13 +212,13 @@ /datum/component/riding/human/vehicle_mob_unbuckle(datum/source, mob/living/M, force = FALSE) var/mob/living/carbon/human/H = parent - H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/human_carry) + H.remove_movespeed_modifier(/datum/movespeed_modifier/human_carry) . = ..() /datum/component/riding/human/vehicle_mob_buckle(datum/source, mob/living/M, force = FALSE) . = ..() var/mob/living/carbon/human/H = parent - H._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/human_carry) + H.add_movespeed_modifier(/datum/movespeed_modifier/human_carry) /datum/component/riding/human/proc/on_host_unarmed_melee(atom/target) var/mob/living/carbon/human/H = parent diff --git a/code/datums/components/shrink.dm b/code/datums/components/shrink.dm index 155c27a9035..157eb36c373 100644 --- a/code/datums/components/shrink.dm +++ b/code/datums/components/shrink.dm @@ -14,7 +14,7 @@ parent_atom.opacity = 0 if(isliving(parent_atom)) var/mob/living/L = parent_atom - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/shrink_ray) + L.add_movespeed_modifier(/datum/movespeed_modifier/shrink_ray) if(iscarbon(L)) var/mob/living/carbon/C = L C.unequip_everything() @@ -34,7 +34,7 @@ parent_atom.opacity = oldopac if(isliving(parent_atom)) var/mob/living/L = parent_atom - L._REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_SHRINK_RAY) + L.remove_movespeed_modifier(MOVESPEED_ID_SHRINK_RAY) if(ishuman(L)) var/mob/living/carbon/human/H = L H.physiology.damage_resistance += 100 diff --git a/code/datums/elements/snail_crawl.dm b/code/datums/elements/snail_crawl.dm index d8e6341e975..b726c55e425 100644 --- a/code/datums/elements/snail_crawl.dm +++ b/code/datums/elements/snail_crawl.dm @@ -16,13 +16,13 @@ . = ..() UnregisterSignal(target, COMSIG_MOVABLE_MOVED) if(istype(target)) - target._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) + target.remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) /datum/element/snailcrawl/proc/snail_crawl(mob/living/carbon/snail) if(snail.resting && !snail.buckled && lubricate(snail)) - snail._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) + snail.add_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) else - snail._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) + snail.remove_movespeed_modifier(/datum/movespeed_modifier/snail_crawl) /datum/element/snailcrawl/proc/lubricate(atom/movable/snail) var/turf/open/OT = get_turf(snail) diff --git a/code/game/objects/effects/mines.dm b/code/game/objects/effects/mines.dm index 4b98939b353..f31e849b67b 100644 --- a/code/game/objects/effects/mines.dm +++ b/code/game/objects/effects/mines.dm @@ -172,9 +172,9 @@ if(!victim.client || !istype(victim)) return to_chat(victim, "You feel fast!") - victim._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) + victim.add_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) sleep(duration) - victim._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) + victim.remove_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) to_chat(victim, "You slow down.") /datum/movespeed_modifier/yellow_orb diff --git a/code/game/objects/items/tanks/jetpack.dm b/code/game/objects/items/tanks/jetpack.dm index 198fd4329a6..a5660c6ca2a 100644 --- a/code/game/objects/items/tanks/jetpack.dm +++ b/code/game/objects/items/tanks/jetpack.dm @@ -56,7 +56,7 @@ ion_trail.start() RegisterSignal(user, COMSIG_MOVABLE_MOVED, .proc/move_react) if(full_speed) - user._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed) + user.add_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed) /obj/item/tank/jetpack/proc/turn_off(mob/user) on = FALSE @@ -64,7 +64,7 @@ icon_state = initial(icon_state) ion_trail.stop() UnregisterSignal(user, COMSIG_MOVABLE_MOVED) - user._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed) + user.remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed) /obj/item/tank/jetpack/proc/move_react(mob/user) allow_thrust(0.01, user) diff --git a/code/modules/antagonists/changeling/powers/strained_muscles.dm b/code/modules/antagonists/changeling/powers/strained_muscles.dm index cf2c73aa1a0..8844c5844c3 100644 --- a/code/modules/antagonists/changeling/powers/strained_muscles.dm +++ b/code/modules/antagonists/changeling/powers/strained_muscles.dm @@ -18,7 +18,7 @@ if(active) to_chat(user, "Our muscles tense and strengthen.") else - user._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) + user.remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) to_chat(user, "Our muscles relax.") if(stacks >= 10) to_chat(user, "We collapse in exhaustion.") @@ -31,12 +31,12 @@ /datum/action/changeling/strained_muscles/proc/muscle_loop(mob/living/carbon/user) while(active) - user._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) + user.add_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) if(user.stat != CONSCIOUS || user.staminaloss >= 90) active = !active to_chat(user, "Our muscles relax without the energy to strengthen them.") user.Paralyze(40) - user._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) + user.remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) break stacks++ diff --git a/code/modules/antagonists/slaughter/slaughter.dm b/code/modules/antagonists/slaughter/slaughter.dm index 127a5bb15a2..61072f6cf9b 100644 --- a/code/modules/antagonists/slaughter/slaughter.dm +++ b/code/modules/antagonists/slaughter/slaughter.dm @@ -67,8 +67,8 @@ /mob/living/simple_animal/slaughter/phasein() . = ..() - _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/slaughter) - addtimer(CALLBACK(src, .proc/_REFACTORING_remove_movespeed_modifier, /datum/movespeed_modifier/slaughter), 6 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE) + add_movespeed_modifier(/datum/movespeed_modifier/slaughter) + addtimer(CALLBACK(src, .proc/remove_movespeed_modifier, /datum/movespeed_modifier/slaughter), 6 SECONDS, TIMER_UNIQUE | TIMER_OVERRIDE) //The loot from killing a slaughter demon - can be consumed to allow the user to blood crawl /obj/item/organ/heart/demon diff --git a/code/modules/awaymissions/mission_code/Academy.dm b/code/modules/awaymissions/mission_code/Academy.dm index 833776486e2..a3be1020169 100644 --- a/code/modules/awaymissions/mission_code/Academy.dm +++ b/code/modules/awaymissions/mission_code/Academy.dm @@ -252,7 +252,7 @@ if(6) //Cut speed T.visible_message("[user] starts moving slower!") - user._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/die_of_fate) + user.add_movespeed_modifier(/datum/movespeed_modifier/die_of_fate) if(7) //Throw T.visible_message("Unseen forces throw [user]!") diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index a6e3fb7ec39..d4e7509d97c 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -497,9 +497,9 @@ /mob/living/carbon/update_mobility() . = ..() if(!(mobility_flags & MOBILITY_STAND)) - _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) + add_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) else - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) + remove_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) /datum/movespeed_modifier/carbon_crawling id = MOVESPEED_ID_CARBON_CRAWLING @@ -526,9 +526,9 @@ med_hud_set_health() if(stat == SOFT_CRIT) - _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit) + add_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit) else - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit) + remove_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit) /mob/living/carbon/update_stamina() var/stam = getStaminaLoss() diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index f53689f1f04..1665829f3c5 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1018,7 +1018,7 @@ return FALSE /mob/living/carbon/human/proc/clear_shove_slowdown() - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/shove) + remove_movespeed_modifier(/datum/movespeed_modifier/shove) var/active_item = get_active_held_item() if(is_type_in_typecache(active_item, GLOB.shove_disarming_types)) visible_message("[src.name] regains their grip on \the [active_item]!", "You regain your grip on \the [active_item]", null, COMBAT_MESSAGE_RANGE) @@ -1031,16 +1031,16 @@ . = ..() dna?.species.spec_updatehealth(src) if(HAS_TRAIT(src, TRAIT_IGNOREDAMAGESLOWDOWN)) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) return var/health_deficiency = max((maxHealth - health), staminaloss) if(health_deficiency >= 40) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) else - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) /mob/living/carbon/human/adjust_nutrition(change) //Honestly FUCK the oldcoders for putting nutrition on /mob someone else can move it up because holy hell I'd have to fix SO many typechecks if(HAS_TRAIT(src, TRAIT_NOHUNGER)) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 7841c02e0e9..5b3fe0ec903 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -353,7 +353,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) C.dna.features["wings"] = "None" C.update_body() - C._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/species) + C.remove_movespeed_modifier(/datum/movespeed_modifier/species) SEND_SIGNAL(C, COMSIG_SPECIES_LOSS, src) @@ -1026,14 +1026,14 @@ GLOBAL_LIST_EMPTY(roundstart_races) if(H.overeatduration < 100) to_chat(H, "You feel fit again!") REMOVE_TRAIT(H, TRAIT_FAT, OBESITY) - H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/obesity) + H.remove_movespeed_modifier(/datum/movespeed_modifier/obesity) H.update_inv_w_uniform() H.update_inv_wear_suit() else if(H.overeatduration >= 100) to_chat(H, "You suddenly feel blubbery!") ADD_TRAIT(H, TRAIT_FAT, OBESITY) - H._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/obesity) + H.add_movespeed_modifier(/datum/movespeed_modifier/obesity) H.update_inv_w_uniform() H.update_inv_wear_suit() @@ -1094,7 +1094,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) if(E.get_charge(H) <= ETHEREAL_CHARGE_NORMAL) H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/hunger, multiplicative_slowdown = (1.5 * (1 - E.get_charge(H) / 100))) else - H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/hunger) + H.remove_movespeed_modifier(/datum/movespeed_modifier/hunger) switch(H.nutrition) if(NUTRITION_LEVEL_FULL to INFINITY) @@ -1377,8 +1377,8 @@ GLOBAL_LIST_EMPTY(roundstart_races) var/knocked_item = FALSE if(!is_type_in_typecache(target_held_item, GLOB.shove_disarming_types)) target_held_item = null - if(!target._REFACTORING_has_movespeed_modifier(/datum/movespeed_modifier/shove)) - target._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/shove) + if(!target.has_movespeed_modifier(/datum/movespeed_modifier/shove)) + target.add_movespeed_modifier(/datum/movespeed_modifier/shove) if(target_held_item) target.visible_message("[target.name]'s grip on \the [target_held_item] loosens!", "Your grip on \the [target_held_item] loosens!", null, COMBAT_MESSAGE_RANGE) @@ -1643,7 +1643,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold") SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "hot", /datum/mood_event/hot) - H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/cold) + H.remove_movespeed_modifier(/datum/movespeed_modifier/cold) var/burn_damage var/firemodifier = H.fire_stacks / 50 @@ -1683,7 +1683,7 @@ GLOBAL_LIST_EMPTY(roundstart_races) else H.clear_alert("temp") - H._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/cold) + H.remove_movespeed_modifier(/datum/movespeed_modifier/cold) SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "cold") SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot") diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index b5e3dbc5634..49419e62646 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -1210,7 +1210,7 @@ if(limbless_slowdown) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/limbless, multiplicative_slowdown = limbless_slowdown) else - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/limbless) + remove_movespeed_modifier(/datum/movespeed_modifier/limbless) /mob/living/proc/fall(forced) if(!(mobility_flags & MOBILITY_USE)) diff --git a/code/modules/mob/living/living_movement.dm b/code/modules/mob/living/living_movement.dm index 8dde0fdcebb..2fb42d1e96c 100644 --- a/code/modules/mob/living/living_movement.dm +++ b/code/modules/mob/living/living_movement.dm @@ -26,31 +26,31 @@ return ..() /mob/living/proc/update_move_intent_slowdown() - _REFACTORING_add_movespeed_modifier((m_intent == MOVE_INTENT_WALK)? /datum/movespeed_modifier/config_walk_run/walk : /datum/movespeed_modifier/config_walk_run/run, override = TRUE) + add_movespeed_modifier((m_intent == MOVE_INTENT_WALK)? /datum/movespeed_modifier/config_walk_run/walk : /datum/movespeed_modifier/config_walk_run/run, override = TRUE) /mob/living/proc/update_turf_movespeed(turf/open/T) if(istype(T)) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown, multiplicative_slowdown = T.slowdown) else - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown) + remove_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown) /mob/living/proc/update_pull_movespeed() if(pulling) if(isliving(pulling)) var/mob/living/L = pulling if(!slowed_by_drag || (L.mobility_flags & MOBILITY_STAND) || L.buckled || grab_state >= GRAB_AGGRESSIVE) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) + remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) return add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/bulky_drag, multiplicative_slowdown = PULL_PRONE_SLOWDOWN) return if(isobj(pulling)) var/obj/structure/S = pulling if(!slowed_by_drag || !S.drag_slowdown) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) + remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) return add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/bulky_drag, multiplicative_slowdown = S.drag_slowdown) return - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) + remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) /mob/living/can_zFall(turf/T, levels) return ..() diff --git a/code/modules/mob/living/silicon/pai/pai.dm b/code/modules/mob/living/silicon/pai/pai.dm index bd2f9e085fd..897ec8ad578 100644 --- a/code/modules/mob/living/silicon/pai/pai.dm +++ b/code/modules/mob/living/silicon/pai/pai.dm @@ -254,9 +254,9 @@ /mob/living/silicon/pai/Process_Spacemove(movement_dir = 0) . = ..() if(!.) - _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk) + add_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk) return TRUE - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk) + remove_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk) return TRUE /mob/living/silicon/pai/examine(mob/user) diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 27ce3a64a89..3413865db47 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -367,7 +367,7 @@ /mob/living/simple_animal/proc/update_simplemob_varspeed() if(speed == 0) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/simplemob_varspeed) + remove_movespeed_modifier(/datum/movespeed_modifier/simplemob_varspeed) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/simplemob_varspeed, multiplicative_slowdown = speed) /mob/living/simple_animal/Stat() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 413177f8e0b..b1aab6af4e3 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1232,20 +1232,20 @@ /mob/setGrabState(newstate) . = ..() if(grab_state == GRAB_PASSIVE) - _REFACTORING_remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAB_STATE) + remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAB_STATE) else switch(grab_state) if(GRAB_AGGRESSIVE) - _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/aggressive) + add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/aggressive) if(GRAB_NECK) - _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/neck) + add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/neck) if(GRAB_KILL) - _REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/kill) + add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/kill) /mob/proc/update_equipment_speed_mods() var/speedies = equipped_speed_mods() if(!speedies) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/equipment_speedmod) + remove_movespeed_modifier(/datum/movespeed_modifier/equipment_speedmod) else add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/equipment_speedmod, multiplicative_slowdown = speedies) diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 9330926db99..45a3e8d88e0 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -330,7 +330,7 @@ /mob/proc/update_gravity(has_gravity, override=FALSE) var/speed_change = max(0, has_gravity - STANDARD_GRAVITY) if(!speed_change) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/gravity) + remove_movespeed_modifier(/datum/movespeed_modifier/gravity) else add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/gravity, multiplicative_slowdown=speed_change) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 7725260c628..3e68ab7bfa0 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -73,7 +73,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) return GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) ///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. -/mob/proc/_REFACTORING_add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE) +/mob/proc/add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE) if(ispath(type_or_datum)) if(!initial(type_or_datum.variable)) type_or_datum = get_cached_movespeed_modifier(type_or_datum) @@ -95,7 +95,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) return TRUE ///Remove a move speed modifier from a mob, whether static or variable. -/mob/proc/_REFACTORING_remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) +/mob/proc/remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) if(ispath(type_id_datum)) if(!initial(type_id_datum.variable)) type_id_datum = get_cached_movespeed_modifier(type_id_datum) @@ -152,7 +152,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) final.multiplicative_slowdown = multiplicative_slowdown modified = TRUE if(inject) - _REFACTORING_add_movespeed_modifier(final, FALSE, TRUE) + add_movespeed_modifier(final, FALSE, TRUE) if(update && modified) update_movespeed(TRUE) return final @@ -162,14 +162,14 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown)) var/diff if(slowdown_edit && isnum(cached_multiplicative_slowdown) && isnum(var_value)) - _REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/admin_varedit) + remove_movespeed_modifier(/datum/movespeed_modifier/admin_varedit) diff = var_value - cached_multiplicative_slowdown . = ..() if(. && slowdown_edit && isnum(diff)) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/admin_varedit, multiplicative_slowdown = diff) ///Is there a movespeed modifier for this mob -/mob/proc/_REFACTORING_has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) +/mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) if(ispath(datum_type_id)) datum_type_id = get_cached_movespeed_modifier(datum_type_id) if(istype(datum_type_id)) diff --git a/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm index 67e57ddf168..82d538429e9 100644 --- a/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/cat2_medicine_reagents.dm @@ -106,11 +106,11 @@ return TRUE /datum/reagent/medicine/C2/lenturi/on_mob_metabolize(mob/living/carbon/M) - M._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/lenturi) + M.add_movespeed_modifier(/datum/movespeed_modifier/reagent/lenturi) return ..() /datum/reagent/medicine/C2/lenturi/on_mob_end_metabolize(mob/living/carbon/M) - M._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/lenturi) + M.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/lenturi) return ..() /datum/reagent/medicine/C2/aiuri diff --git a/code/modules/reagents/chemistry/reagents/drink_reagents.dm b/code/modules/reagents/chemistry/reagents/drink_reagents.dm index 1df4e807393..938770294a5 100644 --- a/code/modules/reagents/chemistry/reagents/drink_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drink_reagents.dm @@ -376,10 +376,10 @@ /datum/reagent/consumable/nuka_cola/on_mob_metabolize(mob/living/L) ..() - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/nuka_cola) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/nuka_cola) /datum/reagent/consumable/nuka_cola/on_mob_end_metabolize(mob/living/L) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nuka_cola) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nuka_cola) ..() /datum/reagent/consumable/nuka_cola/on_mob_life(mob/living/carbon/M) @@ -556,10 +556,10 @@ /datum/reagent/consumable/monkey_energy/on_mob_metabolize(mob/living/L) ..() if(ismonkey(L)) - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/monkey_energy) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/monkey_energy) /datum/reagent/consumable/monkey_energy/on_mob_end_metabolize(mob/living/L) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/monkey_energy) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/monkey_energy) ..() /datum/reagent/consumable/monkey_energy/overdose_process(mob/living/M) diff --git a/code/modules/reagents/chemistry/reagents/drug_reagents.dm b/code/modules/reagents/chemistry/reagents/drug_reagents.dm index 9af53eff1da..a3136823542 100644 --- a/code/modules/reagents/chemistry/reagents/drug_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drug_reagents.dm @@ -174,10 +174,10 @@ /datum/reagent/drug/methamphetamine/on_mob_metabolize(mob/living/L) ..() - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine) /datum/reagent/drug/methamphetamine/on_mob_end_metabolize(mob/living/L) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/methamphetamine) ..() /datum/reagent/drug/methamphetamine/on_mob_life(mob/living/carbon/M) diff --git a/code/modules/reagents/chemistry/reagents/food_reagents.dm b/code/modules/reagents/chemistry/reagents/food_reagents.dm index bd9d3286014..3755e541308 100755 --- a/code/modules/reagents/chemistry/reagents/food_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/food_reagents.dm @@ -293,8 +293,8 @@ victim.blind_eyes(3) // 6 seconds victim.confused = max(M.confused, 5) // 10 seconds victim.Knockdown(3 SECONDS) - victim._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/pepperspray) - addtimer(CALLBACK(victim, /mob.proc/_REFACTORING_remove_movespeed_modifier, /datum/movespeed_modifier/reagent/pepperspray), 10 SECONDS) + victim.add_movespeed_modifier(/datum/movespeed_modifier/reagent/pepperspray) + addtimer(CALLBACK(victim, /mob.proc/remove_movespeed_modifier, /datum/movespeed_modifier/reagent/pepperspray), 10 SECONDS) victim.update_damage_hud() if(method == INGEST) if(!holder.has_reagent(/datum/reagent/consumable/milk)) diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm index 23cad61cc2e..0b5e2493413 100644 --- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm @@ -422,11 +422,11 @@ /datum/reagent/medicine/ephedrine/on_mob_metabolize(mob/living/L) ..() - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/ephedrine) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/ephedrine) ADD_TRAIT(L, TRAIT_STUNRESISTANCE, type) /datum/reagent/medicine/ephedrine/on_mob_end_metabolize(mob/living/L) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/ephedrine) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/ephedrine) REMOVE_TRAIT(L, TRAIT_STUNRESISTANCE, type) ..() @@ -806,11 +806,11 @@ /datum/reagent/medicine/stimulants/on_mob_metabolize(mob/living/L) ..() - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) ADD_TRAIT(L, TRAIT_STUNRESISTANCE, type) /datum/reagent/medicine/stimulants/on_mob_end_metabolize(mob/living/L) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) REMOVE_TRAIT(L, TRAIT_STUNRESISTANCE, type) ..() @@ -1038,10 +1038,10 @@ /datum/reagent/medicine/changelinghaste/on_mob_metabolize(mob/living/L) ..() - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/changelinghaste) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/changelinghaste) /datum/reagent/medicine/changelinghaste/on_mob_end_metabolize(mob/living/L) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/changelinghaste) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/changelinghaste) ..() /datum/reagent/medicine/changelinghaste/on_mob_life(mob/living/carbon/M) @@ -1348,14 +1348,14 @@ ..() ADD_TRAIT(L, TRAIT_SLEEPIMMUNE, type) ADD_TRAIT(L, TRAIT_STUNRESISTANCE, type) - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/badstims) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/badstims) L.ignore_slowdown(type) /datum/reagent/medicine/badstims/on_mob_end_metabolize(mob/living/L) ..() REMOVE_TRAIT(L, TRAIT_SLEEPIMMUNE, type) REMOVE_TRAIT(L, TRAIT_STUNRESISTANCE, type) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/badstims) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/badstims) L.unignore_slowdown(type) L.Dizzy(0) L.Jitter(0) diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index 828ea4779d1..185a273f23f 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -1230,10 +1230,10 @@ /datum/reagent/nitryl/on_mob_metabolize(mob/living/L) ..() - L._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) /datum/reagent/nitryl/on_mob_end_metabolize(mob/living/L) - L._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) ..() /////////////////////////Colorful Powder//////////////////////////// diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm index 785a93f9e0f..8857bca4bd5 100644 --- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm +++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm @@ -185,7 +185,7 @@ alert_type = /obj/screen/alert/status_effect/bloodchill /datum/status_effect/bloodchill/on_apply() - owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) return ..() /datum/status_effect/bloodchill/tick() @@ -193,7 +193,7 @@ owner.adjustFireLoss(2) /datum/status_effect/bloodchill/on_remove() - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) /datum/status_effect/bonechill id = "bonechill" @@ -201,7 +201,7 @@ alert_type = /obj/screen/alert/status_effect/bonechill /datum/status_effect/bonechill/on_apply() - owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) return ..() /datum/status_effect/bonechill/tick() @@ -211,7 +211,7 @@ owner.adjust_bodytemperature(-10) /datum/status_effect/bonechill/on_remove() - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) /obj/screen/alert/status_effect/bonechill name = "Bonechilled" desc = "You feel a shiver down your spine after hearing the haunting noise of bone rattling. You'll move slower and get frostbite for a while!" @@ -365,11 +365,11 @@ datum/status_effect/rebreathing/tick() duration = 30 /datum/status_effect/tarfoot/on_apply() - owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) return ..() /datum/status_effect/tarfoot/on_remove() - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) /datum/status_effect/spookcookie id = "spookcookie" @@ -691,7 +691,7 @@ datum/status_effect/stabilized/blue/on_remove() return ..() /datum/status_effect/stabilized/sepia/on_remove() - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia) /datum/status_effect/stabilized/cerulean id = "stabilizedcerulean" @@ -899,7 +899,7 @@ datum/status_effect/stabilized/blue/on_remove() colour = "light pink" /datum/status_effect/stabilized/lightpink/on_apply() - owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/status_effect/lightpink) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/lightpink) return ..() /datum/status_effect/stabilized/lightpink/tick() @@ -910,7 +910,7 @@ datum/status_effect/stabilized/blue/on_remove() return ..() /datum/status_effect/stabilized/lightpink/on_remove() - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/lightpink) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/lightpink) /datum/status_effect/stabilized/adamantine id = "stabilizedadamantine" diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm index 71708bc91cd..a66b07ec039 100644 --- a/code/modules/station_goals/dna_vault.dm +++ b/code/modules/station_goals/dna_vault.dm @@ -277,7 +277,7 @@ ADD_TRAIT(H, TRAIT_PIERCEIMMUNE, "dna_vault") if(VAULT_SPEED) to_chat(H, "Your legs feel faster.") - H._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/dna_vault_speedup) + H.add_movespeed_modifier(/datum/movespeed_modifier/dna_vault_speedup) if(VAULT_QUICK) to_chat(H, "Your arms move as fast as lightning.") H.next_move_modifier = 0.5 diff --git a/code/modules/surgery/organs/augments_chest.dm b/code/modules/surgery/organs/augments_chest.dm index eb51bc15417..500785f1418 100644 --- a/code/modules/surgery/organs/augments_chest.dm +++ b/code/modules/surgery/organs/augments_chest.dm @@ -152,13 +152,13 @@ if(allow_thrust(0.01)) ion_trail.start() RegisterSignal(owner, COMSIG_MOVABLE_MOVED, .proc/move_react) - owner._REFACTORING_add_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) + owner.add_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) if(!silent) to_chat(owner, "You turn your thrusters set on.") else ion_trail.stop() UnregisterSignal(owner, COMSIG_MOVABLE_MOVED) - owner._REFACTORING_remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) if(!silent) to_chat(owner, "You turn your thrusters set off.") on = FALSE From 6da319481bc484ec823ec75ab433fde9d76861b5 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 22:23:37 -0800 Subject: [PATCH 10/34] woops forgot those --- code/datums/components/mood.dm | 19 +++---------------- code/game/objects/effects/mines.dm | 5 ----- code/modules/mob/living/carbon/carbon.dm | 4 ---- .../modules/movespeed/modifiers/components.dm | 13 +++++++++++++ code/modules/movespeed/modifiers/misc.dm | 5 +++++ code/modules/movespeed/modifiers/mobs.dm | 4 ++++ 6 files changed, 25 insertions(+), 25 deletions(-) diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index f9f2914ed52..63976bd3abc 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -208,15 +208,15 @@ switch(sanity) if(SANITY_INSANE to SANITY_CRAZY) setInsanityEffect(MAJOR_INSANITY_PEN) - master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/insane, override = TRUE) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/insane) sanity_level = 6 if(SANITY_CRAZY to SANITY_UNSTABLE) setInsanityEffect(MINOR_INSANITY_PEN) - master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/crazy, override = TRUE) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/crazy) sanity_level = 5 if(SANITY_UNSTABLE to SANITY_DISTURBED) setInsanityEffect(0) - master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/disturbed, override = TRUE) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/disturbed) sanity_level = 4 if(SANITY_DISTURBED to SANITY_NEUTRAL) setInsanityEffect(0) @@ -232,19 +232,6 @@ sanity_level = 1 update_mood_icon() -/datum/movespeed_modifier/sanity - id = MOVESPEED_ID_SANITY - movetypes = (~FLYING) - -/datum/movespeed_modifier/sanity/insane - multiplicative_slowdown = 1 - -/datum/movespeed_modifier/sanity/crazy - multiplicative_slowdown = 0.5 - -/datum/movespeed_modifier/sanity/disturbed - multiplicative_slowdown = 0.25 - /datum/component/mood/proc/setInsanityEffect(newval) if(newval == insanity_effect) return diff --git a/code/game/objects/effects/mines.dm b/code/game/objects/effects/mines.dm index f31e849b67b..cdb06ba00ba 100644 --- a/code/game/objects/effects/mines.dm +++ b/code/game/objects/effects/mines.dm @@ -176,8 +176,3 @@ sleep(duration) victim.remove_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) to_chat(victim, "You slow down.") - -/datum/movespeed_modifier/yellow_orb - id = MOVESPEED_ID_YELLOW_ORB - multiplicative_slowdown = -2 - blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index d4e7509d97c..dda46b08455 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -501,10 +501,6 @@ else remove_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) -/datum/movespeed_modifier/carbon_crawling - id = MOVESPEED_ID_CARBON_CRAWLING - multiplicative_slowdown = CRAWLING_ADD_SLOWDOWN - //Updates the mob's health from bodyparts and mob damage variables /mob/living/carbon/updatehealth() if(status_flags & GODMODE) diff --git a/code/modules/movespeed/modifiers/components.dm b/code/modules/movespeed/modifiers/components.dm index 040a7950fac..ec4c4e11973 100644 --- a/code/modules/movespeed/modifiers/components.dm +++ b/code/modules/movespeed/modifiers/components.dm @@ -7,3 +7,16 @@ id = MOVESPEED_ID_SNAIL_CRAWL multiplicative_slowdown = -7 movetypes = GROUND + +/datum/movespeed_modifier/sanity + id = MOVESPEED_ID_SANITY + movetypes = (~FLYING) + +/datum/movespeed_modifier/sanity/insane + multiplicative_slowdown = 1 + +/datum/movespeed_modifier/sanity/crazy + multiplicative_slowdown = 0.5 + +/datum/movespeed_modifier/sanity/disturbed + multiplicative_slowdown = 0.25 diff --git a/code/modules/movespeed/modifiers/misc.dm b/code/modules/movespeed/modifiers/misc.dm index 548b35708a7..7e606e3f1e9 100644 --- a/code/modules/movespeed/modifiers/misc.dm +++ b/code/modules/movespeed/modifiers/misc.dm @@ -1,3 +1,8 @@ /datum/movespeed_modifier/admin_varedit variable = TRUE id = MOVESPEED_ID_ADMIN_VAREDIT + +/datum/movespeed_modifier/yellow_orb + id = MOVESPEED_ID_YELLOW_ORB + multiplicative_slowdown = -2 + blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm index 42fc0409433..50f44a96ccc 100644 --- a/code/modules/movespeed/modifiers/mobs.dm +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -118,3 +118,7 @@ /datum/movespeed_modifier/slime_tempmod id = MOVESPEED_ID_SLIME_TEMPMOD variable = TRUE + +/datum/movespeed_modifier/carbon_crawling + id = MOVESPEED_ID_CARBON_CRAWLING + multiplicative_slowdown = CRAWLING_ADD_SLOWDOWN From 58e364834090851bb41ed5b1eb88ac6153e4aae6 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 22:30:13 -0800 Subject: [PATCH 11/34] 150 hours of testing --- code/modules/mob/living/living_movement.dm | 2 +- code/modules/movespeed/_movespeed_modifier.dm | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/living_movement.dm b/code/modules/mob/living/living_movement.dm index 39978822a8a..90e8a498f15 100644 --- a/code/modules/mob/living/living_movement.dm +++ b/code/modules/mob/living/living_movement.dm @@ -26,7 +26,7 @@ return ..() /mob/living/proc/update_move_intent_slowdown() - add_movespeed_modifier((m_intent == MOVE_INTENT_WALK)? /datum/movespeed_modifier/config_walk_run/walk : /datum/movespeed_modifier/config_walk_run/run, override = TRUE) + add_movespeed_modifier((m_intent == MOVE_INTENT_WALK)? /datum/movespeed_modifier/config_walk_run/walk : /datum/movespeed_modifier/config_walk_run/run) /mob/living/proc/update_turf_movespeed(turf/open/T) if(istype(T)) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 3e68ab7bfa0..4aaed2502f4 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -178,7 +178,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) ///Set or update the global movespeed config on a mob /mob/proc/update_config_movespeed() - add_movespeed_modifier(MOVESPEED_ID_CONFIG_SPEEDMOD, FALSE, 100, override = TRUE, multiplicative_slowdown = get_config_multiplicative_speed()) + add_movespeed_modifier(MOVESPEED_ID_CONFIG_SPEEDMOD, FALSE, 100, multiplicative_slowdown = get_config_multiplicative_speed()) ///Get the global config movespeed of a mob by type /mob/proc/get_config_multiplicative_speed() From f56844d54a4161dac58100d9e2cff2d1e69dadcd Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 22:38:35 -0800 Subject: [PATCH 12/34] i forgot how bad i was at coding --- code/modules/movespeed/_movespeed_modifier.dm | 2 +- code/modules/movespeed/modifiers/mobs.dm | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 4aaed2502f4..03a657be7e3 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -178,7 +178,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) ///Set or update the global movespeed config on a mob /mob/proc/update_config_movespeed() - add_movespeed_modifier(MOVESPEED_ID_CONFIG_SPEEDMOD, FALSE, 100, multiplicative_slowdown = get_config_multiplicative_speed()) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/mob_config_speedmod, multiplicative_slowdown = get_config_multiplicative_speed()) ///Get the global config movespeed of a mob by type /mob/proc/get_config_multiplicative_speed() diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm index 50f44a96ccc..376b3ae94f0 100644 --- a/code/modules/movespeed/modifiers/mobs.dm +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -122,3 +122,6 @@ /datum/movespeed_modifier/carbon_crawling id = MOVESPEED_ID_CARBON_CRAWLING multiplicative_slowdown = CRAWLING_ADD_SLOWDOWN + +/datum/movespeed_modifier/mob_config_speedmod + id = MOVESPEED_ID_CONFIG_SPEEDMOD From e5136f86b26924096c9436a8c49410445289efa7 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 23:28:31 -0800 Subject: [PATCH 13/34] *yawn --- code/controllers/subsystem/dcs.dm | 4 ++-- code/modules/mob/living/carbon/human/human_movement.dm | 2 ++ code/modules/movespeed/_movespeed_modifier.dm | 8 ++++---- code/modules/movespeed/modifiers/mobs.dm | 3 +++ 4 files changed, 11 insertions(+), 6 deletions(-) diff --git a/code/controllers/subsystem/dcs.dm b/code/controllers/subsystem/dcs.dm index 53c4b7fa311..ae27e42a617 100644 --- a/code/controllers/subsystem/dcs.dm +++ b/code/controllers/subsystem/dcs.dm @@ -9,7 +9,7 @@ PROCESSING_SUBSYSTEM_DEF(dcs) /datum/controller/subsystem/processing/dcs/proc/GetElement(datum/element/eletype, ...) var/element_id = eletype - + if(initial(eletype.element_flags) & ELEMENT_BESPOKE) var/list/fullid = list("[eletype]") for(var/i in initial(eletype.id_arg_index) to length(args)) @@ -19,7 +19,7 @@ PROCESSING_SUBSYSTEM_DEF(dcs) else fullid += "[REF(argument)]" element_id = fullid.Join("&") - + . = elements_by_type[element_id] if(.) return diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index fd46ad8b9f1..53872edc816 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -6,6 +6,8 @@ var/datum/movespeed_modifier/M = considering[id] if(M.flags & IGNORE_NOSLOW) .[id] = M + else + . = considering /mob/living/carbon/human/slip(knockdown_amount, obj/O, lube, paralyze, forcedrop) if(HAS_TRAIT(src, TRAIT_NOSLIPALL)) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 03a657be7e3..20c2fb8c61b 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -72,7 +72,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) CRASH("[modtype] is a variable modifier, and can never be cached.") return GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) -///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. +///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. If ID conflicts, it will overwrite the old ID. /mob/proc/add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE) if(ispath(type_or_datum)) if(!initial(type_or_datum.variable)) @@ -113,7 +113,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) update_movespeed(FALSE) return TRUE -/// Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. Implies override. Returns the modifier datum if successful +/// Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. Returns the modifier datum if successful /mob/proc/add_or_update_variable_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE, multiplicative_slowdown) /* How this SHOULD work is: @@ -136,7 +136,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) var/id = initial(type_id_datum.id) final = LAZYACCESS(movespeed_modification, id) if(!istype(final)) - final = new + final = new type_id_datum inject = TRUE modified = TRUE else if(istype(type_id_datum)) @@ -152,7 +152,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) final.multiplicative_slowdown = multiplicative_slowdown modified = TRUE if(inject) - add_movespeed_modifier(final, FALSE, TRUE) + add_movespeed_modifier(final, FALSE) if(update && modified) update_movespeed(TRUE) return final diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm index 376b3ae94f0..99bc4a17706 100644 --- a/code/modules/movespeed/modifiers/mobs.dm +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -25,10 +25,12 @@ /datum/movespeed_modifier/damage_slowdown id = MOVESPEED_ID_DAMAGE_SLOWDOWN blacklisted_movetypes = FLOATING|FLYING + variable = TRUE /datum/movespeed_modifier/damage_slowdown_flying id = MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING movetypes = FLOATING + variable = TRUE /datum/movespeed_modifier/equipment_speedmod variable = TRUE @@ -125,3 +127,4 @@ /datum/movespeed_modifier/mob_config_speedmod id = MOVESPEED_ID_CONFIG_SPEEDMOD + variable = TRUE From 67a21c2bd4d977c28db467bc22df43257f44dfea Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 23:34:44 -0800 Subject: [PATCH 14/34] wups --- code/modules/mob/living/carbon/human/human.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 1665829f3c5..b62e40f0712 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1036,8 +1036,8 @@ return var/health_deficiency = max((maxHealth - health), staminaloss) if(health_deficiency >= 40) - add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) - add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown, TRUE, multiplicative_slowdown = health_deficiency / 75) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying, multiplicative_slowdown = health_deficiency / 25) else remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) From 225be9b2ea82ce85973b9fb809e0de7a9b060e38 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Sat, 11 Jan 2020 23:35:02 -0800 Subject: [PATCH 15/34] wups --- code/modules/mob/living/carbon/human/human.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index b62e40f0712..b1356716e84 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1037,7 +1037,7 @@ var/health_deficiency = max((maxHealth - health), staminaloss) if(health_deficiency >= 40) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown, TRUE, multiplicative_slowdown = health_deficiency / 75) - add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying, multiplicative_slowdown = health_deficiency / 25) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying, TRUE, multiplicative_slowdown = health_deficiency / 25) else remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) From f9806e94f307124c2329e80f6da31fba31c3e533 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 13 Jan 2020 18:54:39 -0700 Subject: [PATCH 16/34] stuff --- code/modules/movespeed/_movespeed_modifier.dm | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 20c2fb8c61b..1d7e24fec77 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -7,7 +7,7 @@ var/variable = FALSE /// Unique ID. You can never have different modifications with the same ID - var/id = "ERROR" + var/id /// Higher ones override lower priorities. This is NOT used for ID, ID must be unique, if it isn't unique the newer one overwrites automatically if overriding. var/priority = 0 @@ -101,14 +101,13 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) type_id_datum = get_cached_movespeed_modifier(type_id_datum) else type_id_datum = initial(type_id_datum.id) - if(istype(type_id_datum)) + else type_id_datum = type_id_datum.id if(!istext(type_id_datum)) CRASH("Invalid ID") if(!LAZYACCESS(movespeed_modification, type_id_datum)) return FALSE LAZYREMOVE(movespeed_modification, type_id_datum) - UNSETEMPTY(movespeed_modification) if(update) update_movespeed(FALSE) return TRUE @@ -128,14 +127,14 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) var/datum/movespeed_modifier/final if(istext(type_id_datum)) final = LAZYACCESS(movespeed_modification, type_id_datum) - if(!istype(final)) + if(!final) CRASH("Couldn't find existing modification when only provided an ID.") else if(ispath(type_id_datum)) if(!initial(type_id_datum.variable)) CRASH("Not a variable modifier") var/id = initial(type_id_datum.id) final = LAZYACCESS(movespeed_modification, id) - if(!istype(final)) + if(!final) final = new type_id_datum inject = TRUE modified = TRUE @@ -172,7 +171,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) /mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) if(ispath(datum_type_id)) datum_type_id = get_cached_movespeed_modifier(datum_type_id) - if(istype(datum_type_id)) + else if(!istext(datum_type_id)) datum_type_id = datum_type_id.id return LAZYACCESS(movespeed_modification, datum_type_id) From f19086786a1bf9003323aef4ac268677e02393ad Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:00:07 -0700 Subject: [PATCH 17/34] stuff --- code/modules/movespeed/_movespeed_modifier.dm | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 1d7e24fec77..dc2b7b0304a 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -27,7 +27,7 @@ /*! How move speed for mobs works -Move speed is now calculated by using a list of movespeed modifiers, which is a list itself (to avoid datum overhead) +Move speed is now calculated by using modifier datums which are added to mobs. Some of them (nonvariable ones) are globally cached, the variable ones are instanced and changed based on need. This gives us the ability to have multiple sources of movespeed, reliabily keep them applied and remove them when they should be @@ -79,8 +79,6 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) type_or_datum = get_cached_movespeed_modifier(type_or_datum) else type_or_datum = new type_or_datum - if(!istype(type_or_datum)) - CRASH("Invalid modification datum") var/oldpriority var/datum/movespeed_modifier/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) if(existing) @@ -138,7 +136,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) final = new type_id_datum inject = TRUE modified = TRUE - else if(istype(type_id_datum)) + else if(!initial(type_id_datum.variable)) CRASH("Not a variable modifier") final = type_id_datum @@ -238,7 +236,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) var/list/assembled = list() for(var/our_id in movespeed_modification) var/datum/movespeed_modifier/M = movespeed_modification[our_id] - if(!istype(M) || movespeed_data_null_check(M)) + if(movespeed_data_null_check(M)) movespeed_modification -= our_id continue var/our_priority = M.priority From 3659ac328bf52b0253dfb7df4acb0afc5d866083 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 13 Jan 2020 19:35:19 -0700 Subject: [PATCH 18/34] ok --- code/modules/movespeed/_movespeed_modifier.dm | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index dc2b7b0304a..f0578ad1c7d 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -70,7 +70,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) var/datum/movespeed_modifier/M = modtype if(initial(M.variable)) CRASH("[modtype] is a variable modifier, and can never be cached.") - return GLOB.movespeed_modification_cache[modtype] || ((GLOB.movespeed_modification_cache[modtype] = new modtype)) + return GLOB.movespeed_modification_cache[modtype] || (GLOB.movespeed_modification_cache[modtype] = new modtype) ///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. If ID conflicts, it will overwrite the old ID. /mob/proc/add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE) @@ -143,8 +143,6 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(!LAZYACCESS(movespeed_modification, final.id)) inject = TRUE modified = TRUE - else - CRASH("Invalid modifier") if(!isnull(multiplicative_slowdown)) final.multiplicative_slowdown = multiplicative_slowdown modified = TRUE From 0affadce7f1fd599603952614717941782efa5fd Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 14 Jan 2020 16:06:58 -0700 Subject: [PATCH 19/34] aah. --- code/modules/movespeed/_movespeed_modifier.dm | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index f0578ad1c7d..525704459e4 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -92,17 +92,12 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) update_movespeed(resort) return TRUE -///Remove a move speed modifier from a mob, whether static or variable. +/// Remove a move speed modifier from a mob, whether static or variable. /mob/proc/remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) if(ispath(type_id_datum)) - if(!initial(type_id_datum.variable)) - type_id_datum = get_cached_movespeed_modifier(type_id_datum) - else - type_id_datum = initial(type_id_datum.id) - else + ype_id_datum = initial(type_id_datum.id) + else if(!istext(type_id_datum)) //if it isn't text it has to be a datum, as it isn't a type. type_id_datum = type_id_datum.id - if(!istext(type_id_datum)) - CRASH("Invalid ID") if(!LAZYACCESS(movespeed_modification, type_id_datum)) return FALSE LAZYREMOVE(movespeed_modification, type_id_datum) From a6a585af744c9576bcd7a099eb60504306fae426 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 14 Jan 2020 16:08:34 -0700 Subject: [PATCH 20/34] typo --- code/modules/movespeed/_movespeed_modifier.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 525704459e4..6a6bf29f1cb 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -95,7 +95,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) /// Remove a move speed modifier from a mob, whether static or variable. /mob/proc/remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) if(ispath(type_id_datum)) - ype_id_datum = initial(type_id_datum.id) + type_id_datum = initial(type_id_datum.id) else if(!istext(type_id_datum)) //if it isn't text it has to be a datum, as it isn't a type. type_id_datum = type_id_datum.id if(!LAZYACCESS(movespeed_modification, type_id_datum)) From bab0e4ba81013729ce39026fd8bcd6e8019dd4e3 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Thu, 16 Jan 2020 02:03:21 -0700 Subject: [PATCH 21/34] binary insert wew --- code/modules/movespeed/_movespeed_modifier.dm | 57 ++++++++----------- 1 file changed, 23 insertions(+), 34 deletions(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 6a6bf29f1cb..b1e41e2cdd8 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -79,17 +79,36 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) type_or_datum = get_cached_movespeed_modifier(type_or_datum) else type_or_datum = new type_or_datum - var/oldpriority var/datum/movespeed_modifier/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) if(existing) if(existing == type_or_datum) //same thing don't need to touch return TRUE oldpriority = existing.priority remove_movespeed_modifier(existing, FALSE) + LAZYINITLIST(movespeed_modification) + var/listlen = length(movespeed_modification) + if(!listlen) + movespeed_modification[type_or_datum.id] = type_or_datum + else + var/left = 1 + var/right = listlen + var/mid = (left + right) >> 1 + var/datum/movespeed_modifier/curr + while(left < right) + var/id = movespeed_modification[mid] + curr = movespeed_modification[id] + if(curr.priority <= type_or_datum.priority) + left = mid + 1 + else + right = mid + mid = (left + right) >> 1 + curr = movespeed_modification[mid] + mid = curr.priority > type_or_datum.priority? mid : mid + 1 + movespeed_modification.Insert(mid, type_or_datum.id) + movespeed_modification[type_or_datum.id] = type_or_datum LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) - var/resort = type_or_datum.priority == oldpriority if(update) - update_movespeed(resort) + update_movespeed() return TRUE /// Remove a move speed modifier from a mob, whether static or variable. @@ -178,9 +197,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) return GLOB.mob_config_movespeed_type_lookup[type] ///Go through the list of movespeed modifiers and calculate a final movespeed -/mob/proc/update_movespeed(resort = TRUE) - if(resort) - sort_movespeed_modlist() +/mob/proc/update_movespeed() . = 0 var/list/conflict_tracker = list() for(var/id in get_movespeed_modifiers()) @@ -217,31 +234,3 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) . = TRUE if(M.multiplicative_slowdown) . = FALSE - -/** - * Sort the list of move speed modifiers - * - * Verifies it too. Sorts highest priority (first applied) to lowest priority (last applied) - */ -/mob/proc/sort_movespeed_modlist() - if(!movespeed_modification) - return - var/list/assembled = list() - for(var/our_id in movespeed_modification) - var/datum/movespeed_modifier/M = movespeed_modification[our_id] - if(movespeed_data_null_check(M)) - movespeed_modification -= our_id - continue - var/our_priority = M.priority - var/resolved = FALSE - for(var/their_id in assembled) - var/datum/movespeed_modifier/other = assembled[their_id] - if(other.priority < our_priority) - assembled.Insert(assembled.Find(their_id), our_id) - assembled[our_id] = M - resolved = TRUE - break - if(!resolved) - assembled[our_id] = M - movespeed_modification = assembled - UNSETEMPTY(movespeed_modification) From 0f5075ccd0ffbca84e837bfce1a87b994802a358 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Thu, 16 Jan 2020 02:27:29 -0700 Subject: [PATCH 22/34] compile --- code/modules/movespeed/_movespeed_modifier.dm | 1 - 1 file changed, 1 deletion(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index b1e41e2cdd8..a2f706f231c 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -83,7 +83,6 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(existing) if(existing == type_or_datum) //same thing don't need to touch return TRUE - oldpriority = existing.priority remove_movespeed_modifier(existing, FALSE) LAZYINITLIST(movespeed_modification) var/listlen = length(movespeed_modification) From b5430eb68c37487ee2e8ef3ccd41e02e228bdb0e Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Fri, 24 Jan 2020 14:39:19 -0700 Subject: [PATCH 23/34] fuck --- .../mob/living/carbon/human/species.dm | 11 +-------- code/modules/movespeed/_movespeed_modifier.dm | 23 ++----------------- 2 files changed, 3 insertions(+), 31 deletions(-) diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 3987f64b745..e80dc5d94c7 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -1712,19 +1712,10 @@ GLOBAL_LIST_EMPTY(roundstart_races) // clear any hot moods and apply cold mood SEND_SIGNAL(H, COMSIG_CLEAR_MOOD_EVENT, "hot") SEND_SIGNAL(H, COMSIG_ADD_MOOD_EVENT, "cold", /datum/mood_event/cold) -<<<<<<< HEAD - //Sorry for the nasty oneline but I don't want to assign a variable on something run pretty frequently - H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/cold, multiplicative_slowdown = ((BODYTEMP_COLD_DAMAGE_LIMIT - H.bodytemperature) / COLD_SLOWDOWN_FACTOR)) -======= - // Apply cold slow down - H.add_movespeed_modifier(MOVESPEED_ID_COLD, override = TRUE, \ - multiplicative_slowdown = ((bodytemp_cold_damage_limit - H.bodytemperature) / COLD_SLOWDOWN_FACTOR), \ - blacklisted_movetypes = FLOATING) - + H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/cold, multiplicative_slowdown = ((bodytemp_cold_damage_limit - H.bodytemperature) / COLD_SLOWDOWN_FACTOR)) // Display alerts based on the amount of cold damage being taken // Apply more damage based on how cold you are ->>>>>>> tgstation/master switch(H.bodytemperature) if(200 to bodytemp_cold_damage_limit) H.throw_alert("temp", /obj/screen/alert/cold, 1) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index a2f706f231c..5410ce2ac7c 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -84,27 +84,8 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(existing == type_or_datum) //same thing don't need to touch return TRUE remove_movespeed_modifier(existing, FALSE) - LAZYINITLIST(movespeed_modification) - var/listlen = length(movespeed_modification) - if(!listlen) - movespeed_modification[type_or_datum.id] = type_or_datum - else - var/left = 1 - var/right = listlen - var/mid = (left + right) >> 1 - var/datum/movespeed_modifier/curr - while(left < right) - var/id = movespeed_modification[mid] - curr = movespeed_modification[id] - if(curr.priority <= type_or_datum.priority) - left = mid + 1 - else - right = mid - mid = (left + right) >> 1 - curr = movespeed_modification[mid] - mid = curr.priority > type_or_datum.priority? mid : mid + 1 - movespeed_modification.Insert(mid, type_or_datum.id) - movespeed_modification[type_or_datum.id] = type_or_datum + if(length(movespeed_modification)) + BINARY_INSERT(type_or_datum.id, movespeed_modification, datum/movespeed_modifier, type_or_datum, priority, __BIN_LIST[__BIN_LIST[__BIN_MID]]) LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) if(update) update_movespeed() From 0b9e346aec52f37a7329fc88ddcc91a6395e71d6 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Fri, 24 Jan 2020 16:10:24 -0700 Subject: [PATCH 24/34] thank you keyboard --- code/modules/antagonists/slaughter/slaughter.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/antagonists/slaughter/slaughter.dm b/code/modules/antagonists/slaughter/slaughter.dm index 9617a66f545..e16d0f0d62b 100644 --- a/code/modules/antagonists/slaughter/slaughter.dm +++ b/code/modules/antagonists/slaughter/slaughter.dm @@ -33,7 +33,7 @@ health = 200 healable = 0 environment_smash = ENVIRONMENT_SMASH_STRUCTURES - obj_damage = 5 + obj_damage = 50 melee_damage_lower = 30 melee_damage_upper = 30 see_in_dark = 8 From 9c5676995661b019c4bdf4f2fe1327fedd496d08 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Mon, 3 Feb 2020 14:12:43 -0700 Subject: [PATCH 25/34] ok --- code/modules/movespeed/_movespeed_modifier.dm | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 5410ce2ac7c..9162b98d7b2 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -70,7 +70,10 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) var/datum/movespeed_modifier/M = modtype if(initial(M.variable)) CRASH("[modtype] is a variable modifier, and can never be cached.") - return GLOB.movespeed_modification_cache[modtype] || (GLOB.movespeed_modification_cache[modtype] = new modtype) + M = GLOB.movespeed_modification_cache[modtype] + if(!M) + M = GLOB.movespeed_modification_cache[modtype] = new modtype + return M ///Add a move speed modifier to a mob. If a variable subtype is passed in as the first argument, it will make a new datum. If ID conflicts, it will overwrite the old ID. /mob/proc/add_movespeed_modifier(datum/movespeed_modifier/type_or_datum, update = TRUE) @@ -85,7 +88,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) return TRUE remove_movespeed_modifier(existing, FALSE) if(length(movespeed_modification)) - BINARY_INSERT(type_or_datum.id, movespeed_modification, datum/movespeed_modifier, type_or_datum, priority, __BIN_LIST[__BIN_LIST[__BIN_MID]]) + BINARY_INSERT(type_or_datum.id, movespeed_modification, datum/movespeed_modifier, type_or_datum, priority, COMPARE_VALUE) LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) if(update) update_movespeed() From 1c0b764dcf76f8e4ad550d4a042aced63efb5425 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 18 Feb 2020 00:04:16 -0700 Subject: [PATCH 26/34] no more ids --- code/__DEFINES/movespeed_modification.dm | 63 --------- code/modules/movespeed/_movespeed_modifier.dm | 127 +++++++++--------- .../modules/movespeed/modifiers/components.dm | 3 - code/modules/movespeed/modifiers/innate.dm | 4 - code/modules/movespeed/modifiers/items.dm | 3 - code/modules/movespeed/modifiers/misc.dm | 2 - code/modules/movespeed/modifiers/mobs.dm | 26 ---- code/modules/movespeed/modifiers/reagent.dm | 10 -- .../movespeed/modifiers/status_effects.dm | 5 - 9 files changed, 60 insertions(+), 183 deletions(-) diff --git a/code/__DEFINES/movespeed_modification.dm b/code/__DEFINES/movespeed_modification.dm index eb1d4eeba03..dacaaec6f71 100644 --- a/code/__DEFINES/movespeed_modification.dm +++ b/code/__DEFINES/movespeed_modification.dm @@ -6,66 +6,3 @@ #define MOVE_CONFLICT_JETPACK "JETPACK" //ids - -#define MOVESPEED_ID_MOB_WALK_RUN_CONFIG_SPEED "MOB_WALK_RUN" -#define MOVESPEED_ID_MOB_GRAB_STATE "MOB_GRAB_STATE" -#define MOVESPEED_ID_MOB_EQUIPMENT "MOB_EQUIPMENT" -#define MOVESPEED_ID_MOB_GRAVITY "MOB_GRAVITY" -#define MOVESPEED_ID_CONFIG_SPEEDMOD "MOB_CONFIG_MODIFIER" - -#define MOVESPEED_ID_SLIME_REAGENTMOD "SLIME_REAGENT_MODIFIER" -#define MOVESPEED_ID_SLIME_HEALTHMOD "SLIME_HEALTH_MODIFIER" -#define MOVESPEED_ID_SLIME_TEMPMOD "SLIME_TEMPERATURE_MODIFIER" - -#define MOVESPEED_ID_SLIME_STATUS "SLIME_STATUS" - -#define MOVESPEED_ID_TARANTULA_WEB "TARANTULA_WEB" - -#define MOVESPEED_ID_LIVING_TURF_SPEEDMOD "LIVING_TURF_SPEEDMOD" -#define MOVESPEED_ID_LIVING_LIMBLESS "LIVING_LIMBLESS" - -#define MOVESPEED_ID_CARBON_SOFTCRIT "CARBON_SOFTCRIT" -#define MOVESPEED_ID_CARBON_OLDSPEED "CARBON_DEPRECATED_SPEED" -#define MOVESPEED_ID_CARBON_CRAWLING "CARBON_CRAWLING" - -#define MOVESPEED_ID_DNA_VAULT "DNA_VAULT" - -#define MOVESPEED_ID_YELLOW_ORB "YELLOW_ORB" - -#define MOVESPEED_ID_TARFOOT "TARFOOT" - -#define MOVESPEED_ID_SEPIA "SEPIA" - -#define MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD "MONKEY_REAGENT_SPEEDMOD" -#define MOVESPEED_ID_MONKEY_TEMPERATURE_SPEEDMOD "MONKEY_TEMPERATURE_SPEEDMOD" -#define MOVESPEED_ID_MONKEY_HEALTH_SPEEDMOD "MONKEY_HEALTH_SPEEDMOD" - -#define MOVESPEED_ID_CHANGELING_MUSCLES "CHANGELING_MUSCLES" - -#define MOVESPEED_ID_SIMPLEMOB_VARSPEED "SIMPLEMOB_VARSPEED_MODIFIER" -#define MOVESPEED_ID_ADMIN_VAREDIT "ADMIN_VAREDIT_MODIFIER" - -#define MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD "PAI_SPACEWALK_MODIFIER" - -#define MOVESPEED_ID_SANITY "MOOD_SANITY" - -#define MOVESPEED_ID_SPECIES "SPECIES_SPEED_MOD" -#define MOVESPEED_ID_SNAIL_CRAWL "SNAIL_CRAWL_SPEED_MOD" - -#define MOVESPEED_ID_CYBER_THRUSTER "CYBER_IMPLANT_THRUSTER" -#define MOVESPEED_ID_JETPACK "JETPACK" - -#define MOVESPEED_ID_SLAUGHTER "SLAUGHTER" -#define MOVESPEED_ID_DIE_OF_FATE "DIE_OF_FATE" - -#define MOVESPEED_ID_SHOVE "SHOVE" -#define MOVESPEED_ID_BULKY_DRAGGING "BULKY_DRAG" -#define MOVESPEED_ID_HUMAN_CARRYING "HUMAN_CARRY" -#define MOVESPEED_ID_SHRINK_RAY "SHRUNKEN_SPEED_MODIFIER" -#define MOVESPEED_ID_PEPPER_SPRAY "PEPPER_SPRAYED" -#define MOVESPEED_ID_FAT "FAT" -#define MOVESPEED_ID_COLD "COLD" -#define MOVESPEED_ID_HUNGRY "HUNGRY" -#define MOVESPEED_ID_DAMAGE_SLOWDOWN "DAMAGE" -#define MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING "FLYING" -#define MOVESPEED_ID_LENTURI "LENTURI_SLOWDOWN" diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index 9162b98d7b2..dd8321c68ee 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -1,12 +1,35 @@ -/** - * Movespeed modification datums. - */ +/*! Movespeed modification datums. + + How move speed for mobs works + +Move speed is now calculated by using modifier datums which are added to mobs. Some of them (nonvariable ones) are globally cached, the variable ones are instanced and changed based on need. + +This gives us the ability to have multiple sources of movespeed, reliabily keep them applied and remove them when they should be + +THey can have unique sources and a bunch of extra fancy flags that control behaviour + +Previously trying to update move speed was a shot in the dark that usually meant mobs got stuck going faster or slower + +Movespeed modification list is a simple key = datum system. Key will be the datum's ID if it is overridden to not be null, or type if it is not. + +DO NOT override datum IDs unless you are going to have multiple types that must overwrite each other. It's more efficient to use types, ID functionality is only kept for cases where dynamic creation of modifiers need to be done. + +When update movespeed is called, the list of items is iterated, according to flags priority and a bunch of conditions +this spits out a final calculated value which is used as a modifer to last_move + modifier for calculating when a mob +can next move + +Key procs +* [add_movespeed_modifier](mob.html#proc/add_movespeed_modifier) +* [remove_movespeed_modifier](mob.html#proc/remove_movespeed_modifier) +* [has_movespeed_modifier](mob.html#proc/has_movespeed_modifier) +* [update_movespeed](mob.html#proc/update_movespeed) +*/ /datum/movespeed_modifier /// Whether or not this is a variable modifier. Variable modifiers can NOT be ever auto-cached. ONLY CHECKED VIA INITIAL(), EFFECTIVELY READ ONLY (and for very good reason) var/variable = FALSE - /// Unique ID. You can never have different modifications with the same ID + /// Unique ID. You can never have different modifications with the same ID. By default, this SHOULD NOT be set. Only set it for cases where you're dynamically making modifiers/need to have two types overwrite each other. If unset, uses path as ID. var/id /// Higher ones override lower priorities. This is NOT used for ID, ID must be unique, if it isn't unique the newer one overwrites automatically if overriding. @@ -25,42 +48,6 @@ /// Other modification datums this conflicts with. var/conflicts_with -/*! How move speed for mobs works - -Move speed is now calculated by using modifier datums which are added to mobs. Some of them (nonvariable ones) are globally cached, the variable ones are instanced and changed based on need. - -This gives us the ability to have multiple sources of movespeed, reliabily keep them applied and remove them when they should be - -THey can have unique sources and a bunch of extra fancy flags that control behaviour - -Previously trying to update move speed was a shot in the dark that usually meant mobs got stuck going faster or slower - -This list takes the following format - -```Current movespeed modification list format: - list( - id = list( - priority, - flags, - legacy slowdown/speedup amount, - movetype_flags - ) - ) -``` - -WHen update movespeed is called, the list of items is iterated, according to flags priority and a bunch of conditions -this spits out a final calculated value which is used as a modifer to last_move + modifier for calculating when a mob -can next move - -Key procs -* [add_movespeed_modifier](mob.html#proc/add_movespeed_modifier) -* [remove_movespeed_modifier](mob.html#proc/remove_movespeed_modifier) -* [has_movespeed_modifier](mob.html#proc/has_movespeed_modifier) -* [update_movespeed](mob.html#proc/update_movespeed) -*/ - -//ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE! - GLOBAL_LIST_EMPTY(movespeed_modification_cache) /// Grabs a STATIC MODIFIER datum from cache. YOU MUST NEVER EDIT THESE DATUMS, OR IT WILL AFFECT ANYTHING ELSE USING IT TOO! @@ -82,53 +69,56 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) type_or_datum = get_cached_movespeed_modifier(type_or_datum) else type_or_datum = new type_or_datum - var/datum/movespeed_modifier/existing = LAZYACCESS(movespeed_modification, type_or_datum.id) + var/key = type_or_datum.id || type_or_datum.type //Our key will be ID if it's overridden, or if not, path. + var/datum/movespeed_modifier/existing = LAZYACCESS(movespeed_modification, key) if(existing) if(existing == type_or_datum) //same thing don't need to touch return TRUE remove_movespeed_modifier(existing, FALSE) if(length(movespeed_modification)) - BINARY_INSERT(type_or_datum.id, movespeed_modification, datum/movespeed_modifier, type_or_datum, priority, COMPARE_VALUE) - LAZYSET(movespeed_modification, type_or_datum.id, type_or_datum) + BINARY_INSERT(key, movespeed_modification, datum/movespeed_modifier, type_or_datum, priority, COMPARE_VALUE) + LAZYSET(movespeed_modification, key, type_or_datum) if(update) update_movespeed() return TRUE /// Remove a move speed modifier from a mob, whether static or variable. /mob/proc/remove_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE) + var/key if(ispath(type_id_datum)) - type_id_datum = initial(type_id_datum.id) + key = initial(type_id_datum.id) || type_id_datum //id if set, path if not. else if(!istext(type_id_datum)) //if it isn't text it has to be a datum, as it isn't a type. - type_id_datum = type_id_datum.id - if(!LAZYACCESS(movespeed_modification, type_id_datum)) + key = type_id_datum.id || type_id_datum.type + else //assume it's an id + key = type_id_datum + if(!LAZYACCESS(movespeed_modification, key)) return FALSE - LAZYREMOVE(movespeed_modification, type_id_datum) + LAZYREMOVE(movespeed_modification, key) if(update) update_movespeed(FALSE) return TRUE -/// Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. Returns the modifier datum if successful -/mob/proc/add_or_update_variable_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE, multiplicative_slowdown) - /* +/*! Used for variable slowdowns like hunger/health loss/etc, works somewhat like the old list-based modification adds. Returns the modifier datum if successful How this SHOULD work is: 1. Ensures type_id_datum one way or another refers to a /variable datum. This makes sure it can't be cached. This includes if it's already in the modification list. 2. Instantiate a new datum if type_id_datum isn't already instantiated + in the list, using the type. Obviously, wouldn't work for ID only. 3. Add the datum if necessary using the regular add proc 4. If any of the rest of the args are not null (see: multiplicative slowdown), modify the datum 5. Update if necessary - */ +*/ +/mob/proc/add_or_update_variable_movespeed_modifier(datum/movespeed_modifier/type_id_datum, update = TRUE, multiplicative_slowdown) var/modified = FALSE var/inject = FALSE var/datum/movespeed_modifier/final if(istext(type_id_datum)) final = LAZYACCESS(movespeed_modification, type_id_datum) if(!final) - CRASH("Couldn't find existing modification when only provided an ID.") + CRASH("Couldn't find existing modification when provided a text ID.") else if(ispath(type_id_datum)) if(!initial(type_id_datum.variable)) CRASH("Not a variable modifier") var/id = initial(type_id_datum.id) - final = LAZYACCESS(movespeed_modification, id) + final = LAZYACCESS(movespeed_modification, id || type_or_datum) if(!final) final = new type_id_datum inject = TRUE @@ -137,7 +127,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(!initial(type_id_datum.variable)) CRASH("Not a variable modifier") final = type_id_datum - if(!LAZYACCESS(movespeed_modification, final.id)) + if(!LAZYACCESS(movespeed_modification, final.id || final.type)) inject = TRUE modified = TRUE if(!isnull(multiplicative_slowdown)) @@ -149,7 +139,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) update_movespeed(TRUE) return final -///Handles the special case of editing the movement var +/// Handles the special case of editing the movement var /mob/vv_edit_var(var_name, var_value) var/slowdown_edit = (var_name == NAMEOF(src, cached_multiplicative_slowdown)) var/diff @@ -162,29 +152,32 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) ///Is there a movespeed modifier for this mob /mob/proc/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) + var/key if(ispath(datum_type_id)) - datum_type_id = get_cached_movespeed_modifier(datum_type_id) - else if(!istext(datum_type_id)) - datum_type_id = datum_type_id.id - return LAZYACCESS(movespeed_modification, datum_type_id) + key = initial(datum_type_id.id) || datum_type_id + else if(istext(datum_type_id)) + key = datum_type_id + else + key = datum_type_id.id || datum_type_id.type + return LAZYACCESS(movespeed_modification, key) -///Set or update the global movespeed config on a mob +/// Set or update the global movespeed config on a mob /mob/proc/update_config_movespeed() add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/mob_config_speedmod, multiplicative_slowdown = get_config_multiplicative_speed()) -///Get the global config movespeed of a mob by type +/// Get the global config movespeed of a mob by type /mob/proc/get_config_multiplicative_speed() if(!islist(GLOB.mob_config_movespeed_type_lookup) || !GLOB.mob_config_movespeed_type_lookup[type]) return 0 else return GLOB.mob_config_movespeed_type_lookup[type] -///Go through the list of movespeed modifiers and calculate a final movespeed +/// Go through the list of movespeed modifiers and calculate a final movespeed. ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE! /mob/proc/update_movespeed() . = 0 var/list/conflict_tracker = list() - for(var/id in get_movespeed_modifiers()) - var/datum/movespeed_modifier/M = movespeed_modification[id] + for(var/key in get_movespeed_modifiers()) + var/datum/movespeed_modifier/M = movespeed_modification[key] if(!(M.movetypes & movement_type)) // We don't affect any of these move types, skip continue if(M.blacklisted_movetypes & movement_type) // There's a movetype here that disables this modifier, skip @@ -201,18 +194,18 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) . += amt cached_multiplicative_slowdown = . -///Get the move speed modifiers list of the mob +/// Get the move speed modifiers list of the mob /mob/proc/get_movespeed_modifiers() return movespeed_modification -///Calculate the total slowdown of all movespeed modifiers +/// Calculate the total slowdown of all movespeed modifiers /mob/proc/total_multiplicative_slowdown() . = 0 for(var/id in get_movespeed_modifiers()) var/datum/movespeed_modifier/M = movespeed_modification[id] . += M.multiplicative_slowdown -///Checks if a move speed modifier is valid and not missing any data +/// Checks if a move speed modifier is valid and not missing any data /proc/movespeed_data_null_check(datum/movespeed_modifier/M) //Determines if a data list is not meaningful and should be discarded. . = TRUE if(M.multiplicative_slowdown) diff --git a/code/modules/movespeed/modifiers/components.dm b/code/modules/movespeed/modifiers/components.dm index ec4c4e11973..758b8f5fb7a 100644 --- a/code/modules/movespeed/modifiers/components.dm +++ b/code/modules/movespeed/modifiers/components.dm @@ -1,15 +1,12 @@ /datum/movespeed_modifier/shrink_ray - id = MOVESPEED_ID_SHRINK_RAY movetypes = GROUND multiplicative_slowdown = 4 /datum/movespeed_modifier/snail_crawl - id = MOVESPEED_ID_SNAIL_CRAWL multiplicative_slowdown = -7 movetypes = GROUND /datum/movespeed_modifier/sanity - id = MOVESPEED_ID_SANITY movetypes = (~FLYING) /datum/movespeed_modifier/sanity/insane diff --git a/code/modules/movespeed/modifiers/innate.dm b/code/modules/movespeed/modifiers/innate.dm index cd4b4601f82..ee4ed3a6ecf 100644 --- a/code/modules/movespeed/modifiers/innate.dm +++ b/code/modules/movespeed/modifiers/innate.dm @@ -1,18 +1,14 @@ /datum/movespeed_modifier/strained_muscles - id = MOVESPEED_ID_CHANGELING_MUSCLES multiplicative_slowdown = -1 blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/pai_spacewalk - id = MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD multiplicative_slowdown = 2 /datum/movespeed_modifier/species - id = MOVESPEED_ID_SPECIES movetypes = ~FLYING variable = TRUE /datum/movespeed_modifier/dna_vault_speedup - id = MOVESPEED_ID_DNA_VAULT blacklisted_movetypes = (FLYING|FLOATING) multiplicative_slowdown = -0.4 diff --git a/code/modules/movespeed/modifiers/items.dm b/code/modules/movespeed/modifiers/items.dm index d1ec480b465..e36c05dccee 100644 --- a/code/modules/movespeed/modifiers/items.dm +++ b/code/modules/movespeed/modifiers/items.dm @@ -3,13 +3,10 @@ movetypes = FLOATING /datum/movespeed_modifier/jetpack/cybernetic - id = MOVESPEED_ID_CYBER_THRUSTER multiplicative_slowdown = -0.5 /datum/movespeed_modifier/jetpack/fullspeed - id = MOVESPEED_ID_JETPACK multiplicative_slowdown = -0.5 /datum/movespeed_modifier/die_of_fate - id = MOVESPEED_ID_DIE_OF_FATE multiplicative_slowdown = 1 diff --git a/code/modules/movespeed/modifiers/misc.dm b/code/modules/movespeed/modifiers/misc.dm index 7e606e3f1e9..55c1aef5271 100644 --- a/code/modules/movespeed/modifiers/misc.dm +++ b/code/modules/movespeed/modifiers/misc.dm @@ -1,8 +1,6 @@ /datum/movespeed_modifier/admin_varedit variable = TRUE - id = MOVESPEED_ID_ADMIN_VAREDIT /datum/movespeed_modifier/yellow_orb - id = MOVESPEED_ID_YELLOW_ORB multiplicative_slowdown = -2 blacklisted_movetypes = (FLYING|FLOATING) diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm index 99bc4a17706..24a23923069 100644 --- a/code/modules/movespeed/modifiers/mobs.dm +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -1,44 +1,34 @@ /datum/movespeed_modifier/obesity - id = MOVESPEED_ID_FAT multiplicative_slowdown = 1.5 /datum/movespeed_modifier/monkey_reagent_speedmod variable = TRUE - id = MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD /datum/movespeed_modifier/monkey_health_speedmod variable = TRUE - id = MOVESPEED_ID_MONKEY_HEALTH_SPEEDMOD /datum/movespeed_modifier/monkey_temperature_speedmod variable = TRUE - id = MOVESPEED_ID_MONKEY_TEMPERATURE_SPEEDMOD /datum/movespeed_modifier/hunger - id = MOVESPEED_ID_HUNGRY variable = TRUE /datum/movespeed_modifier/slaughter - id = MOVESPEED_ID_SLAUGHTER multiplicative_slowdown = -1 /datum/movespeed_modifier/damage_slowdown - id = MOVESPEED_ID_DAMAGE_SLOWDOWN blacklisted_movetypes = FLOATING|FLYING variable = TRUE /datum/movespeed_modifier/damage_slowdown_flying - id = MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING movetypes = FLOATING variable = TRUE /datum/movespeed_modifier/equipment_speedmod variable = TRUE - id = MOVESPEED_ID_MOB_EQUIPMENT blacklisted_movetypes = FLOATING /datum/movespeed_modifier/grab_slowdown - id = MOVESPEED_ID_MOB_GRAB_STATE blacklisted_movetypes = FLOATING /datum/movespeed_modifier/grab_slowdown/aggressive @@ -51,15 +41,12 @@ multiplicative_slowdown = 9 /datum/movespeed_modifier/slime_reagentmod - id = MOVESPEED_ID_SLIME_REAGENTMOD variable = TRUE /datum/movespeed_modifier/slime_healthmod - id = MOVESPEED_ID_SLIME_HEALTHMOD variable = TRUE /datum/movespeed_modifier/config_walk_run - id = MOVESPEED_ID_MOB_WALK_RUN_CONFIG_SPEED multiplicative_slowdown = 1 /datum/movespeed_modifier/config_walk_run/proc/sync() @@ -73,58 +60,45 @@ multiplicative_slowdown = isnum(mod)? mod : initial(multiplicative_slowdown) /datum/movespeed_modifier/turf_slowdown - id = MOVESPEED_ID_LIVING_TURF_SPEEDMOD movetypes = GROUND blacklisted_movetypes = (FLYING|FLOATING) variable = TRUE /datum/movespeed_modifier/bulky_drag - id = MOVESPEED_ID_BULKY_DRAGGING variable = TRUE /datum/movespeed_modifier/cold - id = MOVESPEED_ID_COLD blacklisted_movetypes = FLOATING variable = TRUE /datum/movespeed_modifier/shove - id = MOVESPEED_ID_SHOVE multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH /datum/movespeed_modifier/human_carry - id = MOVESPEED_ID_HUMAN_CARRYING multiplicative_slowdown = HUMAN_CARRY_SLOWDOWN /datum/movespeed_modifier/limbless - id = MOVESPEED_ID_LIVING_LIMBLESS variable = TRUE movetypes = GROUND /datum/movespeed_modifier/simplemob_varspeed - id = MOVESPEED_ID_SIMPLEMOB_VARSPEED variable = TRUE /datum/movespeed_modifier/tarantula_web - id = MOVESPEED_ID_TARANTULA_WEB multiplicative_slowdown = 3 /datum/movespeed_modifier/gravity - id = MOVESPEED_ID_MOB_GRAVITY blacklisted_movetypes = FLOATING variable = TRUE /datum/movespeed_modifier/carbon_softcrit - id = MOVESPEED_ID_CARBON_SOFTCRIT multiplicative_slowdown = SOFTCRIT_ADD_SLOWDOWN /datum/movespeed_modifier/slime_tempmod - id = MOVESPEED_ID_SLIME_TEMPMOD variable = TRUE /datum/movespeed_modifier/carbon_crawling - id = MOVESPEED_ID_CARBON_CRAWLING multiplicative_slowdown = CRAWLING_ADD_SLOWDOWN /datum/movespeed_modifier/mob_config_speedmod - id = MOVESPEED_ID_CONFIG_SPEEDMOD variable = TRUE diff --git a/code/modules/movespeed/modifiers/reagent.dm b/code/modules/movespeed/modifiers/reagent.dm index 2c1353a471f..f1a54f98de3 100644 --- a/code/modules/movespeed/modifiers/reagent.dm +++ b/code/modules/movespeed/modifiers/reagent.dm @@ -2,41 +2,31 @@ blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/reagent/stimulants - id = "stimulants_reagent" multiplicative_slowdown = -1 /datum/movespeed_modifier/reagent/ephedrine - id = "ephedrine_reagent" multiplicative_slowdown = -0.5 /datum/movespeed_modifier/reagent/pepperspray - id = MOVESPEED_ID_PEPPER_SPRAY multiplicative_slowdown = 0.25 /datum/movespeed_modifier/reagent/badstims - id = "reagent_badstims" multiplicative_slowdown = -0.45 /datum/movespeed_modifier/reagent/monkey_energy - id = "reagent_monkey_energy" multiplicative_slowdown = -0.35 /datum/movespeed_modifier/reagent/changelinghaste - id = "reagent_changelinghaste" multiplicative_slowdown = -2 /datum/movespeed_modifier/reagent/methamphetamine - id = "reagent_methamphetamine" multiplicative_slowdown = -0.65 /datum/movespeed_modifier/reagent/nitryl - id = "reagent_nitryl" multiplicative_slowdown = -0.65 /datum/movespeed_modifier/reagent/lenturi - id = "reagent_lenturi" multiplicative_slowdown = 1.5 /datum/movespeed_modifier/reagent/nuka_cola - id = "reagent_nukacola" multiplicative_slowdown = -0.35 diff --git a/code/modules/movespeed/modifiers/status_effects.dm b/code/modules/movespeed/modifiers/status_effects.dm index de68bd78ed1..506a4672ef1 100644 --- a/code/modules/movespeed/modifiers/status_effects.dm +++ b/code/modules/movespeed/modifiers/status_effects.dm @@ -1,22 +1,17 @@ /datum/movespeed_modifier/status_effect/bloodchill - id = "bloodchilled" multiplicative_slowdown = 3 /datum/movespeed_modifier/status_effect/bonechill - id = "bonechilled" multiplicative_slowdown = 3 /datum/movespeed_modifier/status_effect/lightpink - id = MOVESPEED_ID_SLIME_STATUS multiplicative_slowdown = -0.5 blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/status_effect/tarfoot - id = MOVESPEED_ID_TARFOOT multiplicative_slowdown = 0.5 blacklisted_movetypes = (FLYING|FLOATING) /datum/movespeed_modifier/status_effect/sepia variable = TRUE - id = MOVESPEED_ID_SEPIA blacklisted_movetypes = (FLYING|FLOATING) From 8d16c25825b527843419cb996a6eb0355113834f Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 18 Feb 2020 00:06:12 -0700 Subject: [PATCH 27/34] these need ids --- code/__DEFINES/movespeed_modification.dm | 3 +++ code/datums/components/shrink.dm | 2 +- code/modules/movespeed/_movespeed_modifier.dm | 2 +- code/modules/movespeed/modifiers/components.dm | 1 + code/modules/movespeed/modifiers/mobs.dm | 1 + 5 files changed, 7 insertions(+), 2 deletions(-) diff --git a/code/__DEFINES/movespeed_modification.dm b/code/__DEFINES/movespeed_modification.dm index dacaaec6f71..832bd1bc55e 100644 --- a/code/__DEFINES/movespeed_modification.dm +++ b/code/__DEFINES/movespeed_modification.dm @@ -6,3 +6,6 @@ #define MOVE_CONFLICT_JETPACK "JETPACK" //ids +#define MOVESPEED_ID_SANITY "sanity_component" + +#define MOVESPEED_ID_MOB_GRAB_STATE "mob_grab_state" diff --git a/code/datums/components/shrink.dm b/code/datums/components/shrink.dm index 157eb36c373..3dfd131923a 100644 --- a/code/datums/components/shrink.dm +++ b/code/datums/components/shrink.dm @@ -34,7 +34,7 @@ parent_atom.opacity = oldopac if(isliving(parent_atom)) var/mob/living/L = parent_atom - L.remove_movespeed_modifier(MOVESPEED_ID_SHRINK_RAY) + L.remove_movespeed_modifier(/datum/movespeed_modifier/shrink_ray) if(ishuman(L)) var/mob/living/carbon/human/H = L H.physiology.damage_resistance += 100 diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm index dd8321c68ee..c6bab4dd712 100644 --- a/code/modules/movespeed/_movespeed_modifier.dm +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -118,7 +118,7 @@ GLOBAL_LIST_EMPTY(movespeed_modification_cache) if(!initial(type_id_datum.variable)) CRASH("Not a variable modifier") var/id = initial(type_id_datum.id) - final = LAZYACCESS(movespeed_modification, id || type_or_datum) + final = LAZYACCESS(movespeed_modification, id || type_id_datum) if(!final) final = new type_id_datum inject = TRUE diff --git a/code/modules/movespeed/modifiers/components.dm b/code/modules/movespeed/modifiers/components.dm index 758b8f5fb7a..a8f0db50181 100644 --- a/code/modules/movespeed/modifiers/components.dm +++ b/code/modules/movespeed/modifiers/components.dm @@ -7,6 +7,7 @@ movetypes = GROUND /datum/movespeed_modifier/sanity + id = MOVESPEED_ID_SANITY movetypes = (~FLYING) /datum/movespeed_modifier/sanity/insane diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm index 24a23923069..2f88a1c33f1 100644 --- a/code/modules/movespeed/modifiers/mobs.dm +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -29,6 +29,7 @@ blacklisted_movetypes = FLOATING /datum/movespeed_modifier/grab_slowdown + id = MOVESPEED_ID_MOB_GRAB_STATE blacklisted_movetypes = FLOATING /datum/movespeed_modifier/grab_slowdown/aggressive From 6dc2f474118014d4969aa2480e8877cb167bb132 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 18 Feb 2020 03:59:28 -0700 Subject: [PATCH 28/34] better idea --- code/__DEFINES/movespeed_modification.dm | 1 + code/datums/outfit.dm | 2 +- code/modules/movespeed/modifiers/mobs.dm | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/code/__DEFINES/movespeed_modification.dm b/code/__DEFINES/movespeed_modification.dm index 832bd1bc55e..6b8ef7bd567 100644 --- a/code/__DEFINES/movespeed_modification.dm +++ b/code/__DEFINES/movespeed_modification.dm @@ -9,3 +9,4 @@ #define MOVESPEED_ID_SANITY "sanity_component" #define MOVESPEED_ID_MOB_GRAB_STATE "mob_grab_state" +#define MOVESPEED_ID_MOB_WALK_RUN "mob_walk_run" diff --git a/code/datums/outfit.dm b/code/datums/outfit.dm index 518350c3be7..2843b558543 100755 --- a/code/datums/outfit.dm +++ b/code/datums/outfit.dm @@ -88,7 +88,7 @@ /// Internals box. Will be inserted at the start of backpack_contents var/box - /** + /** * Any implants the mob should start implanted with * * Format of this list is (typepath, typepath, typepath) diff --git a/code/modules/movespeed/modifiers/mobs.dm b/code/modules/movespeed/modifiers/mobs.dm index 2f88a1c33f1..cc92c38533e 100644 --- a/code/modules/movespeed/modifiers/mobs.dm +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -49,6 +49,7 @@ /datum/movespeed_modifier/config_walk_run multiplicative_slowdown = 1 + id = MOVESPEED_ID_MOB_WALK_RUN /datum/movespeed_modifier/config_walk_run/proc/sync() From 8f1a1a586d8dd33927690f52505674622311d822 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 18 Feb 2020 03:59:39 -0700 Subject: [PATCH 29/34] woops --- code/datums/outfit.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/datums/outfit.dm b/code/datums/outfit.dm index 2843b558543..518350c3be7 100755 --- a/code/datums/outfit.dm +++ b/code/datums/outfit.dm @@ -88,7 +88,7 @@ /// Internals box. Will be inserted at the start of backpack_contents var/box - /** + /** * Any implants the mob should start implanted with * * Format of this list is (typepath, typepath, typepath) From 052c50aef1d5997aca8eb274fb92bf4261c2c5f1 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Wed, 11 Mar 2020 22:54:56 -0700 Subject: [PATCH 30/34] wack --- code/datums/components/tackle.dm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/code/datums/components/tackle.dm b/code/datums/components/tackle.dm index 2719cf65a0a..9980a2fc96f 100644 --- a/code/datums/components/tackle.dm +++ b/code/datums/components/tackle.dm @@ -86,7 +86,7 @@ to_chat(user, "You're not ready to tackle!") return - if(user.has_movespeed_modifier(MOVESPEED_ID_SHOVE)) // can't tackle if you just got shoved + if(user.has_movespeed_modifier(/datum/movespeed_modifier/shove)) // can't tackle if you just got shoved to_chat(user, "You're too off balance to tackle!") return @@ -167,8 +167,8 @@ to_chat(target, "[user] lands a weak tackle on you, briefly knocking you off-balance!") user.Knockdown(30) - if(ishuman(target) && !T.has_movespeed_modifier(MOVESPEED_ID_SHOVE)) - T.add_movespeed_modifier(MOVESPEED_ID_SHOVE, multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH) // maybe define a slightly more severe/longer slowdown for this + if(ishuman(target) && !T.has_movespeed_modifier(/datum/movespeed_modifier/shove)) + T.add_movespeed_modifier(/datum/movespeed_modifier/shove) // maybe define a slightly more severe/longer slowdown for this addtimer(CALLBACK(T, /mob/living/carbon/human/proc/clear_shove_slowdown), SHOVE_SLOWDOWN_LENGTH) if(-1 to 0) // decent hit, both parties are about equally inconvenienced From ad46b3bcefe796a9d535f656b643d1b0e891d2d4 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 17 Mar 2020 09:44:44 -0700 Subject: [PATCH 31/34] Update code/modules/mob/living/living_movement.dm Co-Authored-By: Rohesie --- code/modules/mob/living/living_movement.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/living/living_movement.dm b/code/modules/mob/living/living_movement.dm index b2d222b25cb..b92b2654f78 100644 --- a/code/modules/mob/living/living_movement.dm +++ b/code/modules/mob/living/living_movement.dm @@ -29,7 +29,7 @@ add_movespeed_modifier((m_intent == MOVE_INTENT_WALK)? /datum/movespeed_modifier/config_walk_run/walk : /datum/movespeed_modifier/config_walk_run/run) /mob/living/proc/update_turf_movespeed(turf/open/T) - if(istype(T)) + if(isopenturf(T)) add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown, multiplicative_slowdown = T.slowdown) else remove_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown) From 1b985a5d88890a77a9fb15c3995e7f41089b0e66 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 17 Mar 2020 09:47:27 -0700 Subject: [PATCH 32/34] oh shit u right --- code/modules/mob/mob.dm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index afcabac7566..0101a376d5d 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1233,16 +1233,15 @@ /// Updates the grab state of the mob and updates movespeed /mob/setGrabState(newstate) . = ..() - if(grab_state == GRAB_PASSIVE) - remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAB_STATE) - else - switch(grab_state) - if(GRAB_AGGRESSIVE) - add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/aggressive) - if(GRAB_NECK) - add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/neck) - if(GRAB_KILL) - add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/kill) + switch(grab_state) + if(GRAB_PASSIVE) + remove_movespeed_modifier(MOVESPEED_ID_MOB_GRAB_STATE) + if(GRAB_AGGRESSIVE) + add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/aggressive) + if(GRAB_NECK) + add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/neck) + if(GRAB_KILL) + add_movespeed_modifier(/datum/movespeed_modifier/grab_slowdown/kill) /mob/proc/update_equipment_speed_mods() var/speedies = equipped_speed_mods() From a89cc9b913d5f5bdb1a60c29fffa38370193e975 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 17 Mar 2020 09:49:05 -0700 Subject: [PATCH 33/34] k --- code/modules/mob/living/carbon/human/human.dm | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/code/modules/mob/living/carbon/human/human.dm b/code/modules/mob/living/carbon/human/human.dm index 247ac153469..49a12ed2e3f 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1063,7 +1063,7 @@ return FALSE /mob/living/carbon/human/proc/clear_shove_slowdown() - remove_movespeed_modifier(MOVESPEED_ID_SHOVE) + remove_movespeed_modifier(/datum/movespeed_modifier/shove) var/active_item = get_active_held_item() if(is_type_in_typecache(active_item, GLOB.shove_disarming_types)) visible_message("[src.name] regains their grip on \the [active_item]!", "You regain your grip on \the [active_item]", null, COMBAT_MESSAGE_RANGE) @@ -1076,17 +1076,16 @@ . = ..() dna?.species.spec_updatehealth(src) if(HAS_TRAIT(src, TRAIT_IGNOREDAMAGESLOWDOWN)) - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN) - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING) + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) return var/health_deficiency = max((maxHealth - health), staminaloss) if(health_deficiency >= 40) - add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN, override = TRUE, multiplicative_slowdown = (health_deficiency / 75), blacklisted_movetypes = FLOATING|FLYING) - add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING, override = TRUE, multiplicative_slowdown = (health_deficiency / 25), movetypes = FLYING, blacklisted_movetypes = FLOATING) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown, TRUE, multiplicative_slowdown = health_deficiency / 75) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying, TRUE, multiplicative_slowdown = health_deficiency / 25) else - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN) - remove_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING) - + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown) + remove_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying) /mob/living/carbon/human/washed(var/atom/washer) . = ..() @@ -1106,12 +1105,12 @@ if(gloves && !(HIDEGLOVES in obscured) && gloves.washed(washer)) SEND_SIGNAL(src, COMSIG_COMPONENT_CLEAN_ACT, CLEAN_STRENGTH_BLOOD) -/mob/living/carbon/human/adjust_nutrition(var/change) //Honestly FUCK the oldcoders for putting nutrition on /mob someone else can move it up because holy hell I'd have to fix SO many typechecks +/mob/living/carbon/human/adjust_nutrition(change) //Honestly FUCK the oldcoders for putting nutrition on /mob someone else can move it up because holy hell I'd have to fix SO many typechecks if(HAS_TRAIT(src, TRAIT_NOHUNGER)) return FALSE return ..() -/mob/living/carbon/human/set_nutrition(var/change) //Seriously fuck you oldcoders. +/mob/living/carbon/human/set_nutrition(change) //Seriously fuck you oldcoders. if(HAS_TRAIT(src, TRAIT_NOHUNGER)) return FALSE return ..() From 93861edcef2a64e2d254c6dc41c5b6a7857298e7 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Tue, 17 Mar 2020 10:21:28 -0700 Subject: [PATCH 34/34] fix --- code/modules/clothing/shoes/_shoes.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/clothing/shoes/_shoes.dm b/code/modules/clothing/shoes/_shoes.dm index ee6c2beea9d..590769797eb 100644 --- a/code/modules/clothing/shoes/_shoes.dm +++ b/code/modules/clothing/shoes/_shoes.dm @@ -225,8 +225,8 @@ to_chat(our_guy, "You trip on your shoelaces a bit[have_anything ? ", flinging what you were holding" : ""]!") if(14 to 25) // 1.3ish% chance to stumble and be a bit off balance (like being disarmed) to_chat(our_guy, "You stumble a bit on your untied shoelaces!") - if(!our_guy.has_movespeed_modifier(MOVESPEED_ID_SHOVE)) - our_guy.add_movespeed_modifier(MOVESPEED_ID_SHOVE, multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH) + if(!our_guy.has_movespeed_modifier(/datum/movespeed_modifier/shove)) + our_guy.add_movespeed_modifier(/datum/movespeed_modifier/shove) addtimer(CALLBACK(our_guy, /mob/living/carbon/human/proc/clear_shove_slowdown), SHOVE_SLOWDOWN_LENGTH) if(26 to 1000) wiser = FALSE