Files
isaac-port/notes/systems/rules_economy.md
T

100 lines
8.3 KiB
Markdown

# Rules research: economy (shops, machines/beggars, item pools)
Flash = isaac-classic's engine + base data (Eternal Edition); Rep+ = isaac-ng.exe 1.9.7.17. Engine paths are
isaac-classic's (`src/game/...`, `resources/data/...`). "unverified" = not read to the end.
## Room::init_shop_item_slots (Function 0x813d90)
Fills RoomDescriptor+0x94..0xa2 (8 int16 shop slot types), +0xac ShopItemIdx (reset 0), +0xae sale slot.
- Normal shop (not Greed, not subtype 100..119): list 0..7 (+8 when Room+_shopLevel > 3), RNG::Shuffle, first 8 to
slots 0..7, then slot (rand & 1) (0 or 1) forced to 8. Sale slot: rand % 3 == 0 -> none (-1), else rand % 6.
- Devil/black market/devil-flagged room: all slots 8, sale none 1/3 else % 6. Angel (0xf, Stairway): shuffle
{8,4,4,3,3,0x13,0x13,0x14}, slot 1 = 8. Room subtype 100..119 (T.Keeper shops, unverified): {0xb,3,1,6,5,2} shuffled
around fixed 8,9,10. Secret shop (room idx -13): {8, 0xc|0xd (1/2), 9 (7/8)|0xe, 0xb, 0xb, 0xf, 6, 0x10}. Greed: 3,0,8,9 + 4x
greed_shop_slot_type (greed.md).
- Shop level (Room::Init 0x7f2800): 1 + Store Upgrade achievements 0x97..0x9a (all four -> 5); Greed = stage.
## pickup_roll_random_variant (Function 0x814a50)
Shop stand (5.150) i takes slot type `descriptor+0x94[i]` (i = ShopItemIdx & 7, spawn order): 0 red heart 10.1, 1 bomb
40.1, 2 pill 70 (GetPill), 3 key 30.1, 4 soul heart 10.3, 5 lil battery 90.1, 6 card 300 (GetCardEx(seed,25,0,10,1)),
7 grab bag 69.1, 8 item GetSeededCollectible (room pool: shop 1), 9 boss pool 2, 10 treasure 0, 0xb trinket, 0xc devil 3,
0xd angel 4, 0xe secret 5, 0xf heart 10.6/4/12/11, 0x10 rune/card, 0x11 shop pool 1, 0x12 baby shop 0x1c (Adoption
Papers turns 8/0x11 into 0x12), 0x13 eternal 10.4, 0x14 rune or key. Greed swaps pools to 0x10.. .
## Room::GetShopItemPrice (Function 0x8151e0), _Room::ResolveHeartSubType (Function 0x816250)
Coin prices (shop, not devil room / black market / devil-flagged / shopItemId -2): heart 10.1/10.2 -> 3; golden
bomb 40.4, golden key 30.2 -> 10; grab bag 69 -> 7; collectible -> items.xml shopprice (default 15; angel room 0xf:
shopprice 15 with devilprice 2 -> 30); everything else 5. Keeper (types 0xe/0x21) / Keeper's Bargain (171) /
A Pound of Flesh (0x2a0) change these (content). Devil pricing: -devilprice (1 or 2 hearts), tag 0x200000000 -> -10.
ResolveHeartSubType, coins: n = Steam Sale (0x40) count, +1 when nobody has one and this is the sale slot (+0xae) or a
temporary Steam Sale; Keeper's Bargain x3 on a devil room 1/3 +1. price<6: ceil(p/(n+1)); p>=6 and n==1: p/2
(floor); else ceil(p/(n+1)). Store Credit (13) in a shop: -1000 (free). Restock count u (+0xa4[slot], Restock/restock
machine, non-Greed only): + max(1, base/7) * (u+1) * u / 2, capped 99. Adoption Papers (184) on slot type 0x12: 2/3.
Hearts: no containers -> -3 (3 soul hearts); a 2-heart deal with fewer than 2 containers -> -4 (1 heart + 2 soul);
??? (player type 4) -> -7/-8 (1 or 2 soul hearts); Judas' Tongue (0x38) -2 -> -1; Your Soul (0xad) -> -6.
## Level::place_special_rooms (Function 0x739370) shop branch
Shop placed on stage < 7; stages 7-8 only with Silver Dollar (0x6e), Sheol with Bloody Crown (0xa1), Cathedral with
Holy Crown (0x9b). No Steam Sale late-shop rule. Shop room subtype = rand%(1+a97+a99) + rand%(1+a98+a9a) (0..4 with
all upgrades); then if (rand&1)==0 or not hard: subtype = max (4). 1/256 rare shops (subtype 10/11, Store Key
changes this; unverified). So unlock-free normal mode always uses the level-5 (subtype 4) shop layout.
## Entity_Slot::Update (Function 0x65d950), HandleCollision (Function 0x6627e0), spawn_break_drops (Function 0x663aa0)
Slot machine (6.1), at WiggleEnd: seed%50==0 breaks (explosion + break drops). Else r = rand%21 + 3 (Lucky Foot 46,
or trinket 76 3/4 of the time: rand%15 + 3). r==9: kept 3/10 else 11. r==10: kept 5/10 else 11. r>9 (not a kept 10):
9/10 r+1. r==7: 1/3 -> 11. Daemon's Tail (22) r 5/6 -> 11 4/5. Hard mode: 1/2 r = 0. Prizes: 3 fly (1/3 Pretty Fly
else attack fly 13.0), 4 bomb, 5-6 heart, 7 key, 8 pill, 9 Dollar (18) + machine breaks, 10 Portable Slot (177,
removed from pools) + breaks, 11-13 max(1, rand3) coins, else nothing. Per 21 plays: fly 1, bomb 1, heart 2, key .667,
pill 1, Dollar .3, Portable Slot .5, coins 3.633 (draws), nothing 10.9.
Fortune machine (6.3): threshold 0.65 (hard 0.85; Lucky Foot or trinket 76 1/5: x0.46); RandomFloat < threshold:
fortune (< 0.002 special). Else 1/20 break (+drops), 1/30 Crystal Ball (158) + break, 1/3 card, then 2/3 trinket,
1/3 soul heart (Daemon's Tail 4/5 -> trinket).
Beggar (6.4) / Devil Beggar (6.5): pay 1 coin / take 1 damage (half heart). counter (Init 0) += 1; threshold =
rand4 + rand4 + rand2 (hard: max(5, that)); payout when counter > threshold; counter = rand2 + 2 (+1 Lucky Foot).
Beggar prize: 1/2 resource (1/3 heart, else key or bomb 1/2), else 1/2: card 1/2 / food item 22+rand5 1/2 (Lost
types: beggar pool), else beggar pool (10) item and leaves. Devil beggar: 1/2 pill-or-card, 1/8 trinket, 3/8 demon
beggar pool (11) item and leaves.
Blood Donation (6.2): 1 damage; Prize: 1/100 Child's Heart (34) while in the trinket pool; else 1/15 IV Bag (135) or
Blood Bag (119) 1/2 + break; else coins max(1, rand3) (hard: max(1, rand2) = 1), +1 with PHD (75).
Shell game (6.6): 1 coin; prize one of 4 (DAT_00b64c08), 1/13 item (needs Skatole 9 available); win 1/3 (Lucky Foot
1/3 again, trinket 76 1/20); coins rand2+2, else 2.
Break drops (slot/fortune/beggar default): 1/5 pill or trinket; 1% chest, 1% locked chest; else max(2, rand4) drops
(+1 Lucky Toe 2/3): <.35 1-3 coins, <.55 heart (1/2 uses no count), <.7 key, else bomb; trinkets 45/44/34/41/36
(25/50/100% by multiplier) replace with their pickup. Blood machine: 1..2 rolls of heart or 1-4 coins.
Key Master 7, Bomb Bum 9, Battery Bum 13, Rotten Beggar 18, Restock 10, Crane 16, Confessional 17: Rep+ content.
## ItemPool::GetCollectible (Function 0x733610), pick_weighted (Function 0x732fa0), RemoveCollectible (Function 0x733ff0)
31 pools from pools.xml; entry {id, Weight, running, DecreaseBy, RemoveOn}. Draw: roll = RandomFloat * total base
weight, walk cumulative base weights, accept with chance running/base and only if not in the removed bitset (+0x67c,
global) nor the room blacklist (+0x68c), Item::IsAvailable(-1) (tags/achievements/challenge), flag filters; refused
-> rescale and repick (budget 10, 20 with flag 2, +6/5/4/3/2 by flags 0x10..0x100), then a linear scan. Taken: running
-= DecreaseBy, below RemoveOn -> running 0 + global removed bit; the room blacklist bit too. GetCollectible retries 20
re-seeded picks, then default -> fallback pool or Breakfast (25). No power/quality weighting, no familiar limit, no
"seen" 1/5 rejection, no refill. Pedestal pickup (Entity_Pickup::HandleCollision 0x6e8ae0) and starting items
(Game::add_players, apply_innate_collectibles) RemoveCollectible too. Chaos: get_chaos_pool 0x737010.
Room -> pool (GetPoolForRoom 0x732dc0, get_pool_from_room_entities 0x7ebe20): treasure 0, shop 1, boss 2 (boss with
BossID 23 or level flag 0x20000 -> devil 3; boss challenge -> 2), secret/super secret 5, curse 12, normal challenge 0,
library 6, devil 3, angel 4, chest room 8, black market 1, planetarium 26, ultra secret 24, error room random. Boss
rooms: no fixed per-boss items (no Little Chad/Gish/Steve, ponies, Cube of Meat, Mom's Purse rule); one boss pool for
every chapter. Sins' item drops (TriggerBossDeath 0x7fec00, bossType 0x2e..0x34) belong to the drops area.
## Port comparison and proposals
See the rules research report (rules_economy). Port side: `src/game/items/item_pools.cpp`, `machines/*.cpp`,
`resources/data/{itempools,rooms,entities}.json`, `repentance_plus/*`.
## Ported to isaac-classic (rif/shared-rules)
Rules: shops stock shuffled into the stands, the item in slot 0 or 1, one sale stand rand%6 unless 1/3 (rooms.json
shop item_slots / sale_none_one_in / sale_slots; pill and card are both the engine's pocket ware); beggars count first,
reset to 2 + rand2 (+1 Lucky Foot), hard threshold at least 5, devil beggars count too; pools: no seen rejection, no
familiar limit, no power weighting. Content: Rep's items in the normal pools by itempools.xml (tools/rebirth_items.py
--pools: treasure -> general and challenge, goldenChest -> chest...), normal floors' shops of level 5 (shop4).
Left: battery and grab bag wares, Steam Sale stacking, restock pricing, slot/fortune/blood machine odds, beggar pools,
remove-everywhere draws and Breakfast, pool weights below 1.