sorcery  vfx.lua at [62861f22e2]

File vfx.lua artifact 291a2c52f8 part of check-in 62861f22e2


sorcery.vfx = {}

sorcery.vfx.cast_sparkle = function(caster,color,strength,duration)
	minetest.add_particlespawner {
		amount = 70 * strength;
		time = duration or 1.5;
		attached = caster;
		texture = sorcery.lib.image('sorcery_spark.png'):multiply(color):render();
		minpos = { x = -0.1, z =  0.5, y =  1.2}; 
		maxpos = { x =  0.1, z =  0.3, y =  1.6}; 
		minvel = { x = -0.5, z = -0.5, y = -0.5};
		maxvel = { x =  0.5, z =  0.5, y =  0.5};
		minacc = { x =  0.0, z =  0.0, y =  0.5};
		maxacc = { x =  0.0, z =  0.0, y =  0.5};
		minsize = 0.4, maxsize = 0.8;
		minexptime = 1, maxexptime = 1;
		glow = 14;
		animation = {
			type = 'vertical_frames';
			aspect_w = 16;
			aspect_h = 16;
			length = 1.1;
		};
	}
end

sorcery.vfx.enchantment_sparkle = function(tgt,color)
	local minvel, maxvel
	if minetest.get_node(vector.add(tgt.under,{y=1,z=0,x=0})).name == 'air' then
		minvel = {x=0,z=0,y= 0.3}  maxvel = {x=0,z=0,y= 1.5};
	else
		local dir = vector.subtract(tgt.under,tgt.above)
		minvel = vector.multiply(dir, 0.3)
		maxvel = vector.multiply(dir, 1.2)
	end
	return minetest.add_particlespawner {
		amount = 50;
		time = 0.5;
		minpos = vector.subtract(tgt.under, 0.5);
		maxpos = vector.add(tgt.under, 0.5);
		minvel = minvel, maxvel = maxvel;
		minexptime = 1, maxexptime = 2;
		minsize = 0.5, maxsize = 2;
		texture = sorcery.lib.image('sorcery_spark.png'):multiply(color):render();
		animation = {
			type = 'vertical_frames';
			aspect_w = 16, aspect_h = 16;
			length = 2;
		};
		glow = 14;
	}
end

sorcery.vfx.bloodburst = function(pos,size)
	for i=0, size or 48 do
		minetest.add_particle{
			texture = 'sorcery_blood_' .. math.random(5) .. '.png',
			size = 7,
			expirationtime = 2 + math.random(),
			glow = 1,
			pos = pos,
			velocity = {
				x = (math.random() * 3.0) - 1.5,
				y = math.random(),
				z = (math.random() * 3.0) - 1.5
			},
			acceleration = {
				x = 0,
				y = -1,
				z = 0
			}
		}
	end
end