Skip to content

Using items, and the inventory

This page explains what the server does when a player uses an item (drinks a potion, reads a scroll, opens the cube), where an item can go (the inventory, the stash, the belt, the cursor, the ground), how pickup and drop work, and how long an item then lies on the ground, and how two players trade. It restates three reviewed specs: item use, inventory and trade. They describe the server’s outcomes in game frames. What the screen shows and the cube’s recipes are out of scope; the cube’s transmute is on the other item paths page.

Most of this area is known in one of five ways, and the page names which at each statement. The specs spell out the same split in their sections on how to read the tags and the inventory’s. The differences matter here, because the two runs of the real game were small.

Kind What it is Where it stops
Seen in a game Two runs of the real game, three kept logs, with the server’s calls logged and compared with a prediction. Seeds, amounts, cells and frames were read from the log. The first run was one fresh process, and two of its requests carried a field written by hand (named below; they stay readings). The second used a fresh process per session and forced nothing. They cover a few cases: 17 potion uses by one Sorceress, 80 ground drops, 118 ground searches; each count is given where it is used. Only the expiry amounts and the 16 stored rates were checked against a table committed before the kept sessions. The rest compare the reading with the log case by case, on inputs the log gives: that checks the code against its reading, and says nothing of which inputs occur.
Emulated The game’s own code run in an emulator on made-up inputs, and compared bit for bit with the project’s model. It shows what the code does with the bytes it is given. It is not a game. It says nothing about which inputs a game produces. Many runs stop at a named call into another function, and what is after that call is not covered.
Confirmed by a second reading The instructions read again with a second tool, or a scan of every call of or store into the thing named. The spec counts it confirmed. It covers what the code says, as far as the scan reaches, not that a game reached it.
Read from the code The instructions were read, and nothing ran. It can be wrong in ways no run has checked.
Unknown Named under What is not known yet.

The trade between players has its own run, of two clients in one game; its section says what it covered.

Two further limits keep coming back. The gate in front of every request stops, in the emulator, at a call into the operating system; nothing after it is evidenced. And the whole stretch from a handler to the end of its callees was never followed for random draws; only the cases named below are bounded.

Every client packet passes one gate first.

  • Emulated: the refusals. Packet 0, any packet above 0x66 and any packet with no handler are refused. Five packets skip the player-state test. A player who is in state 54 or in mode 0 or 0x11 is refused for the rest, and the one packet 0x41 passes only in mode 0x11. This held over 428 cases without a mismatch.
  • Emulated, up to the call: a packet that passes reaches the operating-system check of the handler’s address in all 106 cases tried. What that check returns, and the handler’s call after it, are read from the code, not evidenced.
  • Read from the code: two item requests in one batch of packets run in the order they arrived, each to the end, and the second sees the first’s result; no item request is reordered, batched or rate-limited. That was read in the drain and the gate, not through each handler’s callees.
  • Confirmed by a second reading: the batch drops a handler’s “no” answer, so whatever the handler did before refusing stays. Seen in a game: the gate draws nothing, the player’s seed equal across all 175 logged requests.
  • Read from the code: the only item request that does not finish in the same step is a pickup out of reach. It starts a walk, and the pickup runs in a later frame.

Emulated up to the call of the use routine, for each of the four requests, the length and every test in the table included; what the handler does with a refusal the use routine flags after that call is read from the code:

Request Checks before using the item
Use an inventory item (0x20) the packet is 13 bytes; the item exists, is in mode 0 and is found with the player; the player is within 50 of the stated position on each axis
Use a belt item (0x26) 13 bytes; the item is in the belt; the position tested is the player’s own, so the distance test cannot fail
An item on an item (0x27) 9 bytes; both items are the player’s
The mercenary button (0x61) 3 bytes; an expansion game only; a cursor item that is not a quest item, the player alive and using no skill, and the pet of type 7 alive

An item’s row must also be marked usable for the first two. A usable row with no use kind passes that test and does nothing: the item is not used up, unless it is one of the four quest codes below. Among the direct calls read, the belt flag and the two warning columns gate no use; indirect callers were not followed.

The game picks a use kind from the item. A tome or scroll whose row in the books table gives a kind above zero takes that kind; otherwise the kind is the item’s pSpell column. The choice itself, with the kinds 1 to 30 and the empty slots, was emulated over 600 cases; what each effect then does is emulated only up to its first call into another function, except where noted.

Kind Stock items What the effect does How it is known
1 isc, ibk (identify) identifies an item, in two requests emulated to the first call; the rest read
2 tsc, tbk (town portal) opens a town portal for a player; refused in town and on level 136 read
3 hp1 to hp5, mp1 to mp5 a total amount spread over a duration, with a chance of double emulated to the first call; the two draws and the stored rate also seen, below
4 none kind 3’s loop without the class scale and the draws emulated to the first call; no stock item has it
5 rvs, rvl a percent of the maximum, at once emulated to the first call
6 yps, wms clears the named states, then acts as kind 9 read
7 box (the cube) opens the cube; never used up emulated to the first call
8 elx adds a stored stat to a stat emulated to the first call
9 vps, hrb a timed state, with the group clear read
10, 11 none cast skill 47 at level 1 read; draws not looked at

