[mod] Torch bombs! [torch_bomb] 0.4

Post Reply
FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

[mod] Torch bombs! [torch_bomb] 0.4

by FaceDeer » Post

Image

If you've ever been exploring a cave and found a deep, dark hole in the ground with no clue as to what was below, this is the mod for you.

Throw a torch grenade and it will explode on impact, firing up to 12 torches 25 meters away from the detonation point to embed themselves in whatever surfaces they hit.

For surveying a larger chamber three torch grenades can be combined into a single torch bomb. Place the bomb block and ignite it by punching it with a torch. Three seconds later it'll detonate and fire up to 42 torches 50 meters away from the detonation point. Torch bombs are falling nodes when lit, much like TNT, but you need to punch them a second time once they are lit to make them fall.

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 150 meters from the detonation point. 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.

If you want to scatter torches from the center of a cavern to reach floor and ceiling more evenly a torch bomb can be upgraded to a torch rocket with the addition of more TNT. Torch rockets can have a fuse set up to 14 seconds, which at their acceleration of 1 meter per second squared will cause it to rise nearly 100 meters before detonating.

For precision torch placement there are torch crossbows included in this mod. Wood, bronze, and steel crossbows each place a single torch with increasing range.

TNT is an optional dependency for this mod, but torch bombs don't have a crafting recipe (and don't produce a damaging blast) without the tnt mod enabled.

Links
Last edited by FaceDeer on Mon Feb 24, 2020 00:08, edited 5 times in total.

User avatar
texmex
Member
Posts: 1752
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [mod] Torch bombs! [torch_bomb] 0.1

by texmex » Post

Nice! It's an instant classic! =D
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

User avatar
sorcerykid
Member
Posts: 1311
Joined: Fri Aug 26, 2016 15:36
GitHub: sorcerykid
In-game: Nemo
Location: Illinois, USA

Re: [mod] Torch bombs! [torch_bomb] 0.1

by sorcerykid » Post

I have to say, I like the concept. I'm surprised that nobody has thought of this before, since it seems so simple and obvious :D

CalebJ
Member
Posts: 311
Joined: Sat Dec 29, 2018 19:21
GitHub: KaylebJay
IRC: KaylebJay
In-game: CalebJ
Location: Tunnelers' Abyss

Re: [mod] Torch bombs! [torch_bomb] 0.1

by CalebJ » Post

Great concept and excellent execution.
If you want realism, you're in the wrong place. Get off your mobile.

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.2

by FaceDeer » Post

Thanks. I'm surprised it took me this long to do something like this too, I've been working with giant cavern mapgen mods for years and grumbled about placing torches to see what I've made the whole time. :)

Just made an update to the mod, I added "torch grenades" which are smaller throwable versions of the torch bomb. Each torch grenade fires up to 12 torches out of the detonation (usually less than that though) but you can fling the torch grenade some distance away from you.

Let me know if the balance of the various items seems off, I just made up the numbers based on what seemed appropriate.

User avatar
duane
Member
Posts: 1621
Joined: Wed Aug 19, 2015 19:11
GitHub: duane-r
Location: Oklahoma City
Contact:

Re: [mod] Torch bombs! [torch_bomb] 0.2

by duane » Post

Hehe. I like it, but it still seems like cheating. I did basically the same thing, but the lights were only temporary.
Believe in people and you don't need to believe anything else.

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.2

by FaceDeer » Post

duane wrote:Hehe. I like it, but it still seems like cheating. I did basically the same thing, but the lights were only temporary.
Install real_torch and these will be temporary too. :)

I just added a configuration setting for torch_bomb, "torch_bomb_torch_item", that you can set to something other than default:torch if you have a different item that you'd like torch bombs to place. I just tested it with default:meselamp and that seemed to work nicely. In theory it'll properly use whatever on_place callback the item has defined.

Torch_bombs require dynamite as part of their crafting recipe, so hopefully the expense means they won't be a substitute for regular torches most of the time.

User avatar
texmex
Member
Posts: 1752
Joined: Mon Jul 11, 2016 21:08
GitHub: tacotexmex
In-game: tacotexmex

Re: [mod] Torch bombs! [torch_bomb] 0.2

by texmex » Post

This would fit nicely with the Raycasted Explosions API!
Mods | Support Mesehub: bc1qluuests9rxmlnvpjrhsnyjg9ucwy6z3r0y3srw

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.2

by FaceDeer » Post

That mod rolls its own raycasting? Neat. I used the built-in Minetest raycasting API for finding the places to stick torches, and a set of the first three geodesic subdivisions of an icosohedron to give the directions to cast rays in (you can see the triangular pattern of the torches if you blast them into a large distant cliff face).

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.3

by FaceDeer » Post

If duane thought this was "cheaty" before, I regret to inform him I've just added "Torch Bomb Rocket" variants that can launch themselves up to 100 meters upward before detonating. :)

