Dwarf Fortress like ramps in Minetest

Post Reply
BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

If you're familiar with Dwarf Fortress, you know what I'm talking about, in case if not, here is a short explanation.

Dwarf Fortress is a real-time strategy/adventure game. Even though the concepts of Dwarf Fortress and Minetest are vastly different, but they share the same terrain idea: a voxel based approach. But Dwarf Fortress has ramps, Minetest does not.

So, after some hard thinking I came up with with this experiment which allows to generate ramps in Minetest during the world generation phase. Keep in mind that this is inly a proof of concept and can not be applied to other subgames/mods easily. I might find the time later to see if I can bring it into a form that makes it easily re-usable.

Here is a screenshot showing the ramps with meshes.
Image

And this one is showing the ramps as nodeboxes, with a detail level of 6.
Image

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: Dwarf Fortress like ramps in Minetest

by paramat » Post

Interesting and looks good, i once made a mod that placed halfslabs to make terrain walkable.
Reading your code, you actually can set node rotation fast using the luavoxelmanip, set_node is extremely slow. See my flexrealm mod to see how viewtopic.php?f=11&t=7887 i use it to set rotation of trees and leaves.

Sokomine
Member
Posts: 4317
Joined: Sun Sep 09, 2012 17:31
GitHub: Sokomine
IRC: Sokomine
In-game: Sokomine

Re: Dwarf Fortress like ramps in Minetest

by Sokomine » Post

Looks very nice. In the screenshots, the nodebox-variant looks even better. I think this depends on the uniform texture, where the eye desperately seeks some contrast, and will look quite diffrent with the normal dirt texture without borders.

Paramats half-step mapgen was a very intresting experiment as well, though it did not work as good as I had hoped it would. The diffrent lighting of the half-steps and the difficulty when i.e. placing a plant on them didn't work out convincingly in the end. Slopes may be diffrent in that regard. They're now supported by the engine, and their predecessors have been used extensively on Landrush for landshaping - which turned out to look very good.

Maps may look best if only a part of the nodes get converted to slopes. Some steep walls here and there amongst the smooth slopes make the world far more intresting.

The problem with other nodes on top of the slopes remains. Digging them may yield a full dirt block and thous cause no trouble at all. But placing a plant on a slope most likely won't look good. Maybe the slope ought to convert itself into a full node if something is placed on top.
A list of my mods can be found here.

BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Re: Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

@paramat Thank you very much, I completely missed it when looking for it.

@Sokomine Thank you. At the moment the meshes/nodeboxes is determined upon start and can be changed without having to regenerate the map, so testing different settings is very easy (if you want to try it out, see the parameters.lua).

Placing something on top will of course not look nicely. Changing the ramps on the fly would be a solution, of course, that can easily be implemented on a node by node basis, if I remember correctly.

I'll see if I can extract the logic into a separate utility that can be easily re-used in other mods...but I don't know how to fix the map block problematic now.

BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Re: Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

I have extracted the logic into an easily reusable util repository...or at least I hope that it is easy to use. It allows to create and automatically place ramps, even in an already existing subgame. The system has also learned to place ramps at the ceiling, great for caves.

It looks a little odd because the textures are not made for the ramps, that's why they are a little stretched.

Here are a few more screenshots, taking in minetest-game:

Image
Image
Image
Image
Image
Image

User avatar
Krock
Developer
Posts: 4692
Joined: Thu Oct 03, 2013 07:48
GitHub: SmallJoker
Location: Switzerland
Contact:

Re: Dwarf Fortress like ramps in Minetest

by Krock » Post

BobbyBonsaimind wrote:I have extracted the logic.. <snip>
Yes, the nodebox type looks much better and fits to Minetest.
There's a problem when players dig a ramp - the ramps do not "regenerate" automatically.
Look, I programmed a bug for you. >> Mod Search Engine << - Mods by Krock - DuckDuckGo mod search bang: !mtmod <keyword here>

BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Re: Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

Yes, for the time being it is only applied if a map block is generated. You'd have to register an ABM or callback to the node you'd want to automatically turn into a ramp, "rampgen.run_on_node" is the function which can be applied to single nodes...I added an example to the README.

Though, the API is at the moment a little bit complicated with the lookup table that is required, but I didn't have a better idea.

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: Dwarf Fortress like ramps in Minetest

by paramat » Post

Stunning.

User avatar
ExeterDad
Member
Posts: 1717
Joined: Sun Jun 01, 2014 20:00
In-game: ExeterDad
Location: New Hampshire U.S.A

Re: Dwarf Fortress like ramps in Minetest

by ExeterDad » Post

@BobbyBonsaimind
Without looking at your models... I think the odd shading on the corners of the ramps is cause by not exporting your normals when exporting the .obj

The engine won't know how to treat the lighting on the mesh without them. I ran into this when helping Don out with the myroofs and mypaths mods. I was pulling my hair out for days trying to figure out what was wrong with the meshes and why there was this mysterious "shading"

BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Re: Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

@ExeterDad Thank you very much, I already thought that there was something wrong with the normals, but did not think about that they might not have been exported.

Some more pictures with the fixed normals:

