//kungfu
addHook("ThinkFrame", function()
    for player in players.iterate do
        if ((player.mo.skin == "pizzano") or (player.exiting))
			if ((player.mo.state == S_PLAY_MELEE_FINISH) or (player.mo.state == S_PLAY_MELEE) or (player.mo.state == S_PLAY_MELEE_LANDING))
			and not ((player.mo.state == S_PLAY_KUNGFU1) or (player.mo.state == S_PLAY_KUNGFU2) or (player.mo.state == S_PLAY_KUNGFU3) or (player.mo.state == S_PLAY_KUNGFU4) or (player.mo.state == S_PLAY_KUNGFU5) or (player.mo.state == S_PLAY_CHAINSAW) or (player.mo.state == S_PLAY_KUNGFU6))
			and P_IsObjectOnGround(player.mo) then
					player.randomkungfu = P_RandomRange(1, 6)
					if player.randomkungfu == 1
					    player.mo.state = S_PLAY_KUNGFU1
						S_StartSound(player.mo, sfx_kungf)
					elseif player.randomkungfu == 2
						player.mo.state = S_PLAY_KUNGFU2
						S_StartSound(player.mo, sfx_kungf)
					elseif player.randomkungfu == 3
						player.mo.state = S_PLAY_KUNGFU3
						S_StartSound(player.mo, sfx_kungf)
					elseif player.randomkungfu == 4
					    player.mo.state = S_PLAY_KUNGFU4
						S_StartSound(player.mo, sfx_kungf)
					elseif player.randomkungfu == 5
						player.mo.state = S_PLAY_KUNGFU5
						S_StartSound(player.mo, sfx_kungf)
					elseif player.randomkungfu == 6
						player.mo.state = S_PLAY_KUNGFU6
						S_StartSound(player.mo, sfx_kungf)
				end
			end
		end
	end
end)

//can kungfu damage?
addHook("PlayerCanDamage", function(player)
	if player.mo.skin == "pizzano"
	and ((player.mo.state == S_PLAY_KUNGFU1)
	or (player.mo.state == S_PLAY_KUNGFU2)
	or (player.mo.state == S_PLAY_KUNGFU3)
	or (player.mo.state == S_PLAY_KUNGFU4)
	or (player.mo.state == S_PLAY_KUNGFU5)
	or (player.mo.state == S_PLAY_CHAINSAW)
	or (player.mo.state == S_PLAY_KUNGFU6)
	or (player.mo.state == S_PLAY_AIRKUNGFU1)
	or (player.mo.state == S_PLAY_AIRKUNGFU2))
	return true
	end
end)

//if you kungfu, you will be strong
addHook("PlayerThink", function(player)
 if player.mo.skin == "pizzano"
 	and player.mo.state == S_PLAY_KUNGFU1
	or player.mo.state == S_PLAY_KUNGFU2
	or player.mo.state == S_PLAY_KUNGFU3
	or player.mo.state == S_PLAY_KUNGFU4
	or player.mo.state == S_PLAY_KUNGFU5
	or player.mo.state == S_PLAY_KUNGFU6
	or player.mo.state == S_PLAY_AIRKUNGFU1
	or player.mo.state == S_PLAY_AIRKUNGFU2
	or player.mo.state == S_PLAY_CHAINSAW then
	player.powers[pw_strong] = STR_HEAVY|STR_SPRING|STR_SPIKE|STR_ANIM|STR_WALL
	end
end)

//kungfu in mid air (don´t work same the kungfu on ground)
addHook("ThinkFrame", function()
        for player in players.iterate do
        if player.mo.skin == "pizzano" and (player.cmd.buttons & BT_SPIN)
		and player.speed <= 30*FRACUNIT
		and ((player.mo.state == S_PLAY_JUMPINITIAL) or (player.mo.state == S_PLAY_FALL) or (player.mo.state == S_PLAY_PZNOMACH2JUMP) or (player.mo.state == S_PLAY_PZNOMACH3JUMP)) then
                 player.randomkungfuair = P_RandomRange(1, 2)
					if player.randomkungfuair == 1
						player.mo.state = S_PLAY_AIRKUNGFU1
						P_Thrust(player.mo, player.mo.angle, 30*FRACUNIT)
						S_StartSound(player.mo, sfx_kungf)
					elseif player.randomkungfuair == 2
						player.mo.state = S_PLAY_AIRKUNGFU2
						P_Thrust(player.mo, player.mo.angle, 30*FRACUNIT)
						S_StartSound(player.mo, sfx_kungf)
			end
		end
	end
	for player in players.iterate do
		if player.mo.skin == "pizzano" and (player.cmd.buttons & BT_SPIN)
		and player.speed >= 30*FRACUNIT
		and ((player.mo.state == S_PLAY_JUMPINITIAL) or (player.mo.state == S_PLAY_FALL) or (player.mo.state == S_PLAY_PZNOMACH2JUMP) or (player.mo.state == S_PLAY_PZNOMACH3JUMP)) then
                 player.randomkungfuair = P_RandomRange(1, 2)
					if player.randomkungfuair == 1
						player.mo.state = S_PLAY_AIRKUNGFU1
						S_StartSound(player.mo, sfx_kungf)
					elseif player.randomkungfuair == 2
						player.mo.state = S_PLAY_AIRKUNGFU2
						S_StartSound(player.mo, sfx_kungf)
           end
		end
	end
end)