I added boolean settings to disable these, and also to disable the grenades, if you don't want players spraying torches around with quite so wild an abandon.

User avatar
FreeGamers
Member
Posts: 602
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

Re: [mod] Torch bombs! [torch_bomb] 0.3

by FreeGamers » Post

I've added this to Sara's Simple Survival over the weekend after testing it out. The recipes seemed pretty fair. I have real_torch enabled so the torches will extinguish over time, making the utility of this a bit gimped, but I'm happy with that balance. I think it makes it more fair for my survival game. Thanks FD, seems like a fun item for players to create, test, and use. I've noticed some problems where the torch bomb rocket didn't deploy torches once it left the active block range. But that is something resolved by a server config change, probably outside the scope of the program, but to you that probably sounds like a challenge.

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.3

by FaceDeer » Post

Heh. Yeah, I'd noticed that and was thinking I'd have the rocket just predict its detonation point when it unloads and skip ahead to that location. But when I dialed the maximum fuse time down to 14 seconds (limiting the range to <100m) it stopped happening for me and I back-burnered it. I guess I figured "it'll restart when the player gets closer", but since getting closer involves climbing upward into empty space I should probably not assume that's an easy solution.

If you want to un-gimp torch_bombs you could perhaps add some form of longer-burning light source and switch torch_bombs over to use that, the item it places is configurable.

Edit: Predictive detonation of unloaded torch bomb rockets is in. The moment the rocket unloads it does a raycast upward to see if it'll hit anything before its fuse runs out, then schedules a detonation at the predicted detonation point. Should be good enough for most reasonable circumstances. Don't set the maximum allowed fuse time to something ridiculous, though, or things might get silly (probably a good caution regardless :). I was testing with 20-second fuses and that seemed to work, even though it was putting the bomb far enough up that torches weren't reaching the ground.

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.4

by FaceDeer » Post

I figured, I've got all the code in here for raycasting and embedding a torch in a spot, why not make that point-and-click? I've added torch crossbows. I know other mods have torch crossbows too, so I put in a setting so you can disable these if they're redundant with existing mods also installed in your game.

User avatar
FreeGamers
Member
Posts: 602
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

Re: [mod] Torch bombs! [torch_bomb] 0.4

by FreeGamers » Post

My players made me aware of a bug when torch bombs are detonating. I've copied the stack. 5.2.0-dev from a month or two ago.

Code: Select all

2020-03-07 12:43:35: ERROR[Main]: ServerError: AsyncErr: ServerThread::run Lua: Runtime error from mod 'default' in callback node_on_timer(): ...x/bin/../mods/lib_player/awards/src/api_triggers.lua:155: assertion failed!
2020-03-07 12:43:35: ERROR[Main]: stack traceback:
2020-03-07 12:43:35: ERROR[Main]:       [C]: in function 'assert'
2020-03-07 12:43:35: ERROR[Main]:       ...x/bin/../mods/lib_player/awards/src/api_triggers.lua:155: in function 'notify_place'
2020-03-07 12:43:35: ERROR[Main]:       ...linux/bin/../mods/lib_player/awards/src/triggers.lua:98: in function 'callback'
2020-03-07 12:43:35: ERROR[Main]:       ...inetest-5.2.0-dev-linux/bin/../builtin/game/item.lua:390: in function <...inetest-5.2.0-dev-linux/bin/../builtin/game/item.lua:258>
2020-03-07 12:43:35: ERROR[Main]:       (tail call): ?
2020-03-07 12:43:35: ERROR[Main]:       ...ux/bin/../games/minetest_game/mods/default/torch.lua:66: in function 'torch_def_on_place'
2020-03-07 12:43:35: ERROR[Main]:       ...-dev-linux/bin/../mods/lib_items/torch_bomb/init.lua:312: in function 'kerblam'
2020-03-07 12:43:35: ERROR[Main]:       ...-dev-linux/bin/../mods/lib_items/torch_bomb/init.lua:455: in function <...-dev-linux/bin/../mods/lib_items/torch_bomb/init.lua:445>
Here is some actions preceding another crash:

Code: Select all

2020-03-07 13:56:22: ACTION[Server]: REDACTED places node torch_bomb:torch_bomb_rocket at (-1667,11,-330)
2020-03-07 13:56:22: ACTION[Server]: facedir: 2
2020-03-07 13:56:26: WARNING[Server]: active block modifiers took 201ms (processed 368 of 388 active blocks)
2020-03-07 13:56:26: ACTION[Server]: BBG uses fire:flint_and_steel, pointing at [node under=-1667,11,-330 above=-1667,12,-330]
2020-03-07 13:56:28: WARNING[Server]: active block modifiers took 201ms (processed 339 of 388 active blocks)
2020-03-07 13:56:36: WARNING[Server]: active block modifiers took 202ms (processed 348 of 388 active blocks)
2020-03-07 13:56:36: ACTION[Server]: TNT owned by  detonated at (-1667,35,-330) with radius 1
2020-03-07 13:56:36: ACTION[Server]: A TNT explosion occurred at (-1667,35,-330) with radius 1
2020-03-07 13:56:36: ACTION[Server]:  detonated a torch bomb at (-1667,35,-330) and placed 13 torches.
2020-03-07 13:56:36: ACTION[Main]: Server: Shutting down

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.4

