function init()
	s = 0
	sparks = FindLocations("elec")
	sparkBodies = FindShapes("elec",true)
	snd = LoadSound("MOD/snd/map/elec_spark.ogg")
end
function rndVec(length)
	local v = VecNormalize(Vec(math.random(-100,100), math.random(-100,100), math.random(-100,100)))
	return VecScale(v, length)	
end
function tick(dt)
	if math.random(1,30)==2 then
		s = math.random(-1,1)
	end
	for i=1, #sparks do
		if s ~= 0 and math.random(1,150)==5 then
			local pos = GetLocationTransform(sparks[i])
			local dir = TransformToParentVec(pos,Vec(0,0,-1))
			ParticleReset()
			ParticleType("plain")
			ParticleTile(4)
			ParticleColor(1,0.8,0.6)
			ParticleRadius(0.03,0)
			ParticleAlpha(1,0)
			ParticleGravity(-9.8)
			ParticleEmissive(1)
			ParticleStretch(4)
			ParticleSticky(0.1)
			ParticleCollide(1)
			for s=1, math.random(3,5) do
				SpawnParticle(pos.pos,VecAdd(VecScale(dir,math.random(10,20)*0.1),rndVec(0.5)),2)
			end
			PlaySound(snd,pos.pos,0.2)
		end
	end
	for i=1, #sparkBodies do
		if s ~= 0 and math.random(1,100)==5 then
			local pos = GetShapeWorldTransform(sparkBodies[i])
			local dir = TransformToParentVec(pos,Vec(0,-1,0))
			ParticleReset()
			ParticleType("plain")
			ParticleTile(4)
			ParticleColor(1,0.8,0.6)
			ParticleRadius(0.03,0)
			ParticleAlpha(1,0)
			ParticleGravity(-9.8)
			ParticleEmissive(1)
			ParticleStretch(4)
			ParticleSticky(0.1)
			ParticleCollide(1)
			for s=1, math.random(1,3) do
				SpawnParticle(pos.pos,VecAdd(VecScale(dir,math.random(10,20)*0.1),rndVec(0.5)),2)
			end
		end
	end
end