Skip to content

Treasure class resolution: from a drop source to item-creation calls

When a monster dies (or a chest opens), the game picks a treasure class (TC), walks it with draws on the source unit’s seed, and calls item creation once per item it lands on, passing the base item, a quality, a unique/set index and upgrade flags. This spec covers the TC choice for a monster, the level upgrade, the pick loop (positive and negative Picks), NoDrop and its player-count scaling, the recursion into sub-TCs with ratio inheritance, and the hand-off. The quality roll that runs inside the walk is specified by items/quality; here it is a call with a known seed contract. Primitives (Step, Range) are those of rng; TC indices and the load of the TC array are in data/excel § G.

When Function Tag
A monster dies (death event → death drop, noNoDrop = 0) MonDeathEvent → MonDeathDrop → MONSTER_DropItems [C]
A corpse skill re-drops a monster (noNoDrop = 1) CorpseFindItem → MonDropNoNoDrop → MONSTER_DropItems [C]
Monster TC → level upgrade → resolver TC_DropByIndex → TC_ResolveDrops [C]
A chest or other object drops (named only; the callers are objects § J) ObjectChestDrop → TC_ResolveDrops [C]
  • [C] The two monster chains. All 973 entries of MonDeathDrop logged in the H2a run return after its one call site in MonDeathEvent, which is reached through a table in .rdata; the 858 death drops that pass its guard are the 858 MONSTER_DropItems entries with noNoDrop = 0. Find Item on corpses (g_SkillDoFuncs entry 72) made 12 MonDropNoNoDrop calls, each entering MONSTER_DropItems with noNoDrop = 1.
Anchor Used for
TreasureClassEx.txt:Picks, group, level, Magic, Rare, Set, Unique, NoDrop, Item1..10, Prob1..10 the runtime TC array, read through its load-time copy (section A)
MonStats.txt:TreasureClass1 … TreasureClass4(H) (+0x86 + 8·diff + 2·k) the monster’s base TC per difficulty and kind (section B)
MonStats.txt:TCQuestId, MonStats.txt:TCQuestCP the quest TC switch (section B)
MonStats.txt:noRatio (+0x0C bit 2), MonStats.txt:boss (+0x0C bit 6) block the level upgrade (section C)
SuperUniques.txt:TC (TC, TC(N), TC(H): record +0x2C + 2·diff, u16 TC index) a superunique’s TC (section B)
ItemTypes.txt:TreasureClass, ItemTypes.txt:Rarity auto item-type TCs and their entry weights (section I)
ItemTypes.txt:Throwable the classic-game re-pick (section H)
Weapons.txt:version, level, quest, spawnable, type, type2 (same offsets in Armor and Misc) expansion-only flag, auto-TC filter, classic rejection
ItemRatio.txt:Version only inside the quality roll (items/quality)
MonItemPercent.txt:TreasureClassPercent, HeartPercent, BodyPartPercent, ComponentPercent none: loaded, read by no code (Reimplementation notes)

Offsets are byte offsets into the owner; struct names are ours.

State Type Source
game.difficulty u8, 0 Normal, 1 Nightmare, 2 Hell Game+0x6D
game.expansion u32, non-zero in an expansion game Game+0x70
game.type u8 (3 in every single-player call logged, 2 in every TCP/IP host call logged:) Game+0x6A
game.seed Seed, seeds every created item unit Game+0xD0 (rng/seeds step 7a)
player lists, party list the game’s player units, parties Game+0x1120, Game+0x1D2C
g_PlayersOverride u32, set by the /players N command g_PlayersOverride
src the source unit: the dying monster, or the object argument
src.seed Seed at Unit+0x20, every TC draw steps it rng/seeds step 7a
src.type, src.classId u32 (1 monster, 2 object, 0 player, 4 item), class at unit+0x04
monster type flags u16 at monsterData+0x16 (unit+0x14 → +0x16): 0x02 superunique, 0x04 champion, 0x08 unique, 0x10 minion MonTypeFlag
superunique id monsterData+0x26 MonSuperUniqueId
unit stats stat 12 level, 14 gold, 79 item_goldbonus, 100 monster_playercount (itemstatcost ids)
killer the unit credited with the kill (player, or a monster that may have an owner) argument
TC array g_pTreasureClasses, g_nTreasureClasses entries of 0x2C bytes g_pTreasureClasses, g_nTreasureClasses
Name Value Tag
MAX_FRAMES 64 (overflow is fatal error 0xFEA) [I]
MAX_DROP 6 when the caller passes no output array and max < 1 (every monster drop) [C]
MAX_PARTY 8 (cmp edi, 8 / mov edi, 8) [I]
UPGRADE_MASK 0x3FF [I]
THROW_RETRIES 10 per resolver call (classic only) [C]
LONG_SWORD item code lsd (Weapons row 31) [C]
GOLD_TYPE itemtypes record 4 (gold) [C]
x87 control word at the NoDrop evaluation 0x027F (53-bit significand, round to nearest even) in every logged evaluation, single player and TCP/IP host [C]
  • [C] MAX_DROP stops a call. Every one of the 9 265 monster calls of the S2a log set passes max = 0 and no array; the stop at 6 reproduces the 111 calls that made 6 items, and in 4 of them picks were left, which a model without the stop gets wrong.

  • [C] The stop holds against Picks 7. The 30 stock rows with Picks 7, the table’s largest, are the five act bosses’ (plain and quest, three difficulties; Duriel’s are the - Base rows under a Picks 5 row). The 4 logged calls the stop decided are all Duriel’s: Durielq (N), Durielq twice and Duriel. The history and the intent of the limit are not decidable from this image. (TC_ResolveDrops, TreasureClassEx.txt:Picks, row 22)

  • [I] The other four bosses’ rows meet the same stop, which reads no row: no logged call of theirs is among the 4.

  • [C] THROW_RETRIES and LONG_SWORD (forced run: a loose treasureclassex.bin whose Act 1 Junk names three classic throwables). Over 100 classic resolver calls with a throwable pick the counter runs 0, 1, 2… from 0 in each call; all 937 refunds are at counter 0–9 and all 141 Long Swords at 10 or 11, and in each of the 93 calls that reached the bound exactly 10 refunds come before the first lsd. ItemByCode("lsd") returned index 31 each time, and the next creation was of that index.

  • [C] GOLD_TYPE: passes 4 to ITEMS_UnitIsType, which gave 1 for the 207 gld units of the H2a run and 0 for the 506 others.

All draws in sections D–H are on src.seed unless a step says otherwise. Draw numbers restart for each resolver call.

A. The runtime TC (what the resolver reads)

Section titled “A. The runtime TC (what the resolver reads)”

The resolver reads the TC array built at load, not the .bin record. Layout of one TC (0x2C bytes): [C] (TC_LoadTreasureClassEx, TC_ParseItemCell, TC_ResolveDrops: writer and reader agree)

off type field value
+0x00 i16 group group + 5 (the number of auto item types) if group ≠ 0, else 0
+0x02 u16 level level
+0x04 i32 nEntries
+0x08 i32 totalClassic sum of Prob over entries not flagged expansion-only
+0x0C i32 totalExp sum of all Prob
+0x10 i32 picks Picks
+0x14 i32 noDrop NoDrop
+0x1A u16[6] ratio Magic, Rare, Set, Unique, then the two words of .bin +0x30/+0x32 (0 in every stock record)
+0x28 ptr entries 0x1C bytes each

