Make Your IF NPCs Talk
Sass, growl, flirt, threaten, and cajole players.
A good writer can say a lot with a few words. One of the best tricks in interactive fiction is make players do exactly what you want them to do while maintaining the illusion that they have free will. Nowhere is this more evident than in NPC conversations.
Ideally, your NPCs should drop hints, help solve puzzles, and converse with, and ocasionally bedevil, players. How do you predict what players will say? How do you know how to respond? In general, you don’t, but there are a few tricks to make your NPCs seem like living, thinking beings.
Detailing NPC Conversation
Inform comes with a few built-in methods of talking to NPCs. The
centerpiece of the default conversational model is the
Ask
verb. Let’s make this our
means of chatting with the access controller. The
game’s parser will take a command such as
ask the access controller about the token
, toss
out the articles, figure out that the operative verb is
ask
, set the variable noun
to
controller
, and then, as the key part, place the
word token
into the variable
second
. If you type ask the access
controller
about
oatmeal
, the word
oatmeal
goes into the variable
second
, even though there is no
oatmeal
object in the game. This makes
conversation trivial to implement. Add this to the
controller
’s
life
block:
Ask: switch (second) { 'id', 'identity', 'token', 'tokens': if (token has general) "~YES, TOKEN WAS ACCEPTABLE!~ the access controller barks. ~YOU MAY PROCEED!"; ...
Get Gaming Hacks now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.