« Creating a simple mprog | Main | Mob commands »

mprogs

July 20, 2005

Triggers: Setting the prog loose on the world

Progs can be triggered in many different ways. Triggers are chosen when you are attaching a program to a mob (or object or room). Multiple programs can be attached to a mob, and the same program may be attached with multiple triggers.

The syntax for attaching these are (depending on whether it's a mob, object or room):

addmprog <vnum> <trigger> <argument>
addoprog <vnum> <trigger> <argument>
addrprog <vnum> <trigger> <argument>

The argument depends on the trigger type. It can be a percentage (x% chance of being fired), a keyword or an amount (as for bribes).

% chance: When triggered, this is the chance of the prog being run
Direction: This is the direction the trigger is for. These directions used to be purely numeric, however, now you may use the number or word/letter equivilants, as shown here.

0northn
1easte
2souths
3westw
4upu
5downd

The table below shows what triggers are available (and whether they're available for Objects, Mobs or Rooms), what kind of argument it takes and some remarks on usage.

Available Trigger Argument Notes
OM act keyword When an action (or speech) with the keyword is performed
M attacked % chance On being damaged in combat
M bribe amount (platinum) When the mob is bribed with more than the amount
OMR cast Spell name When the spell is cast (by anyone in the room)
O R close Object: % chance
Room: Direction
Object: When the Object is closed
Room: When the exit in the direction specified is closed
M death % chance On the death of the mob
M delay % chance Triggered by the mob command, mob delay <time>, fires after the delay specified in the mprog.
OMR entry % chance Mobs: On entry to a new room
Objects: Only valid on portal objects.
Rooms: Entry from any direction
MR exall Direction Mobs: When a character leaves in that direction
Rooms: When a character leaves in that direction.
OMR exit Mobs: Direction
Object: % chance
Room: direction
Objects: Only valid on portal objects.
Mobs: When a visible character leaves in that direction
Rooms: When a character leaves in that direction.
OMR fight % chance Occurs every round of combat
O get % chance When the Object is picked up
OM give Mobs: <objname/vnum>
Objects: % chance
Mobs: On receipt of an object
Objects: On being given
OMR grall % chance On entry to a room, greets whether visible or not.
OMR greet % chance On entry to a room, only greets visible characters
For objects and rooms, this is equivilant to grall
M hpcnt % mob hit points When current hit points are below the % of original hp
OMR kill % chance Mob: When the mob makes a kill
Object: If the Object is a weapon and wielded when the character makes a kill
Room: When a kill occurs inside the room
O R lock Object: % chance
Room: Direction
Object: When the lock on an Object is locked
Room: When the lock on the direction specified is locked
O R open Object: % chance
Room: Direction
Object: When the Object is opened
Room: When the exit in the direction specified is opened
O R pick Object: % chance
Room: Direction
Object: When the lock on an Object is picked
Room: When the lock on the direction specified is picked
O put % chance On being put
M random % chance Tested 15 times per tick, percentage should be quite low.
OMR speech Keyword Whenever the keyword is spoken
M surr % chance A character surrenders in combat with the surrender command
O R unlock Object: % chance
Room: Direction
Object: When the lock on an Object is unlocked
Room: When the lock on the direction specified is unlocked
O use % chance Only works with Objects that may be used in an action: potions, food, stakes, thrown Objects, wands, etc.
O wear % chance On being worn

Some examples:

Added withWhat it does
addrprog 125 exit north Fires when someone leaves the room north
addoprog 135 exit 50 50/50 chance to fire every time someone exits (emerges) from the portal
addmprog 121 cast blessWhen a bless spell is cast in the same room as the mob
addoprog 122 give 100Every time the item is given to someone
addoprog 123 give 201 in 5 chance every time the item is given to someone
addmprog 145 bribe 300When the mob is bribed with 300 or more platinum
addmprog 121 speech whereWhen someone in the rooms says "where"
addmprog 122 exit southWhen someone leaves south

Removing Progs

Now they're attached. But mistakes happen, and changes sometimes need to be made. delmprog, delrprog and deloprog are the commands we need, however they don't use vnums, unlike the add version of the command, it uses an index number. Thankfully, it's easier to use than it sounds.

Lets return to the goblin (vnum 120, with programs 120, 121 and 122 attached).


medit 120
[enter]
Mass goblin stats, skipped
MOBPrograms for [ 120]:
Number Vnum Trigger Phrase
------ ---- ------- ------
[    0] 120   GRALL  100
[    1] 121   SPEECH where
[    2] 122   EXIT   south
delmprog 0
[enter]
Mass of goblin stats, skipped
MOBPrograms for [ 120]:
Number Vnum Trigger Phrase
------ ---- ------- ------
[    0] 121   SPEECH where
[    2] 122   EXIT   south

The GRALL trigger we added first (number 0), has been removed.

Scrawled illegibly by Meathe at July 20, 2005 12:55 PM

Comments