From 4b7005f8560b565c28b940ad257756d4ed4f2a54 Mon Sep 17 00:00:00 2001 From: alexbobp Date: Mon, 29 Apr 2024 16:51:32 -0500 Subject: [PATCH] add pseudoexponential decay to last-move smoke intensity (so it doesn't stay intense indefinitely after a large capture) --- abm.lua | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/abm.lua b/abm.lua index 42d9cc1..c5ec8ad 100644 --- a/abm.lua +++ b/abm.lua @@ -1,6 +1,6 @@ -- LUALOCALS < --------------------------------------------------------- -local include, nodecore -= include, nodecore +local include, nodecore, math += include, nodecore, math -- LUALOCALS > --------------------------------------------------------- minetest.register_abm({ @@ -10,6 +10,12 @@ minetest.register_abm({ nodenames = {"group:go_stone"}, action = function(pos, node) if not (node.param2 == 0) then + -- if smoke level is higher than 1, it can decay (lazy pseudoexponential decay) + if math.random() < (0.01 * (node.param2 - 1)) then + node.param2 = node.param2 - 1 + minetest.swap_node(pos, node) + end + nodecore.smokefx(pos, 60, node.param2) end end