freeslot(
"MT_NEO_FLING"
)
mobjinfo[MT_NEO_FLING] = {
	doomednum = -1,
	spawnstate = S_PLAY_STND,
	flags = MF_NOCLIPHEIGHT,
	radius = 5*FRACUNIT,
	deathstate = S_XPLD1,
	height = 5*FRACUNIT
}
addHook("MobjDeath", function(trg, inf, src)
	if not (trg.flags & MF_ENEMY) return end
	if trg and trg.valid and inf and inf.valid and inf.health and inf.player and inf.skin == "neostreak" and ((inf.state == S_PLAY_DASH or S_PLAY_ROLL) or inf.player.boosting or inf.player.pflags & PF_THOKKED)
		local p = inf.player
		
		S_StartSound(inf, sfx_s3k49)
		trg.flags2 = $|MF2_DONTDRAW
	//	mobjinfo[MT_NEO_FLING].spawnstate = trg.state --Copying it's spawnstate also copies that state's action , that's BEGGING for weird behaviour.
		local fling = P_SpawnMobjFromMobj(trg, 0, 0, 0, MT_NEO_FLING)
		if fling and fling.valid and trg and trg.valid
			trg.tics = -1
			fling.sprite = trg.sprite --Whatever sprite it's using now.
			fling.sprite2 = trg.sprite2 --just incase it's a player somehow.
			fling.frame = trg.frame --The frame it just used
			fling.angle = trg.angle --The angle it just used
			fling.color = trg.color
			fling.info.deathstate = S_CYBRAKDEMONVILEEXPLOSION1  --I'd recommend this, but for now, let's keep the deathstate behaviour, I guess!
			--fling.info.deathstate = trg.info.deathstate
			fling.nokilltimer = 3
			fling.info.deathsound = sfx_s3kb4
			S_StopSound(trg)
			--print("huhjnjdf")
			P_SetObjectMomZ(fling, 15*FRACUNIT, false)
			P_InstaThrust(fling, R_PointToAngle2(inf.x, inf.y, fling.x, fling.y), 43*FRACUNIT)
			--local storespawnhealth = trg.info.spawnhealth
			--trg.type = MT_NEO_DEADFLING
			--trg.info.spawnhealth = storespawnhealth
		end
	end
end)
addHook("MobjThinker", function(mo)
	if mo and mo.valid and mo.health
		if not (mo.secondphase)
			if mo.nokilltimer > 0
				mo.nokilltimer = $ - 1
			end
			--print(mo.info.deathstate)
			if P_IsObjectOnGround(mo) or (FixedHypot(mo.momx, mo.momy) == 0)
				--mo.rollangle = 0
				if mo.nokilltimer == 0
					mo.momx = 0
					mo.momy = 0
					mo.momz = 0
					mo.flags = $ | MF_NOGRAVITY
					local lmao = P_SpawnMobjFromMobj(mo, 0, 0, 0, MT_NEO_FLING)
					lmao.sprite = mo.sprite
					lmao.sprite2 = mo.sprite2
					lmao.color = mo.color
					lmao.target = mo
					lmao.secondphase = true
					lmao.rollangle = mo.rollangle
					lmao.angle = mo.angle
					P_KillMobj(mo)
					mo.rollangle = 0
				end
			else
				mo.rollangle = $ + FixedAngle(20*FRACUNIT)
			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
end, MT_NEO_FLING)