Heroes of the Lance MudHelpRacesClassesAreasRulesClansPantheonHeroesJournalsRepositoryIdeasHOTL3 Home
 


Area Building Documentation: MudProgs (cont'd)

Commands
The use of commands is a new feature of HOTL3. Command progs are flexible in the sense that they allow area coder to write new commands, or override old commands with his own version. Many things can be achieved with this and many old trigger progs can actually be converted into commands. For example,

Trigger "say" "p hello kitty" "{
    say(hello $n)
    paw($n)
}"

can be converted to:

Command "say" "{
    mpforce($n say $_)
    if $_ == 'hello kitty'
        say(hello $n)
        paw($n)
    endif
}"

The first one works by attaching a "say" trigger to a mob. When someone says the sentence, 'hello kitty', it will trigger the prog. The latter works by overriding the "say" command, thus when someone says something, it will intercept the speech, pass it to the old say function through mpforce ($n say $_), and then check if he says 'hello kitty', and if so, perform some action.

It is difficult to say which is better or worse. Trigger is a more passive method whereas Command is a more active method to gain control. In addition, there are many things which can be done via Command but not Trigger, such as creating a new special command, eg:

Command "pull" "{
    if $_ == 'lever'
        mpechoat($n The room starts to rock as you pull the                  lever)
        mpasound(The earth starts to shake uncontrollably)
    else
        mpechoat($n Pull what?)
    endif
}"

or creating special effects like:

Command "look" "{
    if $_ == 'mirror' // the player looks at a mirror
        mpechoat($n You feel yourself being teleported)
        mptransfer($n 3001)
    else
        // continue with the normal look command
        // and this is how you do it via a special command
abort()
endif
}"

Attaching mudprogs
Mud_progs can be attached to mobs, items, rooms or areas. If attached to mobs or items, then only mobs and items will be affected. If attached to a room, then it only applies to the room - but if it is attached to an area, it will apply to every room in that area.

Triggers can be attached to anything but not all have any effect. For instead, attaching Trigger "give" onto a room doesn't make any sense, nor will it have any effect. Neither will attaching Trigger "hitprcnt" onto an item work, since items don't have any hp.

Commands can be attached to anything and all will have an effect. When a player issues a command, the command parser will scan through the item's mud_prog he is using for a Command prog. If it can't find any (or if the prog aborts) then it will look through the mobile prog of all mobs in the same room as he is, followed by the object prog of all objects in the room, then following that, the room prog and finally the area prog. If nothing is found, then the command will be treated as a normal command and be processed normally.

Attaching the mud_prog to mobs, items, rooms or areas is fairly straightforward. Just enter the prog at the end of the respective section before the #END tag. If you have multiple progs, make sure they are all together in one single block.

For example:

#AREA
Name    "Void"
Builder ""
Level   1 50
Command "say" "{
    mpechoat($n Sorry, you cannot use the command say here)
}"
#END

Note: Notice it starts with "{ and ends with }". This is very important as the whole prog is stored as a string in memory, which is why it is in ""s.

Variables
All the old variables still apply here.

$N - short description of actor (in simple terms, mobs)
$n - short description of victim (in simple terms, players)
$r - short description of a random player
$E, $e - he/she of actor/victim
$M, $m - him/her of actor/victim
$S, $s - his/her of actor/victim
$p - short description of object (if object prog)
$t - same as $N (retained for compatibility)
$$ - just $

In addition, there are a few more new variables:

$0, $1, $2 ... $9 are 10 internal variables which you can use to store numbers or strings that are unique to each individual mob, item, room or area. This is useful when you need a temporary variable or just a way to for the mob to remember something (like who attacked him before).

$_ is only valid when used with command prog. It refers to the parameters which players type in.

Built-in functions
This section is continually expanding. If you encounter any functions or commands which you cannot do using what we have, please email so we know what to implement and what is needed.

rand(x) - function which has x percent chance of returning true
ispc(x) - return true if x is PC. (x = $N/t, $n, $r) (yada yada...)

Mudprog-only commands

PROG WHAT IT DOES
"rand" Do something randomly. Eg:
if rand(50)
say(Ahhhhhhh!)
endif
"ispc" Check whether victim is player character. Eg:
if ispc($n)
mpforce($n giggle)
endif
"isnpc" Check whether victim is non player character
"isgood" "isevil" "isneutral" Check whether victim has good/evil/neutral alignment. Eg:
if isgood($n)
say(Welcome!)
else
    if isevil($n)
    say(Get Lost!)
    endif
else
    say(You can stay if you don't create any         problem!)
endif
"isfight" Check whether victim is fighting (works like Trigger "fight")
"isimmort" Check whether victim is an immortal
"isfollow" Check whether vitim is following the mob
"isleader" Check whether victim is the leader of the group
"isaffected" Check whether victim is affected by a particular spell
"hasitem" Check whether the victim has an item. Eg:
Trigger "speech" "stick" "
if has_item ($n cigarette) == 1
    say(Don't be greedy! You already have one!)
endif
"hitprcnt" Works just like the Trigger "hitprcnt"
"cpcinroom" Check the number of living thing in the victim's room. Eg:
if cpcinroom($n)<1
    mppurge()
endif
"level" Check the level of the victim
"align" Check the alignment of the victim
"sex" Check the sex of the victim. Eg:
if sex($n) == 'male'
    say(Good day, sir.. Care to take a pet         home, sir?)
    emote(looks at you innocently.)
endif
"season" Check whether it's the particular season. Eg:
if season() = 'winter'
    mpecho(Snows start to fall from the sky.)
endif

< Back


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>