mirror of
https://github.com/minetest/minetest_game.git
synced 2025-01-05 04:50:18 +01:00
re-add explode_center and set the minimum number of counted nodes to 1
This commit is contained in:
parent
7e597c92c2
commit
943de3b227
@ -232,7 +232,7 @@ The doors mod allows modders to register custom doors and trapdoors.
|
|||||||
gain_open = 0.3, -- optional, defaults to 0.3
|
gain_open = 0.3, -- optional, defaults to 0.3
|
||||||
gain_close = 0.3, -- optional, defaults to 0.3
|
gain_close = 0.3, -- optional, defaults to 0.3
|
||||||
protected = false, -- If true, only placer can open the door (locked for others)
|
protected = false, -- If true, only placer can open the door (locked for others)
|
||||||
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
|
on_rightclick = function(pos, node, clicker, itemstack, pointed_thing),
|
||||||
-- optional function containing the on_rightclick callback, defaults to a doors.door_toggle-wrapper
|
-- optional function containing the on_rightclick callback, defaults to a doors.door_toggle-wrapper
|
||||||
use_texture_alpha = "clip",
|
use_texture_alpha = "clip",
|
||||||
|
|
||||||
@ -543,7 +543,8 @@ TNT API
|
|||||||
^ Create an explosion.
|
^ Create an explosion.
|
||||||
|
|
||||||
* `position` The center of explosion.
|
* `position` The center of explosion.
|
||||||
* `definition` The TNT definion as passed to `tnt.register`.
|
* `definition` The TNT definion as passed to `tnt.register` with the following addition:
|
||||||
|
* `explode_center` false by default which removes TNT node on blast, when true will explode center node.
|
||||||
|
|
||||||
`tnt.burn(position, [nodename])`
|
`tnt.burn(position, [nodename])`
|
||||||
|
|
||||||
|
@ -279,7 +279,7 @@ function tnt.burn(pos, nodename)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owner)
|
local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owner, explode_center)
|
||||||
pos = vector.round(pos)
|
pos = vector.round(pos)
|
||||||
-- scan for adjacent TNT nodes first, and enlarge the explosion
|
-- scan for adjacent TNT nodes first, and enlarge the explosion
|
||||||
local vm1 = VoxelManip()
|
local vm1 = VoxelManip()
|
||||||
@ -288,7 +288,6 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
|
|||||||
local minp, maxp = vm1:read_from_map(p1, p2)
|
local minp, maxp = vm1:read_from_map(p1, p2)
|
||||||
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
local a = VoxelArea:new({MinEdge = minp, MaxEdge = maxp})
|
||||||
local data = vm1:get_data()
|
local data = vm1:get_data()
|
||||||
local count = 1
|
|
||||||
local c_tnt
|
local c_tnt
|
||||||
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
|
local c_tnt_burning = minetest.get_content_id("tnt:tnt_burning")
|
||||||
local c_tnt_boom = minetest.get_content_id("tnt:boom")
|
local c_tnt_boom = minetest.get_content_id("tnt:boom")
|
||||||
@ -300,11 +299,11 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
|
|||||||
c_tnt = c_tnt_burning -- tnt is not registered if disabled
|
c_tnt = c_tnt_burning -- tnt is not registered if disabled
|
||||||
end
|
end
|
||||||
|
|
||||||
-- don't double-count tnt @ the center
|
local count
|
||||||
local vc = a:index(pos.x, pos.y, pos.z)
|
if explode_center then
|
||||||
local ccid = data[vc]
|
count = 1
|
||||||
if (ccid == c_tnt or ccid == c_tnt_boom or ccid == c_tnt_burning) then
|
else
|
||||||
data[vc] = c_air
|
count = 0
|
||||||
end
|
end
|
||||||
|
|
||||||
for z = pos.z - 2, pos.z + 2 do
|
for z = pos.z - 2, pos.z + 2 do
|
||||||
@ -320,6 +319,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
count = math.max(1, count)
|
||||||
|
|
||||||
vm1:set_data(data)
|
vm1:set_data(data)
|
||||||
vm1:write_to_map()
|
vm1:write_to_map()
|
||||||
@ -353,7 +353,7 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
|
|||||||
if cid ~= c_air and cid ~= c_ignore and (ignore_protection or not minetest.is_protected(p, owner)) then
|
if cid ~= c_air and cid ~= c_ignore and (ignore_protection or not minetest.is_protected(p, owner)) then
|
||||||
data[vi] = destroy(drops, p, cid, c_air, c_fire,
|
data[vi] = destroy(drops, p, cid, c_air, c_fire,
|
||||||
on_blast_queue, on_construct_queue,
|
on_blast_queue, on_construct_queue,
|
||||||
ignore_protection, ignore_on_blast, owner)
|
ignore_on_blast)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
vi = vi + 1
|
vi = vi + 1
|
||||||
@ -362,7 +362,8 @@ local function tnt_explode(pos, radius, ignore_protection, ignore_on_blast, owne
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- make the center of the explosion flash, if it's safe
|
-- make the center of the explosion flash, if it's safe
|
||||||
ccid = data[vc]
|
local vc = a:index(pos.x, pos.y, pos.z)
|
||||||
|
local ccid = data[vc]
|
||||||
if ccid == c_air then
|
if ccid == c_air then
|
||||||
data[vc] = c_tnt_boom
|
data[vc] = c_tnt_boom
|
||||||
end
|
end
|
||||||
@ -423,7 +424,7 @@ function tnt.boom(pos, def)
|
|||||||
minetest.sound_play(sound, {pos = pos, gain = 2.5,
|
minetest.sound_play(sound, {pos = pos, gain = 2.5,
|
||||||
max_hear_distance = math.min(def.radius * 20, 128)}, true)
|
max_hear_distance = math.min(def.radius * 20, 128)}, true)
|
||||||
local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection,
|
local drops, radius = tnt_explode(pos, def.radius, def.ignore_protection,
|
||||||
def.ignore_on_blast, owner)
|
def.ignore_on_blast, owner, def.explode_center)
|
||||||
-- append entity drops
|
-- append entity drops
|
||||||
local damage_radius = (radius / math.max(1, def.radius)) * def.damage_radius
|
local damage_radius = (radius / math.max(1, def.radius)) * def.damage_radius
|
||||||
entity_physics(pos, damage_radius, drops)
|
entity_physics(pos, damage_radius, drops)
|
||||||
|
Loading…
Reference in New Issue
Block a user