# Active item / card / pill dispatch (rif/items-verify) `use_dispatch.tsv` (repo root, from `scripts/use_dispatch.py bin/isaac-ng.exe repentogon/libzhl/functions/Global.zhl`) maps every id to its case: `kind id enum target label anchor shares`. `find.sh active|card|pill ID [N]` prints the case, and also the block under `LAB_:` when Ghidra put the code there (a case that is only a `goto`, e.g. Mom's Shovel / We Need To Go Deeper, Glass Cannon's `goto LAB_005b7f60`). The table is read from the exe's jump tables, so it is exact; only the label (the regex finding the case in the C) depends on how Ghidra printed the switch. ## Entity_Player::UseActiveItem (0x5b39d0) dispatch at 0x5b3c77 - Prologue: id 0x3b (Book of Belial passive, Judas' birthright) is used as 0x22 (Book of Belial). Negative ids (TMTRAINER glitched items) go to 0x9e01b0 instead of the switch. The use is passed through Lua first (0x863760: a callback returning true skips everything). - `id > 0x11a`: table B, `id - 0x11b` in 0..0x1be, byte index 0x5c7760, jump table 0x5c7598 (114 slots, slot 0x71 = default). Ghidra could not normalise it ("Could not find normalized switch variable to match jumptable") and labels its cases with the SLOT (`case 0:` .. `case 0x71:`, sometimes decimal: Abyss is `case 99:`, Suplex `case 100:`). This is why the old `find.sh active` missed every id from 283 (D100) up. - `id == 0x11a` (How to Jump): an `if (pEVar47 == 0x11a)` before switch A. - `id - 0x21` in 0..0xe6: table A, byte index 0x5c746c, jump table 0x5c73a0 (51 slots); Ghidra labels these with the real id (`case (Entity_Player *)0x21:`). - Default 0x5c71f1: log if the id is out of range, then the common tail. - Common tail LAB_005b54d1: Lua MC_USE_ITEM, AnimateCollectible when the case asked for it, RemoveCollectible for single-use (flag 0x40), cache flags from the item config (+0x54) then EvaluateItems, **TemporaryEffects::AddEffect of the item unless the case cleared the flag** (local_60a, default 1), AddCostume; 0x246 (Glowing Hourglass) and 0x2c0 (R Key) extra calls. - Shared cases: Pony 130 / White Pony 181, Candle 164 / Red Candle 289, D6 105 / Eternal D6 609, We Need To Go Deeper 84 / Mom's Shovel 552, Gamekid 93 / Esau Jr 703, Crack the Sky 160 / Book of Virtues 584 (a shared case tests the id where they differ). - Actives with no case at all (only the room TemporaryEffect, read through `HasCollectibleEffect(id)` elsewhere; use `find.sh item ID`): 77 My Little Unicorn, 137 Remote Detonator, 298 Unicorn Stump, 474 Broken Glass Cannon, 516 Sprinkler, 655 Spin to Win (and the unused 43). - D Infinity (0x1e9) uses one of 10 dice from table 0xb1f450 through a recursive UseActiveItem, then a small second switch at 0x5bfbd8 (id - 0x11b, byte index 0x5c79c4, table 0x5c79b0) for the dice's after-effects; that is not a dispatcher. ## Entity_Player::UseCard (0x7b2230) and UsePill (0x7c4180) - UseCard: `card - 1` in 0..0x60, jump table 0x7b8a00, default 0x7b8949; cases labelled with the card id. Ace of Clubs/Diamonds/Spades/Hearts (27-30) share one case. A nested switch inside the Reverse Hermit (0x41) case has its own `case 0x45:`, so the first match of `case 0x45` is not Reverse Death: find.sh matches only indent 2..4. - UsePill: the pill EFFECT (already resolved from the colour by the caller), 0..0x31, jump table 0x7c77e4, default 0x7c7528; horse pill = local_204 (bit 0x800 of the use flags), labelled with the effect id.