Adds footsteps (#39389)

Walking instead of running will reduce the noise, making it now more useful to gameplay.
Plating and wood makes a lot of noise, floor and carpet are quieter.

Range and volume may need to be balanced later on.

Oh, I reorganized some sound files too - the ones beepsky and medbot uses.
This commit is contained in:
nicbn
2018-08-25 21:52:31 -03:00
committed by yogstation13-bot
parent dab3d3f53f
commit afab24733f
119 changed files with 252 additions and 35 deletions

View File

@@ -0,0 +1,39 @@
/datum/component/footstep
var/steps = 0
var/volume
var/e_range
/datum/component/footstep/Initialize(volume_ = 0.5, e_range_ = -1)
if(!isliving(parent))
return COMPONENT_INCOMPATIBLE
volume = volume_
e_range = e_range_
RegisterSignal(parent, list(COMSIG_MOVABLE_MOVED), .proc/play_footstep)
/datum/component/footstep/proc/play_footstep()
var/turf/open/T = get_turf(parent)
if(!istype(T))
return
var/mob/living/LM = parent
var/v = volume
var/e = e_range
if(!T.footstep || LM.lying || !LM.canmove || LM.resting || LM.buckled || LM.throwing)
return
if(iscarbon(LM))
var/mob/living/carbon/C = LM
if(!C.get_bodypart(BODY_ZONE_L_LEG) && !C.get_bodypart(BODY_ZONE_R_LEG))
return
if(ishuman(C) && C.m_intent == MOVE_INTENT_WALK)
v /= 2
e -= 5
steps++
if(steps >= 6)
steps = 0
if(steps % 2)
return
if(!LM.has_gravity(T) && steps != 0) // don't need to step as often when you hop around
return
playsound(T, pick(GLOB.footstep[T.footstep][1]),
GLOB.footstep[T.footstep][2] * v,
TRUE,
GLOB.footstep[T.footstep][3] + e)