Example MUD Prog – Randomly Restrung NPC’s

Example MUD Prog – Randomly Restrung NPC’s

These progs will show you a simple framework for randomly named NPC’s.  The example will randomly set the gender, name, short and long description for the NPC.  The mob will load a random set of clothing and possibly a piece of loot.

Please note, these MUD Progs were written and tested on a Dawn of Time version 1.69s_beta5 MUD. The scripts do require my snippet to give mobiles access to the SHORT and STRING commands in the MP Commands List.

You need a generic mobile that will morph into a random npc when it loads into the game. I’m using mobile 3006, a Dusk Elf. The program that kicks off the random generation is number 3200 in my example, so I have set the Dusk Elf mobile to call that program with a repop trigger.

MUDPrograms for [ 3006]:
Mudprogs on this mob will not ignore questers
Mudprogs on this mob WILL NOT ignore non questers
Mob mudprog triggers: repop 
 Number Vnum Trigger Phrase   
 ------ ---- ------- --------------------
[    0]  3200   repop 100   

Our first program starts off by calling the next two programs (random clothing and random loot). After that, there’s a 50% chance he will stay male and a 50% chance he’ll change into a female mobile instead. In either case, the mobile will call a mud program to set a random name, short and long description.

Vnum:  3200     Area[3]: zaltyra.are
Title: *** Random Mobile Generator ***  Author(s): Phaedra
Last editor: Phaedra on Wed Feb 20 19:00:43 2019
Code:
mob silently mob call 3203
mob silently mob call 3204
if rand 50
    set char self sex 1
    mob call 3201 self
else
    set char self sex 2
    mob call 3202 self
endif

This script chooses one of 25 random male names and then changes the mobile’s appearance to match. 3202 is written the same way but with the female Dusk Elf names.

Vnum:  3201     Area[3]: zaltyra.are
Title: Male Dusk Elf Names  Author(s): Phaedra
Last editor: Phaedra on Wed Feb 20 19:05:02 2019
Code:
if rand 4
    mob string mob self name Aelam
    mob short self Aelam
    mob string mob self long Aelam, a dusk elf, stands here.
    break
endif
if rand 8
    mob string mob self name Alvad
    mob short self Alvad
    mob string mob self long Alvad, a dusk elf, stands here.
    break
endif .................
if rand 92
    mob string mob self name Ysoldi
    mob short self Ysoldi
    mob string mob self long Ysoldi, a dusk elf, stands here.
	break
endif
if rand 96
    mob string mob self name Zidka
    mob short self Zidka
    mob string mob self long Zidka, a dusk elf, stands here.
	break
endif
mob string mob self name Vaynethysa
mob short self Vaynethysa
mob string mob self long Vaynethysa, a dusk elf, stands here.
break

This next script loads a dagger and a pair of boots onto every Dusk Elf NPC. Then it randomly chooses between four torso armor pieces with 4 matching legs.

Vnum:  3203     Area[3]: zaltyra.are
Title: Random Clothing  Author(s): Phaedra
Last editor: Phaedra on Wed Feb 20 18:52:37 2019
Code:
mob oload 3057 w
mob oload 3055 w
if rand 25
    mob oload 3056 w
    mob oload 3058 w
    break
endif
if rand 50
    mob oload 3060 w
    mob oload 3064 w
    break
endif
if rand 75
    mob oload 3061 w
    mob oload 3065 w
    break
endif
mob oload 3062 w
mob oload 3063 w
break

This last script gives each NPC a chance to carry a single random loot item. This gives thieves something to see when they are peeking at potential pickpocket victims.

Vnum:  3204     Area[3]: zaltyra.are
Title: Random Dusk Elf Loot  Author(s): Phaedra
Last editor: Phaedra on Wed Feb 20 18:58:59 2019
Code:
if rand 10
    mob oload 3051
    break
endif
if rand 20
    mob oload 3053 w
    break
endif
if rand 30
    mob oload 3052
    break
endif
if rand 40
    mob oload 3201
    break
endif
if rand 50
    mob oload 3004
    break
endif
if rand 60
    mob oload 3059 w
    break
endif
if rand 60
    mob oload 3251
    break
endif

Here’s how it looks in the game:

Restrung NPC's

Random Gear