Here's the write up promised in the previous post, sorry for the double post but this isn't exactly spam
Everything below was debugged by
@Fruit, I did the write up and the calculations but obviously without him that would not have been possible! So thanks to fruit for doing all of this work!
(all so we can find those exceptional rare polearms!
)
All of the below refers to minions and regular monsters ONLY. All sorts of quest drops are hardcoded and so are champion/unique/SU drops. To add insult to injury the aforementioned code is compromised mostly of spaghetti (I'm echoing fruit's thoughts on the matter here
) One can use the stuff in part 4. of the previous post as a very rough outline but there are some more complicated exceptions to that (and of course it should read that champions drop 'magic items or gold' , not just magic items)
***
First off I will present an outline of a monster drop:
- The monster is killed.
- The chance to drop is taken into account. If this step is unsuccessful the algorithm terminates.
- There is a 5% to do a good drop and a 95% to do a regular drop.
- If the good drop was chosen the monster will pick one item from one a 'good' TC.
- If the regular drop chosen the monster will pick one item from one of the four TCs specified in its monstats.txt entry.
- If the difficulty is NM or Hell and the item has an exceptional version there is a chance for it to be upgraded to exceptional.
- The quality of the chosen item is determined.
This excludes one important step. At some point the game will check if the monster is actually capable of dropping the item type that was selected. It does so by comparing monster level with quality level. If this check fails it will attempt to drop an item of the same 'type' instead. So for example if the monster can't drop a Pike the game tries to find another spear type weapon to drop. This is not described here but also isn't a huge problem since most monsters in NM can drop most normal items, all monsters in Hell can drop all normal items and most monsters in Hell can drop most exceptional items. (Might be forthcoming, no idea
)
Also to anyone new to classic: there is no step in which ethereality is decided, there were simply no ethereal items back then.
Here is a loose collection of explanations regarding this process:
The Chance to Drop
When a monsters is killed the game first checks whether they even drop an item. The chance for this is given by:
Code:
% Chance to drop = min{20*Players+Bonus;90}
where Players is the number of all
alive players within the game (no matter where they are or whether they are partied) and Bonus is the value of the column 'SpawnPctBonus' in the 'monstats.txt' belonging to the monster that was just killed.
A few notes are in order:
1) The maximum chance to drop is 90% and no more than five players are ever needed to reach this maximum.
2) The fifth player is worth at most 10% chance to drop whereas the players before him are worth up to 20% each.
Only a few select monsters have SpawnPctBonus specified at all, so the number of exceptions can be counted on one hand:
View attachment 53600
The 'Specter' class of wraiths spawns in the 'Arcane Sanctuary', the 'Ghoul Lord' class of vampires spawns in the 'Tomb of Tal Rasha' levels as well as the 'Arcane Sanctuary' and finally 'Nest' refers to all four nest variants in the game. (Foul Crow, Blood Hawk, Black Vulture and Cloud Stalker)
Treasure Classes
As in later versions of D2 there is a 'TreasureClass.txt' (from now on shortened to 'TC.txt') in which certain drop patterns are specified. For all intents and purposes the rows of this .txt are the TCs and we can use those terms interchangeably.
Some of the many differences to the modern .txt are these:
1) There are no 'Group' and 'Level' columns since there is no TC upgrade process in Classic.
2) A TC may not refer to another TC. This means that each TC is basically a list of items. In particular there are no armo and weap TCs to collect a lot of item types under one neat header.
3) The actual 'TC.txt' does not reference the items by their ingame name but rather by their internal code, e.g. 'hax' instead of 'Hand Axe'. This can be fixed by using the 'vlookup' function in excel to match the item codes to the item names since those are stored together in the 'weapons.txt'/'armor.txt'.
4) There is no weight system yet so if an item is supposed to drop twice as often as the other members of its TC the item has to be listed twice. In particular every entry in a TC is equally likely. This is incredibly clunkly and causes the first seven columns of each chest TC to be just 'gld' which is the item code for gold.
5) The four rows for quality factors from the 'TCex.txt' are not present yet (the quality selection is somewhat easier in this patch)
6) There are no exceptional items listed in the 'TC.txt' at all. Exceptional drops are instead handled in step 6 of the drop process which decides whether a normal item upgrades to exceptional before being dropped.
7) No 'nodrop' column, see the previous section for the chance to drop.
Because of 2) the way that monsters are assigned their TCs is different than later patches as well. They have four columns in the 'monstats.txt' for each difficulty level which specify the TCs they may drop from in that difficulty. If the game decides that the monster does a regular drop (instead of a 'good' one) it will pick one of the four TCs listed here. Each one of them is equally likely however if one of them is 'Null' it will be disregarded and the roll will go over all the ones which are not 'Null'
Some monsters (such as Bone Walls or Maggot babys) only have 'Null' entries here yet they are regularly seen dropping items. This is caused by the good drop.
(A theoretical side note: The game reads the TCs from left to right and stops once it reads a 'Null'. So everything that occurs after a 'Null' is simply disregarded completely, e.g. if it was 'TC1 - Null - TC2 - Null' the game determines that there is one TC, namely TC1 and then drops from that with a chance of 100%)
Good Drops
If the 5% to do a 'good' drop suceeds the game will force a drop from one of five TCs depending on the difficulty/act the monster died in.
View attachment 53601
I rearranged these TCs to resemble those of later patches, so a ten under Armor means that a TC contains ten pieces of armor. Also the 'Weapons' include melee and missile weapons as well as staves but they do NOT contain wands and scepters.
The 7 under the gem categories means that each type of gem (of that quality) occurs exactly once in this TC, this patch does not yet favor 'actual' gems over skulls. In fact none of the gems (except for chipped skulls) occurs in ANY other TC so they are the only way to get gems short of doing Andariel/HF rushes or popping gem shrines without a gem in your inventory.
Do not forget that nodrop factors into the 'good' drop just as with the 'regular' one. So even with 5 players in the game a monster will still only have a 4,5% chance to do their good drop, the remaining percent are split between no drop (10%) and regular drop (85,5%).
Also note that some monsters have the good TCs assigned to their regular TC slots so they may drop from it even if they do a 'regular' drop. The list of such monsters is very short: Cows and Council Members. Naturally they will have the best chances in the game to actually drop gems.
The Exceptional Upgrade
There are no exceptional items listed in any TC, instead the game tries to upgrade the normal items it picked to exceptional. The chances for this to occur are codified in the 'difficultylevels.txt' (where they are wrongly refered to as 'odds') and are 0% in normal, 10% in NM and 20% in Hell.
(Note that this only applies to regular and minion monsters; the chances for an upgrade are different for other drops)
Some of the exceptional upgrades are simply broken, a full list was posted by GalaXyHaXz:
Note that the
original post contains a claim that the chance for an exceptional upgrade is simply 25% regardless of difficulty and monster, this is NOT correct.
The most important takeaway from that list is the inability of Lances to drop. In fact nobody has ever found a Lance in 1.00 at all. (There is no exceptional upgrade in the Vendor and Gambling Screens and special monsters use the same exceptional upgrade procedure as regulars)
Wrong Entries in the TC.txt
There are a couple of entries in the 'TC.txt' which refer to item codes that simply don't exist. It's always the same code 'bqv' which is very similar to the codes 'aqv' for 'arrow quiver' and 'cqv' for 'bolt quiver'. Usually a TC has 'aqv' and 'cqv' both and not just one or the other. Now some of the chest TCs have 'aqv' but either have no bolts or have 'bqv' instead of 'cqv'.
However this does not break the respective TCs, rather it means that if the game chooses 'bqv' it will fail to find any such item and just drop nothing instead.
Quality Selection
Once the item type has been selected the game will determine its quality. The process used utilizes different paramters for normal and exceptional items but can be described for both at once. First the game checks whether the players has any MF on, if yes then it will use the MF to do rolls for Unique, Rare, Set and Magic quality in that order. If the player has no MF equipped or all of the MF dependent rolls failed it will go through a second set of rolls including Unique, Rare, Set, Magic, Superior and Normal quality all of which are NOT dependent on MF.
If a roll is successful the game will try to assign the respective quality to the item if possible but if all rolls failed the item will become 'low quality' by default.
Throwing weapons can't spawn with a quality higher than superior so if they roll magic or higher the game will set them back to superior quality. Some items like potions or gems can't have a quality at all in which case the quality roll is discarded altogether after being performed.
The MF dependent rolls (which are performed first if MF is non-zero) each have the following reciprocal chance:
Code:
max{1;[(X-[mlvl/Y])*100/MF]}
while the MF independent rolls have the reciprocal chance:
where X and Y are constants that depend on both the quality the roll tries to determine as well as whether the item type is normal or exceptional. (also [ ] means rounding down)
Here's a full table:
View attachment 53602
If you know the 'itemratio.txt' then some of those values will be familiar to you, namely the values for X agree with those for the quality entries in that file while most of the values for Y agree with the divisor entries. It might look like the game uses this file to determine the values X and Y but according to fruit a lot of them are actually hardcoded and just happen to agree with the entries in 'itemratio.txt'. The divisors for unique, rare and set quality specified in the 'itemratio.txt' are not used at all.
Notes on the quality selection
The first thing worth exploring is the max{1; } occuring in both reciprocal chances since it opens the possibilities for chances to 'bottom out' at 1, i.e. to have a 100% of getting the quality in question (if applicable to the item type). So we are interested in finding out when X-[mlvl/Y] or [(X-[mlvl/Y])*100/MF] are 1 or less.
***
First we consider the MF independent chances where we get:
Code:
X-[mlvl/Y] ≤ 1
iff
X-1 ≤ [mlvl/Y]
iff (X is an integer)
X-1 ≤ mlvl/Y
iff
(X-1)*Y ≤ mlvl
The stuff after the 'iff' is the reasoning behind it.
Here's a list of the products (X-1)*Y:
View attachment 53603
Since no monster has mlvl bigger than 90 we conclude that there are only three MF independent rolls whose chances bottom out at 100%:
- Every normal item dropped by a monster of level 24 or higher will be at least of normal quality. (This applies to all NM monsters)
- Every exceptional item dropped by a monster of lvl 48 or higher will be at least of superior quality. (This applies to all Hell monsters)
- Every exceptional item dropped by a monster will be at least of normal quality.
This pretty much settles all questions on the superior and normal qualities. It's worth noting that the chance for normal items to pass their superior check reaches its maximum with monster of level at least 80, it's 1 in 7 then, climbing up all the way from 1 in 12 for monsters of level 15 or lower.
Another funny aspect is the MF independent magic quality roll for exceptional item types which has X and Y equal to 3 and 100 respectively, i.e. the reciprocal chance here is 3-[mlvl/100] which is always equal to 3 since there are no monsters of level 100 or above. Hence the chance to pass this roll is always 1 in 3. (no other quality has such a ridiculously high divisor)
***
Now to the more complicated case of the MF dependent chances, here we get:
Code:
[(X-[mlvl/Y])*100/MF] ≤ 1
iff
(X-[mlvl/Y])*100/MF < 2
iff
X-[mlvl/Y] < 2*MF/100
iff
X < (2*MF/100)+[mlvl/Y]
So we're essentially looking for combinations of MF, mlvl and Y s.t. (2*MF/100)+[mlvl/Y] is bigger than X. Now we assume maximal achievable MF and mlvl which are 359% and 90 respectively and calculate this term for all Y which we simply call the test value. This doesn't need a table because there's only three cases altogether:
- For unique, rare and set quality (on normal and exceptional items) the test value is 97,18 and the lowest X is 100, so here you never bottom out at a chance of 100%.
- For magic quality on normal items the test value is 12,18 and X is 30 so no chance of 100% here either.
- For magic quality on exceptional items the test value is 7,18 and X is 3. This is where the fun begins!
***
Our focus is now set on the magic roll for exceptional items which has reciprocal chance max{1;[(3-[mlvl/100])*100/MF]}. Again the term [mlvl/100] is always 0, so the actual reciprocal chance is max{1;[300/MF]} and we see that for MF at least 151 the chance to pass the magical roll is 100% and hence ALL MF independent quality rolls are skipped.
In fact something similar happens at earlier points. The reciprocal chance for magic quality starts at 300 for 1 MF and quickly reduces to 10 for 29 MF. It keeps decreasing at an alarming rate until 151 MF is reached and it becomes 1. Each time it decreases by 1 the chance to fail the magic quality roll (and thus pass to the MF independent rolls) is decreased significantly.
In practice this means that the chance to get a second attempt at a rare/failed unique roll (for your exceptional polearm!) takes a dip everytime you hit one of the MF values where the magical reciprocal chance goes down by 1. At low values of MF this is is usually made up by the increased chance to pass the rare quality check for the MF dependent part. At 151 MF you lose your 'second' chance altogether and this is why the MF folklore of Classic says that 151 MF is a 'bad' MF value to have.
Not all is lost though because there is an MF value over 151 where the chance to get a rare/failed unique roll 'recovers', i.e. is bigger than it was at 150 MF. Since all of these calculations are dependent on mlvl there is no one value of MF where this happens, rather it's different for every monster.
To give just one example: For a monster of level 82 (like an Urdar) the chance to produce a rare or a failed unique (if an exceptional item was picked) is 5,5% at 150 MF and 4,3% at 151 MF. It is less than 5,5% for MF between 151 and 190 and reaches 5,6% at 191 MF. This shows that the gap to 'recovery' is not so big as to make any MF above 150 useless. With the right rares it is absolutely possible to reach 191 MF or more. At 254 MF the chance is already 7,6% which is roughly 38% higher than 5,5%.
----------------------------------------------------------------
This is it for now, maybe there will be something about the mechanics of Find Item but fruit already hinted that it might not be good for anything but gems.