
//command for fix the hud idk
rawset(_G, "CV_hud", {}) -- for console vars
CV_hud.x = CV_RegisterVar({
	name = "PZNO_hud_x",
	defaultvalue = "283",
	flags = CV_NETVAR|CV_FLOAT,
	PossibleValue = {MIN = -1000, MAX = 1000*FRACUNIT}, 
})

CV_hud.y = CV_RegisterVar({
	name = "PZNO_hud_y",
	defaultvalue = "96",
	flags = CV_NETVAR|CV_FLOAT,
	PossibleValue = {MIN = -1000, MAX = 1000*FRACUNIT}, 
})

//command for enable hud, by xd
COM_AddCommand("PZNO_hud", function(player, arg1)
    if arg1 == nil
        CONS_Printf(player, 'you can enable and disable telereacciones xd.')
        return
    end

    if arg1 == "1" or arg1 == "yes" then
	    CONS_Printf(player, "i want see your beautiful face pizzano.")
        player.hudd = 1
    elseif arg1 == "0" or arg1 == "no" then
	    CONS_Printf(player, "i dont want see you pizzano mf.")
        player.hudd = 0
    end
end)

//TV Reaction

local function face(v, player, cam)
	if player.mo and player.mo.valid
	and player.hudd == 1
	or player.mo and player.mo.valid
	and player.hudd == nil
		if (maptol & TOL_NIGHTS) then
			return
		end
		
		if not player.mo and player.mo.valid
			return
		end
		
		local idleanim = ((leveltime/2) % 57) + 1
		local mach3anim = ((leveltime/1) % 6) + 1
		local mach4anim = ((leveltime/1) % 6) + 1
		local panicanim = ((leveltime/2) % 3) + 1
		local minecartanim = ((leveltime/2) % 2) + 1
		local owchieanim = ((leveltime/2) % 6) + 1
		local overtimeanim = ((leveltime/2) % 3) + 1
		local mach2anim = ((leveltime/2) % 6) + 1
		local mach5anim = ((leveltime/2) % 6) + 1
		local underwateranim = ((leveltime/2) % 2) + 1
		local wallcrashanim = ((leveltime/2) % 3) + 1
		local fireassanim = ((leveltime/2) % 2) + 1
		local fireass = v.cachePatch( 'PNO_FIRE' .. fireassanim )
		local minecart = v.cachePatch( 'PNOMN' .. minecartanim )
		local idle = v.cachePatch( 'PNO_IE' .. idleanim )
		local mach3 = v.cachePatch( 'PNO_H' .. mach3anim )
		local mach4 = v.cachePatch( 'PNO_C' .. mach4anim )
		local panic = v.cachePatch( 'PNO_P' .. panicanim )
		local owchie = v.cachePatch( 'PNO_L' .. owchieanim )
		local overtime = v.cachePatch( 'PNO_O' .. overtimeanim )
		local mach2 = v.cachePatch( 'PNO_M' .. mach2anim )
		local mach5 = v.cachePatch( 'PNO_5' .. mach5anim )
		local underwater = v.cachePatch( 'PNO_WATER' .. underwateranim )
		local wallcrash = v.cachePatch( 'PNO_D' .. wallcrashanim )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		
		 if player.pizzanoreal
		and ((PTSR and PTSR.pizzatime and not PTSR.timeover)
		or ((PTV3 and PTV3.pizzatime and player.ptv3 and not player.ptv3.extreme)
		and not (gametype == GT_PTV3DM)
		and not (PTV3.overtime)))
		and not ((player.mo.state == S_PLAY_PAIN)
		or (player.mo.state == S_PLAY_DEDXD)
		or (player.mo.state == S_PLAY_DEAD)
		or(player.mo.state == S_PLAY_MACH5PZNOREAL)
		or (player.mo.state == S_PLAY_RUN)
		or (player.mo.state == S_PLAY_DASH)
		or (player.mo.state == S_PZNO_MACHHIT)
		or (player.mo.state == S_PLAY_FIRE)
		 or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL) or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL_FINISH)
		or (player.mo.state == S_PLAY_MACH3_PAD)
		or (player.mo.state == S_PLAY_MACH4PZNO) or (player.mo.state == S_PLAY_MACH5PZNO)
		or (player.mo.state == S_PLAY_PZNO_REDIRECT)
		or (player.mo.state == S_PLAY_SUPERJUMP_PREPARESIDE)
		or (player.mo.state == S_PLAY_FIRE_FINISH)
		or (player.mo.state == S_PLAY_SUPERJUMP_SIDE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMP)
		or (player.mo.state == S_PLAY_MACHC1))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, panic, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and ((PTSR and PTSR.pizzatime and PTSR.timeover)
		or (player.ptv3 and player.ptv3.extreme))
		and not ((player.mo.state == S_PLAY_PAIN)
		or (player.mo.state == S_PLAY_DEDXD)
		or (player.mo.state == S_PLAY_DEAD))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, overtime, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and player.powers[pw_carry] == CR_MINECART
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, minecart, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and ((player.mo.state == S_PLAY_DASH)
		or (player.mo.state == S_PZNO_MACHHIT)
		or (player.mo.state == S_PLAY_FIRE)
		 or (player.mo.state == S_PLAY_MACH5PZNO)
		or (player.mo.state == S_PLAY_MACH3_PAD)
		or (player.mo.state == S_PLAY_PZNO_REDIRECT)
		 or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL) or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL_FINISH)
		or (player.mo.state == S_PLAY_SUPERJUMP_PREPARESIDE)
		or (player.mo.state == S_PLAY_FIRE_FINISH)
		or (player.mo.state == S_PLAY_SUPERJUMP_SIDE))
		or  player.pizzanoreal
		and ((player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMP))
		and player.machxdtimerr <= 350
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, mach3, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and ((player.mo.state == S_PZNO_FIREASS) or (player.mo.state == S_PZNO_FIREASS_LAND)) 
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, fireass, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and ((player.mo.state == S_PLAY_MACH4PZNO) or (player.mo.state == S_PLAY_MACH5PZNO)) 
		or player.pizzanoreal
		and player.machxdtimerr >= 350
		and ((player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMP))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, mach4, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			
		elseif player.pizzanoreal
		and not ((PTSR and PTSR.pizzatime and not PTSR.timeover)
		or ((PTV3 and PTV3.pizzatime and player.ptv3 and not player.ptv3.extreme)
		and not (gametype == GT_PTV3DM)
		and not (PTV3.overtime)))
		and (player.mo.eflags & MFE_UNDERWATER)
		and not ((player.mo.state == S_PLAY_PAIN)
		or (player.mo.state == S_PLAY_DEDXD)
		or (player.mo.state == S_PLAY_DEAD)
		or (player.mo.state == S_PLAY_RUN)
		or (player.mo.state == S_PLAY_DASH)
		or (player.mo.state == S_PZNO_MACHHIT)
		or (player.mo.state == S_PLAY_FIRE)
		 or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL) or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL_FINISH)
		or (player.mo.state == S_PLAY_MACH3_PAD)
		or (player.mo.state == S_PLAY_MACH4PZNO) or (player.mo.state == S_PLAY_MACH5PZNO)
		or (player.mo.state == S_PLAY_PZNO_REDIRECT)
		or (player.mo.state == S_PLAY_SUPERJUMP_PREPARESIDE)
		or (player.mo.state == S_PLAY_FIRE_FINISH)
		or (player.mo.state == S_PLAY_SUPERJUMP_SIDE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMP)
		or (player.mo.state == S_PLAY_MACHC1))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, underwater, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			
			elseif player.pizzanoreal
		and ((player.mo.state == S_PLAY_MACH5PZNOREAL)) 
		or player.pizzanoreal
		and player.machxdtimerr >= 900
		and ((player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMP))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, mach5, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and ((player.mo.state == S_PLAY_RUN)
		or (player.mo.state == S_PLAY_MACHC1))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, mach2, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and ((player.mo.state == S_PLAY_PAIN) or (player.mo.state == S_PLAY_DEDXD) or (player.mo.state == S_PLAY_DEAD))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, owchie, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and ((player.mo.state == S_PLAY_WALLCRASSH_AIR_START) or (player.mo.state == S_PLAY_WALLCRASSH_AIR_FINISH)or (player.mo.state == S_PLAY_WALLCRASSH))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, wallcrash, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		
		elseif player.pizzanoreal
		and not ((PTSR and PTSR.pizzatime and not PTSR.timeover)
		or ((PTV3 and PTV3.pizzatime and player.ptv3 and not player.ptv3.extreme)
		and not (gametype == GT_PTV3DM)
		and not (PTV3.overtime)))
		and not ((player.mo.state == S_PLAY_PAIN)
		or (player.mo.state == S_PLAY_DEDXD)
		or (player.mo.state == S_PLAY_DEAD)
		or (player.mo.state == S_PLAY_RUN)
		or (player.mo.state == S_PLAY_DASH)
		or (player.mo.state == S_PZNO_MACHHIT)
		or (player.mo.state == S_PLAY_FIRE)
		 or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL) or (player.mo.state == S_PLAY_WALLCLIMBSPIN_CANCEL_FINISH)
		or (player.mo.state == S_PLAY_MACH3_PAD)
		or (player.mo.state == S_PLAY_MACH4PZNO) or (player.mo.state == S_PLAY_MACH5PZNO)
		or (player.mo.state == S_PLAY_PZNO_REDIRECT)
		or (player.mo.state == S_PLAY_SUPERJUMP_PREPARESIDE)
		or (player.mo.state == S_PLAY_FIRE_FINISH)
		or (player.mo.state == S_PLAY_SUPERJUMP_SIDE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE)
		or (player.mo.state == S_PLAY_PZNOMACH3JUMP)
		or (player.mo.state == S_PLAY_MACHC1))
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, idle, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)

		end
	end
