Roads of Daggerfall

Show off your mod creations or just a work in progress.
l3lessed
Posts: 476
Joined: Mon Aug 12, 2019 4:32 pm
Contact:

Re: Roads of Daggerfall

Post by l3lessed »

Yeah, this is going to require going at the engine script files and recoding the c# code. From having to learn c# from scratch to code for this engine, and not being a professional coder, I can say it wasn't really too hard to pick up and start figuring out, as long as you know the basics of coding languages and how they tend to function.

If you need some assist with the c# coding, let me know. I'm just stuck on one last problem on my project, so I can put my attention on something else, while I try to find a solution to my issue.

For the slope smoothing, could you use a unity lerp calculator to automatically calculate the difference between the two points and smooth it out? You could even use differing math calculators to simulate different terrain sloping based on the type of land it is. Sand would have a large arc to simulate a slow, soft slop. Granite would have a sharp short arc to simulate the hard rock and humans manually cutting it.

https://chicounity3d.wordpress.com/2014 ... ike-a-pro/

I was able to use mathf.lerp to calculate the offset distances of sprites using a dynamic variable based on weapon speed and max amount of offset frames allowed.
My Skyrim Mods: l3lessed Nexus Page

Daggerfall Unity mods: Combat Overhaul Mod

Enjoy the free work I'm doing? Consider lending your support.

User avatar
BadLuckBurt
Posts: 568
Joined: Sun Nov 05, 2017 8:30 pm

Re: Roads of Daggerfall

Post by BadLuckBurt »

l3lessed wrote: Thu Dec 05, 2019 8:48 pm Yeah, this is going to require going at the engine script files and recoding the c# code. From having to learn c# from scratch to code for this engine, and not being a professional coder, I can say it wasn't really too hard to pick up and start figuring out, as long as you know the basics of coding languages and how they tend to function.

If you need some assist with the c# coding, let me know. I'm just stuck on one last problem on my project, so I can put my attention on something else, while I try to find a solution to my issue.

For the slope smoothing, could you use a unity lerp calculator to automatically calculate the difference between the two points and smooth it out? You could even use differing math calculators to simulate different terrain sloping based on the type of land it is. Sand would have a large arc to simulate a slow, soft slop. Granite would have a sharp short arc to simulate the hard rock and humans manually cutting it.

https://chicounity3d.wordpress.com/2014 ... ike-a-pro/

I was able to use mathf.lerp to calculate the offset distances of sprites using a dynamic variable based on weapon speed and max amount of offset frames allowed.
C# is easier than I expected it to be, I still make beginners mistakes but with help from Hazelnut I haven't gotten stuck once, I just need someone more experienced to make sure I don't do stupid stuff :)

I do regret not paying attention during the higher math classes I had :lol: I've just been trying out different things and learning from them, not an easy process but it's starting to pay off. Reading a lot about terrain generation helps too, I'm having a hard time finding new articles.

I have an idea on how to approach the sloping but I won't know if it works until I try and I have enough to wrap up before I get started on that, the next rabbithole so to speak. You have a good point, it will probably look best if the different terrains use different functions for falloff. I'll definitely give that link a good read, who doesn't want to lerp like a pro
Daggerfall Unity on UESP: https://en.uesp.net/w/index.php?title=T ... fall_Unity
Daggerfall Unity on Nexus Mods: https://www.nexusmods.com/daggerfallunity
My github repositories with mostly DFU related stuff: https://github.com/BadLuckBurt

User avatar
jayhova
Posts: 720
Joined: Wed Jul 19, 2017 7:54 pm
Contact:

Re: Roads of Daggerfall

Post by jayhova »

A reminder: The path a road takes is determined by its worth vs. cost.

A road's worth can be determined by how easy it is to get goods to market. Does the road avoid any steep inclines that would make using wagons impractical? Is the road reasonably short? How much added commerce does the road bring?

A road's cost can be determined by the length of the road segment necessary to connect to the target settlement. The amount of terrain modification needed to construct said segment and keep it within a useable grade.
Remember always 'What would Julian Do?'.
Windows 10 Pro 64 bit. DFU Ver. Alpha 0.10.7

meritamas
Posts: 95
Joined: Sun Apr 07, 2019 6:16 am
Location: Slovak Republic

Re: Roads of Daggerfall

Post by meritamas »

Happy New Year, everyone! :)

I have a strong feeling 2020 will be the year we'll have a playable Roads mod ready for DFU.

