What changed
The Android touch overlay can draw a remaining-ammo number on the skill buttons — the count of the equipped quiver or throwing weapon, green above 50, red at 50 or less.
dm/host/dm_ammo.c/.h(new): resolves the ammo source, and decides whether a skill burns ammo.dm/host/diag.c:hud_tickpublishes the ammo source every tick (from the server-side player, see below).dm/host/dm_actions.c/.h:dm_swapskill_face_slot()— reads the face→slot table directly, plus a fallback (see the caveat).dm/android/touch_android.c,TouchOverlay.java: wire the number into the per-button draw call.
Why
The game does warn about low arrows, but the warning sits in the screen corner and the port's own buttons cover it while your thumb is on the button — you notice when the quiver is nearly empty. A number on the button itself is where the eye already is.
How the count is read
- stat 70 (quantity) on the item itself. Measured on the device: three shots took the quiver 85 → 82. Same convention
diag.calready uses for the town-portal tome. - Equipment cells 4 / 5 / 11 / 12. A main hand (cell 4) carrying a count = throwing weapon; otherwise cell 5 being a quiver (item code
aq/cq) = bow/crossbow; then cells 11/12. The weapon-set flag is not used:[[player+0x10]+0xf0]+0x5a0was measured jumping between −1/0/1 while the equipment cells swap as a block on every weapon change (cells 4/5 ↔ 11/12), so picking cells by that flag gets the other set's quiver. - Quiver total = the worn quiver + every quiver of the same code in the backpack (page 0, mode 0). The game refills the off hand by itself when a quiver runs out, so the total is what the player wants to see. Arrows and bolts are counted separately.
- Must be read off the server-side player. The client copy of the inventory has no equipment-page array (
swapskill_pumpgets the client player); reading the same offsets there worked only on occasional frames, which is why the digits never settled.hud_tickpublishes it every tick (same place asdm_swapskill_srv_wset); the pump only reads the published value.
Which skills show a number
Skill-id lists taken from kolbot's skills.txt (d2bs/kolbot/sdk/skills.txt), cross-checked against four ids measured on the device — 6 Magic Arrow, 12 Multiple Shot, 22 Guided Arrow, 32 Valkyrie all match, so D2R 3.x keeps this id set.
- Bow: 0, 7, 11, 12, 16, 21, 22, 26, 27, 31
- Throwing: 2, 15, 20, 25, 35
Magic Arrow (6) is deliberately absent: it is the one bow skill that burns nothing, even though its itypea1 is the same bow requirement as Multiple Shot, so the data table cannot tell them apart. Melee javelin skills and a throwing weapon's normal attack (a close-range stab, measured) do not consume the count either. An unknown skill id shows nothing — better no number than a wrong one.
Caveat: getting the slot for a button
The port's own skill-button readout needs an "all six faces observed" snapshot (dm_tg_group_observe, seen == 63). With an empty skill button the game never queries that face, so the six never complete and the front end gets slot = -1 — the digits never appear. This change falls back to the face→slot table (main+0x2d13cbc), and when that reads back all zeros (it does on my device) to the face index itself, trying both skill sets and keeping the one with content. This is a workaround, not a fix — I did not touch the snapshot mechanism. If you would rather fix dm_tg_group_observe, this part can be dropped or replaced with one line.
Tested
OnePlus Ace 5 Pro (PKR110), Adreno 830, ColorOS, system driver 0x8032004a — an Amazon with a bow and with javelins:
- digits follow the quiver when shooting, and when the game auto-switches to the next quiver
- bow/crossbow and throwing weapon both resolve; the number disappears when switching to a melee weapon
- steady 59.99 fps, no crash over the session
Not tested: iOS (this front end is Android-only), HarmonyOS, other GPU families, and a character carrying two quivers of different codes in the backpack.
Checks run
-
python3 dm/ios/tools/dm_i18n.py --check→dm_i18n OK 486 条 -
python3 dm/i18n/scan_literals.py→ fails on this tree without my change: 25 lines, all fromdm/ios/Sources/s2a_pack_apply.c(the 2.3.1 S2Arm push path). None of the files touched here appear in that output; the only new on-screen content is digits. -
make -C dm/host/tests run— not run (needs a./setup.shworkspace, and this is a Windows host) - everything else — not run (Windows host)
Visible changes
- Something on screen changes — digits on the skill buttons; screenshot above (full screen also: here)
- New on-screen text — none, only numbers, so
ui_text.tsvis untouched anddm_i18n_tab.hwas not regenerated
No game content
- No game files, nothing generated from game files, no keys, no built package
Activity
6Read through it. The design looks careful: it reads from the server-side player in hud_tick, publishes to the pump, adds dm_ammo.c to SRC so the iOS and HarmonyOS builds pick it up as well, and shows nothing for an unknown skill. Two notes:
- Barbarian Double Throw (140) also uses up the thrown weapons (one from each hand) but isn't in
k_throw, so a throwing Barbarian gets no number. Left Hand Throw (4) is the same case, though rarer. - The face → slot fallback guesses the slot from the face index when the table reads all zeros. That can put a number on the wrong button after a rebind. As you say, it's a workaround. If the
seen == 63snapshot can't be fixed here, maybe show the number only when the table gives a real slot.
The ammo IDs for the Amazon match the skill table (0 with a bow, 7, 11, 12, 16, 21, 22, 26, 27, 31; 2, 15, 20, 25, 35), and leaving out Magic Arrow (6) is right.
Both points are in (38230d5).
-
Double Throw (140) and Left Hand Throw (4) are now in the throwing list. The ammo source also records the off-hand throwing weapon's stat 70, so the two skills do not report the same number: Left Hand Throw reuses the off-hand count (and shows nothing when the off hand is not a throwing weapon), while Double Throw reports the smaller of the two — the hand that runs out first.
-
The face-index slot guess is off by default. A number now appears only when the slot comes from the binding data (
g.slot) or from the face mapping table (dm_swapskill_face_slot). The guess stays available behindDM_AMMO_FACE_FALLBACK=1infiles/dm/env, documented in the code as a workaround for the device where that table reads back all zeros — if you would rather not carry the switch at all, say so and I will drop it.
Built full-clean on Windows (deleted .cxx, ninja and clang killed first): BUILD SUCCESSFUL. No test files are touched by this patch.
Thanks, both points are covered in 38230d5.
- Double Throw / Left Hand Throw: good. Left Hand Throw reads the off hand, and Double Throw takes the smaller count.
qty2can't go stale when the off-hand weapon is removed, becausedm_ammo_source_rawclears the whole struct at the start of every read. - Face-index fallback off by default, behind
DM_AMMO_FACE_FALLBACK=1: that's what I had in mind.
The maintainer's host gate passes on this head (built on Linux in a container): mode_scan.py clean, t_hid_receipt 5/5, t_hid_script 37/37, t_touch_mac 39/39. No further comments from me. I didn't run it on a phone.
An installable build of this branch: https://github.com/Diablo-chia619/d2r-mobile/releases/tag/own-2.3.1-ammo-only-1
2.3.1 base + this PR only — no other patches (no dispatch guard, no touch-stick change, no bundled driver). Debug-signed, package id
com.xiaoboluo.d2r.own(installs alongside the official app), no game content in the APK — you still need your own import pack.Two things I would look at first in review: the
dm_swapskill_face_slot()fallback (the port's own snapshot path is what fails — see "Caveat" above), and the skill-id lists, which come from kolbot's table plus four anchors measured on the device, not from anything in the game files I can point at.