History generation improvements continued at a good pace this week.
- History Event Triggers. History events can now trigger future events to produce more logical event sequences. World state entity updates, such as placing an entity in a new location, now emit triggers that get added to a queue. When a new history event is being selected, the trigger queue will be examined first. If the queue is non-empty, the next trigger will be dequeued. The event selector will then find all of the event types that can respond to the trigger, and randomly select one of those. This allows multiple outcomes for an event.
- History Event Parameters. To support History Event Triggers, there needed to be a mechanism for passing an event’s entities to triggered events. This was accomplished by mapping trigger parameters to event entity placeholders. This was a difficult feature to implement because of how extensively indirection is used in history generation. Many of the values in the history event type definitions are expressed as entities (e.g. “ActorA”) or entity attributes referencing other entities (e.g. “ActorA.Section”). Those values are parsed to find the matching entity in the world state. The history event parameters add another layer of indirection by referencing parameter names in the trigger and placeholder names in the triggered events. This approach provides great ease of use and flexibility for designing events at the cost of under-the-hood complexity.
- History Event Significance. The main purpose of history events is to construct the world state. As such, some events aren’t significant enough to convey to the user or record in a history timeline. I added a significance attribute to prevent insignificant events from being presented to the player.
- On-Demand Entity Creation in History Events. Previously, history events could either create an entity or select an existing entity from the world state. Now, events can be configured to attempt to find an existing entity first, and create a new entity if an existing entity isn’t found. This ensures that existing entities are used as much as possible, which makes the timeline more interesting, and that there is a wide variety of event types to choose from (events that require existing entities can only be generated if those entities exist).
Now that there’s a way to link cause and effect history events, next week I’ll resume work on stocking the dungeon from the generated history. The system is working but more content (i.e. event types) is needed. Creating new event types in and of itself is simple; it can be done entirely in the Unity inspector. However, I need to code more varieties of the building blocks that define history events, for example the criteria that determines the types of entities that can be bound to an event.