freeslot("sfx_fwak")

--I hate this so much
addHook("ThinkFrame", function()
for player in players.iterate do
if player.mo and player.mo.valid and player.mo.skin == "fakerguide" then
-- initialize custom variables properly
if player.last_ground_speed == nil then player.last_ground_speed = 0 end
if player.last_grounded == nil then player.last_grounded = false end
if player.footstep_timer == nil then player.footstep_timer = 0 end
-- Calculate player's speed
local speed = R_PointToDist2(0, 0, player.mo.momx, player.mo.momy) / FRACUNIT

-- decrement footstep timer
if player.footstep_timer > 0 and player.mo.state == S_PLAY_WALK then
player.footstep_timer = player.footstep_timer - 1
end

-- check if player is on the ground and running
if P_IsObjectOnGround(player.mo) then
local current_speed = FixedHypot(player.mo.momx, player.mo.momy)

if current_speed > FRACUNIT and player.footstep_timer == 0 then
-- play footsteps
S_StartSound(player.mo, sfx_fwak)
player.footstep_timer = TICRATE/speed + 7
player.last_ground_speed = current_speed
player.last_grounded = true
elseif player.footstep_timer == 0 then
player.last_ground_speed = current_speed
player.last_grounded = true
end
else
player.last_grounded = false
end
end
end
end)