The ilvl of items bought from npc's is clvl+5, with caps in normal difficulty:
Act 1: 12
Act 2: 20
Act 3: 28
Act 4: 36
Act 5: 45
The game will build a list of items wich have at least 1 in the
If ilvl is less than 25, there's a 1 / (MagicMax + 1) chance that the item will skip the "less-than-magic" quality selection, where the chance to be upgraded from normal to superior is: if ilvl >= 10, 25%, else 15% (also, if the ilvl is less than 5, there's a 10% chance that it'll be low quality). The game will select the quality for a number of MagMax items this way. After that, the game continues to where it would have been if it had skipped this section.
Now the game will attempt to create the item with magic quality. There are two restrictions to this: 1) bitfield1 must be an odd number, 2)
After the quality has been chosen, it'll do the difficulty and excep/elite upgrading. The game will skip all upgrading if clvl is 25 or lower (iirc, in the beta this check wasn't done, and you could buy normal/socketed elite items with low level characters in Hell). If in nm, the chance for upgrade to exceptional is:
chance for excep = (ilvl * 64 + 4000) / 100,000
It will upgrade to item in NightmareUpgrade column if it fails to upgrade to exceptional.
In hell:
chance for elite = (ilvl * 16 + 1000) / 100,000
chance for excep = (ilvl * 128 + 5000) / 100,000
It will only upgrade to excep/elite item if HellUpgrade column is blank or "xxx".
Sockets follow the normal distribution. As for misc item, any item with 1 in