The draws of every kind before its first call into another function are listed below.

An effect never removes the item; the request’s handler does, by the effect’s answer. All of this is read from the code; no emulated case enters these functions, and the runs logged outcomes only for the potions below.

  • A scroll or potion with a non-zero answer takes one off the matching skill’s quantity, then is removed. A tome with a skill and charges left loses one charge and stays.
  • A zero answer uses nothing up. Four quest items (by code ass, xyz, tr2 and toa) have their own branch when the answer is zero; three of them have a further test, and each removes the item when it applies.
  • A belt use shifts the remaining items of that column down. An item used on an item from the belt does not shift its column, and a belt scroll used on a target that is not in a grid is removed unused.
  • The mercenary button removes the cursor item whatever the answer was.
  • Using the cube never uses it up. A first identify request uses nothing: it only opens the prompt. The second request, on an unidentified item in the player’s own inventory, identifies it. Unlike the other use requests, the second does not clear the “use mark” before it runs, so the mark the first set still stands; it clears the marks only afterwards. One of 24 other functions, the moves among them, also clears it, and a second request after such a move runs the first step again.

This is the best-evidenced part of the item use. The amount of a potion is a total, not a per-frame number.

  • Two draws, then the doubling. A life or mana potion’s amount slot draws on the user’s seed twice when the vitality or energy is above 0: a range up to the character’s vitality and then a range of 100; a mana potion uses the energy. The total doubles when the second number is below half the first, so the chance rises with vitality or energy (read from the code: about 2.0 % at 10, 24.5 % at 100, 37.0 % at 150, 49.5 % at 200). The draws come before the amount test and happen for an amount of zero too. Seen in a game, 17 of 17 uses: 12 health potions and 5 mana potions of a Sorceress at vitality 165 and energy 150 made exactly these two draws, and the seeds before and after, the draws’ results and the amount equalled the prediction in all 17. The seed chains from each use’s return to the next one’s entry, so nothing else drew on it between them. The prediction was evaluated per case on the logged inputs, so this checks the code against its reading on those inputs; it does not say which inputs occur.
  • The doubling by potion. The health potion showed both outcomes (6 doubled, 6 not, in 12 uses), and the prediction agreed with the logged amount in all 12. The mana potion showed only “not doubled”, 5 of 5. Its doubled branch has not been seen in a game. At an energy of 150 the chance is about 37 %, so five misses in a row happen about one time in ten; this batch does not say that a mana potion never doubles.
  • The rate. The total is stored as a rate per frame, truncated: total divided by the potion’s duration, in stored units of 256 to a point. Seen in 16 of 16 uses on a fresh list: 7 680 or 15 360 over 192 frames gave 40 or 80 for hp1, and 10 240 over 128 gave 80 for mp1. The list’s end was the frame plus the duration. Scope: hp1 and mp1 of a Sorceress. Because of the truncation, a potion can deliver less than its total: hp3’s 100 life over 171 frames is a stored rate of 149 per frame and 99 life in all (read from the code).
  • The class factor. The code scales a life amount by one and a half (by a shift, so an odd amount rounds down) for the Amazon, Paladin and Assassin, by 2 for the Barbarian and for monsters, and by 1 for the others; a mana amount by one and a half for the same three, 2 for Sorceress, Necromancer and Druid, and 1 for the Barbarian. This was emulated over 800 cases. In a game only the Sorceress ran (her health factor 1, her mana factor 2). So hp1’s 30 is 30, 45 or 60 life for a Sorceress, an Amazon or a Barbarian, on the reading.
  • A potion at full life. Seen in a game, one case, hp1: it was used, not refused; the list and rate were set and the answer was 1.
  • Seeds around the request. Seen in a game: the player’s seed moved across each of the 12 inventory requests and the 5 of the 6 belt requests that used a potion; the game seed moved across none. The sixth belt request was a rejuvenation (rvs, below). This bounds those two seeds only, not other units’.
  • A second potion while the first runs is the open case. The code is read to reuse the same list, ending at now plus what the first has left plus the duration, with the rate blending the first’s undelivered part and the new amount. In the game, the second use found the first list in 1 of 4 pairs (33 to 43 frames apart); the other three started a new list. The reading of what decides it is the life or mana meter: the game frees the potion’s list when the meter reaches its maximum. In those three pairs the first potion was used at the maximum, and by the second use no potion list was contributing. The free itself was not logged. The blend of two different amounts was not separated: the one blended use has the same potion twice, where the blend and a plain division give the same 40. It is open.
  • A healing or mana potion does not clear states (no group clear); only kinds 6 and 9 do (read from the code).

A health potion can also feed a Blood Golem: for a positive life amount on a player with a golem, a percentage share of the amount goes to the golem and the player keeps the rest. This was emulated (300 cases) up to the golem heal and not seen in a game (the 17 uses had no golem).

  • Rejuvenation adds a percent of the maximum life and of the maximum mana at once: 35 for rvs and 100 for rvl, capped so the stat does not pass its maximum. Emulated to the first call. Read from the code: a rejuvenation at full life still returns “used”, so it is used up. A belt rvs was used once in a game and did not move the player’s seed; that is one case.
  • The elixir adds the item’s own stored stat to a stat chosen by the item’s file index and does not read the columns the other kinds do. Emulated to the first call (200 cases). How an elixir reaches a player, and what writes its file index and stat, are not known.
  • Keys have no use entry. A key is taken by the chest (and by one case of the object mode switch), which uses the first key on the inventory page: one fewer in the stack, or the key removed. Emulated (300 cases), up to the stat change or the removal. An Assassin needs no key at a chest; that skip is read for the chest only.

