addHook ("ShouldDamage",function(target, inflictor, source, damage, damagetype)
if inflictor and inflictor.player
and inflictor.player.pizzanoreal
and inflictor.player.DoingKungfu == false
and (target.flags & MF_ENEMY)
and not (target.flags & MF_BOSS)
and not (damagetype & DMG_NUKE)
and not (damagetype & DMG_FIRE)
and inflictor.player.machxdtimerr <= 160
and ((inflictor.state == S_PLAY_JUMPINITIAL)
or (inflictor.state == S_PLAY_FALL)
or (inflictor.state == S_PLAY_JUMP)
or (inflictor.state == S_PLAY_PZNOMACH2JUMPDIVE)
or (inflictor.state == S_PLAY_ROLL)
or (inflictor.state == S_PLAY_PZNOMACH2JUMP))
local player = inflictor.player
P_InstaThrust(target, R_PointToAngle2(0, 0, inflictor.momx, inflictor.momy), 7*FRACUNIT)
P_SetObjectMomZ(target, 3*FRACUNIT, false)
S_StartSound(player.mo, sfx_bump)
inflictor.state = S_PLAY_JUMP
return false
end
end)

addHook("MobjDeath", function(trg, inf, src)
	if not (trg.flags & MF_ENEMY) return end
	if not (trg and trg.valid and inf and inf.valid and inf.player and inf.skin == "pizzano" and not ((inf.player.mo.state ==  S_PLAY_SUPERTAUNT_1) or (inf.player.mo.state ==  S_PLAY_SUPERTAUNT_2) or (inf.player.mo.state ==  S_PLAY_SUPERTAUNT_3)) and (inf.player.machxdtimerr >= 160)) return end
	local p = inf.player
	
	trg.flags2 = $|MF2_DONTDRAW
	local fling = P_SpawnMobjFromMobj(trg, 0, 0, 0, MT_ENEMY_FLYING)
	if fling and fling.valid and trg and trg.valid 
    	trg.tics = -1
		fling.sprite = trg.sprite 
		fling.sprite2 = trg.sprite2 
		fling.frame = trg.frame
		fling.angle = trg.angle
		fling.color = trg.color
		fling.info.deathstate = S_CYBRAKDEMONVILEEXPLOSION1 
		fling.nokilltimer = 3
		fling.info.deathsound = sfx_s3kb4
		S_StopSound(trg)
		P_SetObjectMomZ(fling, 15*FRACUNIT, false)
		P_InstaThrust(fling, inf.player.drawangle, inf.player.speed + 10*FRACUNIT)
	end
end)
addHook("MobjThinker", function(mo)
	if not (mo and mo.valid and mo.health) return end
	if not (mo.secondphase)
		if mo.nokilltimer > 0
			mo.nokilltimer = $ - 1
		end
		if P_IsObjectOnGround(mo) or (FixedHypot(mo.momx, mo.momy) == 0)
			if mo.nokilltimer == 0
				mo.momx = 0
				mo.momy = 0
				mo.momz = 0
				mo.flags = $ | MF_NOGRAVITY
				local flyingenemy = P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_ENEMY_FLYING)
				flyingenemy.sprite = mo.sprite
				flyingenemy.sprite2 = mo.sprite2
				flyingenemy.color = mo.color
				P_KillMobj(mo)
				flyingenemy.target = mo
				flyingenemy.secondphase = true
				flyingenemy.angle = mo.angle
			end
		else
			local cloud = P_SpawnMobj(mo.x,mo.y,mo.z,MT_THOK)
			cloud.state = S_CLOUDEFFECT
		end
	else
		if not (mo.target and mo.target.valid)
			P_RemoveMobj(mo)
		else
			mo.momx = 0
			mo.momz = 0
			mo.momy = 0
			if leveltime % 2 == 0
				mo.flags2 = $|MF2_DONTDRAW
			else
				mo.flags2 = $&~MF2_DONTDRAW
			end
		end
	end
end, MT_ENEMY_FLYING)