Visit our sponsors! (or click here and disable ads)
Pathfinder: Wrath of the Righteous Kickstarter Update #26: Reactivity Scripting
Development Info - posted by Infinitron on Thu 27 February 2020, 20:35:27Tags: Owlcat Games; Pathfinder: Wrath of the Righteous
Owlcat have another Pathfinder: Wrath of the Righteous technical update for us today. This time it's about a topic that's near to the Codex's heart - reactivity and choice & consequence. In Pathfinder: Kingmaker, reactivity was implemented by means of a simple array of flags. For Wrath of the Righteous, Owlcat have switched to a more sophisticated tree-based data structure, which is not only more efficient but will also be easier to debug later on.
We have our own scripting engine to work with the game world, which operates under the “Event–Condition–Action” principle. This means that we can set a list of events for every map, and we can assign a set of actions and conditions for every event, e.g. the “Monster killed” event, with the condition “Amiri in party,” and the action “Amiri says she could have handled it easily on her own.” Conditions and actions are also used in other contexts, such as when determining which dialogue options to display.
Whenever the player makes any kind of choice, the game has got to somehow remember this choice for future reactions. In Pathfinder: Kingmaker, we used something called “UnlockableFlags” to do this. These are special flags that are saved as the player makes choices, and each flag can have a number value assigned to it. For example: when talking to a merchant, the player can get lower prices on goods in one of three ways: trick the merchant (1), persuade the merchant (2), or threaten the merchant (3). If the player has the “PricesLowered” flag with the value 2, that means the player persuaded the merchant to lower their prices. In situations where there is an opportunity for the world to react to this flag, we check to see if the flag is there and its value, if any. For instance, if you return to the same merchant, they will compliment you on your haggling skills. Many game projects use similar tools to our flag system, it’s a good and intuitive way to handle reactivity.
Flags can be used in many different ways, such as for quest objectives or for lines and responses in dialogues that the player has seen and selected.
With our scripting system, we can check various moments in the game and assign flags to them, changing the world to reflect the current state of things: characters will appear and disappear, someone will change their position, or an animation will be triggered. We can change the position of objects, the lighting, the music, and much more. All this usually takes place in the final few seconds of loading an area. Dialogue options are unlocked or hidden in real time as you talk to characters.
There were a total of 2,103 flags in Pathfinder: Kingmaker. Keeping track of so many variables was a real challenge. When we started working on Wrath of the Righteous, we thought a lot about the best way to structure our presentation of game conditions, and how we could simplify working with all these variations. Our thought process led us to create our “Etude System” (if you’re wondering why it’s called that... it’s a long story). The system is already up and running, but we still need to add some of its functionality.
In Pathfinder: Wrath of the Righteous, the state of the world at any given moment won’t be presented as a set of unrelated flags, but as tree of “etudes,” where events branch off and lead to various conditions for the world. Every etude in the tree represents a minor or major event or condition of the game world. Unlike flags, etudes can monitor entire scenes and events within them. For example, the “Meet new companion” etude can be responsible for characters and starting cut scenes and dialogues that are triggered by this meeting. Previously, this meeting would have been entirely separate, and each time the player visited the location, a check would have been run to see if the “Meet new companion” flag was present in any of several areas, in order to start the whole process. Now, you just need to trigger the “Meet new companion” event and the event itself is already configured within an etude. If the etude is triggered, the event can take place (the player can meet the companion), if it is not triggered, the event can’t take place (the meeting can’t happen).
This also means we now also have a tool for visualizing the player’s path through the story. When we load a save in the editor, we can clearly see the player’s choices and the state of the world in the current moment: what chapter the player is in, what important information they gained in previous chapters, which companions the player has and how each companion’s story is unfolding, what locations the player has visited, etc. It’s hard to overestimate the value of being able to grasp all of these different elements at a glance, and this will be doubly true when we reach the bug testing stage of the project.
Of course, etudes are much more complex that what we’ve described here, but going into detail would require a whole separate article. Our etudes system is an experiment, and some of our greatest hopes are riding on it. We are confident that our experiment will be successful, and our team will gain a powerful tool for creating non-linear events, and you will get a more vibrant and responsive world to explore.