An item sits in a unit’s inventory in one of five modes (§ A, read from the code): on a page, on the body, in the belt, on the ground or on the cursor. A player has pages for the inventory, the cube, the stash and two for trading.

  • The stash is 6 wide and 8 high in an expansion game, and 6 by 4 in a classic one. Emulated: 400 cases.
  • A page is created on its first use from the size given then. A later request with another size returns nothing, so nothing is placed (read from the code; no run reaches it).
  • The grid sizes are read as bytes. Emulated: a wider reading fails 2 465 of 4 000 searches.
  • The grid row follows the unit and the page (emulated): a monster, a hireling too, uses one row, and two object classes have their own. No path to those two object classes was read, and the table’s hireling rows are never returned (read from the code).

When an item is put on a page without a cell, the server searches the grid. Emulated, 4 000 cases without a mismatch, and 112 distinct outcomes:

  • For a player, an item one cell high takes the free spot scored best, columns from the right and each from the bottom, and an item taller than one cell takes the best by rows from the top, each from the left. The score is how many neighbouring cells, or edges of the page, are filled; a tie keeps the earlier spot. On an empty page the one-cell-high item goes to the bottom-right corner, a taller one to the top-left.
  • For any other owner (a hireling, a monster, an unowned inventory) the first spot that fits wins: one cell high, columns from the right and each from the top; otherwise columns from the left. So a player’s search and a hireling’s differ.
  • The early stop at a perfect score changes no output, and a reimplementation may leave it out.
  • A small worked case, from the project’s model of this search (not logged in a game): five 1 × 1 items in turn on an empty page 10 wide and 4 high go to the last column (index 9), bottom up (rows 3, 2, 1, 0), and then to the column before it at row 3.
  • Putting an item on a cell, with the refusals of an occupied cell or one out of bounds, was emulated up to the removal call that follows (800 cases), and the search as its caller uses it up to that put (500 cases); what comes after is read. A scroll or tome placed on a page other than the stash adds its skill quantity; one placed in the stash adds nothing (read from the code).

Five one-cell items put in turn on a toy page 10 wide and 4 high for a player, computed by our model; columns and rows count from 0.

Item Size Spot (column, row) Score
1 1 x 1 9, 3 2
2 1 x 1 9, 2 2
3 1 x 1 9, 1 2
4 1 x 1 9, 0 3
5 1 x 1 8, 3 2

Type the sizes of up to twelve toy items and the size of a toy page, and see where the search puts each one, in turn. For a player, an item one cell high takes the free spot scored best, columns from the right and each from the bottom, and a taller item the best by rows from the top, each from the left; the score counts the filled neighbouring cells, an edge of the page counting as filled, and a tie keeps the earlier spot. For any other owner the first spot that fits wins, one cell high by columns from the right and each from the top, otherwise by columns from the left (inventory § B1 to B4). Not shown: the size an item really has, pages that already hold items, the other pages, and what follows once the spot is chosen. Computed by our model of the rule, not observed in the game; the starting values are illustrative.

Interactive version: needs JavaScript.

The client’s requests that move an item ran under emulation up to the routine each one calls, their length tests and refusals included; the routines’ own moves are read from the code unless a section below says more. A handler’s refusal changes nothing beyond the handler, since the batch drops it:

Move Request Note
ground to cursor or inventory interact (0x13, 0x16) pickup
cursor to the ground 0x17 drop
cursor to a page 0x18 sets the page first, then places
a page to the cursor 0x19 needs an interaction for any page but the inventory
equip, swap with a body location 0x1A to 0x1E
swap with a page item 0x1F
stack 0x21 stacks
split a stack 0x22 a stub that does nothing
cursor to belt, belt to cursor, swap 0x23, 0x24, 0x25 belts
inventory item to belt 0x63 the belt’s search, then that box

Seen in a game: 0x19 (item to the cursor) moved neither the player’s nor the game’s seed, 80 of 80 request pairs, and the cursor drop 0x17 likewise (80 of 80). This bounds those two seeds around the handler only. By the reading, a stash page that the packet names needs no open stash for a placed item: the item is on the cursor, so the “busy” test passes; it needs a room in town. One forced case ran (in the first run): a placement to the stash page in town with no stash open was accepted, but only after the page field was written into the packet by hand, which the real client cannot send, so it stays a reading.

  • Emulated, 2 000 cases to the return: the belt’s free box. Only a beltable one-by-one item goes in. A column is chosen if its bottom box holds an item of the same class, or of the same group (the health potions, the mana potions, the rejuvenations); the item goes to the first free box up that column. If none, an item whose row allows it goes to the first free bottom box. The number of boxes comes from the worn belt’s row, or from the default row when no belt is worn (four boxes).
  • A row that does not allow it (isc, tsc, yps, vps and wms among them) is in no group, so it joins only a column whose bottom box holds its own class (confirmed against the table: 8 of the 22 beltable rows).
  • A pickup that goes to the belt always uses this search: its test accepted every one of 1 173 items under emulation, and a second reading pins the call.
  • Putting a cursor item into a box (0x23) ran under emulation up to the item’s removal from the cursor (1 500 cases).
  • Taking an item from the belt shifts its column down; a swap is in place; both read from the code.
  • At a corpse’s making (read from the code, not run), a belt moved off the body is treated as the default belt: boxes beyond its four go to the inventory page by the placement search, and to the ground if they do not fit. A community text about the remastered game says the same, and a death with a belt holding items above the fourth box is among the cases left open.
  • One forced case: a belt placement to box 12 of a 12-box belt stayed in box 12, after the box field was written into the packet by hand. The stock route, and whether a smaller belt’s overflow later takes the item, were not run.

