Triggers
Triggers provide the ability for mobs to react to events that are generated in their vacinity.
There are two types of triggers:
Challange Triggers - Which provide the mob with the ability to prevent other mobs (including players) from doing things
Reaction Triggers - Which provide the mob with the ability to take actions after it has 'seen' other mobs (including players) do something.
Triggers are the primary animating force for mobs, being used to drive the initiation of scripts in response to input that the mob recieves. In addition to the normal, visual, events that players see, there are a number of hidden events that only mobs can react to.
Trigger Data
Triggers are part of a mobs definition and are added through the OLC Trigger command.
The attributes for each trigger are:
- Event Type (event type)
This is the type of the event that will be reacted to. A trigger can only match a single event type.
- Sequence Number (int)
The triggers associated with each event type are checked in order of this sequence number. This is important as the order than the events are checked can determine which one matches the trigger.
- Event subtype (event subtype)
This is the subtype defined within the event that the trigger should match. You can also speicfy 'none', in which case the trigger will match all events of its main event type.
- Script Number (script)
The number of the script that should be run when the trigger is satisfied. There are no checks that the script is defined when the trigger is defined.
- Text template (string)
This is an optional string of phrases combined with AND and OR logic that will be compared to the text present on the event. It should be used carefully, as text based matching is expensive.
- Condition (condition)
The condition is evaluated for each event that reaches the trigger. If the condition is satisfied (as well as the type, subtype and text fields), the the trigger has matched the event. No further trigger comparisons will occur for the event (on this mob) and the script associated with the trigger will be enqueued to the mob for execution.
Trigger Evaluation
The processes for evaluating Challange and Reaction Triggers are slightly different. Reaction triggers are about letting all mobs react to an event that has happened. Challange triggers are about finding out if any of the mobs present objects to the action. The evaluation of challange triggers stops as soon as 1 mob in the room objects to the action (ie has a challange trigger which matches the event).
The process is thus:
The events type is used to see if the mob has any triggers for that type. If it does not, there is assumed to be no reaction and no objection.
The triggers for that type are then checked in sequence.
If the subtype on the trigger isn't none, that is checked.
If a text template is specified, that is checked.
Finally, if one is present, the condition is checked.
If there is a match on all of these, then the event is said to have matched the trigger and the reaction (or objection) is scheduled.
With challange triggers, it is the responsability of the mob builder to provide a script which will explain why the action was denied. The code will simply not perform it and no error messages will be issued to anyone.
It should also be noted that certain events do not have challange or reaction forms. These are either because it would be silly/impossible for the mob to deny permission, because the result of such a denial would be ambigious or paradoxical or because the reaction side would produce to much visual clutter for players.
Text Templates
Text templates consist of words or phrases separated by and (&) and or (∨) signs. The ANDs are always evaluated before the ORs.
The following is an example of a text temple:
woman&white|lady&white|ghost&ladyThis is parsed and checked as:
((woman)&(white))|((lady)&(white))|((ghost)&(lady))It would match any of the following:
Have you see the woman in white?
Who is the white lady?
Where is the ghost of lady Zara?
But it would NOT match the following:
Tell me about the white ghost
Who is the ghost of the woman?
Who is the lady of the castle?
The strings being tested may not contain the '&', '|' or '~' characters.
Event Types and Subtypes
- give
-
gold
-
item
- get
-
gold
-
item
- put
-
item
- drop
-
gold
-
item
-
plant
-
item_melt
- poison
-
food
-
weapon
-
fountain
- fill
-
fountain
- drink
-
fountain_ok
-
fountain_bad
-
item_ok
-
item_bad
- eat
-
food_ok
-
food_bad
-
pill
-
herb
-
corpse
- sacrifice
-
pc_corpse
-
corpse
-
trash
-
treasure
-
item
- gadget
-
gadget_ok
-
gadget_bad
- search
-
item
-
room
-
find_item
-
find_mob
-
find_door
-
find_hound
- depart
-
walk
-
sneak
-
fly
-
swim
-
sail
-
portal
-
magic
-
current
-
fleeing
- arrive
-
walk
-
sneak
-
fly
-
swim
-
sail
-
portal
-
magic
-
current
-
fleeing
- pulse
-
1_sec
-
3_sec
-
4_sec
-
5_sec
-
10_sec
-
30_sec
-
area
- time
-
hour
-
day
-
sunrise
-
sunset
-
dawn
-
dusk
- control
-
login
-
logout
-
linkdead
-
reconnect
- mob
-
stop
-
select
-
echo
- death
-
slain
-
stun
- attack
-
kill
-
kick
-
trip
-
bash
-
dirt
-
backstab
-
disarm
-
circle
-
rotate
-
murder
-
tail
-
crush
- combat
-
miss
-
hit
-
block
-
parry
-
dodge
-
absorb
-
immune
- damage
-
injured
-
hurt
-
dirt
-
trip
-
bash
-
env
- oocc
-
beep
-
gossip
-
music
-
immtalk
-
question
-
answer
-
tell
-
gtell
- icc
-
tell
-
say
-
shout
-
scream
-
yell
-
mtell
-
telepathy
- social
-
emote
-
fsoul
-
nsoul
-
hsoul
-
csoul
- idol
-
hold
-
pray
-
object
-
gold
- society
# invite
# join
# advance
# resign
# expel
# demote
# test
# foe
# pardon
dream
# walk
# awaken
# say
# psay
# emote
# pemote
# cast
# pcast- lock
-
d_open
-
i_open
-
d_close
-
i_close
-
d_lock
-
i_lock
-
d_unlock
-
i_unlock
-
d_pick
-
i_pick
-
start
-
stop
-
hits
-
mana
-
moves
-
start
-
continue
-
finish
-
door
-
strange
-
use
-
wear
-
remove
-
explosion
-
photo
-
destroy
-
rebuild
-
effect
-
learn
-
practice
-