Entry (0x1C bytes): cumClassic i32 and cumExp i32 (the running sums before this entry was added), index u16 (item index, or TC index; for a unique or set entry the item index of the row’s base code), aux u16 (for a unique or set entry the uniqueitems or setitems row itself, with no offset; or the mul= value), flags u8 (0x01 unique, 0x02 set, 0x04 sub-TC, 0x10 expansion-only), mod u16[6] from cm=, cr=, cs=, cu=, ce=, cg=. What index and aux hold for a unique or set entry is [I] (A note). [C] for the layout: the loader’s writers (TC_AddEntry, TC_SetEntryProb, TC_ParseItemCell) and the resolver’s reads agree offset by offset with the same 0x1C stride, and the replay exercises cumClassic, cumExp, index and flags on every pick; what the mod words do is H3 and H5.

A1. picks: i32 ← Picks; if picks = 0: picks ← 1 [I]
A2. an entry is expansion-only (flag 0x10), its Prob added to totalExp only, when it is
an item whose version (+0xF6) ≥ 100, or a sub-TC whose own [C]
totalClassic is 0,
or any unique or set reference [I]; no classic call reaches one
A3. cells with Prob < 1 are dropped at load, so every entry has Prob ≥ 1 [I]

Step notes:

  • A2. The two clauses decide the classic totals. Over the 801 classic calls of the S2a log set, a model without the version clause gets 158 calls wrong and one without the sub-TC clause 28. The unique/set clause has no classic case: the only such stock entries (Annihilus in ROP (N) and ROP (H)) are reached by no classic call of the log set. [C]
  • A1, A3. No loaded stock row has Picks 0 (852 rows) and no stock item cell has Prob below 1 (3 404 cells), so neither load rule has a stock case; both rest on the code reading. [I]
  • A. The only modifier in the shipped treasureclassex is mul= (81 of 3 404 item cells, all gld,mul=…). No cm=…cg= cell exists and the +0x30/+0x32 words are 0 in all 852 rows, so the ratio raises of H3 and the upgrade draws of H5 never run with stock data; the replays agree (no upgrade draw, up = 0 in all 7 115 creation calls of the S2a log set). [C]
  • A. A unique or set entry’s two words (flags 0x11 or 0x12, from a cell that names a uniqueitems or setitems row, data/excel G4). index is the items record of the row’s base code (+0x28 of the row), 0 when that code is no item code; aux is the row index the name lookup returned, not minus one, so H4’s uidx = aux + 1 is the row plus one. A unique row is accepted from 1, a set row from 0. A mul=, ma= or mg= after the name overwrites aux. [I] (only an edited TreasureClassEx reaches a named cell, and the run that edits one agrees without raising).
  • A. ma= and mg= write the same aux word as mul=; the resolver reads aux only for the gold multiply and the unique/set index, so on a non-gold item they do nothing here. [I]

B. Monster drop: which TC — MONSTER_DropItems

Section titled “B. Monster drop: which TC — MONSTER_DropItems”
B1. MonsterDrop(game, mon: Unit, noNoDrop: bool, killer: Unit):
d: u8 ← game.difficulty [C]
row ← MonStats[mon.classId] [C]
ilvl: i32 ← mon.stat[12 level] [C]
if ilvl < 1: ilvl ← 1 [I]; no logged monster needed it
B2. if mon has type flag 0x02 (superunique): [C]
su ← superuniques[mon.superuniqueId]
tc: u16 ← su ≠ none ? su[+0x2C + 2·d] : row.TreasureClass3[d] ; missing record → unique column [I]
B3. else if mon has type flag 0x04 (champion): tc ← row.TreasureClass2[d] [C]
B4. else if mon has type flag 0x08 (unique): tc ← row.TreasureClass3[d] [C]
B5. else: tc ← row.TreasureClass1[d] [C]
; minions (flag 0x10 alone) land here
B6. if row.TCQuestId ≠ 0 and row.TreasureClass4[d] ≠ 0 and killer resolves to a player p
and bits 15, 1 and TCQuestCP of p's word TCQuestId are clear: [C]
tc ← row.TreasureClass4[d] ; items/quest-drops § B
B7. DropByIndex(game, mon, killer, tc, forcedQ: 0, ilvl, noNoDrop, out: none, max: 0) [C]

