This is a small FAQ on mobprogs that I have written up, based on popular questions on message boards such as The MUD Connector and Top MUD Sites, as well as questions I specifically gathered for the purpose of this FAQ. My thanks go out to Nisi, Raina and Smadronia for providing some of these questions, and to the many posters on those boards for asking the other questions over and over again. If you've any questions about mobprogs, please feel free to send them my way (noting that my address is mangled, of course). I'll do my best to answer them, though it's been a while since I've used mobprogs in any way.
Mobprogs go by too fast. Can I slow them down?
No, I'm afraid you can't - not without having to do something painful. You would have to string several mobprogs together, using mob delays, remembers, and delay triggers for it. Obviously, the more you want to slow the prog down, the more progs you'll have to write to acheive that.
Of course, you could also bother your coder to make a "mob pause" command that will pause the mobprog in the same way that a delay prog does - using the "pulse_mobile" as a counter. The syntax would most likely be "mob pause X", where X is the number of pulse_mobiles that you want to pause for. If I find something like this, I'll be sure to let the world know. Or, if you have something like this, and want the world to know, tell me and I'll pass the information along.
Back to top
What's rand? And what difference does it make if I use rand 1 or rand 50?
Rand is short for random - and that's just how this trigger type works. Give it a number between 1 and 99, and it will activate the mobprog that percentage of the time. Rand 1 will fire 1% of the time, and rand 50 will fire 50% of the time.
It makes a lot of difference what number you use - too high of a number will lag the MUD, and too low of a number will make it unlikely that players will see it. In practise, these numbers are just as changeable as real odds, much like flipping a coin. The coin may land on heads seven times in a row (your prog triggers several times in rapid succession), and then land on tails a few times (your prog doesn't trigger), then on heads (it triggers), then a streak of tails (your prog doesn't trigger for a while). However, in the long run, it will even out so that your prog does indeed fire that percentage of the time. Do a search on chaos theory if you want more information on that subject.
As I said before, too high of a number will lag the MUD. A few rand 50 progs won't make much of a difference, but too many of them will. The rand trigger only fires when a player is in the area, and this includes immortals and switched immortals.
I have found that a number between 3 and 9 works perfectly well for most rand prog needs.
Back to top
Are you familiar with the lag monster? You will be if you forget that endif. For some reason, leaving one out begins to lag the MUD. It's unnoticeable at first, but after a while, it will become noticeable. And then it will become unbearable, necessitating a reboot to clear the lag. At least, until it rears its ugly head again.
Just go through the recently-added mobprogs, and find the one that's missing the endif, and put it in. Your players and fellow immortals will thank you. Or, at least, they'll stop complaining.
Furthermore, why have all the mobprogs in the MUD stopped working?
See above. For whatever reason, forgetting an endif also has the additional effect of stopping every single other mobprog from working. I assume that this is because all of the MUD's spare resources are being devoted to finding that endif, no matter what, and it runs out of resources to run the other progs. It's like a memory leak: resources are being spent, but none are being returned for re-use.
Back to top
That's because of the way that speech is parsed by mobs with speech triggers. As described, any word or phrase containing "no" will activate that speech trigger, such as "now", "nowhere", "noob", "nonchalant", etc. Basically, whenever a player says something in front of a mob with a speech trigger, the MUD searches what the player says for the word in the mob's speech trigger.
While this can be quite annoying at times, it also facilitates creating strings of words that supposedly trigger something, while only one of those words is actually in the trigger. For instance, if you wished to have a mob open a secret passageway on the phrase "the camel sleeps at midnight, but only anachronistically so", you could use the word "anachronistically" for the trigger, as it's unlikely that any player will say "anachronistcally" and accidentally activate the trigger.
Back to top
Do I have to use "if" and "else"? Can I use "then", too?
Yes you do, and no you can't. "Then" is a redundant word in logic flow, and is implied by the word "if". My apologies if you are used to using if/then/else statements in programming, but if I recall correctly, the word "then" hasn't been used for quite some time in programming. Last time I used it was in BASIC. YMMV.
Back to top
A variable is something that changes. In the context of mobprogs, a variable stands for a certain actor or object in the program, allowing for mobprogs that can get quite complex. For a complete listing of variables, and what actor or object they represent, please see here.
Back to top
A trigger is a command that tells the MUD exactly how, and when, to activate a mobprog. Different types of triggers will activate in different ways, in different circumstances, and at different times. For virtually any action a player can take, there is a trigger that will take that action into account, allowing your mobiles to react to practically everything that a player does.
One of the most universal is the "act" trigger, which will activate whenever a player does an action that is specified in the mob's trigger line. It covers things such as putting objects into and taking them out of containers, wearing and wielding things, performing socials, going to sleep, etc. Another very common trigger is "rand", where the mobprog activates at random times depending on the number specified in the trigger line. A third common trigger is "say", which activates whenever a player says something that is contained in the trigger word.
And what are the triggers, and what do they do?
There's a very brief explanation of three triggers above; for a complete list of triggers and their functions, please refer to this page.
Back to top
It all depends on whether or not you're building with OLC (on-line creation) or offline.
If you are building offline, as I prefer to do, open the area file in a plain text editor such as Notepad. Go to the #MOBILES section, and locate the mob to which you wish to add the mobprog. It will look similar to this (ROM 2.4):
#120 naiad~ a naiad~ A beautiful faerie-like creature splashes happily in the water. ~ The little faerie is a naiad, a type of faerie that lives in and around the water, relying upon it for sustenance. Being away from water will cause her to become lethargic and eventually die. She is absolutely beautiful, with small, gossamer wings and light blue skin. Her eyes light on you and she laughs a wonderful, enticing laugh as she smiles and goes back to playing in the water, which she seems to be one with. ~ unique~ BG BDNPb 1000 0 25 4 25d10+2200 10d10+100 3d12+16 shock -15 -14 -14 -10 FGIU BLR FHIM J stand stand female 0 ACHMV ABCDEFP medium 0 M rand 108 10~
The trigger line is in yellow (don't do that in your area file). Now, go down to the bottom of your area file. Just before the End of File (designated with a #$), add a new section, #MOBPROGS. In this, list your mobprogs in vnumerical order. If they are not in vnumerical order, then they will simply not work. The #MOBPROGS section is closed with a #0 (that's a zero). It should look similar to this (pretend that progs 100 through 107 are there):
#MOBPROGS #108 emote splashes about in the cool water. giggle ~ #0 #$
Note the End of Section and End of File markers there. And that's about all there is to adding mobprogs in an offline environment. Simply repeat as necessary.
Adding your mobprog in an online environment is even simpler. To do, simply follow these steps:
Medit the mob (medit [mob vnum]), and type addmprog [mobprog vnum] [trigger] [argument], and press your Enter key. After that, it is a matter of typing the mobprog in, line by line. I highly recommend writing your mobprogs ahead of time and double-checking them to make this a bit easier. For instance, with the above mobprog, you would type this:
medit 120 addmprog 108 rand 10 done asave changed
Okay, I messed up. What do I do to delete the prog?
Offline, delete the appropriate trigger from the mob in the #MOBILES section, along with the appropriate program from the #MOBPROGS section. And that's the end of that.
Online, type the following (using the same example mobprog and mobile as above):
medit 120 [press Enter to bring up a numbered list of mprogs in your area] delmprog X [where X is the number of the mprog; if it's the only one you added, it should be 0 or 1] done asave changed
And then you can go about your business, whatever that may be. Probably making mobprogs.
Back to top
Calm down, take a deep breath, grab a cigarette or some chocolate, and relax. It'll be okay. I promise. Breathe, breathe ...
This could be caused by any one of several things, the most obvious of which (to me, anyway) is a missing endif. However, there could be another cause, and to tell the truth, I couldn't tell you what it would be without looking at the mobprog. My apologies.
Some general advice: simply delete the mobprog so that it can not slow down the MUD any more, and look over it. If nothing strikes you as being incorrect, wait a bit and look at it again. In the meantime, ask another builder, preferably your head builder, to see if they notice anything wrong. Advantages of asking your head builder: you look willing to learn from your mistakes, they get to show off what they know. Be sure to thank them, too!
Back to top
Is it okay to use the same mobprog on a different mob?
Go for it. There's nothing wrong with it. You can even write different triggers for them. However, I strongly recommend not using the same mobprog too often; it can make your area look shoddy. It can also make your area annoying, because if every single mob in the area greets you with a cheery "Hallo, milord!", you'd probably want to begin decapitations with all due haste. At most, I would use the same mobprog no more than twice, and write different versions to spice things up a bit. However, I believe an exception can be made for singing birds (unless, of course, you want them to have individual songs).
Back to top
How does the delay trigger work?
A delay program has two different parts - the delay trigger itself, and a delay command in a separate program. The program containing the delay must trigger first. For example:
M 1000 greet 100~ #1000 say You may not pass, $n. say Leave now. emote looks at you and fingers his weapon. mob remember $n mob delay 3 ~ M 1001 delay 100~ #1001 say I told you to leave, $q! say Now you must die. mob kill $q mob forget ~
Those progs are for a guard I made up, but they should work (I haven't tested them). Program 1000 is the initial program, which contains the delay command. He uses a greet trigger, says a few things, remembers the player who entered the room, and begins the delay, which has a value of 3. The delay then begins to count down, using pulse_mobile as a counter. As there are 6 pulse_mobiles in a tick, this mob will wait half a tick to begin his next program.
Program 1001 is the actual delay program, and is called once the delay countdown in program 1000 has finished. The trigger line's argument is the percentage of the time that this program will activate; it is a good idea to set it at 100 for most programs, unless circumstances dictate otherwise. He says some things, makes good on his threat, attacks the player ($q is the variable denoting the remembered player in a mob remember), and then forgets him (otherwise, if the player flees, the mobile will continue to attack him every time the player enters the same room as that guard, until the guard remembers a different player or is killed).
Back to top
Can I just put a delay in a mobprog, or do I have to use the delay trigger?
Unless your coder has changed things, the delay trigger is necessary. In stock ROM code, the MUD will stop executing the program after a delay command has been reached. If no corresponding delay trigger is found, then nothing happens.
Back to top
Main
About ...
the site
the author
Rant
Muds
Resources
Mobprog FAQ
Mobprog guide
Mobprog examples
Areas
Games
Morrowind
Rogue-likes
Art
Contact
Misc.
Links
Sitemap