function rnd(mi, ma)
	return math.random(1000)/1000*(ma-mi) + mi
end

function rndVec(t)
	return Vec(rnd(-t, t), rnd(-t, t), rnd(-t, t))
end

function init()
    local exhaust_id = FindLocation("exhaust")
    exhaust_tm = GetLocationTransform(exhaust_id)
end

function tick(dt)
    local emitDir = TransformToParentVec(exhaust_tm, Vec(0, 0, -1))

	ParticleReset()
	ParticleType("smoke")
    ParticleColor(0.5, 0.5, 0.5)
	ParticleGravity(0.0, 0.5, "smooth")
	ParticleDrag(0.25, 3.5, "smooth")
	ParticleRadius(0.1, 0.75, "smooth")
	ParticleAlpha(0.5, 0.0, "smooth")
	for i=1, 2 do
		SpawnParticle(VecAdd(exhaust_tm.pos, rndVec(0.01)), VecScale(emitDir, math.random(100, 400) * 0.01), 5)
	end
end

