//taunt
freeslot("MT_TAUNT","S_TAUNT","SPR_TANT")
states[S_TAUNT] = {SPR_TANT, FF_SEMIBRIGHT|FF_ANIMATE|A, 18, nil, 9, 2, S_NULL}

mobjinfo[MT_TAUNT] = {
	spawnstate = S_TAUNT,
	height = 64*FRACUNIT,
    flags = MF_NOCLIP|MF_NOGRAVITY|MF_NOCLIPHEIGHT|MF_SCENERY,
	spawnHealth = 1000,
    reactionTime = TICRATE,
    speed = 0,
    dispoffset = -50,
    radius = 32*FRACUNIT
}

local function removebubble(mo)
	if mo and mo.valid
		P_RemoveMobj(mo)
	end
end

addHook("MobjSpawn", function(mo)
    mo.tauntTimer2 = 0
end, MT_PLAYER)

addHook("PlayerSpawn", function(p)
	p.tauntbubble = nil
end)

addHook("PlayerThink", function(player)
	local mo = player.mo
	if player.pizzanoreal and player.mo.toosftimr == 1
	and player.playerstate == PST_LIVE
	and not ((player.mo.state == S_PLAY_SUPERJUMP_SIDE) or (player.mo.state == S_PLAY_BODYSLAM_INITIAL) 
or (player.mo.state == S_PLAY_MACH5PZNO) or (player.mo.state == S_PLAY_SUPERJUMP_PREPARESIDE) or (player.mo.state == S_PLAY_SUPERJUMP_RELEASE) or (player.mo.state == S_PLAY_BODYSLAM_FINAL) or (player.mo.state == S_PLAY_FIRE_FINISH)
or (player.mo.state == S_PLAY_BODYSLAMLAND) or (player.mo.state == S_PLAY_AIRKUNGFU1) or (player.mo.state == S_PLAY_AIRKUNGFU2) or (player.mo.state == S_PLAY_CHAINSAW)
or (player.mo.state == S_PLAY_KUNGFU1)
or (player.mo.state == S_PLAY_PAIN)
or (player.mo.state == S_PLAY_DEAD)
or (player.mo.state == S_PLAY_DIVE)
or (player.mo.state == S_PLAY_WALLCRASSH)
or (player.mo.state == S_PLAY_SLIDE)
or (player.mo.state == S_PLAY_AIRKUNGFU3)
or (player.mo.state == S_PLAY_AIRKUNGFU1_FINAL)
or (player.mo.state == S_PLAY_AIRKUNGFU2_FINAL)
or (player.mo.state == S_PLAY_AIRKUNGFU3_FINAL)
or (player.mo.state == S_PLAY_STUNTT)
or (player.mo.state == S_PLAY_KUNGFU2)
or (player.mo.state == S_PLAY_ROLL)
or (player.mo.state == S_PLAY_PARRY)
or (player.mo.state == S_PLAY_SKID)
or (player.mo.state == S_PLAY_CROUNCH_MOVE)
or (player.mo.state == S_PLAY_CROUNCH_AIR)
or (player.mo.state == S_PLAY_CROUNCH)
or (player.mo.state == S_PLAY_WALLCLIMBB)
or (player.mo.state == S_PZNO_FIREASS) or (player.mo.state == S_PZNO_FIREASS_LAND)
or (player.mo.state == S_PLAY_SKID_STOP)
or (player.mo.state == S_PLAY_PZNO_REDIRECT)
or (player.mo.state == S_PLAY_PARRY2)
or (player.mo.state == S_PLAY_PARRY1)
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_FIRE))  then
		if not player.mo.taunting then
			player.mo.taunting = true
			player.mo.prevSpeeed = player.speed
			player.mo.prevState = mo.state
			player.mo.prevMoms = {mo.momx, mo.momy, mo.momz}
			player.mo.lastPFlags = player.pflags
			player.randomtauntsound = P_RandomRange(1, 8)
			if player.randomtauntsound == 1
						S_StartSoundAtVolume(player.mo, sfx_tant1,255)
					elseif player.randomtauntsound == 2
					S_StartSoundAtVolume(player.mo, sfx_tant2,255)
					elseif player.randomtauntsound == 3
					S_StartSoundAtVolume(player.mo, sfx_tant3,255)
					elseif player.randomtauntsound == 4
					S_StartSoundAtVolume(player.mo, sfx_tant4,255)
					elseif player.randomtauntsound == 5
					S_StartSoundAtVolume(player.mo, sfx_tant6,255)
					elseif player.randomtauntsound == 6
					S_StartSoundAtVolume(player.mo, sfx_tant5,255)
					elseif player.randomtauntsound == 7
					S_StartSoundAtVolume(player.mo, sfx_tant7,255)
					elseif player.randomtauntsound == 8
					S_StartSoundAtVolume(player.mo, sfx_tant8,255)
			end
			end
			end
	if player.mo.taunting
	    player.mo.tauntTimer2 = $+1
		mo.momx = 0
		mo.momy = 0
		mo.momz = 0
		player.pflags = $|PF_FULLSTASIS
		if not player.tauntbubble
				player.tauntbubble = P_SpawnMobj(player.mo.x,player.mo.y,player.mo.z,MT_TAUNT)
				player.tauntbubble.scale = player.mo.scale+FRACUNIT/4
				player.tauntbubble.target = player.mo
			end
		if player.tauntbubble and player.tauntbubble.valid
				player.tauntbubble.target = player.mo
				P_SetOrigin(player.tauntbubble,player.mo.x,player.mo.y,player.mo.z)
		end
		    if not ((player.mo.state == S_PLAY_SUPERTAUNT_4) or (player.mo.state == S_PLAY_SUPERTAUNT_1) or (player.mo.state == S_PLAY_PARRY2) or (player.mo.state == S_PLAY_PARRY) or (player.mo.state == S_PLAY_PARRY1) or (player.mo.state == S_PLAY_TAUNT1) or (player.mo.state == S_PLAY_SUPERTAUNT_2)  or (player.mo.state == S_PLAY_SUPERTAUNT_3)) 
		    player.mo.state = S_PLAY_TAUNT1
			player.mo.frame = P_RandomRange(A, skins[player.mo.skin].sprites[SPR2_TAU1].numframes-1)
			player.tframe = player.mo.frame
		end
			if player.mo.tauntTimer2 >= 14 then
			mo.momx = player.mo.prevMoms[1]
			mo.momy = player.mo.prevMoms[2]
			mo.momz = player.mo.prevMoms[3]
			removebubble(player.tauntbubble)
			player.tauntbubble = nil
			player.pflags = player.mo.lastPFlags
			player.pflags = $ & ~PF_FULLSTASIS
		end
		    if player.mo.tauntTimer2 >= 15 then
			mo.state = player.mo.prevState
			player.mo.taunting = false
			player.mo.tauntTimer2 = 0
			player.mo.tauntingState = nil
			player.fixingsomething = false
		end
	end
