Room Triggers
RoomTrigger Command
The roomtrigger command is defined as a separate command.
roomtrigger <name> <type> <call> [<trigger>]
Adds a trigger to the room. Use <name> to give the trigger an unique name. Non-unique names will be rejected. Also numbers are allowed names. This name can be used to delete the trigger later. Type is the trigger type, like “look”, “enter” and so on. Trigger types are described later. <call> is an TCL-script that should be executed. Normally this will be the name of a procedure to execute. The <trigger> gives the trigger condition. This should be a TCL command (or script) that returns a boolean. If the boolean is true, the <call> script will be executed. If no trigger condition is given, the call script will always be executed.
The <trigger>-script may generate variables that then can be used in the <call> script. The <trigger> script has also access to all other functionality you would normally have in a TCL-mobprog.
Trigger Types
Triggers are fairly easy to add, but this basic list should hold for most needs. Their names, argument list syntaxes, and translation into more articulate English are given below. Some triggers generate a trigger value. This value can be accessed with the [trig] command or trough the $::t variable. The trig command has a lot of routines for easy access to these trigger values.
room triggers Command Reference
trigger pre_attack
The trigger fires when somebody is trying to start a fight. If the trigger returns false, a fight will NOT break out. Take care, for the opposite is not true: returning true will not guarantee a fight!
trigger kill
This trigger is checked whenever a PC attacks the mobile. The check occurs only ONCE, in the beginning of combat. Useful for summoning assistance etc. (See room mload).
trigger death
Fires whenever somebody dis in the room. Second char is the killer.
trigger enter
This trigger is called when a player enters a room.
trigger interpret_unknown
This trigger is tested every time a character has entered a command which wasn't recognized as a valid command.
NOTE: Both mobs and players can trigger this trigger.
trigger pre_interpret
This trigger is tested when a character is going to execute a valid command but the command hasn't been executed yet. If the procedure returns a TRUE, the command is blocked.
NOTE: Both mobs and players can trigger this trigger.
trigger post_interpret
This trigger is tested every time a character a valid command is executed.
NOTE: Both mobs and players can trigger this trigger.
trigger pre_social
This trigger is tested when a character is going to execute a social but the social hasn't been executed yet. If the procedure returns a TRUE, the social is blocked.
NOTE: Both mobs and players can trigger this trigger.
trigger social
This trigger is tested every time a character a social is executed.
NOTE: Both mobs and players can trigger this trigger.
trigger leave
This trigger is called when a player tries to leave a room. If it returns FALSE, the leaving is prevented. If it returns TRUE, the person leaves the room.
trigger canlock
Called before the door is locked. If it returns a FALSE, the door will not be be locked. This trigger REPLACES the check for a valid key. The exit flag 'tcl_lock' is required on the exit for this trigger to fire.
trigger pre_lock
Called before the door is locked. If it returns a FALSE, the door will not be be locked.
trigger lock
Called when the door has been locked.
trigger pre_look_ed
Called before the extra description is being looked at. If it returns FALSE, the extra description will not be shown.
trigger look_ed
Called when the extra description has been looked at.
trigger pre_recall
This trigger is tested before a player is going to recall. If it returns FALSE, the recall will not continue.
trigger recall
This trigger is tested just before the player is disappearing from the room.
trigger recall_to
This trigger is tested after a player successfully recalled.
trigger pre_reset
Called before the room is resetted. If the trigger returns false, the room will not be resetted.
trigger reset
Called after the room is resetted.
trigger pre_speech
Called before the words are said. If it returns a FALSE, the words will not be be said.
trigger speech
Called when the words have been said.
trigger sunset
Happens after the message "the sun disappears in the west".
trigger sunrise
Happens after the message "the sun rises in the east".
trigger end_day
Happens after the message "the night has begun."
trigger start_day
Happens after the message "the day has begun."
trigger timer
Every room has a timer, this timer can be started with the room timer command. Normally you issue an room timer 0 command to let the timer start counting from 0. Every PULSE_TICK the timer trigger is called. You can use trig compare to check the trigger value.
trigger hour
This trigger is tested every hour in MUD time.
trigger random
NOTE: This trigger is checked each PULSE_TICK, even if there are no players in the room but there are in the area. If you want this event to be triggered always, you must set the ACT_UPDATE_ALWAYS flag of the mobile.
trigger delay
NOTE: This trigger is checked every PULSE_TICK and activates when the delay of a room (set with the room delay command) expires. This trigger can be used to create staged object behavior. See also room remember. An room can have several delay triggers, but every time the delay timer expires, all the triggers are checked and the first successful one executed.
trigger pre_trap
Called before the trap is sprung. If it returns a FALSE, the trap will not function. The mud will not report this, the progs need to take care of this if desired.
trigger trap
Called when the trap has sprung.
trigger canunlock
Called before the door is unlocked. If it returns a FALSE, the door will not be be unlocked. This trigger REPLACES the check for a valid key. The exit flag 'tcl_lock' is required on the exit for this trigger to fire.
trigger pre_unlock
Called before the door is unlocked. If it returns a FALSE, the door will not be be unlocked.
trigger unlock
Called when the door has been unlocked.
trigger weather
Trips every time the weather changes. State is one of 'cloudless', 'cloudy', 'raining', 'lightning'.