[MOD] Basic Roads

A curated forum for compatible and maintained mods. Users are unable to create new topics in this forum but can reply to existing topics. Please message a moderator to have your mod moved into this forum area.
User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

[MOD] Basic Roads

Post by Hazelnut »

Basic Roads, by Hazelnut

Description

This mod adds roads and tracks to the world of Daggerfall, connecting towns and cities. Roads ring locations they intersect, since the roads don't line up with city gates. This is because the implementation is simple so that it adds very little overhead to the DFU terrain generation and should run on any system that can run the base game. Someone may create a fancy roads mod in the future I expect, which will require higher spec systems, but Basic Roads will always be available.

The roads are integrated with my other mod Travel Options allowing time accelerated travel along paths by pressing a configurable key to start and stop path following. The roads that encircle locations can be circumnavigated as well, and following will stop when a junction is reached. Following roads give all the benefits of cautious travel but without any speed penalty. Dirt tracks are not visible in winter when the ground is covered by snow, which is realistic, but not very user friendly so I plan to add a download with some textures to make them visible for anyone who wants that.

See the WIP forum thread for more details about how this works, as well as progress on adding roads and tracks to the various regions: viewtopic.php?p=46530

Other Mods - accessing path data

Other mods can access the path data for roads and tracks using these messages. Either request a copy of the entire byte array for the path type required, or query specific map pixel coordinates. Use the former if your mod needs constant access to the data, and the latter if you simply need to find out what paths are in a specific map pixel. (or a few) Path types and directions are defined as follows. The direction constants have the binary format in comments because it was not compatible with the MCS compiler. Zero means no paths in that map pixel.

Code: Select all

public const int path_roads = 0;
public const int path_tracks = 1;

public const byte N  = 128;//0b_1000_0000;
public const byte NE = 64; //0b_0100_0000;
public const byte E  = 32; //0b_0010_0000;
public const byte SE = 16; //0b_0001_0000;
public const byte S  = 8;  //0b_0000_1000;
public const byte SW = 4;  //0b_0000_0100;
public const byte W  = 2;  //0b_0000_0010;
public const byte NW = 1;  //0b_0000_0001;
To get a copy of the path data byte array, specifying the path type. This example requests the track data, and the Travel Options mod map window class gets both road and track data if you want more examples. The callBack receives a byte array of 500,000 bytes.

Code: Select all

ModManager.Instance.SendModMessage("BasicRoads", "getPathData", path_tracks, callBack);
To query a specific map pixel use one of the following three messages, supplying the pixel coordinates. The third message gets both road and track data or'ed together. The callback receives a byte of the path data point for that pixel.

Code: Select all

ModManager.Instance.SendModMessage("BasicRoads", "getRoadPoint", coords, callBack);
ModManager.Instance.SendModMessage("BasicRoads", "getTrackPoint", coords, callBack);
ModManager.Instance.SendModMessage("BasicRoads", "getPathsPoint", coords, callBack);
Example usage:

Code: Select all

Vector2Int coords = new Vector2Int(204, 204);
ModManager.Instance.SendModMessage("BasicRoads", "getRoadPoint", coords, 
	(string message, object data) => { Debug.LogFormat("Road point for ({0},{1}) is {2}", coords.x, coords.y, data); });
This prints "Road point for (204,204) is 9" and 9 means road leads North West and South.


To schedule the road painting job from your mod if you're replacing the TerrainTexturing class, call "scheduleRoadsJob" passing MapPixelData, tileData, and the jobs already scheduled. The road painting job has to run after the terrain tile data has been generated but before it's been assigned to the tilemapData. In other words after GenerateTileDataJob and before AssignTilesJob.

Code: Select all

ModManager.Instance.SendModMessage("BasicRoads", "scheduleRoadsJob", object[] {mapData,tileData,dependencies}, callBack);
Example usage:

Code: Select all

// Schedule the paint roads jobs if basic roads mod is enabled
JobHandle preAssignTilesHandle = tileDataHandle;
if (basicRoadsEnabled)
{
    ModManager.Instance.SendModMessage("BasicRoads", "scheduleRoadsJob", new object[] { mapData, tileData, tileDataHandle },
        (string message, object data) =>
        {
            if (message == "error")
                Debug.LogError(data as string);
            else
                preAssignTilesHandle = (JobHandle)data;
        });
}

Screenshots
RoadCity2.JPG
RoadCity2.JPG (252.74 KiB) Viewed 7283 times
RoadsMap.PNG
RoadsMap.PNG (342.25 KiB) Viewed 7283 times

Releases

For DFU v0.13.5+ get v1.2 here: https://www.nexusmods.com/daggerfallunity/mods/134
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Baler
Posts: 225
Joined: Thu May 23, 2019 1:39 am
Location: Earth

Re: [MOD] Basic Roads

Post by Baler »

Super stoked to see a formal release! This will definitely make navigating the over-world a more enjoyable experience.
Thank you Hazelnut!

ps. thanks for releasing it on nexus

User avatar
emmathepony
Posts: 248
Joined: Sat Jun 29, 2019 5:26 pm

Re: [MOD] Basic Roads

Post by emmathepony »

Do I need this if I already have Travel Options installed?

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: [MOD] Basic Roads

Post by Ralzar »

emmathepony wrote: Mon Sep 28, 2020 5:20 am Do I need this if I already have Travel Options installed?
Yes. Travel Options is the travel controls for widlerness and road travel.
This is to get actual roads ingame.

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: [MOD] Basic Roads

Post by Hazelnut »

emmathepony wrote: Mon Sep 28, 2020 5:20 am Do I need this if I already have Travel Options installed?
If you want roads, yes. But you can use TO fine without roads.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
emmathepony
Posts: 248
Joined: Sat Jun 29, 2019 5:26 pm

Re: [MOD] Basic Roads

Post by emmathepony »

Well I definitely want the roads because they look so good!

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: [MOD] Basic Roads

Post by Hazelnut »

There's an issue with the mod causing player to teleport under the sea rather than onto the ship when selecting ship option from travel popup menu. No idea what's happening, but I will investigate. For now if you use the ship a lot, I suggest disabling roads until I can fix this.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Hazelnut
Posts: 3015
Joined: Sat Aug 26, 2017 2:46 pm
Contact:

Re: [MOD] Basic Roads

Post by Hazelnut »

I've fixed the ship issues and several others. Also updated the first post with details of how to access the path data from other mods.
See my mod code for examples of how to change various aspects of DFU: https://github.com/ajrb/dfunity-mods

User avatar
Ferital
Posts: 282
Joined: Thu Apr 05, 2018 8:01 am

Re: [MOD] Basic Roads

Post by Ferital »

Combining this mod with Distant Terrain can lead to interesting paths :)
Screenshot.jpg
Screenshot.jpg (248.06 KiB) Viewed 6300 times

User avatar
Ralzar
Posts: 2211
Joined: Mon Oct 07, 2019 4:11 pm
Location: Norway

Re: [MOD] Basic Roads

Post by Ralzar »

Yeah, at the moment I stick to Mountains&Hills. It's a bit boring combined to Distant or Interesting Terrain, but it works much smoother with Basic Roads and Travel Options.

Post Reply