Skip to content

Commit

Permalink
Adds sneak mode to replicate the old "no footstep" behavior of walking (
Browse files Browse the repository at this point in the history
  • Loading branch information
MrMelbert authored May 11, 2024
1 parent 81c3faa commit 610f762
Show file tree
Hide file tree
Showing 17 changed files with 181 additions and 40 deletions.
1 change: 1 addition & 0 deletions code/__DEFINES/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
//movement intent defines for the move_intent var
#define MOVE_INTENT_WALK "walk"
#define MOVE_INTENT_RUN "run"
#define MOVE_INTENT_SNEAK "sneak" // NON-MODULE CHANGE

//Blood levels
#define BLOOD_VOLUME_MAX_LETHAL 2150
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/hud/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@

using = new /atom/movable/screen/mov_intent(null, src)
using.icon = ui_style
using.icon_state = (owner.move_intent == MOVE_INTENT_RUN ? "running" : "walking")
using.update_appearance() // NON-MODULE CHANGE
using.screen_loc = ui_movi
static_inventory += using

Expand Down
5 changes: 3 additions & 2 deletions code/_onclick/hud/screen_objects.dm
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,17 @@
return
var/mob/living/living_hud_owner = hud.mymob
switch(living_hud_owner.move_intent)
if(MOVE_INTENT_WALK)
if(MOVE_INTENT_WALK, MOVE_INTENT_SNEAK) // NON-MODULE CHANGE
icon_state = "walking"
if(MOVE_INTENT_RUN)
icon_state = "running"
maptext = "<span style='[maptext_style]'>[capitalize(living_hud_owner.move_intent)]</span>" // NON-MODULE CHANGE
return ..()

/atom/movable/screen/mov_intent/proc/toggle(mob/living/user)
if(!istype(user))
return
user.toggle_move_intent(user)
user.toggle_move_intent()

/atom/movable/screen/pull
name = "stop pulling"
Expand Down
4 changes: 2 additions & 2 deletions code/datums/elements/footstep.dm
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@
var/mob/living/carbon/carbon_source = source
if(!carbon_source.get_bodypart(BODY_ZONE_L_LEG) && !carbon_source.get_bodypart(BODY_ZONE_R_LEG))
return
// if(carbon_source.m_intent == MOVE_INTENT_WALK) // NON-MODULE CHANGE
// return// stealth // NON-MODULE CHANGE
if(carbon_source.move_intent == MOVE_INTENT_SNEAK) // NON-MODULE CHANGE
return// stealth
steps_for_living[source] += 1
var/steps = steps_for_living[source]

Expand Down
12 changes: 6 additions & 6 deletions code/datums/keybinding/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -121,28 +121,28 @@
/datum/keybinding/living/toggle_move_intent
hotkey_keys = list("C")
name = "toggle_move_intent"
full_name = "Hold to toggle move intent"
description = "Held down to cycle to the other move intent, release to cycle back"
full_name = "Hold to toggle sprint" // NON-MODULE CHANGE
description = "Hold down to enable sprinting. Releasing will return you to walk." // NON-MODULE CHANGE
keybind_signal = COMSIG_KB_LIVING_TOGGLEMOVEINTENT_DOWN

/datum/keybinding/living/toggle_move_intent/down(client/user)
. = ..()
if(.)
return
var/mob/living/M = user.mob
M.toggle_move_intent()
M.set_move_intent(MOVE_INTENT_RUN) // NON-MODULE CHANGE
return TRUE

/datum/keybinding/living/toggle_move_intent/up(client/user)
var/mob/living/M = user.mob
M.toggle_move_intent()
M.set_move_intent(MOVE_INTENT_WALK) // NON-MODULE CHANGE
return TRUE

/datum/keybinding/living/toggle_move_intent_alternative
hotkey_keys = list("Unbound")
name = "toggle_move_intent_alt"
full_name = "press to cycle move intent"
description = "Pressing this cycle to the opposite move intent, does not cycle back"
full_name = "Press to cycle move intent"
description = "Pressing this will cycle to the next move intent." // NON-MODULE CHANGE
keybind_signal = COMSIG_KB_LIVING_TOGGLEMOVEINTENTALT_DOWN

/datum/keybinding/living/toggle_move_intent_alternative/down(client/user)
Expand Down
4 changes: 2 additions & 2 deletions code/datums/quirks/negative_quirks/nyctophobia.dm
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
quirk_holder.clear_mood_event("nyctophobia")
return

if(quirk_holder.move_intent == MOVE_INTENT_RUN)
if(quirk_holder.move_intent != MOVE_INTENT_SNEAK) // NON-MODULE CHANGE
to_chat(quirk_holder, span_warning("Easy, easy, take it slow... you're in the dark..."))
quirk_holder.toggle_move_intent()
quirk_holder.set_move_intent(MOVE_INTENT_SNEAK) // NON-MODULE CHANGE
quirk_holder.add_mood_event("nyctophobia", /datum/mood_event/nyctophobia)
8 changes: 3 additions & 5 deletions code/datums/voice_of_god_command.dm
Original file line number Diff line number Diff line change
Expand Up @@ -348,18 +348,16 @@ GLOBAL_LIST_INIT(voice_of_god_commands, init_voice_of_god_commands())

/datum/voice_of_god_command/walk/execute(list/listeners, mob/living/user, power_multiplier = 1, message)
for(var/mob/living/target as anything in listeners)
if(target.move_intent != MOVE_INTENT_WALK)
target.toggle_move_intent()
target.set_move_intent(MOVE_INTENT_SNEAK) // NON-MODULE CHANGE

/// This command forces the listeners to switch to run intent.
/datum/voice_of_god_command/run
trigger = "run"
is_regex = FALSE

/datum/voice_of_god_command/walk/execute(list/listeners, mob/living/user, power_multiplier = 1, message)
/datum/voice_of_god_command/run/execute(list/listeners, mob/living/user, power_multiplier = 1, message) // NON-MODULE CHANGE
for(var/mob/living/target as anything in listeners)
if(target.move_intent != MOVE_INTENT_RUN)
target.toggle_move_intent()
target.set_move_intent(MOVE_INTENT_RUN) // NON-MODULE CHANGE

/// This command turns the listeners' throw mode on.
/datum/voice_of_god_command/throw_catch
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/flasher.dm
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/machinery/flasher, 26)

