From c90df6529477aa809aec2e2cd7421b0b8d483e4f Mon Sep 17 00:00:00 2001 From: Auke Kok Date: Sun, 24 Jan 2016 23:48:38 -0800 Subject: [PATCH] TNT: add some depth to the explosion effect We add a dirt-like particle (drawn from scratch, uses some colors from default_dirt's palette) to spawn many particles that have collision enabled around the center of the blast. This has the effect of obscuring the center of the blast, as that is a painfully visible empty area when the explosion happens, as there's only a little spark. The dirt particles bounce around the walls and floor a bit, and disappear rapidly, well before the smoke particles disappear. This is a nice visual distraction that obscures the sudden appearance of the gaping hole, and makes it a whole lot more believable. --- init.lua | 31 +++++++++++++++++++++++++++++++ textures/tnt_blast.png | Bin 0 -> 855 bytes 2 files changed, 31 insertions(+) create mode 100644 textures/tnt_blast.png diff --git a/init.lua b/init.lua index 576d3a8..528aee0 100644 --- a/init.lua +++ b/init.lua @@ -162,6 +162,37 @@ local function add_effects(pos, radius) maxsize = 16, texture = "tnt_smoke.png", }) + + -- we just dropped some items. Look at the items entities and pick + -- one of them to use as texture + local texture = "tnt_blast.png" --fallback texture + local objs = minetest.get_objects_inside_radius(pos, 2) + for _, obj in pairs(objs) do + if obj and obj:get_luaentity() then + local def = ItemStack(obj:get_luaentity().itemstring):get_definition() + if def.tiles then + texture = def.tiles[1] + break + end + end + end + + minetest.add_particlespawner({ + amount = 64, + time = 0.1, + minpos = vector.subtract(pos, radius / 2), + maxpos = vector.add(pos, radius / 2), + minvel = {x=-3, y=0, z=-3}, + maxvel = {x=3, y=5, z=3}, + minacc = {x=0, y=-10, z=0}, + maxacc = {x=0, y=-10, z=0}, + minexptime = 0.8, + maxexptime = 2.0, + minsize = 2, + maxsize = 6, + texture = texture, + collisiondetection = true, + }) end local function burn(pos) diff --git a/textures/tnt_blast.png b/textures/tnt_blast.png new file mode 100644 index 0000000000000000000000000000000000000000..bbb1096f5d81f68b0247f1bd386357f1c14c2579 GIT binary patch literal 855 zcmV-d1E~CoP)o&74tn0wNWtEkm#^jZ>SJP!74EEBU-F0SihuX3Ls`c>`{pYM;V{Pz0=Ql$KI zE%7{$!T1g-raXT7f}f5uUcEjC;P5cS7b}D@hO3*5uwod^oqJMMX4tk(Q4}cSVbTe2 zFC(OsoSuYet(im{?9=a>+^$^SfB1kD|FYXYA_x|I)2i`#D(IiI$wiI9a7ef5a2Z9s zxlp`(9x{z3Vl)HWEbd8mF~@aXF0Z%qt#hB&QdCxkQ_ zlOzdOHyQojmR`0J9yJVFYwR>l8IBX;IA$-%c>MGQCY>-C4*6^hLI~;%u`HK&S1a;l z%AN7JU2e}O@;oO}4pO9i8Y?>WjM+-iZ8``ca9x+BaNR;#h&s;xo4 z7w}FsING;)_4*tsC6`e|w;k}H?vt1*A3x5xT}(Oq@foAJ!|45=DB~fzO^3ff#Rwr7 z{TBi7?4XR4lIy#SNwh(0&FM*ql#;iX5hk6Wj7L!v*roDATCIdM8nRRYhle4PwdUpX z5XBC09McFk{PEWplu|tTHsI3;}TUTrW0;A2k5r9 heHdfdt!UP{&;J-adc&TrL81Tv002ovPDHLkV1k_