//taunt, original from proper peppino´s mod (tgtls)
addHook("MobjSpawn", function(mo)
    mo.tauntTimer2 = 0
end, MT_PLAYER)

//made by clairbun
local function L_Choose(...)
	local args = {...}
	local choice = P_RandomRange(1,#args)
	return args[choice]
end

addHook("PlayerThink", function(player)
    if player.pizzanoreal
	and (player.cmd.buttons & BT_TOSSFLAG) then
		player.mo.tauntTimer = $+1
	else
		player.mo.tauntTimer = 0
	end
	local mo = player.mo
	if player.pizzanoreal and player.mo.tauntTimer == 1
	and not ((player.mo.state == S_PLAY_SUPERJUMP_SIDE) or (player.mo.state == S_PLAY_BODYSLAM_INITIAL) 
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_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_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))  then
		if not player.mo.taunting then
			player.mo.taunting = true
			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
		if not ((player.mo.state == S_PLAY_SUPERTAUNT_1) or (player.mo.state == S_PLAY_SUPERTAUNT_2)  or (player.mo.state == S_PLAY_SUPERTAUNT_3)) 
		mo.state = mo.tauntstate
		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]
			mo.state = player.mo.prevState
			player.pflags = player.mo.lastPFlags
			player.mo.taunting = false
			player.mo.tauntTimer2 = 0
			player.mo.tauntingState = nil
		end
	end
end)

addHook("PlayerThink", function(player)
	if player.pizzanoreal and not player.mo.taunting 
	 and not ((player.mo.state == S_PLAY_PARRY2)
	 or (player.mo.state == S_PLAY_PARRY1)
	 or (player.mo.state == S_PLAY_PARRY)) then
		player.mo.tauntstate = L_Choose(
		S_PLAY_TAUNT1,
		S_PLAY_TAUNT2,
		S_PLAY_TAUNT3,
		S_PLAY_TAUNT4,
		S_PLAY_TAUNT5,
		S_PLAY_TAUNT6,
		S_PLAY_TAUNT7,
		S_PLAY_TAUNT8,
		S_PLAY_TAUNT9)
	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)
	or (player.mo.state == S_PLAY_TAUNT2)
	or (player.mo.state == S_PLAY_TAUNT3)
	or (player.mo.state == S_PLAY_TAUNT4)
	or (player.mo.state == S_PLAY_TAUNT5)
	or (player.mo.state == S_PLAY_TAUNT6)
	or (player.mo.state == S_PLAY_TAUNT7)
	or (player.mo.state == S_PLAY_TAUNT8)
	or (player.mo.state == S_PLAY_TAUNT9))
	and (target.flags & MF_ENEMY)
	    S_StartSound(player.mo, sfx_parry)
		player.taunting = false
		player.tauntTimer2 = 0
		player.tauntingState = nil
        P_InstaThrust(player.mo, player.drawangle, -9*FRACUNIT)
		player.mo.state = 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)
	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_BOSS or inflictor.flags & MF_MISSILE or inflictor.flags & MF_PAIN or damagetype & DMG_SPIKE or damagetype & DMG_ELECTRIC)
		target.player.powers[pw_flashing] = 25
		target.player.taunting = false
		target.player.tauntingtimer = 0
		target.player.score = $+300
		S_StartSound(target, sfx_parry)
		P_InstaThrust(target, target.angle - inflictor.angle, -9*FRACUNIT)
		target.state = L_Choose(S_PLAY_PARRY1, S_PLAY_PARRY2, S_PLAY_PARRY)
		return false
	end
end, MT_PLAYER)

//breakdance (sussy dance(idk))
addHook("PlayerThink", function(player)
    if player.pizzanoreal
    and (player.cmd.buttons & BT_TOSSFLAG) 
	and not ((player.mo.state == S_PLAY_PARRY1) or (player.mo.state == S_PLAY_PARRY2)  or (player.mo.state == S_PLAY_PARRY)) 
	and P_IsObjectOnGround(player.mo)
	and player.normalspeed == FRACUNIT*20 
	and player.mo.tauntTimer2 <= 1 then
		player.mo.state = S_PLAY_DANCE
        player.pflags = $1|PF_JUMPSTASIS
    end
	if player.pizzanoreal
    and not (player.cmd.buttons & BT_TOSSFLAG) 
	and P_IsObjectOnGround(player.mo)
	and player.mo.state == S_PLAY_DANCE then
		player.mo.state = S_PLAY_STND
	end
end)

//super taunt :0
addHook("ThinkFrame", function()
     for player in players.iterate do
	  if player.pizzanoreal
and ((player.powers[pw_shield] == SH_ARMAGEDDON) or (player.powers[pw_shield] == SH_THUNDERCOIN) or (player.powers[pw_shield] == SH_ATTRACT) or (player.powers[pw_shield] == SH_FLAMEAURA) or (player.powers[pw_shield] == SH_WHIRLWIND) or (player.powers[pw_shield] == SH_BUBBLEWRAP) or (player.powers[pw_shield] == SH_ELEMENTAL))
and (player.cmd.buttons & BT_TOSSFLAG)
and (player.cmd.buttons & BT_CUSTOM3)

S_StartSound(player.mo, sfx_sptnt)
P_StartQuake(FRACUNIT*11, TICRATE/4*2)
P_NukeEnemies(player.mo, player.mo, 2700*FRACUNIT)
player.powers[pw_shield] = SH_NONE
player.mo.state = P_RandomRange(S_PLAY_SUPERTAUNT_1, S_PLAY_SUPERTAUNT_3, S_PLAY_SUPERTAUNT_2)
end
end
end)
