Heroes of the Lance MudHelpRacesClassesAreasRulesClansPantheonHeroesJournalsRepositoryIdeasHOTL3 Home
 


Area Building Documentation: MudProgs

Updated by Ops on 24 Feb 1999
This is a brief documentation on the mudprogs available in HOTL3. It is work in progress - thus, not everything is documented yet.

Firstly, the mudprogs in HOTL3 are currently an interpreted language using the yacc/lex parser. Thus, it is neither as fast nor as powerful as other byte-code level languages like LPC. However, the basic framework to make mudprogs a byte-code compiled language is already in. In order to preserve as much compatibility between HOTL3 mudprog with HOTL2 mob/obj prog, the trigger effects, language structure, and some other not-so-nice things have been retained. The end effect is, of course, that we can use HOTL2 mob/obj prog without much modifications.

  1. Strings, numbers and parameters
  2. Basic unit blocks
  3. Types of mud_prog: Triggers & Commands
  4. Attaching mud_prog
  5. Variables
  6. Built-in functions & mud_prog-only commands

Strings, numbers & parameters
Strings in mud_prog are enclosed in single quota, ie '
You can concat two strings by using a dot '.' like this:

'Slimer ' . 'is here.' == 'Slimer is here.'

Note: Since ' is been used as a delimitor, be careful of using ' within your strings as it might cause strange errors. Note that using " in your string is a BAD IDEA(tm) too!

Numbers in mud_prog are just integers values like 1234 or -1234
Standard mathematical functions + - / * can be used on numbers, eg:
Note: ( ) doesnt work yet but the order of evualation is correct, i.e.

12 + 2 * 3 will give a correct 18 and not 52.

Parameters to a mud command or function are enclosed withing brackets ( ). Everything inside the brackets will be passed wholesale to commands. Thus, say ( how do you do ) is the same as typing 'say how do you do' atthe prompt.

Note: A mud command/function must have ( ) even if no paramters eg smile( ) In addition, since ( ) is used as a delimitor, be careful of using ( ) (especially in smily faces : - ). Use [ ] instead and it will be converted to ( ), eg say ( how do you do : - ] ) is same as say how do you do : - )

Basic unit blocks
There are 3 basic unit blocks in mud_prog: Program expression, Program condition, and Program control.

A program expression is a single statement, usually an existing mud command or some other specialised mpcommands, eg:

mpechoat($n You cannot see anything.)

Expressions can be also strings or numerical expressions, eg:

$1 = $n . ' is here.'       // . is a string concat
$2 = 500 + $5 * random(100) // $2 = rand(500,1000)

Program condition is a condition used for evaluating an expression which yields a boolean answer of true or false. It can be a predefined function, eg:

if rand(50) ...

or a numerical or string comparison:

if $1 . 'is here.' == 'Ender is here.' ...
if $2 == 500 ...

In addition, you can use AND and OR functions for evaluating conditions, eg:

if $1 == 500 AND $2 == 'Ender' ...

Program control at the moment only has the if-else-endif control. The for-loop and while-loop controls should be implemented sometime in the future. The syntax for if-else-endif control is as follows:

if <condition>
     <expression>
...
else
     <expression>
...
endif

The block after else is optional. It is important that every if is terminated with an endif.

An example of the if-else-endif control:

if rand(50)
    say(Aiya, don't bother me okie!?) // notice the use of '                                       // is ok here
else
    if $r == 'Meowy'
        paw($r)
    else
        if $r == 'Slimer'
            kok($r)
            shout($r is a kok!!!)
        endif
        growl()
    endif
endif

Types of mudprogs
There are two basic types of mud prog: Trigger and Command.

Triggers
Triggers are the old mob/obj prog which have been maintained for compatibility. It works on a triggered action, maybe a sentence, a word, an action or just plain random events.

Currently, the list of triggers includes: "act" "speech" "rand" "fight" "death" "hitprcnt" "entry" "greet" "greetall" "give" "bribe" "wear" "remove" "get" "drop" "junk" "exam"

TRIGGER SYNTAX EXAMPLE
act Trigger "act" "string1"
"{
what you want the mob to do when the victim acts like string1
}"
Trigger "act" "p pokes you in the ribs."
"{
poke($n)
}"
speech Trigger "speech" "string1"
"{
what you want the mob to do when the victim says something like string1
}"
Trigger "speech" "p mary had a little lamb"
"{
mpmload(vnum of lamb)
}"
rand Trigger "rand" percent1
"{
what you want the mob to do randomly percent1 percent of the time
}"
Trigger "rand" 90
"{
mutter()
}"
death Trigger "death" percent1
"{
when the mob dies, what you want the mob to do percent1 percent of the time
}"
Trigger "death" 100
"{
say(Ahh, you killed me)
}"
hitprcnt Trigger "hitprcnt" percent1
"{
what you want the mob to do when its hp hits percent1 percent or below
}"
Trigger "hitprcnt" 20
"{
cast(holy heal)
cast(holy heal)
cast(holy heal)
}"
entry Trigger "entry" percent1
"{
when the mob enters a room, what you want it to do percent1 percent of the time
}"
Trigger "entry" 100
"{
say(I'm here)
}"
greet Trigger "greet" percent1
"{
what you want the mob to do when someone visible to the mob enters the room percent1 percent of the time
}"
Trigger "greet" 50
"{
slap($n)
say(Please get lost!)
}"
greetall Trigger "greetall" percent1
"{
works like greet but all players will be affected regardless of whether the mob can see them or not
}"
Trigger "greetall" 50
"{
slap($n)
say(Please get lost!)
}"
give Trigger "give" "item1"
"{
what you want the mob to do when someone gives it item1
}"
Trigger "give" "pass"
"{
say(Welcome!)
mptransfer($n 12345)
}"
bribe Trigger "bribe" amount1
"{
what you want the mob to do when someone gives it amount1 amount of gold
}"
Trigger "bribe" 500
"{
say(Thank you!)
}"
Trigger "bribe" 1000
"{
say(Thank you so much!)
}"
Notice that from 500-999 gold, the mob will say 'Thank you!' From 1000 gold onwards, it will say 'Thank you so much!'
wear Trigger "wear" percent1
"{
mostly used for items - what you want the item to do percent1 of the time when someone wears it
}"
Trigger "wear" 100
"{
mpechoaround($n $n's darts start humming merrily.)
mpechoat($n Your darts start humming)
}"
remove Trigger "remove" percent1
"{
mostly used for items - what you want the item to do percent1 of the time when someone removes it
}"
Trigger "remove" 100
"{
mpechoaround($n $n's darts stop humming)
mpechoat($n Your darts stop humming)
}"
get Trigger "get" percent1
"{
mostly used for items - what you want the item to do percent1 of the time when someone gets it
}"
Trigger "get" 100
"{
mpechoat($n Your hands are stung in many places.)
mpdamage($n 20 'poisonous sting' 'poison')
}"
drop Trigger "drop" percent1
"{
mostly used for items - what you want the item to do percent1 of the time when someone drops it
}"
Trigger "drop" 100
"{
mpecho(The darts shimmer and change back to hornets.)
opdestroy()
}"
junk Trigger "junk" percent1
"{
mostly used for items - what you want the item to do percent1 of the time when someone junks it
}"
Trigger "junk" 100
"{
mpecho(The darts shimmer and refuse to be junked.)
mpoload(vnum of dart)
}"
exam Trigger "exam" percent1
"{
mostly used for items - what you want the item to do percent1 of the time when someone examines it
}"
Trigger "exam" 100
"{
say(Hey, what are you looking at??)
}"

Next >


Sections in an ARE file
>
>
>
>
>

Header - define your area
Rooms - rooms, resets & progs
Mobiles - monsters & progs
Items - objects & progs
MudProgs - specials


Area List
For a complete listing of areas

Area Builder's Guide
Things to note when writing your area

Download Area Coders' Pack
Includes documentation & sample area

Back to Areas


 


<Mud> <Help> <Races> <Classes> <Areas> <Rules> <Clans> <Pantheon> <Heroes> <Journals> <Repository> <Ideas> <Home>