add the mega torch bomb

This commit is contained in:
FaceDeer 2020-02-09 22:11:50 -07:00
parent b76956979a
commit a6daddf335
10 changed files with 121 additions and 66 deletions

View File

@ -4,4 +4,6 @@ If you've ever been exploring a cave and found a deep, dark hole in the ground w
One torch bomb will fire up to 42 torches (though usually much less than that) in a radial pattern around itself, with a minimum range of 5 meters (the torches are going too fast closer than that and shatter without a trace) and a maximum range of 40 meters from the detonation point. Torch bombs are falling nodes when lit, much like TNT. One torch bomb will fire up to 42 torches (though usually much less than that) in a radial pattern around itself, with a minimum range of 5 meters (the torches are going too fast closer than that and shatter without a trace) and a maximum range of 40 meters from the detonation point. Torch bombs are falling nodes when lit, much like TNT.
TNT is an optional dependency, but torch bombs don't have a crafting recipe without this mod enabled. Three torch bombs can be combined into one mega torch bomb. A mega torch bomb can fire up to 162 torches with a range of 120 meters from the detonation point (three times that of a regular torch bomb). The minimum range of this monster is 15 meters, and it produces enough of a blast to destroy nodes within 3 meters, so take care. One of these is suitable for illuminating a very large cavern with walls and ceiling too distant to reach otherwise.
TNT is an optional dependency, but torch bombs don't have a crafting recipe (and don't produce a damaging blast) without the tnt mod enabled.

View File

