Varying Worlds: The Written Realms Facts System

Introducing a new world building system to manage variable facts about a world.
Nov 16 2020

A world where nothing ever changes loses its appeal over time. Variety and unpredictability keep players coming back, and more often than not builders have to manually edit their world each time they want to introduce a change.

Taking the example of a Christmas event, a builder might go in and modify certain mobs to be holiday themed, and in the new year change them back. But what if there was a way to schedule this kind of change, so that the start and the end of the event could happen without a builder needing to babysit the process at all? Or perhaps a builder might want to implement a weather system, where every hour there is an even chance of rain, sun or snow.

It is with these goals in mind that we have designed and are now releasing the Written Realms Fact System. There are three components it:

  • Two new builder & mob commands - setfact, which sets a given fact to a specific value, and clearfact which clears a fact.
  • A fact scheduling system where facts can be periodically set according to intervals or specific calendar date & times.
  • Conditions can now be evaluated against these facts, meaning that loaders, quests, reactions and room actions can be conditionally available based on the fact values.

Let's look at a few examples of how a builder might utilize the Facts System to change the world over time without needing manual intervention.

Scheduling Example 1 - Weather

Let us suppose that there is a river that can only be crossed during freezing weather. We're going to a use a 'weather' fact to track current weather, which will change every 20 minutes. To do this, we define the following fact schedule:

  • Fact: weather
  • Value: warm mild cold freezing
  • Value Selection: Random
  • Schedule: 1200
  • Schedule Type: Interval

This will change the 'weather' fact every 20 minutes (1200 seconds), select a random value from the set "warm", "mild", "cold" and "freezing". To prevent the river crossing during warm or mild weather, we could add the following room check:

  • Conditions: not fact_check weather freezing
  • Prevent: Enter
  • Failure Message: You will have to wait for the water to freeze.

Scheduling Example 2 - Seasons Cycle

In the previous example, we used the 'Random' Value Selection, where a random value is selected from the pool of choices and assigned to the fact. Another useful Value Selection is 'Cycle', which will select the next value in the list. For example if we have a 'season' fact that we want to rotate through the four seasons, we could have the following fact schedule:

  • Fact: season
  • Value: summer fall winter spring
  • Value Selection: Cycle
  • Schedule: 86400
  • Schedule Type: Interval
  • Change Message: {{ oldvalue }} gives way to {{ newvalue }}.

With this configuration, the seasons will progress in order from fall to spring, every 24 hours. If the season is 'fall' when the scheduler runs, it will select the next value in the cycle, which is 'winter'.

A similar setup could be used for a day/night cycle, or months of the year, or moon phases, or anything that goes through a predictable loop.

This example also introduces the concept of the Change Message, which if defined will notify everyone in game of the fact change. In this case, going from fall to winter will display "Fall gives way to winter."

Scheduling Example 3 - Special Event Every Thursday at 8pm

So far we've set schedules based on time intervals, so that the facts are set at regular offsets. But what if we want to do something every Thursday night? There is a second of Schedule Type that allows facts to be changed on a "real world" schedule, using the Cron syntax. Here is an example schedule:

  • Fact: special_event
  • Value: on
  • Value Selection: Default
  • Schedule: 0 20 * * 4
  • Schedule Type: Cron

In this case, the schedule value '0 8 * * 4' means: at minute 0, hour 20 (8pm), on Thursday (4th day fo the week). A second schedule could be created for 9pm on Thursdays to set 'special_event' to off.

Fact Commands

The fact scheduler offers a lot of flexibility, and can modify facts without any in-game action needing to be taken. But facts can also be modified in-game, both by builders and mobs, using the setfact and clearfact commands. This facilitates both builders modifying the environment live during special events or dungeon mastering sessions, or for mobs to alter facts when some of their reactions are triggered.

Future Improvements

One of the great joys of developing world building tools is when builders use them in unexpected ways. Only time will tell which aspects of the system resonate and which need adjusting. If, experimenting with all this, you find yourself wishing for tweaks or improvements, don't hesitate to drop us a line on Discord.

But one feature we're thinking about is for certain mobs to be able to "listen" to fact changes. For example, certain trees might look for a 'season' fact to change from fall to winter, and then purge themselves so that a conditional loader can replace them with snow-covered versions.

Another might be for players to have their own sets of facts, so that for instance room actions could be available to players who had a certain fact value and not others. This is already possible via quests, but player facts would be a more light-weight means to achieve the same goal.