The following examples have all been written by me, and all should work in a stock ROM 2.4 MUD with no problems. If you find an error, please let me know about it. I will not guarantee that what has worked for me will work for you. No trigger lines are given, because the mobprog code is often the most difficult part. The type of trigger is still there, so you can easily replicate them.

In all the examples, I've indented if-else-endif statements to make them easier to follow.


Rand prog - A silly little thing I wrote for a naiad.

smile $r
laugh
emote gets a mischieveous grin on her face and dives underwater.
mob echoat $r $I splashes water on you from behind!
mob echoaround $r $I surfaces from the water and puts a finger to her lips.
mob echoaround $r $I splashes water on $r!
giggle
emote Dives back underwater and surfaces back in front of you.
innocent $r
~

Grall prog - I wrote this one for a male ranger; if the player's sex is less than 2 (neuter), he'll tip his hat to them. Otherwise, he'll give the player a rose and wink.

if sex $n < 2
  tip $n
  else
    rose $n
    wink
endif
~

Act prog - The trigger for this is a player putting an offering of grain onto an altar. The priest then checks to see if the player is evil (the priest is an elf, inherently good). If so, he kicks them out. Otherwise, he gives the player a fairly nice medallion, casts bless, and then kicks them out.

if isevil $n
  shake
  say Thank you for your offer, but your evil ways are something I cannot condone.
  say Please leave this place now.
  mob transfer $n 162
  break
  else
    say Thank you for your kind offer.
    say It will help the forest to grow stronger.
    smile $n
    mob oload 138
    give medallion $n
    say This is a gift from the forest to you.
    emote raises his hand in benediction.
    say Go with the blessings of nature.
    mob cast bless $n
    mob transfer $n 162
endif
~

Exit prog - This is for a shopkeeper. When a player tries to leave, he thanks them. The mob transfer and mob force are important - otherwise, the player could never leave due to the way the exit trigger works. The forced look is to simulate the autolook upon entering another room.

say Thanks for comin', stop by anytime!
wave
mob transfer $n 122
mob force $n look
~

