Wizard's tower, outer level
Wizard's tower, outer level
Wizard's tower, 2nd level
Wizard's tower, 2nd level

More miscellaneous updates this week, all revolving around bug-fixing and expanding the level generation process and the integration with the native plugin.

  • Fixed some bugs related to level/zone name generation (zones are areas in a level). Zone names for example are not very useful for the player to know, but for debugging it's great to hover over a tile and know what zone it belongs to, e.g. "crypt".
  • Changed a bit how tags and weights work. Besides being used for plain requirements ("must be have haunted tag", "must not have abandoned tag"), we can associate weights with tags that can be added to some base weight. Example: torches would specify a -0.5 weight for the tag "dark", so dark zones would spawn fewer torches than they normally would
  • I tried to use a separate Unity script to see if I can make dynamic changes to the C# script while the game is running, but if I make a change and the code recompiles, everything breaks. Hmmm, there goes this approach of "hot reload", need to try a few more.
  • Fixed a bug where torches were not spawning
  • Rewrote lighting algorithm as it was a bit dumb: it was using multi-goal Dijkstra to get contribution from multiple light sources, but that created a few issues, one of which is that lights next to each other were not additive. So I've put my super-fast FoV code to do the work ("for every tile in the radius of a lightsource, test visibility") and so far so good with lots of torches (relatively small radius each)
  • Fixed torches having the wrong sprite, this was due to some badly configured JSON which annoyed me so much that I started ...

The Great JSON purge

JSON (mis)configurations were a bit hard to detect as I have to maintain C++ <-> JSON <-> C# . So, if I change a field in C# and I don't fix all the corresponding JSON configurations, I get insidious bugs. So I decided I'll go a bit more robust about it. A few things fixed:

  • Added detection of entries in JSON that do not exist in C# variables. That was a big one, and catches a lot of problems. After I implemented that, it flagged lots of errors in 18 separate JSON files (out of 52). That's a lot. Overall fixed several classes of errors:
    • json key was old and had been changed in c#
    • misplaced key (e.g. in parent object)
    • json key only read in C++ plugin and not in C#
    • C# config classes had some variables that I had decided to remove
  • Duplicate detection in JSON. Before I did have a JSON validator script, but now it's also checking for duplicates, that are allowed but problematic of course.

Inheritable properties

After the JSON purge, I also ended up in another rabbit hole: I have a hierarchical zone relationship, and each zone may or may not have certain settings, e.g. floor type, wall/blocked type, dominant biome, difficulty, tags, etc. I might have values, or I might want to say "inherit from parent". So I did another round of refactoring in both C#/C++ adding support for several zone properties to allow inheritance. Dust is settled on that department for now, and it looks far more reasonable.

Other changes

  • Added support in C# for procedural selection of optional zones, so e.g. prisons may appear in dungeons, altar areas or lean-tos in the wilderness, etc
  • Added support for things like being able to easily specify a wizard tower adventure location in JSON by declaring 1) it's dungeon-style 2) has round shaped levels 3) Further levels go up instead of down 4) levels don't change size (or slightly shrink) as we're going up. My holy grail is to easily specify complex dungeons from JSON or simple C# scripting. At the moment I can do exclusively either "easily" or "complex".
  • Added support with a bool to make a coastal map (a map that in the overworld has border with a big body of water) an island or not.

That's all for now, next week on holidays so it's going to get slow for a couple of weeks. Have a nice weekend!

Yet another tower
Yet another tower