7.13. Traveling Characters

| Chapter 7: Other Characters |

| 7.13. Traveling Characters

There are a number of ways we can make characters navigate our map. We might reasonably want them to approach and follow the player (as in Van Helsing); or to allow the player to follow characters who have left the room (as in Actaeon).

Characters who are less interested in the player will more likely follow their own courses around the available geography, however. A character may move randomly from room to room, as demonstrated in Mistress of Animals; he may follow a path that we have specifically written in advance, as Odyssey shows; or, most elegantly, he may use the "best route" calculation to find the best possible way to a given target room, as seen in Latris Theon.

This final method is arguably the neatest solution to character movement, allowing for characters to act in sophisticated ways; if we incorporate the Locksmith extension, other characters will even unlock and open doors that are in their way. The chief catch is that it should not be used too profligately with large numbers of characters, since on slow machines the processing power required to plan all their travel will make a noticeable difference to the running speed of the game.

All the same, the constraints are not so severe as to preclude having a moderate number of route-finding characters all wandering around at once. This does introduce a new problem, however: movement descriptions can become hard to follow if every turn produces long reams of reports such as

> Joe enters the room from the south.
> Lawrence opens the gate.
> Lawrence departs to the west.
> Lucy comes in from above.
> Ted enters the room from the south.
> Bill departs to the west.

Patient Zero tackles this problem by calculating all of the character movement without printing any text; it then combines similar or related events into coherent paragraphs, as in

> Rhoda and Antony walk into the Post Office. Rhoda could have been rolling in chocolate and Antony looks as though dipped in french vanilla.

or

> Antony opens the iron gate. He goes through.

See Doors, Staircases, and Bridges for some technical details of allowing other characters to interact with doors when they're in rooms that don't contain the player

78
| Example Mistress of Animals A person who moves randomly between rooms of the map. |
WI

263
| Example Odyssey A person who follows a path predetermined and stored in a table, and who can be delayed if the player tries to interact with her. |
WI

185
| Example Latris Theon A person who can accept instructions to go to new destinations and move towards them according to the most reasonable path. |
WI

291
| Example Actaeon A FOLLOW command allowing the player to pursue a person who has just left the room. |
WI

37
| Example Van Helsing A character who approaches the player, then follows him from room to room. |
WI

Suppose we want to write a character who tries to be in the same room as the player. We will do this by testing every turn whether the character's location and the player's location are the same; if the answer is no, the character will look for a path to the player's location, then try to move along that path. (We will learn more about finding paths and giving characters instructions later.) The result will be that if the player ever moves to another location, the character will automatically pursue him. "Van Helsing" The Drawbridge is a room. North of the Drawbridge is the Immensely Enormous Entry Hall. West of the Entry Hall is the Vast Dining Area. North of the Vast Dining Area is the Colossal Kitchen. The Spooky Guano-filled Attic is above the Entry Hall. Count Dracula is a man in the Attic. In the following condition, we could also have written "if the location of Count Dracula is not the location", because "location" by itself is always understood to be the player's location. But it seemed better for clarity to write it this way: Every turn: if the location of Count Dracula is not the location of the player: let the way be the best route from the location of Count Dracula to the location of the player, using doors; try Count Dracula going the way; otherwise: say "'Muhahaha,' says Count Dracula." Test me with "z / z / n / w / e / u / z / d".

396
| Example Patient Zero People who wander around the map performing various errands, and in the process spread a disease which only the player can eradicate. |
WI

Previous | Contents | Next