I7: Leaving tracks


I’m trying to work out a mechanic in the game I have been working on
where characters leave a scent behind that is detectable for a number
of turns after they are gone and then vanishes. I’ve tried working
this out a few different ways… Nothing quite works right and I
thought someone here might have a better idea how I should go about

What I’d like to happen is basically that when a character (player or npc) roams
through a room, the room includes their scent in its
description for ten turns or so. These could pile up in a list,
depending on who has roamed through recently.
Thanks in advance for your thoughts.

Hey there!

Two spontaneous suggestions:

  1. Add a table to every room (at least where the feature will be important), where you can store the name of the stinkers and the number of turns. Should be easy enough to implement although a bit cumbersome since you would have to add a unique table to every room and roughly know the number of blank rows (i.e. the maximum number of stinkers).

  2. Add two lists to every room, one for the stinkers, second for the number of turns. You can then run through the first list when you need to add text and through the second list during every turn to decrease the number of turns. If one value should hit 0, delete the Entry and the Entry at the same position in the list of stinkers. This is not as nicely tied up as in tables, so there is some risks involved, plus lists are more resource hungry, so it might be a bit too expensive, if you’re planing something with z-machines.

There’s going to only be four creatures that leave a scent in the game, so I’ve got that potential table manageable. Every room in the game would list off its scents, so that might be a little labor intensive giving each a table. Also, I don’t think I know how to make a rule for listing off the contents of a table in a room description…

would it be like:

After printing room description: say "You smell [element in row A of the Table of room1 Scents], and [element in row B of the Table of room1 Scents]."

How do I make that conditional to whether or not there are table entries, and how many? " say "[if there are elements in the Table of room1 Scents] You smell [element in row A of the Table of room1 Scents][end if]" ?

I might have to do it with two lists, since I’m not very good with tables…

If there really are only four then it’s probably a better idea to handle them as entries. Something like this:

Table of Scent Storage
Ro Stinker 1 Stinker 2 Stinker 3 Stinker 4
a room a number a number a number a number

That way you don’t have to work with multiple tables and you could do something like

After printing room description: choose row with Ro of (location of player) in Table of Scent Storage; say "You smell [if Stinker 1 Entry is not 0]Stinker 1[end if][if Stinker 1 Entry is not 0 and (Stinker 2 Entry is not 0 or Stinker 3 Entry is not 0)] and [end if][if Stinker 2 Entry is not 0]Stinker 2[end if][if Stinker 2 Entry is not 0 and Stinker 3 Entry is not 0] and [end if][if Stinker 3 Entry is not 0]Stinker 3[end if]."

(Just noticed that I skipped the fourth stinker but I guess the idea should be clear enough now)

Here is a different approach using kinds and relations.

This method will work for an arbitrary number of rooms and persons. Note that in this example, Shemp does not give off a scent, but Larry, Moe, and Curly do. To make Shemp leave a scent trail behind, just add “Shemp leaves behind ten scents”.

Note that the player leaves scent objects behind also, but we only see messages for NPC scents. This is partly because the message for the player’s scent would pretty much always be useless information (since you know where you are), and partly because conjugating verbs is a pain. So I coded it that way.

[code]“More Test Stuffs” by Troy Jones III

Section - Defining Scents

A scent is a kind of thing. A scent is always scenery.
A scent has a number called age. The age of a scent is usually zero.
Instead of doing something with a scent, say “It’s a scent trail left behind by [random thing that leaves behind the noun], [age of noun in words] minutes old. You can’t really do anything with it.”

Leaving behind relates one person to various scents.
The verb to leave behind (it leaves behind, they leave behind, it left behind, it is left behind, it is leaving behind) implies the leaving behind relation.

Definition: a scent is NPC if it is not left behind by the player.

Section - Dramatis Personae

The player leaves behind ten scents.
Larry leaves behind ten scents.
Curly leaves behind ten scents.
Moe leaves behind ten scents.