//slam
addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.mo.state == S_PLAY_BODYSLAM_INITIAL then
   P_SetObjectMomZ(player.realmo, 5*FRACUNIT, false)
   player.pflags = PF_THOKKED
end
end)

addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.mo.state == S_PLAY_BODYSLAM_FINAL then
   P_SetObjectMomZ(player.realmo, -65*FRACUNIT, false)
   player.pflags = PF_THOKKED
   player.powers[pw_nocontrol] = 1500000000000000000000
   player.pflags = PF_JUMPSTASIS
   player.powers[pw_strong] = STR_HEAVY|STR_SPRING|STR_SPIKE|STR_ANIM|STR_WALL
end
end)

addHook("ThinkFrame", do
    for player in players.iterate
        if (player.mo and player.mo.skin == "pizzano")
                if (player.cmd.buttons & BT_CUSTOM1) 
				and player.speed <= 32*FRACUNIT
				and not P_IsObjectOnGround(player.mo) then
		            player.pstomp = true
					player.slamTimer = $+1
	                  else
					player.slamTimer = 0
					
					end
					if player.slamTimer == 1
					and not ((player.mo.state == S_PLAY_BODYSLAM_INITIAL) or (player.mo.state == S_PLAY_BODYSLAM_FINAL) or (player.mo.state == S_PLAY_CROUNCH_AIR)) then
					     player.mo.state = S_PLAY_BODYSLAM_INITIAL
					end
				end
			end
end)

addHook ("PlayerThink",function(player)
if player.mo.skin == "pizzano"
and player.pstomp == true
and P_IsObjectOnGround(player.mo)

player.pstomp = false
player.powers[pw_nocontrol] = 1500000000000000000000
player.pflags = PF_JUMPSTASIS
player.mo.state = S_PLAY_BODYSLAMLAND
P_NukeEnemies(player.mo, player.mo, 300*FRACUNIT)
S_StartSound(player.mo, sfx_slfnl)
P_InstaThrust(player.mo, player.mo.angle, 0*FRACUNIT)
P_Thrust(player.mo, player.mo.angle, 0*FRACUNIT)
P_StartQuake(FRACUNIT*5, TICRATE/8*1)
end
end)

addHook ("PlayerThink",function(player)
if player.mo.skin == "pizzano"
and player.pstomp == true
and player.mo.state == S_PLAY_SPRING then

player.pstomp = false
end 
end)

addHook ("PlayerThink",function(player)
if player.mo.skin == "pizzano"
and player.pstomp == true
and ((player.mo.state == S_PLAY_BODYSLAM_INITIAL) or (player.mo.state == S_PLAY_BODYSLAM_FINAL))
and (player.mo.eflags & MFE_UNDERWATER)

player.pstomp = false
player.mo.state = S_PLAY_FALL
end
end)

//slam sounds effects
addHook("PlayerThink", function(player)
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and (player.mo.state == S_PLAY_BODYSLAM_INITIAL)
		and not S_SoundPlaying(player.mo, sfx_slstar) then
		S_StartSound(player.mo, sfx_slstar)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and not (player.mo.state == S_PLAY_BODYSLAM_INITIAL)
		and S_SoundPlaying(player.mo, sfx_slstar) then
		S_StopSoundByID(player.mo, sfx_slstar)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and (player.mo.state == S_PLAY_BODYSLAM_FINAL)	
		and not S_SoundPlaying(player.mo, sfx_slloop) then
		S_StartSound(player.mo, sfx_slloop)
    end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and not (player.mo.state == S_PLAY_BODYSLAM_FINAL)
		and S_SoundPlaying(player.mo, sfx_slloop) then
		S_StopSoundByID(player.mo, sfx_slloop)
	end
end)