Two items stack when (emulated, 660 cases with each test broken alone) they have the same class, quality and file index, the row is stackable, the ethereal status matches, the quality is not 0 and not one of 4 to 9, and a handful of stats match. The maximum is the row’s maximum plus a stat, capped at 511. A merge over the maximum fills the target to the maximum and leaves the rest on the cursor; otherwise the target takes the sum and the source is freed (the sum itself was emulated up to the first stat write, 500 cases; the remainder is read).

There is no split on the server, confirmed by two tools: the split request reaches a stub that does nothing, and its handler has no other path to a split. The handler then answers “no”, which the batch drops, so nothing changes. Gold’s withdraw and drop are other requests and were not part of that reading.

The stack request itself (0x21) ran under emulation up to the merge (2 000 cases).

Each part says how sure it is. Emulated (2 500 cases): the interact request’s item case, the mode test, the two distance thresholds (under 5 to pick up, 51 or more to do nothing) and the choice between picking up and walking there, up to the pickup, the walk and the line test. The walk after a blocked line, and the tests run again at its end, are read from the code.

  • Reach. The distance from the player to the item uses a table for near units and a different formula for far ones. Emulated, 1 500 cases without a mismatch: a player to an item reaches “under 5” at 22 of the 64 offsets under 8 (a column offset of 0 to 2 with a row offset of 0 to 4, and so on). The sizes were run for a player, an item and an object; a monster and a missile were not.
  • The line between the two must be clear for a pickup in place. The code that shortens and tests the line was emulated (600 cases) as far as the collision test itself, whose result belongs to the collision page of the specs and is a reading there; a player’s collision mask was declared, not read from a game, so whether a player’s line test ever takes the code’s other branch is open. The two tests run again when the walk ends.
  • The order a pickup tries. Gold; an auto-stack into a tome, a stack or a quiver; then an auto-equip location if the item names one (for example an arrow quiver to a hand that holds a bow); the belt for a beltable item; the inventory page by the placement search; and if all fail, the item goes back to the ground and nothing moves. Note that a location that the equip test then refuses gives up on the pickup: it does not fall back to the belt or the inventory. The choice of that location, with the item’s requirement test, ran under emulation (6 000 cases each); the order of the steps is read from the code.
  • Who dropped it is not among the tests read in the pickups. The “no pickup” flag is not read there either, confirmed by a scan: its four references are all in the client’s code, none in the two pickups or their 36 direct callees.
  • A merge’s remainder stays the same item with a reduced count and goes on down the list; with no room it is put back on the ground with that count, and the stacks it merged into keep what they took.
  • Gold and the party’s share are on the prices page.
  • Taking an item to the cursor (not the inventory) follows the same first tests and then moves it to the cursor.

When a player drops the cursor item, or the game drops an item for a monster, a chest, a belt that overflows, a cube that is dropped or a corpse, the same free-cell search picks the cell.

Emulated, 4 000 cases without a mismatch (55 distinct outcomes), with the search at size 1 and step 1, and given that the memory the code asks for was handed over. It is the code’s map on declared rooms, not a game:

  • The search starts at the position plus (2, 3), when the room or one of its near rooms holds that cell, and at the position otherwise.
  • A cell is free when it holds none of a set of blockers, one of which is another ground item, and a walk from it to the origin meets no blocker. A cell holding another item is refused as a place to drop, but does not stop the walk across it. Two bits of the first test are not told apart by any output at this caller.
  • It then looks at rings 1 up to 49 (ring 50 is never looked at). In a ring it takes the side columns first, then the end rows, and keeps the lowest sum of the two distances, the first one met among equals.
  • The room used to find each cell is the last room the previous lookup gave, not the room dropped from. Emulated only: no game search has separated this (a fixed-room reading fails 95 of 4 000 emulated cases and none of the 118 logged searches).
  • With no free cell, a drop takes the start cell, blocked or not, in the room the last lookup gives; with the fallback off the search answers with nothing and keeps the start. Those branches were not reached in a game. That a gold amount’s pile is not dropped when no cell is free is read from the code.
  • The walk follows a direction field from the data file expfield.d2. Over the whole file, every cell walks to its centre in as many steps as its larger offset (checked on all 65 536 cells).

