Monday, September 14, 2009

[Inform 7] Multiple actors per turn

Suppose you wish your game to state, every turn, what several people are doing. This is not a problem if you have, say, NPCs that only walk around, and you only want the game to say where they walk to. Here, you'd just write a message within the routine that governs the walking.

But if you have NPCs that can take a wide range of actions, and ought to be given replies that are equivalent to the ones given to the player's actions, you are in for a nasty surprise. Inform 7 handles player actions very differently from non-player actions, especially where it concerns printing messages about them. Changing the rules in the standard library so that they also display messages when the action is taken by an NPC is simply too much work.

Instead, install the Custom Library Messages extension. Now, before each NPC gets his or her turn, change the gender and person to whatever is appropriate for this NPC, and make the NPC the player character. Don't forget to change it all back before the next prompt appears. This allows you to "fool" the game into thinking that it is responding to the player's command.

Will that solve all your problems? No, because you will probably want to rewrite all library messages that do not mention the actor, e. g., "That's inedible." That must be changed in something like "[The actor] find[-s] that [the noun] is inedible.", or whatever, because otherwise your output becomes an unclear muddle. Still a large amount of work, but not altogether impossible.

By the way, I'm using this for a WIP that consists of a sequence of puzzles. I'll probably put it online once I have polished it a bit more (and maybe added one or two additional puzzles), to see if anyone is interested. It would be very easy to collaborate on a project like this.

No comments:

Post a Comment