by FaceDeer » Post

This is a result of a bug in the awards mod, not torch_bomb itself. I've encountered this before with Digtron.

The problem is that "place_item" is being called in some circumstances by the bomb itself when placing torches, not by a player directly. I try to preserve the responsibility for the player who sets off the bomb, the bomb "remembers" who lit it whenever possible and uses that player reference when calling place_item, but it's not always possible to do so. For example if a torch bomb gets lit by a nearby fire, or a burning trail of gunpowder.

In those circumstances I should be able to just call place_item with a nil player reference, the Minetest API says this is explicitly allowed. I quote:
on_place = function(itemstack, placer, pointed_thing),
-- Shall place item and return the leftover itemstack.
-- The placer may be any ObjectRef or nil.
-- default: minetest.item_place
But some mods don't take this into account and assume that "placer" must always be an actual player, and crash when it's nil or not a player.

I've tried to account for bad coding in other mods with the "fakeplayer" class (you can find it in class_fakeplayer.lua), which is a table that provides the same function calls as a player and attempts to return safe (if useless) values for calls that are made to it. But the problem with Awards specifically is on api_triggers.lua line 155.

Where there's this check:

Code: Select all

assert(player and player.is_player and player:is_player() and key)
fakeplayer returns "false" for the is_player() call, since it's not actually a player, and the "assert" call essentially tells Minetest "I want to crash if is_player() is false." I'm not going to change fakeplayer to lie about that. The real solution here is to fix awards to not assert in this case but to cleanly ignore non-player callbacks when they come along.

I've raised this issue with Rubenwardy before, here's the issue. I'll try poking him again about it. In the meantime, replace the assert with this:

Code: Select all

if not (player and player.is_player and player:is_player() and key) then return end
And that should fix it, I believe.

User avatar
FreeGamers
Member
Posts: 602
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

Re: [mod] Torch bombs! [torch_bomb] 0.4

by FreeGamers » Post

I figured it had something to do with awards but thought maybe it was the compatibility for awards in your mod.

My initial workaround for this was to disable awards, not torch_bomb.

Now after hearing your explanation, I'm deciding to just not include awards. Its a nice mod, but I've always found that concept to be a bit superficial anyways. Sounds like it might make things a bit more robust anyways.

FaceDeer
Member
Posts: 464
Joined: Sat Aug 29, 2015 19:01
GitHub: FaceDeer

Re: [mod] Torch bombs! [torch_bomb] 0.4

by FaceDeer » Post

Okay, if you're sure you don't want awards for other reasons. But if this bug is the only reason you're removing it, it's a trivial one-line fix to incorporate into your own fork and I'd recommend doing that.

I actually have a fork of my own with a branch where I fixed it, I submitted it way back when as a pull request to Rubenwardy. I have no idea why he hasn't accepted the fix, and unfortunately my fork is probably a bit stale now, but maybe it'd work for you.

User avatar
FreeGamers
Member
Posts: 602
Joined: Sat May 25, 2019 00:15
GitHub: is proprietary I use NotABug
Location: United States
Contact:

Re: [mod] Torch bombs! [torch_bomb] 0.4

by FreeGamers » Post

After pondering this for a bit, I think I was too quick to remove it. It adds a bit of flavor for some of the players. Its not for me, but if others might find it fun, I'll keep it around. I'm going to use your branch-fix. Thnx

User avatar
Sokomine
Member
Posts: 4045
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine

Re: [mod] Torch bombs! [torch_bomb] 0.4

by Sokomine » Post

Ohhh! That's a great idea! Please - I'd love to see this mod on as many servers as possible. Let there be light in caves :-) (and: self-extinguishing torches are illegal of course!)
A list of my mods can be found here.

User avatar
Nathan.S
Member
Posts: 1003
Joined: Wed Sep 24, 2014 17:47
GitHub: NathanSalapat
IRC: NathanS21
In-game: NathanS21
Location: Bigsby Texas
Contact:

Re: [mod] Torch bombs! [torch_bomb] 0.4

by Nathan.S » Post

I was able to collect lit torch bombs when they were destroyed from nearby explosions. Is that intentional, or should they drop the non-burning variant?
I record Minetest videos, Mod reviews, Modding tutorials, and Lets plays.
Check out my website, and brand new Minetest Modding Course

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests