Random Treasure Generation Documentation

Written by Dwip, 6/17/03
Modified by Samson, 11/25/04
-----------------------------

Overview:

This document is an overview of the random treasure generation system used
in AFKMud. For those of you familiar with Diablo II or Dungeons and Dragons,
this system owes much to those two sources. In essence, when a mob set to use
randtreasure dies, the code rolls on a series of tables, which generates
something, be it nothing, gold, an item, or a rune.

To use the randtreasure system on a mob, simply set their gold amount to -1.

Note that randtreasure uses the value of OBJ_VNUM_TREASURE (currently vnum
11044 in void.are) extensively. You can change this by altering the value for
it in olc.h and recompiling.

The generation is all in the function generate_treasure in treasure.c, and
works like this:

On a d100 roll:

1-20 = Nothing. Corpse is empty.
21-74 = Gold, to the tune of (moblevel d x) + (moblevel d x/10) + (player luck d x/3) + % extragold[1].
The value of x is determined in generate_treasure.
75-85 = Item (see items section)
86-93 = Gem (see gem section)
94-100 = Rune (see rune section)

[1] - extragold is an item affect. See Values.txt.

The above formulas can be fine tuned on a per-area basis as seen fit.
Refer to the Header.txt document file, TREASURE section for details.
The values used in this document are the global defaults.
-------------------------------

Items:

There are a whole variety of items that can be generated by randtreasure.
The relevant function is generate_item in treasure.c.
Another table is in order:

Items: 1d100 roll

1-20 = Scroll
21-50 = Potion
51-60 = Wand
61-75 = Armor
76-100 = Weapon

The above formulas can be fine tuned on a per-area basis as seen fit.
Refer to the Header.txt document file, TREASURE section for details.
The values used in this document are the global defaults.

Scrolls: 1d10 roll

1 = Cure Light
2 = Recall
3 = Cure Serious
4 = Identify
5 = Bless
6 = Armor
7 = Cure Poison
8 = Cure Blindness
9 = Aqua Breath
10 = Refresh

Potions: 1d10 roll

1 = Cure Light
2 = Bless
3 = Armor
4 = Cure Blindness
5 = Cure Poison
6 = Cure Serious
7 = Aqua Breath
8 = Detect Evil
9 = Protection From Evil
10 = Refresh

Wands: 1d(moblevel/10) roll

1 = Magic Missile
2 = Acid Blast
3 = Magnetic Thrust
4 = Lightning Bolt
5 = Fireball
6 = Cone of Cold
7 = Scorching Surge
8 = Quantum Spike
9 = Meteor Swarm
10 = Spiral Blast

Armor:

For full documentation on random armor generation, see itemgen.txt.

Randomly generated armor can have sockets. See runes.txt for what sockets do.

Sockets: 1d8 if moblevel < 60, 1d12 if moblevel > 60

1-4 = 1 socket
5-8 = 2 sockets
9-12 = 3 sockets

Armor type: 1d12 roll
1 = Padded
2 = Leather
3 = Hide
4 = Studded Leather
5 = Chainmail
6 = Splintmail
7 = Ringmail
8 = Scalemail
9 = Banded Mail
10 = Platemail
11 = Field Plate
12 = Full Plate

Armor material: 1d12 roll

Also based on mob level. Will reroll if moblevel is too low for the material.

1 = Iron (level 1)
2 = Steel (level 1)
3 = Bronze (level 1)
4 = Dwarven Steel (level 10)
5 = Silver (level 10)
6 = Gold (level 15)
7 = Elven Steel (level 10)
8 = Mithril (level 20)
9 = Titanium (level 25)
10 = Adamantine (level 30)
11 = Blackmite (level 40)
12 = Stone (level 5)
13 = Generic, used for organic items (level 0)

Weapons:

For full documentation on random weapon generation, see itemgen.txt.

Randomly generated weapons can have sockets. See runes.txt for what sockets do.

Sockets:

If an armor or weapon gets sockets, it is determined as such:

Mob level < 20: 1 socket
Mob lebel between 20 and 59: 1 or 2 sockets
Mob level from 60 up: 1, 2, or 3 sockets

Weapon Type: 1d12 roll
1 = Dagger
2 = Claw
3 = Shortsword
4 = Longsword
5 = Claymore
6 = Mace
7 = Maul
8 = Staff
9 = Axe
10 = War Axe
11 = Spear
12 = Pike

Weapon Material: 1d12 roll

Also based on mob level. Will reroll if moblevel is too low for the material.

1 = Iron (level 1)
2 = Steel (level 1)
3 = Bronze (level 1)
4 = Dwarven Steel (level 10)
5 = Silver (level 10)
6 = Gold (level 15)
7 = Elven Steel (level 10)
8 = Mithril (level 20)
9 = Titanium (level 25)
10 = Adamantine (level 30)
11 = Blackmite (level 40)
12 = Stone (level 5)
13 = Generic, used for organic items (level 0)

Weapon Quality:

If moblevel 1-20 = 1
If moblevel 21-59 = 2
If moblevel 60-99 = 3
If moblevel 100 = 4

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

Gems:

This section describes the generate_gem function in treasure.c.

Gem names come from the various gems# consts at the beginning of treasure.c.

Gems: 1d100 roll

1-25 = Cost 10, Name from gems1.
26-50 = Cost 50, Name from gems2.
51-70 = Cost 100, Name from gems3.
71-90 = Cost 500, Name from gems4.
91-99 = Cost 1000, Name from gems5.
100 = Cost 5000, Name from gems6.

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

Runes:

This section describes the generate_rune function in treasure.c.

What runes are actually used for is a topic best left for runes.txt.

Runes: 1d100 roll

This roll is capped by moblevel:
  if moblevel < 20, cap = 80
  if moblevel < 40, cap = 98
  if moblevel >= 40, cap = 100

1-88 = Common
89-98 = Rare
99-100 = Ultrarare

From there, the generator goes on to randomly generate a rune of the correct
rarity from the list of runes. Said list can be viewed with the OLC command 
showrune.
