In the latest build of Vidar (posted on Monday – go download it!) I finally threw the switch on the Random Generator. It’s alive! A few weeks ago, I talked about how, using a tile swapper, I’m able to place things like rocks, holes, and direction arrows based on what’s encoded in any given puzzle’s chosen option.
But there is more to life than lifeless rocks. We need things to interact with, and that requires not a tile, but an event. So I needed an event spawner. There are some great event spawners out there – some which make temporary events, some permanent. But what they all have in common is that they spawn the event on the map you’re currently on. It can pull from a different map, but not to a different one.
After playing around with those, it was clear the game wouldn’t work. Particularly once you get to the Dark Cave, there are so many events being spawned per map that when you enter each, there’s a noticeable pause where the game is unresponsive. Also, from a structural standpoint, I didn’t like not knowing the event IDs of a puzzle until you’ve reached that room – I want to know everything in your particular save file right off the bat.
So I built my own, using Eshra’s Spawn Event Script as a starting point. It does mostly the same thing, except it opens up the destination map, adds the new event data, and closes it. I’ve got one “source” map per biome – that is, there’s a Dark Cave map that the player will never see. On it are things like torches, lanterns, wolves, barrels, mirrors – all of the events that will show up in Dark Cave puzzles. A puzzle option knows (i) what map it’s on and (ii) what its “source” map is. From there, it’s a simple matter of copy/pasting events where they should go.
What’s more, I can do this exactly once – when you start a new game. Before you even reach the tutorial, the game runs through every puzzle, chooses an option, does the tile swaps, and now spawns the events on the correct map. This takes some time, which means I need a loading screen in the beginning. But once that’s done, it’s done.
This handles a lot of easy events right off the bat. Barrels in the Dark Cave refill your lantern oil. They don’t reference anything else in the puzzle, they don’t do different things that are context dependent. They just call a single common event that plays a little sound, displays a little text, and changes a variable. So I made that barrel once:
Every dark cave option has as an attribute “barrels”, which itself is a list of coordinates. When an option is chosen, I go through those coordinates and spawn duplicates of that barrel at all of the coordinates. Et voila.
This also helps for one-off things like quest items, which might appear all over the place but will always do exactly one thing. I also use the system to spawn switches, but I’m still saving that mess of a post for another day!