TNT: randomly vary ejecting velocity
authorAuke Kok <sofar@foo-projects.org>
Sat, 16 Apr 2016 19:13:13 +0000 (12:13 -0700)
committerparamat <mat.gregory@virginmedia.com>
Tue, 26 Apr 2016 21:34:00 +0000 (22:34 +0100)
We add a +/- 0.5 random value to the velocity vector of
ejecting nodes.

I've spotted a lot of nodes going exactly straight up if blowing
up sand above TNT. The extra variation looks less artificial.

mods/tnt/init.lua

index b48a56b9b688f68fc3f3dd6e7e66bb7521e0e811..1c92c5e4ffae97fa8f44be96c71128d1af7dcf44 100644 (file)
@@ -123,6 +123,13 @@ local function calc_velocity(pos1, pos2, old_vel, power)
        -- Add old velocity
        vel = vector.add(vel, old_vel)
 
+       -- randomize it a bit
+       vel = vector.add(vel, {
+               x = math.random() - 0.5,
+               y = math.random() - 0.5,
+               z = math.random() - 0.5,
+       })
+
        -- Limit to terminal velocity
        dist = vector.length(vel)
        if dist > 250 then