freeslot("S_PLAY_GJUP", "SPR2_CRAK", "SFX_SCRK")

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

//Borrowed Miguel's core of the hard drop
-- specify the stall duration and downward speed-- 3.5 second 

addHook("ThinkFrame", function()
for player in players.iterate do
-- initialize custom variables
player.stalling = player.stalling or false
player.stallduration = player.stallduration or 0
player.stalltimer = player.stalltimer or 0
player.hasStalled = player.hasStalled or false

if not player.powers[pw_super] then
player.stallduration = 100
else
player.stallduration = 300
end

if player.mo and player.mo.valid and not (gametype == GT_LTMMURDERMYSTERY) and player.mo.skin == "superguide" then
if not player.mo.skin == "superguide" then
player.stalling = false -- reset the stalling flag when the player touches down again
player.stalltimer = 0
player.hasStalled = false
end
if (player.cmd.buttons & BT_CUSTOM1) and (player.pflags & PF_JUMPED) and not player.stalling and not player.hasStalled then
player.mo.state = S_PLAY_GJUP
player.stalling = true
player.stalltimer = player.stallduration
player.hasStalled = true

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

if player.stalling then
player.mo.momz = 0 -- stall vertical movement
player.pflags = $ |PF_CANCARRY

player.stalltimer = player.stalltimer - 1

if player.stalling and not (player.mo.state == S_PLAY_GJUP or player.mo.state == S_PLAY_SPRING or player.mo.state == S_PLAY_WALK) then
S_StartSound(player.mo, sfx_gmis1)
P_SetObjectMomZ(player.mo, 10 * FRACUNIT)
P_InstaThrust(player.mo, player.mo.angle, FixedMul(-12 * FRACUNIT, player.mo.scale))
player.stalltimer = 0
end

if player.stalling and player.mo.state == S_PLAY_SPRING then
S_StartSound(player.mo, sfx_gmis2)
player.stalling = false
player.stalltimer = 0
player.hasStalled = false
player.pflags = $ |PF_JUMPED
player.flutteruses = 3
end

if player.stalltimer <= 0 then
player.stalling = false -- throw player downward

-- play the end sound effect when stalling ends
player.mo.state = S_PLAY_FALL
end	
end
if player.stalling and (player.cmd.buttons & BT_SPIN) ~= 0 then
player.stalltimer = 0
end

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