A Simple Mans Guide to Calculating Item Drop Quality

Post here about all aspects of D2 mod making whether it's information, problems or whatever. Please specify whether your post is relating to Classic D2 or the Expansion.

Moderator: Nizari

Post Reply

0
No votes
 
Total votes: 0

User avatar
Drac0
Retired staff
Angel
Posts: 589
Joined: Tue Sep 24, 2002 2:24 am
Location: Nowra NSW, Australia
Contact:

A Simple Mans Guide to Calculating Item Drop Quality

Post by Drac0 » Mon Oct 03, 2011 6:44 am

A Simple Mans Guide to Calculating Item Drop Quality
Author: Drac0 (30 Sep. 2011)

After looking through the file guides, tutorials & various posts for information on how the quality of an item drop is calculated I realised it can all be very confusing for modders – newbie’s & experienced alike. So I thought I would write a guide on how the game works through what item quality you get once the base item has been selected. How the base item is selected is another matter & beyond the scope of this guide.

Most of this information is pulled from the ItemRatio.txt file guide by Ulmo, including the extra information provided by mishy23. I have just (hopefully) made it a little easier to understand.
The files the game (expansion) uses to determine the quality of an item drop are ItemRatio.txt & TreasureClassEx.txt.

How ItemRatio.txt is used.
In the expansion, the game will use one of the last 4 rows in ItemRatio.txt based on the item selected to drop. If the drop selected is a normal base item it uses the figures from the ‘Ratio - (Monster Level / Ratio Divisor)’ row (row 4), if it’s exceptional or elite it uses the ‘Uber’ row (5). Normal class specifics use the ‘Class Specific’ row (6) while exceptional/elite class specific items use the ‘Class Specific Uber’ row (7). If you take a look you will see that the figures in each of these ‘pairs’ of rows are identical until it comes to selecting a normal drop. The figures in these rows combine with magic find (MF), item qlvl, the dropping monsters level (mlvl) & the item quality columns in TreasureClassEx.txt to determine what quality item should be dropped.

The game firsts tests to see if it should drop a unique & if that fails it cycles through the equation testing each quality in turn until one of the following happens:
1. It has a successful selection.
2. It gets to an item quality in TreasureClassEx.txt with 1024 in it.
3. It fails on a normal item, at which point you get your cracked/damaged/low quality item.

And just getting a successful roll for a set or unique doesn’t mean you will get one due to other factors There may not be a set/unique for that item or the monster is below the level required in UniqueItems.txt or SetItems.txt. In these cases the game will drop an increased durability rare (unique) or magic (set) item in its place.

A Quick Guide to Columns in ItemRatio.txt
Function to Class Specific:
Pretty much self explanatory, used by the game to determine which row to use in its calculations.
Unique/Rare/Set/Magic/HiQuality/Normal:
These columns set the base chance for item quality used in the equation. The higher the number, the rarer that quality of item will be. If you want to change the chances of getting a certain quality of item globally, these are the figures you start with. Lowering the figures will make them more common & raising it will reduce the chance of getting them.
Divisor Columns - Unique/Rare/Set/Magic/HiQuality/Normal:
These columns combine with mlvl & the base items qlvl to help generate a figure for use in the drop calculation (see below for how this works). It is this combination that makes it easier to get a low qlvl unique/set from a monster than a high qlvl one. The greater the gap between mlvl & qlvl, the greater chance of getting a unique/set quality item
Min Columns - Unique/Rare/Set/Magic:
During the calculations, before the equation uses the figures from TreasureClassEx.txt, if the chance drops below this figure it will use this rather than the calculated figure. Remembering that in these calculations a lower figure means a better chance for a drop, this entry prevents excessive magic find or other factors giving too much of a chance for a high quality drop. It means that the max chance of getting a unique item to spawn from any monster with no entry in the unique column for their TC is 2%.
Not used for HiQuality/Normal calculations, these get their own separate calculations for sockets, increased durability, ac, etc.

The Calculations.
So how does it all go together? Well first I’ll explain a few terms I’ll be using then we will see the actual calculations. Note these are just descriptive terms I’ll use in laying out the equation.

