[Mod]Smoke [WIP]

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

Re: [Mod]Smoke [WIP]

by texmex » Post

I think there need to be alot of smoke for the node timer approach to start to lose its effeciency.

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

Version 0.2 is out:
  • Merged Texmex' animated smoke texture. This is not related, but I discovered visual glitches when the smoke is next to a liquid which is due to transparency (the docs are very clear about the fact that it may occur), so I disabled transparency by default. At least Texmex' animation compensate for that loss.
  • Added a "smog", a type of smoke that spreads horizontally first. Nothing produces this type of smoke currently. Also, I'm not too interested in it currently, so I've not tested it much.
  • Split the source into a library part that implement the smokes behavior and its application that adds smoke to nodes in the "smokey" group. It also puts a couple of likely smoke sources (furnaces, lava, fire) in this group. I didn't go as far as putting each in a separate file, I didn't see the point of it.
Next, I'm considering turning the mod's parameters into proper settings. I'm not decided yet, cause as a game maker settings have been of very little use to me. I prefer to edit manually the source files because the settings are saved outside of the game source tree (therefore I doubt they are even per-game). There's mod_storage... But then you lose the UI.

User avatar
BuckarooBanzay
Member
Posts: 435
Joined: Tue Apr 24, 2018 05:58
GitHub: BuckarooBanzay
IRC: BuckarooBanzai
In-game: BuckarooBanzai

Re: [Mod]Smoke [WIP]

by BuckarooBanzay » Post

I tested that with commit 238a2548a1b834a9db04a5ee8ef4aac51284b246 (https://gitlab.com/Astrobe/minetest-smo ... c51284b246)

The "factory":

Image
Image
Image

The results:
Image
Link: https://monitoring.minetest.land/d/YUpo ... 8744390708

Looks good: with something over 100 furnaces and around 500 smoke nodes only 15 milliseconds are needed for the nodetimers, at most..

Good job :)
¯\_(ツ)_/¯ Not active here anymore, contact me on the minetest discord, irc, lemmy or github (for programming issues)

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

Thank you! I checked performances only with the task manager, so it's nice to see actual figures.

I didn't mention that we lost with this update the occasional "collisions" that make some nodes deviate from the straight upwards route. One could tweak the parameters to make it happen again but it would only work near the source. I'll try to do something about it. This is tricky to do because you don't want to take smoke in the face near your furnaces too often.

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

Re: [Mod]Smoke [WIP]

by texmex » Post

That doesn't look healthy at all but sure looks beautiful, BuckarooBanzay. Looks like the node timer approach was good for it still.

I'll be sure to check out the smog smoke type eventually!

micheal65536
Member
Posts: 167
Joined: Mon May 22, 2017 20:27

Re: [Mod]Smoke [WIP]

by micheal65536 » Post

Astrobe wrote:
micheal65536 wrote:
Astrobe wrote:The source ABM is innocent, the CPU activity mainly varies with the number of smoke nodes (timers only).
I haven't done any particular testing on this but this has been my anecdotal experience, anyway. It might be worth trying your mod with ABMs rather than node timers and doing a comparison to see which method is actually faster.
Maybe I'll try this, but one drawback I immediately see is that all smoke nodes will be updated at once (similar to what I had prior the introduction of update jitters), causing "spikes" of activity.
Discussions regarding efficiency aside, you could possibly solve this problem by introducing a random chance in the ABM. That way, only some nodes get updated each time.

