freeslot("S_PLAY_GJUP", "SPR2_CRAK", "SFX_fcrk")

states[S_PLAY_GJUP] = {SPR_PLAY, SPR2_CRAK|FF_ANIMATE, 1, nil, 0, 0, S_PLAY_GJUP}

addHook("ThinkFrame", function()
for player in players.iterate do
-- initialize custom variables
player.fstalling = player.fstalling or false
player.fstalltimer = player.fstalltimer or 0
player.fstalltime = player.fstalltime or 0
player.fhasStalled = player.fhasStalled or false
player.spawn_ghost = player.spawn_ghost or false
player.ghost_timer = player.ghost_timer or 0

if not player.mo.skin == "fakerguide" then
player.fstalling = false -- reset the stalling flag when the player touches down again
player.fstalltimer = 0
player.fhasStalled = false -- allow another stall after touching the ground
end

if player.mo and player.mo.valid and not (gametype == GT_LTMMURDERMYSTERY) and player.mo.skin == "fakerguide" then  -- check if player has fjumped

if not player.powers[pw_super] then
player.fstalltime = 1 * TICRATE
else
player.fstalltime = 3 / 2 * TICRATE
end

if (player.cmd.buttons & BT_CUSTOM1) and (player.pflags & PF_JUMPED) and not player.fstalling and not player.fhasStalled then
player.mo.state = S_PLAY_GJUP
player.fstalling = true
player.fstalltimer = player.fstalltime
player.fhasStalled = true

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

if player.fstalling then
P_SetObjectMomZ(player.mo, player.mo.momz + 1 * FRACUNIT)

player.fstalltimer = player.fstalltimer - 1

if player.fstalltimer <= 0 then
player.fstalling = false -- throw player downward

-- play the end sound effect when stalling ends
player.mo.state = S_PLAY_JUMP
end	
end

if P_IsObjectOnGround(player.mo) then
player.fstalling = false -- reset the stalling flag when the player touches down again
player.fstalltimer = 0
player.fhasStalled = false -- allow another stall after touching the ground
end
end
end
end)

addHook("ThinkFrame", function()
for player in players.iterate do
if player.mo and player.mo.valid and player.mo.skin == "fakerguide" and player.mo.momz >= 23 * FRACUNIT and player.fstalling == true and not player.powers[pw_super] then
player.mo.momz = 23 * FRACUNIT
end
end
end)