Latest problem

The character is being pursued by the monster. The deal is, the monster shows up in the location once a certain action (examining the mouldy book is performed, and my intent was to give the character one turn to get away. I have also programmed the monster to pursue, and again the character has one turn to get away. But what happens is that as soon as the character takes his turn to get away, the monster catches up with him (and the character dies, natch).

Here’s the code:

The monster counter is initially zero. Every turn when Attic is visited: if the monster counter is two: end the story saying "The monster caught up with you and ripped you to shreds. You have died."; otherwise if the monster is in the location: increment the monster counter; otherwise: now the monster counter is zero.

I don’t know what to do.

I have similar code for the monster’s predecessor, the ghost, who also pursues, and my character is able to evade him, which was my intent.

Here’s that code:

[codeThe ghost counter is initially zero.
Every turn:
if the ghost counter is two:
end the story saying “It touched you. You have died.”;
otherwise if player is in Hallway:
now the ghost counter is zero;
otherwise if the ghost is in the location:
increment the ghost counter;
otherwise:
now the ghost counter is zero.][/code]

If the player meets the monster in location A, the counter is set to one. The player moves to B; the monsters follows; and then, assuming that this every turn rule runs after the monster has moves, the counter is set to two and the player dies.

The counter is only reset to zero when the player and the monster are in a different room when the every turn rules run, and that is apparently not happening.

Assuming that you also use an every turn rule to move the monster, you could change that into a “Last every turn” rule, which forces it to go after the “Every turn whenever the Attic is visited” rule.

In terms of design, you should be aware that these kinds of sudden death situations are often quite unsatisfying for players. But perhaps they do work well in your game.

Tried it. Unfortunately, it didn’t work. Anyone else have suggestions?

In the rule that you use to move the monster to the player’s location, try adding a clause that resets the counter to zero. (But it’s hard to diagnose exactly without all your code for moving the monster and changing the monster counter.)

I almost thought I had the problem solved. I rewrote the code thusly:

Every turn when Attic is visited:
if the monster counter is two:
end the story saying “The monster caught up with you and ripped you to shreds. You have died.”;
otherwise if the monster is in the location:
now the monster counter is zero;
otherwise:
increment the monster counter.

It looked like it worked for about three turns, but then the monster unexpectedly killed the character.

Carry out examining mouldy book when ghost is not off-stage:
now the ghost is off-stage;
now the monster is in the location of the player.[/code]

This looks backward–every time the player isn’t in the same room as the monster it will increment the counter, so two turns after the player leaves the monster’s room the counter will hit two and the monster will kill the player.

The monster is chasing the player, right? So you probably have a rule like “Every turn when the Attic is visited and the monster is not in the location and the monster is on-stage: now the monster is in the location of the player.” If that rule runs before the other one (and as written it’s more specific, so it’ll run first), then the monster will be in the player’s location every time the other rule checks the monster counter, so it won’t actually be possible for the player to reset the counter by moving away from the monster.

(I’d also suggest tweaking the counter so the player has time to do something before they need to run away. If you have to run away every turn after the monster shows up, and you haven’t yet examined the thing that lets you get away from the monster, then you just have to run away every turn and you never get to try anything out. This is not fun, even if you’ve hinted that you have to run away from the monster.)

Thanks, matt, but I’m not sure what you’re telling me here. I keep staring at my code, and it OUGHT to work.

Right now you have:

otherwise if the monster is in the location: now the monster counter is zero; otherwise: increment the monster counter.

Now, if the monster is in the location, the counter goes to zero. If the monster is not in the location, the “otherwise” fires, and the counter gets incremented.

So if the monster is in the Attic and the Player is in the Cemetery: The first turn, the counter gets incremented to one.
The second turn, the counter gets incremented to two, and the player gets the message about the monster appearing and killing them.

This seems like the opposite of what you wanted.

Well, I had a little work-around for the location of the monster. I wanted him off-stage at the beginning of the game, but Inform wouldn’t allow that. So the monster starts off in the attic, but as soon as the player escapes from an open grave, but monster’s location is switched there.
Then, once the player gets into the attic and examines the mouldy book, the monster’s location is switched to the attic.
In between posts I did a little more fooling with the code, and what I found out is that the monster counter is set to one when the monster shows up after the player examines the book, not to zero as I had intended.

You can start an object off-stage by just not giving it a location. (In other words, “There is a book.” on its own will create a new object and place it off-stage as no location has been specified for it.)

Thanks, Draconis, I had forgotten that, but I have now solved the problem of the monster killing the character unexpectedly.
I am happy to report that I have an entirely new problem now, and if it gets too tough, I’ll post a new thread. Thanks to matt w and all else who responded.