So for example if you want each smoke node to move on average once every 20 seconds, you could set the ABM interval to 10 seconds and the chance to 0.5 (2) for some variation/randomisation, or you could set the interval to 5 seconds and the chance to 0.25 (4) for even more variation. Basically, decide how many separate "groups" of updates you want (except that they aren't groups, because each node individually has a chance of updating on any cycle), set this as the "chance" parameter for the ABM, then take your desired average update interval and divide it by this number and set this as the interval.

One drawback is that this could cause smoke to move somewhat erratically, like it'll move quickly for a bit and then sit still for a while rather than moving at a near-constant rate, particularly with higher chance settings. I'm not sure what sort of aesthetic you're aiming for so I'm not sure how much of a problem this would be or if you could work around it (perhaps by defining multiple smoke nodes: a "fast" one, a "medium" one, and a "slow" one that move it different speeds?).

Personally, if you're experiencing performance issues, I'd be inclined to try changing node timers for ABMs and see if the performance improves and if you can still achieve the aesthetic that you want.

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

Version 0.3:

- introduces a WIND parameter that make smoke blocks randomly move laterally on occasions.
This parameter should not be set too high, otherwise it could be a nuisance near furnaces. Contrary to what the parameter name suggests, there's actually no preferred direction.

- The lifespan of the smoke nodes depends on altitude.
This feature was introduced mainly to avoid having "dead" smoke blocks in the sky near the active_block_range boundary (timers and ABMs are frozen outside of this range). These blocks are not actually dead, they'll move again if a player comes close enough from them.

The feature has the pro or cons that it makes the lifespan of smoke underground longer. This could turn deep underground lava lakes into fearsome smoke generators. I did not yet test this in a real scenario. It could make access to lava lakes an interesting "ventilation engineering" challenge, or make lava lakes in narrow caves inaccessible.

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

Re: [Mod]Smoke [WIP]

by texmex » Post

Nice additions, especially the wind. There’s another mod also dealibg with wind now, Sailing Kit. Ideal would be to have them pull wind data from the same source. =)

Termos
Member
Posts: 417
Joined: Sun Dec 16, 2018 12:50

Re: [Mod]Smoke [WIP]

by Termos » Post

texmex wrote:Nice additions, especially the wind. There’s another mod also dealibg with wind now, Sailing Kit. Ideal would be to have them pull wind data from the same source. =)
Definitely, with that in mind there's a separate entry point for that in sailing_kit, the function get_wind(). It can be overriden to take wind data from any source, as long as it returns a single vector with length scaled to meters per second.

Grubler
Member
Posts: 98
Joined: Wed Nov 06, 2019 03:01
In-game: Grubler

Re: [Mod]Smoke [WIP]

by Grubler » Post

Would it be possible to make it so torches also make smoke?

Also while being held?

User avatar
Diamond knight
Member
Posts: 475
Joined: Sun Apr 19, 2015 19:50
GitHub: Diamondknight
In-game: Ferrumprinceps
Location: Chilling in Constantinople
Contact:

Re: [Mod]Smoke [WIP]

by Diamond knight » Post

This could possibly work well for the gas attacks in my abandoned WW1 warfare mod.

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

Grubler wrote:Would it be possible to make it so torches also make smoke?

Also while being held?
The second request is difficult to do, because one has to place the smoke node above the torch which is not aligned with a node when held by a character; placement would have to be computed smartly so that the node is not placed "in the face" of the character yet "near enough" the torch.

The first request is much easier to do. I did not include torches as smoke the generators because the smoke node is a bit disproportionate compared to the torch and it is probably too inconvenient.

There's a simple way to do it, add "default:torch" in the list near the bottom of init.lua (e.g. next to "default:lava_source").

However I suspect you will want to adjust the smoke generation rate. So instead, copy this code at the end of init.lua:

Code: Select all

	
minetest.register_abm{
		label="Smoke",
		nodenames= {"default:torch"},
		neighbors={"air"},
		interval=7,
		chance=1,
		action=function(pos)
			local p=minetest.find_node_near(pos, 1, "air")
			if p then smoke.add(p) end
		end
	}
I didn't test it, but it should work as expected (famous last words).

Adjust "interval" to your liking - it tells Minetest to generate a smoke node every N seconds (here: 7). Alternatively you can adjust the "chance" property (e.g. if you change it to 2, there will be 50% chance to generate smoke every 7 seconds).

