Added damage

master
Ginger88895 2014-05-09 11:15:26 +00:00
parent 0a83b9af09
commit 0be603f7a5
1 changed files with 84 additions and 81 deletions

View File

@ -1,13 +1,14 @@
local tnt_tables = {["bettertnt:tnt1"] = {r=1},
["bettertnt:tnt2"] = {r=2},
["bettertnt:tnt3"] = {r=4},
["bettertnt:tnt4"] = {r=6},
["bettertnt:tnt5"] = {r=8},
["bettertnt:tnt6"] = {r=10},
["bettertnt:tnt7"] = {r=12},
["bettertnt:tnt8"] = {r=14},
["bettertnt:tnt9"] = {r=16},
["bettertnt:tnt10"] = {r=18}}
["bettertnt:tnt2"] = {r=6},
["bettertnt:tnt3"] = {r=2},
["bettertnt:tnt4"] = {r=4},
["bettertnt:tnt5"] = {r=6},
["bettertnt:tnt6"] = {r=8},
["bettertnt:tnt7"] = {r=10},
["bettertnt:tnt8"] = {r=12},
["bettertnt:tnt9"] = {r=14},
["bettertnt:tnt10"] = {r=16},
["bettertnt:tnt11"] = {r=18}}
tnt = {}
tnt.force = {
@ -187,7 +188,6 @@ end
function boom_id(pos, time, player, id)
minetest.after(time, function(pos)
print(id);
local tnt_range = tnt_tables[id].r * 6
local t1 = os.clock()
@ -214,7 +214,8 @@ function boom_id(pos, time, player, id)
local obj_p = obj:getpos()
local vec = {x=obj_p.x-pos.x, y=obj_p.y-pos.y, z=obj_p.z-pos.z}
local dist = (vec.x^2+vec.y^2+vec.z^2)^0.5
local damage = (80*0.5^(tnt_range - dist))/2
local damage = 0
if dist < tnt_range/3.0 then damage = tnt_range end
obj:punch(obj, 1.0, {
full_punch_interval=1.0,
damage_groups={fleshy=damage},
@ -225,6 +226,7 @@ function boom_id(pos, time, player, id)
local ents = {}
local storedPoses = {}
if id~="bettertnt:tnt2" then
for dx=-tnt_range,tnt_range do
for dz=-tnt_range,tnt_range do
for dy=-tnt_range,tnt_range do
@ -304,6 +306,7 @@ function boom_id(pos, time, player, id)
for name, val in pairs(ents) do
drop_item(pos, name, player, val)
end
end
minetest.add_particlespawner(
tnt_range * 100, --amount
@ -429,7 +432,7 @@ minetest.register_abm({
interval = 2,
chance = 10,
action = function(pos, node)
if node.name == "tnt:tnt1" then
if tnt_tables[node.name]~=nil then
boom({x=pos.x, y=pos.y, z=pos.z}, 0)
else
burn(pos)