#### Goryani

##### Diabloii.Net Member

I have a few questions about Item Generation:

1. Does D2 use integer division, real division, or rounding? I know that integer division is used in many places, but I'm not sure if integer division is used exclusively. In the following calculations, which steps, if any, use integer division?

1) Find proper line in itemratio.txt.
2) Chance = (BaseChance - ((ilvl-qlvl)/Divisor)) * 128
3) if (we check for unique, set or rare quality) EffectiveMF=MF*Factor/(MF+Factor)
else EffectiveMF=MF
4) Chance= Chance* 100/(100+ EffectiveMF).
5) if (Chance 6) FinalChance=Chance-(Chance*QualityFactor/1024)
7) If (RND[ FinalChance ]<128) return Success
else return Fail
2. What is a good way to deal with the probabilities of a wasted 7th drop from act bosses? Here is what I have so far:
• If the NoDropRate = 0, then you just treat the mob as a pick 6 mob instead of a pick 7 mob: Chance of at least 1 item X = 1-(1-"Chance of 1 item X per pick")^6
• However, if NoDropRate > 0, the mob will attempt to drop 7 items (NoDropRate)^7 percent of the time (it's in decimal form, not % form). During these cases, we should also treat the calculations as a pick6 mob instead of a pick7 mob. Am I off my rocker or wouldn't the expected value formula apply here? For NoDropRate^7 percent of the time we use the pick6 formula and for 1-(NoDropRate^7) percent of the time we use the pick7 formula. In other words, for NoDropRate > 0: Chance of at least 1 item X = (1-(NoDropRate^7))*(1-(1-"Chance of 1 item X per pick")^7) + (NoDropRate^7)*(1-(1-"Chance of 1 item X per pick")^6).

#### Warrior of Light

##### Diabloii.Net Member
All divisions are integer. It is going in the main registers of CPU for better speed. This is why when you kill Baal even on slow PC you donâ€™t see any delay, caused by the complicated drop calculations for all items that he drops.

In the other games all random items may be generated during loading screen, so there may have place more precocious calculations. Good example is TES4:Oblivion.

Where you got an act boss with NoDrop=0? Anyway, each time the game does a pick for a TC with 7 picks, chance for no drop = NoDrop / (NoDrop + Prob1 + ... + Prob10). You call it NoDropRate, if I understand you right.
So NoDropRate is a chance for no dropping an item at each pick.
(1 - NoDropRate) is a chance to drop an item at each pick.
(1 - NoDropRate)^6 is a chance to drop 6 items at first 6 picks.
1 - (1 - NoDropRate)^6 is a chance for no dropping an item at least once at the first 6 picks, or the chance to have pick #7.

It means that the final formula should be like this:
(1 - (1 - NoDropRate)^6) * (1-(1-"Chance of 1 item X per pick")^7) + ((1 - NoDropRate)^6) * (1-(1-"Chance of 1 item X per pick")^6)

By the way, if NoDrop=0, then NoDropRate=0 and this formula degrade to:
1-(1-"Chance of 1 item X per pick")^6

Well, at least this is what I think at the first look, I hope there no a terrible error here. #### Goryani

##### Diabloii.Net Member
Warrior of Light said:
All divisions are integer.
That isn't possible unless nearly every example from the Item Generation thread or from drop calculators like ATMA are incorrect. For instance, calculating a new drop rate based on the number of players in the game isn't possible using entirely integer division. For real numbers between 0 and 1 (basically, ALL probabilities), integer division will yield only a 0 or 1. As a result, if the new drop rate only uses integer division, then the game will either treat the new no drop rate as 0% or 100% and nothing in between. A cursory glance at real drops will tell you this isn't possible.

Now, it may be possible for all the calculations I quoted do indeed use integer division, but somehow I don't think so, or at least, hope so. It would mean that MF isn't a smooth curve but a stair step function, just like IAS, FCR, FHR, etc. For a given mob and base item, different MF values will round to the exact same chance to drop a rare or set item. The two most troublesome scenarios are with high MF and for class specific items (Unique or Set Divisor > 1). Imagine how trade values would shift when people realize that 45% War Travs are identical to 50% War Travs when you have "enough" MF gear.

Warrior of Light said:
Where you got an act boss with NoDrop=0? Assuming I understand the calculations correctly, any act boss killed at /players 6 or higher or with 3+ partied members within 2 screens.

Warrior of Light said:
Anyway, each time the game does a pick for a TC with 7 picks, chance for no drop = NoDrop / (NoDrop + Prob1 + ... + Prob10). You call it NoDropRate, if I understand you right.
So NoDropRate is a chance for no dropping an item at each pick.
(1 - NoDropRate) is a chance to drop an item at each pick.
(1 - NoDropRate)^6 is a chance to drop 6 items at first 6 picks.
1 - (1 - NoDropRate)^6 is a chance for no dropping an item at least once at the first 6 picks, or the chance to have pick #7.

It means that the final formula should be like this:
(1 - (1 - NoDropRate)^6) * (1-(1-"Chance of 1 item X per pick")^7) + ((1 - NoDropRate)^6) * (1-(1-"Chance of 1 item X per pick")^6)

By the way, if NoDrop=0, then NoDropRate=0 and this formula degrade to:
1-(1-"Chance of 1 item X per pick")^6

Well, at least this is what I think at the first look, I hope there no a terrible error here. I see where we differ. My calculations are concerned only with situations in which a pick7 mob tries to drop 7 items. When 7 drops are attempted, one of the drops will have to be culled, stochastically speaking. Probability doesn't care about order so having 6 drops then a no drop is the same as having a no drop and then 6 drops, etc. Only when the magic 7th drop occurs will the odds change.

I believe that your calculations start caring after 6 drops, not 7. In that case, whether or not the 7th pick is a drop or a no drop will alter the probability of situations that start with 6 drops. If the 7th pick is a drop, then the pick6 odds must be used. However, if the 7th pick is a no drop, then the pick7 odds can still be used. Needless to say, this is more complicated.

#### Warrior of Light

##### Diabloii.Net Member
The game donâ€™t calculate drop probabilities. Read my guide again. It uses RND [X] function, that returns an integer number from 0 to X-1, including both.
In algorithm, that you quote, it calculates RND[FinalChance] than compares it with 128. No fractional numbers needed.

Calculating NoDrop, based on players is exception. The game uses fractional numbers there. Otherwise it would be impossible to calculate it, as you see. Trust me, I didnâ€™t do it myself, but others looked directly into code and I just based my guide on their posts.

You will be surprised, but people do know that WT49 and WT50 are equal in game. However new players think that each MF percent counts and old players have enough forum gold to buy anything. Perfect items have style points, you know. It is psychologically important to have a perfect item. Selling Dusk 15% ed and 10% durability you will never attract as many people as when selling 15/15 Dusk. #### Goryani

##### Diabloii.Net Member
My mob value calculator is continuing, but I'm running into a couple of issues.

First of all, I can't duplicate the drop rates that ATMA shows for set items. I can calculate the TC and base item type correctly, and can calculate the chance for a drop to roll as unique, but the correct answer for sets eludes me. Here is an example of my calculations, in case anyone can find my error:

Hell Baal, monster level = 99, ilvl = 99, Set QFactor = 983
MF = 400
Hwanin's Justice, Qlvl = 28, (not used except to verify Baal can drop it)
itemtype = Bill, Qlvl 37, droprate = .00162664918001 (from ATMA and my own calculations)
Divisor = 2, Base Chance = 160, MinChance = 5600, MFFactor = 500

Following the algorithm:
2) Chance = (160-floor((99-37)/2))*128) = 16512
3) EffectiveMF = floor(400*500/(400+500)) = 222
4) Chance = floor(16512*100/(100+222))= 5127
5) is 5127 < 5600? Yes, set chance = 5600
6) FinalChance = 5600 - floor(5600*983/1024) = 225
7) Probability = 128/225 = .56888888888889