The description of yourself is “Four paws and brown and white fur. You also have a keen nose, though you can’t see it very well without crossing your eyes.”

Section - For some reason we perceive scents by looking-- just go with it

After looking:
say “Exits: [exit list][smell list]”;

Instead of smelling:
say “You sniff the air[smell list]”.

To say smell list:
if an NPC scent is in the location:
let 1st-item be true;
repeat with stink running through NPC scents in the location:
if 1st-item is true:
say “.[paragraph break]You can smell [stink]”;
now 1st-item is false;
say “, and [stink]”;
say “.”

Rule for printing the name of a scent (called odor):
say “that [random thing that leaves behind odor] was here [age of odor in words] minute[if age of odor is not one]s[end if] ago”.

To say exit list:
let place be location;
let first-in-list be true;
repeat with way running through directions:
let place be the room way from the location;
if place is a room:
if first-in-list is true:
say " [way]";
now first-in-list is false;
say “, [way]”.

Section - ET rule that distributes and recycles scents and moves the NPCs randomly

Every turn:
repeat with mover running through persons that are not the player:
let destination be a random room;
let thataway be the best route from the location of the mover to the destination, using doors;
if thataway is a direction:
try mover going thataway;
repeat with stinker running through persons that leave behind something:
if the location of stinker encloses something left behind by stinker:
repeat with reek running through scents in the location of stinker:
if reek is left behind by stinker:
now the age of reek is zero;
move a random off-stage thing left behind by stinker to the location of stinker;
repeat with stench running through scents:
if stench is not off-stage:
increment age of stench;
if age of stench > 9:
now age of stench is zero;
now stench is off-stage.

Section - Rooms

Front Porch is a room. “The front porch of your house.”
Driveway is southeast from Front Porch. “Your driveway slopes down to the north and curves left into the garage in back of the house.”
Front Lawn is south from Front Porch and west from Driveway.
Street by Your House is south from Driveway and southeast from Front Lawn.
Foyer is northeast from Front Porch. “A lot of rooms connect to the Foyer so a lot of NPCs will pass through here.”
Master Bedroom is south from Foyer.
Master Bathroom is northeast from Master Bedroom.
Guest Bathroom is southeast from Foyer and southwest from Guest Bedroom.
Guest Bedroom is east from Foyer.
Laundry Room is northeast from Foyer.
Garage is down from Laundry Room and north from driveway.
The Den is north from the Foyer.
The Living Room is west from the Foyer and southwest from the Den.
The Attic is up from the Foyer. “Remember that the Every Turn rule doesn’t fire on turn one, so there won’t be any scents here at first.”
The Family Room is down from the Den and east from the Garage.
The Backyard is north from the Family Room.

Larry is in Attic.
Curly is in Attic.
Moe is in Attic.
Shemp is a man in Attic.

test me with “ne / l / l / smell / l / l / l / n / l / l”.[/code]

Output looks like this (illustrating one scent disappearing after ten turns, and another scent being refreshed before it expires):
You can see Curly here.

Exits: south, southwest, down.

You can smell that Larry was here two minutes ago, and that Moe was here seven minutes ago, and that Curly was here one minute ago.

Curly goes down.

Exits: south, southwest, down.

You can smell that Larry was here three minutes ago, and that Moe was here eight minutes ago, and that Curly was here two minutes ago.

Exits: south, southwest, down.

You can smell that Larry was here four minutes ago, and that Moe was here nine minutes ago, and that Curly was here three minutes ago.

You sniff the air.

You can smell that Larry was here five minutes ago, and that Curly was here four minutes ago.

Exits: south, southwest, down.

You can smell that Larry was here six minutes ago, and that Curly was here five minutes ago.

Curly arrives from the south.

You can see Curly here.

Exits: south, southwest, down.

You can smell that Larry was here seven minutes ago, and that Curly was here one minute ago.

Curly goes down.

Moe arrives from the south.[/rant]

Awesome! Thank you! I never would have figured that out…