Step notes:

  • B1. The row, the level and the hand-off. The base-TC check derives the TC of all 9 265 monster calls of the S2a log set (63, 125 and 23 classes in Normal, Nightmare and Hell, classic and expansion) from MonStats[classId]; in the 5 777 calls with the upgrade gate open, the ilvl passed on equals the level that TC_DropByIndex reads itself with stat 12, a second code path; and every monster call passes forced quality 0, noNoDrop 0 and max 0 (an array with max 0 would be the fatal 0xF44). [C]

  • B1. The death drop is skipped entirely when the monster unit has +0xC4 bit 17 set, or when the collision test at its position (mask 0x801) fails. Of 973 MonDeathDrop entries, 113 stopped at the bit-17 test (exactly those with the bit, fallen1 and fallen4), 2 at the collision test, and no MONSTER_DropItems call followed a skipped one. [C] Monster class 344 (bonewall) is a fatal error there; no class 344 died in the run. [I]

  • B1. [I] +0xC4 bit 17 is “no death drop”. It has two readers: this guard and a saved-unit copy that stores bits 26 and 17 and restores them, so the bit survives that save.

    • a class with MonStats Align 1 (113 classes: town NPCs, critters, hirelings, player summons) when it is created through MonSpawnTry (1 site);
    • the bone prisons (classes 340–343) and the compelling orb (366) in MonPostCreateBoss (2);
    • a monster SpawnOwnedMonster makes for another unit (1), and MonSetNoDeathDrop’s argument (1);
    • an inactive monster restored with its saved bit (1);
    • the Travincal compelling orb: the object init that spawns it (object InitFn 60) and its death in the council quest’s death callback (2);
    • a monster that ends itself through its AI, setting the bit before it enters death mode (12 sites in ten MonAI rows): FoulCrowNest, Sarcophagus and MosquitoNest once their spawn count reaches (FoulCrowNest) or passes (the other two) the AI parameter of the difficulty, GenericSpawner (evilhut), the Trap-Missile, Trap-Poison and Trap-Nova traps, 7TIllusion (seventombs), DarkWanderer and TrappedSoul;
    • a monster made by a spawner: srvdofunc 91 (Nest, EvilHutSpawner), 135 (MinionSpawner), 140 (Baal Tentacle), the EvilHole AI and Baal’s clone (5);
    • a monster brought back to life: srvdofunc 97 (Resurrect), 58 (Revive) and SkillReviveDo, the raise that the item property reanimate queues on a kill (STATEVENT_Reanimate, items/quality § M3) (3);
    • a hireling, at MERC_Init and at its resurrection (2).

    P1b’s split of the unread writers into “three quest drops” and “12 skill-code sites” was wrong: the three are the compelling orb’s two sites and the MosquitoNest AI, and the skill-code sites are the AI self-removals, with the spawner and revive skills as separate writers.

  • B2–B5. The test order is superunique, champion, unique, else. Live monsters carry more than one flag (low byte of the flag word: 0x0b on both superuniques killed, 0x09 on uniques, 0x0d on champions), so the order matters. The column for the normal, minion, unique and superunique kinds is confirmed in Normal and Nightmare: derives the base TC of every monster call from monstats.bin / superuniques.txt and matches all 317 monster calls (280 normal, 28 minion, 7 unique, 2 superunique: Bishibosh → Act 1 Super A in Normal, Rakanishu → Act 1 (N) Super B in Nightmare). [C]

  • B3–B4. Champion before unique. When the monster is not a superunique, the code tests flag 0x04 first and takes TreasureClass2; only if that fails does it test 0x08 for TreasureClass3. The flag test is (flags & mask) ≠ 0, and live champions carry 0x0d (0x04 together with the unique flag 0x08, and 0x01), so a unique test placed first would give a champion the unique column. Both champion kills of the run (class 61 fallenshaman4, Nightmare, mflags = 0d) took TreasureClass2(N) (698 Act 1 (N) Champ C), not TreasureClass3(N) (783 Act 1 (N) Unique C), while a unique of the same class (mflags = 09) took 783; asserts the base TC of all 121 monster calls of that run (98 normal, 17 minion, 2 champion, 4 unique). Scope: Nightmare, expansion, single player, class 61. [C]

  • B3. Champions in every difficulty and in classic. Champions take TreasureClass2 in Normal (30 calls), Nightmare (104, and 12 in classic games) and Hell (11), over 35 monster classes. [C]

  • B2–B3. Superunique first is code-read only: no logged monster carries both 0x02 and 0x04 (champions log 0x0d, 0x2d or 0x4d, superuniques 0x0b). [I]

  • B3. Flag bit 0x01 takes no part in the column choice. Uniques with 0x08 alone (11 calls, the act bosses) and with 0x09 (212) both take TreasureClass3, and champions take TreasureClass2 with 0x01 set. What the bit means is not read. [C]

  • B2–B6. Hell (d = 2) uses the (H) columns by the same 8·d stride: 875 Hell monster calls (410 normal, 400 minion, 11 champion, 20 unique, 34 superunique) pass the base-TC check. [C] (MonStats.txt:TreasureClass1(H))

  • B6. The quest TC replaces whichever TC B2–B5 chose; it is not tied to the unique flag. A killer that is not a player is first resolved to its owning player: a hireling (the Rogue Scout) and a pet (the player’s Hydra) each killed Andariel, were resolved to the player, and the TC so far (TreasureClass1, 830) was replaced with TreasureClass4 (833). [C] The caster of an exp state also stands for the killer, and with no owner there is no switch. [I]

  • B6. The test is confirmed for single player with a player killer: QUESTRECORD_GetState is called on the killer’s own record for bits 15, 1 and TCQuestCP of word TCQuestId, in that order, stopping at the first set bit, and TreasureClass4 is taken when none is set. In 8 boss kills (Andariel and Duriel taken and not taken, Mephisto taken) the TC passed on is the model’s (b6_model) and the drop’s base. The drop runs before the boss’s quest script sets its bits, so a first kill always gets the quest TC. The quest-TC classes, the meaning of each bit per boss, the killer resolution and the party case are in items/quest-drops § B. [C]

  • B6. The pet and hireling resolution ran (above); the TC walk itself still gets the unresolved killer (the drop’s TCR names the hireling or the Hydra). [C] The exp-state resolution and a party (only the resolved player’s record is read) were not run. [I]

C. Level upgrade — TC_DropByIndex and TC_GetByIndex

Section titled “C. Level upgrade — TC_DropByIndex and TC_GetByIndex”
C1. DropByIndex(game, src, killer, tcIndex: u16, forcedQ, ilvl, noNoDrop, out, max):
lvl: i32 ← 0
if game.expansion ≠ 0 and game.difficulty > 0 and src.type = 1 [C]
and not MonStats[src.classId].noRatio [I]; no stock noRatio monster has a TC
and not MonStats[src.classId].boss: [C]
lvl ← src.stat[12 level] ; mlvl
t ← GetByIndex(tcIndex, lvl)
if t ≠ none: Resolve(game, src, killer, t, forcedQ, ilvl, noNoDrop, out, max)
C2. GetByIndex(idx: u16, lvl: i32) → TC or none: [C]
if idx = 0: return none
if idx ≥ g_nTreasureClasses: return none [I]; no stock TC column holds such an index
t ← TC[idx]
if lvl > 0 and t.group ≠ 0 and TC[idx+1].group = t.group:
loop:
if lvl < TC[idx+1].level: return TC[idx] ; next is too high: keep
idx ← idx + 1
if TC[idx+1].group ≠ TC[idx].group: return TC[idx] ; end of the group run
return t

Step notes:

  • C1. The upgrade level is 0 for every Normal monster drop (53 calls) and the monster’s level in Nightmare (167 calls; normal, minion, unique and superunique sources), and the forward walk reproduces in every call: 12 one-step upgrades at mlvl 40 (Act 1 (N) Miss A → Miss B, H2H A → H2H B, Unique A → Unique B), 9 calls held at H2H B because the next TC’s level is 41. [C]

  • C1–C2. The champion group walks the same way. 121 more Nightmare monster calls reproduce the upgrade level and the walk; both champions start at Act 1 (N) Champ C (698, group 18, level 41) and at mlvl 44 walk two steps through Act 2 (N) Champ A (699, level 42) to Act 2 (N) Champ B (700, level 44), stopping before Act 2 (N) Champ C (701, level 45). One boss monster (Andariel, class 156) logged upgrade level 0 in Nightmare. asserts the upgrade level of all 438 monster calls of the two runs. [C]

  • C2. The base TC is always eligible, whatever its own level. The walk only moves forward, so a base TC whose level is above mlvl is kept, never replaced by a lower TC of its group (146 Nightmare calls, Rakanishu’s Act 1 (N) Super B at level 41 for mlvl 40 included). [C]

  • C1–C2. The gate and the walk over the S2a log set. The gate is open (lvl = the monster’s level) in all 5 777 expansion calls above Normal from monsters with neither boss nor noRatio, 106 of them superuniques, and closed (lvl 0) in 2 708 expansion Normal calls, in 775 classic calls (316 of them in Nightmare) and in 5 boss calls (Andariel in Nightmare and Hell, Duriel and class 250 in Nightmare). The forward walk reproduces in all 5 777 (3 239 moved 1 to 5 steps, 2 538 kept, 972 with a base TC above mlvl), and index 0 returns none in all 752 DROP lines with base 0. Only the top TC of a monster drop is upgraded; sub-TCs are fetched with lvl = 0 (G1), and an object never reaches the gate (Entry points). [C]

  • C1. The noRatio gate has no stock case: every stock noRatio monster is a player summon with no TC. [I]

  • C2. The walk reads TC[idx+1] without a bound check. With stock data every group run is followed by a loaded TC: the 18 group runs all end before the last loaded TC (Pandemonium Key C, index 1012, group 0), by a full-table check. [C]

State: a stack of frames {tc, picksLeft: i32, ratio: u16[6]}, cur: i32 the top frame, throwRetries: i32, count: i32 items created. expansion ← game.expansion ≠ 0, and total(t) = expansion ? t.totalExp : t.totalClassic.

