/*
addHook("PlayerThink", function(player)
	if player.mo and player.playerstate == PST_LIVE then
		
		if ((player.pflags & PF_STASIS) or (player.pflags & PF_STARTDASH) or player.powers[pw_carry] ~= CR_NONE) then
			S_StartSound(player.mo, sfx_mswarp)
		end
	end
end)
*/

addHook("PlayerThink", function(player)
	if player.mo then
		if (player.pflags & PF_STASIS) or player.skidtime or player.playerstate ~= PST_LIVE  or (player.pflags & PF_STARTDASH) or player.powers[pw_carry] or P_PlayerInPain(player) or player.powers[pw_nocontrol] or player.spectator or player.exiting or player.climbing or (player.pflags & PF_SLIDING) or (player.powers[pw_super] and mapheaderinfo[gamemap].doomsayfloat) then
			player.control = false
		else
			player.control = true
		end
	end
end)

addHook("PlayerThink", function(player)
	if player.mo then
		
		if player.custom1tic == nil then
			player.custom1tic = 0
		end
		
		if player.custom2tic == nil then
			player.custom2tic = 0
		end
		
		if player.custom3tic == nil then
			player.custom3tic = 0
		end
		
		if player.spintic == nil then
			player.spintic = 0
		end
		
		if player.jumptic == nil then
			player.jumptic = 0
		end
		
		if player.prevtic == nil then
			player.prevtic = 0
		end
		
		if player.nexttic == nil then
			player.nexttic = 0
		end
		
		if player.attacktic == nil then
			player.attacktic = 0
		end
		
		if player.control == nil then
			player.control = false
		end
	end
end)

addHook("PlayerThink", function(player)
	if player.mo and player.playerstate == PST_LIVE then
		
		if player.cmd.buttons & BT_CUSTOM1 and player.custom1tic < 3 then
			player.custom1tic = $ + 1
		elseif not (player.cmd.buttons & BT_CUSTOM1) then
			player.custom1tic = 0
		end
		
		if player.cmd.buttons & BT_CUSTOM2 and player.custom2tic < 3 then
			player.custom2tic = $ + 1
		elseif not (player.cmd.buttons & BT_CUSTOM2) then
			player.custom2tic = 0
		end
		
		if player.cmd.buttons & BT_CUSTOM3 and player.custom3tic < 3 then
			player.custom3tic = $ + 1
		elseif not (player.cmd.buttons & BT_CUSTOM3) then
			player.custom3tic = 0
		end
		
		if player.cmd.buttons & BT_SPIN and player.spintic < 3 then
			player.spintic = $ + 1
		elseif not (player.cmd.buttons & BT_SPIN) then
			player.spintic = 0
		end
		
		if player.cmd.buttons & BT_JUMP and player.jumptic < 3 then
			player.jumptic = $ + 1
		elseif not (player.cmd.buttons & BT_JUMP) then
			player.jumptic = 0
		end
		
		if player.cmd.buttons & BT_WEAPONPREV and player.prevtic < 3 then
			player.prevtic = $ + 1
		elseif not (player.cmd.buttons & BT_WEAPONPREV) then
			player.prevtic = 0
		end
		
		if player.cmd.buttons & BT_WEAPONNEXT and player.nexttic < 3 then
			player.nexttic = $ + 1
		elseif not (player.cmd.buttons & BT_WEAPONNEXT) then
			player.nexttic = 0
		end
		
		if player.cmd.buttons & BT_ATTACK and player.attacktic < 3 then
			player.attacktic = $ + 1
		elseif not (player.cmd.buttons & BT_ATTACK) then
			player.attacktic = 0
		end
		
	end
end)

/*
hud.add(function(v,player)
	if player.mo then
		local xpos = hudinfo[HUD_RINGS].x
		local ypos = hudinfo[HUD_RINGS].y
		v.drawString(xpos, ypos + 40, ("CUSTOM1: " + (player.custom1tic)), V_PERPLAYER|V_GREENMAP)
		v.drawString(xpos, ypos + 50, ("CUSTOM2: " + (player.custom2tic)), V_PERPLAYER|V_GREENMAP)
		v.drawString(xpos, ypos + 60, ("CUSTOM3: " + (player.custom3tic)), V_PERPLAYER|V_GREENMAP)
		v.drawString(xpos, ypos + 70, ("SPIN: " + (player.spintic)), V_PERPLAYER|V_GREENMAP)
		v.drawString(xpos, ypos + 80, ("JUMP: " + (player.jumptic)), V_PERPLAYER|V_GREENMAP)
	end
end)
*/
/*
hud.add(function(v,player)
	if player.mo then
		local xpos = hudinfo[HUD_RINGS].x
		local ypos = hudinfo[HUD_RINGS].y
		v.drawString(xpos, ypos + 40, ("HP: " + (player.mo.health)), V_PERPLAYER|V_GREENMAP)
	end
end)
*/
/*
hud.add(function(v,player)
	if player.mo then
		local xpos = hudinfo[HUD_RINGS].x
		local ypos = hudinfo[HUD_RINGS].y
		v.drawString(xpos, ypos + 40, ("blocked: " + (player.blocked)), V_PERPLAYER|V_GREENMAP)
	end
end)
*/
/*
hud.add(function(v,player)
	if player.mo then
		local xpos = hudinfo[HUD_RINGS].x
		local ypos = hudinfo[HUD_RINGS].y
		v.drawString(xpos, ypos + 40, ("name: " + (player.name)), V_PERPLAYER|V_GREENMAP)
	end
end)
*/