Also please note that if you are using fancy torch mods, you might have to change the "nodenames" property to fit the internal name of the fancy torch introduced by the mod.

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

I have pushed a minor update that makes smoke nodes "floodable" (stupid typo in the commit, won't go out of my way to fix it because it probably involves doing things hazardous that one should never do on a public repo), that is they are deleted by water or lava floods. I also have switched from lava_source to lava_flowing as a smoke generator for lava.

The former change was mainly done because of the peculiarities of my game: I use falling water as a way to cool down lava to get ores. Smoke nodes became trapped or blocked flowing water, which is not very natural. The later change was made in the hope to make lava lakes generate a bit less smoke, as I expect that in general there are more "source" lava nodes than flowing lava in caves.

As for wind, the proposals made here are still on my mind, but I see it as tricky to do right and it is not really a priority.

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

Re: [Mod]Smoke [WIP]

by FreeGamers » Post

I installed this in my server today and havent noticed much of a performance impact. A couple players have asked about it but seem a bit intrigued by it once they learn what the floating smoke nodes are.

One player built chimney with iron bars and is trying to get blocks to pass through bars and trapdoors. Perhaps sometime if it makes sense, you could find some sort of blocks that could be considered as pass-through-able.
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

FreeGamers wrote: One player built chimney with iron bars and is trying to get blocks to pass through bars and trapdoors. Perhaps sometime if it makes sense, you could find some sort of blocks that could be considered as pass-through-able.
Nice to hear that this mod is on a server other than mine ;-)

This is definitely a drawback of using this method, just like a simple flower or bamboo can block smoke.

Making certain nodes pass-through would be expensive if it is a decision made by the smoke nodes. However, what we could do is make some nodes "pump" smoke nodes from one of their sides to the other. Certainly some of the tech mods have ventilators or fans, they would be perfect for this. This requires for these nodes to have an "orientation" (facedir property or something like that) though.

This could become a companion mod. It would offer an API to let modders override some nodes so they act as "smoke pumps". One technical advantage I see is that it could be done with node timers instead of yet-another-ABM.

I'm not sure I'll be able to craft a proof-of-concept in a decent time. If anyone wants to do it, they are welcome.

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

Re: [Mod]Smoke [WIP]

by FreeGamers » Post

I think FaceDeer did something like this with his dynamic_liquids mod.

https://github.com/minetest-mods/dynami ... #L190-L300

I'm not sure if its been implemented fully or not, but this could be a similar concept. I'm heavily working on a big christmas mod right now or I'd explore more.
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

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

Re: [Mod]Smoke [WIP]

by FreeGamers » Post

Its been close to a month now, the smoke mod has generally been pretty well recieved. A few questions are asked when people first encounter it like what is it. But once they are familiar with it, I've seen positive feedback on it. Its a cool dynamic system.

I have volcanoes and magma conduits in my world and the amount of smoke those can produce is a lot, but its still fun because if you are mining underground, it becomes a fun hazard in survival mode to not die from smoke in enclosed spaces. I've also seen some players build houses with furnaces that have chimneys.

Would it make more sense to only cause the smoke to suffocate players like water or vacuum instead of outright damaging them? That would make things more realistic in my opinion. No major complaints though.
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

FreeGamers wrote: I have volcanoes and magma conduits in my world and the amount of smoke those can produce is a lot, but its still fun because if you are mining underground, it becomes a fun hazard in survival mode to not die from smoke in enclosed spaces. I've also seen some players build houses with furnaces that have chimneys.
Yes. I've tried to mitigate the issue with lava producing too much smoke by restricting smoke emission to flowing lava, but that only somewhat works in my game where another mod converts flowing lava to a lava source when there's a walk-able stone below.

Volcanoes must be cool with smoke, especially at night, but I can't have them in my game because of the previous feature that makes lava very flood-prone (that's actually the goal) and even more devastating, considered I also have fire fully enabled.
Would it make more sense to only cause the smoke to suffocate players like water or vacuum instead of outright damaging them? That would make things more realistic in my opinion. No major complaints though.
It is true that I have found myself in irreversible situations where I could not extinguish a source of smoke unless going without armor (to avoid armor wear) and consume a whole stack of food in the process.

