The Reliques of Tolti-Aph

An interactive fiction by Graham Nelson (2005) - the Inform 7 source text

Home page

Contents
Previous
Next

Complete text
Section E(s) - Traps and earthquakes

[Donnelly's original "Sorcerer's Cave" had four hazards, the others being Medusa and Mutiny, but neither works very well for a game played with a single character rather than a "party" acting as a team. Trap and Earthquake are essentially unchanged from the original.]

Hazard-playing is an action out of world applying to one thing.

Every turn:
    let the locale be the location;
    repeat with hazard card running through hazards in the locale
    begin;
        try hazard-playing the hazard card;
    end repeat.

To make the player fall to (destination - room):
    if the destination is unvisited, draw cards for the destination;
    move the player to the destination.

Carry out hazard-playing a Trap:
    return the noun to the pack;
    let the position below be the vector sum of the grid position of the location and the vector of down;
    if the position below is <0,0,0>, continue the action;
    if the location is descending, continue the action;
    let the place below be the room at the position below;
    if the place below is not Solid Rock
    begin;
        say "You fall through a concealed Trap in the cave floor, to emerge back at...";
        change the down exit of the location to the place below;
        make the player fall to the place below;
        stop;
    end if;
    if a labyrinth room (called the place below) is unplaced
    begin;
        say "You fall through a concealed Trap in the cave floor!";
        position the place below at the position below;
        change the down exit of the location to the place below;
        if the place below is not ascending,
            change the up exit of the place below to Solid Rock;
        make the player fall to the place below;
    end if.

A room can be Earthquake-damaged or Earthquake-undamaged. A room is usually not Earthquake-damaged. Instead of going to an Earthquake-damaged room, say "That whole cave has collapsed in an earthquake, and is impassible."

Carry out hazard-playing an Earthquake:
    return the noun to the pack;
    if the previous location is not a labyrinth room, continue the action;
    if the previous maze level is 1, continue the action;[1]
    if the player is in the previous location, continue the action;
    say "An Earthquake causes a rockfall back in [the previous location]!";
    now the previous location is Earthquake-damaged.


Note

[1]. An Earthquake causes a rockfall to block the room just left behind: that would make no sense up in the hedge maze on level 1.