D1. Resolve(game, src, killer, t0, forcedQ, ilvl, noNoDrop, out, max): [C] (TC_ResolveDrops, D1–D5 unless tagged)
if out = none and max < 1: max ← 6
if out ≠ none and max = 0: fatal error 0xF44 [I]; no stock caller passes it
count ← 0; throwRetries ← 0; cur ← 0
frame[0] ← { t0, max(1, |t0.picks|), t0.ratio[0..5] }
D2. loop:
if frame[cur].tc ≠ none and total(frame[cur].tc) ≠ 0:
while frame[cur].picksLeft ≠ 0:
f ← frame[cur]; t ← f.tc ; picks and noDrop re-read each pass
T: i32 ← total(t); if T = 0: break [I]; not shown reached by the logs
D3. if t.picks < 0: [C]
roll: i32 ← |t.picks| − f.picksLeft ; 0, 1, 2, … — NO draw
if roll ≥ T: break [C]; abandons this frame
D4. else:
nd: i32 ← t.noDrop
if nd ≠ 0: nd ← ScaleNoDrop(game, src, killer, nd, T) ; section F, every pick
range: i32 ← noNoDrop ? T : T + nd
roll ← Range(src.seed, range) [C] draw#k, one per positive pick
if not noNoDrop:
if roll < nd: f.picksLeft ← f.picksLeft − 1; continue [C] (signed compare) ; NoDrop
roll ← roll − nd
D5. f.picksLeft ← f.picksLeft − 1 [C]
i ← SelectEntry(t, roll) ; section E
if i ≥ t.nEntries: continue [I]; pick consumed, nothing made; classic only, no stock case (E2)
e ← t.entries[i]
if e.flags & 0x04: PushSubTC(e.index); continue ; section G, changes cur
if e.index = 0xFFFF: continue [I]; no loaded entry has it
ItemPick(e) ; section H; may end the call
if cur = 0: return count [C]
cur ← cur − 1 ; resume the parent frame

Step notes:

  • D3. Negative Picks: no draw. Pick k (0-based, k < |Picks|) takes the entry whose cumulative range contains k, so entry i fires Prob_i times in entry order. Reproduced for Picks = −3 (Act 1 Unique A/B) and Picks = −4 (Act 1 Super A, Act 1 (N) Super B). [C]

  • D3. The early stop when k ≥ total acts. With stock data only the three Countess TCs can reach it (Picks −2, classic total 1), in a classic game. On the classic Normal Countess kill of the H2a run the second pick had roll = 1, total = 1 and the call ended with no entry scan and no draw; the other 62 negative picks of the run (roll < total) each went on to the scan. [C] Picks = 0 (stored as 1, A1) has no stock case. [I]

  • D4. The draw is an inlined copy of Range: range < 1 returns 0 without stepping; otherwise one Step and low mod range (a mask for a power of two, same value). range = 1 therefore still steps the seed and returns 0 (seen on every pick of Act 1 Cpot A, total 1, in the worked example). [C]

  • D4. With noNoDrop (the corpse-skill path) nd is still computed but neither widens the range nor rejects a roll: in all 12 noNoDrop calls of the H2a run nd was above 0, the first pick’s range was the TC total, and no pick was rejected as NoDrop. [C]

  • D5. A pick that ends on a sub-TC is consumed (28 617 pushes over the S2a log set). [C] A pick that ends on index = 0xFFFF, on a classic scan that runs off the end, or on an item rejected in H2 is consumed too; none has a stock case (no loaded entry has 0xFFFF, and E2 and H2 have none). [I]

  • D2. In a classic game total(t) is totalClassic. A classic Normal session reproduces with the draw range over totalClassic in all 485 resolver calls; with totalExp (and the cumExp search of E1) 41 calls break. [C]

  • D2. When a frame runs out of picks the loop pops to its parent, which continues with its own remaining picks: 1 899 pops over the S2a log set, each resuming its parent; a model that ends the call there instead gets 630 calls wrong. [C] (TC_ResolveDrops)

  • D1–D5. The whole resolver reproduces in all 9 390 calls of the S2a log set (Normal 3 231, Nightmare 5 283, Hell 876; 801 classic), 9 184 of them with the quality roll modelled and no oracle: 39 048 positive and 1 374 negative picks, each pick decrementing picksLeft, and each call returning count when frame 0 runs out. The lines left inferred above are those no call reached. [C]

E1. SelectEntry(t, roll) — expansion game:
the entry i whose half-open range [cumExp_i, cumExp_i + Prob_i) [C]
contains roll
E2. SelectEntry(t, roll) — classic game:
for i in 0 ..< t.nEntries:
if entries[i].flags & 0x10: continue [I]; expansion-only entries skipped
if i = t.nEntries − 1 or roll < entries[i+1].cumClassic: return i [C]
return t.nEntries [I]; ran off the end: nothing drops

Step notes:

  • E1. The game finds it by binary search over cumExp: the entry whose cumExp = roll if any, else max(lo − 1, 0) with lo the first entry whose cumExp > roll. Because every Prob ≥ 1 (A3) this is the containment rule of E1. Every SEL index of the 328 replayed calls matches it. [C]

  • E2. The classic scan, observed part: the scan picks the entry whose classic range holds the roll, also when expansion-only entries follow it. asserts the SEL index and every draw of all 485 calls of a classic Normal session: 664 selections, 53 in TCs with expansion-only entries, 14 of them on the last classic entry just before such entries. [C] Over the 801 classic calls of the S2a log set (485 Normal, 316 Nightmare) the same holds, with 254 selections in TCs that have expansion-only entries after the chosen one. [C]

  • E2. The skip and the run off the end have no stock case. An expansion-only entry adds nothing to the classic sum, so a scan without the skip passes it too and selects the same entry; the last classic entry’s successor holds totalClassic > roll, so the scan stops there and never runs off the end in a table this loader builds. Checked over every roll of every stock TC with an expansion-only entry (95 383 selections: none differs, none runs off the end), and both readings reproduce the 801 classic calls, so no run can tell them apart. The two lines stay on the code reading. [I]

F1. ScaleNoDrop(game, src, killer, nd: i32, T: i32) → i32: [C] (TC_ResolveDrops, F1–F4 unless tagged)
party: i32 ← 1
if killer ≠ none:
p ← killer.type = 0 ? killer : MonsterOwner(killer)
if p ≠ none and p.type = 0:
k: i32 ← PartyCountInLevel(game, p) ; F3
if k ≥ 2: party ← min(k, 8) ; the clamp at 8: [I] (F1 note)
F2. n: i32 ← party + (PlayerCount(game) − party) ÷ 2 ; C signed division, toward zero
if src.type = 1:
cap: i32 ← max(1, src.stat[100 monster_playercount])
if n ≥ cap: n ← cap [I]; never acted: n ≤ cap in every logged call
if n ≤ 1: return nd ; unscaled
F4. ; x87, every operation rounded to the precision control (53-bit significand, round to nearest even)
r ← nd / (nd + T) ; nd + T is an i32 sum, converted exactly
p ← r; repeat n − 1 times: p ← p × r ; exactly n − 1 multiplications
q ← 1 − p
if q = 0: return 0
v ← ((1 − q) × T) / q ; (1 − q) is computed, p is not reused
return trunc(v) ; toward zero

