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. 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 type, 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 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 every command line you use in a mobprog, although there are some exceptions. 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 type. 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

>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 <(stat($i,”con”),16)

    mpadd mpset me con 20

    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 used another if check and our first nested mobprog functions, < and stat. This may seem a bit complicated at first, but what this basically does is check to see if the mob’s constitution score is less than 16. Mobs always start with all of their stats as 11, although this can be altered by the equipment they load. So this mob checks its con, and then sets its con to 20. This means the next time someone sets off this prog, the mobs con will be 20 and 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 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

>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 <(stat($i,”con”),16)

    mpadd mpset me con 20

    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. This command, which can never be preceded with an mpadd or mppush, creates a variable and gives it a value. 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. 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, 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

>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 isnpc($n)

     break

  else

    endif

  endif

  if <(stat($i,”con”),16)

    mpadd mpset me con 20

    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. We also added something similar to the beginning of the speech_prog, 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.

 

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, and frequently asked questions.