//slam effect(superjumptoo)
addHook("ThinkFrame", do
	for p in players.iterate
		if ((p.mo.state == S_PLAY_BODYSLAM_FINAL) or (p.mo.state == S_PLAY_SUPERJUMP_RELEASE))
		and leveltime%5 == 0
			local ring = P_SpawnMobj(p.mo.x,p.mo.y,p.mo.z,MT_THOK)
			ring.state = S_MACH4RING
			ring.fuse = 999
			ring.tics = 20
			ring.angle = p.drawangle+ANGLE_90
			ring.scale = p.mo.scale-FRACUNIT/2
			ring.destscale = p.mo.scale*2
			ring.colorized = true
			ring.renderflags = $|RF_FLOORSPRITE
			ring.color = SKINCOLOR_WHITE
			if (p.mo.eflags & MFE_VERTICALFLIP)
				ring.flags2 = $|MF2_OBJECTFLIP
				ring.eflags = $|MFE_VERTICALFLIP
			end
		end
	end
end)

// Pizzano falling during a dive drop while diving. -Wiki
addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and ((player.mo.state == S_PLAY_PZNOMACH2JUMPDIVE) or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE) or (player.mo.state == S_PLAY_DIVE))
and not (player.mo.eflags & MFE_UNDERWATER)
and (player.cmd.buttons & BT_CUSTOM2) then
	player.pstomp = true
	P_Thrust(player.mo,player.mo.angle, -30*FU)
	player.mo.state = S_PLAY_BODYSLAM_INITIAL
end
end) 

//POW!!
addHook("ShouldDamage", function(target, inflictor, source, damage, damagetype)
    if target.player and target.player.valid and target.skin == "pizzano"
	and inflictor and inflictor.valid
    and ((target.player.mo.state == S_PLAY_TAUNT1)
	or (target.player.mo.state == S_PLAY_TAUNT2)
	or (target.player.mo.state == S_PLAY_TAUNT3)
	or (target.player.mo.state == S_PLAY_TAUNT4)
	or (target.player.mo.state == S_PLAY_TAUNT5)
	or (target.player.mo.state == S_PLAY_TAUNT6)
	or (target.player.mo.state == S_PLAY_TAUNT7)
	or (target.player.mo.state == S_PLAY_TAUNT8)
	or (target.player.mo.state == S_PLAY_TAUNT9))
    and (inflictor.flags & MF_ENEMY or inflictor.flags & MF_BOSS or inflictor.flags & MF_MISSILE or inflictor.flags & MF_PAIN or damagetype & DMG_SPIKE or damagetype & DMG_ELECTRIC)
		target.player.powers[pw_flashing] = 15
		P_DamageMobj(inflictor, target, target, DMG_WATER)
		target.player.score = $+500
		S_StartSound(target, sfx_parry)
		P_InstaThrust(target, target.angle, -9*FRACUNIT)
		local parryeffect = P_SpawnMobj(target.x,target.y,target.z,MT_THOK)
		parryeffect.scale = target.scale-FRACUNIT/3
		target.player.tauntbubble = nil
		target.state = P_RandomRange(S_PLAY_PARRY, S_PLAY_PARRY1, S_PLAY_PARRY2)
		return false
    end
end, MT_PLAYER)

//MACH wow!1!!!11!!
//SPIIIIIIIIIIIIIIIN
addHook("PlayerThink", function(p)
	local pmo = p.mo
	
	  if pmo.skin == "pizzano"
	  and p.speed >= 32*FRACUNIT 
	  and p.mo.state == S_PLAY_JUMP then
	  p.mo.state = S_PLAY_PZNOMACH2JUMP
	  end
end)

//SPIIIIIIIN 2.0
addHook("PlayerThink", function(p)
	local pmo = p.mo
	
	  if pmo.skin == "pizzano"
	  and p.dashmode >= 3*TICRATE 
	  and p.mo.state == S_PLAY_PZNOMACH2JUMP then
	  p.mo.state = S_PLAY_PZNOMACH3JUMP
	  end
end)

//WAHOOOOOOOOOOO WE ARE EXTREMELY FAST
addHook("PlayerThink", function(p)
	local pmo = p.mo
	
	if not ((pmo.skin == "pizzano") or (p.exiting))
		return
		    end
	if p.speed >= 60*FRACUNIT
	and not (p.pflags & PF_THOKKED)
	and not (p.pflags & PF_JUMPED)
	and p.dashmode >= 3*TICRATE then
				p.mo.state = S_PLAY_FLY
			end
	if p.mo.state == S_PLAY_FLY
	   and p.speed <= 35*FRACUNIT then
				p.mo.state = S_PLAY_STND
		end
end)