Seen in a game: 118 searches over three logs (37 in the first run, 41 and 40 in the second) matched a model older than the logs, evaluated case by case on the logged collision window, with no mismatch. They are not 118 independent cases. A player’s drops are chains in place: each drop blocks the next, at six spots (6 and 4 in the first run; 24 at the start, 12 at the parapet, 4 in the City of the Damned and 40 at the crowd spot in the second), and the other 28 are monster or chest drops at 24 positions. The rings reached in the logs were: the start cell 27 times, ring 1 31 times, ring 2 32, ring 3 21, and ring 4 or beyond 7. A drop in a crowd shows the walk test mattering (without it 31 of the 40 searches at the crowd spot would come out differently). The walk’s path itself, a full surround and a null result were not reached in a game.

Counted by spot (a chain, or one drop position: 30 in all), the logs separate several of the rules above from a wrong reading at many spots, so those rules are seen in a game as well as emulated: the (2, 3) start, at all 30; another ground item refusing a cell, at 8; the walk’s own, narrower set of blockers, at 6; and, through ring 3, the lowest distance, the first among equals and the side columns first, at 8 or more. That the walk is tested at all is seen at the crowd spot only, and that a ground item does not stop the walk has no logged test of its own: both stay emulated, as do rings 4 and beyond, met at one spot.

A worked case from the crowd session: a player standing at (5032, 5027) in the Act IV town drops six items in a row. The start is (5034, 5030). They land in turn on (5034, 5030), (5033, 5030), (5035, 5030), (5034, 5029), (5034, 5031) and then on (5033, 5029), the first corner at distance 2 in the search’s order.

Who drops with this search is read from the code: 20 direct callers (monster and chest drops, the cursor drop, the belt overflow, the cube’s contents, a corpse’s overflow, NPC menus, shrines), all with size 1 and fallback on; the pair form of the search has 7 direct calls, among them four item-drop bodies, a gold amount (fallback off) and the town portal (size 3, fallback off). A drop whose room is null (the search’s answer) leaves the item on the cursor, makes no item or places nothing, depending on the caller.

An item on the ground has an expiry frame, or none. There are three lives, which are read from the code until a note below lifts part of one:

How it got to the ground Its expiry In a room that stays active
made by the item-creation function for a monster’s or chest’s drop (and a gold pile) none (0) never swept
placed by the game’s ground-placement function: a player’s drop, an overflow, a gold amount, NPC menus, the cube’s the frame plus 15 000, 30 000 or 45 000 (below) freed at the first multiple of 1 500 at or past it
restored when a room comes back the larger of its saved word and now plus 15 000; a saved 0 stays 0 as the second row
  • The amounts (the rule is emulated, 600 cases): a quest item has no expiry; quality 4 and a socket filler (a gem, rune or jewel) get 30 000 frames; qualities 5 to 9 get 45 000; gold gets 45 000 above 10 000 gold and 15 000 otherwise; all else 15 000. At 25 frames a second 15 000 is 10 minutes. Seen in a game, 80 of 80 drops, in 21 groups of base and quality: 15 000 for qualities 1, 2 and 3 (potions, rings), 30 000 for quality 4 and for the filler, 45 000 for qualities 5 to 8. Qualities 1, 3 and 8 and the jewel and runes were built by the run’s recipe, each drop a real click. Not run: gold, a quest item, quality 9 and a socketed item. By the reading, no stock path makes a quality-9 item.
  • The sweep runs every 1 500 frames over the active rooms and frees an item whose expiry is at or before the frame. Its period and its order were emulated, up to the first item reached; its test was emulated in 600 cases, where “before the frame” instead of “at or before” fails 92 and “zero expires” fails 69. Seen in a game, 4 of 4: a player’s quality-2 drops, made at frames 3 659 to 3 863, were freed at the sweep of frame 19 500, with five monster drops beside them still there at 21 000 and 22 500. Scope: quality 2, one sweep, a room that stayed active. Six more predictions were excluded because the room had gone inactive and its activity was not logged. By the reading, the item falls up to 1 499 frames after its expiry.
  • A monster’s or chest’s drop has no expiry, in the cases that ran. Seen in a game: 27 of 27 drops made through the drop function had an expiry of 0 when made, and five of them (followed for 12 to 14 sweep dumps each, 79 sightings in all) were never freed. Scope: that path, those 27 creations and 5 items. The log does not tell a monster’s drop from a chest’s, and the session’s source was kills. “Never swept” stays a reading for a longer life, for gold piles and for any copy of an item.
  • When a room goes inactive and returns, an item’s saved word is computed afresh, as if it were dropped now, not the old expiry: seen, 45 of 45 (one monster drop with 0 before, and 44 player drops). So leaving a room can lengthen any item’s life, a player’s drop too. On return the new expiry is the larger of that word and the current frame plus 15 000: seen in 40 of 40 (26 got the frame plus 15 000 and 14 got the saved word; 36 restores in the town and 4 in the City of the Damned). A saved word of 0 staying 0 and a word equal to the limit were not seen. A restored copy was swept at the first multiple at or past its expiry in 22 of 22 that resolved. 14 more have their expiry after the session’s last dump and are unresolved; 4 were saved again before their predicted sweep and are excluded, as are the 40 town drops of that session, and the 40 crowd sweeps are unresolved. In the first run, three monster drops whose room went inactive came back with an expiry that was not predicted; the reading above is stated for that session as read, because that run did not log its inputs.