Step notes:

  • F2–F4. Confirmed for a party of 1 and of 2: with party = 1 and 1 or 8 counted players (/players 8), n is 1 or 4; with party = 2 and 2 players (two clients, TCP/IP), n is 2. NoDrop' equals the F4 evaluation at 53-bit precision in every logged evaluation, for (NoDrop, T) = (100, 60) → 10 and (125, 38) → 20 at n = 4, and (100, 60) and (100, 47) at n = 2 (68 evaluations). The control word was 0x027F in every evaluation, single player and TCP/IP host. [C]

  • F1. Still code-read: more than two players and the clamp at 8 (a third client exceeds). [I]

  • F3. Party count: same level, no distance test. PartyCountInLevel counts the player and the members of its party (party list game+0x1D2C) whose room is in the same level: the level id of a room is read through room +0x10 (the DRLG room) → +0x58 (its level) → +0x1D0 (the level id), and the ids must be equal. Community guides written for 1.10/1.11 say partied players count fully only “within two screens”; 1.14d counts them anywhere in the killer’s level. In the two-client run a partied player in the killer’s level gave party = 2 in all 44 such calls at 26–375 subtiles (37 of them beyond two screens), an unpartied player in the same level (4 calls) and a partied player in another level (84 calls) gave party = 1; checks every logged party count against this rule. Scope: two players, both alive, player killer. [C]

  • F3. A dead member is not counted. With the partied joiner dead (mode 17) in the Black Marsh, where the host killed, the host’s kills gave party = 1 in all 106 drops of that case; across the run’s 686 resolver calls, 253 gave party = 1 with the joiner dead or in another level, every one predicted. Scope: two players. [C]

  • F3. A member without a room is skipped; a player with no room or no party counts itself only. [I]

  • F2. PlayerCount counts the units in the game’s 128 player hash lists (game+0x1120, next pointer unit+0xE4) that are neither in state 7 (playerbody) nor dead (modes 0/17 for players, 0/12 for monsters, or unit+0xC6 bit 0). If game.type ∈ {1, 2, 3} and g_PlayersOverride is larger, the override is used. /players N stores N only when N ≤ 8 as an unsigned compare. The client’s chat parser takes the command only in client modes 0, 1, 6 and 8, with atol clamped to 1..8. [I]

  • F2. So the override is a maximum, not an addition: a lone player with /players 8 gets n = 1 + (8 − 1) ÷ 2 = 4, the value logged in every /players 8 call, and two live players with /players 1 count 2. [C]

  • F2. The monster_playercount cap applies only to a monster source; an object source is not capped: the 4 chest calls of an H2a session under /players 8 have no cap line and scale at n = 4, while the monster calls of the same log carry 142. [C]

  • F1–F4. Every NoDrop pick reproduces over the S2a log set: 9 589 party counts, the player counts, 9 089 cap lines and 2 909 x87 evaluations at n 2 and 4. The cap itself never acted (monster_playercount ≥ n in every cap line). [C]

G1. PushSubTC(idx: u16): [C]
s ← GetByIndex(idx, 0) ; sub-TCs never upgrade
parent ← cur
if frame[cur].picksLeft > 0: cur ← cur + 1 ; else reuse this frame (tail call)
if cur ≥ 64: fatal error 0xFEA [I]; no stock case: the deepest logged stack is 2 frames
frame[cur].tc ← s; frame[cur].picksLeft ← max(1, |s.picks|)
G2. for k in 0 ..< 6: [C]
a: u16 ← frame[parent].ratio[k]; b: u16 ← s.ratio[k]
frame[cur].ratio[k] ← (a = 0 or b > a) ? b : a ; = max(a, b), unsigned 16-bit

Step notes:

  • G2. Ratios combine by maximum, field by field. Act 1 Super A (1024,972,800,800) over Act 1 Uitem A (1024,800,800,800) reaches the quality roll as 1024,972,800,800 in all 12 oracle entries under it, and a zero-ratio parent takes the child’s values. [C]
  • G1. Push over the S2a log set: 28 617 pushes (1 907 on a new frame, 26 710 tail calls), each frame starting with max(1, |picks|) picks. [C]
  • G2. Each field is read before it is written, so the tail-call case (parent = cur) gives the same maximum: 9 075 tail-call pushes with a non-zero parent ratio reproduce it. [C] The child sees the parent’s ratios as they are at the moment of the push, including any classic cm=…cg= raises (H3), which only edited cells make. [I]
  • G1. The tail call does not change the order of draws; it only saves a frame. A model that puts every sub-TC on a new frame reproduces the same 9 390 calls. [C]
H1. ItemPick(e): [C] (H1–H9 unless tagged)
f ← frame[cur]
H2. if not expansion:
rec ← Items[e.index]
if rec = none or rec.version ≥ 100: return [I]; pick consumed; no stock case (A2)
H3. for k in 0 ..< 6: f.ratio[k] ← max(f.ratio[k], e.mod[k]) [I]; cm/cr/cs/cu/ce/cg, classic only; persists in f; edited cells only
H4. if e.flags & 0x01: quality ← 7; uidx ← e.aux + 1 [I]; unique entry, no draw; this line and the next: edited cells only (H4 note)
else if e.flags & 0x02: quality ← 5; uidx ← e.aux + 1 ; set entry, no draw
else:
uidx ← 0
quality ← forcedQ ≠ 0 ? forcedQ
: DropRollQuality(game, src, killer, f.ratio, ilvl, e.index) ; 0–6 draws on src.seed (items/quality)
H5. up: u32 ← 0
if f.ratio[4] ≠ 0: [I]; this draw and the next: never with stock data
Step(src.seed) ; draw#k (inlined, unguarded)
if (src.seed.low & 0x3FF) < f.ratio[4]: up ← 0x04
if f.ratio[5] ≠ 0:
Step(src.seed) ; draw#k+1
if (src.seed.low & 0x3FF) < f.ratio[5]: up ← up | 0x10
H6. item ← e.index
if not expansion and Throwable(item): [C]
; Throwable(item) = ItemTypes[Items[item].type].Throwable:
; `type`, not `type2`, is the code reading [I] (H6 note)
if throwRetries < 10: throwRetries ← throwRetries + 1; f.picksLeft ← f.picksLeft + 1; return ; refund
throwRetries ← throwRetries + 1
item ← ItemByCode("lsd") ; Long Sword
H7. unit ← DropCreateItem(game, item, src, quality, uidx, up) ; does not touch src.seed
if unit = none: return
H8. if UnitIsType(unit, 4 gold) and e.aux ≠ 0: ; the type test of § K: [I] (ITEMS_UnitIsType, H8–H9 note)
unit.stat[14 gold] ← (i32)(unit.stat[14] × e.aux) >> 8 ; mul=; arithmetic shift, signedness [I] (H8–H9 note)
if out ≠ none: out[count] ← unit
count ← count + 1
if count ≥ max: end the whole Resolve call ; no gold find for this item
H9. if Items[unit].type = 4:
unit.stat[14] ← unit.stat[14] × (100 + GF(killer) + GF(owner of killer)) ÷ 100 ; GF = stat 79

