Monster drop tables

This describes how monster drop tables are realized, and how dropped items are being chosen.

This is sub-layout for documentation pages

Contents

[hide]
Top

1 Introduction

The drop tables are saved in the database.

These explanations focus on describing how it is done, in description are not algorithmic optimalizations, etc. to avoid confusion.
When implemented, table sorting is done only once and so on...

Following diagram illustrates the database tables realization:

2 Dropping random item from target table

So let's imagine, that monster Skeleton was slain. An item in supposed to be dropped from Sketeton drop table. The drop table is displayed in following image:

This is simplified example, and the table structures in database are more complicated!
It is simplified, because it would be impossible to wrap head around the indexes and foreign keys!!! ×

First, a random number from $\mathopen[0, 1\mathclose]$ is chosen
$r = 0.014$

Then, the drops in the table are sorted by their rarity:

Starting from the lowest item rarity, we begin comparing item rarity with the generated roll $r$:
$r = 0.014 \stackrel{?}{<} 0.008$
$r = 0.014 \stackrel{?}{<} 0.2$
Here, we figure out, that item with rarity $1/5 = 0.2$ shall be chosen.
If there would be no items to match our roll, then no item would be chosen, and nothing is dropped
Then, we take all items in that table with rarity $0.2$, which are leather gloves and orb of torture, and we choose random one, using uniformly distributed probability

From here, for example leather gloves will be chosen as a drop.

If there is sure drop in the table, it is never dropped when using this approach, as it is dropped separatelly ×

3 Dropping random item from target table with subtables

3.1 Subtable definition

Let $A, B$ be drop tables. Table $B$ is subtable of table $A \Leftrightarrow$ $A$ has as an item drop reference to table $B$

So let's imagine, that again, monster Skeleton was slain. An item in supposed to be dropped from Sketeton drop table:

In table, there is also gems drop table as an item.
Using the same approach as above, let's say that gems drop table was chosen as an item to be dropped.
But since it is a drop table, the exactly same approach for chosing item will be applied to the gems drop table.

Finally, an item (or no item) will be returned as a drop

Tables may have many subtables inside, but there should never be a cycle.

4 Sure drops

Sometimes happens, that one or more items have drop probability set to 1.
Such items are being dropped always. After that, the approach explained above is used to choose a drop

5 Sub table as sure drop

If there is sure drop in drop table, but it is sub drop table, then a roll always done from the target drop table, it might, however, give no drop