I’m just curious how people implement NPCs who die during the game.
Two basic approaches come to mind:
1. Assign an alive-or-dead property to the NPC, and customize the response to each action involving the NPC so that it varies, as appropriate, depending on how that property is currently set; [i]or[/i]
2. At the moment of death, move Joe (the NPC) offstage and place a thing called Joe's Corpse in whatever location Joe formerly occupied.
My gut reaction is that the second approach seems preferable. However, one issue I see with this approach is that it would be necessary to take everything that Joe carried or wore ante-mortem and make it a part of Joe’s Corpse at the moment of substitution. This, in turn, would require some customization of default messages so that the carried/worn items do not appear to the player to be “parts” (even though that is how they would have to be implemented). For example, if Joe had been wearing a green shirt before his untimely demise, an examination of Joe’s Corpse should tell the player that “The corpse is wearing a green shirt with a bullet hole in it.” as opposed to “A green shirt with a bullet hole in it is part of Joe’s Corpse.”.
The difference between a corpse and a living NPC is usually such that it’s easier to make the corpse a separate object. You will probably want to change all descriptions and most of the responses anyway. Otherwise when writing rules you’ll always have to remember to specify that you mean only the alive state of NPC and it’s very easy to miss something. (I do admit it’s always amusing when a corpse suddenly responds to something like nothing had happened.)
You could make the corpse a person and change the standard responses to something more suitable, which is probably something you’d have to do anyway.
I’ve done both. The latter is probably better if you have lots of other interactions with NPCs (all of which you have to remember to block for dead persons), while the former might be better if you have many NPCs that can get killed (in which case it would be tedious to make separate corpse objects for each) and do not have much interactions with them.
Another possibility, which I used in Fate, is to give every person a part called the body (“A body is a kind of thing. A body is part of every person. The description of a body is “[if the body is part of something]A normal, human body.[otherwise]The body lies in a pool of blood.[end if]””). When they were killed I moved that part to the location. This allows you to have a body as an inanimate thing, while you still don’t have to declare a corpse by hand for every NPC.
I may be wrong, but I’m under the impression that it is English idiom to say “on the body”, as in “On the body you find four cigarettes.”. This means you could just make the corpse a supporter.
If you are going to use dead bodies, I have some code you might find useful. I’ll put it behind spoiler tags. It’s only applicable to your scenario 1, though.
[spoiler]Code for allowing people to pick items up from a dead person, if you decide to keep the person and give the person a property “killed” (from Inform ATTACK):
[code]The can’t take people’s possessions rule is not listed in any rulebook.
Check an actor taking (this is the can’t take living people’s possessions rule):
let the local ceiling be the common ancestor of the actor with the noun;
let H be the not-counting-parts holder of the noun;
while H is not nothing and H is not the local ceiling:
if H is an alive person, stop the action with library message taking action
number 6 for H;
let H be the not-counting-parts holder of H.[/code]
Code for printing the name of a dead person (from Inform ATTACK):
[code]Before printing the name of a killed person (called body) (this is the improper print dead property rule):
if body is improper-named:
say “dead [run paragraph on]”.
After printing the name of a killed person (called body) (this is the proper print dead property rule):
if body is proper-named:
say “'s [if body is plural-named]bodies[otherwise]body[end if]”.[/code]
Code for showing the possessions of a dead person (from Inform ATTACK):
After examining a killed person (this is the give list of possession on dead person rule):
if the number of things carried by the noun is at least one:
say "On the [if the noun is plural-named]bodies[otherwise]body[end if] of [the noun] you also see [list of things carried by the noun with indefinite articles].".[/spoiler]
In The Z-Machine Matter, I have used the latter approach (a separate Corpse object) but there’s still work to be done either way. And I probably there are still some bugs I need to fix. (At one point if you talked to the corpse it shrugged. Rigor mortis, no doubt.) The game is available at IntroComp among many other fine games if you are curious.
Thanks to all. Yesterday, I wrote the code for killing off the NPC in question. I wound up implementing the dearly departed as a separate corpse object. I placed the stuff he was carrying (only one item, actually) in the room where he died (on the theory that he would likely have dropped it). I transferred his clothing to become parts of the corpse (the exception being his hat, on the theory that it probably would have been destroyed when his head was blown off). I mention the clothing in the description of the corpse, but otherwise block any attempt to take it with a wisecrack about stripping dead bodies of their clothing. That way, the player never gets a “the jacket seems to be a part of Fred’s corpse” message.
I think it depends on the context. In my WIP there’s going to be a little bit of combat, so I have three states for people: alert, comatose, and dead. The standard rules that prevent interfering in people’s personal space are all modified to be aware of the different states.
It’s also a game with zombies, so dead is a bit of a fuzzy concept. I’ve been debating whether to add a fourth “reanimated” state.
hi, in my WIP, i do have skirmishes and a good handful of dead NPCs. i created dead NPC objects, but its a huge set of code im hammering out for it and as yet, ive not even alpha-tested it. im concerned when i read above about the corpse reacting to things. does this happen if the corpse is an object, not a “person”? should i be worried? (btw, newbie here)
If the corpse is a non-person thing (notice that every person is a thing, and every thing an object, in Inform 7), you won’t have any problems. You might want to write some custom responses, of course: the player probably shoulnd’t be allowed to take a corpse, and certainly shouldn’t be allowed to take two. But the corpse won’t behave like a living person.