Two players in town can trade: each puts items on an offer page and may offer gold, both accept, and the server swaps the offers. Everything here restates the trade spec. It covers what the server does, in game frames and in a few real-time windows; the trade window on the screen is out of scope.

What “seen” means in this section. The trade has its own run: two unmodified clients on one machine in one hosted expansion game on Normal, played automatically, the host’s server calls logged and replayed against the spec’s rules by a checker. Three kept sessions met 13 planned cases; the checker found no mismatch except two timing lines named below. “Seen” means that a case of this run reached the branch; it checks the branch on the inputs the run gave, and nothing else. The rest is read from the code: the instructions were read and no case reached them.

A trade starts when one player interacts with another.

  • Read from the code: within a distance of 8 (in the game’s own units) the request is made at once, unless the other player is dead, when the interaction picks up the corpse instead; from 9 to 50 the player walks to the other first; farther than 50 nothing happens.
  • Read from the code: nothing happens if the asking player is busy (in an interaction, a trade included, or holding an item on the cursor).
  • Seen: if the other player is busy, the asker gets a message naming them and nothing moves; in the run the other player was in Deckard Cain’s menu. The messages to one asker are spaced at least one second apart (that spacing is read from the code).
  • Seen: within five seconds after the other player’s last trade ended, the asker gets a message naming them, and nothing opens; in the run the request came 80 frames after a close. The asker’s own five-second window gives the same message without a name (read from the code).
  • Read from the code: a request that gets past the busy test and the other player’s five-second window still does nothing, with no message, while either player’s trade state is not back to idle.
  • Both players must be in town. Every request that opened in the run was in town; the refusal outside town was not reached (the run had no route out of town), so it is read from the code. There is no hostility test of the request’s own (read from the code).

When the request passes, the asker is waiting and the other player is asked. When the asked player accepts, both are in an open trade, and the server makes a trade record for each: a snapshot of the whole inventory (in the save file’s item format, by the reading), and the gold carried at that moment, with no gold offered yet. Seen at every opening of the run.

A player has two trade pages besides the inventory: an offer page where it puts what it gives, and a view page that shows what the other player offers.

  • Seen: an item put on a player’s offer page makes a copy, with a new id, on the partner’s view page at the same cell.
  • Any move of an item by a trading player un-accepts both players, even a move the server then refuses. Seen at each of the 19 logged item tests: picking up an offered item, a click on the belt, and three refused cube moves. The exception is read from the code and was not logged: an early test refuses the move and does nothing else, for instance while the partner has no trade record or a rebuild or an exchange is pending. The test runs for seven kinds of move request (taking from a page, the equip swaps, the belt ones), a pick-up from the ordinary inventory included (read from the code). Both players pass through a short “changed” state and are back in the open trade a frame or two later; the steps are seen, the frame delays are read from the code (see the timing question below).
  • Refused moves, seen: a Horadric Cube with items in it (the mover gets a message); a quest item when the partner already holds one of the same kind, which in the run was a cube while the partner held a cube (no message); a belt taken off while it holds potions.
  • Read from the code: an item marked as monster equipment is refused too; a stock player cannot hold one. While trading, 14 other requests are refused, among them dropping an item or gold to the ground, using an item from the inventory or the belt, giving an item to the mercenary, identifying, and interacting with anything else.
  • Taking an item back off the offer page locks both players for ten seconds. Seen: the copy left the partner’s view page, both records got the same lock time, an accept pressed during the lock was refused, and once the lock had passed both were open again and the accept went through. The value of ten seconds, and the re-test every 25 frames, are read from the code. The lock is real time, not game frames, as are the one-second and five-second windows above (read from the code).

A player offers gold with the window’s gold button.

  • The offer is clipped when it is made, to what the receiver can still carry under its gold cap (the character level times 10 000). Seen: a 9 000 offer above the receiver’s room was stored as that room, and the receiver ended at exactly its cap of 800 000 with nothing dropped. The commit moves the amount as stored (seen).
  • Read from the code: offering more gold than the player carries closes the trade, unless either player has a move or a rebuild pending; then the offer is clipped and stored as above. No case reached it: in the run no amount above the offering player’s gold reached the server (an entry typed as 150 000 arrived as 95 000, that player’s gold).
  • A gold offer on its own changes no state. Seen: none of the 113 logged gold messages moved a state. That a partner’s accept survives a gold offer is read from the code and was not reached: in the run every amount came right after an un-accept from the same player, which the client sends when the gold button is clicked, so in the run offering gold took both accepts away.

Each player presses accept once.

  • Seen: an accept moves that player to “accepted”. When the partner is already there, the second accept starts the commit at once, with the second player to accept taken first.
  • Seen: an accept pressed during the ten-second lock was refused, with a message, and the state stayed. By the reading the accept is refused in the same way while a move is pending, outside the open state, or with an item on the cursor; those refusals were not logged.
  • What takes an accept away. Seen: the un-accept button, any item move request (above), and a refusal at the commit. Read from the code: putting an item on, or taking one off, the offer page while either player has accepted; in practice a placement follows a pick-up, which has already un-accepted both, so this is hard to reach. A gold offer alone does not (above).

