« An introduction to *progs: The basics | Main | Triggers: Setting the prog loose on the world »

mprogs

July 20, 2005

Creating a simple mprog

Here, we'll create a simple program, that reacts to a character, greeting them by name.

In the following examples, we'll use a goblin, with a vnum of 120. We know the vnums 120 onwards are free for mprog creation. Commands entered will be shown in this colour. In the mprog editor, the lines are always preceded by the angle bracket >. Do not type this in, it is the mprog edit prompt.


mpedit create 120
MobProgram Code Created.
code
-=======- Entering APPEND Mode -========-
Type .h on a new line for help
Terminate with a ~ or @ on a blank line.
-=======================================-
> say What would you be searching for, down in the depths, man thing?
> @
done

This is a very simple prog, and doesn't know anything about names. When it it triggered, it will simply say the line it has been given.

However, the program is not attached to anything, and so at this stage, will never actually run. Now it must be attached to the goblin (staples are preferred, crazy glue is ok), and the conditions that will trigger it set. There are a wide array of triggers and trigger types, however these will be covered in depth later. For now, we shall use one of the simplest, grall (greet all). Grall will trigger the mprog when anyone enters the room, visible or not to the goblin. Grall also takes a percentage to determine if it should fire every time, or more randomly.

Here we enter the mobile editor for the goblin and add the mobile prog (addmprog), also vnum 120 in this particular case, using a grall trigger, with 100% chance of triggering when anyone enters. In order to test this out, the mob is then loaded, and I leave and renter the room, triggering the program.

medit 120
addmprog 120 grall 100

Mprog Added.

done
load mob 120

Ok.
south
north

In common, a repulsive goblin says 'What would you be searching for, down in the depths, man thing?'

But we wanted this program to greet people by name. In order to do that, we need to look at the variables you can use in mprogs.

Variables

There is quite a selection of variables you can use in mprogs, and you should be able to find one that suits your purpose. The following table is large, but don't panic - you are not expected to memorise it. It's here for reference.

$i The name(s) of the mob/object/room
$I The short description of the mob/object/room
$n The name of who activated the trigger (Or Opponent)
$N The name and title of who activated the trigger
$t The name of the secondary character (Meathe points at Navarre, Meathe = $n, Navarre = $t)
$T The short description (NPC) or name and title of secondary character (PC)
$r The name or a random PC in the room
$R The short description (NPC) or name and title of the random PC
$q The name of the prog target (See MOB REMEMBER)
$Q The short description (NPC) or name and title of the prog target
$u The name of the wielder/wearer of the object (Oprog)
$U The short description (NPC) or name and title of the wielder/wearer of the object (Oprog)
$j He/She/It based on the sex of $i
$e He/She/It based on the sex of $n
$E He/She/It based on the sex of $t
$J He/She/It based on the sex of $r
$X He/She/It based on the sex of $q
$k Him/Her/It based on the sex of $i
$m Him/Her/It based on the sex of $n
$M Him/Her/It based on the sex of $t
$K Him/Her/It based on the sex of $r
$Y Him/Her/It based on the sex of $q
$l His/Hers/Its based on the sex of $i
$s His/Hers/Its based on the sex of $n
$S His/Hers/Its based on the sex of $t
$L His/Hers/Its based on the sex of $r
$Z His/Hers/Its based on the sex of $
$o The name(s) of the primary object (Meathe drops the staff, the staff = $o)
$O The short description of the primary object
$p The name of the secondary object (Meathe puts the staff in the chest, the chest = $p)
$P The short description of the secondary object.

WARNING

It is important to remember that mobs, objects and rooms see the world from slightly different perspectives, so the $ codes may vary in their output slightly when run by different entities. Please test your programs with the object/room/mob that will be running it.

An example is the following program, attached to both a room and an object with a kill trigger:

say Fataility! $n has killed $t!

The output on killing a goblin in the arena (for me) is:

ROOM:In common, the Arena says 'Fataility Meathe has killed a goblin!'
OBJECT:In common, -+-UlTiMaTe WeAPoN-+- says 'Fataility a goblin has killed someone!'

It's not an ideal situation, however, altering the logic of this would disrupt many current progs. Your milage may vary, simply remember to test.

From the table, either $n (name of person setting off the trigger) or $N (name and title) are what we'd like to use for the goblin. In this example, we'll replace the code 'man thing' with $N, add one line to make the goblin peer at the character and finally trigger the program again.


mpedit 120
code
-=======- Entering APPEND Mode -========-
Type .h on a new line for help
Terminate with a ~ or @ on a blank line.
-=======================================-
1. say And what would you be wanting in a place like this, man thing?
> .r 'man thing' '$N'
'man thing' replaced with '$N'.
> peer $n
> @
[enter]
Vnum: [120]
Code:
say And what would you be wanting in a place like this, $N?
peer $n
done
south
north

In common, a repulsive goblin says 'What would you be searching for, down in the depths, Meathe - devourer of fishes?'
A repulsive goblin peers at you.

You can see that the variables can be used in a mix and match style with standard player commands, like look, steal, emotes and the rest.

They are also used in mob commands and the control statements, so you will need to be familiar with how they work.

To enhance this program further, lines such as these could be added:

say I am but a poor, simple $I. I cannot be expected to know.
innocent $n
mutter
say $e's on to usss, my precioussss. $e knows of things. Kills $k we must.
scream $n
murder $n

Scrawled illegibly by Meathe at July 20, 2005 11:34 AM

Comments