Image
Image
Image
Image

User avatar
paramat
Developer
Posts: 3700
Joined: Sun Oct 28, 2012 00:05
GitHub: paramat
IRC: paramat
Location: UK

Re: Dwarf Fortress like ramps in Minetest

by paramat » Post

That looks good, i actually prefer the ramps to stepped nodeboxes

User avatar
LionsDen
Member
Posts: 530
Joined: Thu Jun 06, 2013 03:19

Re: Dwarf Fortress like ramps in Minetest

by LionsDen » Post

Yeah, I prefer the ramps as well.

User avatar
Wuzzy
Member
Posts: 4947
Joined: Mon Sep 24, 2012 15:01
GitHub: Wuzzy2
IRC: Wuzzy
In-game: Wuzzy
Contact:

Re: Dwarf Fortress like ramps in Minetest

by Wuzzy » Post

Well, that's cool. I like the idea. This reminds me of OpenTTD. :-)

BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Re: Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

@wuzzy Yeah, me too, it also reminds me a lot of older games like Half Life, especially when walking through the terrain.

red
Member
Posts: 30
Joined: Sun May 03, 2015 08:18

Re: Dwarf Fortress like ramps in Minetest

by red » Post

Where can I download the version for minetest_game?

BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Re: Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

@red There is no package, you'll have to do it yourself. Here is a very simple variant that will only place ramps during worldgen, you will not be able to place it again afterwards:

1. Get the worldgen-utils and utils mods and pace them in the minetest_game/mods directory.
2. Create a new directory in minetest_game/mods named "mtg_ramps".
3. Create in that directory the files "init.lua" and "depends.txt".

Now to the content of said files, depends.txt:

Code: Select all

worldgen_utils
utils
default
And init.lua:

Code: Select all

local function register_ramps(lookup_table, node_name)
	return tableutil.merge(
		lookup_table,
		ramputil.register_ramps_for_node(
			"default:" .. node_name,
			"mtg_ramps:" .. node_name,
			true,
			6
		)
	)
end


local ramped_nodes = {}

ramped_nodes = register_ramps(ramped_nodes, "desert_sand")
ramped_nodes = register_ramps(ramped_nodes, "dirt")
ramped_nodes = register_ramps(ramped_nodes, "dirt_with_grass")
ramped_nodes = register_ramps(ramped_nodes, "dirt_with_snow")
ramped_nodes = register_ramps(ramped_nodes, "ice")
ramped_nodes = register_ramps(ramped_nodes, "sand")
ramped_nodes = register_ramps(ramped_nodes, "snow")
ramped_nodes = register_ramps(ramped_nodes, "stone")

minetest.register_on_generated(function(minp, maxp, seed)
	local manipulator = MapManipulator:new()

	rampgen.run(manipulator, minp, maxp, ramped_nodes)

	manipulator:set_data()
end)
You'd need to register a callback for the place and dig functions if you want that the ramps are automatically created every time you place or dig a node. I'm not sure how that is possible, given that those nodes are already registered, I'd need to look into it. Also this method has the downside that the textures are kinda distorted.

User avatar
MirceaKitsune
Member
Posts: 982
Joined: Sat May 21, 2011 22:31
GitHub: MirceaKitsune
IRC: Taoki
In-game: MirceaKitsune
Location: Romania, Bucharest

Re: Dwarf Fortress like ramps in Minetest

by MirceaKitsune » Post

This is an amazing idea, thank you for doing it! It might actually work out as an alternative to my smooth voxel terrain idea, depending on how fast and complete this approach can be.

However, I cannot get it to work. I tried this as both a mod and a game, and it crashes as both.

That said, the thing I can say I don't like about this straight away is that it uses an individual node definition per corner. Is there no way to change the mesh or node box of an individual mesh yet, and can this be implemented? From what I know, a change was recently added that lets you modify the texture of an individual node placed in the world.

BobbyBonsaimind
Member
Posts: 97
Joined: Tue Apr 14, 2015 19:32
GitHub: RobertZenz
IRC: Robert_Zenz
In-game: Bobby

Re: Dwarf Fortress like ramps in Minetest

by BobbyBonsaimind » Post

I don't think that "alternative" is a great term, it really is something different, with similar intentions. I like your idea of a smooth terrain in the way you proposed and would like it to see it implement one day (I'm not sure if I could do it or find the time to do it, Marching Cubes seems quite straighforward to implement, but because of mechanics of Minetest there are a lot of corner cases to consider).

If you let me know the error with which it crashes, I might be able to pin point the issue.

I don't think that you can change a node on the fly, at least I could not find a good reference for it. However you can "link" these four nodes (normal plus three ramps) together in a way that it makes it appear like it is only one node to the player.

User avatar
Inocudom
Member
Posts: 3131
Joined: Sat Sep 29, 2012 01:14
IRC: Inocudom
In-game: Inocudom

Re: Dwarf Fortress like ramps in Minetest

by Inocudom » Post

BobbyBonsaimind, you have my thanks for undertaking such an ambitious project. If this feature ever makes it into Minetest, the results will be phenomenal.

Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests