Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Digi lizards now have claw footsteps, diagonal footstep fix #516

Merged
merged 2 commits into from
Jun 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 68 additions & 45 deletions code/datums/elements/footstep.dm
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,13 @@
playsound(turf, 'sound/effects/footstep/crawl1.ogg', 15 * volume, falloff_distance = 1, vary = sound_vary)
return

if(iscarbon(source))
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.move_intent == MOVE_INTENT_SNEAK) // NON-MODULE CHANGE
return// stealth
if(source.move_intent == MOVE_INTENT_SNEAK)
return

steps_for_living[source] += 1
var/steps = steps_for_living[source]

if(steps >= 6)
if(steps >= 8)
steps_for_living[source] = 0
steps = 0

Expand All @@ -93,17 +90,26 @@
if(steps != 0 && !source.has_gravity()) // don't need to step as often when you hop around
return

. = list(FOOTSTEP_MOB_SHOE = turf.footstep, FOOTSTEP_MOB_BAREFOOT = turf.barefootstep, FOOTSTEP_MOB_HEAVY = turf.heavyfootstep, FOOTSTEP_MOB_CLAW = turf.clawfootstep, STEP_SOUND_PRIORITY = STEP_SOUND_NO_PRIORITY)
var/overriden = SEND_SIGNAL(turf, COMSIG_TURF_PREPARE_STEP_SOUND, .) & FOOTSTEP_OVERRIDEN
//The turf has no footstep sound (e.g. open space) and none of the objects on that turf (e.g. catwalks) overrides it
if(!overriden && isnull(turf.footstep))
var/list/footstep_data = list(
FOOTSTEP_MOB_SHOE = turf.footstep,
FOOTSTEP_MOB_BAREFOOT = turf.barefootstep,
FOOTSTEP_MOB_HEAVY = turf.heavyfootstep,
FOOTSTEP_MOB_CLAW = turf.clawfootstep,
STEP_SOUND_PRIORITY = STEP_SOUND_NO_PRIORITY,
)
var/sigreturn = SEND_SIGNAL(turf, COMSIG_TURF_PREPARE_STEP_SOUND, footstep_data)
if(sigreturn & FOOTSTEP_OVERRIDEN)
return footstep_data
if(isnull(turf.footstep))
// The turf has no footstep sound (e.g. open space)
// and none of the objects on that turf (e.g. catwalks) overrides it
return null
return .
return footstep_data

/datum/element/footstep/proc/play_simplestep(mob/living/source, atom/oldloc, direction, forced, list/old_locs, momentum_change)
SIGNAL_HANDLER

if (forced || SHOULD_DISABLE_FOOTSTEPS(source))
if (forced || SHOULD_DISABLE_FOOTSTEPS(source) || source.moving_diagonally == SECOND_DIAG_STEP)
return

var/list/prepared_steps = prepare_step(source)
Expand All @@ -122,7 +128,41 @@
/datum/element/footstep/proc/play_humanstep(mob/living/carbon/human/source, atom/oldloc, direction, forced, list/old_locs, momentum_change)
SIGNAL_HANDLER

if (forced || SHOULD_DISABLE_FOOTSTEPS(source) || !momentum_change)
if (forced || SHOULD_DISABLE_FOOTSTEPS(source) || !momentum_change || source.moving_diagonally == SECOND_DIAG_STEP)
return

var/list/prepared_steps = prepare_step(source)
if(isnull(prepared_steps))
return

var/footstep_type = null
var/stepcount = steps_for_living[source]
var/obj/item/bodypart/leg/left_leg = source.get_bodypart(BODY_ZONE_L_LEG)
var/obj/item/bodypart/leg/right_leg = source.get_bodypart(BODY_ZONE_R_LEG)
if((source.wear_suit?.body_parts_covered|source.w_uniform?.body_parts_covered|source.shoes?.body_parts_covered) & FEET)
footstep_type = FOOTSTEP_MOB_SHOE
// 0, 2, 4, 6 -> reset to 0, repeat
// right = 0, 4, left = 2, 6
else if(stepcount == 2 || stepcount == 6)
footstep_type = left_leg?.footstep_type || right_leg?.footstep_type
else
footstep_type = right_leg?.footstep_type || left_leg?.footstep_type

if(isnull(footstep_type))
return

var/list/footstep_sounds
switch(footstep_type)
if(FOOTSTEP_MOB_CLAW)
footstep_sounds = GLOB.clawfootstep[prepared_steps[footstep_type]]
if(FOOTSTEP_MOB_BAREFOOT)
footstep_sounds = GLOB.barefootstep[prepared_steps[footstep_type]]
if(FOOTSTEP_MOB_HEAVY)
footstep_sounds = GLOB.heavyfootstep[prepared_steps[footstep_type]]
if(FOOTSTEP_MOB_SHOE)
footstep_sounds = GLOB.footstep[prepared_steps[footstep_type]]

if(!length(footstep_sounds))
return

var/volume_multiplier = 1
Expand All @@ -132,37 +172,20 @@
volume_multiplier = 0.6
range_adjustment = -2

var/list/prepared_steps = prepare_step(source)
if(isnull(prepared_steps))
return

//cache for sanic speed (lists are references anyways)
var/footstep_sounds = GLOB.footstep
///list returned by playsound() filled by client mobs who heard the footstep. given to play_fov_effect()
// list returned by playsound() filled by client mobs who heard the footstep. given to play_fov_effect()
var/list/heard_clients

if((source.wear_suit?.body_parts_covered | source.w_uniform?.body_parts_covered | source.shoes?.body_parts_covered) & FEET)
// we are wearing shoes

