TNT: Limit amount of stacks ejected.
authorAuke Kok <sofar@foo-projects.org>
Wed, 23 Mar 2016 04:25:44 +0000 (21:25 -0700)
committerparamat <mat.gregory@virginmedia.com>
Sat, 16 Apr 2016 18:27:16 +0000 (19:27 +0100)
We apply a log scale to the size of the stacks ejected, so that
in larger explosions we are getting larger stacks. For normal r=3
explosions, this gives stack sizes ~6-7 or so, but for r=10 explosions
it could end up giving stacks of 25+.V

mods/tnt/init.lua

index 4010f98742752400f657dad894d42aa46a6f5c39..1f28ee50e4a4f13dcd207bdd52fdb6c226c12f43 100644 (file)
@@ -49,8 +49,9 @@ local function eject_drops(drops, pos, radius)
        local drop_pos = vector.new(pos)
        for _, item in pairs(drops) do
                local count = item:get_count()
+               local take_est = math.log(count * count) + math.random(0,4) - 2
                while count > 0 do
-                       local take = math.min(math.random(2,5),
+                       local take = math.min(take_est,
                                        item:get_count(),
                                        item:get_stack_max())
                        rand_pos(pos, drop_pos, radius)