Mprog Compendium/Examples

==Chibi-Devil==
===Mob Info===
Short descr
:a Chibi-Devil
Long descr:
:A miniature devil flaps around here on tiny bat wings.
Description:
:This little demon is almost cute. It is exactly like a devil but very small. It has small bat wings to flap around with, little nubby red horns, and even a miniature pitchfork. Chibi-devils love causing mischief for adventurers, and are not above swiping from their bags. 
 MOBPrograms for [ 9153]:
 Number Vnum Trigger Phrase
 ------ ---- ------- ------
 [ 0] 9154 GREET 30
 [ 1] 9161 RANDOM 5
 [ 2] 9155 SPAWN 100
===Mobprogs===
MPROG 9154 [GREET 30]
 if align $n > 500
 mob skill backstab $n
 endif
This program executes 30 percent of the time whenever the chibi-devil sees someone enter the room. The $n variable is a shortcut for 'the person that triggered the program'.
Basically, if the person's alignment is greater than 500, we backstab the poor sucker. This program is simple, but effective.
MPROG 9161 [RANDOM 5]
 say Uee-hee-hee!
There is a 5% chance, every tick that the mob's not fighting, of this mob giggling out loud. (Random progs do not execute during fights)
MPROG 9155 [SPAWN 100]
 mob oload 9165 1 W
This program executes every time the mob loads. It makes the mob load and wield a specific item (in this case, a pitchfork; a short piercing weapon so the mob can use backstab). This could also be accomplished with resets, but you can put random chances on a spawn prog.
==Guardia Soldier==
Conversely, this is about the most complicated single mprog I can think of:
 if level $n < 40
 if rand 33
 say Give it a rest, kid.
 else
 if rand 50
 say Simmer down there, sparky.
 else
 say Whoa, calm down!
 endif
 endif
 mob peace
 mob goto self
 endif
 if counter $i == 1
 remove double
 wield _+grdwep
 mob skill dual tonfa
 mob count zero
 break
 endif
 if carries $i double
 if affected $i haste
 else
 if rand 33
 mob count 1
 remove _+grdwep
 hold double
 zap self
 break
 endif
 endif
 endif
 if hpcnt $i < 25
 and rand 50
 if carries $i potion
 quaff potion
 break
 endif
 if clones > 1
 mob skill fallback 2.guardiasoldier
 else
 if rand 33
 if rand 33
 say I don't wanna die!
 else
 if rand 50
 say Where's my backup!?
 else
 shriek
 endif
 endif
 mob flee
 endif
 endif
 endif
 if wears $i +projectile
 if rand 33
 mob at 9849 remove +projectile
 if rand 50
 emote loads and fires incendiary ammunition!
 mob oload 9807 0 W
 else
 emote loads and fires envenomed ammunition!
 mob oload 9808 0 W
 endif
 mob goto self
 mob kill $n
 mob junk fakecrossbow
 mob at 9849 wield +projectile
 endif
 break
 endif
 if rand 33
 if rand 50
 mob skill bash
 else
 mob skill trip
 endif
 endif
Feel free to try to decipher this! These mobs:
*Have different special attacks depending on which weapon they spawned with.
**Loading a special weapon with an odd damage type, going to a different room to wield it, then doing an extra attack, then (silently) switching back to the first weapon, emulates having a true special attack.
*Emulate a player having to remove a weapon to zap themselves with a haste materia.
*Fallback behind an ally when low on HP, or chug a potion, or flee.
*Say different things randomly when running away or not killing a <l40 player