var/shoestep_type = prepared_steps[FOOTSTEP_MOB_SHOE]
if(!isnull(shoestep_type) && footstep_sounds[shoestep_type]) // shoestep type can be null
heard_clients = playsound(source.loc, pick(footstep_sounds[shoestep_type][1]),
footstep_sounds[shoestep_type][2] * volume * volume_multiplier,
TRUE,
footstep_sounds[shoestep_type][3] + e_range + range_adjustment, falloff_distance = 1, vary = sound_vary)
else
// we are barefoot

if(source.dna.species.special_step_sounds)
heard_clients = playsound(source.loc, pick(source.dna.species.special_step_sounds), 50, TRUE, falloff_distance = 1, vary = sound_vary)
else
var/barefoot_type = prepared_steps[FOOTSTEP_MOB_BAREFOOT]
var/bare_footstep_sounds = GLOB.barefootstep
if(!isnull(barefoot_type) && bare_footstep_sounds[barefoot_type]) // barefoot_type can be null
heard_clients = playsound(source.loc, pick(bare_footstep_sounds[barefoot_type][1]),
bare_footstep_sounds[barefoot_type][2] * volume * volume_multiplier,
TRUE,
bare_footstep_sounds[barefoot_type][3] + e_range + range_adjustment, falloff_distance = 1, vary = sound_vary)
var/picked_sound = pick(footstep_sounds[1])
var/picked_volume = footstep_sounds[2] * volume * volume_multiplier
var/picked_range = footstep_sounds[3] + e_range + range_adjustment

heard_clients = playsound(
source = source,
soundin = picked_sound,
vol = picked_volume,
vary = sound_vary,
extrarange = picked_range,
falloff_distance = 1,
)

if(heard_clients)
play_fov_effect(source, 5, "footstep", direction, ignore_self = TRUE, override_list = heard_clients)
Expand All @@ -172,7 +195,7 @@
/datum/element/footstep/proc/play_simplestep_machine(atom/movable/source, atom/oldloc, direction, forced, list/old_locs, momentum_change)
SIGNAL_HANDLER

if (forced || SHOULD_DISABLE_FOOTSTEPS(source))
if (forced || SHOULD_DISABLE_FOOTSTEPS(source) || source.moving_diagonally == SECOND_DIAG_STEP)
return

var/turf/open/source_loc = get_turf(source)
Expand Down
2 changes: 0 additions & 2 deletions code/modules/mob/living/carbon/human/_species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,6 @@ GLOBAL_LIST_EMPTY(features_by_species)
var/inert_mutation = /datum/mutation/human/dwarfism
///Used to set the mob's death_sound upon species change
var/death_sound
///Sounds to override barefeet walking
var/list/special_step_sounds
///Special sound for grabbing
var/grab_sound
/// A path to an outfit that is important for species life e.g. plasmaman outfit
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/human/human_movement.dm
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

/mob/living/carbon/human/Move(NewLoc, direct)
. = ..()
if(shoes && body_position == STANDING_UP && loc == NewLoc && has_gravity(loc))
if(shoes && !moving_diagonally && body_position == STANDING_UP && loc == NewLoc && has_gravity(loc))
SEND_SIGNAL(shoes, COMSIG_SHOES_STEP_ACTION)

/mob/living/carbon/human/Process_Spacemove(movement_dir = 0, continuous_move = FALSE)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/surgery/bodyparts/parts.dm
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,8 @@
unarmed_effectiveness = 15
/// Datum describing how to offset things worn on the foot of this leg, note that an x offset won't do anything here
var/datum/worn_feature_offset/worn_foot_offset

/// What does our footsteps (barefoot) sound like?
var/footstep_type = FOOTSTEP_MOB_BAREFOOT
biological_state = BIO_STANDARD_JOINTED

/obj/item/bodypart/leg/Destroy()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
icon_greyscale = 'icons/mob/human/species/lizard/bodyparts.dmi'
limb_id = BODYPART_ID_DIGITIGRADE
bodytype = BODYTYPE_HUMANOID | BODYTYPE_ORGANIC | BODYTYPE_DIGITIGRADE
footstep_type = FOOTSTEP_MOB_CLAW

/obj/item/bodypart/leg/left/digitigrade/update_limb(dropping_limb = FALSE, is_creating = FALSE)
. = ..()
Expand All @@ -77,6 +78,7 @@
icon_greyscale = 'icons/mob/human/species/lizard/bodyparts.dmi'
limb_id = BODYPART_ID_DIGITIGRADE
bodytype = BODYTYPE_HUMANOID | BODYTYPE_ORGANIC | BODYTYPE_DIGITIGRADE
footstep_type = FOOTSTEP_MOB_CLAW

/obj/item/bodypart/leg/right/digitigrade/update_limb(dropping_limb = FALSE, is_creating = FALSE)
. = ..()
Expand Down
2 changes: 1 addition & 1 deletion maplestation_modules/code/datums/elements/shoe_footstep.dm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
SIGNAL_HANDLER

var/mob/living/carbon/human/owner = source.loc
if(CHECK_MOVE_LOOP_FLAGS(owner, MOVEMENT_LOOP_OUTSIDE_CONTROL))
if(CHECK_MOVE_LOOP_FLAGS(owner, MOVEMENT_LOOP_OUTSIDE_CONTROL) || owner.moving_diagonally == SECOND_DIAG_STEP)
return
if(owner.move_intent == MOVE_INTENT_SNEAK || (owner.movement_type & (VENTCRAWLING|FLYING|FLOATING)))
return
Expand Down
Loading