From db1a97868d6d8002bdc99fe4158527824c8ff2b7 Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Sun, 12 Mar 2023 01:05:53 +1100 Subject: [PATCH 1/2] Implementing movement system flags, fixing simplemob movement delays. --- code/__defines/movement.dm | 9 ++++-- code/_onclick/hud/screen_objects.dm | 2 +- code/datums/move_intent.dm | 29 +++++++++++++++++++ .../changeling/powers/visible_camouflage.dm | 4 +-- code/game/objects/items/weapons/handcuffs.dm | 6 ++-- code/modules/mob/dead/observer/observer.dm | 1 + .../mob/living/simple_mob/simple_mob.dm | 11 ++++--- code/modules/mob/mob.dm | 2 +- code/modules/organs/internal/intestine.dm | 2 +- code/modules/organs/internal/kidneys.dm | 2 +- .../projectiles/targeting/targeting_mob.dm | 17 +++++++---- 11 files changed, 63 insertions(+), 22 deletions(-) diff --git a/code/__defines/movement.dm b/code/__defines/movement.dm index eeab541cb5..96d0af40c7 100644 --- a/code/__defines/movement.dm +++ b/code/__defines/movement.dm @@ -1,3 +1,6 @@ -// Move intent decl helpers. -#define IS_WALKING(X) istype(X.move_intent, /decl/move_intent/walk) -#define IS_RUNNING(X) istype(X.move_intent, /decl/move_intent/run) +// Defines used for movement state evaluation. +#define MOVEMENT_INTENT_WALKING 1 +#define MOVEMENT_INTENT_RUNNING 2 + +#define IS_WALKING(X) (X?.move_intent?.flags & MOVEMENT_INTENT_WALKING) +#define IS_RUNNING(X) (X?.move_intent?.flags & MOVEMENT_INTENT_RUNNING) diff --git a/code/_onclick/hud/screen_objects.dm b/code/_onclick/hud/screen_objects.dm index 5591b23a43..4cbe85475b 100644 --- a/code/_onclick/hud/screen_objects.dm +++ b/code/_onclick/hud/screen_objects.dm @@ -280,7 +280,7 @@ var/mob/living/carbon/C = L if(C.legcuffed) to_chat(C, "You are legcuffed! You cannot run until you get [C.legcuffed] removed!") - C.set_move_intent(/decl/move_intent/walk) // Just incase. + C.set_move_intent(C.get_movement_intent_with_flag(MOVEMENT_INTENT_WALKING)) // Just incase. return 1 var/next_move_intent = next_in_list(L.move_intent.type, L.move_intents) L.set_move_intent(next_move_intent) diff --git a/code/datums/move_intent.dm b/code/datums/move_intent.dm index 4f0c4e0ccc..65a010be5e 100644 --- a/code/datums/move_intent.dm +++ b/code/datums/move_intent.dm @@ -2,11 +2,13 @@ var/name var/move_delay = 1 var/hud_icon_state + var/flags = 0 // Walking /decl/move_intent/walk name = "Walk" hud_icon_state = "walking" + flags = MOVEMENT_INTENT_WALKING /decl/move_intent/walk/Initialize() . = ..() @@ -16,7 +18,34 @@ /decl/move_intent/run name = "Run" hud_icon_state = "running" + flags = MOVEMENT_INTENT_RUNNING /decl/move_intent/run/Initialize() . = ..() move_delay = config.run_speed + +// Simplemob movement intents. +/decl/move_intent/animal_walk + name = "Walk" + hud_icon_state = "walking" + flags = MOVEMENT_INTENT_WALKING + +/decl/move_intent/animal_walk/Initialize() + . = ..() + move_delay = config.animal_delay + 1 + +/decl/move_intent/animal_run + name = "Run" + hud_icon_state = "running" + flags = MOVEMENT_INTENT_RUNNING + +/decl/move_intent/animal_run/Initialize() + . = ..() + move_delay = config.animal_delay + +// Ghost movement intent. +/decl/move_intent/no_delay + name = "Move" + hud_icon_state = "running" + flags = MOVEMENT_INTENT_WALKING | MOVEMENT_INTENT_RUNNING + move_delay = 0 diff --git a/code/game/gamemodes/changeling/powers/visible_camouflage.dm b/code/game/gamemodes/changeling/powers/visible_camouflage.dm index 4cb3c97775..3d93d1ce90 100644 --- a/code/game/gamemodes/changeling/powers/visible_camouflage.dm +++ b/code/game/gamemodes/changeling/powers/visible_camouflage.dm @@ -42,7 +42,7 @@ to_chat(src, "We may move at our normal speed while hidden.") if(must_walk) - H.set_move_intent(/decl/move_intent/walk) + H.set_move_intent(H.get_movement_intent_with_flag(MOVEMENT_INTENT_WALKING)) var/remain_cloaked = TRUE while(remain_cloaked) //This loop will keep going until the player uncloaks. @@ -66,7 +66,7 @@ H.invisibility = initial(invisibility) visible_message("[src] suddenly fades in, seemingly from nowhere!", "We revert our camouflage, revealing ourselves.") - H.set_move_intent(/decl/move_intent/run) + H.set_move_intent(H.get_movement_intent_with_flag(MOVEMENT_INTENT_RUNNING)) H.mind.changeling.cloaked = 0 H.mind.changeling.chem_recharge_rate = old_regen_rate diff --git a/code/game/objects/items/weapons/handcuffs.dm b/code/game/objects/items/weapons/handcuffs.dm index a470694327..366db784df 100644 --- a/code/game/objects/items/weapons/handcuffs.dm +++ b/code/game/objects/items/weapons/handcuffs.dm @@ -274,14 +274,14 @@ var/global/last_chew = 0 target.legcuffed = lcuffs target.update_inv_legcuffed() if(!IS_WALKING(target)) - target.set_move_intent(/decl/move_intent/walk) + target.set_move_intent(target.get_movement_intent_with_flag(MOVEMENT_INTENT_WALKING)) return 1 /obj/item/handcuffs/legcuffs/equipped(var/mob/living/user,var/slot) . = ..() if(slot == slot_legcuffed) if(!IS_WALKING(user)) - user.set_move_intent(/decl/move_intent/walk) + user.set_move_intent(user.get_movement_intent_with_flag(MOVEMENT_INTENT_WALKING)) /obj/item/handcuffs/legcuffs/bola @@ -321,5 +321,5 @@ var/global/last_chew = 0 target.legcuffed = lcuffs target.update_inv_legcuffed() if(!IS_WALKING(target)) - target.set_move_intent(/decl/move_intent/walk) + target.set_move_intent(target.get_movement_intent_with_flag(MOVEMENT_INTENT_WALKING)) return 1 diff --git a/code/modules/mob/dead/observer/observer.dm b/code/modules/mob/dead/observer/observer.dm index 7a3b8d8740..dff26e0647 100644 --- a/code/modules/mob/dead/observer/observer.dm +++ b/code/modules/mob/dead/observer/observer.dm @@ -2,6 +2,7 @@ name = "observer" desc = "This shouldn't appear" density = 0 + move_intents = list(/decl/move_intent/no_delay) /mob/observer/dead name = "ghost" diff --git a/code/modules/mob/living/simple_mob/simple_mob.dm b/code/modules/mob/living/simple_mob/simple_mob.dm index c0cd8c0f93..1fcf0ac7df 100644 --- a/code/modules/mob/living/simple_mob/simple_mob.dm +++ b/code/modules/mob/living/simple_mob/simple_mob.dm @@ -17,6 +17,11 @@ has_huds = TRUE // We do show AI status huds for buildmode players + move_intents = list( + /decl/move_intent/animal_run, + /decl/move_intent/animal_walk + ) + var/tt_desc = null //Tooltip description //Settings for played mobs @@ -225,17 +230,17 @@ return ..() */ /mob/living/simple_mob/movement_delay() - . = movement_cooldown if(force_max_speed) return -3 - + . = 0 for(var/datum/modifier/M in modifiers) if(!isnull(M.haste) && M.haste == TRUE) return -3 if(!isnull(M.slowdown)) . += M.slowdown + . += ..() + movement_cooldown // Turf related slowdown var/turf/T = get_turf(src) if(T && T.get_movement_cost() && !hovering) // Flying mobs ignore turf-based slowdown. Aquatic mobs ignore water slowdown, and can gain bonus speed in it. @@ -252,8 +257,6 @@ if(IS_WALKING(src)) . *= 1.5 - . += config.animal_delay - . += ..() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 3f100dbc7a..78da1fab82 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -34,7 +34,7 @@ zone_sel = null /mob/Initialize() - move_intent = GET_DECL(/decl/move_intent/run) // Sets the initial move_intent. + move_intent = GET_DECL(move_intents[1]) // Sets the initial move_intent. mob_list += src if(stat == DEAD) dead_mob_list += src diff --git a/code/modules/organs/internal/intestine.dm b/code/modules/organs/internal/intestine.dm index f57eadc499..9e60845897 100644 --- a/code/modules/organs/internal/intestine.dm +++ b/code/modules/organs/internal/intestine.dm @@ -17,7 +17,7 @@ if(prob(1)) owner.custom_pain("Your abdomen feels like it's tearing itself apart!",1) if(!IS_WALKING(owner)) - owner.set_move_intent(/decl/move_intent/walk) + owner.set_move_intent(owner.get_movement_intent_with_flag(MOVEMENT_INTENT_WALKING)) /obj/item/organ/internal/intestine/xeno color = "#555555" diff --git a/code/modules/organs/internal/kidneys.dm b/code/modules/organs/internal/kidneys.dm index 91c476986d..889fe45421 100644 --- a/code/modules/organs/internal/kidneys.dm +++ b/code/modules/organs/internal/kidneys.dm @@ -39,7 +39,7 @@ if(prob(1)) owner.custom_pain("You feel extremely tired, like you can't move!",1) if(!IS_WALKING(owner)) - owner.set_move_intent(/decl/move_intent/walk) + owner.set_move_intent(owner.get_movement_intent_with_flag(MOVEMENT_INTENT_WALKING)) /obj/item/organ/internal/kidneys/grey icon_state = "kidneys_grey" diff --git a/code/modules/projectiles/targeting/targeting_mob.dm b/code/modules/projectiles/targeting/targeting_mob.dm index 1f7acace83..e111d1c832 100644 --- a/code/modules/projectiles/targeting/targeting_mob.dm +++ b/code/modules/projectiles/targeting/targeting_mob.dm @@ -58,13 +58,18 @@ trigger_aiming(TARGET_CAN_MOVE) /mob/living/proc/set_move_intent(decl/move_intent/intent) - if(move_intent.type == intent) - return - var/new_intent = GET_DECL(intent) if(isnull(new_intent)) return + if(move_intent != new_intent) + move_intent = new_intent + if(hud_used?.move_intent) + hud_used.move_intent.icon_state = move_intent.hud_icon_state - move_intent = new_intent - if(hud_used?.move_intent) - hud_used.move_intent.icon_state = move_intent.hud_icon_state +/mob/living/proc/get_movement_intent_with_flag(var/flag_to_check = MOVEMENT_INTENT_WALKING) + if(!flag_to_check || !length(move_intents)) + return + for(var/move_intent_type in move_intents) + var/decl/move_intent/check_intent = GET_DECL(move_intent_type) + if(check_intent.flags & flag_to_check) + return move_intent_type From 97334fd6adb36008180fbf85667d26fcb8ad5184 Mon Sep 17 00:00:00 2001 From: MistakeNot4892 Date: Sun, 12 Mar 2023 01:26:22 +1100 Subject: [PATCH 2/2] Removing unused slowdown config, implementing robot move handlers. --- code/controllers/configuration.dm | 9 -- code/datums/move_intent.dm | 9 ++ .../living/silicon/robot/robot_movement.dm | 2 - code/modules/mob/living/silicon/silicon.dm | 7 +- config/example/game_options.txt | 141 +++++++++--------- 5 files changed, 84 insertions(+), 84 deletions(-) diff --git a/code/controllers/configuration.dm b/code/controllers/configuration.dm index 3fcea0996a..d1aa9c69a4 100644 --- a/code/controllers/configuration.dm +++ b/code/controllers/configuration.dm @@ -181,9 +181,6 @@ var/global/list/gamemode_cache = list() //Mob specific modifiers. NOTE: These will affect different mob types in different ways var/human_delay = 0 var/robot_delay = 0 - var/monkey_delay = 0 - var/alien_delay = 0 - var/slime_delay = 0 var/animal_delay = 0 var/footstep_volume = 0 @@ -998,12 +995,6 @@ var/global/list/gamemode_cache = list() config.human_delay = value if("robot_delay") config.robot_delay = value - if("monkey_delay") - config.monkey_delay = value - if("alien_delay") - config.alien_delay = value - if("slime_delay") - config.slime_delay = value if("animal_delay") config.animal_delay = value diff --git a/code/datums/move_intent.dm b/code/datums/move_intent.dm index 65a010be5e..5ec3ebaa27 100644 --- a/code/datums/move_intent.dm +++ b/code/datums/move_intent.dm @@ -49,3 +49,12 @@ hud_icon_state = "running" flags = MOVEMENT_INTENT_WALKING | MOVEMENT_INTENT_RUNNING move_delay = 0 + +// Robot movement intents. +/decl/move_intent/walk/robot/Initialize() + . = ..() + move_delay += config.robot_delay + +/decl/move_intent/run/robot/Initialize() + . = ..() + move_delay += config.robot_delay diff --git a/code/modules/mob/living/silicon/robot/robot_movement.dm b/code/modules/mob/living/silicon/robot/robot_movement.dm index f401a741f5..a554176536 100644 --- a/code/modules/mob/living/silicon/robot/robot_movement.dm +++ b/code/modules/mob/living/silicon/robot/robot_movement.dm @@ -35,8 +35,6 @@ if(get_restraining_bolt()) // Borgs with Restraining Bolts move slower. . += 1 - . += config.robot_delay - . += ..() // NEW: Use power while moving. diff --git a/code/modules/mob/living/silicon/silicon.dm b/code/modules/mob/living/silicon/silicon.dm index 1526cc959d..2a75149f9b 100644 --- a/code/modules/mob/living/silicon/silicon.dm +++ b/code/modules/mob/living/silicon/silicon.dm @@ -1,13 +1,18 @@ /mob/living/silicon gender = NEUTER voice_name = "synthesized voice" + has_huds = TRUE + move_intents = list( + /decl/move_intent/run/robot, + /decl/move_intent/walk/robot + ) + var/syndicate = 0 var/const/MAIN_CHANNEL = "Main Frequency" var/lawchannel = MAIN_CHANNEL // Default channel on which to state laws var/list/stating_laws = list()// Channels laws are currently being stated on var/obj/item/radio/common_radio - has_huds = TRUE var/list/speech_synthesizer_langs = list() //which languages can be vocalized by the speech synthesizer //Used in say.dm. diff --git a/config/example/game_options.txt b/config/example/game_options.txt index f537c90e92..b30fcef0b2 100644 --- a/config/example/game_options.txt +++ b/config/example/game_options.txt @@ -1,72 +1,69 @@ -### HEALTH ### - -## level of health at which a mob goes into continual shock (soft crit) -HEALTH_THRESHOLD_SOFTCRIT 0 - -## level of health at which a mob becomes unconscious (crit) -HEALTH_THRESHOLD_CRIT -50 - -## level of health at which a mob becomes dead -HEALTH_THRESHOLD_DEAD -100 - -## Determines whether bones can be broken through excessive damage to the organ -## 0 means bones can't break, 1 means they can -BONES_CAN_BREAK 1 -## Determines whether limbs can be amputated through excessive damage to the organ -## 0 means limbs can't be amputated, 1 means they can -LIMBS_CAN_BREAK 1 - -## multiplier which enables organs to take more damage before bones breaking or limbs being destroyed -## 100 means normal, 50 means half -ORGAN_HEALTH_MULTIPLIER 100 - -## multiplier which influences how fast organs regenerate naturally -## 100 means normal, 50 means half -ORGAN_REGENERATION_MULTIPLIER 75 - -### REVIVAL ### - -## whether pod plants work or not -REVIVAL_POD_PLANTS 1 - -## whether cloning tubes work or not -REVIVAL_CLONING 1 - -## amount of time (in hundredths of seconds) for which a brain retains the "spark of life" after the person's death (set to -1 for infinite) -REVIVAL_BRAIN_LIFE -1 - -## Uncomment to allow headgibbing -ALLOW_HEADGIBS - -### MOB MOVEMENT ### - -## We suggest editing these variabled in-game to find a good speed for your server. To do this you must be a high level admin. Open the 'debug' tab ingame. Select "Debug Controller" and then, in the popup, select "Configuration". These variables should have the same name. - -## These values get directly added to values and totals in-game. To speed things up make the number negative, to slow things down, make the number positive. - - -## These modify the run/walk speed of all mobs before the mob-specific modifiers are applied. -RUN_SPEED 2 -WALK_SPEED 5 - - -## The variables below affect the movement of specific mob types. -HUMAN_DELAY 0 -ROBOT_DELAY 0 -MONKEY_DELAY 0 -ALIEN_DELAY 0 -METROID_DELAY 0 -ANIMAL_DELAY 0 - -## Volume of footstep sound effects. Range: 1-100, Set to 0 to disable footstep sounds. -FOOTSTEP_VOLUME 60 - -### Miscellaneous ### - -## Config options which, of course, don't fit into previous categories. - -## Remove the # in front of this config option to have loyalty implants spawn by default on your server. -#USE_LOYALTY_IMPLANTS - -## Whether or not humans show an area message when they die. -SHOW_HUMAN_DEATH_MESSAGE \ No newline at end of file +### HEALTH ### + +## level of health at which a mob goes into continual shock (soft crit) +HEALTH_THRESHOLD_SOFTCRIT 0 + +## level of health at which a mob becomes unconscious (crit) +HEALTH_THRESHOLD_CRIT -50 + +## level of health at which a mob becomes dead +HEALTH_THRESHOLD_DEAD -100 + +## Determines whether bones can be broken through excessive damage to the organ +## 0 means bones can't break, 1 means they can +BONES_CAN_BREAK 1 +## Determines whether limbs can be amputated through excessive damage to the organ +## 0 means limbs can't be amputated, 1 means they can +LIMBS_CAN_BREAK 1 + +## multiplier which enables organs to take more damage before bones breaking or limbs being destroyed +## 100 means normal, 50 means half +ORGAN_HEALTH_MULTIPLIER 100 + +## multiplier which influences how fast organs regenerate naturally +## 100 means normal, 50 means half +ORGAN_REGENERATION_MULTIPLIER 75 + +### REVIVAL ### + +## whether pod plants work or not +REVIVAL_POD_PLANTS 1 + +## whether cloning tubes work or not +REVIVAL_CLONING 1 + +## amount of time (in hundredths of seconds) for which a brain retains the "spark of life" after the person's death (set to -1 for infinite) +REVIVAL_BRAIN_LIFE -1 + +## Uncomment to allow headgibbing +ALLOW_HEADGIBS + +### MOB MOVEMENT ### + +## We suggest editing these variabled in-game to find a good speed for your server. To do this you must be a high level admin. Open the 'debug' tab ingame. Select "Debug Controller" and then, in the popup, select "Configuration". These variables should have the same name. + +## These values get directly added to values and totals in-game. To speed things up make the number negative, to slow things down, make the number positive. + + +## These modify the run/walk speed of all mobs before the mob-specific modifiers are applied. +RUN_SPEED 2 +WALK_SPEED 5 + + +## The variables below affect the movement of specific mob types. +HUMAN_DELAY 0 +ROBOT_DELAY 0 +ANIMAL_DELAY 0 + +## Volume of footstep sound effects. Range: 1-100, Set to 0 to disable footstep sounds. +FOOTSTEP_VOLUME 60 + +### Miscellaneous ### + +## Config options which, of course, don't fit into previous categories. + +## Remove the # in front of this config option to have loyalty implants spawn by default on your server. +#USE_LOYALTY_IMPLANTS + +## Whether or not humans show an area message when they die. +SHOW_HUMAN_DEATH_MESSAGE