Scripting stories

The past week has gone in putting some final touches on the story scripting engine in Pirates and Traders 2/Dwarf Kingdom. The original script engine of P&T was pretty poor; it has been improved on since then, but I’ve still not been quite happy with it for various reasons.

A couple of months ago, I did a new survey of the various interactive fiction/story script engines commonly used. I’ve done some research on various interactive fiction script engines in the past, but none of them have really suited my purposes. I need something that is extremely easy to write in (so that other people than me can write stuff if they want to), but which is also easy to parse. I also don’t want to be tied to a specific editor, because that is rarely a good idea. At the same time, unfortunately, I also need the scripting language to be pretty powerful – for a game like Pirates and Traders, for instance, I do a lot of calls into the core game engine to fetch stats, skills, even entire descriptions.

Inkle have a fantastic writing tool in their Inklewriter – probably the most beautiful interactive story scripting tool done yet; sadly, the scripts generated by their engine are not human readable (JSON). Most of the popular interactive fiction languages that I looked at had more in common with programming than writing; useful, given their use-cases, but not for me.

I spent a lot of time considering Choicescript. It’s popular (lots of games developed using it), well supported by the Choice of Games guys, and contains almost everything that I need. Unfortunately, they went for an indentation-based syntax. I wish they hadn’t. Indentation syntax isn’t easy for people to get used to, and invisible markup (e.g., the difference between space and tab) is simply an accident waiting to happen – especially in the hands of someone who isn’t used to programming. It makes having a great text editor pretty much a requirement for being productive – and most people don’t. Despite the many good things about it, I eventually decided to drop the idea of using the Choicescript syntax.


Cloak of Darkness

At this point, I’ve settled on a Markdown-based syntax. I fell across one such syntax, called Ficdown, during my research and was struck by how similar the structures were to the non-Markdown compatible syntax I was already doing. After a little bit of work, I’ve developed a syntax for the story engine inspired by this which creates readable text in a WYSIWYG Markdown editor, while retaining all the flexibility I need.

Implementing the new syntax was pretty easy, so it’s already functional. I did a small writeup on how it looks like on the future Pirates 2 wiki. Hopefully, it is also pretty easy to use for non-programming people. The idea is to have it so simple that anyone who wants to, can write their own small adventures/quests for Pirates and Traders, and have them loaded into your game where you can play them (the same as the existing stories). The documentation is not complete yet, but the core elements are there. I’ve been putting the final touches on the implementation this week, and hope to start (re)writing some of the encounters and quests for the game soon.

I also experimented a bit with creating a stand-alone story viewer for the Story Script (see the image on the left); as I thought this might perhaps be useful for modders in future. It’s very plain, but works well – as it should, of course (it’s 99% the same code as I have in Pirates and Traders – I pretty much just stripped out the fancy UI).

At the moment, I’m actually considering whether to publish the story viewer as a free stand-alone app. Feels like it could be quite fun to give people the possibility to write their own CYOA games using something as basically simple as Markdown. On the other hand, I’m not really sure the interactive fiction community really needs yet another scripting language/viewer. At the moment, I’m just planning to fool around with it a bit, continue writing stuff for P&T, post a little bit around, and see if there is any interest. If it’s the sort of thing you’re interested in, feel free to post a comment or send me an e-mail.

In the mean-time, I need to put the last touches on the story engine, and adding the final hooks into the role-playing module.


Authorial direction, replayability, and player narrative

Some years ago, while I was still working actively on the Imperium project, I wrote a bit on the subject of Narrative in strategy games, where I speculated on whether less structure in a game story actually gave richer narrative. As Will Wright pointed out in his 2007 SXSW talk: “Players invariably come up with stories about what they did in games. They’re never describing a cut scene.”

This relates a lot to a discussion I’ve seen repeated a few times when browsing the interactive fiction community – whose story is being told? The traditional interactive fiction/choose-your-own-adventure (CYOA) approach is very author-driven; even though you – as the player – are making choices, you’re making them within a tightly limited framework. Every action – every connection – in the game has been painstakingly mapped out by the writer. Which is pretty amazing, because doing this is a huge amount of work (if you don’t believe that, try to write even a small choose-your-own adventure sometime). But I’m not convinced it is the right approach in a game.

Interactive fiction has been making a strong come-back on mobile devices, with many of the past masters returning to bring their CYOA books to an entirely new audience. It turns out that people like to read good stories (who would have guessed). One problem I do have with these games, though, is their limited replayability. Once you’ve seen the good ending, there is very little incentive to go back and play again. The more choices a game includes, the fewer players will actually get to see it. This is actually one place where the book medium is superior to apps/games; if you’ve finished playing through a CYOA book, you can always page through the book and see what other endings were possible without too much effort. That is rarely possible in a digital gamebook.

I really like the approach to solving this that Inkle Studios have taken, where they essentially allow the player to “rewind” the game to any previous choice, and continue on from there. It is still an approach tied up in the “physical” origin of the medium though; which is why I find the approach taken by Failbetter Games (Fallen London) more interesting. Sadly some of the really cool blog posts they did on this seem to have disappeared, but basically, the game(s) are based around these multiple short chunks of text (storylets). These texts are intentionally kept short, because – as noted on their site – player’s will skim any text that they are forced to read more than a few times.

The storylets are tied together by the stats/traits of the players – completing a storylet rewards the players with a stat/trait, and as the player gains these, more and more stories open up to the player. This is a branching narrative, but one where the player drives the narrative to a much greater extent than in regular IF. These are the stories that player’s enjoy retelling. I find the mechanisms for this fascinating.

