From cfa70b3d022095144ce9caee62887ce5f5235c44 Mon Sep 17 00:00:00 2001 From: jhaizhou <258432107+jhaizhou-ops@users.noreply.github.com> Date: Wed, 14 Oct 2026 13:46:32 +0800 Subject: [PATCH] Greater Rift: invading act bosses from level 80 (second segment of #26), Guardian count on the top bar, boss-summoned units keep original strength; touch: floating stick measured from the touch-down point, item descriptions move beside the inventory; rewriter output r43 --- dm/PRODUCT | 2 +- dm/host/diag.c | 1 + dm/host/dm.h | 2 +- dm/host/dm_cursor.c | 41 ++++++++-- dm/host/dm_i18n_tab.h | 6 ++ dm/host/dm_rift.c | 121 ++++++++++++++++++++++++++--- dm/host/dm_rift.h | 2 +- dm/host/tests/t_rift_next.c | 12 +++ dm/host/tests/t_rift_oldrun.c | 6 ++ dm/i18n/ui_text.tsv | 6 ++ dm/ios/Sources/dm_rift_hud.m | 3 +- dm/ios/Sources/dm_touch_controls.c | 21 ++--- dm/ios/Sources/dm_touch_controls.h | 3 +- dm/ios/tests/t_touch_controls.c | 45 ++++++++--- dm/tools/patch_nso.py | 1 + 15 files changed, 234 insertions(+), 38 deletions(-) diff --git a/dm/PRODUCT b/dm/PRODUCT index e7d16f0..66c4f3c 100644 --- a/dm/PRODUCT +++ b/dm/PRODUCT @@ -1 +1 @@ -3.3.94012-r42 +3.3.94012-r43 diff --git a/dm/host/diag.c b/dm/host/diag.c index b1a0e7d..82b04d7 100644 --- a/dm/host/diag.c +++ b/dm/host/diag.c @@ -438,6 +438,7 @@ static void setlang_obs(const uint64_t *regs) { void probe_install(void) { if (gate_obs_present(OBS_SETLANG)) gate_obs_set(OBS_SETLANG, setlang_obs); if (gate_obs_present(OBS_EVENT_MSG)) gate_obs_set(OBS_EVENT_MSG, event_msg_obs); + { void dm_ui_tooltip_obs(const uint64_t *regs); if (gate_obs_present(OBS_TOOLTIP)) gate_obs_set(OBS_TOOLTIP, dm_ui_tooltip_obs); } // 说明框停靠(dm_cursor.c) | tooltip docking (dm_cursor.c) const char *ui = getenv("DM_UIMSG"); if (ui && strcmp(ui, "1") && !(g_uifp = fopen(ui, "w"))) die("DM_UIMSG 打不开 %s", ui); g_ui_print = ui != NULL; diff --git a/dm/host/dm.h b/dm/host/dm.h index c5672a2..38ac7e8 100644 --- a/dm/host/dm.h +++ b/dm/host/dm.h @@ -54,7 +54,7 @@ module_t *module_of(const void *p); uint64_t gate_dispatch(uint64_t ret_addr, uint64_t *regs); // 观测门(改写器 OBS 表;编号与 patch_nso.py 一致):只读回调,挂上即在门命中时调用 // Observation gates (rewriter OBS table; numbering matches patch_nso.py): read-only callbacks, called on a gate hit once attached -enum { OBS_UIMSG = 1, OBS_TICK = 2, OBS_C2S = 3, OBS_C2S_SYS = 4, OBS_SETLANG = 5, OBS_TARGET_RANK = 7, OBS_UI_PROJECT = 8, OBS_FREEZE_WORLD = 10, OBS_FREEZE_CLIENT = 11, OBS_FREEZE_ANIM = 12, OBS_FREEZE_RENDER = 13, OBS_TEXTBOX = 14, OBS_EVENT_MSG = 15, OBS_LEVEL_WARP = 16, OBS_QUEST_KILL = 17, OBS_NOTICE_INPUT = 18, OBS_ERR_SMOOTH = 19, OBS_MODEL_YAW = 20, OBS_MAX = 21 }; // 6 = iOS 绑定读取(dm_touch_game_bridge.c) | 6 = iOS binding read (dm_touch_game_bridge.c) +enum { OBS_UIMSG = 1, OBS_TICK = 2, OBS_C2S = 3, OBS_C2S_SYS = 4, OBS_SETLANG = 5, OBS_TARGET_RANK = 7, OBS_UI_PROJECT = 8, OBS_FREEZE_WORLD = 10, OBS_FREEZE_CLIENT = 11, OBS_FREEZE_ANIM = 12, OBS_FREEZE_RENDER = 13, OBS_TEXTBOX = 14, OBS_EVENT_MSG = 15, OBS_LEVEL_WARP = 16, OBS_QUEST_KILL = 17, OBS_NOTICE_INPUT = 18, OBS_ERR_SMOOTH = 19, OBS_MODEL_YAW = 20, OBS_TOOLTIP = 21, OBS_MAX = 22 }; // 6 = iOS 绑定读取(dm_touch_game_bridge.c) | 6 = iOS binding read (dm_touch_game_bridge.c) void gate_obs_set(int id, void (*fn)(const uint64_t *regs)); int gate_obs_present(int id); void dm_quiet_difficulty_msg(int on); // 秘境局里拦原版「游戏难度设为 N」提示(观测门 15,diag.c) | In a rift run, block the original game's 「游戏难度设为 N」(Game difficulty set to N) message (observation gate 15, diag.c) diff --git a/dm/host/dm_cursor.c b/dm/host/dm_cursor.c index 87ebd31..91389f9 100644 --- a/dm/host/dm_cursor.c +++ b/dm/host/dm_cursor.c @@ -2432,12 +2432,43 @@ static void ui_panel_state_pump(uint64_t root) { // 游戏主线程,每帧 | // 两种模式都跑:ui_target_pump(鉴定目标,含手柄按住 A)、ui_item_pump(命中查询,宿主自己也问)、ui_ptr_pump(指针事件,宿主合成的点击也走)、 // ui_safe_pump / ui_lift_pump / ui_trove_tabs_pump / ui_minimap_pump / ui_map_pump / ui_map_geom_pump / ui_map_center(屏幕几何,与输入方式无关)、ui_boss_pct_pump、ui_npcdlg_pump、 // ui_widestash_pump、mv_audit_pump、ui_pages_pump(含手柄 L / R 翻页)、ui_watch_pump、ui_panel_heal、ui_panel_state_pump、rs_pump(一键重开,在前端泵里调) -// Per-frame pumps fall into two classes by mode (the long line in dm_ui_mouse_pump below; tests/mode_scan.py checks that every pump on that line either has if (tm) or is on this "runs in both modes" list; a new pump in neither fails). -// Touch only (with if (tm)): requests all come from touch gestures: tap world / mercenary portrait, long-press pickup, double-tap use, tap-to-buy, drag and drop, tap skill binding, off-hand set tab, open mercenary page. -// Not run in controller mode or while a mode switch is in progress; in-flight requests are voided by the switch cleanup (dm_ui_cache_mode_leave). -// Both modes: ui_target_pump (identify target, including controller hold A), ui_item_pump (hit query, the host asks too), ui_ptr_pump (pointer events, host-synthesized clicks go through it too), +// 物品说明框停靠(观测门 OBS_TOOLTIP,挂在说明框面板的「提交一条说明」函数入口 main+0xb0d560(面板, 文字, 目标矩形左上 x2, 目标矩形宽高 x3, 样式, 文字 2))。 +// 说明框是即时式的:悬停着的控件每帧重新提交、画完就清,宿主在自己的时机读面板里的记录数一直是 0,所以只能在提交那一刻改输入。 +// 原版把框摆在目标矩形(被点的那一格)正下 / 正上方:长说明(暗金、符文之语,十几行)盖住腰带、戒指、背包中间几列和「存放」钮,要点被盖住的格子得先点别处。 +// 触屏、只开着物品栏一个面板(它居中,左右各有一条「屏幕边到面板内框」的空带,约 0.6 个屏高宽)、光标下是物品时:把目标矩形换成对侧空带顶上的一个点—— +// 物品在面板右半停左带、在左半停右带,框从上往下排;量字、摆放、推回屏内仍是游戏自己做(离屏幕边的距离走布局里的 screenEdgePadding)。 +// 其余一律原样放行:手柄 / 键鼠模式;并排两个面板的页(储藏箱 / 商人 / 魔盒 / 单件槽 / 佣兵页——没有空带);技能、属性、按钮的说明(光标下不是物品);世界里的名牌。 +// 面板内框的半宽 = 0.484 × 屏高(真机截图量:2868×1320 上内框 x 795–2073);顶上让开关闭 X 那一行(0.10 × 屏高)。只许游戏主线程(门回调就在)。 +// 测试开关 DM_TEST_TIPDOCK=1:不看模式(Mac 宿主是手柄版,用它看效果);=0:整个关掉 +// The per-frame pumps fall into two kinds by mode (the long line in dm_ui_mouse_pump below; tests/mode_scan.py checks: each pump on that line either carries if (tm) or is on this "runs in both modes" list, and a new pump on neither list is red). +// Touch only (with if (tm)): all requests come from touch gestures - tapping the world / the mercenary portrait, long press to take, double tap to use, tap goods to buy, drag and drop, tap to bind a skill, the off-hand set tab, opening the mercenary page. +// Not run in gamepad mode or while a switching transaction is in progress; requests in flight are voided by the switch cleanup (dm_ui_cache_mode_leave). +// Run in both modes: ui_target_pump (identify target, including holding A on a gamepad), ui_item_pump (hit queries, also asked by the host itself), ui_ptr_pump (pointer events, also used by clicks synthesised by the host), // ui_safe_pump / ui_lift_pump / ui_trove_tabs_pump / ui_minimap_pump / ui_map_pump / ui_map_geom_pump / ui_map_center (screen geometry, independent of input method), ui_boss_pct_pump, ui_npcdlg_pump, -// ui_widestash_pump, mv_audit_pump, ui_pages_pump (including controller L / R paging), ui_watch_pump, ui_panel_heal, ui_panel_state_pump, rs_pump (Quick Restart, called from the front-end pump) +// ui_widestash_pump, mv_audit_pump, ui_pages_pump (including gamepad L / R paging), ui_watch_pump, ui_panel_heal, ui_panel_state_pump, rs_pump (one-tap restart, called in the front-end pump) +// Item tooltip docking (observation gate OBS_TOOLTIP, hooked at the entry of the tooltip panel's "submit one tooltip" function main+0xb0d560(panel, text, top-left of target rect x2, size of target rect x3, style, text 2)). +// The tooltip is immediate-mode: the hovered widget resubmits it every frame and it is cleared once drawn, so the record count in the panel is always 0 whenever the host reads it; the input can only be changed at the moment of submission. +// The original places the box directly below / above the target rectangle (the tapped cell): a long description (uniques, runewords, a dozen lines) covers the belt, rings, the middle columns of the inventory and the "Store" button, and a covered cell can only be tapped after tapping elsewhere first. +// With touch, only the inventory panel open (it is centred, with a free band on each side "from the screen edge to the panel's inner frame", about 0.6 of the screen height wide), and an item under the cursor: the target rectangle is replaced by a point at the top of the opposite free band - +// an item in the right half of the panel docks to the left band, one in the left half to the right band, the box running downwards; measuring the text, placing it and pushing it back on screen are still done by the game (the distance from the screen edge follows screenEdgePadding in the layout). +// Everything else passes through unchanged: gamepad / keyboard-and-mouse mode; pages with two panels side by side (stash / vendor / cube / single-item slots / mercenary page - no free band); tooltips of skills, stats and buttons (not an item under the cursor); name plates in the world. +// Half width of the panel's inner frame = 0.484 x screen height (measured from device screenshots: inner frame x 795–2073 on 2868x1320); the top leaves room for the row with the close X (0.10 x screen height). Game main thread only (where the gate callback runs). +// Test switch DM_TEST_TIPDOCK=1: ignore the mode (the Mac host uses the gamepad layout; use it to see the effect); =0: turn it off entirely +static int ui_touch_mode(void); +void dm_ui_tooltip_obs(const uint64_t *regs) { + static int force = -2; if (force == -2) { const char *e = getenv("DM_TEST_TIPDOCK"); force = e ? atoi(e) : -1; } + if (force == 0 || (force < 0 && !ui_touch_mode())) return; + module_t *m = main_module(); uint64_t root = 0; if (!m) return; memcpy(&root, m->base + 0x2f05458, 8); if (!root) return; + if (atomic_load(&g_pstate) & (DM_PS_BANK | DM_PS_VENDOR | DM_PS_IMBUE | DM_PS_CUBE | DM_PS_VAULT | DM_PS_DEAD)) return; + if (!ui_panel(root, "PlayerInventoryExpansionLayout") || ui_panel(root, "HirelingInventoryPanel")) return; + dm_cursor_item_info ci; if (!dm_cursor_item(&ci)) return; + int W = *(int32_t *)(m->base + 0x211da38), H = *(int32_t *)(m->base + 0x211da3c); if (W <= 0 || H <= 0) return; + int tx = (int32_t)regs[2], tw = (int32_t)regs[3], half = (int)(0.484f * H), strip = W / 2 - half; if (strip < H / 4) return; // 空带太窄(窄屏)就不挪 | free band too narrow (narrow screen): do not move it + int left = tx + tw / 2 >= W / 2, cx = left ? strip / 2 : W - strip / 2, y = (int)(0.10f * H); + uint64_t *r = (uint64_t *)(uintptr_t)regs; // 门只回写 x0–x8:改 x2 / x3 | the gate writes back only x0-x8: change x2 / x3 + r[2] = (uint64_t)(uint32_t)cx | (uint64_t)(uint32_t)y << 32; r[3] = 0; + static int lg; static int ll = -1; if (ll != left && lg < 40) { ll = left; lg++; LOG("说明框停靠:物品 %s 在面板%s半 → 说明框停到%s侧空带(中线 x %d,顶 y %d;画面 %dx%d)", ci.code, left ? "右" : "左", left ? "左" : "右", cx, y, W, H); } +} static int ui_touch_mode(void) { int dm_padmode_current(void), dm_padmode_busy(void); return !dm_padmode_current() && !dm_padmode_busy(); } // Mac App:界面是手柄版(上面答「不是触屏模式」),但真鼠标走的是触屏那套物品手势(touch_mac.c 把鼠标事件喂给触屏状态机)。 // 只把物品手势的四个执行泵(长按 / 双击使用 / 买 / 拖放)在真鼠标模式下补跑一遍;绑定框、技能页签对调、佣兵页这些改触屏布局的泵不跑。没有请求时这四个什么都不做,手柄玩家不受影响 diff --git a/dm/host/dm_i18n_tab.h b/dm/host/dm_i18n_tab.h index 42cbbac..4b4571e 100644 --- a/dm/host/dm_i18n_tab.h +++ b/dm/host/dm_i18n_tab.h @@ -206,6 +206,9 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = { { "dmRiftSayStart", "第 %d 层开始,限时 15 分钟", "Level %d: 15 minute time limit" }, { "dmRiftSayGift", "赠彩虹刻面一颗,已掉在脚下", "A Rainbow Facet has dropped" }, { "dmRiftSayTimeout", "时间到:本层未过关,守护者仍会掉落", "Time's up: level not cleared" }, + { "dmRiftSayFoes", "本场有 %d 位强敌", "%d powerful foes this run" }, + { "dmRiftSayInvader", "强敌逼近!", "A powerful foe approaches!" }, + { "dmRiftSayInvaderGone", "闯入者退去了", "The intruder withdraws" }, { "dmRiftSayGuardians", "进度已满:两位守护者现身!", "Two Rift Guardians appear!" }, { "dmRiftSayGuardian", "进度已满:守护者现身!", "The Rift Guardian appears!" }, { "dmElyToaGround", "背包已满,赦免之证掉在脚边", "Inventory full: Token of Absolution dropped" }, @@ -261,6 +264,9 @@ static const struct { const char *k, *zh, *en; } k_dm_i18n[] = { { "dmRiftHudNext", "下次第 %d 层", "Next: Level %d" }, { "dmRiftHudTop", "已通关最高层", "Highest level cleared" }, { "dmRiftHudOver", "已超时:打完仍有掉落,不计通关", "Overtime: drops, no clear" }, + { "dmRiftHudKillN", "击败守护者(%d/%d)", "Slay the Guardians (%d/%d)" }, + { "dmRiftHudOverKill", "已超时:击败守护者仍有掉落", "Overtime: slay it for drops" }, + { "dmRiftHudOverKillN", "已超时:击败守护者(%d/%d)仍有掉落", "Overtime: slay %d/%d for drops" }, { "dmRiftHudSame", "下次仍是这一层", "Next: same level" }, { "dmRiftHudKill", "击败守护者", "Slay the Rift Guardian" }, { "dmRiftHudGoal", "消灭秘境中的怪物 %d%%", "Slay the monsters %d%%" }, diff --git a/dm/host/dm_rift.c b/dm/host/dm_rift.c index e9e016f..00ffc06 100644 --- a/dm/host/dm_rift.c +++ b/dm/host/dm_rift.c @@ -99,7 +99,9 @@ static void say(const char *key, ...) { char line[160], full[180]; va_list ap; v enum { ST_IDLE, ST_RUN, ST_DONE }; static struct { _Atomic int st; int tier, maps[3], nmaps, cur; // 本次层数、串起来的图、正在第几张 | This rift's level, the chained maps, which map we are on + _Atomic int gdead, gtotal; // 守护者:已倒下几位 / 本场已刷出几位(顶部条用) | Guardians: how many have fallen / how many have been spawned this run (for the top bar) _Atomic int score, need; uint64_t t0_ns; _Atomic int timeout, guard_dead; // 分数(客户端加)、开局时刻(客体时钟)、超时、守护者已死 | Score (added by the client), start time (guest clock), timed out, guardian dead + int inv_n, inv_cls[2], inv_pct[2], inv_st[2]; uint32_t inv_id[2], inv_t[2]; // 闯入首领(80 层起):本场几位、各自类号、在进度百分之几闯入、状态(0 未到 / 1 已预警 / 2 在场 / 3 已死 / 4 作罢)、单位 id、预警那一拍 | Invading bosses (from level 80): how many this run, their class ids, at what percentage of progress they invade, state (0 not yet / 1 warned / 2 present / 3 dead / 4 called off), unit id, the tick of the warning uint32_t guard, guards[3]; int guard_cls, gcls[3], nplan, inc; // 守护者:guards[] 各位的单位 id(guard = 第一位,非 0 即「已刷出」)、gcls[] 开局抽好的类号、nplan 本场几位;inc 成功涨了几层 | Guardians: guards[] unit id of each (guard = the first, non-zero meaning "spawned"), gcls[] class ids drawn at the start, nplan how many in this run; inc how many levels were gained on success int players_old; // 开局前的 /players 档 | The /players setting from before the start of the run char who[64]; // 角色名(层数侧文件) | Character name (level sidecar file) @@ -298,6 +300,10 @@ int dm_rift_hud(dm_rift_hud_t *o) { int el = K.t0_ns ? (int)((now - K.t0_ns) / 1000000000ull) : 0; int need = atomic_load(&K.need); o->tier = K.tier; o->progress = need > 0 ? (float)atomic_load(&K.score) / need : 0; if (o->progress > 1) o->progress = 1; o->secs_left = st == ST_DONE ? g_left_done : RIFT_SECS - el; o->done = st == ST_DONE; o->guardian = K.guard != 0 && !atomic_load(&K.guard_dead); o->inc = K.inc; o->next = next_tier(); o->overtime = rift_overtime(); + // 第二行写哪一句在这里定(一个来源):超时优先说明「已超时」,守护者在场就把「击败守护者」合进同一句;两位以上带(已倒 / 总数) + // Which sentence the second line shows is decided here (one source): overtime takes priority with "Overtime", and when Guardians are present "Slay the Rift Guardian" is merged into the same sentence; with two or more it carries (fallen / total) + o->gdead = atomic_load(&K.gdead); o->gtotal = atomic_load(&K.gtotal); + o->goal = o->overtime ? (o->guardian ? (o->gtotal >= 2 ? 5 : 4) : 3) : o->guardian ? (o->gtotal >= 2 ? 2 : 1) : 0; return 1; } @@ -311,16 +317,25 @@ static uint32_t g_swept[1024]; int dm_rift_swept(uint32_t id) { return id && g_s static int hi_on(const char *seg, int from) { static int off = -1; if (off < 0) { const char *e = getenv("DM_RIFT_HI"); off = e && !strcmp(e, "0"); } if (off) return 0; const char *f = getenv("DM_RIFT_TEST_HI"); return (f && strstr(f, seg)) || K.tier >= from; } // 双守护者每位的生命系数 s、伤害系数 d(×1000):75 层 0.51 / 0.75,线性到 100 层 0.775 / 1.0;低于 75 层被测试开关强制时取 75 层的值。 -// s 的两端:75 层双守护者期望总量 = 74 层单守护者的 1.16 倍(不跳变;双守护者的池是四位,见 k_duo);100 层最大的单体(巴尔)正好不过属性上限。d 未用读数校过 +// s 的两端:75 层双守护者期望总量 = 74 层单守护者的 1.16 倍(不跳变;双守护者的池是四位,见 k_duo);100 层最大的单体(巴尔)正好不过属性上限。d 用替身读数校过一轮(设计稿第十五节:75 层六对的承伤每秒峰值最高是 74 层最重单体的 1.06 倍,各 1 局) // Life factor s and damage factor d of each of two Guardians (x1000): 0.51 / 0.75 at level 75, linear to 0.775 / 1.0 at level 100; below level 75 (forced by a test switch) the level-75 values are used. -// The two ends of s: the expected total of two Guardians at level 75 = 1.16 times a single Guardian at level 74 (no jump; the dual pool has four bosses, see k_duo); at level 100 the largest single one (Baal) stays just within the stat limit. d has not been calibrated with readouts +// The two ends of s: the expected total of two Guardians at level 75 = 1.16 times a single Guardian at level 74 (no jump; the dual pool has four bosses, see k_duo); at level 100 the largest single one (Baal) stays just within the stat limit. d has been calibrated once with stand-in readouts (for the six pairs at level 75 the highest per-second peak of damage taken is 1.06 times the heaviest single Guardian at level 74, one run each) static int hi_duo_x1000(int which) { int t = K.tier < 75 ? 75 : K.tier > 100 ? 100 : K.tier; return which ? 750 + 250 * (t - 75) / 25 : 510 + 265 * (t - 75) / 25; } // 多位首领同场的池不含安达利尔(156):她死后十几到四十拍,同场的另一位首领会跟着死——与巴尔、迪亚波罗各试过,3 + 1 局必现,那时另一位还剩大半生命、 // 不是被伤害打死的;带不带任务事件门都一样;对照组(都瑞尔 + 迪亚波罗)没有这回事。看起来是她原版的死亡过程带的,没读到那段代码。单守护者(74 层及以下)仍是五位 // The pool for several bosses in one fight does not include Andariel (156): ten-odd to forty ticks after she dies, the other boss in the same fight dies too - tried with Baal and with Diablo, reproduced in 3 + 1 runs, with the other one still at most of its life at that point, // not killed by damage; the same with or without the quest-event gate; the control pair (Duriel + Diablo) shows nothing of the kind. It appears to come with her original death sequence; that code has not been read. A single Guardian (level 74 and below) is still drawn from all five static const int k_duo[] = { 211, 242, 243, 544 }; -static int is_guard(uint32_t id) { return id && (id == K.guards[0] || id == K.guards[1] || id == K.guards[2]); } +static int g_entry_lv, g_entry_x, g_entry_y; // 玩家进当前这张秘境图时的落点(退场找不到远处空地时的兜底去处:一定可达) | where the player entered the current rift map (the fallback destination when no distant open ground is found for leaving: always reachable) +static uint32_t g_inv_gone[2]; static int g_inv_gone_xy[2][2]; // 已退场的闯入首领:单位 id(等它所在的房间被游戏卸载后,把它那条存档记录改成不还原;见 inv_gone_pump)与退场落点 | an invading boss that has left: its unit id (once the game unloads the room it is in, its saved record is changed to do-not-restore; see inv_gone_pump) and where it was sent +// 首领自己召出来的单位(现在只有巴尔的:触手 562–566、分身 570)。75 层以上它们不按层改属性、保持原版数值——它们是首领技能的一部分,不是秘境的怪; +// 按层放大会让触手变成打不完的墙,并且随战斗时长在场上越积越多(实测巴尔在场 36 秒同屏多 26 只、141 秒多 44 只)。74 层及以下照旧(那条「逐位不变」的线不为此破例)。 +// 按类号认:单位上「召唤者是谁」的字段没读到;以后别的首领有召唤物要加进来 +// Units summoned by a boss itself (currently only Baal's: tentacles 562–566, clone 570). Above level 75 they are not scaled by level and keep the original values - they are part of the boss's skills, not monsters of the rift; +// scaling them by level turns the tentacles into a wall that cannot be cleared, and they pile up on the field as the fight goes on (measured: 26 more on screen after Baal has been present for 36 seconds, 44 more after 141 seconds). Level 74 and below stay as they were (the "nothing changes" line is not broken for this). +// Recognised by class id: the "who summoned it" field on the unit has not been read; summons of other bosses will have to be added later +static int boss_summon(uint32_t cls) { return (cls >= 562 && cls <= 566) || cls == 570; } +static int is_guard(uint32_t id) { return id && (id == K.guards[0] || id == K.guards[1] || id == K.guards[2] || id == K.inv_id[0] || id == K.inv_id[1] || id == g_inv_gone[0] || id == g_inv_gone[1]); } // 守护者与闯入首领:不按普通怪再改一遍属性、不按普通怪计分 | Guardians and invading bosses: not scaled again as ordinary monsters, not scored as ordinary monsters static int pts_of(uint8_t fl) { return fl & 0x02 ? 15 : fl & 0x08 ? 10 : fl & 0x04 ? 5 : fl & 0x10 ? 2 : 1; } // 怪物数据 +0x1a:超级独特 / 金怪 / 冠军 / 随从 / 普通(同 hle_target.c) | Monster data +0x1a: super unique / unique (gold) monster / champion / minion / normal (same as hle_target.c) // ---- 每场读数(75 层以上内容曲线的量具,docs 设计稿第 0 步):只记、不改任何玩法。结算时打一行: // 用时;击杀只数与这些怪的生命上限之和(按层改完之后的值,守护者另加);本场认作敌对并改过属性的怪的只数与生命和; @@ -877,6 +892,20 @@ static void region_set(uint64_t G, int mode) { // mode 0 写回原值、1 置 for (int i = 0; i < K.nmaps; i++) { int lv = K.maps[i]; uint8_t *umin, *umax; int32_t *den = region_of(G, lv, &umin, &umax); if (!den) continue; int d = mode ? 0 : g_reg[lv].den, a = mode ? 0 : g_reg[lv].umin, b = mode ? 0 : g_reg[lv].umax; if (*den == d && *umin == a && *umax == b) continue; LOG("秘境:关卡 %d 本局怪物区域 密度 %d → %d、精英组 %d–%d → %d–%d(%s)", lv, *den, d, *umin, *umax, a, b, mode ? "已结算,不再填怪" : "写回原值"); *den = d; *umin = (uint8_t)a; *umax = (uint8_t)b; } } +// 退场的闯入首领的真移除:它被传到远处后,那间房离玩家远、游戏自己会把房间卸载(实测约 150 拍),单位随之从单位表里拿掉、存成房间存档里的一条怪物记录 +// (记录 +0xc 是单位号)。这时把那条记录照 saved_purge 的做法改成「不还原」(标志 +0x14 置 0x100、单位号写成全 1)——以后玩家走回去,房间重新载入也不会再把它放出来。 +// 全程不走死亡 / 掉落 / 击杀计数。房间还没卸载时什么都不做(它在 150 格外原地站着) +// True removal of an invading boss that has left: after it is teleported far away, its room is far from the player and the game unloads the room by itself (about 150 ticks, measured), taking the unit out of the unit table and storing it as one monster record in the room's saved state +// (record +0xc is the unit id). At that point the record is changed to "do not restore" the way saved_purge does it (flag +0x14 set to 0x100, unit id written as all ones) - if the player walks back later and the room is loaded again, it is not brought out again. +// No death / drop / kill count is involved at any point. Nothing is done while the room is not yet unloaded (it stands in place more than 150 tiles away) +static void inv_gone_pump(uint64_t G, uint32_t t) { + for (int i = 0; i < 2; i++) { uint32_t id = g_inv_gone[i]; if (!id || find_unit(G, 1, id)) continue; + uint64_t T = tables(G), heads = rd(G + 0x1b0); int acts = T ? *(int32_t *)(uintptr_t)(T + 0x108) : 0, hit = 0; if (!heads || acts <= 0 || acts > 8) continue; + for (int a = 0; a < acts && !hit; a++) for (uint64_t nd = rd(heads + 8ull * a), k = 0; nd && k < 4096 && !hit; nd = rd(nd + 0x20), k++) for (uint64_t r = rd(nd + 0x10), j = 0; r && j < 1024; r = rd(r + 0xb0), j++) + if (*(uint32_t *)(uintptr_t)(r + 0xc) == id) { *(uint32_t *)(uintptr_t)(r + 0x14) |= 0x100; *(uint32_t *)(uintptr_t)(r + 0xc) = 0xffffffffu; hit = 1; break; } + if (hit) { LOG("秘境:拍 %u 退场的闯入首领(单位 id %u)所在房间已卸载,它的存档记录改成不还原", t, id); g_inv_gone[i] = 0; } + else { static uint32_t warned; if (warned != id && t % 250 == 0) { warned = id; LOG("秘境:拍 %u 退场的闯入首领(单位 id %u)不在单位表里,房间存档里也没找到它的记录", t, id); } } } +} // 已结算的图里,地图预设点上的怪也不再放:给预设记录置原版自己的「跳过」位(记录 +0x28 位 0,放预设单位的循环 main+0x7ce9bc 读它;+0x20 = 1 是怪)。记录在房间初始化时才有,所以每拍对一遍 // 单位阵营(0 敌对 / 2 玩家一方):原版存房间时自己的读法(main+0x7e0f3c 起)——单位 +0x88 的属性表,+0x1c 位 31 没置 = 0;否则在 +0xd0 / +0xd8 两条链(下一条 +0x68)里找状态 0x69 的节点, // 对它取属性 0xac:main+0x5bc810([单位 +0x1bd] 字节, 节点, 0xac, 0);没有这个节点 = 0 @@ -1101,12 +1130,28 @@ static int start_rift(uint64_t G, uint64_t player, uint32_t t, int tier) { for (int q = 0; q < K.nmaps && L.nused < 24; q++) L.used[L.nused++] = K.maps[q]; atomic_fetch_add(&g_run_seq, 1); rift_setup(G); K.cur = 0; atomic_store(&K.score, getenv("DM_RIFT_TEST_SCORE") ? atoi(getenv("DM_RIFT_TEST_SCORE")) : 0); // 测试:初始分数(看进度条) | Test: initial score (to see the progress bar) - atomic_store(&K.guard_dead, 0); atomic_store(&K.timeout, 0); K.guard = 0; memset(K.guards, 0, sizeof K.guards); K.inc = 0; + atomic_store(&K.guard_dead, 0); atomic_store(&K.timeout, 0); atomic_store(&K.gdead, 0); atomic_store(&K.gtotal, 0); K.guard = 0; memset(K.guards, 0, sizeof K.guards); K.inc = 0; // 本场的守护者开局就抽好(之后回城再来、继续,都是这几位):75 层起两位不同的。测试开关 DM_RIFT_TEST_GUARDS=<类号>[,<类号>] 指定(逐对验收用) // This run's Guardians are drawn at the start (returning to town and coming back, or continuing, gives the same ones): from level 75 two different ones. Test switch DM_RIFT_TEST_GUARDS=[,] specifies them (for pair-by-pair acceptance) { K.nplan = hi_on("duo", 75) ? 2 : 1; K.gcls[2] = 0; if (K.nplan == 2) { int a = rnd(4), b = (a + 1 + rnd(3)) % 4; K.gcls[0] = k_duo[a]; K.gcls[1] = k_duo[b]; } else { K.gcls[0] = k_guard[rnd(5)]; K.gcls[1] = 0; } const char *e = getenv("DM_RIFT_TEST_GUARDS"); if (e) { int x = 0, y = 0, n = sscanf(e, "%d,%d", &x, &y); if (n >= 1 && x > 0) K.gcls[0] = x; if (n >= 2 && y > 0) K.gcls[1] = y; } + // 闯入首领(设计稿第二、十七、十八节):80 层起 1 位、90 层起 2 位,开局抽好——是谁(多首领同场的池里、不与本场守护者同类号的那几位,两位不重样)、 + // 在进度百分之几闯入(1 位:30–70;2 位:25–45 与 55–80)。同一场不重抽。掉落不干预:它被打死就照自己在当前难度的原版表掉。 + // 测试开关:DM_RIFT_TEST_INVADE=<类号>[,<类号>] 指定是谁、DM_RIFT_TEST_INVPCT=<百分数> 指定第一位的闯入点 + // Invading bosses (design draft): 1 from level 80, 2 from level 90, drawn at the start - who (from the pool for several bosses in one fight, not sharing a class id with this run's Guardians, the two being different), + // and at what percentage of progress they invade (1 boss: 30–70; 2 bosses: 25–45 and 55–80). Not redrawn within a run. Drops are not interfered with: when killed it drops from its own original table for the current difficulty. + // Test switches: DM_RIFT_TEST_INVADE=[,] chooses who, DM_RIFT_TEST_INVPCT= the first one's invasion point + { memset(K.inv_cls, 0, sizeof K.inv_cls); memset(K.inv_st, 0, sizeof K.inv_st); memset(K.inv_id, 0, sizeof K.inv_id); K.inv_n = !hi_on("invade", 80) ? 0 : (K.tier >= 90 || (getenv("DM_RIFT_TEST_HI") && strstr(getenv("DM_RIFT_TEST_HI"), "invade2"))) ? 2 : 1; + int pool[4], np = 0; for (int q = 0; q < 4; q++) pool[np++] = k_duo[q]; // 可以与本场守护者同类号:守护者现身时在场的闯入首领退场(见刷守护者处),两者不会同场 | it may share a class id with this run's Guardians: when the Guardians appear an invading boss that is present leaves (see where the Guardians are spawned), so the two are never on the field together + if (K.inv_n > np) K.inv_n = np; + for (int q = 0; q < K.inv_n; q++) { int j = rnd(np); K.inv_cls[q] = pool[j]; pool[j] = pool[--np]; + K.inv_pct[q] = K.inv_n == 1 ? 30 + rnd(41) : q == 0 ? 25 + rnd(21) : 55 + rnd(26); } + const char *e = getenv("DM_RIFT_TEST_INVADE"); if (e && K.inv_n) { int x = 0, y = 0, n = sscanf(e, "%d,%d", &x, &y); if (n >= 1 && x > 0) K.inv_cls[0] = x; if (n >= 2 && y > 0 && K.inv_n > 1) K.inv_cls[1] = y; } + if ((e = getenv("DM_RIFT_TEST_INVPCT")) && K.inv_n) K.inv_pct[0] = atoi(e); + if (K.inv_n) { int nd = atomic_load(&K.need); atomic_store(&K.need, nd * (100 + 12 * K.inv_n) / 100); // 打掉一位 +12% 进度:进度需求同步上调,免得内容更多反而更快出守护者 | +12% progress for each one killed: the progress requirement is raised to match, so that more content does not make the Guardians appear sooner + if (K.inv_n >= 2) say("dmRiftSayFoes", K.inv_n); // 90 层起开局说一声本场有几位强敌(不说是谁、不说何时) | from level 90, say at the start how many strong enemies this run has (not who, not when) + LOG("秘境:本场闯入首领 %d 位:类号 %d(进度 %d%% 时)%s;进度需求 %d → %d", K.inv_n, K.inv_cls[0], K.inv_pct[0], K.inv_n > 1 ? "与另一位(见闯入时的日志)" : "", nd, atomic_load(&K.need)); } } K.guard_cls = K.gcls[0]; if (K.nplan == 2) LOG("秘境:本场守护者两位,类号 %d 与 %d(生命 ×%d.%03d、伤害 ×%d.%03d)", K.gcls[0], K.gcls[1], hi_duo_x1000(0) / 1000, hi_duo_x1000(0) % 1000, hi_duo_x1000(1) / 1000, hi_duo_x1000(1) % 1000); } K.t0_ns = guest_ns(); if (getenv("DM_RIFT_TEST_LATE")) { K.t0_ns -= (uint64_t)RIFT_SECS * 1000000000ull; LOG("秘境:测试 DM_RIFT_TEST_LATE 开局即超时"); } // 造「超时打倒守护者」现场 | set up the "Guardian defeated after time ran out" test case @@ -1269,7 +1314,9 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { // Newly spawned hostile monsters get their stats changed by level (from level 9). Test switch DM_RIFT_TEST_LOWHP=1: change to 1 life point (hold the main attack button and kill all the way through; verifies scoring / guardian / level increase) static int lowhp = -1; if (lowhp < 0) lowhp = getenv("DM_RIFT_TEST_LOWHP") != NULL; if (K.tier >= 9 || lowhp) { static uint32_t r_; uint32_t w = atomic_load(&g_newq_w); if (w - r_ > NQ) r_ = w - NQ; int lt = target_level(player); - for (; r_ != w; r_++) { uint32_t id = atomic_load(&g_newq[r_ % NQ]); uint64_t u = find_unit(G, 1, id); if (u && !is_guard(id)) { if (K.tier >= 9) scale_monster(G, u, lt, dm_rift_tier_level(9, gs(player, 12))); if (lowhp) ss(u, 6, 256); dmg_probe_add(id, t); hs_spawn(id, gs(u, 7) >> 8); } } } + for (; r_ != w; r_++) { uint32_t id = atomic_load(&g_newq[r_ % NQ]); uint64_t u = find_unit(G, 1, id); if (u && !is_guard(id) && hi_on("summon", 75) && boss_summon(*(uint32_t *)(uintptr_t)(u + 4))) { static int n, sq = -1; int cur = atomic_load(&g_run_seq); if (cur != sq) { sq = cur; n = 0; } + if (n++ < 4) LOG("秘境:首领召唤物 id %u(类号 %u)不按层改,保持原版:等级 %d 生命 %d", id, *(uint32_t *)(uintptr_t)(u + 4), gs(u, 12), gs(u, 7) >> 8); hs_spawn(id, gs(u, 7) >> 8); continue; } + if (u && !is_guard(id)) { if (K.tier >= 9) scale_monster(G, u, lt, dm_rift_tier_level(9, gs(player, 12))); if (lowhp) ss(u, 6, 256); dmg_probe_add(id, t); hs_spawn(id, gs(u, 7) >> 8); } } } dmg_probe_pump(G, t); hs_tick(G, player, t, lv); // 测试读数 DM_RIFT_TEST_ILVL=1:每 10 秒数一次地上的物品(服务端物品表 G+0x2e30,模式 3),报物品等级(数据块 +0x38)范围——验 B 方案下掉落物品等级跟不跟改过的怪物等级 // Test readout DM_RIFT_TEST_ILVL=1: every 10 seconds count the items on the ground (server item table G+0x2e30, mode 3) and report the item level (data block +0x38) range -- verifies whether drop item levels follow the modified monster level under plan B @@ -1280,7 +1327,8 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { // 测试开关 DM_RIFT_TEST_PULL=1:每 3 秒用原版传送 0x7cc530 把人放到一只还活着的敌对怪(客户端认的)旁边——脚本按主攻击键就能一路打(验计分 / 守护者) // Test switch DM_RIFT_TEST_PULL=1: every 3 seconds use the original game's teleport 0x7cc530 to put the player next to a still-living hostile monster (as recognized by the client) -- a script only has to press the main attack button to fight all the way through (verifies scoring / guardian) { static int pull = -1; if (pull < 0) pull = getenv("DM_RIFT_TEST_PULL") != NULL; - if (pull && t % 38 == 0 && in_rift_map(lv) && K.guard && !atomic_load(&K.guard_dead)) { uint64_t g = 0; for (int i = 0; i < 3 && !g; i++) { uint64_t gu = K.guards[i] ? find_unit(G, 1, K.guards[i]) : 0; uint32_t gm = gu ? *(uint32_t *)(uintptr_t)(gu + 0xc) : 0; if (gu && gm != 0 && gm != 12) g = gu; } int x, y; if (g && unit_xy(g, &x, &y)) dm_teleport(B, G, player, unit_room(g), x + 2, y + 2); } + if (pull && t % 38 == 0 && in_rift_map(lv) && ((K.guard && !atomic_load(&K.guard_dead)) || K.inv_st[0] == 2 || K.inv_st[1] == 2)) { uint64_t g = 0; for (int i = 0; i < 2 && !g; i++) { uint64_t gu = K.inv_st[i] == 2 ? find_unit(G, 1, K.inv_id[i]) : 0; uint32_t gm = gu ? *(uint32_t *)(uintptr_t)(gu + 0xc) : 0; if (gu && gm != 0 && gm != 12) g = gu; } /* 在场的闯入首领优先 | an invading boss that is present takes priority */ + for (int i = 0; i < 3 && !g; i++) { uint64_t gu = K.guards[i] ? find_unit(G, 1, K.guards[i]) : 0; uint32_t gm = gu ? *(uint32_t *)(uintptr_t)(gu + 0xc) : 0; if (gu && gm != 0 && gm != 12) g = gu; } int x, y; if (g && unit_xy(g, &x, &y)) dm_teleport(B, G, player, unit_room(g), x + 2, y + 2); } else if (pull && t % 38 == 0 && in_rift_map(lv)) { uint32_t w = atomic_load(&g_newq_w); int px, py, bd = 1 << 30, bx = 0, by = 0; unit_xy(player, &px, &py); // 最近的那只 | The nearest one for (uint32_t k = 0; k < NQ && k < w; k++) { uint64_t u = find_unit(G, 1, atomic_load(&g_newq[(w - 1 - k) % NQ])); if (!u || unit_level(u) != lv) continue; uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) continue; int x, y; if (!unit_xy(u, &x, &y)) continue; int d = abs(x - px) + abs(y - py); if (d < bd) { bd = d; bx = x; by = y; } } @@ -1292,7 +1340,59 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { if (!atomic_load(&K.timeout) && now - K.t0_ns > (uint64_t)RIFT_SECS * 1000000000ull) { atomic_store(&K.timeout, 1); say("dmRiftSayTimeout"); } } // 守护者 // Guardian + inv_gone_pump(G, t); + if (in_rift_map(lv) && g_entry_lv != lv) { int ex, ey; if (unit_xy(player, &ex, &ey)) { g_entry_lv = lv; g_entry_x = ex; g_entry_y = ey; } } else if (!in_rift_map(lv)) g_entry_lv = 0; + // 测试读数 DM_RIFT_TEST_GONE=<拍>:退场的闯入首领每 25 拍报一次位置 / 模式 / 生命 / 离人多远;到 <拍> 时把人传到它跟前,并让固定输出替身开始打它(验:退场后它动不动、走过去会不会打起来、打死给不给进度 / 掉不掉东西) + // Test readout DM_RIFT_TEST_GONE=: an invading boss that has left reports its position / mode / life / distance from the player every 25 ticks; at the player is teleported next to it and the fixed-output stand-in starts hitting it (to verify: whether it moves after leaving, whether walking up to it starts a fight, whether killing it gives progress / drops) + { static int at = -1, hit, gx, gy, cls; static uint32_t hit_t; if (at < 0) { const char *e = getenv("DM_RIFT_TEST_GONE"); at = e ? atoi(e) : 0; } + // 测试开关 DM_RIFT_TEST_GONEKILL=1:退场后第 10 拍把人传到它跟前、把它当前血置 1(由随从补刀)——验「退场到被真移除之间被打死」给不给进度、掉不掉东西 + // Test switch DM_RIFT_TEST_GONEKILL=1: at the 10th tick after it leaves, teleport the player next to it and set its current life to 1 (a minion delivers the last hit) - to verify whether "killed between leaving and being truly removed" gives progress or drops anything + if (getenv("DM_RIFT_TEST_GONEKILL")) for (int i = 0; i < 2; i++) { static uint32_t t0[2], did[2]; uint64_t u = g_inv_gone[i] ? find_unit(G, 1, g_inv_gone[i]) : 0; if (!u) continue; if (did[i] != g_inv_gone[i]) { did[i] = g_inv_gone[i]; t0[i] = t; } + uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); int x, y; unit_xy(u, &x, &y); + if (t - t0[i] == 10) { LOG("[退场读数] 拍 %u 把人传到退场的闯入首领跟前(它在 %d,%d,进度 %d)", t, x, y, atomic_load(&K.score)); dm_teleport(B, G, player, unit_room(u), x + 2, y + 2); } + if (t - t0[i] >= 10 && m != 0 && m != 12) ss(u, 6, 256); + if ((m == 0 || m == 12) && t0[i] != 1) { t0[i] = 1; LOG("[退场读数] 拍 %u 退场的闯入首领被打死了(模式 %u),进度 %d", t, m, atomic_load(&K.score)); } } + if (at > 0) { for (int i = 0; i < 2; i++) { uint64_t u = g_inv_gone[i] ? find_unit(G, 1, g_inv_gone[i]) : 0; if (g_inv_gone_xy[i][0]) { gx = g_inv_gone_xy[i][0]; gy = g_inv_gone_xy[i][1]; cls = K.inv_cls[i]; } if (!u || t % 25) continue; + int x, y, px, py; unit_xy(u, &x, &y); unit_xy(player, &px, &py); LOG("[退场读数] 拍 %u 第 %d 位:位置 %d,%d 模式 %u 生命 %d / %d 离人 %d 格", t, i + 1, x, y, *(uint32_t *)(uintptr_t)(u + 0xc), gs(u, 6) >> 8, gs(u, 7) >> 8, abs(x - px) + abs(y - py)); } + if (gx && t >= (uint32_t)at && !hit) { int32_t pos[2] = { gx, gy }; uint64_t rs = room_load(G, level_of(player), gx, gy), rr = rs ? free_spot(G, rs, pos) : 0; hit = 1; hit_t = t; LOG("[退场读数] 拍 %u 把人传到退场落点 %d,%d(%s)", t, gx, gy, rr && dm_teleport(B, G, player, rr, pos[0], pos[1]) ? "成" : "没成"); } + if (hit == 1 && t - hit_t >= 150) { hit = 2; int n = 0, px, py; unit_xy(player, &px, &py); for (int b = 0; b < 128; b++) for (uint64_t u = rd(G + 0x2230 + 1 * 0x400 + 8 * b); u; u = rd(u + 0x158)) { int x, y; if ((int)*(uint32_t *)(uintptr_t)(u + 4) == cls && unit_xy(u, &x, &y) && abs(x - px) + abs(y - py) < 80) n++; } + LOG("[退场读数] 拍 %u 人已在退场落点 150 拍:80 格内类号 %d 的单位 %d 只(人在 %d,%d)", t, cls, n, px, py); } } } + // 测试开关 DM_RIFT_TEST_SCOREAT=<拍>:<分数>:到这一拍把进度分数直接设成这个数(造「闯入首领还活着时进度满了」这类现场) + // Test switch DM_RIFT_TEST_SCOREAT=:: at this tick set the progress score directly to this number (to stage scenes such as "progress fills while an invading boss is still alive") + { static int at = -1, sc; if (at < 0) { const char *e = getenv("DM_RIFT_TEST_SCOREAT"); at = e ? atoi(e) : 0; const char *c = e ? strchr(e, ':') : NULL; sc = c ? atoi(c + 1) : 0; } + if (at > 0 && t >= (uint32_t)at && atomic_load(&K.st) == ST_RUN) { at = 0; atomic_store(&K.score, sc); LOG("秘境:测试 DM_RIFT_TEST_SCOREAT 拍 %u 把进度分数设成 %d", t, sc); } } + // 闯入首领:进度走到抽好的那一点 → 提示(约 3 秒预警)→ 在离人 36 格左右的空地刷出;生命 = 规则应得值 × 0.30;死了 +12% 进度。 + // 同一时刻最多一位;守护者出来之后不再预警 / 不再刷(已在场的那位留着,它与守护者不同类号)。它不是结算条件 + // Invading boss: progress reaches the drawn point -> message (about 3 seconds of warning) -> spawned on open ground about 36 tiles from the player; life = the rule value x 0.30; +12% progress on death. + // At most one at a time; after the Guardians appear there are no more warnings / spawns (one already present stays; it has a different class id from the Guardians). It is not a completion condition + if (K.inv_n && atomic_load(&K.st) == ST_RUN && in_rift_map(lv)) { int nd = atomic_load(&K.need), busy = 0; for (int i = 0; i < K.inv_n; i++) busy |= K.inv_st[i] == 1 || K.inv_st[i] == 2; + for (int i = 0; i < K.inv_n; i++) { + if (K.inv_st[i] == 0 && !busy && !K.guard && nd > 0 && atomic_load(&K.score) * 100 >= (long long)nd * K.inv_pct[i]) { K.inv_st[i] = 1; K.inv_t[i] = t; busy = 1; say("dmRiftSayInvader"); LOG("秘境:拍 %u 闯入首领预警(第 %d 位,类号 %d,进度 %d%%)", t, i + 1, K.inv_cls[i], K.inv_pct[i]); } + else if (K.inv_st[i] == 1 && K.guard) { K.inv_st[i] = 4; LOG("秘境:守护者已现身,第 %d 位闯入首领作罢", i + 1); } + else if (K.inv_st[i] == 1 && t - K.inv_t[i] >= 75) { static const int dx[8] = { 36, 26, 0, -26, -36, -26, 0, 26 }, dy[8] = { 0, 26, 36, 26, 0, -26, -36, -26 }; int x, y; unit_xy(player, &x, &y); uint64_t u = 0; int32_t pos[2] = { 0, 0 }; + for (int k = 0, d0 = rnd(8); k < 8 && !u; k++) { int d = (d0 + k) % 8; pos[0] = x + dx[d]; pos[1] = y + dy[d]; uint64_t rs = room_load(G, level_of(player), pos[0], pos[1]), rr = rs ? free_spot(G, rs, pos) : 0; + if (!rr || abs(pos[0] - x) + abs(pos[1] - y) < 24) continue; /* 找到的空地被挪到人跟前就不要 | open ground that got moved right next to the player is not accepted */ + u = ((uint64_t (*)(uint64_t, uint64_t, int, int, int, int, int, int, uint64_t))(B + 0x7ce630))(G, rr, 1, K.inv_cls[i], pos[0], pos[1], 1, 0, 0x10); } + if (!u) { if (t - K.inv_t[i] > 325) { K.inv_st[i] = 4; LOG("秘境:第 %d 位闯入首领 10 秒内没找到落点,作罢", i + 1); } continue; } + K.inv_id[i] = *(uint32_t *)(uintptr_t)(u + 8); K.inv_st[i] = 2; + if (K.tier >= 9) { g_hp_mul = 300; scale_monster(G, u, target_level(player) + 3, dm_rift_tier_level(9, gs(player, 12)) + 3); g_hp_mul = 1000; } + LOG("秘境:拍 %u 闯入首领刷出(第 %d 位)类号 %d id %u 在 %d,%d(离人 %d 格)等级 %d 生命 %d", t, i + 1, K.inv_cls[i], K.inv_id[i], pos[0], pos[1], abs(pos[0] - x) + abs(pos[1] - y), gs(u, 12), gs(u, 7) >> 8); } + else if (K.inv_st[i] == 2) { uint64_t u = find_unit(G, 1, K.inv_id[i]); uint32_t m = u ? *(uint32_t *)(uintptr_t)(u + 0xc) : 1; + if (u && (m == 0 || m == 12)) { K.inv_st[i] = 3; int add = nd * 12 / (100 + 12 * K.inv_n); if (add < 1) add = 1; int sc = atomic_fetch_add(&K.score, add) + add; /* 12% 按上调前的进度需求算 | 12% is computed on the progress requirement before the increase */ + LOG("秘境:拍 %u 闯入首领死亡(第 %d 位,类号 %d)→ 进度 +%d,现 %d / %d", t, i + 1, K.inv_cls[i], add, sc, nd); } } } } if (!K.guard && atomic_load(&K.score) >= atomic_load(&K.need) && in_rift_map(lv)) { + // 守护者现身:还在场的闯入首领退场——守护者战期间场上只有守护者。原版没有读到能安全移除一个单位的入口,用已验证过的定点传送把它送到这张图的远处(不触发死亡 / 掉落 / 击杀计数), + // 状态记作罢:之后它死不死都不给进度。玩家想要它的进度与掉落,就得在进度满之前解决它 + // Guardians appear: an invading boss still present leaves - during the Guardian fight only the Guardians are on the field. No entry was found in the original for safely removing a unit, so the already-verified fixed-point teleport sends it far away on this map (no death / drop / kill count is triggered), + // and its state is recorded as called off: whether or not it dies afterwards, it gives no progress. A player who wants its progress and drops has to deal with it before progress is full + for (int i = 0; i < K.inv_n; i++) { if (K.inv_st[i] == 1) { K.inv_st[i] = 4; continue; } if (K.inv_st[i] != 2) continue; + static const int fx[8] = { 150, 106, 0, -106, -150, -106, 0, 106 }, fy[8] = { 0, 106, 150, 106, 0, -106, -150, -106 }; uint64_t iu = find_unit(G, 1, K.inv_id[i]); int px, py, moved = 0; unit_xy(player, &px, &py); + for (int k = 0; iu && k < 8 && !moved && !getenv("DM_RIFT_TEST_NOFAR"); k++) { int32_t fp[2] = { px + fx[k], py + fy[k] }; /* 测试开关 DM_RIFT_TEST_NOFAR=1:当作远处没有空地,走兜底 | test switch DM_RIFT_TEST_NOFAR=1: act as if there were no open ground far away, taking the fallback */ uint64_t rs = room_load(G, level_of(player), fp[0], fp[1]), rr = rs ? free_spot(G, rs, fp) : 0; + if (rr && abs(fp[0] - px) + abs(fp[1] - py) >= 100 && dm_teleport(B, G, iu, rr, fp[0], fp[1])) { moved = 1; LOG("秘境:拍 %u 守护者现身,闯入首领(第 %d 位,类号 %d)退场到 %d,%d(离人 %d 格),不再给进度", t, i + 1, K.inv_cls[i], fp[0], fp[1], abs(fp[0] - px) + abs(fp[1] - py)); } } + if (!moved && iu && g_entry_lv == lv) { int32_t fp[2] = { g_entry_x, g_entry_y }; uint64_t rs = room_load(G, level_of(player), fp[0], fp[1]), rr = rs ? free_spot(G, rs, fp) : 0; // 兜底:传到玩家进这张图时的落点(一定可达) | fallback: teleport to the point where the player entered this map (always reachable) + if (rr && dm_teleport(B, G, iu, rr, fp[0], fp[1])) { moved = 1; LOG("秘境:拍 %u 守护者现身,闯入首领(第 %d 位,类号 %d)远处没有空地,退场到本图入口 %d,%d(离人 %d 格)", t, i + 1, K.inv_cls[i], fp[0], fp[1], abs(fp[0] - px) + abs(fp[1] - py)); } } + if (!moved) LOG("【红】秘境:拍 %u 守护者现身,闯入首领(第 %d 位)退场落点与本图入口都没传成,留在场上(作罢,不给进度)", t, i + 1); + g_inv_gone[i] = K.inv_id[i]; if (iu) unit_xy(iu, &g_inv_gone_xy[i][0], &g_inv_gone_xy[i][1]); K.inv_st[i] = 4; K.inv_id[i] = 0; say("dmRiftSayInvaderGone"); } // 一位:人右下 6 格;两位:一左一右各 6 格。每位先照常按层改(守护者 = 本层怪物等级 + 3,起算层也 + 3,同吃本层总倍率),两位时再各乘 s(生命)与 d(伤害) // One Guardian: 6 tiles to the lower right of the player; two: 6 tiles to the left and to the right. Each is first scaled by level as usual (Guardian = this level's monster level + 3, the starting level + 3 as well, with this level's total multiplier), and with two each is additionally multiplied by s (life) and d (damage) static const int ox[2][2] = { { 6, 0 }, { 6, -6 } }, oy[2][2] = { { 6, 0 }, { 6, 6 } }; int x, y, n = 0; unit_xy(player, &x, &y); hs_sync(); @@ -1304,16 +1404,19 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) { if (K.nplan == 2 && !lowhp) ss(u, 25, (int)((100LL + gs(u, 25)) * hi_duo_x1000(1) / 1000 - 100)); // 伤害:属性 25 是「伤害 +N%」,整体乘 d 即 (100 + N) × d − 100 | damage: stat 25 is "damage +N%", so multiplying the whole by d gives (100 + N) x d - 100 HS.guard_hp += gs(u, 7) >> 8; LOG("秘境:拍 %u 刷守护者%s 类号 %d id %u 等级 %d 生命 %d 伤害百分比 %d", t, K.nplan == 2 ? (i ? "(第二位)" : "(第一位)") : "", K.gcls[i], K.guards[i], gs(u, 12), gs(u, 7) >> 8, gs(u, 25)); } - if (n) say(K.nplan == 2 && n == 2 ? "dmRiftSayGuardians" : "dmRiftSayGuardian"); } + atomic_store(&K.gtotal, n); if (n) say(K.nplan == 2 && n == 2 ? "dmRiftSayGuardians" : "dmRiftSayGuardian"); } // 测试替身 DM_RIFT_TEST_DUMMY=<每秒点数>:对在场的每位守护者按固定输出扣当前生命(留 1 点,由随从补最后一下)——人物不用真打,用来出「承伤每秒峰值」的相对值 // Test stand-in DM_RIFT_TEST_DUMMY=: deduct current life from every Guardian present at a fixed output (leaving 1 point, with a minion delivering the last hit) - the character does not have to fight for real; used to obtain relative values of the "per-second peak of damage taken" { static int dps = -1; if (dps < 0) { const char *e = getenv("DM_RIFT_TEST_DUMMY"); dps = e ? atoi(e) : 0; } + if (dps > 0) for (int i = 0; i < 2; i++) { uint64_t u = K.inv_st[i] == 2 ? find_unit(G, 1, K.inv_id[i]) : 0; uint32_t m = u ? *(uint32_t *)(uintptr_t)(u + 0xc) : 0; if (!u || m == 0 || m == 12) continue; /* 在场的闯入首领同样按固定输出扣 | an invading boss that is present is deducted at the fixed output as well */ + long long h = (long long)gs(u, 6) - (long long)dps * 256 / 25; ss(u, 6, h < 256 ? 256 : (int)h); } if (dps > 0 && K.guard && !atomic_load(&K.guard_dead)) for (int i = 0; i < 3; i++) { uint64_t u = K.guards[i] ? find_unit(G, 1, K.guards[i]) : 0; uint32_t m = u ? *(uint32_t *)(uintptr_t)(u + 0xc) : 0; if (!u || m == 0 || m == 12) continue; long long h = (long long)gs(u, 6) - (long long)dps * 256 / 25; ss(u, 6, h < 256 ? 256 : (int)h); } } // 结算条件:本场刷出的守护者全部死亡。任一位还活着(或还在单位表里没判死)都不结算、不开门 // Completion condition: all the Guardians spawned in this run are dead. While any one is alive (or still in the unit table and not judged dead) there is no completion and no door - if (K.guard && !atomic_load(&K.guard_dead)) { int alive = 0; uint64_t last = 0; + if (K.guard && !atomic_load(&K.guard_dead)) { int alive = 0, deadn = 0; uint64_t last = 0; for (int i = 0; i < 3; i++) { if (!K.guards[i]) continue; uint64_t u = find_unit(G, 1, K.guards[i]); if (!u) { alive++; continue; } /* 不在单位表里(房间卸载):不当它死了 | not in the unit table (room unloaded): do not treat it as dead */ - uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) { last = u; static uint32_t said[3]; if (said[i] != K.guards[i]) { said[i] = K.guards[i]; LOG("秘境:拍 %u 守护者死亡(类号 %d id %u)", t, K.gcls[i], K.guards[i]); } } else alive++; } + uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) { last = u; deadn++; static uint32_t said[3]; if (said[i] != K.guards[i]) { said[i] = K.guards[i]; LOG("秘境:拍 %u 守护者死亡(类号 %d id %u)", t, K.gcls[i], K.guards[i]); } } else alive++; } + atomic_store(&K.gdead, deadn); if (!alive && last) { atomic_store(&K.guard_dead, 1); LOG("秘境:拍 %u 守护者全部死亡 → 结算", t); finish(G, player, last); } } } diff --git a/dm/host/dm_rift.h b/dm/host/dm_rift.h index 7778874..e5e40a0 100644 --- a/dm/host/dm_rift.h +++ b/dm/host/dm_rift.h @@ -2,7 +2,7 @@ // Rift tower climb (dm_rift.c) #pragma once #include -typedef struct { int tier; float progress; int secs_left, done, guardian, inc, next, overtime; } dm_rift_hud_t; // overtime = 进行中且限时已到(还能打完拿掉落,不计通关);与菜单里的同名量同源;next = 本层完成后下一次打第几层(封顶 100;等于 tier = 不涨:超时,或已在最高层)。显示方只读它,不自己用 tier + inc 算 | overtime = in progress and the time limit has passed (can still be finished for loot, does not count as a clear); the same source as the quantity of the same name in the menu; next = which level will be played after this one is completed (capped at 100; equal to tier = no increase: overtime, or already at the highest level). Display code only reads it and does not compute tier + inc itself +typedef struct { int tier; float progress; int secs_left, done, guardian, inc, next, overtime, goal, gdead, gtotal; } dm_rift_hud_t; /* goal = 没结算时第二行该写哪一句(宿主定,显示方只照着选串):0 进度目标、1 击败守护者、2 击败守护者(已倒 / 总数)、3 已超时、4 已超时 + 击败守护者、5 已超时 + 击败守护者(已倒 / 总数);gdead / gtotal = 已倒下与本场已刷出的守护者数 | goal = which sentence the second line should show before completion (decided by the host; the display only picks the string accordingly): 0 progress goal, 1 slay the Guardian, 2 slay the Guardians (fallen / total), 3 overtime, 4 overtime + slay the Guardian, 5 overtime + slay the Guardians (fallen / total); gdead / gtotal = Guardians fallen and Guardians spawned this run */ // overtime = 进行中且限时已到(还能打完拿掉落,不计通关);与菜单里的同名量同源;next = 本层完成后下一次打第几层(封顶 100;等于 tier = 不涨:超时,或已在最高层)。显示方只读它,不自己用 tier + inc 算 | overtime = in progress and the time limit has passed (can still be finished for loot, does not count as a clear); the same source as the quantity of the same name in the menu; next = which level will be played after this one is completed (capped at 100; equal to tier = no increase: overtime, or already at the highest level). Display code only reads it and does not compute tier + inc itself void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base); // 服务端拍(diag.c) | Server tick (diag.c) void dm_rift_c2s(uint64_t G, const uint8_t *pkt, uint32_t len); // 客户端命令(点门) | Client command (door tap) void dm_rift_client_pump(uint8_t *main_base); // 取手柄处(dm_world.c):认击杀、新刷出的怪 | At the controller sampling point (dm_world.c): recognize kills and newly spawned monsters diff --git a/dm/host/tests/t_rift_next.c b/dm/host/tests/t_rift_next.c index 15d21e1..98e5ab7 100644 --- a/dm/host/tests/t_rift_next.c +++ b/dm/host/tests/t_rift_next.c @@ -51,6 +51,18 @@ int main(void) { K.tier = 100; if (10819454LL * hi_duo_x1000(0) / 1000 > 8388607LL) { fails++; printf(" ✗ 100 层巴尔 × s 过了属性上限\n"); } K.guards[0] = 7; K.guards[1] = 9; K.guards[2] = 0; if (!is_guard(7) || !is_guard(9) || is_guard(0) || is_guard(8)) { fails++; printf(" ✗ is_guard 认错\n"); } printf("hi_duo %s:4 格系数 + 巴尔不过上限 + 认守护者\n", fails ? "失败" : "OK"); + // 闯入首领也算「特殊单位」(不按普通怪计分、不按普通怪再改属性):在场的(K.inv_id)与已退场、还没被真移除的(g_inv_gone)都算—— + // 后者漏掉的话,退场后那几秒里被打死会按普通金怪计 10 分(实测过:进度 400 → 410) + // Invading bosses also count as "special units" (not scored as ordinary monsters, not scaled again as ordinary monsters): both the one present (K.inv_id) and one that has left but is not yet truly removed (g_inv_gone) - + // if the latter is missed, being killed in the few seconds after leaving would score 10 points as an ordinary unique monster (measured: progress 400 -> 410) + K.guards[0] = K.guards[1] = K.guards[2] = 0; K.inv_id[0] = 21; K.inv_id[1] = 0; g_inv_gone[0] = 0; g_inv_gone[1] = 33; + if (!is_guard(21) || !is_guard(33) || is_guard(22) || is_guard(0)) { fails++; printf(" ✗ is_guard 没认全闯入首领(在场 21、已退场 33)\n"); } + K.inv_id[0] = 0; g_inv_gone[1] = 0; if (is_guard(21) || is_guard(33)) { fails++; printf(" ✗ 清掉之后 is_guard 还认\n"); } + // 首领召唤物按类号认:巴尔触手 562–566、分身 570;巴尔本体 544、它的小怪 571、普通怪不算 + // Boss summons are recognised by class id: Baal's tentacles 562–566 and clone 570; Baal himself 544, his minions 571 and ordinary monsters do not count + { static const struct { uint32_t cls; int want; } bc[] = { { 561, 0 }, { 562, 1 }, { 564, 1 }, { 566, 1 }, { 567, 0 }, { 570, 1 }, { 571, 0 }, { 544, 0 }, { 45, 0 } }; + for (unsigned i = 0; i < sizeof bc / sizeof *bc; i++) if (boss_summon(bc[i].cls) != bc[i].want) { fails++; printf(" ✗ boss_summon(%u) 应为 %d\n", bc[i].cls, bc[i].want); } } + printf("invader_guard %s:在场与已退场的闯入首领都算特殊单位\n", fails ? "失败" : "OK"); printf("t_rift_next %s:%d 格(层 × 晋级量)下一层 = 手写期望且 ≤ 100,宿主与顶部条同值\n", fails ? "失败" : "OK", n); return fails != 0; } diff --git a/dm/host/tests/t_rift_oldrun.c b/dm/host/tests/t_rift_oldrun.c index 3f0c502..e0d9256 100644 --- a/dm/host/tests/t_rift_oldrun.c +++ b/dm/host/tests/t_rift_oldrun.c @@ -33,6 +33,12 @@ int main(void) { for (unsigned i = 0; i < sizeof oc / sizeof *oc; i++) { atomic_store(&K.st, oc[i].st); K.t0_ns = guest_ns() - (uint64_t)oc[i].ago * 1000000000ull; dm_rift_hud_t h = {0}; dm_rift_menu_t m = {0}; dm_rift_hud(&h); menu_fill(&m, 2); if (rift_overtime() != oc[i].want || m.overtime != oc[i].want || (oc[i].st != ST_IDLE && h.overtime != oc[i].want)) { fails++; printf(" ✗ 状态 %d 开局 %d 秒前:超时量应为 %d,得 %d(顶部条 %d、菜单 %d)\n", oc[i].st, oc[i].ago, oc[i].want, rift_overtime(), h.overtime, m.overtime); } } printf("rift_overtime %s:6 格\n", fails ? "失败" : "OK"); + // 顶部条第二行写哪一句(dm_rift_hud 的 goal,宿主一处定):按「是否超时 × 守护者是否在场 × 守护者几位」手写期望 + // Which sentence the second line of the top bar shows (goal of dm_rift_hud, decided in one place in the host): expected values written by hand over "overtime or not x Guardians present or not x how many Guardians" + static const struct { int ago, guard, dead, total, want; } gc[] = { { 100, 0, 0, 0, 0 }, { 100, 1, 0, 1, 1 }, { 100, 1, 0, 2, 2 }, { 100, 1, 1, 2, 2 }, { 100, 1, 1, 3, 2 }, { 901, 0, 0, 0, 3 }, { 901, 1, 0, 1, 4 }, { 901, 1, 1, 2, 5 } }; + for (unsigned i = 0; i < sizeof gc / sizeof *gc; i++) { atomic_store(&K.st, ST_RUN); K.t0_ns = guest_ns() - (uint64_t)gc[i].ago * 1000000000ull; K.guard = gc[i].guard ? 7 : 0; atomic_store(&K.guard_dead, 0); atomic_store(&K.gdead, gc[i].dead); atomic_store(&K.gtotal, gc[i].total); + dm_rift_hud_t h = {0}; dm_rift_hud(&h); if (h.goal != gc[i].want || h.gdead != gc[i].dead || h.gtotal != gc[i].total) { fails++; printf(" ✗ 开局 %d 秒前 守护者在场 %d(%d/%d):第二行应为 %d,得 %d\n", gc[i].ago, gc[i].guard, gc[i].dead, gc[i].total, gc[i].want, h.goal); } } + K.guard = 0; printf("hud_goal %s:8 格\n", fails ? "失败" : "OK"); printf("t_rift_oldrun %s:%d 格城里入口给页 + 新局重置清请求\n", fails ? "失败" : "OK", n); return fails != 0; } diff --git a/dm/i18n/ui_text.tsv b/dm/i18n/ui_text.tsv index 39a5611..634a0ca 100644 --- a/dm/i18n/ui_text.tsv +++ b/dm/i18n/ui_text.tsv @@ -204,6 +204,9 @@ dmRiftSayErr 秘境出错了,这次没开 The Rift could not be opened 秘境 dmRiftSayStart 第 %d 层开始,限时 15 分钟 Level %d: 15 minute time limit 秘境系统提示(dm_rift.c);英文:Greater Rift level / time limit 取自暗黑 3 官方 2.1.0 补丁说明(news.blizzard.com/en-us/article/14569138)「complete the current Greater Rift level within the designated time limit」 dmRiftSayGift 赠彩虹刻面一颗,已掉在脚下 A Rainbow Facet has dropped 秘境系统提示(dm_rift.c);「彩虹刻面」是旧译名(原版现行「彩虹魔石」);英文物品名 = 原版键 Rainbow Facet 的 enUS;英文:物品名 = 暗黑 2 原版 item-names[Rainbow Facet] dmRiftSayTimeout 时间到:本层未过关,守护者仍会掉落 Time's up: level not cleared 秘境系统提示(dm_rift.c);超时打倒守护者不算过关;英文:not cleared,不用 Failed(没死也没失败,只是不计) +dmRiftSayFoes 本场有 %d 位强敌 %d powerful foes this run 秘境系统提示(dm_rift.c):90 层起开局提示本场闯入首领的位数;英文:拟 +dmRiftSayInvader 强敌逼近! A powerful foe approaches! 秘境系统提示(dm_rift.c):80 层起途中闯入一位首领,刷出前约 3 秒提示;英文:拟 +dmRiftSayInvaderGone 闯入者退去了 The intruder withdraws 秘境系统提示(dm_rift.c):守护者现身时,还在场的闯入首领退场;英文:拟 dmRiftSayGuardians 进度已满:两位守护者现身! Two Rift Guardians appear! 秘境系统提示(dm_rift.c):75 层起守护者是两位;英文:同 dmRiftSayGuardian 的用词 dmRiftSayGuardian 进度已满:守护者现身! The Rift Guardian appears! 秘境系统提示(dm_rift.c);英文:Rift Guardian 取自暗黑 3 官方 2.1.0 补丁说明(news.blizzard.com/en-us/article/14569138);出现时的界面原句没查到,拟 dmElyToaGround 背包已满,赦免之证掉在脚边 Inventory full: Token of Absolution dropped 极乐世界新角色补齐(dm_elysium.c):背包放不下时的系统提示;英文物品名 = 暗黑 2 原版 Token of Absolution @@ -259,6 +262,9 @@ dmRiftHudGuard 守护者现身 Rift Guardian 秘境顶部进度条(dm_rift_hud dmRiftHudNext 下次第 %d 层 Next: Level %d 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟 dmRiftHudTop 已通关最高层 Highest level cleared 秘境顶部进度条(dm_rift_hud.m,UIKit):第 100 层限时内通关,没有下一层了(公开仓库);英文:拟 dmRiftHudOver 已超时:打完仍有掉落,不计通关 Overtime: drops, no clear 秘境顶部进度条(dm_rift_hud.m,UIKit)第二行:限时已到、守护者还没倒(公开仓库);英文:拟 +dmRiftHudKillN 击败守护者(%d/%d) Slay the Guardians (%d/%d) 秘境顶部进度条第二行:守护者两位以上时带已倒 / 总数;英文:同 dmRiftHudKill 的用词 +dmRiftHudOverKill 已超时:击败守护者仍有掉落 Overtime: slay it for drops 秘境顶部进度条第二行:已超时且守护者在场(一位);英文:拟 +dmRiftHudOverKillN 已超时:击败守护者(%d/%d)仍有掉落 Overtime: slay %d/%d for drops 同上,守护者两位以上;英文:拟 dmRiftHudSame 下次仍是这一层 Next: same level 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟 dmRiftHudKill 击败守护者 Slay the Rift Guardian 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟;任务目标原句没查到 dmRiftHudGoal 消灭秘境中的怪物 %d%% Slay the monsters %d%% 秘境顶部进度条(dm_rift_hud.m,UIKit);英文:拟;任务目标原句没查到 diff --git a/dm/ios/Sources/dm_rift_hud.m b/dm/ios/Sources/dm_rift_hud.m index 5fb740d..a2e5c38 100644 --- a/dm/ios/Sources/dm_rift_hud.m +++ b/dm/ios/Sources/dm_rift_hud.m @@ -75,7 +75,8 @@ void dm_rift_hud_draw(UIView *host, CGRect wr, BOOL hide) { NSString *st = h.done ? (h.inc ? [NSString stringWithFormat:@(dm_ui("dmRiftHudDone")), h.tier] : [NSString stringWithFormat:@(dm_ui("dmRiftHudLate")), h.tier]) : g ? @(dm_ui("dmRiftHudGuard")) : [NSString stringWithFormat:@(dm_ui("dmRiftTierN")), h.tier]; set_text(sub, st, d2font(14 * u), white, CGRectMake(48 * u, 9 * u, 130 * u, 19 * u), kCAAlignmentLeft); set_text(timer, [NSString stringWithFormat:@"%d:%02d", s / 60, s % 60], d2font(17 * u), (s <= 60 && !h.done) ? red : gold, CGRectMake(W - 90 * u, 6 * u, 80 * u, 22 * u), kCAAlignmentRight); - NSString *gl = h.done ? (!h.inc ? @(dm_ui("dmRiftHudSame")) : h.next > h.tier ? [NSString stringWithFormat:@(dm_ui("dmRiftHudNext")), h.next] : @(dm_ui("dmRiftHudTop"))) : h.overtime ? @(dm_ui("dmRiftHudOver")) : g ? @(dm_ui("dmRiftHudKill")) : [NSString stringWithFormat:@(dm_ui("dmRiftHudGoal")), (int)(h.progress * 100)]; // 已超时:第二行换成这一句,优先于「击败守护者」/ 进度目标(第一行照旧写第几层 / 守护者现身) | overtime: the second line becomes this sentence, taking priority over "Slay the Rift Guardian" / the progress goal (the first line still says which level / that the Guardian has appeared) + NSString *gl = h.done ? (!h.inc ? @(dm_ui("dmRiftHudSame")) : h.next > h.tier ? [NSString stringWithFormat:@(dm_ui("dmRiftHudNext")), h.next] : @(dm_ui("dmRiftHudTop"))) : h.goal == 5 ? [NSString stringWithFormat:@(dm_ui("dmRiftHudOverKillN")), h.gdead, h.gtotal] : h.goal == 4 ? @(dm_ui("dmRiftHudOverKill")) : h.goal == 3 ? @(dm_ui("dmRiftHudOver")) + : h.goal == 2 ? [NSString stringWithFormat:@(dm_ui("dmRiftHudKillN")), h.gdead, h.gtotal] : h.goal == 1 ? @(dm_ui("dmRiftHudKill")) : [NSString stringWithFormat:@(dm_ui("dmRiftHudGoal")), (int)(h.progress * 100)]; // 已超时:第二行换成这一句,优先于「击败守护者」/ 进度目标(第一行照旧写第几层 / 守护者现身) | overtime: the second line becomes this sentence, taking priority over "Slay the Rift Guardian" / the progress goal (the first line still says which level / that the Guardian has appeared) set_text(goal, gl, d2font(12 * u), grey, CGRectMake(10 * u, 32 * u, W - 20 * u, 17 * u), kCAAlignmentLeft); CGRect tr = CGRectMake(11 * u, 55 * u, W - 22 * u, 10 * u); // 含 1 单位外框(条 8 + 外框各 1) // 进度条:外框暗边 + 深底,填充金褐(守护者转暗红),每 10% 一道刻痕,两端菱形钉 | Includes the 1-unit outer frame (bar 8 + frame 1 on each side) // Progress bar: dark-edged outer frame + deep background, golden-brown fill (turns dark red for the guardian), a notch every 10%, diamond studs at both ends track.frame = tr; track.backgroundColor = rgb(25, 20, 14, 1).CGColor; track.borderColor = rgb(95, 78, 48, 1).CGColor; track.borderWidth = MAX(1, u); diff --git a/dm/ios/Sources/dm_touch_controls.c b/dm/ios/Sources/dm_touch_controls.c index acf7171..f244dc7 100644 --- a/dm/ios/Sources/dm_touch_controls.c +++ b/dm/ios/Sources/dm_touch_controls.c @@ -79,16 +79,18 @@ void dm_tc_layout_make(dm_tc_layout *l, float width, float height) { /* 左摇杆是浮动底盘:左下「起摇杆区」里手指落在哪,底盘圆心就落在哪,松手回静止位。 静止位:圆心离安全区左界 90(底盘半径 60 + 30)、不小于 120,离屏幕底 115——只是没按时画在哪。 起摇杆区:屏宽的左 40% × 屏高的下 55%(左与下到屏幕边:拇指压在刘海那一条上也算);区里我们的圆钮 / 腰带格、原版界面上可点的东西各自优先。 - 夹回:落点贴边时圆心挪回来,整个底盘留在安全区左界以右、底盘下沿离屏幕底不少于 25(不撞系统横条) + 夹回:只为底盘整圈画在屏内——落点离左沿 / 底沿不到「半径 + 8」时底盘圆心挪回到那条线上;只影响画,轴值仍按手指相对落点算(摇杆头 = 底盘圆心 + 轴值 × 半径)。不让安全区(原先左界取「安全区 + 半径」,刘海机型约 122 点: + 拇指自然落在离左边 60–120 点的人一落指就带明显的向左分量;左下角没有刘海也没有系统横条)。静止位仍让安全区,那只是没按时画在哪 The left stick is a floating base: wherever the finger lands inside the bottom-left "stick-start zone", the base centre goes there, and it returns to the rest position on release. Rest position: centre 90 from the left edge of the safe area (base radius 60 + 30), not less than 120, and 115 from the bottom of the screen - only where it is drawn while not pressed. Stick-start zone: the left 40% of the screen width x the lower 55% of the screen height (reaching the screen edges on the left and bottom: a thumb on the notch strip counts too); inside the zone our round buttons / belt cells and the clickable things of the original UI each take priority. - Clamping: when the touch point is near an edge the centre is moved back so that the whole base stays to the right of the safe area's left edge and its lower rim is at least 25 from the bottom of the screen (clear of the system bar) */ + Clamping: only so that the whole base is drawn on screen - when the touch point is closer than "radius + 8" to the left / bottom edge the base centre is moved back onto that line; it only affects drawing, and the axes are still computed from the finger relative to the touch point (stick knob = base centre + axes x radius). The safe area is not respected (the left bound used to be "safe area + radius", about 122 points on notched devices: + a thumb landing naturally 60–120 points from the left edge got a clear leftward component the moment it touched down; the bottom-left corner has neither a notch nor the system bar). The rest position still respects the safe area, which is only where it is drawn while not pressed */ l->joy_radius = 60*k; l->joy_x = fmaxf(90*k, g_safe_l + 60*k) + 30*k; l->joy_y = l->height - 115*k; l->joy_zone_r = l->width*0.40f; l->joy_zone_t = l->height*0.45f; - l->joy_min_x = g_safe_l + l->joy_radius; l->joy_max_y = l->height - 25*k - l->joy_radius; + l->joy_min_x = l->joy_radius + 8*k; l->joy_max_y = l->height - l->joy_radius - 8*k; } int dm_tc_hit(const dm_tc_layout *l, float x, float y) { @@ -214,7 +216,7 @@ static void update(dm_tc_state *s) { s->lx = s->ly = 0; if (s->joy_slot < 0) return; dm_tc_finger *f = &s->finger[s->joy_slot]; - float dx = f->x-s->joy_origin_x, dy = s->joy_origin_y-f->y; + float dx = f->x-s->joy_touch_x, dy = s->joy_touch_y-f->y; /* 相对落点,不相对底盘圆心:夹回只影响底盘画在哪,不进算法(贴角落指时圆心在手指右上方,按圆心算会出现手指往右、人往下) | relative to the touch point, not the base centre: clamping only affects where the base is drawn and does not enter the computation (touching down in a corner puts the centre to the upper right of the finger, and computing from the centre would make the character move down while the finger moves right) */ /* 输入行程不跟大屏的视觉放大走:拇指不随屏幕变大。满偏 60 点、死区 6 点,手机与 iPad 一致 (原先乘视觉倍数,12.9 寸 iPad 要推 105 点 ≈ 20 mm 才满偏,是手机的两倍)。底盘和摇杆头的大小仍按视觉倍数画。 Input travel does not follow the visual enlargement on large screens: the thumb does not grow with the screen. Full deflection 60 points, dead zone 6 points, same on phone and iPad @@ -388,7 +390,7 @@ void dm_tc_cancel_finger(dm_tc_state *s, int slot) { if (slot < 0 || slot >= DM_TC_MAX_TOUCH) return; ++s->gesture_epoch; if (s->finger[slot].active && s->finger[slot].target == DM_TC_PORTAL) { dm_tc_cancel_portal(s); } - if (slot == s->joy_slot && s->finger[slot].active) { s->joy_lost_s = s->last_time_s; s->joy_lost_x = s->finger[slot].x; s->joy_lost_y = s->finger[slot].y; s->joy_lost_ox = s->joy_origin_x; s->joy_lost_oy = s->joy_origin_y; } /* 系统取消了摇杆那根手指:记下,紧接着在附近重新落下的接着当摇杆 | the system cancelled the joystick finger: record it, and a finger landing again nearby right afterwards continues as the joystick */ + if (slot == s->joy_slot && s->finger[slot].active) { s->joy_lost_s = s->last_time_s; s->joy_lost_x = s->finger[slot].x; s->joy_lost_y = s->finger[slot].y; s->joy_lost_ox = s->joy_origin_x; s->joy_lost_oy = s->joy_origin_y; s->joy_lost_tx = s->joy_touch_x; s->joy_lost_ty = s->joy_touch_y; } /* 系统取消了摇杆那根手指:记下,紧接着在附近重新落下的接着当摇杆 | the system cancelled the joystick finger: record it, and a finger landing again nearby right afterwards continues as the joystick */ s->finger[slot] = (dm_tc_finger){.target=DM_TC_NONE}; if (slot == s->joy_slot) { s->joy_slot = DM_TC_NONE; s->joy_origin_x = s->joy_origin_y = 0; } if (slot == s->aim_slot) s->aim_slot = DM_TC_NONE; @@ -505,14 +507,14 @@ void dm_tc_begin_at(dm_tc_state *s, int slot, float x, float y, double now_s) { } else if (!s->navigation_mode && !s->joy_block && hit == DM_TC_NONE && s->joy_slot == DM_TC_NONE && x >= 0 && y <= s->layout.height && ((x < s->layout.joy_zone_r && y > s->layout.joy_zone_t) || (x < s->layout.width*0.43f && y > s->layout.height*0.25f && s->joy_lost_s > 0 && now_s - s->joy_lost_s <= DM_TC_JOY_RESUME_S && hypotf(x - s->joy_lost_x, y - s->joy_lost_y) <= DM_TC_JOY_GRAB_K * s->layout.joy_radius))) { - /* 浮动底盘:落在起摇杆区里就起摇杆,底盘圆心 = 落点(贴边时夹回,见布局处),方向与幅度按「手指相对底盘圆心」算,按住后拖到多远都照样识别, + /* 浮动底盘:落在起摇杆区里就起摇杆,底盘圆心 = 落点(贴边时夹回,见布局处),方向与幅度按「手指相对落点」算,按住后拖到多远都照样识别, 底盘不跟手走;落在区外照旧是点地。这一下若很快原地松开,仍兼作一次点击(dm_tc_end_at):区里的怪、掉落物、NPC 要点得到。 摇杆那根手指刚被系统取消(通知横幅、系统手势;dm_tc_cancel_finger 记下时刻与位置),DM_TC_JOY_RESUME_S 内在原处附近重新落下的手指接着当摇杆, - 哪怕落点已拖出起摇杆区。只开着讲话文字框 / 对话菜单时不起摇杆(joy_block):夹回会让落点 ≠ 圆心、一落下就有方向,那一下只该关框 - Floating base: a touch inside the stick-start zone starts the stick with the base centre = the touch point (clamped back near the edges, see the layout), direction and magnitude are computed from "finger relative to base centre", and once held, dragging any distance is still recognised; + 哪怕落点已拖出起摇杆区。只开着讲话文字框 / 对话菜单时不起摇杆(joy_block):那一下只该关框、人不走(落指位移为零本来也不出方向,但手指稍一滑就会走,照旧整根挡掉) + Floating base: a touch inside the stick-start zone starts the stick with the base centre = the touch point (clamped near the edges, see the layout), direction and magnitude are computed from "finger relative to the touch point", and once held, dragging any distance is still recognised; the base does not follow the finger; a touch outside the zone is a ground tap as before. If this touch is released quickly in place it still doubles as a tap (dm_tc_end_at): monsters, dropped items and NPCs inside the zone must remain tappable. When the stick finger has just been cancelled by the system (notification banner, system gesture; dm_tc_cancel_finger records the time and position), a finger touching down again near the same place within DM_TC_JOY_RESUME_S continues as the stick, - even if the touch point has been dragged out of the stick-start zone. The stick does not start while only a speech text box / dialogue menu is open (joy_block): clamping would make touch point != centre and give a direction the moment it lands, when that touch should only close the box */ + even if the touch point has been dragged out of the stick-start zone. The stick does not start while only a speech text box / dialogue menu is open (joy_block): that touch should only close the box without moving the character (zero displacement on touch-down gives no direction anyway, but a slight slide would walk, so the whole finger is still blocked) */ int resume = s->joy_lost_s > 0 && now_s - s->joy_lost_s <= DM_TC_JOY_RESUME_S && hypotf(x - s->joy_lost_x, y - s->joy_lost_y) <= DM_TC_JOY_GRAB_K * s->layout.joy_radius; s->joy_lost_s = 0; f->target = DM_TC_JOYSTICK; @@ -520,6 +522,7 @@ void dm_tc_begin_at(dm_tc_state *s, int slot, float x, float y, double now_s) { /* 接续的沿用取消前的圆心,不按新落点重定:触摸被系统反复打断又重来的机器上,每重来一次底盘就跳到手指当前位置,看着像底盘追着手指跑 | a continuation keeps the centre from before the cancel instead of re-centring on the new touch point: on devices where touches are repeatedly interrupted by the system and restarted, the base would jump to the finger's current position on every restart and look as if it were chasing the finger */ s->joy_origin_x = resume ? s->joy_lost_ox : fmaxf(x, s->layout.joy_min_x); s->joy_origin_y = resume ? s->joy_lost_oy : fminf(y, s->layout.joy_max_y); + s->joy_touch_x = resume ? s->joy_lost_tx : x; s->joy_touch_y = resume ? s->joy_lost_ty : y; /* 接续的沿用取消前的落点,同样不按新落点重定 | a continuation keeps the touch point from before the cancel, likewise not re-centred on the new touch point */ } update(s); } diff --git a/dm/ios/Sources/dm_touch_controls.h b/dm/ios/Sources/dm_touch_controls.h index e500634..6912cdd 100644 --- a/dm/ios/Sources/dm_touch_controls.h +++ b/dm/ios/Sources/dm_touch_controls.h @@ -19,7 +19,7 @@ typedef struct { float width, height; dm_tc_target target[DM_TC_COUNT]; float joy_x, joy_y, joy_radius; /* 没按时底盘的显示位置(静止位)与底盘半径 | where the base is shown while not pressed (rest position), and the base radius */ - float joy_zone_r, joy_zone_t, joy_min_x, joy_max_y; /* 起摇杆区的右界与上界(左与下到屏幕边);按下后底盘圆心的夹回界:x 不小于、y 不大于 | right and upper bounds of the stick-start zone (left and bottom reach the screen edges); clamp bounds for the base centre once pressed: x not less than, y not greater than */ + float joy_zone_r, joy_zone_t, joy_min_x, joy_max_y; /* 起摇杆区的右界与上界(左与下到屏幕边);按下后底盘圆心的夹回界:x 不小于、y 不大于(只为底盘整圈画在屏内:屏幕边 + 半径 + 8) | right and upper bounds of the stick-start zone (left and bottom reach the screen edges); clamp bounds for the base centre once pressed: x not less than, y not greater than (only so that the whole base is drawn on screen: screen edge + radius + 8) */ dm_tc_target swap; /* 技能组切换键:本地开关,不直接发按键 | Skill set switch key: a local toggle; does not send a key directly */ dm_tc_target diff; /* 底部 UI v4 第 0 格难度:点开 / 收起 1–8 选择条,不发按键 | Bottom UI v4 cell 0 difficulty: tap to open / collapse the 1–8 selector bar; sends no key */ dm_tc_target pick[8]; /* 选择条 8 格(第 i 格 = 人数档 i+1),在七格上方 | The selector bar's 8 cells (cell i = player-count level i+1), above the seven cells */ @@ -125,6 +125,7 @@ typedef struct { int belt_gap_cell; double belt_gap_at; /* 按着第二组技能时要喝药:先把 ZL 和技能键松开、空出 DM_TC_ZL_LEAD_S,到 belt_gap_at 才按腰带键(belt_gap_cell = 等着的那一格,0 = 没有) | to drink a potion while a skill of the second skill set is held: first release ZL and the skill key and leave a gap of DM_TC_ZL_LEAD_S, and only at belt_gap_at press the belt key (belt_gap_cell = the cell that is waiting, 0 = none) */ double joy_lost_s; float joy_lost_x, joy_lost_y, joy_lost_ox, joy_lost_oy; /* 摇杆手指被系统取消的时刻与当时的位置(0 = 没有):紧接着在附近重新落下的手指接着当摇杆 | time and position at which the joystick finger was cancelled by the system (0 = none): a finger landing again nearby right afterwards continues as the joystick */ int joy_block; /* 讲话文字框单独开着(前端不进面板态):这时落在底座上的手指不起摇杆,照旧只当一次点击(关讲话框)。前端按面板栈写 | speech text box open on its own (the front end does not enter panel state): a finger on the base starts no stick and is still just one click (closes the speech box). Written by the front end from the panel stack */ + float joy_touch_x, joy_touch_y, joy_lost_tx, joy_lost_ty; /* 摇杆那根手指的落点(方向与幅度一律按「手指相对落点」算;joy_origin 只是底盘画在哪 = 落点夹回屏内之后);被系统取消时记下的落点 | touch point of the stick finger (direction and magnitude are always computed from "finger relative to the touch point"; joy_origin is only where the base is drawn = the touch point clamped onto the screen); the touch point recorded when it was cancelled by the system */ double belt_pulse_s; /* 最近一次「给玩家喝」的腰带脉冲还在发的时刻:其间按着的第二组技能连同 ZL 一起让开,收回后 ZL 重新领先 DM_TC_ZL_LEAD_S 技能键才回来 | Time until which the most recent "player drinks" belt pulse is still being sent: during it the held second-set skill gives way together with ZL, and after the release ZL again leads by DM_TC_ZL_LEAD_S before the skill key comes back */ int belt_q; /* 此刻有别的脉冲在发 / 别的补发在等:排着,空了再落地(不互相盖掉)。值 = 格 | another pulse is being sent / another resend is pending: queue and fire when free (they never overwrite each other). Value = cell */ } dm_tc_state; diff --git a/dm/ios/tests/t_touch_controls.c b/dm/ios/tests/t_touch_controls.c index 6f11f89..ce51f63 100644 --- a/dm/ios/tests/t_touch_controls.c +++ b/dm/ios/tests/t_touch_controls.c @@ -118,11 +118,11 @@ static void two_fingers_same_key(void) { } static void joystick_deadzone(void) { /* 浮动底盘。667×375(k = 1、安全区 0)手算:静止位 (max(90, 0+60)+30, 375−115) = (120, 260);起摇杆区 x < 667×0.40 = 266.8 且 y > 375×0.45 = 168.75; - 夹回 x ≥ 0+60 = 60、y ≤ 375−25−60 = 290。落在区里起手:圆心 = 落点,位移为零 + 夹回只为底盘整圈在屏内:x ≥ 60+8 = 68、y ≤ 375−60−8 = 307(不让安全区)。落在区里起手:圆心 = 落点,位移为零 Floating base. Worked by hand for 667x375 (k = 1, safe area 0): rest position (max(90, 0+60)+30, 375-115) = (120, 260); stick-start zone x < 667x0.40 = 266.8 and y > 375x0.45 = 168.75; - clamp x >= 0+60 = 60, y <= 375-25-60 = 290. Starting inside the zone: centre = touch point, zero displacement */ + clamping only keeps the whole base on screen: x >= 60+8 = 68, y <= 375-60-8 = 307 (not respecting the safe area). Starting inside the zone: centre = touch point, zero displacement */ dm_tc_state s; dm_tc_init(&s,667,375); NEAR(s.layout.joy_x,120,0.001); NEAR(s.layout.joy_y,260,0.001); - NEAR(s.layout.joy_zone_r,266.8,0.001); NEAR(s.layout.joy_zone_t,168.75,0.001); NEAR(s.layout.joy_min_x,60,0.001); NEAR(s.layout.joy_max_y,290,0.001); + NEAR(s.layout.joy_zone_r,266.8,0.001); NEAR(s.layout.joy_zone_t,168.75,0.001); NEAR(s.layout.joy_min_x,68,0.001); NEAR(s.layout.joy_max_y,307,0.001); dm_tc_begin(&s,0,90,275); CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,90,0); NEAR(s.joy_origin_y,275,0); CHECK(s.lx==0 && s.ly==0); @@ -135,8 +135,15 @@ static void joystick_deadzone(void) { dm_tc_move(&s,0,600,200); CHECK(s.lx==DM_STICK_MAX && s.ly==0); NEAR(s.joy_origin_x,200,0); dm_tc_move(&s,0,200,25); CHECK(s.lx==0 && s.ly==DM_STICK_MAX); NEAR(s.joy_origin_y,200,0); dm_tc_end(&s,0); CHECK(s.joy_slot==-1 && s.lx==0 && s.ly==0); NEAR(s.layout.joy_x,120,0.001); - /* 贴左下角落指 (10,370):圆心夹回 (60,290),手指在圆心左下 (−50,−80),一落下就是左下满偏 | touching down against the bottom-left corner (10,370): the centre is clamped back to (60,290), the finger is at (-50,-80) to the lower left of the centre, so it is at full lower-left deflection the moment it lands */ - dm_tc_begin(&s,0,10,370); CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,60,0); NEAR(s.joy_origin_y,290,0); CHECK(s.lx<0 && s.ly<0); dm_tc_end(&s,0); + /* 贴左下角落指 (10,370):底盘画在夹回后的 (68,307),轴值按手指相对落点算——落指那一下为 0;向右挪 6 点仍在死区;7 点起出值 (7−6)/54 × 32767 = 607; + 向右拖满 60 点 = 向右满偏(不是按底盘圆心算出来的「左下」)。底盘不跟手走 + touching down against the bottom-left corner (10,370): the base is drawn at the clamped (68,307), and the axes are computed from the finger relative to the touch point - 0 on touch-down; moving 6 points right is still inside the dead zone; from 7 points the output is (7-6)/54 x 32767 = 607; + dragging the full 60 points right = full right deflection (not the "down-left" one would get by computing from the base centre). The base does not follow the finger */ + dm_tc_begin(&s,0,10,370); CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,68,0); NEAR(s.joy_origin_y,307,0); CHECK(s.lx==0 && s.ly==0); + dm_tc_move(&s,0,16,370); CHECK(s.lx==0 && s.ly==0); + dm_tc_move(&s,0,17,370); CHECK(abs(s.lx-607)<=1 && s.ly==0); + dm_tc_move(&s,0,70,370); CHECK(s.lx==DM_STICK_MAX && s.ly==0); NEAR(s.joy_origin_x,68,0); NEAR(s.joy_origin_y,307,0); + dm_tc_end(&s,0); dm_tc_begin(&s,0,266,169); CHECK(s.joy_slot==0); NEAR(s.joy_origin_x,266,0); NEAR(s.joy_origin_y,169,0); dm_tc_end(&s,0); /* 区的右上角以内 | just inside the zone's top-right corner */ /* 区外:不起摇杆,拖也不变成摇杆 | outside the zone: no stick starts, and dragging does not turn into a stick either */ dm_tc_begin(&s,0,267,275); CHECK(s.joy_slot==-1 && s.lx==0); dm_tc_end(&s,0); @@ -145,13 +152,31 @@ static void joystick_deadzone(void) { /* 区里很快原地松开的那一下兼作点击(落点记成点世界),按久了 / 拖开了的不算 | a quick release in place inside the zone doubles as a tap (the touch point is recorded as a world tap); held long / dragged away does not count */ { unsigned q = s.world_tap_seq; dm_tc_begin_at(&s,0,150,250,40.0); dm_tc_end_at(&s,0,40.1); CHECK(s.world_tap_seq==q+1); NEAR(s.world_tap_x,150,0); NEAR(s.world_tap_y,250,0); dm_tc_begin_at(&s,0,150,250,41.0); dm_tc_move_at(&s,0,200,250,41.05); dm_tc_end_at(&s,0,41.1); CHECK(s.world_tap_seq==q+1); } - /* 拖远了的摇杆手指被系统取消,0.2 秒后在离取消处 40 点的 (236,128) 重新落下((260,160) 偏 (−24,−32);已在起摇杆区上界 168.75 之外):接着当摇杆,圆心沿用取消前的 (90,275)、方向按旧圆心算;超时:不接 | the stick finger, dragged far away, is cancelled by the system and 0.2 s later touches down again at (236,128), 40 points from where it was cancelled ((260,160) offset by (-24,-32); already above the zone's upper bound 168.75): it continues as the stick, the centre stays at (90,275) from before the cancel and the direction is computed from the old centre; after the timeout: not continued */ + /* 拖远了的摇杆手指被系统取消,0.2 秒后在离取消处 40 点的 (236,128) 重新落下((260,160) 偏 (−24,−32);已在起摇杆区上界 168.75 之外):接着当摇杆,落点与底盘沿用取消前的 (90,275)、方向按旧落点算;超时:不接 | the stick finger, dragged far away, is cancelled by the system and 0.2 s later touches down again at (236,128), 40 points from where it was cancelled ((260,160) offset by (-24,-32); already above the zone's upper bound 168.75): it continues as the stick, the touch point and base stay at (90,275) from before the cancel and the direction is computed from the old touch point; after the timeout: not continued */ dm_tc_begin_at(&s,0,90,275,50.0); dm_tc_move_at(&s,0,260,160,50.2); CHECK(s.lx>0 && s.ly>0); dm_tc_cancel_finger(&s,0); CHECK(s.joy_slot==-1 && s.lx==0); dm_tc_begin_at(&s,1,236,128,50.4); CHECK(s.joy_slot==1 && s.lx>0 && s.ly>0); NEAR(s.joy_origin_x,90,0); NEAR(s.joy_origin_y,275,0); dm_tc_cancel_finger(&s,1); dm_tc_begin_at(&s,2,236,128,50.4+0.36); CHECK(s.joy_slot==-1); dm_tc_end_at(&s,2,51.5); /* 超过 0.35 秒、落点在区外 | beyond 0.35 s, touch point outside the zone */ - /* 取消后在区里别处重落(离取消处 140 点,不算接续):按新落点起一个新的,圆心 (265, min(300,290)) | after a cancel, touching down elsewhere in the zone (140 points from where it was cancelled, not a continuation): a new stick starts at the new touch point, centre (265, min(300,290)) */ + /* 取消后在区里别处重落(离取消处 140 点,不算接续):按新落点起一个新的,圆心 (265, min(300,307)) = (265,300),落指那一下轴为 0 | after a cancel, touching down elsewhere in the zone (140 points from where it was cancelled, not a continuation): a new stick starts at the new touch point, centre (265, min(300,307)) = (265,300), axes 0 on touch-down */ dm_tc_begin_at(&s,0,90,275,52.0); dm_tc_move_at(&s,0,260,160,52.2); dm_tc_cancel_finger(&s,0); - dm_tc_begin_at(&s,1,265,300,52.3); CHECK(s.joy_slot==1); NEAR(s.joy_origin_x,265,0); NEAR(s.joy_origin_y,290,0); dm_tc_end_at(&s,1,53.5); + dm_tc_begin_at(&s,1,265,300,52.3); CHECK(s.joy_slot==1); NEAR(s.joy_origin_x,265,0); NEAR(s.joy_origin_y,300,0); CHECK(s.lx==0 && s.ly==0); dm_tc_end_at(&s,1,53.5); +} +/* 956×440(k = 1)手算:夹回界 x ≥ 60+8 = 68、y ≤ 440−68 = 372,只决定底盘画在哪:(6,434) → (68,372);(60,400) → (68,372);(150,330) → 不夹。 + 三处落指那一下轴都为 0;各自向右、向上、向左上(45°)拖 60 点,轴值只看手指相对落点,三处完全相同: + 向右 (60,0) → (32767, 0);向上 (0,60) → (0, 32767);向左上 (−42.43, 42.43) → 斜向预修正后 (−1, 2)/√5 × 32767 = (−14654, 29308)(走出来的屏幕方向 = 手指方向,同 joystick_axes 那例)。 + 贴左下角时向左 / 向下拖不出 60 点(手指到屏幕边了)是物理限制,不在这里测 + Worked by hand for 956x440 (k = 1): clamp bounds x >= 60+8 = 68, y <= 440-68 = 372, which only decide where the base is drawn: (6,434) -> (68,372); (60,400) -> (68,372); (150,330) -> not clamped. + At all three touch points the axes are 0 on touch-down; dragging 60 points right, up and up-left (45 degrees) from each, the axes depend only on the finger relative to the touch point and are identical for all three: + right (60,0) -> (32767, 0); up (0,60) -> (0, 32767); up-left (-42.43, 42.43) -> after the diagonal pre-correction (-1, 2)/sqrt(5) x 32767 = (-14654, 29308) (the screen direction walked = the finger direction, as in the joystick_axes example). + Near the bottom-left corner a drag of 60 points to the left / downwards is not possible (the finger reaches the screen edge); that is a physical limit and not tested here */ +static void joystick_clamp_956(void) { + static const float at[3][4] = {{6, 434, 68, 372}, {60, 400, 68, 372}, {150, 330, 150, 330}}; + dm_tc_state s; dm_tc_init(&s,956,440); NEAR(s.layout.joy_min_x,68,0.001); NEAR(s.layout.joy_max_y,372,0.001); + for (int i = 0; i < 3; i++) { float x = at[i][0], y = at[i][1]; + dm_tc_begin(&s,0,x,y); NEAR(s.joy_origin_x,at[i][2],0); NEAR(s.joy_origin_y,at[i][3],0); CHECK(s.lx==0 && s.ly==0); + dm_tc_move(&s,0,x+60,y); CHECK(s.lx==DM_STICK_MAX && s.ly==0); + dm_tc_move(&s,0,x,y-60); CHECK(s.lx==0 && s.ly==DM_STICK_MAX); + dm_tc_move(&s,0,x-42.4264f,y-42.4264f); CHECK(abs(s.lx+14654)<=2 && abs(s.ly-29308)<=2); + NEAR(s.joy_origin_x,at[i][2],0); NEAR(s.joy_origin_y,at[i][3],0); dm_tc_end(&s,0); } } static void joystick_axes(void) { dm_tc_state s; dm_tc_init(&s,667,375); dm_tc_begin(&s,0,90,275); /* 圆心 90,275;下面各点 = 原用例整体平移 (−10, +75) | center 90,275; the points below = the original cases shifted as a whole by (−10, +75) */ @@ -437,7 +462,7 @@ static void safe_insets(void) { dm_tc_set_safe_insets(62, 62); dm_tc_layout_make(&b, 956, 440); dm_tc_set_safe_insets(0, 0); NEAR(a.target[DM_TC_MAIN].x, 900, 0.001); NEAR(b.target[DM_TC_MAIN].x, 854, 0.001); NEAR(b.target[DM_TC_MAIN].y, a.target[DM_TC_MAIN].y, 0.001); for (int i = DM_TC_SKILL1; i <= DM_TC_SKILL4; ++i) { NEAR(a.target[i].x - b.target[i].x, 46, 0.001); NEAR(a.target[i].y, b.target[i].y, 0.001); CHECK(b.target[i].x + b.target[i].r <= 894.001f); } - NEAR(a.swap.x - b.swap.x, 46, 0.001); NEAR(a.joy_x, 120, 0.001); NEAR(b.joy_x, 152, 0.001); NEAR(b.joy_min_x, 122, 0.001); NEAR(a.joy_y, 325, 0.001); NEAR(a.joy_max_y, 355, 0.001); /* 静止位 max(90, 安全区 + 60) + 30、440 − 115;夹回界 安全区 + 60、440 − 25 − 60 | rest position max(90, safe area + 60) + 30, 440 - 115; clamp bounds safe area + 60, 440 - 25 - 60 */ + NEAR(a.swap.x - b.swap.x, 46, 0.001); NEAR(a.joy_x, 120, 0.001); NEAR(b.joy_x, 152, 0.001); NEAR(b.joy_min_x, 68, 0.001); NEAR(a.joy_y, 325, 0.001); NEAR(a.joy_max_y, 372, 0.001); /* 静止位 max(90, 安全区 + 60) + 30、440 − 115(让安全区);夹回界 60 + 8、440 − 60 − 8(不让安全区) | rest position max(90, safe area + 60) + 30, 440 - 115 (respecting the safe area); clamp bounds 60 + 8, 440 - 60 - 8 (not respecting the safe area) */ dm_tc_layout c; dm_tc_layout_make(&c, 956, 440); NEAR(c.target[DM_TC_MAIN].x, 900, 0.001); } /* 换组键:956×440 下主键中心 (900,358),换组键在技能一正下方 (900−112, 358+52) = (788,410),半径 22;不与技能一(中心 (788,358) 半径 26)重叠、不出屏 | Set-switch button: at 956×440 the main button center is (900,358), the set-switch button is directly below skill one at (900−112, 358+52) = (788,410), radius 22; it does not overlap skill one (center (788,358), radius 26) and does not go off screen */ @@ -556,7 +581,7 @@ static void belt_single_double(void) { } int main(void) { RUN(layout_667); RUN(layout_812); RUN(layout_956); RUN(layout_1024); RUN(layout_ipad169); RUN(layout_pixels); RUN(small_layout); RUN(difficulty_picker); - RUN(hit_edges); RUN(key_hold_and_ownership); RUN(two_fingers_same_key); RUN(joystick_deadzone); + RUN(hit_edges); RUN(key_hold_and_ownership); RUN(two_fingers_same_key); RUN(joystick_deadzone); RUN(joystick_clamp_956); RUN(joystick_axes); RUN(joystick_plus_skills); RUN(no_auto_handoff); RUN(background_no_key); RUN(circles_before_joystick); RUN(cancel_and_resize); RUN(deferred_skill_vs_belt); RUN(held_skill2_vs_belt); RUN(belt_single_double); RUN(no_ui_drag_outside_modal); RUN(invalid_slots_and_repeated_begin); RUN(all_slots_hold); RUN(enabled_targets); RUN(ui_scene_messages); RUN(pointer_tap); RUN(world_tap); RUN(pointer_outside_close); RUN(scene_dialog_only); RUN(pointer_item_tap); RUN(pointer_stack_tap); RUN(pointer_over_disabled_target); RUN(ui_drag_typing); RUN(pointer_drag_out); RUN(pointer_drag); RUN(pointer_long); RUN(pointer_long_then_drag); RUN(pointer_long_seq); RUN(pointer_shop_drag); RUN(pointer_control_hit); RUN(pointer_game_mode); RUN(pointer_pulse_queue); RUN(safe_insets); RUN(swap_key); diff --git a/dm/tools/patch_nso.py b/dm/tools/patch_nso.py index c98d2db..0a97409 100644 --- a/dm/tools/patch_nso.py +++ b/dm/tools/patch_nso.py @@ -641,6 +641,7 @@ if RULE_RUN and PRIVATE_GATES: obs.append((0x463f40, 19, "f81c0ff7", "client per-frame position-error smoothing entry (s0 = frame length in ticks), called by the main loop right after all units were extrapolated in place and before the per-unit error is added back: the native error is only computed on start / stop (0x4639c0, which runs before the tick loop), so a sharp turn inside a tick snaps the extrapolated position back in one frame; the host adds that frame's jump to the local player's error fields (path +0x2a8 / +0x2ac, same clamp as native) and the native code decays it")) obs.append((0x9da5b0, 20, "d104c3ff", "model yaw component per-frame update entry (x1 = argument block: +8 component, +0x20 -> +8 unit): the body turn speed is instance data on the component (+0x10..+0x2c min / max degrees per second for controller / mouse, +0x34 spring parameter); the host only reads them for the local player when a test switch is set")) obs.append((0x2f7664, 7, "6dbb23e9", "touch target rank: candidate compare entry (closure, unit, kind, s0=score); host raises Boss/elite score, native eligibility unchanged")) + obs.append((0xb0d560, 21, "fc1a0fe8", "TooltipsPanel add-tooltip entry (panel, text, target position x2 / x3, style, text2): tooltips are immediate-mode (re-submitted by the hovered widget every frame and cleared after drawing, so the host cannot reach the record at its own time); on touch, in panel state, for an item the player just tapped, the host swaps the target position so the game lays the tooltip out beside the panel instead of over the item grid; everything else passes through unchanged")) for off, oid, ow, why in obs: w = struct.unpack_from('