Smoke nodes are actually both "drowning" (suffocating) and damaging nodes. I added the damaging part because I was not satisfied with how drowning worked and the API gives little control over it.

I am inclined to make them suffocating only by default. I'll test the change in my game to see if it doesn't make the smoke worthless as a hazard. If it does, maybe I can kind of replace this hazard by something else - maybe strongly reduced visibility.

In any case, you can comment-out the line "damage_per_second=1" in the definition of "smoke:block" (and maybe "smoke:smog" if you use it) to remove the damage part, the change will take effect immediately after reload, including the existing nodes.

This is the type of thing that calls for the creation of proper settings, but I've been reluctant to do that work because they always have been of little use for me; most often I ended up hacking other's mods directly anyway.

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

Re: [Mod]Smoke [WIP]

by FreeGamers » Post

I think removing damage per second would make it less of a hazard but I think that would still keep it a hazard while going underground and coming accross lava areas. In my opinion that would be sufficient. I also think the visibility in the smoke nodes is quite good already. I personally just don't find the 1 DPS instantly as sensible. Too game-y even though that is what we are making here :)

Its up to you, I will likely end up removing it from my server through a custom change if its not removed in master.
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

I pushed version 0.4.

Opacity and damage per second for both smoke types are now mod constants for easy tuning.

By default, damage is disabled.

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

BTW, is your server public, FreeGamers? I would like to see those volcanoes.

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

Re: [Mod]Smoke [WIP]

by FreeGamers » Post

I actually removed it from the lava nodes for now because it was really hitting the cpu hard, we had some lag problems.

I may try it again to verify if it is the lava + smoke that is causing it. But the public server is called "Sara's Simple Survival Server".
FreeGamers.org has moved to MeseCraft.net | FreeGamers on this forum is now MeseCraft

Astrobe
Member
Posts: 568
Joined: Sun Apr 01, 2018 10:46

Re: [Mod]Smoke [WIP]

by Astrobe » Post

I am interested in your findings about that. If it is not usable on servers I should definitely warn people about it. AFAIC I don't have enough simultaneous players to make meaningful tests.

It also occurred to me that, when you return to an area after a long time, all timers there will have expired and potentially would trigger all at the same time, which might cause lag.

I first suspected this could be the case because I had lags when returned to areas where I collected a lot of apples and berries, which are timer-based too. However, they could equally be caused by disk loading (I have an aging HD).

Germain
Member
Posts: 42
Joined: Thu Aug 13, 2015 10:16

Re: [Mod]Smoke [WIP]

by Germain » Post

I keep the smoke with lava. It's funny, and I didn't see any lag, but was only two players.

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

Re: [Mod]Smoke [WIP]

by FaceDeer » Post

FreeGamers wrote:I actually removed it from the lava nodes for now because it was really hitting the cpu hard, we had some lag problems.
If you think it would help, I could add an option to the magma_conduits mod that would spawn a special kind of lava at the upper extent of a volcano's throat so that only volcanoes emit smoke.

This is a really nice mod. I've done some related work myself in the past - the dynamic_liquid stuff mentioned earlier in this thread, and also a heavier-than-air flammable/suffocating gas in the mine_gas sub-module of dfcaverns. I have generally favoured ABMs for this kind of thing because it seems like that's the role ABMs are specifically designed for, so effective optimizations can be done engine-side that will help my code. But I've not done much experimenting with profiling.

I like adding interesting hazards to the underground of the world and I think I'm going to have fun with this one. The Magma Sea cavern layer of DFCaverns might be about to get even more dangerous in future updates. And the Torchspines in the Black Cap cavern layer, too. :)

Post Reply

Who is online

Users browsing this forum: No registered users and 9 guests