From 63870cc9d1fce651cac364996655132440b078e1 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Wed, 22 Apr 2020 22:01:39 +0200 Subject: [PATCH 1/2] Movespeed modifiers refactor port. --- code/__DEFINES/combat.dm | 3 - code/__DEFINES/mobs.dm | 4 + code/__DEFINES/movespeed_modification.dm | 78 +------ code/__HELPERS/_lists.dm | 64 ++++-- .../configuration/entries/game_options.dm | 10 + code/controllers/subsystem/timer.dm | 4 +- code/datums/components/mood.dm | 12 +- code/datums/components/riding.dm | 4 +- code/datums/components/shrink.dm | 4 +- code/datums/dna.dm | 4 +- code/datums/status_effects/debuffs.dm | 19 +- code/game/objects/effects/mines.dm | 4 +- code/game/objects/items/tanks/jetpack.dm | 4 +- .../changeling/powers/strained_muscles.dm | 6 +- .../antagonists/slaughter/slaughter.dm | 4 +- code/modules/mob/living/carbon/carbon.dm | 5 +- code/modules/mob/living/carbon/human/human.dm | 14 +- .../mob/living/carbon/human/human_movement.dm | 12 +- .../mob/living/carbon/human/species.dm | 32 +-- .../mob/living/carbon/monkey/monkey.dm | 8 +- code/modules/mob/living/living_mobility.dm | 6 +- code/modules/mob/living/living_movement.dm | 24 +- code/modules/mob/living/silicon/pai/pai.dm | 4 +- .../simple_animal/hostile/giant_spider.dm | 4 +- .../mob/living/simple_animal/simple_animal.dm | 4 +- .../mob/living/simple_animal/slime/slime.dm | 13 +- code/modules/mob/living/status_procs.dm | 34 ++- code/modules/mob/mob.dm | 17 +- code/modules/mob/mob_defines.dm | 5 +- code/modules/mob/mob_movement.dm | 4 +- code/modules/mob/mob_movespeed.dm | 126 ---------- code/modules/movespeed/_movespeed_modifier.dm | 217 ++++++++++++++++++ .../modules/movespeed/modifiers/components.dm | 21 ++ code/modules/movespeed/modifiers/innate.dm | 20 ++ code/modules/movespeed/modifiers/items.dm | 12 + code/modules/movespeed/modifiers/misc.dm | 6 + code/modules/movespeed/modifiers/mobs.dm | 120 ++++++++++ code/modules/movespeed/modifiers/reagents.dm | 14 ++ .../movespeed/modifiers/status_effects.dm | 44 ++++ .../chemistry/reagents/drug_reagents.dm | 4 +- .../chemistry/reagents/medicine_reagents.dm | 16 +- .../chemistry/reagents/other_reagents.dm | 4 +- .../crossbreeding/_status_effects.dm | 24 +- code/modules/station_goals/dna_vault.dm | 2 +- code/modules/surgery/organs/augments_chest.dm | 4 +- code/modules/surgery/organs/liver.dm | 8 +- .../code/datums/status_effects/chems.dm | 18 +- tgstation.dme | 9 +- 48 files changed, 696 insertions(+), 383 deletions(-) delete mode 100644 code/modules/mob/mob_movespeed.dm create mode 100644 code/modules/movespeed/_movespeed_modifier.dm 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/items.dm create mode 100644 code/modules/movespeed/modifiers/misc.dm create mode 100644 code/modules/movespeed/modifiers/mobs.dm create mode 100644 code/modules/movespeed/modifiers/reagents.dm create mode 100644 code/modules/movespeed/modifiers/status_effects.dm diff --git a/code/__DEFINES/combat.dm b/code/__DEFINES/combat.dm index 14c78f90d0..b1664c5a7d 100644 --- a/code/__DEFINES/combat.dm +++ b/code/__DEFINES/combat.dm @@ -111,9 +111,6 @@ #define GRAB_NECK 2 #define GRAB_KILL 3 -//slowdown when in softcrit -#define SOFTCRIT_ADD_SLOWDOWN 6 - /// Attack types for check_block()/run_block(). Flags, combinable. /// Attack was melee, whether or not armed. #define ATTACK_TYPE_MELEE (1<<0) diff --git a/code/__DEFINES/mobs.dm b/code/__DEFINES/mobs.dm index e5f817614b..c89bd4843e 100644 --- a/code/__DEFINES/mobs.dm +++ b/code/__DEFINES/mobs.dm @@ -291,3 +291,7 @@ #define PULL_PRONE_SLOWDOWN 0.6 #define FIREMAN_CARRY_SLOWDOWN 0 #define PIGGYBACK_CARRY_SLOWDOWN 1 +//slowdown when in softcrit. Note that crawling slowdown will also apply at the same time! +#define SOFTCRIT_ADD_SLOWDOWN 2 +//slowdown when crawling +#define CRAWLING_ADD_SLOWDOWN 4 diff --git a/code/__DEFINES/movespeed_modification.dm b/code/__DEFINES/movespeed_modification.dm index 4d40474a3c..1f3ae63940 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) @@ -15,70 +6,7 @@ #define MOVE_CONFLICT_JETPACK "JETPACK" //ids +#define MOVESPEED_ID_SANITY "mood_sanity" -#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_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_SMALL_STRIDE "SMALL_STRIDE" -#define MOVESPEED_ID_PRONE_DRAGGING "PRONE_DRAG" -#define MOVESPEED_ID_HUMAN_CARRYING "HUMAN_CARRY" -#define MOVESPEED_ID_SHRINK_RAY "SHRUNKEN_SPEED_MODIFIER" - -#define MOVESPEED_ID_SLAUGHTER "SLAUGHTER" - -#define MOVESPEED_ID_CYBER_THRUSTER "CYBER_IMPLANT_THRUSTER" -#define MOVESPEED_ID_JETPACK "JETPACK" - -#define MOVESPEED_ID_MKULTRA "MKULTRA" - -#define MOVESPEED_ID_TASED_STATUS "TASED" -#define MOVESPEED_ID_ELECTROSTAFF "ELECTROSTAFF" - -#define MOVESPEED_ID_SHOVE "SHOVE" -#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_CIRRHOSIS "CIRRHOSIS" \ No newline at end of file +#define MOVESPEED_ID_MOB_GRAB_STATE "mob_grab_state" +#define MOVESPEED_ID_MOB_WALK_RUN "mob_walk_run" diff --git a/code/__HELPERS/_lists.dm b/code/__HELPERS/_lists.dm index a34b3ce67c..de7253c6a9 100644 --- a/code/__HELPERS/_lists.dm +++ b/code/__HELPERS/_lists.dm @@ -11,6 +11,7 @@ #define LAZYINITLIST(L) if (!L) L = list() #define UNSETEMPTY(L) if (L && !length(L)) L = null +#define LAZYCOPY(L) (L ? L.Copy() : list() ) #define LAZYREMOVE(L, I) if(L) { L -= I; if(!length(L)) { L = null; } } #define LAZYADD(L, I) if(!L) { L = list(); } L += I; #define LAZYOR(L, I) if(!L) { L = list(); } L |= I; @@ -21,34 +22,47 @@ #define LAZYCLEARLIST(L) if(L) L.Cut() #define SANITIZE_LIST(L) ( islist(L) ? L : list() ) #define reverseList(L) reverseRange(L.Copy()) +#define LAZYADDASSOC(L, K, V) if(!L) { L = list(); } L[K] += list(V); +#define LAZYREMOVEASSOC(L, K, V) if(L) { if(L[K]) { L[K] -= V; if(!length(L[K])) L -= K; } if(!length(L)) L = null; } -// binary search sorted insert -// IN: Object to be inserted -// LIST: List to insert object into -// TYPECONT: The typepath of the contents of the list -// COMPARE: The variable on the objects to compare -#define BINARY_INSERT(IN, LIST, TYPECONT, COMPARE) \ - var/__BIN_CTTL = length(LIST);\ - if(!__BIN_CTTL) {\ - LIST += IN;\ - } else {\ - var/__BIN_LEFT = 1;\ - var/__BIN_RIGHT = __BIN_CTTL;\ - var/__BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\ - var/##TYPECONT/__BIN_ITEM;\ - while(__BIN_LEFT < __BIN_RIGHT) {\ - __BIN_ITEM = LIST[__BIN_MID];\ - if(__BIN_ITEM.##COMPARE <= IN.##COMPARE) {\ - __BIN_LEFT = __BIN_MID + 1;\ - } else {\ - __BIN_RIGHT = __BIN_MID;\ +/// Passed into BINARY_INSERT to compare keys +#define COMPARE_KEY __BIN_LIST[__BIN_MID] +/// Passed into BINARY_INSERT to compare values +#define COMPARE_VALUE __BIN_LIST[__BIN_LIST[__BIN_MID]] + +/**** + * Binary search sorted insert + * INPUT: Object to be inserted + * LIST: List to insert object into + * TYPECONT: The typepath of the contents of the list + * COMPARE: The object to compare against, usualy the same as INPUT + * COMPARISON: The variable on the objects to compare + */ +#define BINARY_INSERT(INPUT, LIST, TYPECONT, COMPARE, COMPARISON, COMPTYPE) \ + do {\ + var/list/__BIN_LIST = LIST;\ + var/__BIN_CTTL = length(__BIN_LIST);\ + if(!__BIN_CTTL) {\ + __BIN_LIST += INPUT;\ + } else {\ + var/__BIN_LEFT = 1;\ + var/__BIN_RIGHT = __BIN_CTTL;\ + var/__BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\ + var/##TYPECONT/__BIN_ITEM;\ + while(__BIN_LEFT < __BIN_RIGHT) {\ + __BIN_ITEM = COMPTYPE;\ + if(__BIN_ITEM.##COMPARISON <= COMPARE.##COMPARISON) {\ + __BIN_LEFT = __BIN_MID + 1;\ + } else {\ + __BIN_RIGHT = __BIN_MID;\ + };\ + __BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\ };\ - __BIN_MID = (__BIN_LEFT + __BIN_RIGHT) >> 1;\ + __BIN_ITEM = COMPTYPE;\ + __BIN_MID = __BIN_ITEM.##COMPARISON > COMPARE.##COMPARISON ? __BIN_MID : __BIN_MID + 1;\ + __BIN_LIST.Insert(__BIN_MID, INPUT);\ };\ - __BIN_ITEM = LIST[__BIN_MID];\ - __BIN_MID = __BIN_ITEM.##COMPARE > IN.##COMPARE ? __BIN_MID : __BIN_MID + 1;\ - LIST.Insert(__BIN_MID, IN);\ - } + } while(FALSE) //Returns a list in plain english as a string /proc/english_list(list/input, nothing_text = "nothing", and_text = " and ", comma_text = ", ", final_comma_text = "" ) diff --git a/code/controllers/configuration/entries/game_options.dm b/code/controllers/configuration/entries/game_options.dm index 60eda61802..61d396a5af 100644 --- a/code/controllers/configuration/entries/game_options.dm +++ b/code/controllers/configuration/entries/game_options.dm @@ -248,8 +248,18 @@ /datum/config_entry/number/movedelay/run_delay +/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 +/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() + /datum/config_entry/number/movedelay/sprint_speed_increase config_entry_value = 1 diff --git a/code/controllers/subsystem/timer.dm b/code/controllers/subsystem/timer.dm index bd2fb854af..36bf992cfb 100644 --- a/code/controllers/subsystem/timer.dm +++ b/code/controllers/subsystem/timer.dm @@ -94,7 +94,7 @@ SUBSYSTEM_DEF(timer) if(ctime_timer.flags & TIMER_LOOP) ctime_timer.spent = 0 ctime_timer.timeToRun = REALTIMEOFDAY + ctime_timer.wait - BINARY_INSERT(ctime_timer, clienttime_timers, datum/timedevent, timeToRun) + BINARY_INSERT(ctime_timer, clienttime_timers, datum/timedevent, ctime_timer, timeToRun, COMPARE_KEY) else qdel(ctime_timer) @@ -423,7 +423,7 @@ SUBSYSTEM_DEF(timer) L = SStimer.second_queue if(L) - BINARY_INSERT(src, L, datum/timedevent, timeToRun) + BINARY_INSERT(src, L, datum/timedevent, src, timeToRun, COMPARE_KEY) return //get the list of buckets diff --git a/code/datums/components/mood.dm b/code/datums/components/mood.dm index 5e9382f88e..6938046e11 100644 --- a/code/datums/components/mood.dm +++ b/code/datums/components/mood.dm @@ -175,27 +175,27 @@ switch(sanity) if(-INFINITY to SANITY_CRAZY) setInsanityEffect(MAJOR_INSANITY_PEN) - master.add_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE, 100, override=TRUE, multiplicative_slowdown=1.5) //Did we change something ? movetypes is runtiming, movetypes=(~FLYING)) + 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(MOVESPEED_ID_SANITY, TRUE, 100, override=TRUE, multiplicative_slowdown=1)//, movetypes=(~FLYING)) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/crazy) 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.5)//, movetypes=(~FLYING)) + master.add_movespeed_modifier(/datum/movespeed_modifier/sanity/disturbed) sanity_level = 4 if(SANITY_DISTURBED to SANITY_NEUTRAL) setInsanityEffect(0) - master.remove_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE) + 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.remove_movespeed_modifier(MOVESPEED_ID_SANITY, TRUE) + master.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.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 4d8cfc4412..9b7eaa49ca 100644 --- a/code/datums/components/riding.dm +++ b/code/datums/components/riding.dm @@ -204,7 +204,7 @@ . = ..() var/mob/living/carbon/human/H = parent if(!length(H.buckled_mobs)) - H.remove_movespeed_modifier(MOVESPEED_ID_HUMAN_CARRYING) + H.remove_movespeed_modifier(/datum/movespeed_modifier/human_carry) if(!fireman_carrying) M.Daze(25) REMOVE_TRAIT(M, TRAIT_MOBILITY_NOUSE, src) @@ -213,7 +213,7 @@ . = ..() var/mob/living/carbon/human/H = parent if(length(H.buckled_mobs)) - H.add_movespeed_modifier(MOVESPEED_ID_HUMAN_CARRYING, multiplicative_slowdown = fireman_carrying? FIREMAN_CARRY_SLOWDOWN : PIGGYBACK_CARRY_SLOWDOWN) + H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/human_carry, TRUE, fireman_carrying? FIREMAN_CARRY_SLOWDOWN : PIGGYBACK_CARRY_SLOWDOWN) if(fireman_carrying) ADD_TRAIT(M, TRAIT_MOBILITY_NOUSE, src) diff --git a/code/datums/components/shrink.dm b/code/datums/components/shrink.dm index f070d9b22f..96807fe313 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) + L.add_movespeed_modifier(/datum/movespeed_modifier/shrink_ray) if(iscarbon(L)) var/mob/living/carbon/C = L C.unequip_everything() @@ -35,7 +35,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/datums/dna.dm b/code/datums/dna.dm index e08d5c509c..f57fb70ca8 100644 --- a/code/datums/dna.dm +++ b/code/datums/dna.dm @@ -662,6 +662,6 @@ var/danger = CONFIG_GET(number/threshold_body_size_slowdown) if(features["body_size"] < danger) var/slowdown = 1 + round(danger/features["body_size"], 0.1) * CONFIG_GET(number/body_size_slowdown_multiplier) - holder.add_movespeed_modifier(MOVESPEED_ID_SMALL_STRIDE, TRUE, 100, NONE, TRUE, slowdown, ALL, FLOATING|CRAWLING) + holder.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/small_stride, TRUE, slowdown) else if(old_size < danger) - holder.remove_movespeed_modifier(MOVESPEED_ID_SMALL_STRIDE) + holder.remove_movespeed_modifier(/datum/movespeed_modifier/small_stride) diff --git a/code/datums/status_effects/debuffs.dm b/code/datums/status_effects/debuffs.dm index 69b74841df..e15ac65258 100644 --- a/code/datums/status_effects/debuffs.dm +++ b/code/datums/status_effects/debuffs.dm @@ -120,12 +120,12 @@ /datum/status_effect/mesmerize/on_creation(mob/living/new_owner, set_duration) . = ..() ADD_TRAIT(owner, TRAIT_MUTE, "mesmerize") - owner.add_movespeed_modifier("[STATUS_EFFECT_MESMERIZE]_[id]", TRUE, priority = 64, override = TRUE, multiplicative_slowdown = 5, blacklisted_movetypes = FALSE? NONE : CRAWLING) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/mesmerize) /datum/status_effect/mesmerize/on_remove() . = ..() REMOVE_TRAIT(owner, TRAIT_MUTE, "mesmerize") - owner.remove_movespeed_modifier("[STATUS_EFFECT_MESMERIZE]_[id]") + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/mesmerize) /datum/status_effect/mesmerize/on_creation(mob/living/new_owner, set_duration) if(isnum(set_duration)) @@ -141,9 +141,7 @@ /datum/status_effect/electrode id = "tased" alert_type = null - var/slowdown = 1.5 - var/slowdown_priority = 50 //to make sure the stronger effect overrides - var/affect_crawl = FALSE + var/movespeed_mod = /datum/movespeed_modifier/status_effect/tased var/nextmove_modifier = 1 var/stamdmg_per_ds = 0 //a 20 duration would do 20 stamdmg, disablers do 24 or something var/last_tick = 0 //fastprocess processing speed is a goddamn sham, don't trust it. @@ -155,12 +153,12 @@ last_tick = world.time if(iscarbon(owner)) var/mob/living/carbon/C = owner - C.add_movespeed_modifier("[MOVESPEED_ID_TASED_STATUS]_[id]", TRUE, priority = slowdown_priority, override = TRUE, multiplicative_slowdown = slowdown, blacklisted_movetypes = affect_crawl? NONE : CRAWLING) + C.add_movespeed_modifier(movespeed_mod) /datum/status_effect/electrode/on_remove() if(iscarbon(owner)) var/mob/living/carbon/C = owner - C.remove_movespeed_modifier("[MOVESPEED_ID_TASED_STATUS]_[id]") + C.remove_movespeed_modifier(movespeed_mod) . = ..() /datum/status_effect/electrode/tick() @@ -178,8 +176,7 @@ /datum/status_effect/electrode/no_combat_mode id = "tased_strong" - slowdown = 8 - slowdown_priority = 100 + movespeed_mod = /datum/movespeed_modifier/status_effect/tased/no_combat_mode nextmove_modifier = 2 blocks_combatmode = TRUE stamdmg_per_ds = 1 @@ -650,11 +647,11 @@ if(isnum(set_duration)) duration = set_duration . = ..() - owner.add_movespeed_modifier(MOVESPEED_ID_ELECTROSTAFF, multiplicative_slowdown = 1, movetypes = GROUND) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/electrostaff) /datum/status_effect/electrostaff/on_remove() . = ..() - owner.remove_movespeed_modifier(MOVESPEED_ID_ELECTROSTAFF) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/electrostaff) //GOLEM GANG diff --git a/code/game/objects/effects/mines.dm b/code/game/objects/effects/mines.dm index 2fb068a29b..1fe5e46e25 100644 --- a/code/game/objects/effects/mines.dm +++ b/code/game/objects/effects/mines.dm @@ -170,7 +170,7 @@ 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.add_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) sleep(duration) - victim.remove_movespeed_modifier(MOVESPEED_ID_YELLOW_ORB) + victim.remove_movespeed_modifier(/datum/movespeed_modifier/yellow_orb) to_chat(victim, "You slow down.") diff --git a/code/game/objects/items/tanks/jetpack.dm b/code/game/objects/items/tanks/jetpack.dm index f592055338..e81294ceea 100644 --- a/code/game/objects/items/tanks/jetpack.dm +++ b/code/game/objects/items/tanks/jetpack.dm @@ -52,7 +52,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=-2, movetypes=FLOATING, conflict=MOVE_CONFLICT_JETPACK) + user.add_movespeed_modifier(/datum/movespeed_modifier/jetpack/fullspeed) /obj/item/tank/jetpack/proc/turn_off(mob/user) on = FALSE @@ -60,7 +60,7 @@ icon_state = initial(icon_state) ion_trail.stop() UnregisterSignal(user, COMSIG_MOVABLE_MOVED) - user.remove_movespeed_modifier(MOVESPEED_ID_JETPACK) + 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 a98700683e..d8572f04cc 100644 --- a/code/modules/antagonists/changeling/powers/strained_muscles.dm +++ b/code/modules/antagonists/changeling/powers/strained_muscles.dm @@ -21,7 +21,7 @@ to_chat(user, "Our muscles tense and strengthen.") changeling.chem_recharge_slowdown += 0.5 else - user.remove_movespeed_modifier(MOVESPEED_ID_CHANGELING_MUSCLES) + user.remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) to_chat(user, "Our muscles relax.") changeling.chem_recharge_slowdown -= 0.5 if(stacks >= 20) @@ -36,12 +36,12 @@ /obj/effect/proc_holder/changeling/strained_muscles/proc/muscle_loop(mob/living/carbon/user) var/datum/antagonist/changeling/changeling = user.mind.has_antag_datum(/datum/antagonist/changeling) while(active) - user.add_movespeed_modifier(MOVESPEED_ID_CHANGELING_MUSCLES, update=TRUE, priority=100, multiplicative_slowdown=-1, blacklisted_movetypes=(FLYING|FLOATING)) + 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.DefaultCombatKnockdown(40) - user.remove_movespeed_modifier(MOVESPEED_ID_CHANGELING_MUSCLES) + user.remove_movespeed_modifier(/datum/movespeed_modifier/strained_muscles) changeling.chem_recharge_slowdown -= 0.5 break diff --git a/code/modules/antagonists/slaughter/slaughter.dm b/code/modules/antagonists/slaughter/slaughter.dm index 475438ba52..5d409a7fb9 100644 --- a/code/modules/antagonists/slaughter/slaughter.dm +++ b/code/modules/antagonists/slaughter/slaughter.dm @@ -64,8 +64,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) + 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 diff --git a/code/modules/mob/living/carbon/carbon.dm b/code/modules/mob/living/carbon/carbon.dm index 377540233f..cef445113b 100644 --- a/code/modules/mob/living/carbon/carbon.dm +++ b/code/modules/mob/living/carbon/carbon.dm @@ -7,6 +7,7 @@ update_body_parts() //to update the carbon's new bodyparts appearance GLOB.carbon_list += src blood_volume = (BLOOD_VOLUME_NORMAL * blood_ratio) + add_movespeed_modifier(/datum/movespeed_modifier/carbon_crawling) /mob/living/carbon/Destroy() //This must be done first, so the mob ghosts correctly before DNA etc is nulled @@ -574,9 +575,9 @@ become_husk("burn") med_hud_set_health() if(stat == SOFT_CRIT) - add_movespeed_modifier(MOVESPEED_ID_CARBON_SOFTCRIT, TRUE, multiplicative_slowdown = SOFTCRIT_ADD_SLOWDOWN) + add_movespeed_modifier(/datum/movespeed_modifier/carbon_softcrit) else - remove_movespeed_modifier(MOVESPEED_ID_CARBON_SOFTCRIT, TRUE) + 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 94aba6851a..b1d14f2e10 100644 --- a/code/modules/mob/living/carbon/human/human.dm +++ b/code/modules/mob/living/carbon/human/human.dm @@ -1041,7 +1041,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) @@ -1050,17 +1050,17 @@ . = ..() if(HAS_TRAIT(src, TRAIT_IGNORESLOWDOWN)) - 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/stambufferinfluence = (bufferedstam*(100/stambuffer))*0.2 //CIT CHANGE - makes stamina buffer influence movedelay var/health_deficiency = ((100 + stambufferinfluence) - health + (getStaminaLoss()*0.75))//CIT CHANGE - reduces the impact of staminaloss and makes stamina buffer influence it if(health_deficiency >= 40) - add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN, override = TRUE, multiplicative_slowdown = ((health_deficiency-39) / 75), blacklisted_movetypes = FLOATING|FLYING) - add_movespeed_modifier(MOVESPEED_ID_DAMAGE_SLOWDOWN_FLYING, override = TRUE, multiplicative_slowdown = ((health_deficiency-39) / 25), movetypes = FLYING, blacklisted_movetypes = FLOATING) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown, TRUE, (health_deficiency-39) / 75) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/damage_slowdown_flying, TRUE, (health_deficiency-39) / 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/do_after_coefficent() . = ..() diff --git a/code/modules/mob/living/carbon/human/human_movement.dm b/code/modules/mob/living/carbon/human/human_movement.dm index a26bdd99cd..09dfa602e1 100644 --- a/code/modules/mob/living/carbon/human/human_movement.dm +++ b/code/modules/mob/living/carbon/human/human_movement.dm @@ -1,11 +1,13 @@ /mob/living/carbon/human/get_movespeed_modifiers() var/list/considering = ..() - . = considering if(HAS_TRAIT(src, TRAIT_IGNORESLOWDOWN)) - for(var/id in .) - var/list/data = .[id] - if(data[MOVESPEED_DATA_INDEX_FLAGS] & IGNORE_NOSLOW) - .[id] = data + . = list() + for(var/id in considering) + var/datum/movespeed_modifier/M = considering[id] + if(M.flags & IGNORE_NOSLOW || M.multiplicative_slowdown < 0) + .[id] = M + return + return considering /mob/living/carbon/human/movement_delay() . = ..() diff --git a/code/modules/mob/living/carbon/human/species.dm b/code/modules/mob/living/carbon/human/species.dm index 32e492f5fa..683c3e18fd 100644 --- a/code/modules/mob/living/carbon/human/species.dm +++ b/code/modules/mob/living/carbon/human/species.dm @@ -331,7 +331,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) if(mutant_bodyparts["meat_type"]) //I can't believe it's come to the meat H.type_of_meat = GLOB.meat_types[H.dna.features["meat_type"]] - 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, TRUE, multiplicative_slowdown = speedmod) SEND_SIGNAL(C, COMSIG_SPECIES_GAIN, src, old_species) @@ -349,7 +349,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) for(var/X in inherent_traits) REMOVE_TRAIT(C, X, SPECIES_TRAIT) - C.remove_movespeed_modifier(MOVESPEED_ID_SPECIES) + C.remove_movespeed_modifier(/datum/movespeed_modifier/species) if(mutant_bodyparts["meat_type"]) C.type_of_meat = GLOB.meat_types[C.dna.features["meat_type"]] @@ -1299,14 +1299,14 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) 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.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.add_movespeed_modifier(/datum/movespeed_modifier/obesity) H.update_inv_w_uniform() H.update_inv_wear_suit() @@ -1362,9 +1362,9 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) 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 - H.remove_movespeed_modifier(MOVESPEED_ID_HUNGRY) + H.remove_movespeed_modifier(/datum/movespeed_modifier/hunger) switch(H.nutrition) if(NUTRITION_LEVEL_FULL to INFINITY) @@ -1615,7 +1615,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) "You hear a slap." ) return FALSE - + else user.do_attack_animation(target, ATTACK_EFFECT_DISARM) @@ -1623,10 +1623,10 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) user.adjustStaminaLossBuffered(1) else user.adjustStaminaLossBuffered(3) - + if(attacker_style && attacker_style.disarm_act(user,target)) return TRUE - + if(target.w_uniform) target.w_uniform.add_fingerprint(user) //var/randomized_zone = ran_zone(user.zone_selected) CIT CHANGE - comments out to prevent compiling errors @@ -1659,7 +1659,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) randn -= 25 //if you are a pugilist, you're slapping that item from them pretty reliably if(HAS_TRAIT(target, TRAIT_PUGILIST)) randn += 25 //meanwhile, pugilists are less likely to get disarmed - + if(randn <= 35)//CIT CHANGE - changes this back to a 35% chance to accomodate for the above being commented out in favor of right-click pushing var/obj/item/I = null if(target.pulling) @@ -1932,8 +1932,8 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) var/obj/item/target_held_item = target.get_active_held_item() 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.has_movespeed_modifier(/datum/movespeed_modifier/shove)) + target.add_movespeed_modifier(/datum/movespeed_modifier/shove) if(target_held_item) if(!HAS_TRAIT(target_held_item, TRAIT_NODROP)) target.visible_message("[target.name]'s grip on \the [target_held_item] loosens!", @@ -2084,7 +2084,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) 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.remove_movespeed_modifier(/datum/movespeed_modifier/cold) var/burn_damage var/firemodifier = H.fire_stacks / 50 @@ -2101,8 +2101,8 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) else if(H.bodytemperature < BODYTEMP_COLD_DAMAGE_LIMIT && !HAS_TRAIT(H, TRAIT_RESISTCOLD)) 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) + //Apply cold slowdown + 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.apply_damage(COLD_DAMAGE_LEVEL_1*coldmod*H.physiology.cold_mod, BURN) @@ -2112,7 +2112,7 @@ GLOBAL_LIST_EMPTY(roundstart_race_names) H.apply_damage(COLD_DAMAGE_LEVEL_3*coldmod*H.physiology.cold_mod, BURN) else - H.remove_movespeed_modifier(MOVESPEED_ID_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/carbon/monkey/monkey.dm b/code/modules/mob/living/carbon/monkey/monkey.dm index d3e5941e4e..6242fa56be 100644 --- a/code/modules/mob/living/carbon/monkey/monkey.dm +++ b/code/modules/mob/living/carbon/monkey/monkey.dm @@ -65,12 +65,11 @@ /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(amount) - add_movespeed_modifier(MOVESPEED_ID_MONKEY_REAGENT_SPEEDMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = amount) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/monkey_reagent_speedmod, TRUE, amount) /mob/living/carbon/monkey/updatehealth() . = ..() @@ -78,7 +77,7 @@ var/health_deficiency = (100 - 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_variable_movespeed_modifier(/datum/movespeed_modifier/monkey_health_speedmod, TRUE, slow) /mob/living/carbon/monkey/adjust_bodytemperature(amount) . = ..() @@ -87,7 +86,7 @@ slow += (283.222 - bodytemperature) / 10 * 1.75 if(slow <= 0) return - add_movespeed_modifier(MOVESPEED_ID_MONKEY_TEMPERATURE_SPEEDMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = amount) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/monkey_temperature_speedmod, TRUE, slow) /mob/living/carbon/monkey/Stat() ..() @@ -99,7 +98,6 @@ if(changeling) stat("Chemical Storage", "[changeling.chem_charges]/[changeling.chem_storage]") stat("Absorbed DNA", changeling.absorbedcount) - return /mob/living/carbon/monkey/verb/removeinternal() diff --git a/code/modules/mob/living/living_mobility.dm b/code/modules/mob/living/living_mobility.dm index 49d4a20887..32038a6102 100644 --- a/code/modules/mob/living/living_mobility.dm +++ b/code/modules/mob/living/living_mobility.dm @@ -94,11 +94,13 @@ if(should_be_lying) mobility_flags &= ~MOBILITY_STAND + setMovetype(movement_type | CRAWLING) if(!lying) //force them on the ground lying = pick(90, 270) if(has_gravity() && !buckled) playsound(src, "bodyfall", 20, 1) else + setMovetype(movement_type & ~CRAWLING) mobility_flags |= MOBILITY_STAND lying = 0 @@ -161,8 +163,8 @@ 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, blacklisted_movetypes = FLYING|FLOATING) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/limbless, multiplicative_slowdown = limbless_slowdown) else - remove_movespeed_modifier(MOVESPEED_ID_LIVING_LIMBLESS, update=TRUE) + remove_movespeed_modifier(/datum/movespeed_modifier/limbless) return mobility_flags diff --git a/code/modules/mob/living/living_movement.dm b/code/modules/mob/living/living_movement.dm index ec291094fe..ddcf3e6292 100644 --- a/code/modules/mob/living/living_movement.dm +++ b/code/modules/mob/living/living_movement.dm @@ -36,38 +36,26 @@ sprint_stamina_cost = CONFIG_GET(number/movedelay/sprint_stamina_cost) return ..() -/mob/living/movement_delay(ignorewalk = 0) - . = ..() - if(!CHECK_MOBILITY(src, MOBILITY_STAND)) - . += 6 - /// whether or not we can slide under another living mob. defaults to if we're not dense. CanPass should check "overriding circumstances" like buckled mobs/having PASSMOB flag, etc. /mob/living/proc/can_move_under_living(mob/living/other) return !density /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) + 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(isopenturf(T) && !is_flying()) - add_movespeed_modifier(MOVESPEED_ID_LIVING_TURF_SPEEDMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = T.slowdown) + if(isopenturf(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) + remove_movespeed_modifier(/datum/movespeed_modifier/turf_slowdown) /mob/living/proc/update_pull_movespeed() if(pulling && isliving(pulling)) var/mob/living/L = pulling if(drag_slowdown && L.lying && !L.buckled && grab_state < GRAB_AGGRESSIVE) - add_movespeed_modifier(MOVESPEED_ID_PRONE_DRAGGING, multiplicative_slowdown = PULL_PRONE_SLOWDOWN) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/bulky_drag, multiplicative_slowdown = PULL_PRONE_SLOWDOWN) return - remove_movespeed_modifier(MOVESPEED_ID_PRONE_DRAGGING) + remove_movespeed_modifier(/datum/movespeed_modifier/bulky_drag) /mob/living/canZMove(dir, turf/target) return can_zTravel(target, dir) && (movement_type & FLYING) diff --git a/code/modules/mob/living/silicon/pai/pai.dm b/code/modules/mob/living/silicon/pai/pai.dm index 26fa3b505d..cdb5d421ae 100644 --- a/code/modules/mob/living/silicon/pai/pai.dm +++ b/code/modules/mob/living/silicon/pai/pai.dm @@ -273,9 +273,9 @@ /mob/living/silicon/pai/Process_Spacemove(movement_dir = 0) . = ..() if(!.) - add_movespeed_modifier(MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD, TRUE, 100, multiplicative_slowdown = 2) + add_movespeed_modifier(/datum/movespeed_modifier/pai_spacewalk) return TRUE - remove_movespeed_modifier(MOVESPEED_ID_PAI_SPACEWALK_SPEEDMOD, TRUE) + 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/hostile/giant_spider.dm b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm index 439bedf3cc..f19aa0a2a7 100644 --- a/code/modules/mob/living/simple_animal/hostile/giant_spider.dm +++ b/code/modules/mob/living/simple_animal/hostile/giant_spider.dm @@ -186,10 +186,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 //midwives are the queen of the spiders, can send messages to all them and web faster. That rare round where you get a queen spider and turn your 'for honor' players into 'r6siege' players will be a fun one. diff --git a/code/modules/mob/living/simple_animal/simple_animal.dm b/code/modules/mob/living/simple_animal/simple_animal.dm index 3feed2129b..a831dc6f16 100644 --- a/code/modules/mob/living/simple_animal/simple_animal.dm +++ b/code/modules/mob/living/simple_animal/simple_animal.dm @@ -292,8 +292,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) + 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 8594d53bd1..dd454c4243 100644 --- a/code/modules/mob/living/simple_animal/slime/slime.dm +++ b/code/modules/mob/living/simple_animal/slime/slime.dm @@ -147,25 +147,25 @@ /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() . = ..() - remove_movespeed_modifier(MOVESPEED_ID_SLIME_HEALTHMOD, FALSE) + remove_movespeed_modifier(/datum/movespeed_modifier/slime_healthmod) var/health_deficiency = (100 - health) var/mod = 0 if(health_deficiency >= 45) mod += (health_deficiency / 25) if(health <= 0) mod += 2 - add_movespeed_modifier(MOVESPEED_ID_SLIME_HEALTHMOD, TRUE, 100, multiplicative_slowdown = mod) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/slime_healthmod, multiplicative_slowdown = mod) /mob/living/simple_animal/slime/adjust_bodytemperature() . = ..() @@ -173,9 +173,8 @@ if(bodytemperature >= 330.23) // 135 F or 57.08 C mod = -1 // slimes become supercharged at high temperatures else if(bodytemperature < 183.222) - mod = (283.222 - bodytemperature) / 10 * 1.75 - if(mod) - add_movespeed_modifier(MOVESPEED_ID_SLIME_TEMPMOD, TRUE, 100, override = TRUE, multiplicative_slowdown = mod) + mod = min(15, (283.222 - bodytemperature) / 10 * 1.75) + 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/living/status_procs.dm b/code/modules/mob/living/status_procs.dm index 1375d88948..0d41347179 100644 --- a/code/modules/mob/living/status_procs.dm +++ b/code/modules/mob/living/status_procs.dm @@ -622,10 +622,40 @@ tod = STATION_TIME_TIMESTAMP("hh:mm:ss", world.time) update_stat() +///Unignores all slowdowns that lack the IGNORE_NOSLOW flag. /mob/living/proc/unignore_slowdown(source) REMOVE_TRAIT(src, TRAIT_IGNORESLOWDOWN, source) - update_movespeed(FALSE) + update_movespeed() +///Ignores all slowdowns that lack the IGNORE_NOSLOW flag. /mob/living/proc/ignore_slowdown(source) ADD_TRAIT(src, TRAIT_IGNORESLOWDOWN, source) - update_movespeed(FALSE) + update_movespeed() + +///Ignores specific slowdowns. Accepts a list of slowdowns. +/mob/living/proc/add_movespeed_mod_immunities(source, slowdown_type, update = TRUE) + if(islist(slowdown_type)) + for(var/listed_type in slowdown_type) + if(ispath(listed_type)) + listed_type = "[listed_type]" //Path2String + LAZYADDASSOC(movespeed_mod_immunities, listed_type, source) + else + if(ispath(slowdown_type)) + slowdown_type = "[slowdown_type]" //Path2String + LAZYADDASSOC(movespeed_mod_immunities, slowdown_type, source) + if(update) + update_movespeed() + +///Unignores specific slowdowns. Accepts a list of slowdowns. +/mob/living/proc/remove_movespeed_mod_immunities(source, slowdown_type, update = TRUE) + if(islist(slowdown_type)) + for(var/listed_type in slowdown_type) + if(ispath(listed_type)) + listed_type = "[listed_type]" //Path2String + LAZYREMOVEASSOC(movespeed_mod_immunities, listed_type, source) + else + if(ispath(slowdown_type)) + slowdown_type = "[slowdown_type]" //Path2String + LAZYREMOVEASSOC(movespeed_mod_immunities, slowdown_type, source) + if(update) + update_movespeed() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index fd786c8631..088e758f06 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -1033,17 +1033,22 @@ GLOBAL_VAR_INIT(exploit_warn_spam_prevention, 0) /// 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, update=TRUE) - 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_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() if(!speedies) - remove_movespeed_modifier(MOVESPEED_ID_MOB_EQUIPMENT, update=TRUE) + remove_movespeed_modifier(/datum/movespeed_modifier/equipment_speedmod, update=TRUE) 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_defines.dm b/code/modules/mob/mob_defines.dm index bf9dad1bc7..7d177e7ac2 100644 --- a/code/modules/mob/mob_defines.dm +++ b/code/modules/mob/mob_defines.dm @@ -42,8 +42,11 @@ var/lying_prev = 0 var/is_shifted = FALSE - //MOVEMENT SPEED + /// List of movement speed modifiers applying to this mob var/list/movespeed_modification //Lazy list, see mob_movespeed.dm + /// List of movement speed modifiers ignored by this mob. List -> List (id) -> List (sources) + var/list/movespeed_mod_immunities //Lazy list, see mob_movespeed.dm + /// The calculated mob speed slowdown based on the modifiers list var/cached_multiplicative_slowdown ///////////////// diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index ffc0970bdf..9bef48320b 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -251,9 +251,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) + 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_movespeed_modifier(/datum/movespeed_modifier/gravity, multiplicative_slowdown = speed_change) //bodypart selection - Cyberboss //8 toggles through head - eyes - mouth diff --git a/code/modules/mob/mob_movespeed.dm b/code/modules/mob/mob_movespeed.dm deleted file mode 100644 index a0be8ff7cb..0000000000 --- a/code/modules/mob/mob_movespeed.dm +++ /dev/null @@ -1,126 +0,0 @@ - -/*Current movespeed modification list format: list(id = list( - priority, - flags, - legacy slowdown/speedup amount, - movetype_flags, - blacklisted_movetypes, - conflict - )) -*/ - -//ANY ADD/REMOVE DONE IN UPDATE_MOVESPEED MUST HAVE THE UPDATE ARGUMENT SET AS FALSE! -/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)) - 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) - if(update) - update_movespeed(resort) - return TRUE - -/mob/proc/remove_movespeed_modifier(id, update = TRUE) - if(!LAZYACCESS(movespeed_modification, id)) - return FALSE - LAZYREMOVE(movespeed_modification, id) - UNSETEMPTY(movespeed_modification) - if(update) - update_movespeed(FALSE) - return TRUE - -/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) - -/mob/proc/has_movespeed_modifier(id) - return LAZYACCESS(movespeed_modification, id) - -/mob/proc/update_config_movespeed() - add_movespeed_modifier(MOVESPEED_ID_CONFIG_SPEEDMOD, FALSE, 100, override = TRUE, multiplicative_slowdown = get_config_multiplicative_speed()) - -/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] - -/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 = . - -/mob/proc/get_movespeed_modifiers() - return movespeed_modification - -/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 - -/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] - -/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 - -/mob/proc/sort_movespeed_modlist() //Verifies it too. Sorts highest priority (first applied) to lowest priority (last applied) - 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) \ No newline at end of file diff --git a/code/modules/movespeed/_movespeed_modifier.dm b/code/modules/movespeed/_movespeed_modifier.dm new file mode 100644 index 0000000000..0976f4d067 --- /dev/null +++ b/code/modules/movespeed/_movespeed_modifier.dm @@ -0,0 +1,217 @@ +/*! 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. 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 (converted to text) 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. + 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 + +/datum/movespeed_modifier/New() + . = ..() + if(!id) + id = "[type]" //We turn the path into a string. + +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_modifier(modtype) + if(!ispath(modtype, /datum/movespeed_modifier)) + CRASH("[modtype] is not a movespeed modification typepath.") + var/datum/movespeed_modifier/M = modtype + if(initial(M.variable)) + CRASH("[modtype] is a variable modifier, and can never be cached.") + 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) + if(ispath(type_or_datum)) + if(!initial(type_or_datum.variable)) + 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) + 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) + 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)) + key = initial(type_id_datum.id) || "[type_id_datum]" //id if set, path set to string 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. + key = type_id_datum.id + else //assume it's an id + key = type_id_datum + if(!LAZYACCESS(movespeed_modification, key)) + return FALSE + 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 + 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 provided a text ID.") + else if(ispath(type_id_datum)) + if(!initial(type_id_datum.variable)) + CRASH("Not a variable modifier") + final = LAZYACCESS(movespeed_modification, initial(type_id_datum.id) || "[type_id_datum]") + if(!final) + final = new type_id_datum + inject = TRUE + modified = TRUE + else + if(!initial(type_id_datum.variable)) + CRASH("Not a variable modifier") + final = type_id_datum + if(!LAZYACCESS(movespeed_modification, final.id)) + inject = TRUE + modified = TRUE + if(!isnull(multiplicative_slowdown)) + final.multiplicative_slowdown = multiplicative_slowdown + modified = TRUE + if(inject) + add_movespeed_modifier(final, FALSE) + if(update && modified) + update_movespeed(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(/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/has_movespeed_modifier(datum/movespeed_modifier/datum_type_id) + var/key + if(ispath(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 + return LAZYACCESS(movespeed_modification, key) + +/// 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 +/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. 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/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 + continue + var/conflict = M.conflicts_with + 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 + 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() + . = LAZYCOPY(movespeed_modification) + for(var/id in movespeed_mod_immunities) + . -= id + +/// 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 +/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) + . = FALSE diff --git a/code/modules/movespeed/modifiers/components.dm b/code/modules/movespeed/modifiers/components.dm new file mode 100644 index 0000000000..436b85e2e1 --- /dev/null +++ b/code/modules/movespeed/modifiers/components.dm @@ -0,0 +1,21 @@ +/datum/movespeed_modifier/shrink_ray + movetypes = GROUND + multiplicative_slowdown = 4 + flags = IGNORE_NOSLOW + +/datum/movespeed_modifier/snail_crawl + multiplicative_slowdown = -7 + movetypes = GROUND + +/datum/movespeed_modifier/sanity + id = MOVESPEED_ID_SANITY + blacklisted_movetypes = FLYING + +/datum/movespeed_modifier/sanity/insane + multiplicative_slowdown = 1.5 + +/datum/movespeed_modifier/sanity/crazy + multiplicative_slowdown = 1 + +/datum/movespeed_modifier/sanity/disturbed + multiplicative_slowdown = 0.5 diff --git a/code/modules/movespeed/modifiers/innate.dm b/code/modules/movespeed/modifiers/innate.dm new file mode 100644 index 0000000000..a0357ddf0f --- /dev/null +++ b/code/modules/movespeed/modifiers/innate.dm @@ -0,0 +1,20 @@ +/datum/movespeed_modifier/strained_muscles + multiplicative_slowdown = -1 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/pai_spacewalk + multiplicative_slowdown = 2 + flags = IGNORE_NOSLOW + +/datum/movespeed_modifier/species + movetypes = ~FLYING + variable = TRUE + +/datum/movespeed_modifier/dna_vault_speedup + blacklisted_movetypes = (FLYING|FLOATING) + multiplicative_slowdown = -1 + +/datum/movespeed_modifier/small_stride + blacklisted_movetypes = (FLOATING|CRAWLING) + variable = TRUE + flags = IGNORE_NOSLOW diff --git a/code/modules/movespeed/modifiers/items.dm b/code/modules/movespeed/modifiers/items.dm new file mode 100644 index 0000000000..94dc2a1553 --- /dev/null +++ b/code/modules/movespeed/modifiers/items.dm @@ -0,0 +1,12 @@ +/datum/movespeed_modifier/jetpack + conflicts_with = MOVE_CONFLICT_JETPACK + movetypes = FLOATING + +/datum/movespeed_modifier/jetpack/cybernetic + multiplicative_slowdown = -0.5 + +/datum/movespeed_modifier/jetpack/fullspeed + multiplicative_slowdown = -2 + +/datum/movespeed_modifier/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 0000000000..55c1aef527 --- /dev/null +++ b/code/modules/movespeed/modifiers/misc.dm @@ -0,0 +1,6 @@ +/datum/movespeed_modifier/admin_varedit + variable = TRUE + +/datum/movespeed_modifier/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 new file mode 100644 index 0000000000..aa60966591 --- /dev/null +++ b/code/modules/movespeed/modifiers/mobs.dm @@ -0,0 +1,120 @@ +/datum/movespeed_modifier/obesity + multiplicative_slowdown = 1.5 + +/datum/movespeed_modifier/monkey_reagent_speedmod + blacklisted_movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/monkey_health_speedmod + blacklisted_movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/monkey_temperature_speedmod + blacklisted_movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/hunger + variable = TRUE + +/datum/movespeed_modifier/slaughter + multiplicative_slowdown = -1 + +/datum/movespeed_modifier/damage_slowdown + blacklisted_movetypes = FLOATING|FLYING + variable = TRUE + +/datum/movespeed_modifier/damage_slowdown_flying + movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/equipment_speedmod + variable = TRUE + 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 + variable = TRUE + +/datum/movespeed_modifier/slime_healthmod + variable = TRUE + +/datum/movespeed_modifier/config_walk_run + multiplicative_slowdown = 1 + id = MOVESPEED_ID_MOB_WALK_RUN + flags = IGNORE_NOSLOW + +/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 + movetypes = GROUND + blacklisted_movetypes = (FLYING|FLOATING) + variable = TRUE + +/datum/movespeed_modifier/bulky_drag + variable = TRUE + +/datum/movespeed_modifier/cold + blacklisted_movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/shove + multiplicative_slowdown = SHOVE_SLOWDOWN_STRENGTH + +/datum/movespeed_modifier/human_carry + variable = TRUE + +/datum/movespeed_modifier/limbless + variable = TRUE + movetypes = GROUND + flags = IGNORE_NOSLOW + +/datum/movespeed_modifier/simplemob_varspeed + variable = TRUE + flags = IGNORE_NOSLOW + +/datum/movespeed_modifier/tarantula_web + multiplicative_slowdown = 3 + +/datum/movespeed_modifier/gravity + blacklisted_movetypes = FLOATING + variable = TRUE + flags = IGNORE_NOSLOW + +/datum/movespeed_modifier/carbon_softcrit + multiplicative_slowdown = SOFTCRIT_ADD_SLOWDOWN + +/datum/movespeed_modifier/slime_tempmod + variable = TRUE + +/datum/movespeed_modifier/carbon_crawling + multiplicative_slowdown = CRAWLING_ADD_SLOWDOWN + movetypes = CRAWLING + flags = IGNORE_NOSLOW + +/datum/movespeed_modifier/mob_config_speedmod + variable = TRUE + flags = IGNORE_NOSLOW + +/datum/movespeed_modifier/liver_cirrhosis + blacklisted_movetypes = FLOATING + variable = TRUE diff --git a/code/modules/movespeed/modifiers/reagents.dm b/code/modules/movespeed/modifiers/reagents.dm new file mode 100644 index 0000000000..b6c2458670 --- /dev/null +++ b/code/modules/movespeed/modifiers/reagents.dm @@ -0,0 +1,14 @@ +/datum/movespeed_modifier/reagent + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/reagent/stimulants + multiplicative_slowdown = -0.5 + +/datum/movespeed_modifier/reagent/changelinghaste + multiplicative_slowdown = -2 + +/datum/movespeed_modifier/reagent/skooma + multiplicative_slowdown = -1 + +/datum/movespeed_modifier/reagent/nitryl + multiplicative_slowdown = -1 diff --git a/code/modules/movespeed/modifiers/status_effects.dm b/code/modules/movespeed/modifiers/status_effects.dm new file mode 100644 index 0000000000..4c710cb483 --- /dev/null +++ b/code/modules/movespeed/modifiers/status_effects.dm @@ -0,0 +1,44 @@ +/datum/movespeed_modifier/status_effect/bloodchill + multiplicative_slowdown = 3 + +/datum/movespeed_modifier/status_effect/bonechill + multiplicative_slowdown = 3 + +/datum/movespeed_modifier/status_effect/tarfoot + multiplicative_slowdown = 0.5 + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/status_effect/sepia + variable = TRUE + blacklisted_movetypes = (FLYING|FLOATING) + +/datum/movespeed_modifier/status_effect/mesmerize + blacklisted_movetypes = CRAWLING + multiplicative_slowdown = 5 + priority = 64 + +/datum/movespeed_modifier/status_effect/tased + multiplicative_slowdown = 1.5 + priority = 50 + +/datum/movespeed_modifier/status_effect/tased/no_combat_mode + multiplicative_slowdown = 8 + priority = 100 + +/datum/movespeed_modifier/status_effect/electrostaff + multiplicative_slowdown = 1 + movetypes = GROUND + +//no comment. +/datum/movespeed_modifier/status_effect/breast_hypertrophy + blacklisted_movetypes = FLOATING + variable = TRUE + +//this shouldn't even exist. +/datum/movespeed_modifier/status_effect/penis_hypertrophy + blacklisted_movetypes = FLOATING + variable = TRUE + +/datum/movespeed_modifier/status_effect/mkultra + multiplicative_slowdown = -2 + blacklisted_movetypes= FLYING|FLOATING diff --git a/code/modules/reagents/chemistry/reagents/drug_reagents.dm b/code/modules/reagents/chemistry/reagents/drug_reagents.dm index c96feec4e2..50e8658215 100644 --- a/code/modules/reagents/chemistry/reagents/drug_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/drug_reagents.dm @@ -460,7 +460,7 @@ /datum/reagent/drug/skooma/on_mob_metabolize(mob/living/L) . = ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-1, blacklisted_movetypes=(FLYING|FLOATING)) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/skooma) L.next_move_modifier *= 2 if(ishuman(L)) var/mob/living/carbon/human/H = L @@ -473,7 +473,7 @@ /datum/reagent/drug/skooma/on_mob_end_metabolize(mob/living/L) . = ..() - L.remove_movespeed_modifier(type) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/skooma) L.next_move_modifier *= 0.5 if(ishuman(L)) var/mob/living/carbon/human/H = L diff --git a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm index ecceb6e8bf..1cf1a65c75 100644 --- a/code/modules/reagents/chemistry/reagents/medicine_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/medicine_reagents.dm @@ -708,10 +708,10 @@ datum/reagent/medicine/styptic_powder/overdose_start(mob/living/M) /datum/reagent/medicine/morphine/on_mob_metabolize(mob/living/L) ..() - L.ignore_slowdown(type) + L.add_movespeed_mod_immunities(type, list(/datum/movespeed_modifier/damage_slowdown, /datum/movespeed_modifier/damage_slowdown_flying, /datum/movespeed_modifier/monkey_health_speedmod)) /datum/reagent/medicine/morphine/on_mob_end_metabolize(mob/living/L) - L.unignore_slowdown(type) + L.remove_movespeed_mod_immunities(type, list(/datum/movespeed_modifier/damage_slowdown, /datum/movespeed_modifier/damage_slowdown_flying, /datum/movespeed_modifier/monkey_health_speedmod)) ..() /datum/reagent/medicine/morphine/on_mob_life(mob/living/carbon/M) @@ -993,11 +993,11 @@ datum/reagent/medicine/styptic_powder/overdose_start(mob/living/M) /datum/reagent/medicine/stimulants/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-0.5, blacklisted_movetypes=(FLYING|FLOATING)) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) ADD_TRAIT(L, TRAIT_TASED_RESISTANCE, type) /datum/reagent/medicine/stimulants/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/stimulants) REMOVE_TRAIT(L, TRAIT_TASED_RESISTANCE, type) ..() @@ -1332,10 +1332,10 @@ datum/reagent/medicine/styptic_powder/overdose_start(mob/living/M) /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.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.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/changelinghaste) ..() /datum/reagent/medicine/changelinghaste/on_mob_life(mob/living/carbon/M) @@ -1368,11 +1368,11 @@ datum/reagent/medicine/styptic_powder/overdose_start(mob/living/M) /datum/reagent/medicine/muscle_stimulant/on_mob_metabolize(mob/living/M) . = ..() - M.ignore_slowdown(type) + M.add_movespeed_mod_immunities(type, list(/datum/movespeed_modifier/damage_slowdown, /datum/movespeed_modifier/damage_slowdown_flying, /datum/movespeed_modifier/monkey_health_speedmod)) /datum/reagent/medicine/muscle_stimulant/on_mob_end_metabolize(mob/living/M) . = ..() - M.unignore_slowdown(type) + M.remove_movespeed_mod_immunities(type, list(/datum/movespeed_modifier/damage_slowdown, /datum/movespeed_modifier/damage_slowdown_flying, /datum/movespeed_modifier/monkey_health_speedmod)) /datum/reagent/medicine/modafinil name = "Modafinil" diff --git a/code/modules/reagents/chemistry/reagents/other_reagents.dm b/code/modules/reagents/chemistry/reagents/other_reagents.dm index e66ebc5f20..ff44416e42 100644 --- a/code/modules/reagents/chemistry/reagents/other_reagents.dm +++ b/code/modules/reagents/chemistry/reagents/other_reagents.dm @@ -1445,10 +1445,10 @@ /datum/reagent/nitryl/on_mob_metabolize(mob/living/L) ..() - L.add_movespeed_modifier(type, update=TRUE, priority=100, multiplicative_slowdown=-1, blacklisted_movetypes=(FLYING|FLOATING)) + L.add_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) /datum/reagent/nitryl/on_mob_end_metabolize(mob/living/L) - L.remove_movespeed_modifier(type) + L.remove_movespeed_modifier(/datum/movespeed_modifier/reagent/nitryl) ..() /////////////////////////Coloured Crayon Powder//////////////////////////// diff --git a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm index 95d6c49529..4fd7c2105f 100644 --- a/code/modules/research/xenobiology/crossbreeding/_status_effects.dm +++ b/code/modules/research/xenobiology/crossbreeding/_status_effects.dm @@ -191,7 +191,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.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) return ..() /datum/status_effect/bloodchill/tick() @@ -199,7 +199,7 @@ owner.adjustFireLoss(2) /datum/status_effect/bloodchill/on_remove() - owner.remove_movespeed_modifier("bloodchilled") + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bloodchill) return ..() /obj/screen/alert/status_effect/bloodchill @@ -213,7 +213,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.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) return ..() /datum/status_effect/bonechill/tick() @@ -223,7 +223,7 @@ owner.adjust_bodytemperature(-10) /datum/status_effect/bonechill/on_remove() - owner.remove_movespeed_modifier("bonechilled") + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/bonechill) return ..() /obj/screen/alert/status_effect/bonechill @@ -385,11 +385,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.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) return ..() /datum/status_effect/tarfoot/on_remove() - owner.remove_movespeed_modifier(MOVESPEED_ID_TARFOOT) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/tarfoot) return ..() /datum/status_effect/spookcookie @@ -707,15 +707,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, update=TRUE, priority=100, multiplicative_slowdown=-1, blacklisted_movetypes=(FLYING|FLOATING)) + owner.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia, multiplicative_slowdown = 1) 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, 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.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/sepia) return ..() /datum/status_effect/stabilized/cerulean @@ -777,11 +777,11 @@ datum/status_effect/stabilized/blue/on_remove() colour = "red" /datum/status_effect/stabilized/red/on_apply() - owner.ignore_slowdown("slimestatus") - return ..() + . = ..() + owner.add_movespeed_mod_immunities(type, /datum/movespeed_modifier/equipment_speedmod) /datum/status_effect/stabilized/red/on_remove() - owner.unignore_slowdown("slimestatus") + owner.remove_movespeed_mod_immunities(type, /datum/movespeed_modifier/equipment_speedmod) return ..() /datum/status_effect/stabilized/green diff --git a/code/modules/station_goals/dna_vault.dm b/code/modules/station_goals/dna_vault.dm index 2aae17b0f3..6c21456e63 100644 --- a/code/modules/station_goals/dna_vault.dm +++ b/code/modules/station_goals/dna_vault.dm @@ -276,7 +276,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=-1, blacklisted_movetypes=(FLYING|FLOATING)) + 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 47a452cc76..eb42303060 100644 --- a/code/modules/surgery/organs/augments_chest.dm +++ b/code/modules/surgery/organs/augments_chest.dm @@ -165,14 +165,14 @@ 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=-2, movetypes=FLOATING, conflict=MOVE_CONFLICT_JETPACK) + owner.add_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) if(!silent) to_chat(owner, "You turn your thrusters set on.") else ion_trail.stop() if(!QDELETED(owner)) UnregisterSignal(owner, COMSIG_MOVABLE_MOVED) - owner.remove_movespeed_modifier(MOVESPEED_ID_CYBER_THRUSTER) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/jetpack/cybernetic) if(!silent) to_chat(owner, "You turn your thrusters set off.") on = FALSE diff --git a/code/modules/surgery/organs/liver.dm b/code/modules/surgery/organs/liver.dm index 6e5ea0e111..f4771de14f 100755 --- a/code/modules/surgery/organs/liver.dm +++ b/code/modules/surgery/organs/liver.dm @@ -56,22 +56,22 @@ return if(damage >= high_threshold) var/move_calc = 1+((round(damage) - high_threshold)/(high_threshold/3)) - owner.add_movespeed_modifier(MOVESPEED_ID_CIRRHOSIS, TRUE, 100, NONE, override = TRUE, multiplicative_slowdown = move_calc) + owner.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/liver_cirrhosis, multiplicative_slowdown = move_calc) sizeMoveMod(move_calc, owner) else - owner.remove_movespeed_modifier(MOVESPEED_ID_CIRRHOSIS) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/liver_cirrhosis) sizeMoveMod(1, owner) /obj/item/organ/liver/Insert(mob/living/carbon/M, special = FALSE, drop_if_replaced = TRUE) . = ..() if(. && damage >= high_threshold) var/move_calc = 1+((round(damage) - high_threshold)/(high_threshold/3)) - M.add_movespeed_modifier(MOVESPEED_ID_CIRRHOSIS, TRUE, 100, NONE, override = TRUE, multiplicative_slowdown = move_calc) + M.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/liver_cirrhosis, multiplicative_slowdown = move_calc) sizeMoveMod(move_calc, owner) /obj/item/organ/liver/Remove(special = FALSE) if(!QDELETED(owner)) - owner.remove_movespeed_modifier(MOVESPEED_ID_CIRRHOSIS) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/liver_cirrhosis) sizeMoveMod(1, owner) return ..() diff --git a/modular_citadel/code/datums/status_effects/chems.dm b/modular_citadel/code/datums/status_effects/chems.dm index 369fb377a5..9a9e846d5b 100644 --- a/modular_citadel/code/datums/status_effects/chems.dm +++ b/modular_citadel/code/datums/status_effects/chems.dm @@ -76,7 +76,7 @@ to_chat(H, "Your enormous breasts are way too large to fit anything over them!") if(last_checked_size != B.cached_size) - H.add_movespeed_modifier(BREAST_MOVEMENT_SPEED, TRUE, 100, NONE, override = TRUE, multiplicative_slowdown = moveCalc) + H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/status_effect/breast_hypertrophy, multiplicative_slowdown = moveCalc) sizeMoveMod(moveCalc) if (B.size == "huge") @@ -93,7 +93,7 @@ /datum/status_effect/chem/breast_enlarger/on_remove() log_game("FERMICHEM: [owner]'s breasts has reduced to an acceptable size. ID: [owner.key]") to_chat(owner, "Your expansive chest has become a more managable size, liberating your movements.") - owner.remove_movespeed_modifier(BREAST_MOVEMENT_SPEED) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/breast_hypertrophy) sizeMoveMod(1) return ..() @@ -152,18 +152,18 @@ playsound(H.loc, 'sound/items/poster_ripped.ogg', 50, 1) to_chat(H, "Your enormous package is way to large to fit anything over!") - if(P.length < 22 && H.has_movespeed_modifier(DICK_MOVEMENT_SPEED)) + if(P.length < 22 && H.has_movespeed_modifier(/datum/movespeed_modifier/status_effect/penis_hypertrophy)) to_chat(owner, "Your rascally willy has become a more managable size, liberating your movements.") - H.remove_movespeed_modifier(DICK_MOVEMENT_SPEED) - else if(P.length >= 22 && !H.has_movespeed_modifier(DICK_MOVEMENT_SPEED)) + H.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/penis_hypertrophy) + else if(P.length >= 22 && !H.has_movespeed_modifier(/datum/movespeed_modifier/status_effect/penis_hypertrophy)) to_chat(H, "Your indulgent johnson is so substantial, it's taking all your blood and affecting your movements!") - H.add_movespeed_modifier(DICK_MOVEMENT_SPEED, TRUE, 100, NONE, override = TRUE, multiplicative_slowdown = moveCalc) + H.add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/status_effect/penis_hypertrophy, multiplicative_slowdown = moveCalc) H.AdjustBloodVol(bloodCalc) ..() /datum/status_effect/chem/penis_enlarger/on_remove() log_game("FERMICHEM: [owner]'s dick has reduced to an acceptable size. ID: [owner.key]") - owner.remove_movespeed_modifier(DICK_MOVEMENT_SPEED) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/penis_hypertrophy) owner.ResetBloodVol() return ..() @@ -532,7 +532,7 @@ cooldown += 1 //Cooldown doesn't process till status is done else if(status == "charge") - owner.add_movespeed_modifier(MOVESPEED_ID_MKULTRA, update=TRUE, priority=100, multiplicative_slowdown=-2, blacklisted_movetypes=(FLYING|FLOATING)) + owner.add_movespeed_modifier(/datum/movespeed_modifier/status_effect/mkultra) status = "charged" if(lewd) to_chat(owner, "Your [enthrallGender]'s order fills you with a burst of speed!") @@ -542,7 +542,7 @@ else if (status == "charged") if (statusStrength < 0) status = null - owner.remove_movespeed_modifier(MOVESPEED_ID_MKULTRA) + owner.remove_movespeed_modifier(/datum/movespeed_modifier/status_effect/mkultra) owner.DefaultCombatKnockdown(50) to_chat(owner, "Your body gives out as the adrenaline in your system runs out.") else diff --git a/tgstation.dme b/tgstation.dme index 41708bc0bd..a52826feec 100755 --- a/tgstation.dme +++ b/tgstation.dme @@ -2198,7 +2198,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\say_vr.dm" @@ -2594,6 +2593,14 @@ #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\items.dm" +#include "code\modules\movespeed\modifiers\misc.dm" +#include "code\modules\movespeed\modifiers\mobs.dm" +#include "code\modules\movespeed\modifiers\reagents.dm" +#include "code\modules\movespeed\modifiers\status_effects.dm" #include "code\modules\newscaster\_news.dm" #include "code\modules\newscaster\feed_channel.dm" #include "code\modules\newscaster\feed_comment.dm" From b5abfd927312a8302bdb3a9508b43bb2f11a3ea1 Mon Sep 17 00:00:00 2001 From: Ghommie <42542238+Ghommie@users.noreply.github.com> Date: Thu, 23 Apr 2020 14:49:05 +0200 Subject: [PATCH 2/2] thank you dreamchecker. --- code/modules/mob/mob_movement.dm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/modules/mob/mob_movement.dm b/code/modules/mob/mob_movement.dm index 9bef48320b..ddcebe9c0a 100644 --- a/code/modules/mob/mob_movement.dm +++ b/code/modules/mob/mob_movement.dm @@ -253,7 +253,7 @@ if(!speed_change) remove_movespeed_modifier(/datum/movespeed_modifier/gravity) else - add_movespeed_modifier(/datum/movespeed_modifier/gravity, multiplicative_slowdown = speed_change) + add_or_update_variable_movespeed_modifier(/datum/movespeed_modifier/gravity, multiplicative_slowdown = speed_change) //bodypart selection - Cyberboss //8 toggles through head - eyes - mouth