end
hud.add(face, "game")

//super taunt hud yeeeea
local function supertaunthuds(v, player)
	if player.mo and player.mo.valid
	and player.hudd == 1
	or player.mo and player.mo.valid
	and player.hudd == nil
		if (maptol & TOL_NIGHTS) then
			return
		end
		
		if not player.mo and player.mo.valid
			return
		end
		
		//KILL ENEMIES NOW!!!
		local supertaunthudanimlevel0 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel0 = v.cachePatch( 'SPTNLV_0' .. supertaunthudanimlevel0 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//9 remains
		local supertaunthudanimlevel1 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel1 = v.cachePatch( 'SPTNLV_1' .. supertaunthudanimlevel1 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		
		local supertaunthudanimlevel2 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel2 = v.cachePatch( 'SPTNLV_2' .. supertaunthudanimlevel2 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//idk
		local supertaunthudanimlevel3 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel3 = v.cachePatch( 'SPTNLV_3' .. supertaunthudanimlevel3 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//remains 6
		local supertaunthudanimlevel4 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel4 = v.cachePatch( 'SPTNLV_4' .. supertaunthudanimlevel4 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//remains 5
		local supertaunthudanimlevel5 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel5 = v.cachePatch( 'SPTNLV_5' .. supertaunthudanimlevel5 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//remains 4
		local supertaunthudanimlevel6 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel6 = v.cachePatch( 'SPTNLV_6' .. supertaunthudanimlevel6 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//near
		local supertaunthudanimlevel7 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel7 = v.cachePatch( 'SPTNLV_7' .. supertaunthudanimlevel7 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//close
		local supertaunthudanimlevel8 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel8 = v.cachePatch( 'SPTNLV_8' .. supertaunthudanimlevel8 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//so cloooooose
		local supertaunthudanimlevel9 = ((leveltime/2) % 1) + 1
		local supertaunthudlevel9 = v.cachePatch( 'SPTNLV_9' .. supertaunthudanimlevel9 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		//FULL
		local supertaunthudanimlevelfull = ((leveltime/2) % 7) + 1
		local supertaunthudlevelfull = v.cachePatch( 'SPTNLV_F' .. supertaunthudanimlevelfull )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		
		 if player.pizzanoreal
		and player.pznosupertauntcounter == 0
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel0, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		elseif player.pizzanoreal
		and player.pznosupertauntcounter == 1
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel1, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		elseif player.pizzanoreal
		and player.pznosupertauntcounter == 2
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel2, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter == 3
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel3, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter == 4
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel4, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter == 5
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel5, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter == 6
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel6, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter == 7
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel7, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter == 8
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel8, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter == 9
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevel9, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
			elseif player.pizzanoreal
		and player.pznosupertauntcounter >= 10
			v.drawScaled(CV_hud.x.value, CV_hud.y.value, FRACUNIT/2, supertaunthudlevelfull, V_SNAPTOTOP|V_SNAPTORIGHT, playercolor)
		end
	end
end
hud.add(supertaunthuds, "game")

//tutorial hehe
COM_AddCommand("PZNO_tutorial", function(player, arg1)
    if arg1 == nil
        CONS_Printf(player, 'you can learn about pizzanos moveset with a tutorial(show and hide).')
        return
    end

    if arg1 == "1" or arg1 == "show" or arg1 == "yes" then
        player.pznotutorial = 1
    elseif arg1 == "0" or arg1 == "hide" or arg1 == "no" then
        player.pznotutorial = 0
    end
end)

addHook("PlayerThink", function(player)
	if player.pizzanoreal == true
	and not ((player.pznotutorialpag3 == true)
	or (player.pznotutorialpag2 == true))
	player.pznotutorialpag1 = true
	end
	
	if player.pizzanoreal
	and ((player.pznotutorialpag1 == true)
	or (player.pznotutorialpag3 == true))
	and player.c2timr == 1
	player.pznotutorialpag2 = true
	player.pznotutorialpag1 = false
	player.pznotutorialpag3 = false
	end
	
	if player.pizzanoreal
	and ((player.pznotutorialpag2 == true)
	or (player.pznotutorialpag3 == true))
	and player.c1timr == 1
	player.pznotutorialpag2 = false
	player.pznotutorialpag1 = true
	player.pznotutorialpag3 = false
	end
	
	if player.pizzanoreal
	and ((player.pznotutorialpag1 == true)
	or (player.pznotutorialpag2 == true))
	and player.c3timr == 1
	player.pznotutorialpag2 = false
	player.pznotutorialpag1 = false
	player.pznotutorialpag3 = true
	end
end)

local function showtutorial(v, player)
	if player.mo and player.mo.valid
	and player.pizzanoreal
	and player.pznotutorial == 1
		if (maptol & TOL_NIGHTS) then
			return
		end
		
		if not player.mo and player.mo.valid
			return
		end
		
		local pnotutorialpagg1 = ((leveltime/2) % 1) + 1
		local pnotutorialpagg2 = ((leveltime/2) % 1) + 1
		local pnotutorialpagg3 = ((leveltime/2) % 1) + 1
		local pnotutorialpag1 = v.cachePatch( 'TUTORIALPAG1' .. pnotutorialpagg1 )
		local pnotutorialpag2 = v.cachePatch( 'TUTORIALPAG2' .. pnotutorialpagg2 )
		local pnotutorialpag3 = v.cachePatch( 'TUTORIALPAG3' .. pnotutorialpagg3 )
		local playercolor = v.getColormap(player.skin, player.mo.color)
		
		 if player.pizzanoreal
		 and player.pznotutorialpag1 == true
			v.drawScaled(60*FRACUNIT, 60*FRACUNIT, FRACUNIT/2, pnotutorialpag1, V_PERPLAYER, playercolor)
         
		 elseif player.pizzanoreal
		 and player.pznotutorialpag2 == true
		 v.drawScaled(60*FRACUNIT, 60*FRACUNIT, FRACUNIT/2, pnotutorialpag2, V_PERPLAYER, playercolor)
		 
		 elseif player.pizzanoreal
		 and player.pznotutorialpag3 == true
		 v.drawScaled(60*FRACUNIT, 60*FRACUNIT, FRACUNIT/2, pnotutorialpag3, V_PERPLAYER, playercolor)
		end
	end
end
hud.add(showtutorial, "game")
