/*

Fire Burn VFX, by Angular

Originally written for the Sol Badniks in Ivo's maps, this script can be extended to really any other source of fire.

append a p.hurtBurn to get the same effects, preferably on your damage hooks... 

*/

if burnvfx then return end

local function applyBurn(p, inf, s)
	if not(inf) then return end -- need a valid inflictor!
	if inf.type == MT_SOLFIRE or inf.type == MT_BADNIKSOL
		p.hurtBurn = true
		print("DISCO INFERNO")
		S_StartSound(p.mo, sfx_kc31) --there's no good stock ones...
	end
end

addHook("PlayerSpin", applyBurn)

local steamflame, burnflame
addHook("ThinkFrame", do 
	
	for p in players.iterate do	
        if not p.mo or not p.mo.valid continue end 
		
		if p.hurtBurn
			p.mo.color = SKINCOLOR_BLACK
			p.mo.colorized = true
			burnflame = P_SpawnMobj(p.mo.x+p.mo.momx+P_RandomRange(-10, 10)*p.mo.scale, p.mo.y+p.mo.momy+P_RandomRange(-10, 10)*p.mo.scale, p.mo.z+P_RandomRange(1, 20)*p.mo.scale, MT_SMOKE)
			burnflame.momz = P_RandomRange(2, 8)*p.mo.scale
			burnflame.scale = 2*p.mo.scale
			burnflame.frame = $|TR_TRANS30
			if not(p.kartstuff[k_spinouttimer] or p.kartstuff[k_wipeoutslow])
				p.hurtBurn = nil --break the cycle
				p.mo.color = p.skincolor
				p.mo.colorized = false
			end
		end
		
	end
	
end)

rawset(_G, "burnvfx", true) 