Maps: a modding capability discussion.

Discuss modding questions and implementation details.
Post Reply
LongRoadAhead
Posts: 4
Joined: Sun Apr 08, 2018 5:21 am

Maps: a modding capability discussion.

Post by LongRoadAhead »

Combing through the forums and the updates, I'm very much liking what's been done with Daggerfall Unity so far. In the case of the modding capability, the community has already shown to have the versatility of mods from the Morrowind-era onward to be made, from texture replacers to the Archaeology guild. There is one aspect of Daggerfall Unity that I'm unsure of though- maps.

Now, when I say maps, I mean two things:

1. The actual in-game map, or the landscape/worldspace/playable area/gamespace/ whatever term floats your boat.

2. The many and multiple in-game maps used for navigation in actions such as fast travel.

Image Image

Regarding both questions, I asked on the subreddit https://www.reddit.com/r/daggerfallunit ... p_modding/ about the possibility. Interkama responded:
It's possible to mod the TerrainSampler class to set heightmap however you like per world cell. For example, Nystul's distant terrain mod uses a custom TerrainSampler to create a more exaggerated look. You could do the same thing to sample from a different height map entirely (e.g. transplant Daggerfall to the surface of Mars). I provide a couple of examples in the code using completely flat and perlin noise samplers totally divorced from Daggerfall's own height map.

Interesting so far! But the part I was more interested in came afterwards.
A few things are hardcoded such as world scale, how terrain is smoothed down to place locations, and locations themselves. Location data is read from the end user's game files and currently not possible to modify whole locations or regions (and may never be possible to do this - just to manage expectations). But you could do stuff like change a specific world tile to use a different height map, place custom geometry, add special encounters in the wilderness, and so on. There's probably a lot you can do here with some imagination and tinkering around the edges of what is possible.

So for now, it's unlikely to modify the region wholesale, but you can do a pass on the details, like buildings and such. This is where I'm not sure what the capabilities are.

To give an example of what I'm talking about, let's say I wanted to create an extension of the Alik'r Desert- specifically, adding in the landscape of the desert that is not currently part of the playable world space. (Come to think of it, any extension in any direction could do. ) Would this be considered falling under altering the world scale or modifying locations and regions? Or would the addition of a location/region mean that it would function as long as it doesn't touch the originals?


My latter question about maps luckily requires much less setup to articulate. Would it be possible to replace the maps used in-game with other maps? I don't mean just a retexture- I mean using a resized map, and still having appropriate functionality (as in when I click on the Kingdom of Daggerfall, it recognizes it- even though it's not in the bottom-right corner of the map now for some reason).

Thoughts? Comments?

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Maps: a modding capability discussion.

Post by Interkarma »

Welcome to the forums LongRoadAhead. :)

I'll try and answer your questions as best I can. I might need to answer in a few different sessions however depending on time I have available to formulate a detailed response.

Just one thing I need to ask first is how comfortable are you with C# and Unity, and Daggerfall's file formats overall? For the items you're asking about some of the conversation is necessarily technical, and it helps if I know the best way to present information.

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Maps: a modding capability discussion.

Post by Interkarma »

Just for some basic high-level information, Daggerfall's world is defined in the following manner:
  • The game world is 1000x500 cells or "map pixels". They are often called map pixels because any point on the 1000x500 surface area corresponds to a set of 1000x500 pixel data maps. These are:
  • Height map: Just your standard heightmap. This is how high or low the terrain for that world cell is in game.
  • Climate map: Defines if the world cell is temperate, forest, desert, etc. Also controls NPC appearance, name generation of NPCs, skies, and foliage.
  • Political map: Defines the region any map pixel belongs to. There are a fixed and hardcoded number of regions.
  • As for locations, these are just a list (like a database) of locations. Each location has an X, Y position telling the game which map pixel they belong to. Same for dungeons. A map pixel can only have one surface location and one dungeon at most.
  • Each surface location is constructed from blocks, which in turn define where to place geometry, foliage, etc. The largest locations (e.g. Daggerfall, Sentinel, Wayrest) are made of 8x8 RMB blocks and fill almost the entire world cell. They have a small band of empty space around them to blend into surrounding wilderness.
  • Every dungeon is made of any number of RDB blocks. Unlike RMB blocks which are laid out in a width*height grid, RDB blocks are laid out using cartesian coordinates relative to central block (the entrance block). Normal blocks are open on every side and the dungeon is sealed using special border blocks around the outside (which only open inwards towards normal blocks).
  • The travel map where you select regions is not generated from game data. It's a set of hand-pained IMG files, one for each region. They are numbered in a way defining their layout and adjacency in the UI. You can view these map images in Daggerfall Imaging 2.