if(iscarbon(proximity_check_mob))
var/mob/living/carbon/proximity_carbon = proximity_check_mob
if (proximity_carbon.move_intent != MOVE_INTENT_WALK && anchored)
if (proximity_carbon.move_intent != MOVE_INTENT_SNEAK && anchored) // NON-MODULE CHANGE
flash()

/obj/machinery/flasher/portable/vv_edit_var(vname, vval)
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/effects/decals/remains.dm
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

if(iscarbon(tomb_raider))
var/mob/living/carbon/nearby_carbon = tomb_raider
if (nearby_carbon.move_intent != MOVE_INTENT_WALK || prob(15))
if (nearby_carbon.move_intent != MOVE_INTENT_SNEAK || prob(15)) // NON-MODULE CHANGE
release_smoke(nearby_carbon)
COOLDOWN_START(src, gas_cooldown, rand(20 SECONDS, 2 MINUTES))

Expand Down
2 changes: 1 addition & 1 deletion code/game/turfs/open/_open.dm
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@
else
if(!(lube & SLIP_WHEN_CRAWLING) && (slipper.body_position == LYING_DOWN || !(slipper.status_flags & CANKNOCKDOWN))) // can't slip unbuckled mob if they're lying or can't fall.
return FALSE
if(slipper.move_intent == MOVE_INTENT_WALK && (lube & NO_SLIP_WHEN_WALKING))
if(slipper.move_intent != MOVE_INTENT_RUN && (lube & NO_SLIP_WHEN_WALKING)) // NON-MODULE CHANGE
return FALSE