Step notes:

  • H4. The quality roll is a boundary for this spec. It is called with the source unit, the killer, the frame’s ratio words, the resolver’s ilvl and the item index. In the replay its entry seed, item, ilvl and six ratio words were asserted on every call and its exit seed and return value taken from the log (oracle). [C] for this entry contract

  • H4. It returns a quality code starting at 1. The run saw the codes 1, 2, 3, 4 and 6 (QOUT lines: 1 ×8, 2 ×231, 3 ×4, 4 ×25, 6 ×4); worked example 1 shows code 1. [C] The full range of codes and their meaning are in items/quality § Outputs.

  • H4. A unique entry (flags & 0x01) can only come from a cell that names a unique item (resolved at load by name, data/excel G4), and a set entry likewise; both are expansion-only (A2). No stock cell reached by a logged drop names one, so only edited cells reach them. [I]

  • H5. The upgrade draws are unguarded inlined steps; the test uses the low word after the step. They run only when the frame’s ratio words 4/5 are non-zero, which needs a ce=/cg= modifier (classic only, H3) or a non-zero .bin +0x30 word: never with stock data. [I]

  • H5. [I] 0x04 is forced ethereal and 0x10 forced sockets, not upgrades. The ethereal roll makes the item ethereal when record +0x80 has 0x04; the socket roll makes its Range(100) draw and, with 0x10, replaces it by 0 so that sockets are always added. Since ce= and cg= exist only in a classic game, where the ethereal roll does not run (item version < 100), ce= has no effect at all.

  • H6. The throwable test runs after the quality roll, so a refunded pick has already stepped src.seed. The first 10 throwables in one resolver call refund their pick; later ones become a Long Sword (THROW_RETRIES, LONG_SWORD). In the forced run each of the 1 078 throwable picks follows its own quality roll with no pick between, every one of those rolls had stepped the seed, and the replay holds the seed chain of all 377 calls. Classic only: the stock expansion control (the logs) has 13 expansion creations of throwable types, each made with neither refund nor Long Sword. [C]

  • H6. The test reads the item’s type and not type2, and the upgrade draws of H5 sit between the roll and the test. Neither is separated by a run: no Weapons, Armor or Misc row has a throwable type2 without a throwable type, and the ratio words 4 and 5 were 0 in every pick of the forced run. Both rest on the code reading. [I]

  • H6. The throwable refund, observed part: in a classic Normal session 16 picks of throwable types were refunded, at most 3 in one call: tpot potions (11), javelins, a throwing axe and a throwing knife. Each came after its quality roll, created no item, and the pick was taken again. Without the refund 13 of the 485 calls break. [C]

  • H6. The Long Sword after the tenth throwable is exercised in the forced run: 141 picks past the tenth became lsd (index 31) and were created as such. [C]

  • H2. The version ≥ 100 reject has no stock case: A2 flags every such item entry expansion-only and the classic scan never selects a flagged entry (0 rejects in 801 classic calls). [I]

  • H7. Item creation leaves the source seed alone: src.seed is equal before and after every creation call of the 328 replayed calls. [C]

  • H7. Creation builds a 0x84-byte record: source unit, game, the item’s level (taken again from the source: monster or player level stat, else the area’s MonLvl[Ex][d], minimum 1), item index, drop position (a free spot near the source) and its room, quality, uidx, and the flags up, plus bit 0 when the source is monster class 391 (hellbovine). The resolver’s ilvl argument feeds only the quality roll. [I]

  • H7. The record as logged: flag bit 0 is set for exactly the hellbovine drops (221 of 221 cow drops, 0 of 4 796 others), the upgrade bits are 0, the quality is the resolver’s, and the level is the source monster’s (5 017 drops). The level for an object or player source is not logged. [C] (DropCreateItem)

  • H7. [I] Record +0x2A takes game+0x78, the game’s item version (u16): 101 in every logged expansion record, 2 in the classic ones. Flag bit 0 (the hellbovine source) is what lets set 29 be picked (items/uniques-sets D2).

  • H7. The item’s seed comes from the game seed, not from src.seed: drops pass no seed in the record, so ItemCreate leaves the two game-seed draws of the unit constructor in place (rng/seeds step 7a). In all 988 drop creations of the H2b run the record passed no seed, the unit seed and the item seed were those of two game-seed steps from the game seed at ItemCreate’s entry ({g1.low, 666}, {g2.low, 666}), and the source seed was the same before and after. [C] In a classic game creation also refuses an item with version ≥ 100; no classic creation path names one. [I]

  • H8. max counts created items across the whole recursion. Reaching it ends the resolver at once, and the item that reaches it gets no gold find (H9 is skipped): the 8 calls of the H2a run that made 6 items made them at the ends of separate sub-TC descents, and each went from its sixth item to the end of the call with no gold-find entry, while the 705 items below max each entered it. [C]

  • H8–H9. mul= on gold, then gold find on the item’s own type 4. The Countess’s gld,mul=1280 pile: 45 × 1280 >> 8 = 225, then 225 × 455 ÷ 100 = 1023. Gold find: 202 products, each gold × (100 + GF) ÷ 100 truncated, skipped for the 489 items whose own type is not 4 and for the 14 items of sources with no killer. [C]

  • H8–H9. mul= tests type gold through the type test of § K and gold find tests the own type exactly 4; on stock data only gld is of type 4 by any route, so the two tests agree there. Both products are signed 32-bit and ÷ 100 is an exact signed division; every logged product was positive. [I]

I. Auto item-type TCs (weapN, armoN, bowN, meleN, abowN)

Section titled “I. Auto item-type TCs (weapN, armoN, bowN, meleN, abowN)”

These are TC indices 1–160; this section adds what their contents are.

I1. for each itemtypes record t with TreasureClass ≠ 0, in record order: [C]
for L in 3, 6, …, 96:
name ← type code with padding spaces removed, then L in decimal ; "bow " → "bow3"
new TC: picks 1, group 0, level L − 3, noDrop 0, ratio all 0
for each item i in item-index order (weapons, armor, misc):
if Items[i].quest = 0 and Items[i].spawnable ≠ 0
and IsType(i, t) ; § K: type and type2, through Equiv1/Equiv2
and (t = 38 or not IsType(i, 38)) ; 38 = tpot
and L − 3 < Items[i].level ≤ L:
add entry i with Prob = max(1, ItemTypes[Items[i].type].Rarity)
flag it expansion-only if Items[i].version ≥ 100

