MRE
Many older interactive fiction games required the player to find food and eat on a regular basis in order to avoid death. This effect was often unrealistic (since most people can survive much longer than a few hours without eating) and is often seen as an annoyance. However, for the sake of argument, suppose that we do want to construct a hunger-and-death system.
To make things a little more interesting, we will postulate that different foods are differently filling, so that if the player manages to find something really caloric, he is off the hook on his hunger search for a while.
We will also implement the system so that the player gets messages when he is hungry, then dies a short time later. (The times involved are ludicrously short, but this allows us to see the effects within a simple example. In a real game we would want to allow a considerably longer timer for the hunger to play out.)
First, a little scene-setting:
Now we define our food, and add some special instructions for what happens to our hunger counters when the food is eaten:
The first of those two phrases, "now the player is replete", causes the player to cease to be hungry; the second one sets up a future event in which the hunger sets in again. The length of time until that event depends on how satisfying the specific food is. Now we define that event:
Note "if the player is hungry": it is possible that the starvation event will be set up but the player will eat before it occurs; in that case, we want it not to take effect.
And now, since we really ought to give the player some warning of what is happening to him:
hunger |
"Gosh, you're starving." |
"It feels as though you haven't eaten in days. Weeks, almost." |
"The world seems to slow down and everything becomes sharper and brighter. You are a hunter, a hunter of foodstuffs." |
"You find yourself staring at [the random visible thing that is not the player] and wondering how it would taste." |
Test me with "eat apple / z / z / z / eat candy bar / z / z / z / z / z / z / z / z / z".
This room has been reinforced after each incident -- and there have been dozens in the last two months -- so that it now rivals Fort Knox. Only your new skill and speed enabled you to dodge the motion sensors, knock out the computerized security system, fool the retinal scanner, and punch a hole in the steel containment grating. But you're inside now.
You can see an apple, a candy bar and a large plate of pasta here.
>(Testing.)
>[1] eat apple
(first taking the apple)
You eat the apple. Not bad.
>[2] z
Time passes.
>[3] z
Time passes.
>[4] z
Time passes.
It feels as though you haven't eaten in days. Weeks, almost.
>[5] eat candy bar
(first taking the candy bar)
You eat the candy bar. Not bad.
>[6] z
Time passes.
>[7] z
Time passes.
>[8] z
Time passes.
>[9] z
Time passes.
>[10] z
Time passes.
>[11] z
Time passes.
The world seems to slow down and everything becomes sharper and brighter. You are a hunter, a hunter of foodstuffs.
>[12] z
Time passes.
Gosh, you're starving.
>[13] z
Time passes.
You find yourself staring at the large plate of pasta and wondering how it would taste.
*** You have starved ***
Would you like to RESTART, RESTORE a saved game, QUIT or UNDO the last command?
> [14] z
Please give one of the answers above.