When both have accepted, the server runs its checks in a fixed order, then makes the swap.

  1. Gold. Each offer is tested against the giver’s carried gold and the receiver’s cap (read from the code; never reached, since the offer is already clipped when it is made).
  2. Room. The server copies both players’ inventory grids into two scratch grids and fits each side’s offer into the other’s copy. If one does not fit, both gold offers are set to zero, both players get a “no room” message (which one names the receiver and which the giver depends on the side), and the commit is cancelled. Seen once, for the offer of the player who accepted first: a 2 × 4 axe offered to a player with no two free columns side by side; nothing moved. A failure of the second accepter’s offer was not reached.
  3. Quest items. Each offered item passes the quest gate (read from the code; no refusal reached).
  4. The moves. Both players are marked as ending, then the second player to accept has its offer placed into the partner’s inventory, then the partner’s offer into the second player’s (seen in that order in the worked example below). Each placed item is a new copy on the receiver’s inventory page (seen at each exchange). After a half is placed, its giver’s offer and view pages are emptied (read from the code; the emptied pages are seen at the end of each exchange).
  5. The gold moves, the second accepter’s offer first by the reading, the records are freed and the trade ends. Seen as an exchange three times; the order of the two gold moves is read from the code.

The room test and the real moves search the grid differently. The test uses the first spot that fits, the order the search uses for any owner that is not a player, because the scratch grids have no owner. The moves place into the player’s own inventory with the player’s best-scored spot. Seen: every scratch cell of the five logged commits sat where the first-fit order puts it, and every real placement where the best-spot order puts it. So the two can disagree:

  • The test passes and a move fails. Seen (the worked example below): the test passed, the first half moved, the second half ran out of room at its fourth item, and the cancel took the moved item back from its receiver.
  • The test refuses an offer the moves would have placed. Found on the inventory model, not run: a page holding a 2 × 1, a 1 × 4 and two 1 × 3 items, with three 2 × 2 items offered; first-fit fails the third, the best-spot order places all three. The spec keeps the first-fit test as the game’s behaviour.

A worked example from the run. Page 0 is 10 wide and 4 high. The joiner’s page holds a 2 × 2, a 2 × 4 and two 2 × 3 items and it offers one 1 × 1 gem; the host offers four 1 × 2 wands and holds one 2 × 4. The joiner accepts last, so its gem moves first.

Step Search Cells (column, row) Result
room test: the gem into the host’s copy first fit (7, 0) fits
room test: the four wands into the joiner’s copy first fit (2, 0), (2, 2), (9, 0), (9, 2) fits: the test passes
move the gem to the host best spot (7, 3) placed
move the wands to the joiner best spot (9, 0), (9, 2), (2, 1), then none fails: the free cells (2, 0) and (2, 3) are not next to each other
cancel both inventories from the snapshots the gem back with the joiner

Every cell in the table is a logged value that the two search orders predicted.

Every way out except the exchange, and except the cases the next table says leave the trade alone, puts both inventories back from the snapshots taken when the window opened.

  • Seen: the whole inventory is rebuilt, not just the offer. After each logged restore (a close, the two cancels at the commit, the partner in the two aborts) the item list had its opening layout, and no item id from before the restore survived: items moved on the inventory page during the trade go back to their opening cells, and every item comes back as a new unit with a new id.
  • Read from the code: the carried gold is set back to the gold at opening, except for a player with no gold or a dead one, who keeps its gold. The trade moves no gold before the commit, so in the run the restored gold always equalled the opening gold.
  • Unknown: whether the item units the restore throws away, and the hidden copy of an item taken back, are freed.
Way out What happens How it is known
The exchange items and gold swapped, the window closes seen (three exchanges)
Closing the window (Escape or its close button) both rebuilt from the snapshots, both end, both five-second windows restart seen
A refusal at the commit both rebuilt, offers and gold set to zero, the window stays open, empty seen (two cancels)
A player’s client leaves the game for a dropped client the server saves first, then both are rebuilt and both end seen for a client that was killed (twice); the leaver’s own rebuild is read from the code, and whether the other ways of leaving save first is not read
A player dies both rebuilt, both end, as for a leaver but with no save first read from the code
Offering more gold than carried; an offer copy that cannot be placed the window closes as on a close read from the code
Accepting the request again inside an open trade the window closes; while a move is pending, after a short wait that ends once neither player has one read from the code
The Act IV end move it presses a button that does nothing: the trade stays read from the code
Waypoint travel no trade code runs: only the traveller’s link to the partner is cleared, both trades stay recorded read from the code; whether a client can send it while trading is unknown

Read from the code: if a leaver’s partner no longer names the leaver (after waypoint travel, say), the leaver’s link is cleared and nothing else happens: no state change, no rebuild, and the records stay.

After a close, an abort or the exchange both players step through two “ended” states back to idle (seen; one frame apart by the reading). A cancel at the commit steps back to open the same way. Timing question: in one cancel of the run its two steps ran inside one logged frame, where the rule (and the other cancel) gives one frame each. The states and their order agree; the frame delays stay read from the code, and the mismatch is an open question.

