Starting Out
First of all, you should have some mobs ready to add mobprogs to. To do this, you will need to read the building docs found on the main Age of Chaos site, and begin construction on a zone. Using the Age of Chaos zonebuilder utility, you should have little problem getting a nice mob file set to go. Normally, I would suggest that you do your mobprogs absolutely last. Why? Because once you have every object, mob, and room done, and know where all of them fit together, it becomes much easier to figure out what you want your mobs to do. Let’s assume for now that you have a mob ready to add mobprogs to. Perhaps similar to the one below:
*
throughout this series of examples, red denotes new text added to the previous
example
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in
this tavern, as he seems wild and looks as if
he comes from a far off wasteland.
Perhaps if you can do something to calm him
down, he might tell you why he’s so
upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
A
5
C
2
If you aren’t sure what all of these numbers and symbols mean, it might be best to consult the Age of Chaos main web page before moving on. Now, let’s say we are ready to add our first mobprog to this mob. In this case, we want Groenk to attack anyone who enters the room. We will be using a greet_prog to do this. Now, we simply place our mobprog between the position/sex line and the letter A denoting the attacks per round of the mob:
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in this tavern, as he seems wild and looks as if
he comes from a far off wasteland. Perhaps if you can do something to calm him
down, he might tell you why he’s so upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
>greet_prog 100~
A
5
C
2
Note that we first place an > symbol, then the mobprog trigger, and at the end of the line we place a ~ symbol. This is always how mobprogs are inserted. Each mobprog also ends with a ~ symbol on a new line, and an entire set of mobprogs – all of the total mobprogs on a single mob - is ended with a | symbol on a new line:
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in this tavern, as he seems wild and looks as if
he comes from a far off wasteland. Perhaps if you can do something to calm him
down, he might tell you why he’s so upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
>greet_prog 100~
mpadd kill $n
~
|
A
5
C
2
You will note two more things from the example above. First of all, the use of mpadd. This is our first mobprog command. What mpadd does is sets the command into a queue to be followed. Generally, it is best to use mpadd before most commands you have a mob perform, although there are several exceptions. You can read more about the mpadd and mppush commands on the mobprog commands page. The second thing you’ll notice is the use of the $n character variable. Character variables tell the mob who it is that they are supposed to be interacting with. The symbol $n means the actor, or the person setting off the mobprog. Now, we need to make a few minor adjustments to our mobprog. First of all, right now the mob will kill anything that enters the room. We certainly don’t want Groenk to kill other mobs if they happen to wander in, so we had better do something about that. Also, let’s give Groenk a little more personality:
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in this tavern, as he seems wild and looks as if
he comes from a far off wasteland. Perhaps if you can do something to calm him
down, he might tell you why he’s so upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
>greet_prog 100~
if ispc($n)
mpadd mpecho $I says, ‘Get out of my way!! GRRR!!!’
mpadd kill $n
else
endif
endif
~
|
A
5
C
2
There. Much better. As you can see, we added an if check using our first mobprog function, ispc, which checks to see whether $n (the actor) is a player character or not. If $n is a player, Groenk will now use the mpecho mobprog command to present a message to the room, and then attack the actor. The character variable $I is the extended name of the mob itself, in this case, Groenk the Crazed Barbarian. If $n (the actor) is not a player character, the if statement is ended with a simple endif, which tells the mob to basically do nothing. If we wanted Groenk to do something to non-pc’s here, we certainly could have something besides endif. Now, let’s say we want to have another kind of mobprog in this mob as well:
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in this tavern, as he seems wild and looks as if
he comes from a far off wasteland. Perhaps if you can do something to calm him
down, he might tell you why he’s so upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
>greet_prog 100~
if ispc($n)
mpadd mpecho $I says, ‘Get out of my way!! GRRR!!!’
mpadd kill $n
else
endif
endif
~
>speech_prog witch mikaela sorceress~
mpadd mpecho $I growls angrily.
mpadd mpecho $I says, ‘That evil witch, Mikaela.’
mpadd mpecho $I says, ‘She drove my people from their homeland.’
mpadd mpecho $I says, ‘This opens her tower. I could not figure out
how.’
mpadd mpecho $I says, ‘Perhaps you’ll have better luck.’
mpadd mpoload 10045
mpadd give scepter $n
~
|
A
5
C
2
As you can see, we have added a speech_prog, another mobprog trigger. If someone says any of the words in the keyword list, the prog will be triggered. A series of mpecho commands follows, followed by the mpoload command. So the mob will load object 10045, and then give it to the actor. Now let’s say we only want Groenk to give out one scepter. Right now, millions of scepters could be loaded by triggering the speech_prog. Let’s fix that:
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in this tavern, as he seems wild and looks as if
he comes from a far off wasteland. Perhaps if you can do something to calm him
down, he might tell you why he’s so upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
>load_prog 100~
mpsetvar me witchtalk 1
~
>greet_prog 100~
if ispc($n)
mpadd mpecho $I says, ‘Get out of my way!! GRRR!!!’
mpadd kill $n
else
endif
endif
~
>speech_prog witch mikaela sorceress~
if <(var-witchtalk,2)
mpsetvar me witchtalk 2
mpadd mpecho $I growls angrily.
mpadd mpecho $I says, ‘That evil witch, Mikaela.’
mpadd mpecho $I says, ‘She drove my people from their homeland.’
mpadd mpecho $I says, ‘This opens her tower. I could not figure out how.’
mpadd mpecho $I says, ‘Perhaps you’ll have better luck.’
mpadd mpoload 10045
mpadd give scepter $n
else
mpadd mpecho $I says, ‘That evil witch, Mikaela.’
mpadd mpecho $I says, ‘She drove my people from their homeland.’
mpadd mpecho $I says, ‘I hope that adventurer finds and butchers her.’
endif
~
|
A
5
C
2
As you can see, we have added a new mobprog trigger: load_prog. Load_prog triggers once and only once when the mob is first loaded, however that may come about. The variable we will later check is set to a default state using load_prog. This means the first time someone sets off the speech_prog, the variable will be set to 2, so subsequent triggerings of the prog will use the second string of mpechos after the else will be set off instead. Now hold on a minute. That adventurer? Can’t we do better than that? We sure can, if we use more variables:
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in this tavern, as he seems wild and looks as if
he comes from a far off wasteland. Perhaps if you can do something to calm him
down, he might tell you why he’s so upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
>load_prog 100~
mpsetvar me witchtalk 1
~
>greet_prog 100~
if ispc($n)
mpadd mpecho $I says, ‘Get out of my way!! GRRR!!!’
mpadd kill $n
else
endif
endif
~
>speech_prog witch mikaela sorceress~
if <(var-witchtalk,2)
mpsetvar me witchtalk 2
mpsetvar me adventurer var-actor
mpadd mpecho $I growls angrily.
mpadd mpecho $I says, ‘That evil witch, Mikaela.’
mpadd mpecho $I says, ‘She drove my people from their homeland.’
mpadd mpecho $I says, ‘This opens her tower. I could not figure out how.’
mpadd mpecho $I says, ‘Perhaps you’ll have better luck.’
mpadd mpoload 10045
mpadd give scepter $n
else
mpadd mpecho $I says, ‘That evil witch, Mikaela.’
mpadd mpecho $I says, ‘She drove my people from their homeland.’
mpadd mpecho $I says, ‘I hope $[adventurer] finds and butchers her.’
endif
~
|
A
5
C
2
So, what we have done here is used the mpsetvar command again. This command, which can never be preceded with an mpadd or mppush, creates a variable and gives it a value. In the previous example, this value was 2. In this case, the variable “adventurer” is created and given the value var-actor, which is $n, the person who set off the mobprog. The variable is later expanded using $[adventurer]. Now whoever asks about the witch will be told who the last person Groenk gave the scepter to was. Another way of setting the variable would be to use the following syntax: $[adventurer] := var-actor. You can learn a lot more about variables in the variable tutorial page. Let’s make two final changes. First of all, let’s handle a potential problem in the greet prog. If a group of players comes into Groenk’s room, each person in the group will trigger the greet_prog. This generates a lot of unnecessary spam and trouble. Let’s also make sure that only player characters can set off the speech_prog, and they can’t spam it, just to be safe:
#10001
groenk crazed barbarian~
Groenk the Crazed Barbarian~
A berserking barbarian tears apart the room here in a fit of anger!
~
This barbarian is in a frenzied battle with every piece of furniture in the
room. You
wonder how he even came to be in this tavern, as he seems wild and looks as if
he comes from a far off wasteland. Perhaps if you can do something to calm him
down, he might tell you why he’s so upset.
~
2 32776 0 S
24 4 –2 5d5+875 3d5+22
150 100000
8 8 1
>load_prog 100~
mpsetvar me witchtalk 1
~
>greet_prog 100~
if isqueued($i)
break
else
endif
endif
if ispc($n)
mpadd mpecho $I says, ‘Get out of my way!! GRRR!!!’
mpadd kill $n
else
endif
endif
~
>speech_prog witch mikaela sorceress~
if isqueued($i)
break
else
endif
endif
if isnpc($n)
break
else
endif
endif
if <(var-witchtalk,2)
mpsetvar me witchtalk 2
mpsetvar me adventurer var-actor
mpadd mpecho $I growls angrily.
mpadd mpecho $I says, ‘That evil witch, Mikaela.’
mpadd mpecho $I says, ‘She drove my people from their homeland.’
mpadd mpecho $I says, ‘This opens her tower. I could not figure out how.’
mpadd mpecho $I says, ‘Perhaps you’ll have better luck.’
mpadd mpoload 10045
mpadd give scepter $n
else
mpadd mpecho $I says, ‘That evil witch, Mikaela.’
mpadd mpecho $I says, ‘She drove my people from their homeland.’
mpadd mpecho $I says, ‘I hope $[adventurer] finds and butchers her.’
endif
~
|
A
5
C
2
In the greet_prog, we have added an if check with yet another mobprog function, isqueued. What this does is check to see if the mob already has commands in its queue. Also of note is break. The use of break in your mobprogs can be quite valuable. What break does is basically stop the mobprog. As soon as a mobprog comes to a break in its queue of commands, the mobprog is aborted. So in the greet_prog here, if the prog is set off multiple times in a row, the first will go through, and the rest will do nothing. This is handy; let’s say a group of nine people wandered in on Groenk. Instead of roaring and attacking all of them he’ll just go after the group leader which is a lot less spammy and in control. We also added something similar to the beginning of the speech_prog, using isqueued and also using the mobprog function isnpc, which checks to see if $n is a mob. If the speaker triggering the speech_prog is a mob, then the mobprog will break before any other command is given. Right now, the speech_prog would be triggered multiple times and spam a player considerably if they happened to say something like, ‘where is the sorceress, the evil witch they call mikaela?’ This would in fact trigger the speech_prog three times (one for each keyword) and that’s just sloppy. However, by adding an isqueued function, the mob can check and see if it’s busy and we can make it refuse to do its mobprog using the break function.
Hopefully now you can see some of the basics of mobprog design. From here you can look at other mobprog types, character variables, mobprog commands, and mobprog functions, or read more about variable usage, more complicated mobprogs, regular expressions, and frequently asked questions.
|
A MUD based on Robert Jordan's Wheel of Time series. With roleplaying encouraged through
guilds, clans, clanwars, holywars and throne wars. Experience the Wheel of Time world in a
whole new way: in an Age ravaged by the Last Battle. The time lace has been broken, the barrier
between dream and reality shattered. Weaves. Clans. Crafting. Huge World. Free Online Role Playing Game or commonly called RPG. The most unique Free Online RPG set in the Wheel of Time world.
|
- Wheel of Time Game - Wheel of Time Forum - Wheel of Time News - Wheel of Time About