Now on to modding:

Right now the only world map that can be modded is the heightmap by using a custom TerrainSampler as mentioned above. It's feasible to mod the climate and political maps by altering the game files directly or adding code to mod these in Daggerfall Unity. Whatever changes you make to the maps however, the world must always be 1000x500 map pixels in dimension. You cannot add terrain outside of the total map area.

You could also mod locations or dungeon layouts by editing game data directly or adding code to change their layout. You could move a location by changing its coordinates, but a lot of systems use these coordinates to uniquely identify the location (just like a database key), so changing this is probably not a good idea.

The names and political indices of regions are hardcoded. You could in theory move the region of Daggerfall to another spot on the political map, but this won't change the map pixels locations are coded for. It would also break the travel map interface. Probably best to think of the world map as a fairly immutable sandbox and imagine content you can add into that sandbox rather than rebuilding the entire sandbox itself. For example, think of GTA V - the world map remains the same regardless of any gameplay systems overlaid into that world.

For individual RMB blocks, you can merge new data into individual buildings such as adding decor, new NPCs, etc. Hazelnut not only built this system but makes excellent use of it in the Archaeologists Guild mod. There's a huge amount of potential for modding here.

For the wilderness, you could create a mod which checks the map pixel player is currently inside of to do something specific, or just add random events to the world when player is in wilderness. You could even add custom geometry, etc. to the wilderness with mods.

Whatever you end up doing, some amount of programming will be required. Daggerfall is a highly procedural game which means hooking into those procedural elements to define the flow of information from source into the world.

LongRoadAhead
Posts: 4
Joined: Sun Apr 08, 2018 5:21 am

Re: Maps: a modding capability discussion.

Post by LongRoadAhead »

... For lack of a better set of terms, damn that is a hell of an answer.

First off, get as complicated as you need to with C# and Unity, and as complicated as you want to with Daggerfall's file formats. In the case of the latter, I'm assuming the way DFUnity works with Daggerfall means that whatever goes on in Daggerfall's end will prevent extensions to the map?

Secondly, regarding map pixels:
The game world is 1000x500 cells or "map pixels". They are often called map pixels because any point on the 1000x500 surface area corresponds to a set of 1000x500 pixel data maps.
You later go on to say this:
Whatever changes you make to the maps however, the world must always be 1000x500 map pixels in dimension. You cannot add terrain outside of the total map area.
So the game world must have 1000x500 cells. Would I be incorrect in thinking one of the modifiers of the cells in question could be the cell size itself?

User avatar
Interkarma
Posts: 7236
Joined: Sun Mar 22, 2015 1:51 am

Re: Maps: a modding capability discussion.

Post by Interkarma »

Besides the world being 1000x500 cells, each cell is 32768x32768 Daggerfall units (inches) in world space. In game this is changed to Unity units (metres).

There are two coordinate systems in game. The first is player's position in local space within the live scene (only part of the world surrounding player is streamed in at a time). The second coordinate system is the player's position in world space. This is used to determine where player is on world map regardless of which part of the world is currently loaded into local space.

There's a floating origin setup in the StreamingWorld class to snap entire world back towards origin as player runs in any direction. This prevents floating point precision problems and allows player to seamlessly walk across entire map if they want. In local space, they never get farther than about 1km from 0,0,0 but their true position in world is tracked at all times by PlayerGPS class. The world our player sees is like a conveyer belt where new parts of world are loaded in ahead of player in direction they are moving.

The various game systems all need to reconcile where player is at any time and convert between local and world coordinates as necessary. There are helpers in the code to assist with the conversions.

For a shorter answer: the world is always 1000x500 cells and every cell is a fixed size in world units. You can influence elements how a cell is constructed (e.g. heightmap to change terrain elevation) but you can't fundamentally change the physical properties of the world layout itself. That steps well outside of modding into making a different game.

Post Reply