Home Play News FAQ Forums Links

For Players

For Builders

Community


Vote for Our Mud on TMC!

Laios's Mob Program Tutorial

Mobprogs are a series of commands that a mob can use, each time a certain
trigger occurs. Building a mobprog can be fairly simple or it can be fairly
complex, depending on what exactly you want it to do.

There are two parts to making a mobprog. The first is actually coding the
commands themselves, in the order you want the mob to perform them in. Mobs
can use almost any normal command that players can use plus several more
special ones that only can be accessed using mobprogs. They cannot use
channels, however, so gossip, yell, shout etc cannot be the commands they
will use.

Mob special commands tend to duplicate imm-only commands, in order to make
more complex things happen around them. For example, a mob can trans people,
use echos, load/junk objects or mobs, and much more.

Each mobprog uses a seperate vnum, just like objects, rooms, and mobs do.
The mobprogs themselves can be in no particular vnum order. To start a blank
one, type 'mpedit create #', where # is a vnum in your area, preferably the
first one. (so for example, if your vnum range is 4200-4299, you would type
mpedit create 4200 to make your first one)

When you are in mpedit mode, of you press enter or type show, it comes up
with the stats just like anything else in edit mode. You'll note there's
only one field - the code. Mobprogs only have that one attribute, to which
you add the lines of text one by one in a by-now-no-doubt familiar
description writing utility.

Here are the basics of coding the mobprog itself:

Type 'code' after you're in your blank mobprog, in edit mode. It'll bring
you to a description window, just like writing room descriptions or mob
descriptions. A mobprog is very simple to code - just write the exact
command you want your mob to do, press enter, and add as many as you like in
the same manner. For example, if I wanted a mob to dance every time someone
entered the room then laugh right after, I would type this to create my
mobprog:

mpedit create 4200
code
dance
laugh
@
done
asave changed

And voila, you have a mobprog. Now it doesn't actually do anything yet,
because it needs 1. a mob to go on, and 2. a trigger to set it off.

To add a mobprog to a mob, (you can add as many mobprogs to mobs as you
like, and give mobs the same mobprog as well.. after all, all the mobprog is
is a series of commands), just go into medit mode on the mob you'd like to
add it to. The syntax to add the mobprog is thusly:

addprog <vnum of mobprog> <trigger name> <trigger specifics>

To get rid of an old one, type 'show' or press enter in medit mode to see
the list of mobprogs, and there will be a # list on the left hand side, of
them in order. (ie the first one will be 0, the second 1). delprog # will
erase the one on the list.

Done, then asave changed like normal, purge any existing mobs that you have,
then load the mob and trigger the mobprog. Voila.

Continuing the example I already used, assume I want the mob to dance and
laugh every time someone walked in the room, if the mob can see them. I have
already created the mobprog above, so it exists in the database for my area.
I would then go into medit to edit the mob I want to add the mprog to, and
type mpedit create 4200 greet 100. Thus, there is a 100% chance that when
someone enters the room from any direction, mprog 4200 will go off and thus
make him dance and laugh.


Here are a list of possible triggers and their possible values:
----------------------------------------------------------------------
ACT - string of text: mob checks if the string of text is shown in the room
somehow, as if he were a player -- poses, socials, commands. For example:
mpedit create 4200 act dances wildly before you. will trigger the mobprog
each time someone dances.

BRIBE - gold value: trigger happens if the amount of gold that someone gives
the mob is equal to or over the amount in the bribe #. So if a mob had
mpedit create 4200 bribe 10, if someone gives 10 gold the trigger would fire
but not if they gave 9 gold.

DEATH - percent: Trigger fires if a random % value is less then or equal to
the percent value you specify, at the instant the mob dies and before he is
actually whisked away into nothingness. So mpedit create death 100 will
always trigger on his death, mpedit create death 50 will trigger half the
time.

ENTRY - percent: Triggers if 1. the mob enters a room, and 2. if the % you
specify is less then or equal to a random percentage. So mpedit create 4200
entry 100 will always trigger if the mob enters a room. It triggers after
he's actually entered the room, though.

FIGHT - percent: Triggers if the mob is in combat. Each combat round it
checks once with a random % number, if it succeeds then at the end of the
mob's combat round, it will fire the mobprog. Don't raise the % too high or
the mob will be doing it constantly.

GIVE - vnum or object name or all: Triggers when a player gives an object to
the mob, that's not money, AND if the item the person gives has either the
vnum or the keyword in its name that you specify. For example, mpedit create
4200 give sword would trigger every time someone gave the mob any object
with the name 'sword' in it somewhere. mepdit create 4200 give 4371 would
trigger every time the mob is given an object with the vnum 4371. Give all
means any object in the game.