end)

//POW!! by me
addHook("PlayerCanDamage", function(player,target)
	 if player.pizzanoreal
	 and target and target.valid
	 and ((player.mo.state == S_PLAY_TAUNT1))
	and (target.flags & MF_ENEMY)
	    S_StartSound(player.mo, sfx_parry)
		player.mo.tauntTimer2 = 15
		player.powers[pw_flashing] = 50
		player.tauntingState = nil
        P_InstaThrust(player.mo, player.drawangle, -9*FRACUNIT)
		player.mo.prevState = P_RandomRange(S_PLAY_PARRY, S_PLAY_PARRY1, S_PLAY_PARRY2)
        local fling = P_SpawnMobjFromMobj(target, 0, 0, 0, MT_ENEMY_FLYING)
     	if fling and fling.valid
    	target.tics = -1
		fling.sprite = target.sprite 
		fling.sprite2 = target.sprite2 
		fling.frame = target.frame
		fling.angle = target.angle
		fling.color = target.color
		fling.info.deathstate = S_CYBRAKDEMONVILEEXPLOSION1 
		fling.nokilltimer = 3
		fling.info.deathsound = sfx_s3kb4
		S_StopSound(target)
		P_SetObjectMomZ(fling, 15*FRACUNIT, false)
		P_InstaThrust(fling, target.angle, 100*FRACUNIT)
        end
	return true
end
end)

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))
    and (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] = 50
		target.player.mo.prevState = P_RandomRange(S_PLAY_PARRY, S_PLAY_PARRY1, S_PLAY_PARRY2)
		target.player.score = $+300
		S_StartSound(target, sfx_parry)
		P_InstaThrust(target, target.angle - inflictor.angle, -15*FRACUNIT)
		target.player.mo.tauntTimer2 = 15
		return false
	end
