
//divethok
addHook("PlayerThink", function(player)
	if (player.mo and player.mo.valid and player.mo.skin == "rafael")
		if not (player.cmd.buttons & BT_CUSTOM2) then
			player.jumptapready = true
			player.jumptapping = false
		elseif player.jumptapready then
			player.jumptapping = true
			player.jumptapready = false
		else
			player.jumptapping = false
		end
		
		if player.jumptapping then
			if P_IsObjectOnGround(player.mo) == false and player.smakuse == false then
				P_SetObjectMomZ(player.mo, (0 - 20*FRACUNIT), true) 
				S_StartSound(player.mo,sfx_zoom, player)
				player.smakuse = true
				player.mo.state = S_PLAY_FALL
				player.timon = true
				player.pflags = $ |PF_SPINNING
			end
		elseif P_IsObjectOnGround(player.mo) == true then
			player.smakuse = false
			player.timon = false
			player.timer = 0
		elseif player.timon == true then
			player.timer = $ + 1
			P_SpawnGhostMobj(player.mo)
			if player.timer >= 5 and player.timer <= 35 and player.mo.momz <= 15*FRACUNIT then
				P_SetObjectMomZ(player.mo, (4*FRACUNIT), true)  
				player.mo.state = S_PLAY_ROLL
				player.pflags = $ & ~PF_SPINNING
				S_StartSound(player.mo,sfx_spndsh, player)
			elseif player.timer >= 1*TICRATE - 1*TICRATE/2 and player.timer <= 2*TICRATE then
				player.mo.state = S_PLAY_SPRING
				player.pflags = $ & ~PF_SPINNING
				player.timon = false
				player.timer = 0
			end
		end
	end
end)

//skidattack
addHook("PlayerThink", function(player)
	if (player.mo and player.mo.valid and player.mo.skin == "rafael")
		if player.mo.state == S_PLAY_SKID
			if (leveltime % 2 == 0) then
				P_SpawnSpinMobj(player, MT_RAFASKID)
			local sectorthing = P_PlayerTouchingSectorSpecial(player, 0, 0)
			elseif sectorthing.valid then
				for fof in sectorthing.ffloors()
					if fof.valid and (fof.flags & FF_BUSTUP) and (fof.flags & FF_EXISTS)
					and (abs(fof.topheight - player.mo.z) <= 40*player.mo.scale) then
						EV_CrumbleChain(player.sectorthing, fof)
					end
				end
			end
		end
	end
end)
		