TNT: Fix multiple explosions erasing drops
authorAuke Kok <sofar@foo-projects.org>
Wed, 27 Apr 2016 06:08:00 +0000 (23:08 -0700)
committerparamat <mat.gregory@virginmedia.com>
Sat, 30 Apr 2016 19:47:21 +0000 (20:47 +0100)
Any second explosion near a first TNT explosion will punch all
entities found nearby, including item drops. This causes the
item pickup code to think the item was picked up, but by
a `nil` player, thus removing the item.

We query for the immortal entity group, and if the item is in
the immortal group, do not punch the item.

mods/tnt/init.lua

index 4330c4fcaddaf93453aca9e46c926a82425cd6b9..d61cbf13df4c5ace8d4b0d7f953635a80218ea56 100644 (file)
@@ -160,10 +160,12 @@ local function entity_physics(pos, radius)
                        local obj_vel = obj:getvelocity()
                        obj:setvelocity(calc_velocity(pos, obj_pos,
                                        obj_vel, radius * 10))
-                       obj:punch(obj, 1.0, {
-                               full_punch_interval = 1.0,
-                               damage_groups = {fleshy = damage},
-                       }, nil)
+                       if not obj:get_armor_groups().immortal then
+                               obj:punch(obj, 1.0, {
+                                       full_punch_interval = 1.0,
+                                       damage_groups = {fleshy = damage},
+                               }, nil)
+                       end
                end
        end
 end