//the momentum
addHook("PlayerThink", function(player)
    if (player.cmd.forwardmove or player.cmd.sidemove)
	and ((player.mo.skin == "pizzano") or (player.exiting))
    and player.normalspeed <= player.speed then
        player.mo.friction = FRACUNIT
    else
        player.mo.friction = 29*FRACUNIT/32
    end
end)

//the mach sounds
addHook("PlayerThink", function(player)
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and ((player.mo.state == S_PLAY_DASH) or (player.mo.state == S_PLAY_FIRE) or (player.mo.state == S_PLAY_FIRE_FINISH))
		and not S_SoundPlaying(player.mo, sfx_mach3) then
		S_StartSound(player.mo, sfx_mach3)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and not ((player.mo.state == S_PLAY_DASH) or (player.mo.state == S_PLAY_FIRE) or (player.mo.state == S_PLAY_FIRE_FINISH))
		or (player.mo.state == S_PLAY_WALK)
		and S_SoundPlaying(player.mo, sfx_mach3) then
		S_StopSoundByID(player.mo, sfx_mach3)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and (player.mo.state == S_PLAY_RUN)	
		and not S_SoundPlaying(player.mo, sfx_mach2) then
		S_StartSound(player.mo, sfx_mach2)
    end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and not (player.mo.state == S_PLAY_RUN)
		or (player.mo.state == S_PLAY_WALK)
		and S_SoundPlaying(player.mo, sfx_mach2) then
		S_StopSoundByID(player.mo, sfx_mach2)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and (player.mo.state == S_PLAY_WALK)	
		and not S_SoundPlaying(player.mo, sfx_mach1) then
		S_StartSound(player.mo, sfx_mach1)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and not (player.mo.state == S_PLAY_WALK)
		and S_SoundPlaying(player.mo, sfx_mach1) then
		S_StopSoundByID(player.mo, sfx_mach1)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and (player.mo.state == S_PLAY_FLY)
		and not S_SoundPlaying(player.mo, sfx_mach4) then
		S_StartSound(player.mo, sfx_mach4)
	end
	    if ((player.mo.skin == "pizzano") or (player.exiting))
	    and not (player.mo.state == S_PLAY_FLY)
		or (player.mo.state == S_PLAY_WALK)
		and S_SoundPlaying(player.mo, sfx_mach4) then
		S_StopSoundByID(player.mo, sfx_mach4)
	end
end)

//mach 4 effects
rawset(_G, "P_CreateRing", function(p)
    
	local ring = P_SpawnMobj(p.mo.x,p.mo.y,p.mo.z,MT_THOK)
	ring.state = S_MACH4RING
	ring.fuse = 999
	ring.tics = 20
	ring.angle = p.drawangle+ANGLE_90
	ring.scale = p.mo.scale-FRACUNIT/2
	ring.destscale = p.mo.scale*2
	ring.colorized = true
	ring.color = SKINCOLOR_WHITE
	if (p.mo.eflags & MFE_VERTICALFLIP)
		ring.flags2 = $|MF2_OBJECTFLIP
		ring.eflags = $|MFE_VERTICALFLIP
	end
end)

addHook("ThinkFrame", do
	for player in players.iterate
		local mo = player.mo
		if P_IsObjectOnGround(mo)
		and ((player.mo.skin == "pizzano") or (player.exiting))
		and mo.state == S_PLAY_FLY
		and leveltime%10 == 0
			for i = -1, 1, 2
				local ang = i * ANG10
				local factor = FixedMul(4*mo.scale, cos(ang))
				local x = P_ReturnThrustX(mo, player.drawangle + ANGLE_180 + ang, 24*mo.scale)
				local y = P_ReturnThrustY(mo, player.drawangle + ANGLE_180 + ang, 24*mo.scale)
				local dust = P_SpawnMobjFromMobj(mo, x, y, 0, MT_THOK)
				dust.scale = mo.scale
				dust.angle = R_PointToAngle2(dust.x, dust.y, mo.x, mo.y)
				dust.state = S_MACH4_FIRE
				dust.momx = FixedMul(factor, cos(dust.angle - i*ANGLE_90))
				dust.momy = FixedMul(factor, sin(dust.angle - i*ANGLE_90))
			end
		end
	end
end)

addHook("ThinkFrame", do
	for p in players.iterate
		if ((p.mo.skin == "pizzano") or (p.exiting))
		and p.mo.state == S_PLAY_FLY
		and leveltime%5 == 0
			P_CreateRing(p)
		end
	end
end)

