The game will start with building a list of avalible items. The chance for an item to get on the list is: 1 / (rarity - act number). Act number is act - 1 (so act 1 has 0, act 2 has 1, etc). If rarity - act number is 0 or lower, the item automatically gets on the list. Also, qlvl must be equal or lower than area level - 1 (wich is the ilvl), else the item is skipped. Weapon racks also require that the result of bitfield1 AND 2 will be non-zero. One could just say that the values 0,1,4,5,7,8, and so on will give zero as result. This is to check if the item is of metal. Then the item to drop is chosen randomly from that list.
After this, quality is chosen. The formula is:
chance = 1 / (base - (ilvl - qlvl) / divisor)
Note that ilvl - qlvl has a min cap of 1.
The values to put in are:
Base
Quality | Normal | Uber | Class Spec | Class spec uber | |
Unique | 500 | 500 | 300 | 300 | |
Rare | 200 | 200 | 150 | 150 | |
Set | 200 | 200 | 150 | 150 | |
Magic | 34 | 34 | 17 | 17 | |
Superior | 12 | 12 | 9 | 9 | |
Normal | 2 | 1 | 2 | 1 |
Divisor
Quality | Normal | Uber | Class Spec | Class spec uber |
Unique | 1 | 2 | 3 | 3 |
Rare | 2 | 2 | 3 | 3 |
Set | 2 | 2 | 3 | 3 |
Magic | 3 | 3 | 6 | 6 |
Superior | 8 | 8 | 8 | 8 |
Normal | 2 | 1 | 2 | 1 |
"Uber" means exceptional or elite. This is also the order that is checked; unique, rare, etc. to normal.
Thanks to Jarulf for pointing out the act number factor in weapon/armor stands, and the bitfield1 limit of weapon racks.