In Draeywin I’ve been using markers to easily mark teleport locations, NPC patrol points, and quest markers. Essentially, they are just point classes that I can place on maps directly in TrenchBroom which saves me a lot on trying to figure out direct coordinates.
This had worked quite well so far since for teleportation I could simple point to id
of the map, and the id
of the marker and the code could figure out the rest.
However, this approach doesn’t quite work for open worlds, because now the code would also need to know in which cell the marker resides.
I could invest a special syntax that includes the cell e.g. <world>:<x>_<y>:<marker_id>
but that would leave me hunting down coordinates again.
Since worlds need to be registered by modules, I could loop through all cells and build a index of all markers in that map, but that would increase load time.
So in the end, I went with building another separate tool called worldindex
.
This takes a map as an arguments and loops through all its cells to find markers, which it then records and stores in a simple array that can be spliced into the module.json
.
The code is not very interesting, but it involves using godot-tscn-parser (isn’t free open-source software great) and about 200 lines of code.
Running the following command will loop through all the cells of dev_world
and outputs a JSON array containing all the markers that it could find.
$ worldindex ../modules/main/worlds/dev_world
The output is a JSON array that can be spliced into the module.json
using jq
:
[
{
"id": "dev_world_start",
"world_id": "dev_world",
"x": -59,
"y": 6.5,
"z": -599,
"rotation_degrees": 0
},
]
Using this approach all I need to find a marker is the id
of the marker.
Now I know which world it resides it (I want to extend this to dungeon maps as well), and what the exact coordinates of if is.
And in fact the game has to do no runtime lookups apart from looking it up in the marker index contributed by all modules.
And thus my range of tools to work on the data of the game continues to grow.