Mini-Tutorial

POISON

Written by Rich Dersheimer


First create a room and give it a description, whatever you like.

Create a dynamic object called "an apple" and have it start in the room. Give it a description like "It is a shiny red apple." Don't worry about making it edible, we're going to over-ride the "eat apple" system command anyway.

Create a dynamic object called "some antidote" and have it start in the room. Give it a description something like "It is a bottle of medicine." Don't make it edible either.

Under Adventure>Introduction check the box marked "Display first room" so that the player will see the apple and the antidote when the game starts.

Add a task called "* eat * apple *" (the asterisks are there so that commands like "I eat the yummy apple quickly" will work) The message upon completion should be something like "You eat the apple, but it tastes kind of funny." Let the task be completeable in all rooms, and add a restriction that "an apple must be held by player" - else display "You don't have the apple." Add an action to the task "Move an apple to room hidden."

Add a task called "* drink * antidote *" and have the completion message display "You drink up all the medicine and feel much better." Let the task be completeable in all rooms, and add the restriction that "some antidote must be held by player" - else display "You don't have the antidote." Add an action to the task - "Move some antidote to room hidden."

So far you have a room with an apple and some antidote in it. When the apple is eaten, it vanishes. If you drink the antidote it vanishes too. If you turn the debugger window on, you can monitor the tasks, and the location of the apple and antidote.

Now the fun part - getting the game to display the player's upset stomach every turn he is poisoned...

Add an event called "Poisoned" and have it start "After task Eat * Apple is complete." The event should last from 1 to 1 turns, and the "Restart this event as soon as it finishes" box should be checked. On the descriptions page, for what to display on event finish, type in "You feel sick to your stomach." You have to put it in the event finish box, because the event start message only appears once, but the event finish message appears every turn the event runs. On the Advanced tab page, set "Event can be paused if drink * antidote is completed."

Run the game again. Eating the apple now triggers the event "Poisoned" and "You feel sick to your stomach." will be displayed every turn. When the player drinks the antidote the "Poisoned" event is permanently paused.

That's the basics of getting a message to display every turn. You can use this in many situations - water dripping from a faucet, machinery operating, etc. Here's a couple of ways we can spice up this event.

In the room description, add "There is a lever on the wall."

Under Adventure -> Advanced -> Variables add a variable named "Poisoned" and leave it starting at 0.

Add a task called "* pull * lever *" and make it completeable in this room. Have the description when completed say "You yank down on the lever." Add a restriction "Poisoned must be equal to 0" else display "You are too weak to pull the lever!" Make it a repeatable task.

Add an action to the "* eat * apple *" task. Have it "Change Poison TO exact value 1."

Now add an action to the "* drink * antidote *" task. Have it "Change Poison TO exact value 0."

Run the game. Now the player won't be able to pull the lever if he is poisoned! You could limit many tasks like this.

Okay, how about if instead of displaying "You feel sick to your stomach" every turn, we display a random message about what the poison feels like?

Create a variable called "SickMessage" and set it to a value of 1 to start with.

Open up Windows Notepad and copy these 4 lines into the window.

[SICK=1]|sick to your stomach.
[SICK=2]|like you might puke at any moment.
[SICK=3]|nauseous.
[SICK=4]|like you are about to faint.

Save the file as "Poison.alr"

In Generator, use File>Import>Language Resource to import the Poison.alr file.

In the Poisoned event, change the event finish message to:

You feel [SICK=%SickMessage%]

Add a task called "# change sickness" and make it completeable in all rooms, make it repeatable, and give it an action "Change SickMessage TO random value between 1 and 4."

In the Poisoned event, under Advanced, have "when event finishes" execute the "# change sickness task."

Now the game will display a random message every turn that the player is poisoned.

To see the ALR, load the included example program and export the ALR from Adrift Generator.