//crounch and dive
//crounch
addHook("PlayerThink", function(player)
    if player.mo.skin ~= "pizzano"
        return
    end

    if (player.cmd.buttons & BT_CUSTOM1) and P_IsObjectOnGround(player.mo) and player.speed <= 30*FRACUNIT  then
        player.height = 30*FRACUNIT
		player.mo.state = S_PLAY_CROUNCH
        player.pflags = $1|PF_STASIS
    else
        player.height = 58*FRACUNIT
    end
end)

//slide
addHook("PlayerThink", function(player)
    if player.mo.skin ~= "pizzano"
        return
    end

    if (player.cmd.buttons & BT_CUSTOM1) and P_IsObjectOnGround(player.mo) and player.speed >= 30*FRACUNIT then
        player.height = 30*FRACUNIT
		player.mo.state = S_PLAY_SLIDE
    else
        player.height = 58*FRACUNIT
    end
end)

addHook("PlayerThink", function(player)
    if player.mo.skin ~= "pizzano"
        return
    end

    if not (player.cmd.buttons & BT_CUSTOM1) and P_IsObjectOnGround(player.mo) and player.speed >= 30*FRACUNIT and player.mo.state == S_PLAY_SLIDE then
		player.mo.state = S_PLAY_STND
		end
end)

//"dive"
addHook("PlayerThink", function(player)
    if player.mo.skin ~= "pizzano"
        return
    end
	
      if (player.cmd.buttons & BT_CUSTOM1) 
		and player.speed >= 32*FRACUNIT
		and not P_IsObjectOnGround(player.mo)
		and player.mo.state == S_PLAY_PZNOMACH2JUMP then
					P_SetObjectMomZ(player.realmo, -17*FRACUNIT, false)
					player.mo.state = S_PLAY_PZNOMACH2JUMPDIVE
					end
	 if (player.cmd.buttons & BT_CUSTOM1) 
		and player.speed >= 32*FRACUNIT
		and not P_IsObjectOnGround(player.mo)
		and player.mo.state == S_PLAY_PZNOMACH3JUMP then
					P_SetObjectMomZ(player.realmo, -17*FRACUNIT, false)
					player.mo.state = S_PLAY_PZNOMACH3JUMPDIVE
					end
	 if (player.cmd.buttons & BT_CUSTOM1) 
		and not P_IsObjectOnGround(player.mo)
		and player.mo.state == S_PLAY_SLIDE then
					P_SetObjectMomZ(player.realmo, -20*FRACUNIT, false)
					player.mo.state = S_PLAY_DIVE
					end
	 if (player.cmd.buttons & BT_CUSTOM1) 
		and not P_IsObjectOnGround(player.mo)
		and player.mo.state == S_PLAY_RUN then
					P_SetObjectMomZ(player.realmo, -20*FRACUNIT, false)
					player.mo.state = S_PLAY_DIVE
					end
	 if (player.cmd.buttons & BT_CUSTOM1) 
		and not P_IsObjectOnGround(player.mo)
		and player.mo.state == S_PLAY_DASH then
					P_SetObjectMomZ(player.realmo, -20*FRACUNIT, false)
					player.mo.state = S_PLAY_DIVE
					end
	 if (player.cmd.buttons & BT_CUSTOM1) 
	 	and not P_IsObjectOnGround(player.mo)
		and player.mo.state == S_PLAY_FLY then
					P_SetObjectMomZ(player.realmo, -20*FRACUNIT, false)
					player.mo.state = S_PLAY_DIVE
					end
end)

//YOOOOOOOOOO jump animation!
addHook("PlayerThink", do
	    for player in players.iterate do
		if ((player.mo.skin == "pizzano") or (player.exiting))
		and player.mo.state == S_PLAY_JUMP then 
			player.mo.state = S_PLAY_JUMPINITIAL
		end
	end
end)

// PANIC!!!
addHook("PlayerThink", function(p)
      local pmo = p.mo

  if not ((pmo.skin == "pizzano") or (p.exiting))
		return
		end
  if p.mo.state == S_PLAY_STND
	and (PTSR and PTSR.pizzatime)
		or (PizzaTime and PizzaTime.sync and PizzaTime.sync.PizzaTime) then
				p.mo.state = S_PLAY_PANIC
				end 
				
  if p.mo.state == S_PLAY_PANIC
	   and p.speed >= 1*FRACUNIT then
				p.mo.state = S_PLAY_STND
	end
end)

//double jump animation
addHook("PlayerThink", do
	    for player in players.iterate do
		if player.mo and player.mo.skin == "pizzano"
		and not player.powers [pw_shield]
		and player.cmd.buttons & BT_JUMP
		and not ((player.mo.state == S_PLAY_PZNOMACH2JUMPDIVE) or (player.mo.state == S_PLAY_BODYSLAMLAND) or (player.mo.state == S_PLAY_BODYSLAM_INITIAL) or (player.mo.state == S_PLAY_BODYSLAM_FINAL) or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE))
		and not P_IsObjectOnGround(player.mo)
		and player.charability == CA_DOUBLEJUMP
		and not player.pstomp == true
		and (player.pflags & PF_THOKKED) then 
			player.mo.state = S_PLAY_ROLL
		end
	end