if(!(lube & SLIDE_ICE))
Expand Down
12 changes: 6 additions & 6 deletions code/modules/admin/smites/ghost_control.dm
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@
"throw" = CALLBACK(target, TYPE_PROC_REF(/mob, throw_item), get_edge_target_turf(target, pick(GLOB.alldirs))),
"shove" = CALLBACK(src, PROC_REF(ghost_shove), target),
"sit" = CALLBACK(src, PROC_REF(ghost_sit), target),
"run" = CALLBACK(src, PROC_REF(ghost_speed), target, MOVE_INTENT_RUN),
"walk" = CALLBACK(src, PROC_REF(ghost_speed), target, MOVE_INTENT_WALK),
"run" = CALLBACK(target, TYPE_PROC_REF(/mob/living, set_move_intent), MOVE_INTENT_RUN), // NON-MODULE CHANGE
"walk" = CALLBACK(target, TYPE_PROC_REF(/mob/living, set_move_intent), MOVE_INTENT_WALK), // NON-MODULE CHANGE
"sneak" = CALLBACK(target, TYPE_PROC_REF(/mob/living, set_move_intent), MOVE_INTENT_SNEAK), // NON-MODULE CHANGE
"crawl" = CALLBACK(target, TYPE_PROC_REF(/mob/living, set_resting), TRUE), // NON-MODULE CHANGE
"stand" = CALLBACK(target, TYPE_PROC_REF(/mob/living, set_resting), FALSE), // NON-MODULE CHANGE
), 7 SECONDS)

to_chat(target, span_revenwarning("You feel a ghastly presence!!!"))
Expand Down Expand Up @@ -45,7 +48,4 @@
var/obj/structure/chair/sitting_chair = pick(chairs)
sitting_chair.buckle_mob(target, check_loc = FALSE)

/datum/smite/ghost_control/proc/ghost_speed(mob/living/target, new_speed)
if(target.move_intent == new_speed)
return
target.toggle_move_intent()
// NON-MODULE CHANGE: this proc is gone we don't need it any more
2 changes: 1 addition & 1 deletion code/modules/clothing/glasses/_glasses.dm
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
return
if(isliving(movable))
var/mob/living/crusher = movable
if(crusher.move_intent != MOVE_INTENT_WALK && (!(crusher.movement_type & MOVETYPES_NOT_TOUCHING_GROUND) || crusher.buckled))
if(crusher.move_intent != MOVE_INTENT_SNEAK && (!(crusher.movement_type & MOVETYPES_NOT_TOUCHING_GROUND) || crusher.buckled)) // NON-MODULE CHANGE
playsound(src, 'sound/effects/footstep/glass_step.ogg', 30, TRUE)
visible_message(span_warning("[crusher] steps on [src], damaging it!"))
take_damage(100, sound_effect = FALSE)
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@
//Called when we bump onto a mob
/mob/living/proc/MobBump(mob/M)
//No bumping/swapping/pushing others if you are on walk intent
if(move_intent == MOVE_INTENT_WALK)
if(move_intent != MOVE_INTENT_RUN) // NON-MODULE CHANGE
return TRUE

if(SEND_SIGNAL(M, COMSIG_LIVING_PRE_MOB_BUMP, src) & COMPONENT_LIVING_BLOCK_PRE_MOB_BUMP)
Expand Down
4 changes: 2 additions & 2 deletions code/modules/mob/mob_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -481,14 +481,14 @@
set instant = TRUE
if(isliving(mob))
var/mob/living/user_mob = mob
user_mob.toggle_move_intent(usr)
user_mob.toggle_move_intent()

/**
* Toggle the move intent of the mob
*
* triggers an update the move intent hud as well
*/
/mob/living/proc/toggle_move_intent(mob/user)
/mob/living/proc/toggle_move_intent()
if(move_intent == MOVE_INTENT_RUN)
move_intent = MOVE_INTENT_WALK
else
Expand Down
1 change: 1 addition & 0 deletions maplestation.dme
Original file line number Diff line number Diff line change
Expand Up @@ -6392,6 +6392,7 @@
#include "maplestation_modules\code\modules\mob\living\impede_speech_verb.dm"
#include "maplestation_modules\code\modules\mob\living\living.dm"
#include "maplestation_modules\code\modules\mob\living\living_movement.dm"
#include "maplestation_modules\code\modules\mob\living\sneak.dm"
#include "maplestation_modules\code\modules\mob\living\speech_and_radio_sounds.dm"
#include "maplestation_modules\code\modules\mob\living\sprint.dm"
#include "maplestation_modules\code\modules\mob\living\carbon\human\human.dm"
Expand Down
112 changes: 112 additions & 0 deletions maplestation_modules/code/modules/mob/living/sneak.dm
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
// Reworks toggle_move_intent to cycle rather than go back and forth
/mob/living/toggle_move_intent(backwards)