I hope to attempt something very similar in Pirates and Traders 2. Player’s of the original will already be familiar with the text-based missions in the game; a few of which tie together in longer “epics”. This is actually pretty similar to the Storylet concept, except that the glue binding the stories together is either non-existent (the small random missions), or completely deterministic (the epics). My plan for P&T2 is to create more missions that are loosely coupled with each other, with the glue being player character’s traits and relations to NPCs (compared to Fallen London, that may perhaps be the unique aspect of my approach). So in one game, story A leads on to story B, whereas in the next story A occurs, but you never see story B or – if you do – it occurs in a completely different context. This is key to replayability in a narrative – each re-telling of the story has to be unique.

As a writer, it means abandoning much of the authorial control over the story flow, and trusting in the game systems and the player. At it’s best, this can result in some amazing narratives, especially if one can get the story aspects to respond closely to the choices and actions of the player. There are no guarantees that what the game system puts together is a cohesive story, though – the game essentially relies on the player’s ability to smooth out any inconsistencies, fill in the blanks, and put together a sensible narrative from the different parts presented. This is the player’s story – not the writer’s.

I’m looking forward to finding out how well that works.

Creating real characters in games

Yesterday’s article about NPCs by Austin Walker definitely struck a chord with me, and got me wanting to write on the subject of characters and personality in games again. One of the big differences between Pirates and Traders 2 and its predecessor will be its addition of persistent characters – and with it – persistent personalities. I haven’t invented a snazzy name for it like “The Nemesis System”, but what I’m planning to do is not far removed from it.

The idea is not inherited from Shadows of Mordor, though; these are game design ideas that I’ve played around with for many years. In fact, in the first ever interview I did as an “indie developer” back in 2005, I wax lyrical about using personality models to drive narrative. I love character-driven games, and have literally tons of scribbled design notes and research papers on the subject. Which makes it all the more ironic that when I finally published a game, I ended up building a game engine that made adding persistent characters in the game almost impossible. It’s not that I didn’t try but – but as I’ve mentioned a couple of times on Facebook – the code in Pirates and Traders has some nasty peculiarities, caused by the way the game got developed. At some point, I simply had to decide whether to implement persistent characters properly, and risk breaking the savegames of thousands of players, or leave well enough alone. I chose the latter. To this day, there is at least one annoying bug in the game that I believe was caused by my (half-finished) attempt to improve the character model. If you’ve ever encountered a character #MissingVariable, then you know what I’m talking about.

The engine which will power Pirates and Traders 2 and my collaborative project with Ashton Saylor – Dwarf Kingdom – basically rebuilds this aspect of the game from scratch. As I described last year, there will be a lot more persistent characters. And as can be seen in this early screenshot of Dwarf Kingdom, characters will be generated with personality traits.

I’ve commented a bit on the consequences of the Facebook pages, but probably not all in one place. What does it mean? First and foremost it means that you will have repeat encounters with characters, in different times and places. And your interactions with them earlier will inform their opinions of you later, and shape their future (i.e., pretty similar to the Nemesis System in SoM). So – for example; you might do a few good turns for the governor of Eleuthera, and become good friends with him. Which is nice, but not really all that useful, seeing as how that settlement is little more than a few huts on an island. But then he gets promoted to Governor of Port Royal, and suddenly you have a friend in control of the central British port of the Caribbean.  Or lets assume that you started a rivalry with another pirate captain. You exchange some words with him in random tavern encounters. Perhaps you grabbed a prize that he intended to take. Bad blood. As the heat grows on all pirates, perhaps he secures a pardon and is given a powerful ship and license to hunt down pirates. Guess who he will be looking to hunt down? The idea of the game mechanics is to have the potential to generate lots of these kind of small stories.

It’s difficult to go into details on exactly how all this will work, because … it’s complicated. I’m not even sure it will all work the way I want it to. Although, there are games that have experimented with these elements in recent years (one being the fascinating Redshirt by Tiniest Shark), there are not many of them. The trick is to find the right balance of psychological simulation and pragmatic game mechanics that still results in a fun game. But the four key ideas that I believe that I can build an interesting system around are:

  1. Personality traits. Most importantly, characters will not be just stats. They have traits, backgrounds, and motivation which (at least partially) guide their actions and their reactions to what you do. These will (mostly) be procedurally generated, so that the same base story may well play out differently from game to game.
  2. Character agency. A pet peeve of mine in RPGs. If character’s have their own motivations, they must also show agency – otherwise it’s just text. NPCs won’t just wait around for you; they’ll act and interact – with you and others – in order to further their own agendas.
  3. Relations as a journey, not a goal. Another pet peeve of mine. Why is it that most games have you becoming BFFs forever as the goal of relationships? Doesn’t reflect real life as I know it; I’m friends with people because I like them – not because I hope to gain some great bonus artifact when I score +100 relationship points. I want to try and play with the incentives a bit here; perhaps remove explicit incentives altogether. Because gameplay were you do something because you feel for it, rather than just because you gain a +4 cutlass is the kind of stuff that – IMO – makes for awesome stories that stay with you.
  4. Conflict is not just about villains or violence. I particularly want to experiment with the former. Relationships between characters should not depend on agreeing with another character as strongly as possible; in real life, it is possible to be friends and still have differing opinions. This goes hand in hand with character agency; sometimes the antagonist in the story isn’t necessarily a moustache-twirling Captain Hook, but the conflicting priorities of your boatswain. And the conflict cannot simply be solved by murdering everyone who opposes you.

If I can implement those four elements, I think NPCs in the game will have gone a fair distance toward my goal of making the characters feel more alive.