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

[MIRROR] Fixes footsteps runtimes, part 2 #871

Merged
merged 1 commit into from
Nov 29, 2023
Merged
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
21 changes: 12 additions & 9 deletions code/datums/elements/footstep.dm
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@
return

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

if(isfile(footstep_sounds) || istext(footstep_sounds))
playsound(source.loc, footstep_sounds, volume, falloff_distance = 1, vary = sound_vary)
return

var/turf_footstep = prepared_steps[footstep_type]
if(!turf_footstep)
if(isnull(turf_footstep) || !footstep_sounds[turf_footstep])
return
playsound(source.loc, pick(footstep_sounds[turf_footstep][1]), footstep_sounds[turf_footstep][2] * volume, TRUE, footstep_sounds[turf_footstep][3] + e_range, falloff_distance = 1, vary = sound_vary)

Expand All @@ -133,27 +133,30 @@
range_adjustment = -2

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

//cache for sanic speed (lists are references anyways)
var/static/list/footstep_sounds = GLOB.footstep
///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)
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]
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)
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
var/barefoot_type = prepared_steps[FOOTSTEP_MOB_BAREFOOT]
// 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/static/list/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]),
Expand Down
Loading