Terms Used
base: The base chance from ItemRatio.txt.
qlvl: from the ‘Level’ column in Armor.txt/Weapons.txt/Misc.txt for the selected base item.
mlvl: Monster level from MonStats.txt or the area level from Levels.txt in Nightmare/Hell, + any bonus levels the monster gets for being a champion/unique.
mdiv: divisor column in ItemRatio.txt for each particular quality.
EMF: Effective Magic Find.
For magic items & magic find up to 10% EMF = MF.
For unique, set & rare items the following formula is used:
EMF = MF*[a]/(MF+[a])
Where [a] = 250 for unique, 500 for set & 600 for rare. So the EMF for a unique item with 300% MF would be:
EMF = 300*250/(300+250) = 136
Naturally, MF isn’t applied to items below magic.
mldiv: (mlvl–qlvl)/mdiv.
qmin: minimum quality chance from ItemRatio.txt
tc_q: from the quality columns in TreasureClassEx.txt.
chance: the chance before applying tc_q.
f_ch: the final chance at the end of all calculations.

How it Works
This is the actual equation.
(Note that chance is multiplied by 128 for greater precision)
chance = (base–mldiv)*128*100/(100+EMF)
if chance is less than qmin at this point, use qmin instead of chance for calculating f_ch.
f_ch = chance–(chance*tc_q)/1024
Divide 128 by f_ch & multiply by 100 to find the actual percentage chance of getting that particular quality item for the base item type (128/f_ch*100).

Some Examples
Here are a few of examples; the first is the same as the example used in the ItemRatio.txt file guide.

EXAMPLE 1
The chance of getting a unique ring from Andariels Hell quest drop with 300% MF.
Base Item: ring
qlvl: 1 (from level column in Misc.txt)
mlvl: 78
base: 400 (Unique column in ItemRatio.txt)
mdiv: 1 (UniqueDivisor column in ItemRatio.txt)
EMF: = 300*250/(300+250) = 136
mldiv: = (78-1)/1 = 77
qmin: 6400 (UniqueMin from ItemRatio.txt)
tc_q: 995 (Unique column for Andarielq (H) in TreasureClassEx.txt)

chance: = (400–77)*128*100/(100+136) = 17518
chance is higher than qmin so use chance figure
f_ch: = 17518–(17518*995)/1024 = 496
So if a ring is selected as the base item for an Andy quest drop in hell the chance of it being unique is:
= 128/496*100 = 25.81%

EXAMPLE 2
Let’s do the same again, but see what % chance we have of getting Atma’s Wail embossed plate.
The only change will be to mldiv because the base item has a qlvl of 58. So it changes to: (78–58)/1 = 20
chance: = (400–20)*128*100/(100+136) = 20610
f_ch: = 20610–(20610*995)/1024 = 583
% chance: = 128/583*100 = 21.95%
It can be seen from this that as the level of the item moves closer to the level of the monster, the percentage chance of getting the unique version drops.

EXAMPLE 3
So what about a normal monster who has nothing in the quality columns of TreasureClassEx.txt? It works exactly the same but because there is no modifier in TreasureClassEx.txt, f_ch = chance.
With 300% MF again, this time we’ll use a Greater Hellspawn from Worldstone lvl 2 in NM and check the chance of getting a set with the base item a cuirass. So the needed figures are:
base: = 160
qlvl: = 47
mlvl: = 65
mdiv: = 2
EMF: = 300* 500/(300+500) = 187
mldiv: = (65-47)/2 = 9
qmin: = 5600
tc_q: = 0

chance: = (160–9)*128*100/(100+187) =6734
6734 > 5600 (qmin) so use chance & because tc_q is 0:
f_ch: = chance = 6734
% chance = 128/6734*100 = 1.90%
So less than a 2% chance for a set item even if you’re lucky enough to get the monster to drop anything at all.

Remember, these calculations are made AFTER the base item for the drop has been selected!

That’s it, hope you find it useful/informative. Corrections/comments welcome.

Thanks to Ulmo & mishy23 for the information in ItemRatio.txt file guide.
Attachments
A Simple Mans Guide to Calculating Item Drop Quality.rar
RTF version of this guide.
(11.34 KiB) Downloaded 226 times

Post Reply

Return to “General Mod Making”