Chance per drop = .00162664918001 * .56888888888889 = .00092538264463

However, ATMA shows a result of .00075246442782

Using algebra, it seems that ATMA's quality probability is: .00075246442782 / .00162664918001 = .46258556366492

Thus, ATMA's FinalChance number is: 128/.46258556366492 = 276.70556553018500

Working backwords again, we can see that the result of ATMA's step 4 and 5 will be around 6875.

My calculations for Effective MF for set items agrees with ATMA, at 222. Thus, at the end of step 2, ATMA must show around 22140

However, I don't see any possible scenario in the game where this is possible. If ilvl = qlvl, then step 2 reduces down to 160*128 = 20480. Therefore, 20480 is the absolute max value that step 2 can produce. Thus, 22140 is not possible.

I'm stuck. I don't see where my error is. Working backwords from ATMA numbers gives a value that shouldn't be possible in game.

#### Delreich

##### Diabloii.Net Member
You missed the bit where it rolls for unique first, set second, I think.
So, for it to be a set item, there first has to be a failed unique roll,
followed by a successful set roll.

Ie.
Chance per drop = typeProb * (1 - uniqueProb) * setProb

Judging by your numbers, uniqueProb should be something like 0.19.

#### Demonic Angel Rules

##### Diabloii.Net Member
Wow I guess my teacher was right. I really do need to learn algebra to get by in this world.