GREET - percent: Mob will check each time someone enters the room, from any
direction. If both 1. the mob can see the player, and 2. a randomly
generated % number is less then the one you specify, then the trigger will
fire on their entry. For example, mpedit create 4200 greet 100 will always
trigger when someone enters the room and the mob can see them - ie no invis,
sneak, wizi or whatnot.

GRALL - percent: Much similar to Greet, only it doesn't check if the mob can
see the person or not, the only thing it checks against is the random %
value. So if you added mpedit create 4200 grall 100, the mobprog will ALWAYS
trigger if someone enters the room.

KILL - percent: On the very first round of combat (ie if a mob is out of
combat and gets attacked), the mobprog will trigger if the % value is higher
then a randomly generated one. So if you have mpedit create 4200 kill 100,
then every time the mob gets attacked when he's not already in combat, the
trigger will fire.

HPCNT - percent: Stands for 'hit points percent', if the mob is 1. in
combat, 2. less then or equal to his own max hp divided by his current hp,
and that value is less then the % defined when adding the mobprog. For
example, mpedit create 4200 hpcnt 50 means each combat round, the mobprog
will fire if and only if his hp are below 50% of max. (ie below big nasty)

RANDOM - percent: Each update tick (ie each time, for example, the poison or
plague messages come up), if a person is in the same area as the mob, and
the % you've set the trigger to is greater then a randomly generated %, then
the mobprog will fire and the mob will perform the associated commands.
Note-- this is good for making mobs howl, or noises across your area, or to
check if people are in the area at all.

SPEECH - text string: checks whenever a person uses 'say' in the same room
as the mob and any series of words matches what you've put in his trigger.
For example, mpedit create speech password is dancing monkeys will trigger
whenever someone has the words 'password is dancing monkeys' in a say. So if
they say 'hey I think the password is dancing monkeys' it will trigger, but
if they left out the 'hey I think the' part, it would trigger also.

EXIT - direction: checks a certain direction for when a player wants to
leave, and if they do then it will trigger. NOTE: A player will NOT be able
to leave the room if they want to go in that direction and there is an exit
trigger on a mob. You will have to make the mob trans them, or make the mob
killable so they can pass. Ie mpedit create 4200 exit north will not allow
people to leave north, but the exit will still remain. ONLY triggers if the
mob can see the person, however.

EXALL - direction: Works the exact same way as the Exit trigger, though
triggers even if the mob cannot see the player.

DELAY - seconds: The mob can 'remember' a player using a previous mobprog
code, and can use that person's name in the delay mobprog - ie when the
delay timer has gone off, the new mobprog will fire. This mobprog trigger
tends to get quite complicated, so it's best to just leave it alone.

SURR - percent: triggers if a player types 'surrender' in combat with the
mob. If the percentage is higher then a randomly generated one, then it will
stop combat and do the series of commands. Not a terribly useful mobprog,
but it's here nonetheless. If the check fails the combat will still continue
like normal.
-----------------------------------------------------------------------

But what if you want the mob to actually interact with the player in some
way? Ahh, that's not hard at all, either. Every time the trigger goes off,
the mobprog stores who or what triggered it in seperate values called
'variables', that you can use in your mobprogs. It definately helps to
breathe life into your mobprogs.

Here are some of the easier values to remember:

are the -keywords- for a mob. For players, their keywords are their name,
but for mobs they are the keywords defined when the mob is created and
players won't actually see. If you add to a mobprog in saying something,
though, it will show their keywords instead-- like if my mobprog code was
'say Hello, !' if a mob triggered the mobprog, the mob who has the mobprog
would say something like 'Hello, cityguard guard oldstyle man human!'
Instead, use .

is the short_description of who you triggered the trigger. So whoever
entered the room on a greet trigger, whoever's fighting the mob on a
fight/death trigger, whoever gave the object on a give trigger. If you want
your mob to say the name properly, use instead of .

So for example, in the earlier mobprog I created, I could change it to:

dance
laugh
say Wow, is ever a bad dancer!

And it would automatically replace with whoever triggers the mobprog each
time, in this case, each time someone enters the room it would replace those
variables with their name. Neat eh?

In the same manner, you can use %o, for object. This only is useful for the
'give' trigger, however, because no other triggers would know what object
you're talking about. The object that you give is the , obviously - so if
I wanted, for example, a trash compacter mob that automatically sacrifices
objects, I would put the following in the code:

drop
say Hah! I'm going to sacrifice this nice shiny !
sacrifice
snicker

And then I'd add the mobprog as on 'give all' for trigger, and loaded the
mob. I could give the mob any item I was carrying, and he'd automatically
drop it and sac it, then snicker at me. The bastard!

-----------------------------------------------------------------------

Instead of just using boring humdrum player commands in your mobprogs, like
dance and snicker and kill and so on, mobprogs can make the mob do special
fun commands that normally people who aren't imms would not be able to do.
If they're abused then you will lose immship immediately and everything
you've done nuked, mainly because it gives mobs the power to do nearly
anything.

To use a mobcommand, simply type them into the mobprog code like you'd type
a normal command. Make sure they have 'mob' in front of them, however. Like
'mob asound A yell sounds from nearby.' will, when the mobprog triggers,
have everyone in adjacent rooms see 'A yell sounds from nearby.' But if you
have 'asound A yell sounds from nearby.' nothing will happen, because you
need the 'mob' before it.

--ASOUND: Syntax: mob asound <string> = shows the exact string to all rooms
adjacent to the mob, when it is triggered. So it doesn't really have
anything to do with sounds or music.

--GECHO: Syntax: mob gecho <string> = Echoes the string to every player in
the game, whether or not they're sleeping, quiet, or whatever. Use EXTREMELY
sparingly, because nobody wants to be bothered by stuff when they're nowhere
near your area. :P

--ZECHO: Syntax: mob zecho <string> = Sends the string to everyone in the
zone that the mob is in. Great for replacing yells, which mobs can't do.
Remember that in all these strings, you can add or to add some color-
like mob zecho A sentry yells, ' is here!' will make the mob /seem/ to
yell it, but asleep people or deaf/quiet can still see.

--KILL: Syntax: mob kill <player/mob> = Allows a mob to attack a player/mob
without having to use 'murder', which is logged and can get spammy. Also, it
doesn't check if the player is safe from taking damage, so use it
judiciously. 'mob kill ' will make the mob start combat, for example, with
whoever triggers it in the first place. (ie if you have it in a grall
trigger, everytime someone enters the room with the mob in it, they'll get
attacked)

--ASSIST: Syntax: mob assist <player/mob> = Allows a mob to assist another
player or mob in combat, the recipient of which is in the keyword used.
Doesn't check kill stealing or safeness, so if you have 'mob assist ', for
example, then 1. when the mobprog triggers, and 2. if the triggering
person/mob is in combat, then the mob with the mobprog will leap into the
fray and help . Good for a speech trigger like, mepdit create 4200 speech
help me, and in code mob assist , and the mob will jump in if someone says
help me and they're fighting.

--JUNK: Syntax: mob junk <obj name/keyword/all> = Mob utterly nukes an item,
defined in the name/keywords/all. The object has to be either worn by the
mob or in the mob's inventory for it to be junked. Using mob junk all, every
item in the mob's inventory will be nuked. To nuke things you give to a mob,
use 'mob junk ' on a give trigger, and each time the mob is given
something he'll junk it. No message is given, it just vanishes.

--ECHOAROUND: Syntax: mob echoaround <target> <string> = Everyone in the
room EXCEPT whoever is in <target> and the mob itself, will see the string
shown. So mob echoaround A giant squirrel runs in and beats over the
head. will show the string to everone in the room but (namely, the person
who triggered it in the first place) and the mob who the trigger is on.

--ECHOAT: Syntax: mob echoat <target> <string> = Prints the message to ONLY
the person specified in the 'target' section. So mob echoat You fall off
the cliff! will show it to whoever triggered the trigger in the first place,
and nobody else.

--ECHO: Syntax: mob echo <string> = Prints the text to everyone who's in the
room, whether or not they're sleeping, quiet, or whatever.

--MLOAD: Syntax: mob mload <vnum> = Loads a mob of vnum that you've defined,
in the same room as the mob with the trigger. Doesn't show any load
messages, the mob will just appear there as if an imm had loaded it. While
any mob from any area can be loaded, use your own common sense and please
just load mobs from your OWN area into your own area.

--OLOAD: Syntax: mob oload <vnum> <level> {R}/{W} = Lets a mob load an
object. If R is not added to the end, the mob will load it into his
inventory. If so, the mob will load it into the room, on the floor. If W is
there instead, the object will load in his inventory, then the mob will
automatically wear it. There are no wear messages, however. The <level>
should be whatever level the object itself is; it's just there so you can
make objects lower then their normal level. Which you shouldn't do. Ever.
Got that? Good.

