The Hazards of Invisibility, or, Making Your NPCs Respond the Way They're Supposed to by C.E. Forman Writing "The Path to Fortune," my first serious attempt at IF, has taught me a lot about puzzle design, but one realization has stuck with me like no other, and I thought it might save some new authors a lot of trouble if I passed it along. Namely, I learned to never, ever, allow an object which alters the NPCs' reactions toward the player to find its way into the mainstream scope of an open-design game. Here's what happened: One of the items the player acquires in PTF is a cloak, which, when worn, makes its user invisible. This is necessary (obviously) for solving one of the game's puzzles. Unfortunately, neither I nor my co-author gave it much thought at design time. Only after I'd sat down and tried to program it did I realize the possibilities involved. PTF's design makes it a very open game. That is, players have the ability to explore about 80 percent of the game world right from the start -- only a small number of locations are blocked off by puzzles. PTF has 11 major NPCs, and about a dozen minor creatures for the player to interact with. Almost all of these are accessible from the start, and there's no limit to what the player can take along when visiting them. Starting to see what I'd gotten myself into? The player has the ability to wear the cloak almost anywhere in the game, because there is no means of limiting its transport. No logical method of restricting the cloak's location came to mind, and re- design of the entire game was out of the question -- I'd already been programming for three months when this came up. (It's amazing what you think of when you actually sit down and attempt to code something.) Now, since the player can wear the cloak anywhere, this means it can be put on and taken off in front of the various NPCs, and can also be worn when the player walks into the location. What this meant was that I had to go through all my NPC objects and interactions, adding evaluations that checked if the player was wearing the cloak (since, for example, you shouldn't be able to give something to a character who can't even see you). Compounding the problem is the fact that the game by itself was already fairly complex to begin with. A particular spell can be used to put characters to sleep, the characters have their own waking and sleeping cycles, and a couple characters' behavior changes drastically during the course of the game. All this meant more checks and confirmations. The simple act of adding that cloak easily quadrupled the complexity of the NPC objects' code. In the end, I ended up modifying most NPC actions with a check for the cloak, but left some of the less changeable alone (such as killing characters while wearing the cloak -- I couldn't very well have the player be able to walk away from something like this, as it would alter the state of the game far too drastically). For some of the more magical or more alert characters, I simply decided to let the player interact with them in the usual manner (although this did occasionally require mentioning the cloak, which meant that an 'if' expression was still in order). I'm still finding corrections that need to be made because of the cloak. No doubt beta-testing will reveal even more that I missed. The moral of the story is this: If, when designing a game, you're considering the addition of an object that: 1) Can be used more than once in the game; 2) For whatever reason, makes the NPCs behave differently around the player; and 3) Exists in a game in which most of the locations are accessible by the player, at any given time, and while carrying the aforementioned object, do yourself a favor and think it over several times before adding it. Redesign the puzzles or map while you still can. Don't rush the initial design phase -- take your time, thinking everything through, and try to see every possibility from the outset. Ensure that coding every possibility is worth the trouble before you start. Hopefully it'll save you from some of the trouble I ended up going through. - o -