end, MT_PLAYER)

//breakdance
addHook("PlayerThink", function(player)
	if player.pre_breakdancetimer == nil
			player.pre_breakdancetimer = 0
		end
	if player.breakdance == nil
			player.breakdance = false
		end
    if player.pizzanoreal
	and not ((player.mo.state == S_PLAY_PARRY1) or (player.mo.state == S_PLAY_PARRY2) or (player.mo.state == S_PLAY_TAUNT1) or (player.mo.state == S_PLAY_PARRY)) 
	and P_IsObjectOnGround(player.mo)
	and player.playerstate == PST_LIVE
	and player.normalspeed == FRACUNIT*20 
	and player.mo.tauntTimer2 <= 1
	and player.machxdtimerr <= 2
	and player.breakdance == false
	    if (player.cmd.buttons & BT_TOSSFLAG) 
		      player.pre_breakdancetimer = $+1
			  player.mo.state = S_PLAY_PREDANCE
			  else
			  player.pre_breakdancetimer = 0
	    end
	end
	if player.pre_breakdancetimer >=1
	and not player.breakdance
         player.pflags = $1|PF_JUMPSTASIS
	end
	if player.pre_breakdancetimer >= 22
	and player.breakdance == false
		 player.pre_breakdancetimer = 0
		 S_StartSound(target, sfx_breakd)
		 player.breakdance = true
	end
	if player.pizzanoreal
    and not (player.cmd.buttons & BT_TOSSFLAG) 
	and P_IsObjectOnGround(player.mo)
	and ((player.mo.state == S_PLAY_DANCE)
	or (player.mo.state == S_PLAY_DANCE2)
	or (player.mo.state == S_PLAY_DANCE4)
	or (player.mo.state == S_PLAY_PREDANCE)
    or (player.mo.state == S_PLAY_DANCE3)) then
		player.mo.state = S_PLAY_STND
		player.breakdance = false
		player.pre_breakdancetimer = 0
	end
	if player.pizzanoreal
    and not (player.cmd.buttons & BT_TOSSFLAG) 
	and P_IsObjectOnGround(player.mo)
	and player.breakdance
		player.breakdance = false
		player.pre_breakdancetimer = 0
	end
end)

