The dropping of set (and unique) items is actually a bit simpler than rares most of the time (it doesn't happen as often, but it's simpler).
All you need for a monster to drop a set or unique is that it can drop the base item (high enough TC) and it succeeds in the quality roll (gg MF) and the monster is high enough level for the appropriate item (eg Pindle can't drop Azurewrath). After that all its mods are preset (maybe variable).
When a rare spawns though, you have to work out which affixes it can get. That involves working out alvl, which depends on ilvl and qlvl and a fiddly little bit of code. In general, higher affixes require higher ilvl to spawn them, which is why you need level 90 amulets to get +2 skills, and why you need wands able to get alvl 60 to get +3 summoning. I think most players are more or less familiar with this idea, if not the details.
Staffmods, on the other hand, are a more complex beast. Staffmods is the name given to +particular skills on items like wands and staves and sceptres, and also necro heads and assassin claws. They are not well explained anywhere on-line that I have seen. They have, however, been carefully examined by the kind of people who brought us most of the other information we have about item creation. Unfortunately (and this will sound like a cop-out) I can't point you to where, because it is on a competing forum and links to such places are prohibited here. But cutting and pasting is not. This is from Hammerman, with additions from Ruvanal, at the Lurker Lounge:
It is a rare example in D2 of something being too high level.
Now, you can actually fake out the alvl chooser - very high qlvl will override a low ilvl and so a high qlvl, low ilvl item can still get the high mods. But the trouble here is that there is no way to get a low ilvl, high qlvl magic wand. They won't drop (in general a dropped item will have ilvl close to or more than qlvl) and the ony cube recipes that can lower a magic item ilvl are the 3-gem recipes, but they lower it at most to 25 which is still too high (so exactly too high it probably isn't a coincidence).
Now there's a lot there, most of it is well known except the staffmod stuff. That has been derived by examining the assembly code of the game, and then confirmed by modded testing.
All you need for a monster to drop a set or unique is that it can drop the base item (high enough TC) and it succeeds in the quality roll (gg MF) and the monster is high enough level for the appropriate item (eg Pindle can't drop Azurewrath). After that all its mods are preset (maybe variable).
When a rare spawns though, you have to work out which affixes it can get. That involves working out alvl, which depends on ilvl and qlvl and a fiddly little bit of code. In general, higher affixes require higher ilvl to spawn them, which is why you need level 90 amulets to get +2 skills, and why you need wands able to get alvl 60 to get +3 summoning. I think most players are more or less familiar with this idea, if not the details.
Staffmods, on the other hand, are a more complex beast. Staffmods is the name given to +particular skills on items like wands and staves and sceptres, and also necro heads and assassin claws. They are not well explained anywhere on-line that I have seen. They have, however, been carefully examined by the kind of people who brought us most of the other information we have about item creation. Unfortunately (and this will sound like a cop-out) I can't point you to where, because it is on a competing forum and links to such places are prohibited here. But cutting and pasting is not. This is from Hammerman, with additions from Ruvanal, at the Lurker Lounge:
What does that mean? Well, if a wand is over ilvl 24, it starts with a skill id of at least 4. The most that can be modified down by is -2, which still leaves it as 2. That corresponds to the 2nd tier of skills for each class, ie the level 6 skills. So an ilvl 25+ item simply can't spawn level 1 skills like RS and SM.First, the game chooses how many skills to add. It will do rnd[100], and add to it the ilvl of the item IF it is being imbued. Then, if higher than 90, 3 skills will be chosen. If higher than 70, 2 skills. If higher tan 30, 1.
After this, it selects the skill id. It will start at a certain value depending on the ilvl:
Above 36: 5
Between 25 and 36: 4
Between 19 and 24: 3
Between 12 and 18: 2
11 or lower: 1
This the becomes a base for all the skill ids. Then, it has a chance to be modified:
20% chance to add 1
50% chance to stay unmodified
20% chance to subtract 1
10% chance to subtract 2
If the item is low quality, then the skill id as of now is capped at 4. Then the final id is chosen from the formula below. skill_adder is the skill id so far, base_id is the starting id for the character class.
id = skill_adder + (base_id + 4 * skill_adder) - 5 + rnd[5]
If this ends as 73 (Poison Dagger), it will do the rnd[5] again. And finally, the total skill bonus is chosen. It will do rnd[100], and add to that ilvl / 2 if from imbue.
If 90 or above, +3
Between 60 and 90: +2
Lower than 60: +1
It is a rare example in D2 of something being too high level.
Now, you can actually fake out the alvl chooser - very high qlvl will override a low ilvl and so a high qlvl, low ilvl item can still get the high mods. But the trouble here is that there is no way to get a low ilvl, high qlvl magic wand. They won't drop (in general a dropped item will have ilvl close to or more than qlvl) and the ony cube recipes that can lower a magic item ilvl are the 3-gem recipes, but they lower it at most to 25 which is still too high (so exactly too high it probably isn't a coincidence).
Now there's a lot there, most of it is well known except the staffmod stuff. That has been derived by examining the assembly code of the game, and then confirmed by modded testing.