end)

//he likes the blue licore
addHook("MusicChange", function(oldname, newname, mflags, looping, position, prefadems, fadeinms)
	if splitscreen
		return
	end
	if not (consoleplayer and consoleplayer.valid)
		return
		end
	local snikmus = skins[consoleplayer.skin].name
	if snikmus == "pizzano"
		if newname == "PIZTIM"
			newname = "LP1NO"
		elseif newname == "DEAOLI"
			newname = "LP2NO"
		elseif newname == "PIJORE" or newname == "LAP3LO"
			newname = "LP3NO"
		elseif newname == "GLUWAY"
			newname = "LP4NO"
		elseif newname == "EXTREM"
			newname = "LP4NO"
		end
		return newname, mflags, looping, position, prefadems, fadeinms
	end
end)

//dance (SUS)
addHook("PlayerThink", function(player)
    if player.mo.skin ~= "pizzano"
        return
    end

    if (player.cmd.buttons & BT_FIRENORMAL) and P_IsObjectOnGround(player.mo) 
	and player.speed <= 17*FRACUNIT then
		player.mo.state = S_PLAY_DANCE
        player.pflags = $1|PF_JUMPSTASIS
    end
end)

//taunts
addHook("ThinkFrame", function()
        for player in players.iterate do
        if ((player.mo.skin == "pizzano") or (player.exiting)) and (player.cmd.buttons & BT_TOSSFLAG) and not ((player.mo.state == S_PLAY_FIRE) or (player.mo.state == S_PLAY_FIRE_FINISH) or (player.mo.state == S_PLAY_ROLL) or (player.mo.state == S_PLAY_AIRKUNGFU1) or (player.mo.state == S_PLAY_AIRKUNGFU2))
				player.pflags = PF_THOKKED
				if player.tossdelay == 0
					player.randomtaunt = P_RandomRange(1, 9)
					if player.randomtaunt == 1
						player.mo.state = S_PLAY_TAUNT1
						S_StartSound(player.mo, sfx_tant1)
						player.tossdelay = 20
					elseif player.randomtaunt == 2
						player.mo.state = S_PLAY_TAUNT2
						S_StartSound(player.mo, sfx_tant2)
						player.tossdelay = 20
					elseif player.randomtaunt == 3
						player.mo.state = S_PLAY_TAUNT3
						S_StartSound(player.mo, sfx_tant3)
						player.tossdelay = 20
					elseif player.randomtaunt == 4
						player.mo.state = S_PLAY_TAUNT4
						S_StartSound(player.mo, sfx_chadt)
						player.tossdelay = 20
					elseif player.randomtaunt == 5
						player.mo.state = S_PLAY_TAUNT5
						S_StartSound(player.mo, sfx_tant4)
						player.tossdelay = 20
					elseif player.randomtaunt == 6
						player.mo.state = S_PLAY_TAUNT6
						S_StartSound(player.mo, sfx_tant5)
						player.tossdelay = 20
					elseif player.randomtaunt == 7
						player.mo.state = S_PLAY_TAUNT7
						S_StartSound(player.mo, sfx_tant6)
						player.tossdelay = 20
					elseif player.randomtaunt == 8
						player.mo.state = S_PLAY_TAUNT8
						S_StartSound(player.mo, sfx_tant7)
						player.tossdelay = 20
					elseif player.randomtaunt == 9
						player.mo.state = S_PLAY_TAUNT9
						S_StartSound(player.mo, sfx_tant8)
						player.tossdelay = 20
				end
			end
		end
	end
end)

//fly
addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.dashmode >= 3*TICRATE
and player.charability == CA_DOUBLEJUMP 
and not ((player.mo.state == S_PLAY_PZNOMACH2JUMPDIVE) or (player.mo.state == S_PLAY_BODYSLAM_INITIAL) or (player.mo.state == S_PLAY_BODYSLAMLAND) or (player.mo.state == S_PLAY_BODYSLAM_FINAL) or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE))
and not P_IsObjectOnGround(player.mo) then
   player.charability = CA_FLOAT
     end

if player.mo and player.mo.skin == "pizzano"
and not P_IsObjectOnGround(player.mo)
and player.speed <= 36*FRACUNIT 
and not ((player.mo.state == S_PLAY_PZNOMACH2JUMPDIVE) or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE))
and player.charability == CA_FLOAT then
   player.charability = CA_DOUBLEJUMP
     end
 end)