What follows is the Daggerfall base heightmap with the population centers - the cities - denoted. Big thanks to BadLuckBurt for supplying me with the location data, heightmaps (1000x500 and 5000x1000) and advice on how to interpret these. (I hope I didn't forget anything.)
.
daggerfallHeightmapwithcities.png
daggerfallHeightmapwithcities.png (1.05 MiB) Viewed 880 times

The next picture shows a map of the Daggerfall region, with some roads drawn into it. It's far from perfect (which it will never be), but also far from finished (which I hope it will be soon).

It only shows what it would like to connect - via drawing a straight line between the two locations.
I also started implementing a version of the A* algorithm to actually place roads between two points more properly. Will try to incorporate as many features as I can that contribute to the road network being as realistic as possible.
.
DaggerFallRegion1.png
DaggerFallRegion1.png (294.91 KiB) Viewed 880 times
.

The code that generated this works roughly like this (there might be small, not obvious bugs) :
  • First come the cities. For each city, the nearest city negihbor in the given directions is found. (each direction includes 90 degrees inclusive, so a city that is +100 points on the X coordinate and -50 points on the Y coordinate counts as a North-East neighbor and also as an East neighbor, one at +50 points on the X coordinate and -50 points on the Y coordinate would count as a NE, a N and an E neighbor, while one +100 on the X and 0 difference on the Y would count as an E, a NE and a SE neighbor). A city could theoretically have as much as 3-4 closest neigbors, each in different directions compared to the others.
  • Then come some lines between the neighbors. For each city, a line to the nearest neighbor. Then, if the route would not be too long compared to the average intercity line length, another, then, another etc. A maximum of four.
  • Then, all the things that are not cities. These are divided into groups (spheres of influence) based on the closest city.
  • Each NonCity needs to be directly or indirectly connected to the city central to the group. First, the towns are connected. Then each further location in turn is connected to the already connected location in the group that is closest to it. The locations closer to the city are connected first.
  • At this point, the intercity and the intra-group connections are generated independently of each other. This means that the smaller roads ignore that there is an IC road nearby.
On my laptop, all this runs in under a second - around half a second to be more precise.

I also learned a lot in the process of working with the map images, the location data and writing the code. I am optimistic now. I think it is possible to place roads on the Daggerfall map well enough with a code that doesn't take forever to run. I think I will be able to find the time in the first half of 2020 to get this part done.

About actually placing the roads into StreamingWorld, that's another challenge. Not trying to push anybody into anything they wouldn't otherwise do, I hope BadLuckBurt with possible help from others will be able to tackle this part (or, at least, help with it). In the mean time, I will try to get more familiar with this part too, but for the moment, I feel my skills are more productive working on the road placement part. Hope to be back with news of more progress around the end of January.
Interest in expanding and improving the Magic system, Capitalism and an Unleveled World.

Planning to return to Roads too in the coming months.

User avatar
pango
Posts: 2549
Joined: Wed Jul 18, 2018 6:14 pm
Location: France
Contact:

Re: Roads of Daggerfall

Post by pango »

I see some issues (like roads crossing bodies of water), but it's otherwise looking great, keep up the good work!
When a measure becomes a target, it ceases to be a good measure.
-- Charles Goodhart

User avatar
Seferoth
Posts: 555
Joined: Fri Nov 22, 2019 5:45 pm
Location: Finland

Re: Roads of Daggerfall

Post by Seferoth »

pango wrote: Wed Jan 01, 2020 11:38 am I see some issues (like roads crossing bodies of water), but it's otherwise looking great, keep up the good work!
We need to start building bridges then. :D
You can't have a nightmare if you never dream.

meritamas
Posts: 95
Joined: Sun Apr 07, 2019 6:16 am
Location: Slovak Republic

Re: Roads of Daggerfall

Post by meritamas »

pango wrote: Wed Jan 01, 2020 11:38 am [...] it's otherwise looking great, keep up the good work!
Thanks, will endeavor to.
pango wrote: Wed Jan 01, 2020 11:38 am I see some issues (like roads crossing bodies of water) [...]
Seferoth wrote: Wed Jan 01, 2020 12:13 pm We need to start building bridges then. :D
:D

I'm currently not planning for bridges, but if the envisioned generation algorithm works in practice, it should only require some adjustments in the parameters to have it consider this option as well (like with very high costs associated with placing roads over water tiles).

The lines in the current picture only denote that the algorithm has determined that the two places need to be connected. Straight lines are used for the lack of a better solution so far.

The implementation of a proper road-placer algorithm is under way and that will solve this issue and more. I'll give just one example: the presence of water between two locations sometimes makes a connection impossible but not always. It might make it only less attractive than our current simple heuristic - distance on the map - would indicate (because you need to go around the body of water, which a longer route). This should also have an effect on which locations are connected in the first place.
Interest in expanding and improving the Magic system, Capitalism and an Unleveled World.

Planning to return to Roads too in the coming months.

User avatar
ByteMixer
Posts: 123
Joined: Sun Mar 25, 2018 4:43 am
Location: Philadelphia, PA, USA
Contact:

Re: Roads of Daggerfall

Post by ByteMixer »

Nice to see some potentially tangible progress on this. Aside from some of the odd water crossings, i'm seeing some shapes in places that don't make a lot of sense, but I'm sure the algorithm can be fine tuned to clean some of those up. Looking forward to the rest of this year, then! Wishing you the best of luck in this endeavor.
"Whatever you do, make good art." - Neil Gaiman

chtujo
Posts: 48
Joined: Fri Sep 22, 2017 12:54 am

Re: Roads of Daggerfall

Post by chtujo »

This looks really cool, I can't wait to see this stuff in-game.

chtujo
Posts: 48
Joined: Fri Sep 22, 2017 12:54 am

Re: Roads of Daggerfall

Post by chtujo »

Something extra I'd like to add to this - IMHO Daggerfall is in need of an updated heightmap. The old one only stores a few different height levels, and is rather low resolution. If possible, it would be good if this mod was designed so that it can easily be re-run on a new heightmap if it were to be released, with minimal manual adjustment.

Post Reply