if(backwards)
switch(move_intent)
if(MOVE_INTENT_RUN)
move_intent = MOVE_INTENT_WALK
if(MOVE_INTENT_WALK)
move_intent = MOVE_INTENT_SNEAK
if(MOVE_INTENT_SNEAK)
move_intent = MOVE_INTENT_RUN

else
switch(move_intent)
if(MOVE_INTENT_RUN)
move_intent = MOVE_INTENT_SNEAK
if(MOVE_INTENT_SNEAK)
move_intent = MOVE_INTENT_WALK
if(MOVE_INTENT_WALK)
move_intent = MOVE_INTENT_RUN

for(var/atom/movable/screen/mov_intent/selector in hud_used?.static_inventory)
selector.update_appearance()
update_move_intent_slowdown()

/// Sets the mob's move intent to the passed intent
/mob/living/proc/set_move_intent(new_intent)
if(move_intent == new_intent)
return

move_intent = new_intent
for(var/atom/movable/screen/mov_intent/selector in hud_used?.static_inventory)
selector.update_appearance()
update_move_intent_slowdown()

// Adds sneak movespeed modifier as an option
/mob/living/update_move_intent_slowdown()
switch(move_intent)
if(MOVE_INTENT_WALK)
add_movespeed_modifier(/datum/movespeed_modifier/config_walk_run/walk)
if(MOVE_INTENT_RUN)
add_movespeed_modifier(/datum/movespeed_modifier/config_walk_run/run)
if(MOVE_INTENT_SNEAK)
add_movespeed_modifier(/datum/movespeed_modifier/config_walk_run/walk/sneak)

// Movespeed modifier for sneaking. It's just 1.5x the slowness of walking.
/datum/movespeed_modifier/config_walk_run/walk/sneak/sync()
var/mod = CONFIG_GET(number/movedelay/walk_delay)
multiplicative_slowdown = (isnum(mod) ? mod : initial(multiplicative_slowdown)) * 1.5

// Syncs the sneak movespeed modifier with the walk movespeed modifier
/datum/config_entry/number/movedelay/walk_delay/ValidateAndSet()
. = ..()
var/datum/movespeed_modifier/config_walk_run/sneak = get_cached_movespeed_modifier(/datum/movespeed_modifier/config_walk_run/walk/sneak)
sneak.sync()

// Keybind for sneak intent
/datum/keybinding/living/opposite_toggle_move_intent
hotkey_keys = list("Unbound")
name = "opposite_toggle_move_intent"
full_name = "Hold to toggle sneak"
description = "Hold down to enable sneaking. Releasing will return you to walk."
keybind_signal = "keybinding_mob_oppositetogglemoveintent_down"

/datum/keybinding/living/opposite_toggle_move_intent/down(client/user)
. = ..()
if(.)
return
var/mob/living/M = user.mob
M.set_move_intent(MOVE_INTENT_SNEAK)
return TRUE

/datum/keybinding/living/opposite_toggle_move_intent/up(client/user)
var/mob/living/M = user.mob
M.set_move_intent(MOVE_INTENT_WALK)
return TRUE

/datum/keybinding/living/set_move_intent
hotkey_keys = list("Unbound")
name = "set_move_intent"
full_name = "Toggle Run"
description = "Press to start sprinting. Press again to stop."
keybind_signal = "keybinding_mob_setmoveintent"

/datum/keybinding/living/set_move_intent/down(client/user)
. = ..()
if(.)
return
var/mob/living/M = user.mob
if(M.move_intent == MOVE_INTENT_RUN)
M.set_move_intent(MOVE_INTENT_WALK)
else
M.set_move_intent(MOVE_INTENT_RUN)
return TRUE

/datum/keybinding/living/opposite_set_move_intent
hotkey_keys = list("Unbound")
name = "opposite_set_move_intent"
full_name = "Toggle Sneak"
description = "Press to start sneaking. Press again to stop."
keybind_signal = "keybinding_mob_oppositesetmoveintent"

/datum/keybinding/living/opposite_set_move_intent/down(client/user)
. = ..()
if(.)
return
var/mob/living/M = user.mob
if(M.move_intent == MOVE_INTENT_SNEAK)
M.set_move_intent(MOVE_INTENT_WALK)
else
M.set_move_intent(MOVE_INTENT_SNEAK)
return TRUE
Loading

0 comments on commit 610f762

Please sign in to comment.