2019-01-26 13:58:35 -05:00
|
|
|
-- LUALOCALS < ---------------------------------------------------------
|
2019-03-04 19:33:55 -05:00
|
|
|
local minetest, nodecore, pairs, vector
|
|
|
|
= minetest, nodecore, pairs, vector
|
2019-01-26 13:58:35 -05:00
|
|
|
-- LUALOCALS > ---------------------------------------------------------
|
|
|
|
|
|
|
|
local fallname = "__builtin:falling_node"
|
|
|
|
local fallnode = minetest.registered_entities[fallname]
|
|
|
|
|
|
|
|
local oldtick = fallnode.on_step
|
|
|
|
fallnode.on_step = function(self, dtime, ...)
|
2019-01-29 20:41:29 -05:00
|
|
|
if not self.crush_damage then
|
|
|
|
local def = minetest.registered_items[self.node.name]
|
2019-02-03 09:11:36 -05:00
|
|
|
self.crush_damage = def and def.crush_damage or 0
|
2019-01-29 20:41:29 -05:00
|
|
|
end
|
|
|
|
if self.crush_damage <= 0 then
|
|
|
|
return oldtick(self, dtime, ...)
|
|
|
|
end
|
|
|
|
|
2019-04-06 20:34:13 -04:00
|
|
|
local pos = self.object:get_pos()
|
|
|
|
local vel = self.object:get_velocity()
|
2019-01-26 13:58:35 -05:00
|
|
|
local v = vector.length(vel)
|
2019-03-04 19:33:55 -05:00
|
|
|
local q = v * v * dtime * self.crush_damage
|
2019-08-31 09:26:53 -04:00
|
|
|
for _, o in pairs(minetest.get_objects_inside_radius(pos, 1)) do
|
|
|
|
if o:is_player() then
|
|
|
|
nodecore.addphealth(o, -q)
|
2019-01-26 13:58:35 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
return oldtick(self, dtime, ...)
|
|
|
|
end
|
|
|
|
|
|
|
|
minetest.register_entity(":" .. fallname, fallnode)
|