By the reading, a player saved while its trade record is open is saved with its items as they were when the window opened, and its carried gold as it is.

  • Seen: at the two dropped clients the server saved both players before ending the trade, and each of the eight copies the save code took was that player’s opening snapshot, for the leaver and for the host alike.
  • Read from the code: before the window opens (only a request) the live item list is saved.
  • Not observed: which of the save routes those saves took, and the file written: the leaver’s save file on disk was not rewritten during that session.

In the table below only the potions draw; each other count holds up to the point named, and no whole move is bounded. What is established, by how:

Path Draws How it is known
Healing and mana potions 2 per life or mana amount slot with vitality or energy above 0, on the user’s seed emulated before the first call; seen for 17 uses
Kinds 4, 5, 8, identify (both requests), the cube, a key 0 before the first call into another function emulated; nothing after the first call is covered
Kinds 2, 6, 9 0 in the entry’s own body read, direct calls
The gate 0 on this path read
The placement search, belts, stack tests, the grid rows 0 to their returns, no traced access to a unit’s seed emulated
The ground search, walk, expiry and distance no seed is given read: none of the functions below them holds a seed step, with indirect calls unfollowed
Cursor drop and item to cursor the player’s and the game’s seeds unchanged seen, 80 of 80 pairs each
A trade’s item copies unknown whether copying an offered item draws from any seed was not read

Beside the search there are draws: a chest-spawner missile draws twice on its unit’s seed for an offset, two shrines step a unit’s seed, and a target player’s belt item taken to the ground draws once and may then stop (read from the code; an inline scan of the 20 callers; calls to the random functions inside them were not scanned). No move’s own body holds a draw, but a whole move’s bound is open: the closures under the moves hold 2 096 to 2 122 functions, 118 of which hold a seed step, with indirect calls unfollowed. And a monster’s drop inside a death: no seed trace through the drain was built; how the item itself is made is on the items page.

From the specs’ open questions. The first three need a further session in a game, and none is planned.

  • The blend of different amounts. What a second potion of a different strength does while the first runs, with the meter below its maximum both times, is a reading; the one blended use in the game had the same potion twice. The free of a potion’s list at the maximum was not logged either.
  • Potion types for the hireling. The reading is that a mana potion given to the mercenary by the belt flag or by the mercenary button is refused: only three potion types pass the code’s test, and the mana potion’s type is not one of them. It was not run. A community text says a hireling takes health, mana and rejuvenation potions; the reading and that text disagree, and 1.14d has not been tried.
  • A death with a belt holding items above the fourth box. The reading is that they go to the inventory, then to the ground; not run in 1.14d.
  • The mana potion’s doubled branch in a game (5 of 5 seen undoubled); every class’s factors but the Sorceress’s; the greater health potion; a rejuvenation on a maximum above 4 096.
  • Other use cases never run: the group clear on the antidote, thawing potion, stamina potion and herb; the Blood Golem split; both identify requests; a belt identify scroll and the town portal’s column shift; the cube; a usable row with no kind; a key on a chest and a door; a potion to the mercenary; a use while trading; the elixir; the four quest codes. What the items’ use does after the first call into another function is unbounded for draws, apart from the 17 uses.
  • Ground cases never run: two requests in one batch, requests from a dead player, pickup at the edges of the reach and behind a wall, a stack remainder on the ground, a scroll into a tome, auto-equip, a dropped cube and the chest spawner’s two draws. A drop at the seam between two rooms in a crowd, a full surround and a null result, and a drop at a room’s edge are only emulated.
  • Grid and belt cases never run in a game: sequential pickups, a full inventory’s message, the cube, the stash’s size by game type, the refusals of placing on a page and of taking to the cursor, belts by type, an inventory item to the belt, a belt taken off, stack merges, a tome’s skill quantity and the moves’ seeds.
  • Expiry cases: gold’s 10 000 boundary, a quest item, a socketed item, a sweep’s removal message and seed, qualities above 2 on a first drop, a longer life for a monster’s drop, whether a chest’s drop was among the 27.
  • Stock routes of two forced requests: the stash placement with no stash open and a belt box beyond the belt’s count each ran only with a written packet field.
  • What an elixir’s value comes from and which object classes the two last grid rows belong to are not known.
  • Trade cases never reached: the refusal outside town; an overspend and a gold offer while the partner has accepted (an unmodified client sends neither); the re-accept states and their wait; the room test failing on the offer of the player who accepted last; the gold and quest refusals at the commit; the first half of the moves failing; an offer copy that cannot be placed; a death during a trade.
  • The trade’s timing mismatch: in one cancel two steps ran inside one logged frame, where the rule gives one frame each. One lead is that the logged frame number belongs to the outer loop; a run logging the frame at the event pass would settle it.
  • Trade questions of the code: which save route a dropped client takes and the file it writes; whether a trading player’s client can send waypoint travel; whether the units a restore throws away are freed; when three other placement paths (a belt’s overflow, an emptied cube’s drop, a page swap) show an offer to the partner; whether a trade’s item copies draw from any seed.

Two community texts differ from 1.14d, and the specs keep the code’s reading. One says the belt table’s box rectangles are “for server verification”: by direct calls no 1.14d server code reads them. The other says potions are scaled by class columns of a table: 1.14d’s table has no such column, and the scale is in the code, as above.