Int Fic Locked Item

Locked Item

Purpose: To prevent a player from taking/opening/using an object until they have met a certain criteria. Literally, a second object is requited to unlock the object, thus enabling it to be opened.

Problem: The author wants to render an object unusable, until something else is done to it, either as a puzzle (The player must find a key before s/he can proceed into the next room), or to preserve a sense of reality (the player can't very well pick up a hot coal without some sort of protective glove)

Context: In the simplest case, an object (often a container of some sort) exists in a game location. This object cannot be accessed unless the player solves the associated puzzle (usually in the form of obtaining a second object)

Forces: Solution: The author traps the normal VerbActionRoutine for accessing the object, allowing it to proceed iff (if and only if) the puzzle has been solved.

A "Trap" is laid, which prevents the player from proceeding. By solving the "Puzzle", the "Solution" occurs, which counters the conditional set in the "Trap"

The general form of this solution requires that some flag within the game be set, by the puzzle, when it is solved. The verb trapping then conditionally checks if this flag has been set.

Examples: In inform, the basic case, an object which cannot be opened unless unlocked with a second object, is accounted for thus:

 Object box "locked Box"
	with name 'locked' 'box',
		with_key key,
	has locked container openable lockable;

object key "key" with name "key";

-> Trap : if (box hasnt locked) <- from the Open VerbActionRoutine -> Puzzle: obtaining the key -> Solution: give box ~locked <- from the Unlock VerbActionRoutine

The attribute "Openable" tells the parser that the object is a candidate for the Open command. The attribute "lockable" tells the parser that this item may be locked and unlocked by the player. The attribute "locked" tells the game that this object is currently locked. The standard grammar for Open prevents the player from opening a locked object. The property "with_key" contains the object name of the key to the box. Only this object can be used to unlock the box.

When the key object is used to unlock the box, the attribute "locked" is removed, and the player is allowed to open the box at their leisure.

An alternative solution is presented in the inform library NewLock?.H by L RossRaszewski. Using this library, the author may omit the line "with_key key," from the door definition, instead adding the line "key_to box," to the key's definition.

The general solution, in inform makes use of the before entry point. If the puzzle has not been solved, this entry point should return true, halting further action by the library. For example, if a computer could be switched on only if the player had repaired the power supply, one would do thus:

 object "computer"
	with name "computer",
		before [; switchon: if (p_supply hasnt general) 
		"You can't activate the computer until the
		power supply is working.";];

! Fixed a slight bug here where the computer would only turn on if the power supply ! hadn't been fixed yet :-) -- premchai21

object p_supply "power supply" with name "power" "supply", before [; fix: give self general; "You repair the power supply";];

-> Trap: if (p_supply has general) -> Puzzle: fixing the power supply -> Solution: give p_supply general;

where Fix is an VerbActionRoutine defined in your source code. If the puzzle requires a player merely to be holding an object, then rather than setting attributes, the author may set a trap such as

-> Trap: if (x in player) or -> Trap: if (indirectlyContains(player,x))

in which case, the solution,

-> Solution: move x to player;

is handled by the VerbActionRoutine for Take.

Rationale: The game must have a way of telling if the puzzle in question has been solved. The puzzle is solved when the "Solution" occurs. A "Trap" prevents the action in question from occuring until that "Solution" is performed.

Relationships: The IntFicLockedItem is closely related to the IntFicTransporter, and indeed, the two are special cases of each other: all Transporters which block the players progress in some way are Locked items, and all locked items which, when solved, move the player, are Transporters.

Known Uses: Locked doors and boxes fit the literal (or "simple") type locked objects. Most IF puzzles are some advanced form of the locked object.

[ Please edit this if you think it's over complicated, sloppy, or just plain bad :-) L RossRaszewski.]
EditText of this page (last edited November 11, 2001)
FindPage by searching (or browse LikePages or take a VisualTour)