//taken from my other addon, Soap the Hedge

//nothing fancy here, just regular ghosts
//scrap that, lets add some pizza tower styled afterimages!!
//lets make this follow the soap, so we can actually see the thing
rawset(_G, "PizzaTowerAfterImages", function(p, me, color)
//	local ghost = P_SpawnGhostMobj(me)
//	ghost.frame = TR_TRANS80
//	ghost.destscale = $*99
	if p.ptaiframewait
		return
	end
	local chasecam = CV_FindVar("chasecam")
	local afteri = P_SpawnGhostMobj(me)
	
	if not (PizzaTowerAICandidates[me.skin][3])
		if p.ptaistyle == 1 or p.ptaistyle == nil or (not(PizzaTowerAICandidates[me.skin][2]))
			if color == 1
				afteri.color = SKINCOLOR_AIREALLYRED
			elseif color == 2
				afteri.color = SKINCOLOR_AIREALLYGREEN
			end
		elseif p.ptaistyle == 2
			if color == 1
				afteri.color = SKINCOLOR_AIREALLYBLUE
			elseif color == 2
				afteri.color = SKINCOLOR_AIREALLYPINK
			end
		elseif p.ptaistyle == 3 //customcolor
		and PizzaTowerAICandidates[me.skin][2]
			if color == 1
				afteri.color = p.ptaicolor1
			elseif color == 2
				afteri.color = p.ptaicolor2
			end		
		end
	else
			if color == 1
				afteri.color = PizzaTowerAICandidates[me.skin][4]
			elseif color == 2
				afteri.color = PizzaTowerAICandidates[me.skin][5]
			end		
	
	end
	afteri.colorized = true
	afteri.frame = FF_FULLBRIGHT|me.frame|TR_TRANS10
	afteri.fuse = 14
	
	//should you be out of my face?
	if chasecam.value
		afteri.flags2 = $ & ~MF2_DONTDRAW
	else
		afteri.flags2 = $ | MF2_DONTDRAW
	end

	//delete the ai if we cant emit them
	//not even sure if this works
	if not p.ptaicanai
		afteri.fuse = 0
		P_KillMobj(afteri)
	end
end)

rawset(_G, "PizzaTowerAICheckForSpecialSkins", function(p, me)
	if me.skin == "juniosonic"
	or me.skin == "blaze"
	or me.skin == "pointy"
	or me.skin == "fluffy"
		p.ptaispecialskin = 1
	end
end)