Step notes:

  • I1. group 0 means an auto TC never upgrades, and all-zero ratios mean it inherits its ratios from the TC that references it (G2). The weight is the Rarity of the item’s own type, not of t. The 160 auto TCs built from the tables by this rule reproduce the 1 799 selections inside them over the S2a log set; weighting by the TC type’s Rarity instead gets 1 235 calls wrong. [C] (ItemTypes.txt:Rarity, Weapons.txt:spawnable, Weapons.txt:level)
  • I1. “Of type t” and “not of type 38” are the record test IsType of § K: the item’s type and type2, each through Equiv1/Equiv2, so a t such as weap, mele or armo takes every item whose type descends from it. The weight is the exception: it reads the own type. [I]
  • I1. If the code rebuild fails for a type, no TC is allocated for that level and the numbering shifts; this does not happen with stock data (160 TCs). [I]
  • [C] An object’s TC is Act N Chest A/B/C for its difficulty, by a tier (A/B/C = 0/1/2) that compares the monster level of the chest’s own level with those of the act’s two reference levels, the span between them cut into thirds:

    J1. lid ← RoomGetLevelId(room of the object); act ← DRLG_ActFromLevelId(lid)
    v ← LevelMonLvl(lid, d, expansion) ; Levels MonLvl (classic) or MonLvlEx, s16
    a ← LevelMonLvl(T[act].lo, d, expansion); b ← LevelMonLvl(T[act].hi, d, expansion)
    ; T: (2, 37), (41, 73), (76, 102), (104, 108), (109, 136)
    t: i32 ← (|b − a| + 1) ÷ 3 ; signed, toward zero
    tier ← v < a + t ? 0 : (v ≥ a + 2t ? 2 : 1) ; signed compares
    tc ← TC_GetChestTC(d, act, tier)
  • [I] TC_GetChestTC(diff, act, tier) reads g_ChestTCs, filled at load with the names "Act %d%s Chest %s" (suffix "", " (N)", " (H)"). The resolver gets the object as src, the operating player as killer, max = 6, an output array and no level upgrade. The |b − a| and the return-1 guards of LevelMonLvl (d ≥ 3, an invalid level id) have no stock case: b ≥ a for every act, difficulty and game type, and every chest’s level is a valid id. The callers, how many drops they ask for and the forced quality they pass (0, or 4/6 for a sparkle chest) are objects § J.

  • [C] The chest drop passes its tier as the resolver’s ilvl. The call pushes the tier (0, 1 or 2) in the ilvl slot and its forced quality in the forced-quality slot; the 59 chest calls log ilvl = the modelled tier in every call. The resolver’s ilvl feeds only the quality roll (H4), so a chest drop’s quality roll runs at ilvl 0–2, while the created item’s own level is taken from the source as for any drop (items/quality step note on chests).

  • [I] A forced quality on a gold or potion entry is handed through with no quality roll (H4), and ItemCreateByQuality’s last override then writes 2 for every base whose own type has Normal = 1: gold and the potion types hpot, mpot, rpot, spot, apot, wpot, tpot. So a sparkle chest’s gold or potion is built as quality 2, after the source seed skipped the quality draws; elix has Normal 0 and keeps the forced quality.

  • [C] The 11 object calls in the run (Act 1 Chest A, max = 6, 8 of them with forced quality 4) reproduce with D–H unchanged.

K. The item-type test — ITEMS_IsType and ITEMS_UnitIsType

Section titled “K. The item-type test — ITEMS_IsType and ITEMS_UnitIsType”

“Item i is of type t” (I1, H8, and the specs that link here: items/quality S2, data/excel G2) is this test, not a compare with the item’s own type column. It has two entry points: one takes an item index, the other an item unit and tests the unit’s base item.

Neither test walks Equiv1/Equiv2 when it is called: both read one bit of an n × n matrix (n the number of itemtypes records) that the itemtypes loader builds once (K1).

K1. at load, once, after the itemtypes records: [I]
for i in 0 ..< n: for t in 0 ..< n: M[i][t] ← TypeIsOf(i, t) ; row i = the types i counts as
TypeIsOf(i, t) → 0 or 1:
if t ≤ 0: return 1 ; before any other test: bit 0 is set in every row
if i ≤ 0 or i ≥ n: return 0
stack ← [i] ; i32[128]
while stack is not empty:
x ← pop(stack) ; last in, first out
if x = t: return 1
if x ≥ n: return 0 ; signed
if size(stack) > 124: return 0 ; the depth bound
e1: i16 ← ItemTypes[x].Equiv1
if e1 > 0: ; Equiv1 ≤ 0 (blank: 0) skips Equiv2 as well
push(stack, e1)
e2: i16 ← ItemTypes[x].Equiv2; if e2 ≠ 0: push(stack, e2) ; so Equiv2's branch is walked first
return 0
K2. IsType(i, t): [I]; item index i
if t < 0 or t ≥ n: return 0
if Items[i] is none: return 0
ty ← Items[i].type; if ty < 0 or ty ≥ n: return 0
if M[ty][t]: return 1
ty2: i16 ← Items[i].type2; if ty2 = 0 or ty2 ≥ n: return 0
return M[ty2][t] ; non-zero, not necessarily 1
K3. UnitIsType(unit, t): [C] its answers (K3 note); the guards and type2's > 0 test: [I]
if unit is none or t < 0 or t ≥ n: return 0
as K2 on the unit's base item, with no range test of its type, and type2 tested only when > 0 (and < n)

Step notes:

  • K1. [I] Bit 0 is set in every row, since TypeIsOf(i, 0) returns 1 before it tests i: IsType(x, 0) and UnitIsType(u, 0) are true for every item with a valid type, and row 0 holds bit 0 only. No test of this spec or of the specs that link here asks for type 0 (I1’s t has TreasureClass ≠ 0, H8 asks for 4, items/quality S2 for 45 and 50), so this bit decides none of their answers.
  • K1. [I] Cycles need edited data. A cycle through rows with one parent each never grows the stack, so the load hangs; at a row with two parents a cycle that continues through Equiv2 grows the stack by one per turn until the depth bound returns 0, and one that continues through Equiv1 hangs once the Equiv2 branch ends. A negative Equiv2 is pushed and read below the records (x ≥ n is a signed test).
  • K1. [C] The stock table has none of these cases. A full read of itemtypes.bin (103 records, W = 4): no row has a blank Equiv1 with a set Equiv2, no Equiv word is negative, the Equiv graph has no cycle, and its longest chain is 4 edges.
  • K1. [I] So on stock data M[i][t] = (t = 0) or t ∈ Closure(i), the plain transitive closure Closure(x) = {x} ∪ Closure(Equiv1) ∪ Closure(Equiv2) over the non-blank parents. A second reading of the code builds the matrix with the walk and compares it with a closure that has a visited set: 0 differences once bit 0 is taken as set in every row (426 bits; no walk reaches the depth bound, the stack never holds more than 2 entries). A reimplementation may compute the closure plus bit 0 for stock data; the walk’s bound, its skipped Equiv2 and its cycle cases decide nothing there.
  • K1. [C] A blank Equiv1 or Equiv2 cell stores record 0 (None, the first row with the blank code), not a “no parent” value: the loader looks a blank code up like any other.
  • K2. [I] The record test reads type, then type2 only when it is non-zero, each as a row of the matrix; a type2 hit returns the masked dword, so a caller tests it for non-zero. The auto TCs of I1 are built with it; on stock data reading type2 changes no count.
  • K3. [C] The unit test answers as the closure of the base’s type and type2 on every type the runs asked for: taken as that closure it gives the logged affix candidate list of every pick of the run (items/affixes C5c–C5d), and the gold test of H8 gave 1 for the 207 gld units of the H2a run and 0 for the 506 others (Constants, GOLD_TYPE). That it reads the K1 matrix, which equals that closure plus bit 0 on stock data, is the code reading (K1 notes, [I]). Its type2 is tested only when positive, [I].
  • K. The tests that do not go through IsType read the item’s own type column only: the throwable test (H6), gold find (H9), the auto-TC weight (I1, the own type’s Rarity), and items/quality A2–A5 and S1. [I]

For one resolver call, in order. Items 1, 2 and 4 are [C] for every expansion-game call of the run, with the quality roll as oracle (TC_ResolveDrops: 328 calls, every seed asserted).

  1. Each positive pick with range ≥ 1: one draw (D4). Negative picks: none (D3).
  2. Each item pick that is not a unique/set entry and has no forced quality: the quality roll’s draws (H4).
  3. Then the two upgrade draws, each only when its ratio word is non-zero (H5). Never ran: no stock data makes those words non-zero. [I]
  4. Item creation: no draw on src.seed (H7); its unit-seed draws are on game.seed.