--PURGE: Syntax: mob purge <target>, or mob purge = Lets a mob nuke a
certain thing in the room. There are no messages for this, however. Purge
removes it entirely from the game, be it an object or a mob. Mob purge does
exactly as the immortal command 'purge' does - wipes all mobs and all
no_purge objects in the room. For safety reasons, the mob cannot purge
himself.

--GOTO: Syntax: mob goto <vnum/mob/player> = Lets the mob transfer himself
exactly as if he had used the imm command, 'goto'. Try not to have mobs goto
things outside your area though, or resets could get a bit messed up.

--AT: Syntax: mob at <command> = Lets a mob do a command /at/ a certain
target - target must be a name of a mob, like mob at <action> or mob at
lizard dance, for example. You can also nest mob commands, to do things like
mob at mob mload 4200, which will load the mob 4200 at wherever the
person who triggered the mobprog is. It can be both very useful and very
complex, however.

--TRANSFER: Syntax: mob transfer <target/all> <location> = In much the same
as mob goto, mob trans can transfer the target player or mob to a different
location, be the location a vnum or another mob or player. If you put 'all'
instead of a mob's name, every mob and player in the room will be transfered
to the new location. Has no message for transfering, and immediately halts
combat to all people as well.

--GTRANSFER: Syntax: mob gtransfer <target> <location> = Works the same way
as mob trans, but transfers everyone in the same group as the target to the
new location as well. As always has no messages for transing, so make your
own via mob echo if you want.

--FORCE: Syntax: mob force <target/all> <command> = Forces the target to do
a certain command. Cannot be imm-level commands, and the target has to be in
the same room as the mob with the mobprog. Mob force all <command> makes
everyone in the same room use the command.

--GFORCE: Syntax: mob gforce <target> <command> = Much like mob force, this
mob command makes everyone who's in the same group as <target> perform the
command, as long as they to are in the same room.

--VFORCE: Syntax: mob vforce <vnum> <command> = Similar to the other force
commands, vforce however searches through all mobs in the game, and if the
vnum is the same as <vnum>, forces them to perform the action. Please limit
this command as it's somewhat server-heavy, and never force mobs outside
your area to do things. Jsut common curtesy.

--CAST: Syntax: mob cast <spell> {target} = This mob command allows a mob to
cast any spell in the game. It does not check for target validity or mana,
so use sparingly. Make sure you do all necessary checking beforehand in your
mobprog, or better yet just don't use it at all.

--DAMAGE: Syntax: mob damage <victim> <max> <min> {lethal} = This command
does unconditional, unblockable damage to someone without bringing them into
a fight with the mob. Use with caution, since it has no damage message you
should add your own via mob echo. If you omit the 'lethal' at the end, then
the mobprog will not kill the person, but if you do then it will when they
go below 1hp. An example - mob damage 200 200 lethal - that will hit
whoever triggered the mobprog for 200 points of damage, killing them if they
get below that.

--REMEMBER: Syntax: mob remember <target> = Lets a mobile remember a target,
that can then be called on using and in future triggered mobprogs
rather then and , so the person doesn't even have to be the one
triggering it. For example, the drunks in midgaard remember who it is they
stumble towards, so a tick later they puke on them. They use the mob
remember to remember the person's name, and in the next mobprog they have
puke . It can get quite complex and entertaining if you have lots of these
- one idea is for people on the street to rememeber when people pass by.

--FORGET: Syntax: mob forget = Clears the and variables from mob
remember. Make sure if you set a new mob remember, that you clear the old
one.

--DELAY: Syntax: mob delay <pulses> = Sets a delay time for mobprog
execution. When the timer counts down and hits 0, the mob is checked for any
mobprogs with the 'delay' trigger set on them. If one is found, it triggers
the mobprog. Can be used with mob remember to delay a certain time, then use
the to do things to people no longer triggering it.

--CANCEL: Syntax: mob cancel = Stops any mob delays currently counting down,
before it's reached 0.

--CALL: Syntax: mob call <target/null> <field1/null> <field2/null> = Lets a
mobprog call another mobprog. Careful of unwanted loops and triggerings, and
too many is a big problem. It's best just to not use mob call at all.

--FLEE: Syntax: mob flee = Forces the mobile to flee. Doesn't give messages
I believe, and doesn't check for web or being bashed or whatnot.

--OTRANSFER: Syntax: mob otransfer <item name> <destination> = Lets the mob
transfer an object, which must be in the same room as the mob who is using
the mobprog. It's basically exactly the same as mob transfer, only with
objects instead of players.

