Object Triggers
ObjTrigger Command
The objtrigger command is defined as a separate command.
objtrigger <name> <type> <call> [<trigger>]
Adds a trigger to the object. 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 “drop”, “eat”, “zap”, etc. 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.
object triggers Command Reference
- close
- drink
- drop
- eat
- enter
- get
- give
- hit
- interpret
- load
- lock
- lookat
- lookin
- open
- play
- positions
- pre_attack
- put
- quaff
- recite
- remove
- sell
- speech
- sun/day
- time
- trap
- unlock
- use
- wear
- weather
- zap
trigger pre_close
Called before the object is closed. If it returns a FALSE, the object will not be be closed.
trigger close
Called when the object has been closed.
trigger pre_drink
Called before the object is drank. If it returns a FALSE, the object will not be be drunk.
trigger drink
Called when the object has been drank.
trigger pre_drop
Called before the object is dropped. If it returns a FALSE, the object will not be be dropped.
trigger drop
Called when the object has been dropped.
trigger pre_eat
Called before the object is eaten. If it returns a FALSE, the object will not be be eaten.
trigger eat
Called when the object has been eaten.
trigger pre_enter
Called before a mob/char have entered the object. If it returns a FALSE, the object will not be entered.
trigger enter
Called when a mob/player have entered an object.
trigger pre_get
Called before the object is taken. If it returns a FALSE, the object will not be taken.
trigger get
Called when the object has been taken.
trigger pre_getout
Called before an object is taken out of the container. If it returns a FALSE, the object will not be taken.
trigger getout
Called when an object has been taken out of the container.
trigger pre_give
Called before the object is given to somebody. If it returns a FALSE, the object will not be given away.
trigger give
Called when the object has been given.
trigger pre_hit
Called before the object has damaged a player. If it returns a FALSE, the attack with this object will not happen. The weapon can be used again in the same round in haste/second/third attack.
trigger hit
Called when the object has hit somebody.
trigger nohit
Called when the obj failed to hit the opponent. Reason for it is in [trig value]. This trigger is NOT preceded by a pre_hit action.
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 load
Happens when an object is loaded and placed into a room, inventory or in another object. Note that this trigger doesn't go off for treasures and objects created during the loading of the player.
trigger canlock
Called before the object is locked. If it returns a FALSE, the object will not be be locked. This trigger REPLACES the check for a valid key.
trigger pre_lock
Called before the object is locked. If it returns a FALSE, the object will not be be locked.
trigger lock
Called when the object has been locked.
trigger pre_lookat
Called before the object is looked at. If it returns a FALSE, the object will not be be looked at. Because of POLA this trigger will also fire when looking at extra-descriptions and the object has no pre_lookat_ed trigger.
trigger pre_lookat_ed
Called before the object is looked at. If it returns a FALSE, the object will not be be looked at.
trigger lookat
Called when the object has been looked at.
trigger lookat_ed
Called when the objects extra-description has been looked at. Because of POLA this trigger will also fire when looking at extra-descriptions and the object has no lookat_ed trigger.
trigger pre_lookin
Called before the object is looked in. If it returns a FALSE, the object will not be be looked in.
trigger lookin
Called when the object has been looked in.
trigger pre_open
Called before the object is opened. If it returns a FALSE, the object will not be be opened.
trigger open
Called when the object has been opened.
trigger playfilter
Called when showing the list of songs in the jukebox. Once for each song. If the trigger returns false the song is hidden from view. [Missing] Also called before the pre_play trigger. If this trigger returns false the jukebox behaves as if the song doesn't exist.
trigger pre_play
Called before the jukebox starts a song. If the trigger returns FALSE the song is never started.
trigger play
Called when a song is started in a jukebox. The first line of the song appears some time after this trigger.
trigger pre_sleep
trigger pre_rest
trigger pre_sit
trigger pre_stand
Called before the mob starts to sleep/rest/sit/stand on the obj. If it returns a FALSE, the mob won't move to the new position.
trigger sleep
trigger rest
trigger sit
trigger stand
Called after the mob went to sleep/rest/sit/stand on the obj.
trigger pre_attack
This trigger is called when a mob start combat without using magic. (eg. kill/eyepoke/trip/backstab/....) The second char [char -second] is the mob being attacked.
trigger pre_put
Called before the object is put into something. If it returns a FALSE, the object will not be be put into it.
trigger put
Called when the object has been putted.
trigger pre_putin
Called before something is put in the container. If it returns a FALSE, the object will not be be put into it.
trigger putin
Called when an object has been put into the container.
trigger pre_quaff
Called before the object is quaffed. If it returns a FALSE, the object will not be be quaffed.
trigger quaff
Called when the object has been quaffed.
trigger pre_recite
Called before the object is recite. If it returns a FALSE, the scroll will not be be recited. Target of the scroll is stored in -second (either obj or char)
trigger recite
Called when the scroll has been recited. Target of the scroll is stored in -second (either obj or char)
trigger pre_remove
Called before the object is removed. If it returns a FALSE, the object will not be removed.
trigger remove
Called when the object has been removed.
trigger pre_sell
Called before the object is sold. If it returns a FALSE, the selling of this object will not be done.
trigger sell
Called when the object has been sold.
trigger buy
Called when the object has been bought.
trigger pre_speech
Called before the words are said. If it returns a FALSE, the words will not be be said.
This only goes for the objects in your inventory, in your equipment and in the room. Not for objects in objects.
trigger speech
Called when the words have been said.
This only goes for the objects in your inventory, in your equipment and in the room. Not for objects in objects.
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 object has a timer, this timer can be started with the obj timer command. Normally you issue an obj 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 object (set with the obj delay command) expires. This trigger can be used to create staged object behavior. See also obj remember. An object 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 object is unlocked. If it returns a FALSE, the object will not be be locked. This trigger REPLACES the check for a valid key.
trigger pre_unlock
Called before the object is unlocked. If it returns a FALSE, the object will not be be unlocked.
trigger unlock
Called when the object has been unlocked.
trigger pre_use
Called before the object is used. If it returns a FALSE, the object will not be used.
trigger use
Called when the object is used. The normal use command doesn't output anything, it completly relies on these triggers for output.
trigger pre_wear
Called before the object is being worn. If it returns a FALSE, the object will not be be worn.
trigger wear
Called when the object has been worn.
trigger weather
Trips every time the weather changes. State is one of 'cloudless', 'cloudy', 'raining', 'lightning'.
trigger pre_zap
Called before the object is zapped. If it returns a FALSE, the object will not be be zapped. Target of the zap is stored in -second (either obj or char)
trigger zap
Called when the object has been zapped. Target of the zap is stored in -second (either obj or char)