Sub-TCs interleave depth first: a sub-TC’s picks (and the items under them) all happen before the parent’s next pick. Over the S2a log set, 1 907 new-frame pushes each finish before their parent’s next pick, in the order every logged pick seed asserts. [C]

  • [C] count: the number of item units created (≤ max), in creation order (9 390 call counts and 7 115 creation calls in order over the S2a log set). Monster drops pass no array; the units are placed in the world near the source.

  • [I] When the caller passes out, it holds the units in creation order; the array’s content is not logged.

  • [C] src.seed advanced by exactly the draws of items 1, 2 and 4 above in every recorded call; the upgrade draws (item 3) are code-read only.

  • [C] For each item: one creation call with (item index, quality, uidx, up); game.seed stepped by the unit constructor. Every one of 988 drop creations of the H2b run holds exactly one ItemCreate call, for the item the resolver picked, with the game seed two steps on after the constructor and no further step before the quality build.

Seeds are low:high in hex. Expansion game, Normal.

1. Positive picks, NoDrop, two sub-TCs (call #0). Monster class 5 (no type flags), ilvl 1, killer a lone player with no /players, so party = 1, PlayerCount = 1, cap 1, n = 1 and NoDrop stays 100. src.seed on entry a165c8f5:45c801b7. [C]

# TC (index) Picks, NoDrop, total Draw src.seed after roll Result
1 Act 1 H2H A (430) 1, 100, 60 Range(160) 99a37640:43515534 128 128 − 100 = 28 → entry 1 Act 1 Equip A (cum 21, prob 16)
2 Act 1 Equip A (218) 1, 0, 14 Range(14) 661f5474:4014da46 0 entry 0 weap3
3 weap3 (33) 1, 0, 27 Range(27) cf6a178a:2a982ef3 9 entry 4 ssd, item 25 (cum 8, prob 3)
— quality oracle ratios 0,0,0,0,0,0, ilvl 1 (oracle) a2ada0ba:6a57e192 — quality 1
— create item 25 — none a2ada0ba:6a57e192 — count = 1

Each sub-TC push came after its parent’s only pick was consumed, so each reused the frame (G1 tail call), so all three TCs ran in frame 0. Frame 0 then has no picks left and the call ends with count = 1 and src.seed = a2ada0ba:6a57e192. The other three calls of that log (Act 1 H2H A, fallen, class 19) drew once each, rolled below 100 and dropped nothing.

2. Negative picks and ratio inheritance (call #15). Unique monster, class 58, mflags = 09, ilvl 5, Act 1 Unique A (767, Picks = −3, entries Act 1 Uitem A prob 1 and Act 1 Cpot A prob 2). src.seed on entry 64be0388:64bef445. [C]

Step Frame Draw roll Result
neg 0 Unique A none 0 Act 1 Uitem A (725, ratios 1024,800,800,800) pushed
1 Uitem A (total 62) Range(62) → d8242bed:2a04d165 17 Act 1 Equip A
2 Equip A (14) Range(14) → f1ddeec6:5a26a064 6 weap3
3 weap3 (27) Range(27) → f962bec2:64e17f4b 8 item 25; quality oracle with ratios 1024,800,800,800,0,0 → 4, seed 604edad6:4a9978d0
neg 1 Unique A none 1 Act 1 Cpot A (640, Picks = 2, one entry Hpotion 1, total 1)
4 Cpot A Range(1) → 9fe43f7e:282b5a10 0 Hpotion 1 (174, total 17)
5 Hpotion 1 Range(17) → ddfb1606:42b0873e 7 hp1 (587); oracle → 2, no draw
6 Cpot A Range(1) → d5efd9dc:5c9624d9 0 Hpotion 1
7 Hpotion 1 Range(17) → 80dc8b25:593b40b3 14 mp2 (593); oracle → 2, no draw
neg 2 Unique A none 2 Act 1 Cpot A again
8–11 as 4–7 four draws 0, 16, 0, 3 rvs (515), hp1 (587)

Five items, count = 5, final src.seed = 43a0c080:5dec9d2e. The ratio words reach the oracle from Uitem A through two zero-ratio sub-TCs (G2), the Range(1) picks step the seed (D4), and the potions’ quality calls return without drawing (H4).

3. NoDrop scaling at n = 4 (lone player, /players 8): (NoDrop, T) = (100, 60) gives r = 0.625, p = r⁴ = 0.152587890625, q = 0.847412109375, (1 − q) × 60 / q = 10.80… → 10; (125, 38) gives 20. Every pick then draws Range(70) or Range(58) instead of Range(160) or Range(163). [C]

  • MonItemPercent adds nothing to a drop. The table loads in every run, but no code reads it: its record getter and its table getter have no caller, and no instruction names its globals outside the loader and the free. So a monster’s death drop (MonDeathDrop → MONSTER_DropItems → TC_DropByIndex → TC_ResolveDrops) chooses no MonItemPercent row, makes no draw on it and steps no seed for it; the draw order is complete without it. Do not gate a drop on TreasureClassPercent. [I] The load itself is logged in every H3b run that reaches it. [C]

  • Two seeds. TC picks and quality rolls step the source unit’s seed (unit+0x20); the created items get their seeds from the game seed. Mixing them up shifts every later drop. [C]

  • The quality roll interleaves with the picks on the same seed, so a TC walk cannot be reproduced without the quality model (items/quality). [C]

  • NoDrop is recomputed for every pick, from the unscaled NoDrop and the current TC’s total, in floating point. A reimplementation in IEEE binary64 with round-to-nearest-even rounds each F4 operation to the same 53-bit significand as the logged control word, for these operand ranges (no overflow or subnormals): the 53-bit model matches all 2 909 logged evaluations of the S2a log set. [C] (nodrop_scaled) Do not use the algebraically equal p·T/(1 − p): the game computes 1 − q. On stock data the two never differ (every (NoDrop, T) pair with n 2 to 8, and every logged evaluation, truncates to the same value either way), so this rests on the code reading. [I]

  • The party rule is “same level”, not “two screens”. 1.14d differs from the 1.10/1.11 community descriptions here; do not “correct” it. [C]

  • /players is a floor on the player count, not an addition, in single player (type 3) and on a TCP/IP host (type 2), where only the server’s process setting counts. [C] Game type 1 also takes it, and other types do not. [I]

  • The level walk is forward-only and starts at the base TC, which is kept even when its own level is above mlvl. Do not search the whole group for the best level. [C]

  • Range(1) draws. A sub-TC of total 1 with no NoDrop still steps the seed once per pick. [C]

  • max is global to the call (6 for monster drops): the 6th created item ends the whole recursion, and that item skips gold find (H8). [C]

  • Runtime group is offset by 5 for TCEx rows with a non-zero group. [I] Only equality between neighbours matters, so a reimplementation may keep the table value: every walk of every TC at every level 0–99 is the same with and without the offset. [C] (TC_GetByIndex)

  • Classic games differ in the draw total (D2, A2), the entry selection (E2), the throwable re-pick and the Long Sword (H6). The classic sessions reproduce the classic total and its two A2 clauses, the scan, the refund, and (forced) the bound of 10 and lsd. [C] Item rejection (H2) and the ratio raises (H3) differ too; the skip of an expansion-only entry, the scan off the end and the version reject have no stock case, and the raises need edited cells. [I]

  • excel.md § G: TC load, cell resolution, the TC index space.
  • Tables: TreasureClassEx, MonStats, ItemTypes, Weapons, ItemRatio.