From 9c304105e978dcd6c7023491fe325ed62a3a4668 Mon Sep 17 00:00:00 2001 From: Wuzzy Date: Wed, 5 Aug 2020 19:26:51 +0200 Subject: [PATCH] Add special particles for throwable water bottles --- mods/ITEMS/mcl_potions/lingering.lua | 83 +++++++++++------- mods/ITEMS/mcl_potions/splash.lua | 15 +++- .../textures/mcl_potions_droplet.png | Bin 0 -> 85 bytes 3 files changed, 61 insertions(+), 37 deletions(-) create mode 100644 mods/ITEMS/mcl_potions/textures/mcl_potions_droplet.png diff --git a/mods/ITEMS/mcl_potions/lingering.lua b/mods/ITEMS/mcl_potions/lingering.lua index beb838bae3..d5f4623b16 100644 --- a/mods/ITEMS/mcl_potions/lingering.lua +++ b/mods/ITEMS/mcl_potions/lingering.lua @@ -27,26 +27,31 @@ minetest.register_globalstep(function(dtime) vals.timer = vals.timer - lingering_timer local d = 4 * (vals.timer / 30.0) - + local texture + if vals.is_water then + texture = "mcl_potions_droplet.png" + else + texture = "mcl_potions_sprite.png" + end minetest.add_particlespawner({ - amount = 10 * d^2, - time = 1, - minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, - maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d}, - minvel = {x=-0.5, y=0, z=-0.5}, - maxvel = {x=0.5, y=0.5, z=0.5}, - minacc = {x=-0.2, y=0, z=-0.2}, - maxacc = {x=0.2, y=.05, z=0.2}, - minexptime = 1, - maxexptime = 2, - minsize = 2, - maxsize = 4, - collisiondetection = true, - vertical = false, - texture = "mcl_potions_sprite.png^[colorize:"..vals.color..":127", - }) + amount = 10 * d^2, + time = 1, + minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, + maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d}, + minvel = {x=-0.5, y=0, z=-0.5}, + maxvel = {x=0.5, y=0.5, z=0.5}, + minacc = {x=-0.2, y=0, z=-0.2}, + maxacc = {x=0.2, y=.05, z=0.2}, + minexptime = 1, + maxexptime = 2, + minsize = 2, + maxsize = 4, + collisiondetection = true, + vertical = false, + texture = texture.."^[colorize:"..vals.color..":127", + }) - -- Extingish fire if water bottle + -- Extinguish fire if water bottle if vals.is_water then if mcl_potions._extinguish_nearby_fire(pos) then vals.timer = vals.timer / 2 @@ -129,23 +134,33 @@ function mcl_potions.register_lingering(name, descr, color, def) if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" or mcl_potions.is_obj_hit(self, pos) then minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) add_lingering_effect(pos, color, def, name == "water") + local texture, minacc, maxacc + if name == "water" then + texture = "mcl_potions_droplet.png" + minacc = {x=-0.2, y=-0.05, z=-0.2} + maxacc = {x=0.2, y=0.05, z=0.2} + else + texture = "mcl_potions_sprite.png" + minacc = {x=-0.2, y=0, z=-0.2} + maxacc = {x=0.2, y=.05, z=0.2} + end minetest.add_particlespawner({ - amount = 40, - time = 1, - minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, - maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d}, - minvel = {x=-0.5, y=0, z=-0.5}, - maxvel = {x=0.5, y=0.5, z=0.5}, - minacc = {x=-0.2, y=0, z=-0.2}, - maxacc = {x=0.2, y=.05, z=0.2}, - minexptime = 1, - maxexptime = 2, - minsize = 1, - maxsize = 2, - collisiondetection = true, - vertical = false, - texture = "mcl_potions_sprite.png^[colorize:"..color..":127", - }) + amount = 40, + time = 1, + minpos = {x=pos.x-d, y=pos.y+0.5, z=pos.z-d}, + maxpos = {x=pos.x+d, y=pos.y+1, z=pos.z+d}, + minvel = {x=-0.5, y=0, z=-0.5}, + maxvel = {x=0.5, y=0.5, z=0.5}, + minacc = minacc, + maxacc = maxacc, + minexptime = 1, + maxexptime = 2, + minsize = 1, + maxsize = 2, + collisiondetection = true, + vertical = false, + texture = texture.."^[colorize:"..color..":127", + }) if name == "water" then mcl_potions._extinguish_nearby_fire(pos) end diff --git a/mods/ITEMS/mcl_potions/splash.lua b/mods/ITEMS/mcl_potions/splash.lua index e31bd27ed9..1dc87b1981 100644 --- a/mods/ITEMS/mcl_potions/splash.lua +++ b/mods/ITEMS/mcl_potions/splash.lua @@ -1,4 +1,5 @@ local S = minetest.get_translator("mcl_potions") +local GRAVITY = tonumber(minetest.settings:get("movement_gravity")) local splash_image = function(colorstring, opacity) if not opacity then @@ -63,6 +64,14 @@ function mcl_potions.register_splash(name, descr, color, def) local redux_map = {7/8,0.5,0.25} if n ~= "air" and n ~= "mcl_portals:portal" and n ~= "mcl_portals:portal_end" or mcl_potions.is_obj_hit(self, pos) then minetest.sound_play("mcl_potions_breaking_glass", {pos = pos, max_hear_distance = 16, gain = 1}) + local texture, acc + if name == "water" then + texture = "mcl_potions_droplet.png" + acc = {x=0, y=-GRAVITY, z=0} + else + texture = "mcl_potions_sprite.png" + acc = {x=0, y=0, z=0} + end minetest.add_particlespawner({ amount = 50, time = 0.1, @@ -70,15 +79,15 @@ function mcl_potions.register_splash(name, descr, color, def) maxpos = {x=pos.x+d, y=pos.y+0.5+d, z=pos.z+d}, minvel = {x=-2, y=0, z=-2}, maxvel = {x=2, y=2, z=2}, - minacc = {x=0, y=0, z=0}, - maxacc = {x=0, y=0, z=0}, + minacc = acc, + maxacc = acc, minexptime = 0.5, maxexptime = 1.25, minsize = 1, maxsize = 2, collisiondetection = true, vertical = false, - texture = "mcl_potions_sprite.png^[colorize:"..color..":127", + texture = texture.."^[colorize:"..color..":127" }) if name == "water" then diff --git a/mods/ITEMS/mcl_potions/textures/mcl_potions_droplet.png b/mods/ITEMS/mcl_potions/textures/mcl_potions_droplet.png new file mode 100644 index 0000000000000000000000000000000000000000..e85767d321eed3e6abdc309e04a13af21c7233db GIT binary patch literal 85 zcmeAS@N?(olHy`uVBq!ia0vp^AT}2V8<6ZZI=>f4$#}XrhEy;nOSn8ZGt-z?!6!h_ iXqkuNva8MP3=HSXl{RueN<0Tt$KdJe=d#Wzp$P!<;}w7a literal 0 HcmV?d00001