Kill prog - I wrote this one for a meditating druid. The room was flagged no_mob, so nothing could have wandered in. When the druid is attacked, she has a 40% chance of calling this prog. A ranger jumps in and starts beating up on whoever attacked (coincidentally, it's the same ranger who tips his hat or winks at players).

yell Help me! I'm being attacked by $n!
echo Suddenly, a ranger crashes through the bushes!
mob mload 103
say It was $n!
point $n
mob force ranger mob kill $n
~

Speech prog - For the one friendly mob in a dangerous area, whose task is to kill the Nephilim Pain. Incidentally, it's also the task of any player in the area, since if the Nephilim still lives, the player can't leave. It's easier said than done, however.

if mobexists nephilimpain
  say She's still here ... her magic won't let me let you go.
  apologize $n
  say I'm sorry.
  break
  else
    say I will let you go ... I just want to help those leave who wish.
    say Fare well, $n.
    emote closes her eyes and mumbles a few words.
    emote points at you and concentrates with the nature around her.
    mob gtransfer $n 21930
endif
~

Bribe prog - For a tavernkeeper in a city. If the player gives him 200 silver (or 2 gold), he'll take them to a safe room with a cosy bed. I don't think many players caught on to this one, even though his greet prog mentioned giving him 200 silver for a room.

say Thank ya kindly. Your room's just up these stairs, follow me ...
emote escorts you up the stairs into your room.
say Have a pleasant rest.
mob transfer $n 6241
mob force $n look
~

I would like to thank Kristian Jørgensen, Deanna (of Hell's Gate) and Alex Mandez for graciously providing the following examples.

Kristian's Examples

Give prog - Upon giving the lost object to the mob (who seems to be a burglar), he gives you a clue about something that's in a nearby house.

say Thanks a lot, stranger. I've been looking for that darn thing for hours.
say You might want to look in a little hole I found in a house nearby.

Fight prog - Fairly straightforward; if the mage has less than 10% of his hit points remaining, he "vanishes" using a mob purge command. Otherwise, he taunts the player and keeps fighting.

if hpcnt $i < 10
  mob echo The summoned mage startes to shimmer and suddenly disappears.
  mob purge $i
  else
    say Am I too strong for you?
endif

Greet prog used with Delay prog - The first line is viable only if all weapons in your MUD are required to have "weapon" as a keyword; otherwise, it can be replaced with a weapon type (sword, dagger, etc.). In the second prog (the delay prog), if the player is still using (i.e., wielding) his weapon, the guard will attack.

if uses $n weapon
  say You will remove your weapon or be attacked!
  mob remember $n
  mob delay 5
  break
  else
    emote nods at you.
endif

if hastarget $i
if uses $q weapon
  say I told you to sheath your weapon..pay the price!
  mob kill $q
  else
    say Good...keep your weapon that way.
endif
mob forget

Deanna's Examples

Delay prog - Another prog (that I was not given ^^;) is needed with this one so that the mob can acquire a target (a simple greet prog will work with a very short delay, 2 is plenty). Then it can be called, and the results are fairly straightforward. The player is blinded, and the baker "rescues" him with some water.

if hastarget $i
  mob echo A cold breeze blows in from the south.
  mob echo You are blinded by the flour in your eyes.
  mob echo You can't see a thing!
  mob echo Someone throws water at your face, clearing the flour from your eyes.
  say Sorry. Happens all the time.
  sigh
  mob forget
  else
    mob forget
endif

Greet prog used with Delay prog - Used in a general store, the shopkeeper seems to be a very sleepy one. If the player is in the room for more than a tick, the shopkeeper falls asleep.

stretch
say Pssst, $N.
say Quickly, find what you need and leave.
yawn
mob remember $n
mob delay 6

if hastarget $i
  emote blinks slowly...
  emote falls asleep on the counter.
  mob forget
  else
    mob forget
endif

Speech prog - This one is used for the entrance to a clanhall; if the player says the correct keyword, then the prog is called. Otherwise, the clanhall's guard does nothing (that I know of, anyway).

mob echoaround $n $n is shoved rudely north through the door!
mob echoat $n You are shoved north through the door!
mob transfer $n 12025
mob echoat 12025 $n stumbles in from the door to the south!

Entry progs - Two entry progs here; the first is for a dog who likes good-aligned players, but not so much neutrals or evils. The second prog is for a pet shop (seems to be a wandering pet shopkeeper, since entry progs only fire when the mob enters a room).

if isgood $n
  mob echoat $n $I wags $l tail at you.
  mob echoaround $n $I wags $l tails at $N.
  else
    growl $n
endif

if sex $n < 2
  say Hello $n!
  say What can I do for you today?
  else
    say Greetings M'Lady!
    say Kittens are most loveable.
    bow $n
endif

Rand prog - Deanna says she has a lot of different rand progs for drunks (such as this one) and beggars, and her cities have really come to life. I strongly urge everyone to do the same ^.^

burp
say Oh, pardon me.
giggle
say Yummm... taste likes beer.

Act prog with a mob call and a Delay prog - Ah, complexity :) In the first prog, the mob checks to see if the player is fighting (perhaps it is called on something like "engages in combat"?) and warns the player to stop. In the second prog, the mob checks to see if the player is wanted (a criminal). If so, the mob warns the player that he has five seconds to stop. In the third, if the player still hasn't stopped fighting, the mob knocks him out and transfers him to jail. Perhaps now the troublemakers will learn their lesson.

if pos $r == fighting
  say Damn it, stop fighting.
  mob call 31841 $r null null
  else
    mob forget
endif

if wanted $n
  say You have five seconds, $N, to stop this outrage.
  peer $n
  mob remember $n
  mob delay 1
endif

if wanted $n
  mob echoat $n You have been knocked unconcious!
  mob echoaround $N The Guard knocks $n out with at huge stick.
  mob echoat $n You have been hualed off to jail.
  mob transfer $n 32039
  mob echo The guard sends $n to jail.
  say Some people never learn!
  else
    mob forget
endif

Alex's Example

Nested Rand progs - The nested rand prog had slipped my mind for some reason. They are quite useful in certain situations. This mobprog is for a bard, and randomly selects lyrics for her to sing. I'm told the lyrics don't translate to anything, which isn't bad - it gives the impression that the song is in a language that is mostly forgotten to the people in the world of your MUD. Also note the way that rand is used - the highest is listed first, and it goes down.

if rand 75
  emote sings, "Tiral... Nir van estal..."
  emote sings, "Uran in sion de pr'an."
  emote strums her Lyre and continues singing.
  else
    if rand 50
      emote carfully picks a beautiful harmony.
      emote sings, "Eden qurrel lorn..."
      emote sings, "Firnir in sion de pr'an."
      emote continues singing.
      else
        if rand 25
          emote sings, "Es yewm van estal..."
          emote sings, "Ishon it'lal lorn."
          emote strums her Lyre and continues singing.
          else
            emote sings, "Tiral... Iob'ne uten."
            emote makes a sweeping chime with her Lyre.
            emote sings, "In opr'an es yewm."
            emote continues singing.
        endif
    endif
endif