--REMOVE: Syntax: mob remove <target> <vnum/all> = Mob forces the target to
remove a certain piece of equipment. Doesn't have a message and doesn't
check validity (ie no_remove eq..) so use sparingly and with caution. With
all instead of a vnum.. hehe, you can force a player to remove all their eq
at once. Fun eh?
----------------------------------------------------------------------

You can also have if checks in your mobprogs, which make them a hella lot
more complicated. If you are just looking for basic mobprogs, read no
further because this will likely confuse and frustrate you. Plus if you are
a newbie mobprog maker, don't fiddle with if statements because if you type
them incorrectly, all mobprogs will suddenly stop working. :P

An if statement is a section of your mobprog code that checks for a certain
thing or attribute to be true, and only lets the mob do the commands if the
statement is true. You can check a large list of things, which I will name
later. Here is the syntax simplified:

If <if statement>
command
command
command
else
command
command
end if


You would put this in your mobprog code itself, and replace the <if
statement> with one of the following:
(note: if I use * somewhere, that means it's a numerical checking -- use one
of the following: >, <, ==, or != .. do not use = to check if something
equals something, use == )


if rand # -- if a randomly generated, temporary % less then #
if mobhere <name/vnum> -- if there is a <mob/player name> in the room
if objhere <name/vnum> -- if there is an obj with name/vnum in the room
if mobexists <name> -- does the mob exist somewhere in the world
if objexists <name> -- does the object exist somewhere in the world
if people * # -- does room contain # number of players + mobs
(eg if people < 4 -- does room contain less then 4 mobs or players)
if players * # -- as above, but players only
if mobs * # -- as above, but with mobs only
if clones * # -- as above, but with mobs of same vnum
if order * # -- is mob number # in list of players/mobs in room
(eg 'if order == 0' will check if mob first mob in the room)
if hour * # -- is game time compared to #
(eg is hour < 11 will check if the time is under 11oclock)
if isnpc <player/mob> -- is player/mob a mob
if ispc <player/mob> -- is player/mob a character (player)
if isgood <player/mob> -- is player/mob good-aligned (over 300 align)
if isevil <player/mob> -- is player/mob evil-aligned (under 300 align)
if isneutral <player/mob> -- is player/mob neutral-aligned
if isimmortal <player/mob> -- is player/mob an imm (level 93+)
if ischarm <player/mob> -- is player/mob affected by charm
if isfollow <player/mob> -- is player/mob following someone
if isactive <player/mob> -- is player/mob not sleeping
if isdelay <mob> -- does the mob have a mob delay counting down
if isvisible <mob/player> -- can the mob see the mob/player
if hastarget <mob/player> -- does the mob have a target for mobprogs
if istarget <mob/player> -- is the mob a target of a mobprog
if exists <name> -- does the <name> exist somewhere in the world
if affected <name> <affect> -- is the <name> affected by an affect..
(eg. if affected blindness will check if is blinded)
if act <name> <actflag> -- does the <name> have act flag <flag>
(eg. if act sentinel will check if is a sentinel mob)
if off <mob> <offensive> -- does the mob have <offensive> offensive flag,
ie bash
if imm <mob/player> <immunity> -- is the mob/player immune to a certain
thing, ie fire
if carries <target> <vnum/name> -- does the mob/player carry a certain
object
if wears <target> <vnum/name> -- does the mob/player wear a certain object
if has <target> <item type> -- does the mob/player have any item of type
<type>
(eg. if has weapon)
if uses <target> <item type> -- as above, only if worn
if name <target> <string> -- is the target's keyword <string>
if pos <target> <position> -- is the target's position <position>
(positions include dead, sleeping, standing, sitting, resting, etc)
if clan <target> <clan name> -- is the target in <clan name> clan
(eg. if clan shaido)
if race <race name>
if class <class name>
if objtype <object name>
if vnum <thing> <vnum>
if hpcnt * # - ie. if hpcnt < 50
if room * # - ie. if room == 12500
if sex * # - checks for sex - 0 male, 1 female, 2 neutral
if level * # - checks if level <>= #
if align * # - checks for align
if money * # - checks if 's gold

-------------------------------------------------------------
Here's a sample, simple if check, using mob commands as well:

mpedit create 4200
code
if affected flying
mob echoat You flutter easily above the boiling lava.
else
mob echoat Ouch! You are burned on hot lava!
mob echoaround is burned as tries to cross hot lava!
mob damage 100 250 lethal
end if
@
done
asave changed

Say my mob is mob 4223, I would then type..
mpedit 4223
addprog 4200 grall 100
done
asave changed

And to test..
load mob 4223
Walk back in and out, and it'll come up with the message. :)