
mobjinfo[MT_REVERIESPARK1] = {
	spawnstate = S_REVERIESPARK1,
	deathstate = S_NULL,
	speed = FRACUNIT,
	radius = FRACUNIT,
	height = FRACUNIT,
	flags = MF_NOGRAVITY
}

states[S_REVERIESPARK1] = {
	sprite = SPR_RVSP,
	frame = A|FF_FULLBRIGHT|FF_ANIMATE|TR_TRANS30,
	tics = 26,
	var1 = 12,
	var2 = 2,
	nextstate = S_NULL
}

//Spawns a sparkle and sends it flying off in a random direction
local function sparkleburst(mo, speed)
	if not mo then return end
	
	local an,slope = P_RandomRange(0, 359)*ANG1, P_RandomRange(0, 359)*ANG1
	local slope2 = sin(slope)
	local x,y,z = mo.x,mo.y,mo.z + mo.height/2
	
	if (mo.eflags & MFE_VERTICALFLIP)
		z = mo.z - mo.height/2
	end
	
	local th = P_SpawnMobj(x, y, z, MT_REVERIESPARK1)
	if not th then return end

	th.momx = FixedMul(speed, cos(an))
	th.momy = FixedMul(speed, sin(an))
		
	th.momx = FixedMul(th.momx, cos(slope))
	th.momy = FixedMul(th.momy, cos(slope))
	
	th.momz = FixedMul(speed, slope2)
	
	return th
end

function A_ManiaExplode(actor)
	for i=0,12
		sparkleburst(actor, 30*FRACUNIT)
	end
end