RNG Within Diablo II Controlling Drop Mechanics
in D2 Mechanics
Background
The goal of this post is to detail the order of events with respect to usage of the RNG within Diablo II in order to understand how a seeded game may be used to achieve desired drops or property selection.
The impetus behind starting this research came from this Reddit post about a Lower Kurast seed. A comment from May 29, 2023 discusses how Seed 638589163 can give an easy Ber rune drop.
MrLlamaSc posted a video even before that on August 17, 2022 showing how using Seed 100000147 can get an easy Mal rune drop from an LK chest. Ginger Gaming Mentor posted a video about “infinite Ber rune” drops using the seed from the May 29, 2023 Reddit comment. Ginger also did some tests in that and other videos trying to discover what affected the drops from chests and monsters. Some of the results were interesting, because they seemed to imply that the number of items a player had in their inventory affected the affixes chosen for an item, but didn’t affect the type of item that dropped.
Knowing that much of Diablo II drop mechanics were already known about and discussed in lengthy posts about how magic find works and how item generation works, I assumed someone would have already explained the underlying details behind this. I asked around on the Phrozen Keep Discord, which appears to be where the last vestiges of the community from blizzhackers hang out. Blizzhackers was THE place to go in the 2000s and 2010s to get Diablo II internals information. Their forums were filled with reverse engineering results that enabled the hacks and mods to exist.
However, it seemed that specific technical detail regarding which RNG type and how many seeds and which seeds for drops were never written up or discussed. So that is the real reason for this post.
Changes
2024-05-16: This was updated to include more technical background information on random number generation when it was modified to be a post on this site rather than the PDF as originally released. The algorithm for determining the Game Seed and DRLG Seed were also updated.
2024-04-15: The first release of this document (2024-03-13) was reviewed by Necrolis and Mysterio from The Phrozen Keep Discord. Mysterio rightfully suggested not to refer to RNG as “good” or “bad,” so that was removed from the phrasing in the “Takeaway” section. Necrolis also mentioned that some ItemData Seeds are saved in the character file. I looked into this, and the Unit Seed is effectively saved off, but the ItemData Seed is generated newly on every new game. The consequence of this can be used to know ahead of time the stat values that will be rolled on a runeword in a specific game. More on this will be released in a future version of this document.
Version
The following information was derived from the project D2MOO, which has largely annotated most of the decompiled Diablo II binaries. This project is based on Diablo II version 1.10f, and thus may not be 100% accurate for D2R or the latest version of the original D2 Lord of Destruction, 1.14d. However, according to users more familiar with the differences, the main drop mechanics surrounding the RNG have not changed.
The RNG involved in drop mechanics of online Diablo II games is currently unknown. A fairly reliable source who worked at Blizzard has mentioned that the game’s server code was patched to use Microsoft’s cryptographically secure CryptGenRandom function for some random numbers rather than the source’s built-in MWC RNG, but it is unknown where exactly this change applies. Others have performed lengthy analysis on Lower Kurast chest drops in online games to verify that the RNG does not match the single player game’s. Therefore, this information may only be relevant for single player games and can explain the observations of “infinite ber rune” drops using a given game seed as well as a player’s inventory items affecting an item’s properties but not the item selection itself.
Thanks
I’d like to thank all of those individuals (most of whom are from the Phrozen Keep and blizzhackers) who have done the painstaking work of reverse engineering and annotating the disassembly and decompilation of Diablo II. I don’t have enough information about who they are, so I’m sure I’ll miss many of the early names, but Necrolis, Kingpin, Mysterio, Pavke, Nefarius, Lectem, Jarulf, Beowulf, McGod, and Dark_Mage- were all associated in one way or another at some point.
Past Work
Some great work has been done on understanding the drop mechanics within Diablo II. However, the understanding and write ups on these mechanics focused mainly on the high-level details of predicting drop chances and understanding item and item property selection. Tying those mechanics to the underlying details of dynamic random level generation (DRLG) and the exact implementation of RNG has never been written up. Previous write ups that focus on exact item drop chances, how magic find affects the equations used to determine drop quality, and chest drop specifics can be found at:
- https://diablo2.diablowiki.net/Item_Generation_Tutorial
- https://www.reddit.com/r/diablo2/comments/13u4tqv/how_does_magic_find_actually_work_an_advanced/
- https://www.purediablo.com/forums/threads/guide-regular-special-and-sparkly-chests.380/
This is not to say that this knowledge is new. Plenty of groups throughout the years have understood Diablo II’s internals. When the server code was identical to the reverse engineered code back in the day, it was an even more guarded secret on how the internals of RNG worked so that private groups could exploit it online. The information here may not be that interesting for general players given that exploiting it requires the use of a set seed, which is typically viewed as “cheating” in any competitive environment. If you’re using a seed in single player specifically to get a high rune or a godly item or property, why not just use the D2 LoD Hero Editor1 or the D2R Hero Editor2?
Correction and Contact
If you are more familiar than I am with any of the concepts described in this document and would like to help my understanding of them, or if you notice something that is technically incorrect, feel free to contact me at any of the social media sites listed on this site’s main page. I would be happy to make corrections and credit you.
Caution
Note that this is not an “all-encompassing” or “definitive” guide to RNG usage during drop creation and affix and property selection. There are many specifics and instances of RNG usage that are left out of this description that would be vital to understand if it was desired to exploit a specific seed to get the desired item or property on an item. For example, opening a special chest performs an extra roll on the ObjectControl Seed random sequence to determine magic or rare quality where normal chests don’t. An exhaustive list of all of the random rolls like this would be required in order to utilize a specific Game Seed sequence in order to get a specific item or property selection. This paper presents a high-level understanding of how it all works rather than the nitty gritty details of every specific usage.
Introduction
Random Number Generation (RNG)
Many people have misconceptions about the term “random” when it comes to random numbers. Some get bogged down in the details about whether a number is “truly” random. For games and many other applications, however, it doesn’t actually matter. The goal is usually to make something feel non-deterministic. Game programmers using random numbers typically only care that the value they’re getting is evenly distributed across a range of values. If I want to make the chance of getting a specific item in my game a 10% chance, then my random values need to be uniformly distributed so that I can retrieve a value, divide by 10, get the remainder, check if it’s equal to 9, and return pass or fail. For that to actually be a 10% chance, my sequence of random numbers must be uniformly distributed well enough that over a reasonable sample size the check passes 10% of the time. So “random” in games typically only refers to “uniformly distributed” rather than “true random number generator” vs “pseudo random number generator.”
RNG in Games
You don’t have to take my word for it. Many articles can be found online about this subject. A well-written post on RNG and how it is used in video games can be found at https://medium.com/@naomijoyce/random-number-generation-in-video-games-dda985c5652f
Random number generation in games can vary depending upon each individual game’s need for random values. In all cases for games, however, pseudo random number generators (PRNGs) are used. You can think of a PRNG as a huge group of card dealers. Instead of standard playing cards, however, these dealers’ cards simply have ones and zeros. Their decks are enormous: depending upon the PRNG, the random string of bits can be 18 quintillion bits long or even longer. Which dealer you use determines which long string of bits you get. The dealer is determined by a value called a “seed.” The seed is typically chosen by using a non-deterministic value, like milliseconds since system boot, system timestamp, etc. Once the individual dealer is chosen by the seed, their unique deck of zeros and ones is the random sequence of numbers used by the game to get random numbers. A game can use more than one dealer. It could use hundreds or thousands. In the end, though, the seed value chooses which sequence (or deck) is used.
Multiply with Carry PRNG
The pseudo-random number generator used in Diablo II is a type of “multiply with carry” (MWC) RNG. This isn’t particularly important outside of understanding that each unique seed contains all the state for a unique sequence of random numbers, just like in our dealer/deck analogy. When a random number is “rolled” from a seed, some math occurs to that seed to transition it to the next random number in the sequence. This math has been well-researched and is well-understood. The implementation found in Diablo II follows a method described by George Marsaglia in one of his papers3 and is mathematically sound in how it creates extremely long, uniformly distributed random number sequences. It even uses a constant provided by Marsaglia in a Usenet post4 giving an x86 implementation of the MWC.
RNG in Diablo II
Diablo II has one global Game Seed that defines one main sequence of random numbers and is forceable to a specified value using the -seed command line argument when launching the game. If the seed is not specified, Diablo II mixes values returned from Microsoft Win32’s QueryPerformanceCounter, GetTickCount(), and time() functions to initialize this Game Seed.
Two other random sequences the game uses are the sequence and the ObjectControl Seed sequence. The ObjectControl Seed is set to the second random value in the Game Seed sequence. The DRLG Seed (which is the Map Seed), is set to the first random value from the Game Seed sequence mixed with return values from time() and GetTickCount(). However, if a saved character file has a saved Map Seed already, the game uses the saved value. This allows single player games to continue using the same map while the Game Seed and ObjectControl Seed (which are the sequences used for mobs and drops) continue to change from game to game. Specifying a specific Game Seed with the -seed command line argument will keep both the Game Seed and ObjectControl Seed consistent from game to game.
Units
All types of objects in Diablo II are Units. Monsters, Items, and Objects are all subtypes of Units. Items include weapons, rings, armor, etc. and can exist equipped on the player, on a mercenary, in a player’s inventory, etc. Objects include chests, shrines, armor stands, and other interactables within a map. Each Unit has its own Seed, which we’ll call the Unit Seed as well as additional data specific to the type of object it is. This additional data for Items keeps track of the item quality, item level, item affixes, etc. including another Seed. We’ll call this other seed the ItemData Seed.
Unit Creation
When Units are created in Diablo II, their Unit Seed is assigned as a random number rolled from one of the multiple random sequences throughout the engine. If the Unit is an Item, the Game Seed is rolled to assign the Item’s random seed. The ItemData Seed is also assigned as a random number rolled from the Game Seed. This is true for all Items, including random drops, gambled, vended, and “preexisting” ones like items on a player or in the player’s inventory. They all need to be initialized, and those items all get new seeds on every game. This means that when a Player and their inventory, stash, and mercenary are initialized, all their items are created and two seeds are initialized for each item by rolling the Game Seed twice.
If the Unit is an Object (e.g. a Chest), the game’s ObjectControl Seed is used rather than the Game Seed. What the ObjectControl is is not important for this write up, but what is important is that the ObjectControl’s Seed is initialized to a random value from the Game Seed sequence when the game was created. This occurs prior to initializing the Player and their items, so the ObjectControl Seed will be identical for a given Game Seed regardless of how many items are on a player.
Dynamic Random Level Generation (DRLG)
When Diablo II needs to generate an area, it uses a method of creating areas, rooms, and tiles termed Dynamic Random Level Generation (DRLG). The DRLG system determines an area’s layout using complex algorithms, randomization, rulesets for certain tiles, etc. How all this works is outside the scope of this document, but the act of loading an area uses a seed called the DRLG Seed. The DRLG Seed just so happens to be initialized to the very first random value in the Game Seed sequence every time an act is loaded. The Game Seed is not rolled every time an act is loaded: the first random value rolled from the Game Seed when the game is created is saved off and stored in the DRLG system. That singular random value is used as the DRLG Seed every time an act is loaded, so given a specified Game Seed, every area should always have the same DRLG area layout.
When the DRLG area creation specifies that an object exists at a tile location (e.g. a chest in Lower Kurast), that chest object Unit will be created and initialized as described above, using the ObjectControl Seed to initialize its Unit Seed. Because the ObjectControl Seed is rolled from the Game Seed prior to initializing the player and items, the only variable that affects the chest’s Unit Seed is the point in the ObjectControl Seed’s random sequence at which the chest is initialized. This variable can be controlled by always initializing the same number of objects, which can be easy to do, especially if the chest is spawned near a waypoint, for example. A character loading a game in Act III and then proceeding immediately to the Lower Kurast waypoint will always initialize the same number of objects, and so a chest near that waypoint will always get the same Unit Seed.
Fresh Meat
Drop Item Creation
Operating a chest creates item drops slightly differently than killing a monster due to some unique properties of chests possibly having a chance to be all magic or rare items and other, higher-level differences. However, the underlying item creation uses the same code.
When an item drop needs to occur, the game uses the act, the area level ID, and/or the monster’s level in order to select the appropriate treasure class (see the linked references in the “Past Work” section above for exact details on treasure class and item selection). A random chance is then rolled from the Unit Seed (a monster in the case of a monster being killed or an object in the case of a chest being operated). The random chance is then checked against the treasure class entries (where a special “NoDrop” entry is possible) to select a base item. Once the base item type is selected, all the complex magic find calculations are done. Here, multiple rolls against the Unit Seed can occur when testing for item quality, including rolls to check for Unique, Set, Rare, Magic, Superior, then Normal quality.
After the base item and its quality are chosen, the actual item unit is created, as detailed in the “Unit Creation” section above. The overall steps in an item drop are:
The DRLG specified a chest object at a specific tile. When the player approaches close enough to the tile, the chest object unit is created and assigned a Unit Seed from the ObjectControl random sequence.
The player interacts with the chest, causing drop picks to be performed and an item to be created. The chest’s Unit Seed random sequence is rolled multiple times to determine which item will drop and the item’s quality.
The Item Unit itself is created and assigned a Unit Seed and an ItemData Seed from the Game Seed random sequence.

