Creeper mod - FIX#1

Fix for do_tnt_physics
This commit is contained in:
Dave Devil's 2015-03-13 00:48:47 +01:00 committed by LeMagnesium
parent f21cf6d434
commit 2d719aa3ba
1 changed files with 19 additions and 3 deletions

View File

@ -521,7 +521,7 @@ function mobs:register_mob(name, def)
pos.x = math.floor(pos.x+0.5)
pos.y = math.floor(pos.y+0.5)
pos.z = math.floor(pos.z+0.5)
--do_tnt_physics(pos, 3)
do_tnt_physics(pos, 3) -- on applique le principe le la tnt
local meta = minetest.get_meta(pos)
minetest.sound_play("tnt_explode", {pos = pos,gain = 1.0,max_hear_distance = 16,})
if minetest.get_node(pos).name == "default:water_source" or minetest.get_node(pos).name == "default:water_flowing" or minetest.is_protected(pos, "tnt") then
@ -535,7 +535,7 @@ function mobs:register_mob(name, def)
local np={x=pos.x+x,y=pos.y+y,z=pos.z+z}
local n = minetest.get_node(np)
if n.name ~= "air" and n.name ~= "default:obsidian" and n.name ~= "default:bedrock" and n.name ~= "protector:protect" then
--activate_if_tnt(n.name, np, pos, 3)
--activate_if_tnt(n.name, np, pos, 3) -- Pas de module TNT sur le serveur donc inutile
minetest.remove_node(np)
nodeupdate(np)
if n.name ~= "tnt:tnt" and math.random() > 0.9 then
@ -882,7 +882,23 @@ function check_for_death(self)
end
end
function do_tnt_physics(tnt_np,tntr)
local objs = minetest.get_objects_inside_radius(tnt_np, tntr)
for k, obj in pairs(objs) do
local oname = obj:get_entity_name()
local v = obj:getvelocity()
local p = obj:getpos()
if v ~= nil then
obj:setvelocity({x=(p.x - tnt_np.x) + (tntr / 4) + v.x, y=(p.y - tnt_np.y) + (tntr / 2) + v.y, z=(p.z - tnt_np.z) + (tntr / 4) + v.z})
else
if obj:get_player_name() ~= nil then
obj:set_hp(obj:get_hp() - 8) -- lost of 8 life level
end
end
end
end
function mobs:register_arrow(name, def)
minetest.register_entity(name, {
physical = false,