//super taunt, crtl+c,crtl+v of normal taunt
addHook("ThinkFrame", do
	for player in players.iterate
		if player.pznosupertaunt == nil
			player.pznosupertaunt = false
		end
		if player.mo and player.mo.valid
		and player.pizzanoreal
		and player.playerstate == PST_LIVE
		and player.tosspressed == 1
		and player.pznosupertauntcounter >= 10
		and (player.cmd.buttons & BT_CUSTOM3)
		and not ((player.mo.state == S_PLAY_SUPERJUMP_SIDE) or (player.mo.state == S_PLAY_BODYSLAM_INITIAL) 
or (player.mo.state == S_PLAY_MACH5PZNO) or (player.mo.state == S_PLAY_SUPERJUMP_PREPARESIDE) or (player.mo.state == S_PLAY_SUPERJUMP_RELEASE) or (player.mo.state == S_PLAY_BODYSLAM_FINAL) or (player.mo.state == S_PLAY_FIRE_FINISH)
or (player.mo.state == S_PLAY_BODYSLAMLAND) or (player.mo.state == S_PLAY_AIRKUNGFU1) or (player.mo.state == S_PLAY_AIRKUNGFU2) or (player.mo.state == S_PLAY_CHAINSAW)
or (player.mo.state == S_PLAY_KUNGFU1)
or (player.mo.state == S_PLAY_DIVE)
or (player.mo.state == S_PLAY_AIRKUNGFU3)
or (player.mo.state == S_PLAY_AIRKUNGFU1_FINAL)
or (player.mo.state == S_PLAY_AIRKUNGFU2_FINAL)
or (player.mo.state == S_PLAY_AIRKUNGFU3_FINAL)
or (player.mo.state == S_PZNO_FIREASS) or (player.mo.state == S_PZNO_FIREASS_LAND)
or (player.mo.state == S_PLAY_WALLCRASSH)
or (player.mo.state == S_PLAY_SLIDE)
or (player.mo.state == S_PLAY_STUNTT)
or (player.mo.state == S_PLAY_KUNGFU2)
or (player.mo.state == S_PLAY_PARRY)
or (player.mo.state == S_PLAY_ROLL)
or (player.mo.state == S_PLAY_SKID)
or (player.mo.state == S_PLAY_CROUNCH_MOVE)
or (player.mo.state == S_PLAY_CROUNCH_AIR)
or (player.mo.state == S_PLAY_CROUNCH)
or (player.mo.state == S_PLAY_WALLCLIMBB)
or (player.mo.state == S_PLAY_SKID_STOP)
or (player.mo.state == S_PLAY_PZNO_REDIRECT)
or (player.mo.state == S_PLAY_PARRY2)
or (player.mo.state == S_PLAY_PARRY1)
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_FIRE))
			player.pznosupertaunt = true
			S_StartSound(player.mo, sfx_sptnt)
			P_NukeEnemies(player.mo, player.mo, 2700*FRACUNIT)
			player.pznosupertauntcounter = 0
			player.stsound = true
            player.randomtauntsound = P_RandomRange(1, 4)
			if player.randomtauntsound == 1
					player.mo.state = S_PLAY_SUPERTAUNT_1
			elseif player.randomtauntsound == 2
			        player.mo.state = S_PLAY_SUPERTAUNT_2
			elseif player.randomtauntsound == 3
			        player.mo.state = S_PLAY_SUPERTAUNT_3
			elseif player.randomtauntsound == 4
			        player.mo.state = S_PLAY_SUPERTAUNT_4
			end
		end
		if ((player.mo.state == S_PLAY_SUPERTAUNT_1)
        or (player.mo.state == S_PLAY_SUPERTAUNT_2)
        or (player.mo.state == S_PLAY_SUPERTAUNT_3)
		or (player.mo.state == S_PLAY_SUPERTAUNT_4))
		and player.mo.tauntTimer2 >= 12
		player.mo.tauntTimer2 = 12
		end
		
		if player.mo and player.mo.valid
		and player.pizzanoreal
		and player.playerstate == PST_LIVE
		and player.pznosupertauntcounter == 10
		and player.stsound == false
		and not S_SoundPlaying(player.mo, sfx_stpre) then
		S_StartSound(player.mo, sfx_stpre)
	    player.stsound = true
		end
	end
end)

//bad intent to do a super taunt counter idk, but it works
addHook("ThinkFrame", function()
    for player in players.iterate do
	    if player.pznosupertauntcounter == nil
		player.pznosupertauntcounter = 0
			end
		end
end)

addHook ("ShouldDamage",function(target, inflictor, source, damage, damagetype)
if inflictor and inflictor.player
and inflictor.player.pizzanoreal
and (target.flags & MF_ENEMY)
and not (target.flags & MF_BOSS)
inflictor.player.pznosupertauntcounter = $+1
end
end)