#### Mt Dew

##### Banned
:undecided: ...you lost me at item generator.

and that was the best line I've ever heard Demonic, lol. I always thought, "wow, wtf will algebra actually do for me later in life..." and here I am today.

#### Goryani

##### Diabloii.Net Member
Delreich said:
You missed the bit where it rolls for unique first, set second, I think.
So, for it to be a set item, there first has to be a failed unique roll,
followed by a successful set roll.

Ie.
Chance per drop = typeProb * (1 - uniqueProb) * setProb

Judging by your numbers, uniqueProb should be something like 0.19.

Thanks Delreich. That was my problem.

Now on to the other issues...

1. Do rings, amulets, charms and jewels use the same unique/set values found in itemratio.txt?

2. For the quality step 2 calculations, are the following Qlvls used?
ring = 1
amulet = 1
jewel = 1
grand charm = 1

Yes, qlvl=1

#### Goryani

##### Diabloii.Net Member
I see the light at the end of the tunnel... and also a new problem. :cry:

Here is the situation:

L85 area
cr_archer3 (Dark Archer)
single player game

I'm trying to calculate the chance of any BaseItem. I have the correct values for champion and unique mobs, but not for regular mobs.

Looking up in monstats.txt, I can see that cr_archer3 drops from Act 1 (H) Miss B. However, since neither the boss nor the noRatio field is TRUE, then we look for area level upgrades. In a L85 area, a regular mob will be L85. Looking in TreasureclassEX.txt we see that the level for Act 1 (H) Miss B is only level 66. Is 85 > 66? Yes, so we upgrade to Act 1 (H) Miss C. We continue upgrading until we get to the last entry in that group: Act 5 (H) Miss C.

The Act 5 (H) Miss C entry has the following stats:
nodrop = 100
totaldrops = 160
Act 5 (H) Equip C = 13
Act 5 (H) Good = 2
Act 5 (H) Bow B = 6

The Act 5 (H) Equip C entry has the following stats:
weap87 = 15
Act 5 (H) Equip B = 1530
totaldrops = 1565

Act 5 (H) Equip B entry has the following stats:
weap87 = 2
totaldrops = 1566

Act 5 (H) Bow B entry has the following stats:
bow87 = 10
Act 5 (H) Bow A = 2080
totaldrops = 2113

Act 5 (H) Bow A entry has the following stats:
bow87 = 3
totaldrops = 2113

The Weapon87 entry looks like this:
scissors suwayyah = 2
berserker axe = 3
glorious axe = 3
unearthed wand = 1
thunder maul = 3
mythical sword = 3
legend spike = 3
winged harpoon = 3
war pike = 3
giant thresher = 3
archon staff = 1
hydra bow = 3
dimensional shard = 1
total drops = 36

The bow87 entry looks like this:
Hydra Bow = 3
total drops = 3

Thus, we have everything needed to calculate the chance of any weapon87 base item dropping from a Dark Archer in the pits in a single player game.

The non-bows are easy, since there is only 1 path to reach them. The basic formula is:
(p Equip_path)(p weapon87viaEquipC + p weapon87viaEquipB)(p BaseItem)

