C. Everett's Concept Exercises

Now that I’ve finished the game I was working on, I want to try getting a better grasp on Inform 7. I thought it made sense to make this a different thread from my other one, since these problems don’t really involve games I’m really working on. They’re just concepts I had that I want to try and get working.

The first one is decapitating an NPC and leaving behind a corpse and a severed head that can be picked up by the player. A little graphic, maybe, but it’s just an exercise.

The code I have right now is:

Execution Chamber is a room.  Victim is a neuter person in execution chamber. 

Decapitating is an action applying to one visible thing.  Understand "decapitate [thing]" as decapitating.

Storehouse is a room.

Victim's corpse is a thing.  It is in the Storehouse.  It is fixed in place.  Victim's severed head is a thing in the Storehouse.

The description of Victim's corpse is "A headless body.  If you had not done the de-headifying yourself, you would have no idea who it was.".

The description of Victim's severed head is "Victim's head.  He wasn't too bad looking.  Too bad he pissed off the king.".

Check decapitating a thing:
	if thing is a person:
		if person is Victim:
			remove Victim from play;
			move Victim's corpse to Execution Chamber;
			move Victim's severed head to Execution Chamber;
			say "Your blade comes down, and parts his head from his shoulders.".
	if thing is Victim's severed head:
		say "It wouldn't do much good, would it?";
	if thing is Victim's corpse:
		say "He's only got the one head!".

This is what Inform says:

I think maybe I’m misusing ‘check’. Is that part of it?

I think you misplaced a full stop.

if person is Victim:
remove Victim from play;
move Victim’s corpse to Execution Chamber;
move Victim’s severed head to Execution Chamber;
say “Your blade comes down, and parts his head from his shoulders.”. [size=150]<---- here[/size]
if thing is Victim’s severed head:

That was it. Thank you!

But now it’s doing something I don’t know how to explain:

The problem is in your if checks. You’re asking for example, is the severed head a thing? It is, so the condition is true.

You want, ‘if noun is Victim’s severed head’, etcetera.

Also the check rule can be just ‘check decapitating’ in this case.

In regard to the idea of general concepts, moving beyond any particulars I’d suggest the following:

a) You’ll probably be better off down the road if you start using some “best practices” now. You’re currently sticking everything associated with this example in a single check rule (reminiscent of an “instead” rule), which if repeated many times in many unrelated cases will lead to code that will probably become too confusing for you to even decipher let alone modify anymore. I think you’d be better off sticking to using “check” rules for checking conditions that allow an action to proceed or fail, using “carry out” rules for changing the game world (moving the parts and removing the npc), and using “report” rules for telling the player how the game world has changed due to his actions. This isn’t an issue of functionality as much as an issue of convenience for yourself in the future. In any case, I think anyone who wants to move beyond doing the simplest things with Inform must master the check/carry out/report system (as opposed to the newbie/quick-start “instead” system) so the sooner you start thinking about everything in these terms the quicker you’ll progress.

b) As you start to consider more expansive options, you’ll need to start considering more extensive implementations of these options. Given the rule in your example, for instance, what happens if the player:

–tries to decapitate an inanimate object?
–tries to decapitate the player-character?
–tries to decapitate someone other than victim?
–tries to decapitate people when not carrying a blade?
–tries to decapitate people in rooms other than the execution chamber, with or without a blade?

–Also, how do characters react to an attempted decapitation of themselves or witnessing the attempted decapitation of another character? It seems problematic to imply that “victim” simply stands still and complies with the player’s attempted assault. Furthermore if one attacks and kills Joe’s pal Fred, does Joe’s behavior toward the player change?

These are more philosophical issues than technical issues. You need to make a decision about how far your games will go to accomodate unconventional behavior by a player. Sometimes this falls under the category of making the game “user-friendly,” while in other cases it’s more about being thorough and making the game unbreakable. My own opinion on these matters is that if you publicly release a game, some wiseacre out there will intentionally try all sorts of irrational in-game behavior and then whine endlessly about how your game is lame if it doesn’t accomodate the player’s every desire to be silly and break the system. Whether that happens or not, by designing as if it will happen you’ll become a much better designer in general, and the quality of your work will automatically increase considerably (I’m speaking of general principles, and not implying that there’s any problem of quality in your current work). If you’re familiar with the old “Fallout” crpg series, for example, consider the design flaws that enabled the commonly used tactic of poisoning npcs with medicinal super-stimpacks that were intended to be used for healing, and the resulting genuine frustration of players in cases where this unexpected behavior broke the functionality of the games.

c) Rather than having all these objects (which will become hard to keep track of as their number grows) off-stage, why not just give each character a body and head? Decapitation would then involve removing the attached head and resolves some of the issues listed in (b) above. This approach would involve an investment of coding time up-front (during which you’ll likely incidentally learn a lot), but would make things much easier down the road compared to the time one would spend writing special rules for each case and then sorting out how all those special rules interact with each other.