addHook("PlayerThink", do
	    for player in players.iterate do
		if player.mo and player.mo.skin == "pizzano"
		and player.cmd.buttons & BT_JUMP
		and not P_IsObjectOnGround(player.mo)
		and not ((player.mo.state == S_PLAY_PZNOMACH2JUMPDIVE) or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE) or (player.mo.state == S_PLAY_FALL))
		and player.charability == CA_FLOAT
		and (player.pflags & PF_THOKKED) then 
			player.mo.state = S_PLAY_FIRE
		end
	end
end)

 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and ((player.mo.state == S_PLAY_FIRE) or (player.mo.state == S_PLAY_FIRE_FINISH))
and (player.cmd.buttons & BT_CUSTOM3) then
   P_SetObjectMomZ(player.realmo, 7*FRACUNIT, false)
end
end)

addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and ((player.mo.state == S_PLAY_FIRE) or (player.mo.state == S_PLAY_FIRE_FINISH))
and not (player.mo.eflags & MFE_UNDERWATER)
and (player.cmd.buttons & BT_CUSTOM2) then
   P_SetObjectMomZ(player.realmo, -7*FRACUNIT, false)
end
end)

//SUPER JUMP: this is perfect -Pizzano
 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.dashmode >= 3*TICRATE
and (player.cmd.buttons & BT_CUSTOM3)
and  P_IsObjectOnGround(player.mo) then
   player.mo.state = S_PLAY_SUPERJUMP_PREPARE
   P_InstaThrust(player.mo, player.mo.angle, 0*FRACUNIT)
   P_Thrust(player.mo, player.mo.angle, 0*FRACUNIT)
end
end)


 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano" 
and player.mo.state == S_PLAY_SUPERJUMP_PREPARE then
   player.pflags = $|PF_STASIS
end
end)

 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano" 
and player.mo.state == S_PLAY_SUPERJUMP_RELEASE then
   P_SetObjectMomZ(player.realmo, 45*FRACUNIT, false)
end
end) 

addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.mo.state == S_PLAY_SUPERJUMP_PREPARE
and not(player.cmd.buttons & BT_CUSTOM3) then
   player.mo.state = S_PLAY_SUPERJUMP_RELEASE
end
end)

rawset(_G, "CheckCel", function(player, dist)
	local cel = player.mo.ceilingz
	local celcheck = player.mo.z >= (cel - (player.mo.height+dist))
	if P_MobjFlip(player.mo) == 1
		cel = player.mo.ceilingz
		celcheck = player.mo.z >= (cel - (player.mo.height+dist))
	else
		cel = player.mo.floorz
		celcheck = player.mo.z+player.mo.height <= (cel + (player.mo.height+dist))
	end
	if celcheck
		return true
	else
		return false
	end
end)

addHook("PlayerThink", function(p)
	if p.celhit == nil
		p.celhit = false
	end
	if p.mo.state == S_PLAY_SUPERJUMP_RELEASE
	and CheckCel(p, FRACUNIT)
		p.celhit = true
		p.mo.state = S_PLAY_FALL
	end
end)

 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano" 
and player.mo.state == S_PLAY_SUPERJUMP_RELEASE
and (player.cmd.buttons & BT_SPIN) then
   P_SetObjectMomZ(player.realmo, 0*FRACUNIT, false)
   P_Thrust(player.mo, player.mo.angle, 11*FRACUNIT)
   player.mo.state = S_PLAY_SUPERJUMP_PREPARESIDE
end
end) 

 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano" 
and player.mo.state == S_PLAY_SUPERJUMP_SIDE then
   P_SetObjectMomZ(player.realmo, 0*FRACUNIT, false)
   P_InstaThrust(player.mo, player.mo.angle, 23*FRACUNIT)
   P_Thrust(player.mo, player.mo.angle, 23*FRACUNIT)
end
end) 

 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano" 
and player.mo.state == S_PLAY_SUPERJUMP_SIDE
player.pflags = PF_THOKKED
end
end)

 addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.mo.state == S_PLAY_SUPERJUMP_SIDE
and (player.cmd.buttons & BT_CUSTOM3) then
   P_SetObjectMomZ(player.realmo, 7*FRACUNIT, false)
end
end)

addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.mo.state == S_PLAY_SUPERJUMP_SIDE
and (player.cmd.buttons & BT_CUSTOM2) then
   P_SetObjectMomZ(player.realmo, -7*FRACUNIT, false)
end
end)