Remember that the base item and its quality were chosen by rolling random numbers from the Unit Seed of the monster or object that dropped it, but the drop’s Unit Seed and ItemData Seed are chosen from the Game Seed random sequence. So how do the item’s Unit Seed and ItemData Seed affect the item itself?
Item Affix Property Selection
Immediately after the Unit for the item is created, the item’s stats are assigned. The stats come from the affixes that are randomly selected from affix groups. There are a lot of rules and mechanics involved with the affix groups and affixes not being possible or being more or less likely on certain items, but all of that is outside the scope of this document. When selecting affixes and then when selecting the exact value of a mod resulting from that affix, the game uses the ItemData Seed for all of its random rolls. This means that the stats on an item are effectively dependent upon the Game Seed random sequence at the time of item creation, from which was assigned the ItemData Seed.
Takeaway
Effects on Item Drops
The consequence resulting from the item type/quality itself being chosen from the Unit Seed and the item properties being assigned based on selections from the Item Data Seed is that the dropped item type is affected by how many game objects have been loaded (strictly, dependent upon anything that rolls the ObjectControl Seed), whereas the properties on the item are affected by rolls on the Game Seed. This means that the number of items on a player, in their inventory, etc. (remember, each item at initialization is assigned two seeds from the Game Seed random sequence) affect the properties rolled for an item drop but not the item itself.
Figure 1 shows an example of a “Jeweler’s Archon Plate of the Whale” with +91 life being selected from a chest drop with example RNG values from each of the relevant RNG sequences. This example attempts to show all relevant RNG sequences and the order in which they’re used in-game.
Addressing “Bad Seeds”
When watching some streamers grind for specific items (e.g. farming keys for ubers, running Countess for specific runes, etc.) there is talk every now and then about possibly having a “bad seed.” This is usually in reference to a single player game where the map is consistent and a player is not getting the drops they want after a lot of time playing, so it gives the appearance that the RNG may be consistently not in their favor due to a “bad seed.” However, although the DRLG map generation is exactly the same on every new game of the same difficultly, this is achieved by modifying only the DRLG Seed on loading of a player’s save game file. As is evident from Figure 1, nothing derives from the DRLG random sequence with respect to item drops. The Game Seed and ObjectControl Seed are both randomized on every new game if the -seed option is not used.
Using the -seed option is the only way to have a chance of getting consistent drops, and this is mostly dependent on the ObjectControl Seed being rolled the exact same number of times at the point when a monster or chest is created.
Conclusion and Future Work
This write up has described in detail the relevant RNG sequences in play when creating items and drops in Diablo II LoD (and probably D2R) in single player mode. The research shown should help to clarify why certain examples of play sequences while using the -seed command line option can lead to consistent item drops as well as why having different numbers of items on a player when an item is dropped can change the items properties.
Note that these example RNG rolls and selections do not show the exhaustive usage of the RNG sequences. There may be other rolls against those seeds and sequences not shown in the figures. This write up and illustration was meant to provide an overall picture of the different RNG sequences and the drop creation mechanism while explaining some of the observations made by the Diablo II community.
Perfect Runeword Rolls Teaser
An interesting part of Diablo II drops that this research did not cover is item socketing. There are recipes for the Horadric cube that allow a player to socket items, with the number of sockets applied to the item being a random chance. Additionally, the variable stats on runewords use RNG. The rolls for variable stats on runewords use the ItemData Seed of the rune that is insert into the object last. Since the ItemData Seed is recreated for each item on every new game, it would theoretically be possible to test the result a certain Game Seed would give for a runeword or socket roll on a specific item and only perform the roll when a good seed was seen. This test in online games could help understand if the RNG on the server was modified in the way that was claimed.