The calculations for a berserker axe are as follows:
(13/160)*[(15/1565) + (2/1566)*(1530/1565)]*(3/36) = .00007335007283
I get the same result as ATMA, so far so good.

My problem lies in calculating the chance of bows. There are two separate paths for a Hydra Bow to drop from a L85 Pit Dark Archer. One path is identical to the above calculations via the Equip route. The other path traverses the Bow path.

The Equip path looks like this:
(13/160)*[(15/1565) + (2/1566)*(1530/1565)]*(3/36) = .00007335007283

The basic formula for the bow path looks like this:
(p Bow_path)(p bow87viaBowB + p bow87viaBowA)(p BaseItem) =
(6/160)*[(10/2113)+(3/2113)*(2080/2113)]*(3/3) = .00022988311377

The final chance for a Hydra Bow to drop is merely adding the chance for both paths together (logical OR) which I calculate as: .00030323318660
Unfortunately for me, ATMA says it should be: .00008306344384

If I assume that my Equip path is correct (it is for all non-bows) then according to ATMA, the Bow path should only add .00000971337101 to the chance of a Hydra Bow dropping. I'm off by a factor of 23!

#### Delreich

##### Diabloii.Net Member
Goryani said:
The Weapon87 entry looks like this:
scissors suwayyah = 2
berserker axe = 3
glorious axe = 3
unearthed wand = 1
thunder maul = 3
mythical sword = 3
legend spike = 3
winged harpoon = 3
war pike = 3
giant thresher = 3
archon staff = 1
hydra bow = 3
dimensional shard = 1
total drops = 36

The bow87 entry looks like this:
Hydra Bow = 3
total drops = 3
These are supposed to be the 'rarity' field, right? If that's the case, then that could be where your problem lies.

This is what I'm getting, from weapons.txt
Code:
``````[b]name			type	rarity	level[/b]
Unearthed Wand		wand	1	86
Scissors Suwayyah	h2h2	2	85
Berserker Axe		axe	4	85
Glorious Axe		axe	4	85
Thunder Maul		hamm	3	85
Mythical Sword		swor	4	85
Legend Spike		knif	3	85
Winged Harpoon		jave	4	85
War Pike		spea	4	85
Giant Thresher		pole	3	85
Archon Staff		staf	2	85
Hydra Bow		bow	2	85
Dimensional Shard	orb	5	85``````
 Unless it's the rarity from itemtypes.txt that's used... then you'd be correct after all. :undecided:

#### Sumendar

##### Diabloii.Net Member
The rarity in weapons.txt is only used for racks, not for monster drops.

#### Goryani

##### Diabloii.Net Member
Another quick question:

What weapon types count as melee? Is it everything except for bows, Xbows, javelins, throwing knives, throwing axes, throwing potions, amazon bows and amazon javelins?

#### Delreich

##### Diabloii.Net Member
Goryani said:
[...]javelins, throwing knives, throwing axes and amazon javelins [...]
Fairly sure those counts as melee, at least as far as TCs goes. They're all included under Combo weapons as both melee and thrown weapons. They're also melee through their respective base type (spear, knife, axe). Twice as melee as most thing, in other words. :wink3:

Melee, as far as I can tell from itemtypes.txt, should include
Axe, Sword, Knife, Spear, Polearm, Combo (listed above), Hand to hand (ie claws), Blunt (club, hammer, mace, wand, staff, scepter)

#### Goryani

##### Diabloii.Net Member
Hmm, either way, I'm not getting the same numbers that ATMA does. I can calculate the armor TCs from the Cow King correctly, but not the weapon drops. It's like how I can't get the ATMA numbers for bow drops from archer mobs but I calculate non-bow weapons and armor just fine.

Can anyone show the equations that AMTA uses for Melee and Missile type TCs?

#### Hrus

##### Diabloii.Net Member
Goryani said:
Another quick question:

What weapon types count as melee? Is it everything except for bows, Xbows, javelins, throwing knives, throwing axes, throwing potions, amazon bows and amazon javelins?
I think that Atma stashes have the same tree structure as game item types, so melee weapons should exclude missile weapons, throwing weapons and orbs.

For exact Atma algorithm, try to send a PM to Hakai_no_Tenshi, he logs in from time to time.