freeslot("sfx_vchr", "sfx_vwee")
addHook("ThinkFrame", function()
for player in players.iterate do
-- initialize custom variables
player.vstallduration = player.vstallduration or 15 -- 1 second (35 tics)
player.vstall = player.vstall or false
player.vstalltimer = player.vstalltimer or 0
player.vkup = player.vkup or 0
player.vkfront = player.vkfront or 0
player.VobStalled = player.VobStalled or false
player.spawn_ghost = player.spawn_ghost or false
player.ghost_timer = player.ghost_timer or 0

if player.mo and player.mo.valid and not (gametype == GT_LTMMURDERMYSTERY) and player.mo.skin == "vob" then

if (player.cmd.buttons & BT_CUSTOM2) ~= 0 then
player.spawn_ghost = true
player.ghost_timer = ghost_interval
end

if (player.cmd.buttons & BT_CUSTOM2) ~= 0 and (player.pflags & PF_JUMPED) ~= 0 and not player.vstall and not player.VobStalled then
player.vstall = true
player.vstalltimer = player.vstallduration
player.VobStalled = true

-- play the start sound effect for stalling
S_StartSound(player.mo, sfx_vwee)
end

if player.vstall then
player.mo.momz = 0 * FRACUNIT -- stall vertical movement
P_InstaThrust(player.mo, player.mo.angle, FixedMul(0 * FRACUNIT, player.mo.scale))
player.mo.state = S_PLAY_ROLL

player.vstalltimer = player.vstalltimer - 1

if player.vstalltimer <= 0 then
player.vstall = false
P_SetObjectMomZ(player.mo, 9 * FRACUNIT)
player.mo.state = S_PLAY_FALL
P_SpawnMobjFromMobj(player.mo, 1 * FRACUNIT, 1 * FRACUNIT, 1 * FRACUNIT, MT_EXPLODE)
P_InstaThrust(player.mo, player.mo.angle,(P_RandomRange(10, 45) * FRACUNIT), player.mo.scale) -- do the fucking dash -- throw player downward

-- play the end sound effect when stalling ends
S_StartSound(player.mo, sfx_vchr)
player.mo.state = S_PLAY_ROLL
end	
end

if P_IsObjectOnGround(player.mo) then
player.vstall = false -- reset the stalling flag when the player touches down again
player.vstalltimer = 0
player.VobStalled = false -- allow another stall after touching the ground

player.spawn_ghost = false -- stop spawning ghost mobjs
player.ghost_timer = 0 -- reset the ghost timer
end
end
end
end)
