The Lair of the Usurpers

So, I’ve put together the first draft of my text adventure. It’s neither spectacular nor particularly imaginative, but does show pretty clearly (I hope) how these things are written.

Oh, and don’t you just love blogposts which begin with “so”?

I wanted something that plays and feels like a straight role-playing dungeon; rather than provide a persona for the character in the game or a complex combat system, the idea is that it plays much more like a straight RPG game. Generate a character in the best pen-and-paper tradition and use the stats provided in the game for the monsters. Play the combat out as normal, then continue with the game. Assuming you win, of course.

I used the traditional six-room dungeon format beloved of Monte Cook and minimalist gamers everywhere. That’s enough locations to work as a proof-of-concept.

Here’s the map:

Anyhow. Download the code here and the finished game here. The code can be opened up in any ol’ text editor and can be compiled using inform. Grab a copy of Frotz if you want to actually play the game. I’ll take it chunk by chunk so you can see how this is put together.

The first part of the script simply sets the title, subtitle, opening blurb and sets the starting location:

 Constant Story "The Lair of the Usurpers";
 Constant Headline "^A D&D adventure suitable for 1st level characters^ By Greywulf^";
 Include "Parser";
 Include "VerbLib";

 [ Initialise;
  location = Entrance;
  "This is the first adventure in a series designed for solo play. Create a D&D character of appropriate level and play through the game. If (when) you encounter dangerous foes, play through the combat. EXAMINE the monster to see the game stats. If you defeat the foe, KILL it and continue in your quest. If it defeats you, your body is added to the pile of heroes this adventure has defeated. We mourn your loss.^^You have heard of recent activity at the old Temple to the Earth Mother high in the hills above your village. You decide to investigate before whatever is there starts raiding the farms.^After a few hours' trek you arrive at your goal....^";

After that we describe each room in turn, setting the exits. I’ve set the first room to have a light source – the others will be dark without illumination of some kind.

Here’s the first two locations:

 Object Entrance "Entrance"
   with  description "You face east, gazing at the entrance to the temple. The worn stone pillars erected around the hollow in the hillside are a mute testament to a people long forgotten. The climbing vines show clear signs of disturbance.",
   e_to Corridor, has light;

 Object Corridor "Corridor"
   with description "A dank earthen corridor sucks the light from outside. The dull drip of water echoes from somewhere deeper inside. In the gloom you see archways to the north and south, and an open stone arch to the east. Crumbled stonework marks the temple exit west.",
   n_to Robing_Room, s_to Storage_Room, e_to Temple, w_to Entrance;

Rooms are objects just like anything else in the game, and have an “in-game” name and an internal name. This is a teeny tiny dungeon, so I’ve set them to be the same. In anything bigger, a room naming scheme is a necessity.

Now for the fun stuff. On to the monsters. I’ve put two types of creature into this mini-dungeon – Goblins and Hobgoblins. I’ve put the game stats in their description so you can type EXAMINE GOBLIN and pull up the game stats for combat. Easy, eh?

Here’s the info for the Goblins:

 Class Goblin
   with name "goblin", description "Goblin Warrior CR 1/3^NE Small Humanoid (Goblinoid)^ ^
 Init +1; Senses darkvision 60 ft.; Listen +2, Spot +2^
 Languages Goblin^
 AC 15, touch 12, flat-footed 14^
 (+1 size, +1 Dex, +2 leather, +1 light shield)^
 hp 5 (1 HD)^
 Fort +3, Ref +1, Will -1^
 Speed 30 ft.^
 Melee Morningstar +2 (1d6)^
 Ranged Javelin +3 (1d4)^
 Space 5 ft.; Reach 5 ft.^
 Base Atk +1; Grp -3^
 Abilities Str 11, Dex 13, Con 12, Int 10, Wis 9, Cha 6^
 Feats Alertness^
 Skills Hide +5, Listen +2, Move Silently +5, Ride +4, Spot +2^
 A goblin stands 3 to 3-1/2 feet tall and weigh 40 to 45 pounds. Its eyes are usually dull and glazed, varying in color from red to yellow. A goblin's skin color ranges from yellow through any shade of orange to a deep red; usually all members of a single tribe are about the same color. Goblins wear clothing of dark leather, tending toward drab, soiled-looking colors.",
   life [;
     Kiss: "You have a strange taste in women, that's for sure!.";
     Attack: remove self; "It drops to the floor with a gurgled curse.";
   react_before [;
     Go: "The Goblin bars your way with a menacing growl.";
   has animate;

This gives us a generic Goblin “template”. I’ve told the game that Goblins are animate, so can move, be talked to, etc, and set up a handful of standard responses when Goblins are attacked or (heaven forbid) kissed. There’s also a bit of magic to stop the brave adventurer leave the room if there’s still a live Goblin in there. The caret ^ mark puts a newline in the game text. Just so you know.

Now to take this template and add real Goblins (real Goblins?) into the rooms:

 Goblin Ugly_Goblin "ugly Goblin" Robing_Room with name "ugly" "goblin";
 Goblin Young_Goblin "young Goblin" Storage_Room with name "young" "goblin";
 Goblin Old_Goblin "old Goblin" Storage_Room with name "old" "goblin";
 Goblin Servant_Goblin "servant Goblin" Sanctum with name "servant" "goblin";

I’ve added a Hobgoblin in too, using the same technique. The advantage to this is it’s a simple matter to create one monster-type and populate your dungeon with a cast of thousands. I like.

Finally, there’s the dungeon dressing. Here’s the equipment and scenery found in the rooms. These give the character things to look at and interact with. The two most important items are the torch which provided much-needed light (in the actual code I’ve added an in-game crawly that kills your character if you stay in the dark for too long) and the “goal” – a piece of parchment detailing an upcoming Goblin incursion.

 Object Torch "torch" Corridor with name "torch" has light;
 Object Robes "tattered robes" Robing_Room with name "tattered" "robes" has clothing pluralname;
 Object Stalactites "stalactites" Temple with name "stalactites" "stalactite", description "Pale green and slimy." has scenery;
 Object Pools "pools" Temple with name "pool" "pools" "water", description "The water is clear and very, very cold." has scenery;
 Object Firepit "Firepit" Sanctum with name "pit" "fire" "firepit" "ashes" "embers", description "Old logs are now little more than glowing embers." has scenery;
 Object Cooking_Pot "cooking pot" Sanctum with name "cooking" "pot", description "Rat tails float atop the smelly, greasy liquid." has scenery;
 Object Chest "treasure chest" Sanctum with name "treasure" "chest" has openable container static;
 Object Silver "small bag containing 300 silver coins" Chest with name "silver" "coins" "small" "bag";
 Object Letter "piece of parchment inscribed in Goblin blood" Chest with name "letter" "note" "parchment",
   after [;
     Take: deadflag = 2;
     "Congratulations! You have made it through the temple, uncovered the treasure and found proof that the Goblins are on the move into the area. You can return and warn your village and begin to make preparations for the coming Winter War. Gain 450XP and make ready, brave warrior......";

There’s still a lot to do, of course; a full adventure would need a lot more locations, puzzles, better interaction with the critters and traps. Mustn’t forget those :) I’ll fiddle some more.

In all, once the structure is in place it’s as easy to construct a fully fledged text adventure as it is to write a paper role-playing game. While this first draft is short and low on the interactivity count, it does show what’s possible. Using inform‘s language capabilities, the only limit is your imagination.

Leave a Reply