addHook("PlayerThink",function(player)
if player.mo and player.mo.skin == "pizzano"
and player.mo.state == S_PLAY_SUPERJUMP_SIDE
and (player.cmd.buttons & BT_SPIN) then
    player.pstomp = true
	P_Thrust(player.mo,player.mo.angle, -30*FU)
	player.mo.state = S_PLAY_BODYSLAM_INITIAL
end
end)

//after images B)
freeslot("SKINCOLOR_AFTERIMAGEPINK","SKINCOLOR_AFTERIMAGECYAN")

skincolors[SKINCOLOR_AFTERIMAGEPINK] = {
    name = "After Image Pink",
    ramp = {202,202,202,202,202,202,202,202,202,202,202,204,204,204,204,204},
    invcolor = SKINCOLOR_AFTERIMAGECYAN,
    invshade = 9,
    chatcolor = V_REDMAP,
    accessible = false
}

skincolors[SKINCOLOR_AFTERIMAGECYAN] = {
    name = "After Image Cyan",
    ramp = {134,134,134,134,134,134,134,134,134,134,134,136,136,136,136,136},
    invcolor = SKINCOLOR_AFTERIMAGEPINK,
    invshade = 9,
    chatcolor = V_GREENMAP,
    accessible = false
}

local function createafterimage(p)
	local afti = P_SpawnGhostMobj(p.mo)
	afti.colorized = true
	afti.fuse = 999
	afti.tics = 5
	afti.frame = TR_TRANS10|p.mo.frame|FF_FULLBRIGHT
	afti.color = P_RandomRange(SKINCOLOR_AFTERIMAGECYAN,SKINCOLOR_AFTERIMAGEPINK)
	afti.scale = p.mo.scale
end

local function momz(p)
	if not (p.mo.eflags & MFE_VERTICALFLIP)
	and p.mo.momz < 0
	or (p.mo.eflags & MFE_VERTICALFLIP)
	and p.mo.momz > 0
		return true
	else
		return false
	end
end

addHook("PlayerThink", function(player)
	if player.playerstate == PST_DEAD return end
	
	if  player.mo and player.mo.skin == "pizzano"
	and ((player.mo.state == S_PLAY_PZNOMACH2JUMPDIVE) or (player.mo.state == S_PLAY_PZNOMACH3JUMPDIVE) or (player.mo.state == S_PLAY_SUPERJUMP_RELEASE) or (player.mo.state == S_PLAY_DASH) or (player.mo.state == S_PLAY_FLY)
	or (player.mo.state == S_PLAY_SUPERJUMP_SIDE)
	or (player.mo.state == S_PLAY_KUNGFU1) or (player.mo.state == S_PLAY_KUNGFU2) or (player.mo.state == S_PLAY_KUNGFU3) or (player.mo.state == S_PLAY_KUNGFU4) or (player.mo.state == S_PLAY_KUNGFU5) or (player.mo.state == S_PLAY_BODYSLAM_FINAL) or (player.mo.state == S_PLAY_KUNGFU6) or (player.mo.state == S_PLAY_RUN) or (player.mo.state == S_PLAY_PZNOMACH3JUMP) or (player.mo.state == S_PLAY_PZNOMACH2JUMP)
	or (player.mo.state == S_PLAY_FIRE) or (player.mo.state == S_PLAY_FIRE_FINISH) or (player.mo.state == S_PLAY_AIRKUNGFU1) or (player.mo.state == S_PLAY_AIRKUNGFU2))
		createafterimage(player)
	end
end)

//"wall check" of the superjump
addHook("PlayerThink", function(p)
		if  p.mo and p.mo.skin == "pizzano"
		and p.speed <= 10*FRACUNIT
	    and p.mo.state == S_PLAY_SUPERJUMP_SIDE then
  p.mo.state = S_PLAY_FALL
	end
end)

//chainsaw(idk)
addHook("PlayerThink", function(player)
		if  player.mo and player.mo.skin == "pizzano"
        and player.speed <= 69*FRACUNIT
		and P_IsObjectOnGround(player.mo)
		and (player.cmd.buttons & BT_CUSTOM2)
		and ((player.mo.state == S_PLAY_KUNGFU1) or (player.mo.state == S_PLAY_KUNGFU2) or (player.mo.state == S_PLAY_KUNGFU3) or (player.mo.state == S_PLAY_KUNGFU4) or (player.mo.state == S_PLAY_KUNGFU5) or (player.mo.state == S_PLAY_KUNGFU6))
			player.mo.state = S_PLAY_CHAINSAW
			S_StartSound(player.mo, sfx_chain)
			P_Thrust(player.mo, player.mo.angle, 20*FRACUNIT)
		end
end)