Mprog building

From WDWiki
Jump to: navigation, search

Below you will find a set of reference tables for use when building mprogs along with some examples. For a more complete guide to their creation I recomend This file as a starting guide.
Download the MPROG guide here

Variables[edit]

As it is relatively new and the description is lacking on the mprog guide in the mud, I will put here a detailed guide on how to use variables.

Variables are an incredibly powerful tool for the creation of complicated mprogs. Previously, for a mob to track the order of events, it had to create token items signifying that an event had happened. Now a mob can simply set the value of a variable and refer back to it in later steps of the mprog chain.

Variables are labelled @1 through @99. Each area has its own set of variables and they do not mix. A mob will set a variable for the area that it is currently loaded in. So if the mob then moves to a different area, it will not recognize the set variable any more.

Variables are set with the command string "set @1 1" or "set @1 blue" They do not have to be numbers. Now when creating an mprog you can call the variable in the middle of an mprog. (say Well hello Vorcet, thats a lovely @1 shirt you have there.) would put out to the mud (mob says 'Well hello Vorcet, thats a lovely blue shirt you have there.). At this time Variables will NOT recognize $n, $I, etc. This means that you cannot set a variable to a player or mobs name, so the remember command is still important.

In addition to setting variables, they can also be added to or subtracted from. The syntax for this would be "set @1 + 1" This will add one to whatever the current numerical value of @1 is. This is great for mprogs that require the giving of multiple of an item to the mob to craft something.

REFERENCE TABLES[edit]

Trigger Argument What must happen to activate trigger
Act
STRING
to match the act() to mobile
speech
STRING
to match in dialogue (say, tell) to mobile
rand
percent
chance to check whenever a pc is in the mobile zone
bribe
INTEGER
Minimum amount of silver coins given to mobile
give
Obj
obj name, vnum, or ALL given to mob
greet
percent
chance to check if visible character enters mobs room
grall
percent
chance to check when ANY char enters mobs room
entry
percent
chance to check when mobile moves to new room
exit
exit number
a visible character tries to exit mobiles room
exall
exit number
any char tries to exit mobiles room
kill
percent
a chance to check when the mobile begins fighting
fight
percent
chance to check at fight_pulse if mobile is fighting
hpcnt
percent
lower than mobs hit/max_hit if mobile is fighting
death
percent
chance to check after mobile has been slain


Variable Mobile Actor Victim Random Target Object Second Object
name
$i
$n
$t
$r
$q
$o
$p
shrt_desc/title
$I
$N
$T
$R
$Q
$O
$Q
he/she/it
$j
$e
$E
$J
$X
him/her/it
$l
$m
$M
$L
$Y
his/hers/its
$k
$s
$S
$K
$Z


ifcheck argument(s) Meaning
rand
integer
Is random % less than or equal to integer
mobhere
vnum
is NPC with this vnum in the room
mobhere
name
is NPC with this name in the room
objhere
vnum
is obj with this vnum in the room
obj here
name
is obj with this name in the room
mobexists
name
does mob with this name exist in the world
objexist
name
does obj with this name exist in the world
people
== integer
is the number of people in the room equal to integer
players
== integer
is the number of PC's in the room equal to integer
mobs
== integer
is the numbers of NPC's in the room equal to integer
clones
== integer
is the number of NPC's in the room with same vnum equal to integer
isnpc
$*
is $* an NPC
ispc
$*
is $* a PC
isgood
$*
is $* good aligned
isneutral
$*
is $* neutral aligned
isevil
$*
is $* evil
isimmort
$*
is $* an immortal
ischarm
$*
is $* affected by charm
isfollow
$*
is $* a follower with master in the room
isactive
$*
is $*'s position > POS_Sleeping
isdelay
$*
does $* have a delay mprog pending
isvisible
$*
is $* visible to NPC who activates prog
hastarget
$*
Does $* have a mprog targetted in the room
istarget
$*
is $* the target of NPC who activated mprog
affected
$* 'affect'
Is $* affected by 'affect'
act
$* 'act'
is $*'s ACT bit 'act' set
off
$* 'off'
is $*'s OFF bit 'off' set
imm
$* 'imm'
is $*'s IMM bit 'imm' set
carries
$* 'name'
is $* carrying object 'name'
wears
$* 'name'
is $* wearing 'name'
has
$* 'type'
does $* have object of item_type 'type'
uses
$* 'type'
is $* wearing an object of item_type 'type'
name
$* 'name'
is $*'s name 'name'
pos
$* 'position'
is $*'s position 'position' (sleeping etc)
clan
$* 'name'
is $* in clan 'name'
race
$* 'name'
is $* of race 'name'
class
$* 'name'
is $*'s class 'name'
objtype
$* 'type'
is $*'s item type 'type'
vnum
$* == integer
is $*'s vnum equal to an integer
hpcnt
$* == integer
is $*'s HP percentage equal to an integer
room
$* == integer
is vnum of room $* is in equal to integer
sex
$* == integer
is $*'s sex equal to integer
level
$* == integer
is $*'s level equal to integer
align
$* == integer
is $*'s align equal to integer
money
$* == integer
does $* have money (in silver) equal to integer


MOBcommand argument_list MOBcommand argument_list
ASOUND
text_string
ECHO
text_string
GECHO
text_string
ZECHO
text_string
ECHOAT
victim text_string
ECHOAROUND
victim text_string
MLOAD
vnum
OLOAD
Vnum
KILL
victim
FLEE
REMOVE
victim vnum
MOB JUNK
object
PURGE
argument
AT
dest command
GOTO
Destination
TRANSFER
victim destination
GTRANSFER
victim destination
OTRANSFER
object destination
FORCE
victim command
GFORCE
victim command
VFORCE
vnum command
CAST
spell victim
DAMAGE
victim min max lethal
DELAY
CANCEL
REMEMBER
victim
FORGET
CALL
mprog vnum

SIMPLE MPROG EXAMPLES[edit]

As a disclaimer here. These are examples I came up with off the top of my head and in no way resemble any mprogs actually installed in the game. Enjoy.

Example One[edit]

if isgood $n
mob ECHOAT $n $i nods at you in greeting.
mob ECHOAROUND $n $i nods at $n in greeting
say Be welcome $n
else
mob ECHOAT $n $i looks at you warily.
mob ECHOAROUND $n $i looks at $n warily.
say We dont serve your kind here $n.
endif

The trigger for an mprog such as this would be a GRALL. so when adding to a mob it would be addmprog <mprog vunum> grall 100
This trigger would activate every time a person enters the room.


Example Two[edit]

if rand 50
mob REMEMBER $r
mob ECHOAT $q $i swings his sword in a rapid sieries of blows removing your limbs.
mob ECHOAROUND $q $i swings his sword at $q in a rapid series of blows removing %Z limbs.
mob damage $q 1000000 1000000 lethal
mob FORGET
else
mob ECHO $i swings around wildly with his sword, completely missing his intended target.
endif

This mprog is an example of a instakill mprog. The trigger for this would be addmprog (mprog vnum) fight 100
This would make the mob evaluate this mprog every round of combat. 50 percent of the time it would kill a random person and the other 50 miss completely.


Example Three[edit]

mob goto (treasure room vnum)
mob OLOAD (obj vnum) ---- Treasure chest key
mob OLOAD (obj vnum) ---- Prize
if rand 50
mob OLOAD (obj vnum) ---- second possible prize
else
mob oload (obj vnum) ---- Third possible prize
endif
unlock chest
open chest
put prize chest
put 2ndprize chest
put 3rdprize chest
close chest
lock chest
mob GOTO (mob holder room vnum)
mob MLOAD (mobs vnum) ---- Same vnum of the mob activating the mprog
mob GOTO (vnum where mob is killed)

This is an example of a mob death prog. This is typical to what you would see on a run mob for loading its loot. the trigger for this would be addmprog (mprog vnum) death 100.
This will evaluate every time the mob dies. The things after and including the ---- are not aprt of the mprog but explainations of certain functions. A mob holder room is a place to load a copy of the mob to keep it from respawning in its normal place. This is useful for making a mob a "once per reboot" event.


Example Four[edit]

if carries $i (objects name/vnum)
mob ECHO $i shudders with delight as he takes a bite out of the bread.
say Ahhh heavenly this be.
say Take this small trinket with my gratitude.
mob oload (vnum of worthless trinket)
give worthlesstrinket $n
mob JUNK all

This would be an example of a give mprog. addmprog give (vnum of obj) 100. This would evaluate every time an object of the vnum specified is given to the mobile. The mob then loads some worthless trinket as a reward and junks the bread afterwards.