@ -9,7 +9,7 @@ end
local bomb_range = tonumber(minetest.settings:get("torch_bomb_max_range")) or 40 local bomb_range = tonumber(minetest.settings:get("torch_bomb_max_range")) or 40
-- 12 torches (torch grenade?) -- 12 torches (torch grenade? Not currently used)
local ico1 = { local ico1 = {
vector.new(0.000000, -1.000000, 0.000000), vector.new(0.000000, -1.000000, 0.000000),
vector.new(0.723600, -0.447215, 0.525720), vector.new(0.723600, -0.447215, 0.525720),
@ -25,7 +25,7 @@ local ico1 = {
vector.new(0.000000, 1.000000, 0.000000), vector.new(0.000000, 1.000000, 0.000000),
} }
-- 42 torches -- 42 torches, 1*bomb_range
local ico2 = { local ico2 = {
vector.new(0.000000, -1.000000, 0.000000), vector.new(0.000000, -1.000000, 0.000000),
vector.new(0.723607, -0.447220, 0.525725), vector.new(0.723607, -0.447220, 0.525725),
@ -70,8 +70,12 @@ local ico2 = {
vector.new(-0.425323, 0.850654, -0.309011), vector.new(-0.425323, 0.850654, -0.309011),
vector.new(0.162456, 0.850654, -0.499995), vector.new(0.162456, 0.850654, -0.499995),
} }
-- Pre-multiply the range into these unit vectors
for i, pos in ipairs(ico2) do
ico2[i] = vector.multiply(pos, bomb_range)
end
-- 162 torches (maybe for a mega-bomb with big range) -- 162 torches, 3* bomb_range
local ico3 = { local ico3 = {
vector.new(0.000000, -1.000000, 0.000000), vector.new(0.000000, -1.000000, 0.000000),
vector.new(0.723607, -0.447220, 0.525725), vector.new(0.723607, -0.447220, 0.525725),
@ -236,6 +240,10 @@ local ico3 = {
vector.new(0.138199, -0.894429, 0.425321), vector.new(0.138199, -0.894429, 0.425321),
vector.new(0.361805, -0.723611, 0.587779), vector.new(0.361805, -0.723611, 0.587779),
} }
-- Pre-multiply the range into these unit vectors
for i, pos in ipairs(ico3) do
ico3[i] = vector.multiply(pos, bomb_range*3)
end
local function find_target(raycast) local function find_target(raycast)
local next_pointed = raycast:next() local next_pointed = raycast:next()
@ -257,13 +265,13 @@ end
local torch_def_on_place = minetest.registered_nodes["default:torch"].on_place local torch_def_on_place = minetest.registered_nodes["default:torch"].on_place
local function kerblam(pos, placer, dirs, range) local function kerblam(pos, placer, dirs, min_range)
local targets = {} local targets = {}
for _, pos2 in ipairs(dirs) do for _, pos2 in ipairs(dirs) do
local raycast = minetest.raycast(pos, vector.add(pos, vector.multiply(pos2, range)), false, true) local raycast = minetest.raycast(pos, vector.add(pos, pos2), false, true)
local target_pointed = find_target(raycast) local target_pointed = find_target(raycast)
if target_pointed then if target_pointed then
if vector.distance(pos, target_pointed.above) > 5 then if vector.distance(pos, target_pointed.above) > min_range then
table.insert(targets, target_pointed) table.insert(targets, target_pointed)
end end
end end
@ -272,22 +280,44 @@ local function kerblam(pos, placer, dirs, range)
for _, target in ipairs(targets) do for _, target in ipairs(targets) do
if minetest.get_item_group(minetest.get_node(target.above).name, "torch") == 0 then -- TODO remove this check after culling close-together targets if minetest.get_item_group(minetest.get_node(target.above).name, "torch") == 0 then -- TODO remove this check after culling close-together targets
torch_def_on_place(ItemStack("default:torch"), placer, target) torch_def_on_place(ItemStack("default:torch"), placer, target)
local target_pos = target.above
local dir_back = vector.normalize(vector.subtract(pos, target_pos))
local vel_back = vector.multiply(dir_back, 10)
minetest.add_particlespawner({
amount = math.random(1,6),
time = 0.1,
minpos = target_pos,
maxpos = target_pos,
minvel = vector.subtract(dir_back, 2),
maxvel = vector.add(dir_back, 2),
minacc = {x=0, y=-9, z=0},
maxacc = {x=0, y=-9, z=0},
minexptime = 1,
maxexptime = 2,
minsize = 1,
maxsize = 2,
collisiondetection = true,
collision_removal = false,
texture = "torch_bomb_shard.png",
})
end end
end end
end end
minetest.register_node("torch_bomb:torch_bomb", { local function register_torch_bomb(name, desc, dirs, min_range, blast_radius, texture)
description = S("Torch Bomb"),
drawtype = "normal", -- See "Node drawtypes"
tiles = {"torch_bomb_top.png", "torch_bomb_bottom.png", "torch_bomb_side.png"},
paramtype = "light", -- See "Nodes"
paramtype2 = "facedir", -- See "Nodes"
groups = {tnt = 1}, minetest.register_node("torch_bomb:" .. name, {
description = desc,
drawtype = "normal",
tiles = {"torch_bomb_top.png", "torch_bomb_bottom.png", "torch_bomb_side_base.png^"..texture},
paramtype = "light",
paramtype2 = "facedir",
groups = {tnt = 1, oddly_breakable_by_hand = 1},
on_punch = function(pos, node, puncher) on_punch = function(pos, node, puncher)
if puncher:get_wielded_item():get_name() == "default:torch" then if puncher:get_wielded_item():get_name() == "default:torch" then
minetest.set_node(pos, {name = "torch_bomb:torch_bomb_burning"}) minetest.set_node(pos, {name = "torch_bomb:"..name.."_burning"})
minetest.get_meta(pos):set_string("torch_bomb_ignitor", puncher:get_player_name()) minetest.get_meta(pos):set_string("torch_bomb_ignitor", puncher:get_player_name())
minetest.log("action", puncher:get_player_name() .. " ignites " .. node.name .. " at " .. minetest.log("action", puncher:get_player_name() .. " ignites " .. node.name .. " at " ..
minetest.pos_to_string(pos)) minetest.pos_to_string(pos))
@ -295,12 +325,12 @@ minetest.register_node("torch_bomb:torch_bomb", {
end, end,
on_ignite = function(pos) -- used by TNT mod on_ignite = function(pos) -- used by TNT mod
minetest.set_node(pos, {name = "torch_bomb:torch_bomb_burning"}) minetest.set_node(pos, {name = "torch_bomb:"..name.."_burning"})
end, end,
}) })
minetest.register_node("torch_bomb:torch_bomb_burning", { minetest.register_node("torch_bomb:"..name.."_burning", {
description = S("Torch Bomb"), description = desc,
drawtype = "normal", -- See "Node drawtypes" drawtype = "normal", -- See "Node drawtypes"
tiles = {{ tiles = {{
name = "torch_bomb_top_burning_animated.png", name = "torch_bomb_top_burning_animated.png",
@ -311,7 +341,7 @@ minetest.register_node("torch_bomb:torch_bomb_burning", {
length = 1, length = 1,
} }
}, },
"torch_bomb_bottom.png", "torch_bomb_side.png"}, "torch_bomb_bottom.png", "torch_bomb_side_base.png^"..texture},
groups = {falling_node = 1, not_in_creative_inventory = 1}, groups = {falling_node = 1, not_in_creative_inventory = 1},
paramtype = "light", paramtype = "light",
paramtype2 = "facedir", paramtype2 = "facedir",
@ -333,19 +363,37 @@ minetest.register_node("torch_bomb:torch_bomb_burning", {
end end
minetest.set_node(pos, {name="air"}) minetest.set_node(pos, {name="air"})
if tnt_modpath then if tnt_modpath then
tnt.boom(pos, {radius=1, damage_radius=3}) tnt.boom(pos, {radius=blast_radius, damage_radius=blast_radius+3})
end end
kerblam(pos, puncher, ico2, bomb_range) kerblam(pos, puncher, dirs, min_range)
end, end,
}) })
end
register_torch_bomb("torch_bomb", S("Torch Bomb"), ico2, 5, 1, "torch_bomb_one_torch.png")
register_torch_bomb("mega_torch_bomb", S("Mega Torch Bomb"), ico3, 15, 3, "torch_bomb_three_torches.png")
if enable_tnt and tnt_modpath then if enable_tnt and tnt_modpath then
minetest.register_craft({ minetest.register_craft({
output = "torch_bomb:torch_bomb", output = "torch_bomb:torch_bomb",
recipe = { recipe = {
{'group:wood', 'default:coalblock', 'group:wood'}, {'default:coalblock', 'tnt:tnt_stick', 'default:coalblock'},
{'group:wood', 'tnt:tnt_stick', 'group:wood'},
{'group:wood', 'tnt:tnt_stick', 'group:wood'}, {'group:wood', 'tnt:tnt_stick', 'group:wood'},
{'group:wood', 'group:wood', 'group:wood'},
}, },
}) })
minetest.register_craft({
type = "shapeless",
output = "torch_bomb:mega_torch_bomb",
recipe = {"torch_bomb:torch_bomb", "torch_bomb:torch_bomb", "torch_bomb:torch_bomb"},
})
minetest.register_craft({
type = "shapeless",
output = "torch_bomb:torch_bomb 3",
recipe = {"torch_bomb:mega_torch_bomb"},
})
end end

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2020-02-09 18:05-0700\n" "POT-Creation-Date: 2020-02-09 22:05-0700\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -17,7 +17,10 @@ msgstr ""
"Content-Type: text/plain; charset=CHARSET\n" "Content-Type: text/plain; charset=CHARSET\n"
"Content-Transfer-Encoding: 8bit\n" "Content-Transfer-Encoding: 8bit\n"
#: torch_bomb\init.lua:275 #: torch_bomb\init.lua:374
#: torch_bomb\init.lua:298
msgid "Torch Bomb" msgid "Torch Bomb"
msgstr "" msgstr ""
#: torch_bomb\init.lua:375
msgid "Mega Torch Bomb"
msgstr ""

BIN
screenshot.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 51 KiB

View File

@ -5,3 +5,5 @@ Copyright (C) 2014-2016 ShadowNinja
Copyright (C) 2015-2016 Wuzzy Copyright (C) 2015-2016 Wuzzy
Copyright (C) 2016 sofar (sofar@foo-projects.org) Copyright (C) 2016 sofar (sofar@foo-projects.org)
Copyright (C) 2018 paramat Copyright (C) 2018 paramat
Torch bomb shard by FaceDeer 2020 under the CC0 license

Binary file not shown.

After

Width:  |  Height:  |  Size: 227 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 350 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 211 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 91 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 254 B