|
Each game item (room, mobile, or object) can have a script. A script is
composed of one or more triggers, which work in collaboration to define complex
actions of the game object. A trigger is a definition of an event that the
script watches for, and list of commands to execute when that event occurs.
There are several different types of triggers. Each trigger type determines
when the trigger will be checked. For example, a mob speech trigger is checked
every time a character who is in the same room as the mob with the trigger uses
the 'say' command. A room enter trigger is checked every time a character enters
the room. There are two parts of the trigger used to determine if the trigger's
commands are executed when it is checked, the argument and numerical argument
(NArg). Some triggers use both; some may use only one of the two; and some may
use neither. The interpretation of these two fields is dependant on the type,
and is described in more detail in Triggers
section of this document.
When an event in the game occurs, each script in the room where the event
occurred is checked to see if there are any triggers which are supposed to react
to that event. A trigger currently running (such as from a 'wait' command) is
skipped. Only one trigger of each script will be run by a single event. For
example, if there are two triggers on a script, and both are the same type with
the same arguments, the second trigger will only be run if the first one is
already running.
Triggers can be of more than one type. For example, to simulate a cursed
item, a trigger on the object could be of types drop, give, and remove. A more
common combined trigger would have both random and global types, so the random
trigger would be check even when the zone was empty. Combined triggers must have
the same argument and numerical argument.
The other component of a trigger is the command list. This is a series of
commands that are executed when the trigger is run. Commands are chosen from two
groups of commands, script specific commands and game commands. Script specific
commands are those commands that only the script interpreter can recognize.
These include flow control commands (such as if, elseif, else, end, halt, wait,
and return), and commands to manipulate variables (such as set, eval, unset, and
global). Script specific commands are explained in section 5.1. Game commands,
covered in detail in section 5.2, are similar to commands that players can use.
|