Greater Rift: two Guardians from level 75, overtime status spelled out (#33); item descriptions stay open on touch (#32); Mac: click monsters to attack, items take the mouse, Share Log
The overtime status (#33) was reported with a clear direction by Joe Hu, who also sent a patch along the same lines (#34). Co-authored-by: Joe Hu <12777592+hubeiqiao@users.noreply.github.com>
This commit is contained in:
+94
-18
@@ -100,7 +100,7 @@ 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 score, need; uint64_t t0_ns; _Atomic int timeout, guard_dead; // 分数(客户端加)、开局时刻(客体时钟)、超时、守护者已死 | Score (added by the client), start time (guest clock), timed out, guardian dead
|
||||
uint32_t guard; int guard_cls, inc; // 守护者单位 id;成功涨了几层 | Guardian unit id; how many levels were gained on success
|
||||
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)
|
||||
int resume_tier; // 图用完 → 一键重开后新局里要直接开的层(0 = 无) | Maps ran out -> the level to open directly in the new run after the one-tap restart (0 = none)
|
||||
@@ -286,13 +286,18 @@ int dm_rift_active(void) { return atomic_load(&K.st) == ST_RUN; }
|
||||
// The next level after this one is completed: completing within the time limit goes up K.inc levels (capped at 100), completing overtime does not go up. The next level is computed in this one place only - the door at the Guardian, the completion log and "next: level N" on the progress bar at the top all take it from here
|
||||
// (the top bar used to compute tier + inc by itself without the cap, and wrote "next: level 103" after a timed clear of level 100)
|
||||
static int next_tier(void) { int nt = K.inc ? K.tier + K.inc : K.tier; return nt > 100 ? 100 : nt; }
|
||||
// 「进行中且已超时」:限时到了但守护者还没倒——还能打完、有掉落,但不计通关。只有这一处算;顶部条与城里入口菜单都读它,不各自拿剩余秒数去猜
|
||||
// (公开仓库 超时后只弹一次提示,之后顶部条只剩红色 0:00 和平常的目标,城里菜单仍叫「进行中」,分不清是超时还是还在限时内)
|
||||
// "In progress and overtime": the time limit has passed but the Guardian is not down yet - the run can still be finished and still drops loot, but does not count as a clear. Computed in this one place only; the top bar and the town entrance menu both read it instead of each guessing from the seconds left
|
||||
// (after timing out only one message was shown, then the top bar was left with a red 0:00 and the usual goal, and the town menu still said "in progress", so overtime could not be told from still being within the limit)
|
||||
static int rift_overtime(void) { return atomic_load(&K.st) == ST_RUN && K.t0_ns && guest_ns() - K.t0_ns >= (uint64_t)RIFT_SECS * 1000000000ull; }
|
||||
static int g_left_done; // 结算时剩余秒数:打倒守护者后顶部条与面板都显示它,不再往下走 | Seconds left at completion: after the guardian is defeated both the top bar and the panel show it, and it no longer counts down
|
||||
int dm_rift_hud(dm_rift_hud_t *o) {
|
||||
int st = atomic_load(&K.st); if (st != ST_RUN && st != ST_DONE) return 0;
|
||||
uint64_t now = guest_ns();
|
||||
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->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();
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -301,7 +306,54 @@ int dm_rift_hud(dm_rift_hud_t *o) {
|
||||
enum { NQ = 256 };
|
||||
static _Atomic uint32_t g_newq[NQ]; static _Atomic uint32_t g_newq_w; // 新见到的敌对怪 id(服务端按目标等级改属性) | Newly seen hostile monster ids (the server changes stats by target level)
|
||||
static uint32_t g_swept[1024]; int dm_rift_swept(uint32_t id) { return id && g_swept[id & 1023] == id; } // 这只是结算后清掉的(积分牌不计击杀) | This one was cleared after completion (the kill board does not count the kill)
|
||||
// ---- 75 层以上的内容(设计稿)。总开关 DM_RIFT_HI=0 整体关回原状;测试开关 DM_RIFT_TEST_HI=<段名,…> 在任意层强制某一段(duo = 双守护者)
|
||||
// ---- Content above level 75 (design draft). The master switch DM_RIFT_HI=0 turns it all back to the previous behaviour; the test switch DM_RIFT_TEST_HI=<segment,...> forces a segment at any level (duo = dual Guardians)
|
||||
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 未用读数校过
|
||||
// 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
|
||||
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 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 步):只记、不改任何玩法。结算时打一行:
|
||||
// 用时;击杀只数与这些怪的生命上限之和(按层改完之后的值,守护者另加);本场认作敌对并改过属性的怪的只数与生命和;
|
||||
// 玩家受到的伤害和(当前生命逐拍下降量之和,回血不抵)、每秒峰值(连续 25 拍内的最大和)、死亡次数;
|
||||
// 玩家 40 格内活着的敌对单位数的峰值与均值(每 25 拍数一次,只在秘境图里数)。
|
||||
// 生命以点计(原始定点 >> 8)。表按单位号记,每开一层清一次。击杀在客户端每帧函数里认(另一条线程),所以两个累加量用原子量;其余只在服务端拍里读写
|
||||
// ---- Per-run readouts (the measuring tool for the content curve above level 75, step 0 of the design): record only, change no gameplay. One line at completion:
|
||||
// time taken; number of kills and the sum of those monsters' maximum life (the values after per-level scaling, Guardian added separately); number and life total of the monsters recognised as hostile and scaled in this run;
|
||||
// total damage the player took (sum of per-tick drops in current life, healing not offset), the per-second peak (largest sum within 25 consecutive ticks), number of deaths;
|
||||
// peak and mean of the number of living hostile units within 40 tiles of the player (counted every 25 ticks, only on rift maps).
|
||||
// Life is in points (raw fixed point >> 8). The table is keyed by unit id and cleared at the start of every level. Kills are recognised in the client's per-frame function (another thread), so the two accumulators are atomics; everything else is read and written only on server ticks
|
||||
static struct { int seq; uint32_t id[4096]; int hp[4096]; _Atomic long long kill_hp; _Atomic int kills; long long spawn_hp, guard_hp, dmg, win[25], win_sum, dmg_peak, near_sum; int spawns, wi, last_hp, deaths0, near_peak, near_n; } HS;
|
||||
static int unit_align(uint64_t u);
|
||||
static void hs_sync(void) { int sq = atomic_load(&g_run_seq); if (sq == HS.seq) return; memset(&HS, 0, sizeof HS); HS.seq = sq; HS.deaths0 = R.deaths; }
|
||||
static void hs_spawn(uint32_t id, int hp) { hs_sync(); HS.id[id & 4095] = id; HS.hp[id & 4095] = hp; HS.spawns++; HS.spawn_hp += hp; }
|
||||
static void hs_kill(uint32_t id) { if (HS.id[id & 4095] != id) return; atomic_fetch_add(&HS.kill_hp, HS.hp[id & 4095]); atomic_fetch_add(&HS.kills, 1); }
|
||||
static void hs_tick(uint64_t G, uint64_t player, uint32_t t, int lv) {
|
||||
hs_sync(); int hp = gs(player, 6) >> 8, d = HS.last_hp > 0 && hp < HS.last_hp ? HS.last_hp - hp : 0; HS.last_hp = hp;
|
||||
HS.dmg += d; HS.win_sum += d - HS.win[HS.wi]; HS.win[HS.wi] = d; HS.wi = (HS.wi + 1) % 25; if (HS.win_sum > HS.dmg_peak) HS.dmg_peak = HS.win_sum;
|
||||
// 测试读数 DM_RIFT_TEST_HSLOG=1:每 750 拍打一行进行中的读数(自动跑的局打不完一整场时,用「击杀生命和 ÷ 已得分数」推算整场)
|
||||
// Test readout DM_RIFT_TEST_HSLOG=1: print one line of in-progress readouts every 750 ticks (when an automated run cannot finish a whole run, the whole run is estimated from "killed life total / score so far")
|
||||
{ static int on = -1; if (on < 0) on = getenv("DM_RIFT_TEST_HSLOG") != NULL; if (on && t % 750 == 0 && atomic_load(&K.st) == ST_RUN) { int sc = atomic_load(&K.score);
|
||||
LOG("秘境:读数(进行中)第 %d 层 拍 %u:分数 %d / %d,击杀 %d 只、生命和 %lld 点(每分 %.0f 点);改过属性的敌对怪 %d 只、生命和 %lld 点;40 格内敌对单位 峰值 %d / 均值 %.1f", K.tier, t, sc, atomic_load(&K.need), atomic_load(&HS.kills), atomic_load(&HS.kill_hp), sc ? (double)atomic_load(&HS.kill_hp) / sc : 0.0, HS.spawns, HS.spawn_hp, HS.near_peak, HS.near_n ? (double)HS.near_sum / HS.near_n : 0.0); } }
|
||||
if (t % 25 || !in_rift_map(lv)) return;
|
||||
int px, py, n = 0; if (!unit_xy(player, &px, &py)) return;
|
||||
for (int b = 0; b < 128; b++) for (uint64_t u = rd(G + 0x2230 + 1 * 0x400 + 8 * b); u; u = rd(u + 0x158)) { uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); int x, y;
|
||||
if (m == 0 || m == 12 || unit_level(u) != lv || !unit_xy(u, &x, &y) || abs(x - px) > 40 || abs(y - py) > 40 || unit_align(u)) continue; n++; }
|
||||
HS.near_sum += n; HS.near_n++; if (n > HS.near_peak) HS.near_peak = n;
|
||||
}
|
||||
static void hs_report(int secs) {
|
||||
LOG("秘境:读数 第 %d 层 用时 %d 秒:击杀 %d 只、生命和 %lld 点(另守护者 %lld 点);改过属性的敌对怪 %d 只、生命和 %lld 点;承伤和 %lld 点、每秒峰值 %lld 点、死亡 %d 次;40 格内敌对单位 峰值 %d / 均值 %.1f(采样 %d 次)",
|
||||
K.tier, secs, atomic_load(&HS.kills), atomic_load(&HS.kill_hp), HS.guard_hp, HS.spawns, HS.spawn_hp, HS.dmg, HS.dmg_peak, R.deaths - HS.deaths0, HS.near_peak, HS.near_n ? (double)HS.near_sum / HS.near_n : 0.0, HS.near_n);
|
||||
}
|
||||
void dm_rift_client_pump(uint8_t *b) {
|
||||
static uint32_t seen[4096], dead[4096]; static int lvp = -1;
|
||||
// 每开一层清一次「见过 / 已算死」两张表:表按单位号记,而单位号每局从头编——上一局(一键重开、退出再进)或上一层留下的记录会让新局里
|
||||
@@ -329,13 +381,13 @@ void dm_rift_client_pump(uint8_t *b) {
|
||||
if (!in_rift_map(lv)) return;
|
||||
for (int k = 0; k < 128; k++) for (uint64_t u = rd((uint64_t)(uintptr_t)(b + 0x2d603a0 + 1 * 0x400 + k * 8)); u; u = rd(u + 0x158)) {
|
||||
uint32_t id = *(uint32_t *)(uintptr_t)(u + 8), m = *(uint32_t *)(uintptr_t)(u + 0xc), h = id & 4095;
|
||||
if (id == K.guard) continue; // 守护者另算 | The guardian is counted separately
|
||||
if (is_guard(id)) continue; // 守护者另算 | The guardian is counted separately
|
||||
int alive = m != 0 && m != 12;
|
||||
if (alive) { if (seen[h] == id) continue;
|
||||
if (((int (*)(int, uint64_t, uint64_t))(b + 0x2f7b7c))(0x165, pl, u) != 1) continue;
|
||||
seen[h] = id; uint32_t w = atomic_fetch_add(&g_newq_w, 1); atomic_store(&g_newq[w % NQ], id); continue; }
|
||||
if (seen[h] != id || dead[h] == id) continue; // 只算活着时见过、认作敌对的 | Count only those seen alive and identified as hostile
|
||||
dead[h] = id; uint64_t md = rd(u + 0x10); uint8_t fl = md ? *(uint8_t *)(uintptr_t)(md + 0x1a) : 0; int p = pts_of(fl);
|
||||
dead[h] = id; hs_kill(id); uint64_t md = rd(u + 0x10); uint8_t fl = md ? *(uint8_t *)(uintptr_t)(md + 0x1a) : 0; int p = pts_of(fl);
|
||||
int s = atomic_fetch_add(&K.score, p) + p; static int ln; if (ln++ < 40 || s % 50 < p) LOG("秘境:击杀 id %u(标志 %#x,+%d)→ 分数 %d / %d", id, fl, p, s, atomic_load(&K.need));
|
||||
}
|
||||
}
|
||||
@@ -400,12 +452,13 @@ static uint32_t monlvl(uint64_t G, int lvl, int grp) { uint64_t T = tables(G), a
|
||||
// for a unit with a percentage life bonus, writing the base up to the limit makes the total overflow to a negative number, which is read as 1 point (this is how minions fell back to 1). So headroom is left according to the current total / base.
|
||||
// base / full = the base entry and the total at this moment (raw fixed-point values); with no bonus (total not greater than base) or when the base entry cannot be read, it is the stat limit itself
|
||||
static long long hp_base_limit(int base, int full) { return base > 0 && full > base ? 0x7fffff00LL * base / full : 0x7fffff00LL; }
|
||||
static int g_hp_mul = 1000; // scale_monster 的生命额外系数(×1000):双守护者的 s 在截顶之前乘进去——先截顶再乘的话,规则值过上限的那位(巴尔)会被多砍一刀 | extra life factor of scale_monster (x1000): the dual-Guardian s is multiplied in before the clamp - clamping first and multiplying afterwards would cut the one whose rule value exceeds the limit (Baal) a second time
|
||||
static void scale_monster(uint64_t G, uint64_t u, int lt, int l9) { // lt = 本层的等级(守护者 + 3)、l9 = 起算层的等级 | lt = this level's level (Guardian + 3), l9 = the baseline level's level
|
||||
int l0 = gs(u, 12); if (l0 <= 0) return; if (lt > lvl_cap()) lt = lvl_cap(); if (l9 > lt) l9 = lt;
|
||||
int tx = tier_total_x1000(K.tier, 0), lb = l0 > l9 ? l0 : l9, le = l0 > lt ? l0 : lt; // lb:「起算层那只怪」的等级;le:写进单位的等级(不降级) | lb: the level of "that monster at the baseline level"; le: the level written into the unit (never lowered)
|
||||
if (le == l0 && lb == l0 && tx == 1000) return; // 9 层、原生等级已不低于目标:什么都不用改 | level 9 and the native level is already no lower than the target: nothing to change
|
||||
uint32_t h0 = monlvl(G, l0, 2), hb = monlvl(G, lb, 2), d0 = monlvl(G, l0, 3), db = monlvl(G, lb, 3), a0 = monlvl(G, l0, 0), a1 = monlvl(G, le, 0); if (!h0 || !d0 || !a0) return;
|
||||
long long want = (long long)gs(u, 7) * hb / h0 * tx / 1000, hp = want, lim = hp_base_limit(gsb(u, 7), gs(u, 7)); if (hp > lim) hp = lim; // 定点 ×256;原版上限 2²³ 点,带百分比生命加成的怪按比例留余量(hp_base_limit) | fixed point x256; the original's limit is 2^23 points, and monsters with a percentage life bonus get proportional headroom (hp_base_limit)
|
||||
long long want = (long long)gs(u, 7) * hb / h0 * tx / 1000 * g_hp_mul / 1000, hp = want, lim = hp_base_limit(gsb(u, 7), gs(u, 7)); if (hp > lim) hp = lim; // 定点 ×256;原版上限 2²³ 点,带百分比生命加成的怪按比例留余量(hp_base_limit) | fixed point x256; the original's limit is 2^23 points, and monsters with a percentage life bonus get proportional headroom (hp_base_limit)
|
||||
// 顶到上限不静默:这只怪(多半是守护者)的生命没按线涨足,只剩伤害在涨。每开一层记前 3 只
|
||||
// Hitting the cap is not silent: this monster (most likely the Guardian) did not get its full life according to the line, and only its damage keeps
|
||||
// growing. The first 3 are logged for each level opened
|
||||
@@ -921,6 +974,7 @@ static void milestone(uint64_t G, uint64_t player, int m) {
|
||||
static void finish(uint64_t G, uint64_t player, uint64_t guard) {
|
||||
uint64_t now = guest_ns();
|
||||
int left = RIFT_SECS - (int)((now - K.t0_ns) / 1000000000ull); g_left_done = left; // 结算这一拍停表 | Stop the clock on the completion tick
|
||||
hs_report(RIFT_SECS - left);
|
||||
K.inc = left >= 600 ? 3 : left >= 300 ? 2 : left > 0 ? 1 : 0; int next = next_tier();
|
||||
if (K.inc) { R.clears++; if (K.tier > R.best) R.best = K.tier; } if (K.inc && (!R.fast[K.tier] || RIFT_SECS - left < R.fast[K.tier])) R.fast[K.tier] = RIFT_SECS - left;
|
||||
if (K.inc) pts_grant(player); // 通关点数:R.best 更新之后、下面 rec_save 之前。只算限时内通关(「超时通关不算过关,15 分钟内才是过关」),与上一行最高通关层同一口径 | clear points: after R.best is updated and before rec_save below. Only clears within the time limit count ("a clear after the time limit does not count as passing; only within 15 minutes does"), same rule as the highest cleared level on the previous line
|
||||
@@ -995,7 +1049,7 @@ static void finish(uint64_t G, uint64_t player, uint64_t guard) {
|
||||
static void menu_fill(dm_rift_menu_t *o, int m) {
|
||||
uint64_t now = guest_ns();
|
||||
int need = atomic_load(&K.need); o->menu = m; o->best = R.best; o->unlock = R.unlock < 1 ? 1 : R.unlock; o->def = R.tier; o->ms = R.ms; o->clvl = atomic_load(&M.clvl);
|
||||
o->tier = K.tier; o->done = atomic_load(&K.st) == ST_DONE; o->inc = K.inc; o->next = next_tier(); o->secs_left = o->done ? g_left_done : K.t0_ns ? RIFT_SECS - (int)((now - K.t0_ns) / 1000000000ull) : RIFT_SECS; if (o->secs_left < 0) o->secs_left = 0;
|
||||
o->tier = K.tier; o->done = atomic_load(&K.st) == ST_DONE; o->inc = K.inc; o->next = next_tier(); o->overtime = rift_overtime(); o->secs_left = o->done ? g_left_done : K.t0_ns ? RIFT_SECS - (int)((now - K.t0_ns) / 1000000000ull) : RIFT_SECS; if (o->secs_left < 0) o->secs_left = 0;
|
||||
o->progress = need > 0 ? (float)atomic_load(&K.score) / need : 0; if (o->progress > 1) o->progress = 1;
|
||||
}
|
||||
int dm_rift_menu(dm_rift_menu_t *o) { int m = atomic_load(&M.menu); if (m == MENU_NONE) return 0; menu_fill(o, m); return 1; }
|
||||
@@ -1047,7 +1101,13 @@ 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; K.inc = 0;
|
||||
atomic_store(&K.guard_dead, 0); atomic_store(&K.timeout, 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=<class id>[,<class id>] 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; }
|
||||
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
|
||||
K.players_old = dm_hud_requested_players(); if (!K.players_old) K.players_old = 1;
|
||||
@@ -1126,7 +1186,7 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) {
|
||||
{ static int at = -1; if (at < 0) { const char *e = getenv("DM_RIFT_TEST_SAVE"); at = e ? atoi(e) : 0; } if (at > 0 && t >= (uint32_t)at) { at = 0; int dm_request_save(void); LOG("秘境:测试 DM_RIFT_TEST_SAVE 拍 %u 请游戏存盘 → %d", t, dm_request_save()); } } // 测试开关 DM_RIFT_TEST_SAVE=<拍>:到这一拍请游戏存一次盘(验放大着的随从生命进不进角色档) | test switch DM_RIFT_TEST_SAVE=<tick>: ask the game to save once at this tick (to check whether boosted minion life gets into the character save)
|
||||
{ static int at = -1; if (at < 0) { const char *e = getenv("DM_RIFT_TEST_ABANDON"); at = e ? atoi(e) : 0; } if (at > 0 && t >= (uint32_t)at && st == ST_RUN) { at = 0; LOG("秘境:测试 DM_RIFT_TEST_ABANDON 拍 %u 替玩家放弃本层", t); atomic_store(&M.req_abandon, 1); } } // 测试开关 DM_RIFT_TEST_ABANDON=<拍>:秘境进行中到这一拍替玩家放弃(裸宿主上点不了「放弃」) | test switch DM_RIFT_TEST_ABANDON=<tick>: during a rift run, abandon on the player's behalf at this tick ("Abandon" cannot be clicked on the bare host)
|
||||
if (atomic_exchange(&M.req_abandon, 0) && (st == ST_RUN || st == ST_DONE)) { // 放弃:本层作废(不涨层、不发奖),写回改过的表,回选层页 | Abandon: this level is void (no level increase, no rewards); write back the modified tables and return to the level selection page
|
||||
region_set(G, 0); if (K.players_old) dm_hud_request_players(K.players_old); K.guard = 0; L.next_door = L.town_door = 0; L.nd_lv = 0; atomic_store(&K.st, ST_IDLE); st = ST_IDLE;
|
||||
region_set(G, 0); if (K.players_old) dm_hud_request_players(K.players_old); K.guard = 0; memset(K.guards, 0, sizeof K.guards); L.next_door = L.town_door = 0; L.nd_lv = 0; atomic_store(&K.st, ST_IDLE); st = ST_IDLE;
|
||||
LOG("秘境:放弃第 %d 层", K.tier); atomic_store(&M.menu, MENU_SELECT);
|
||||
pet_hp_pump(G, player, t); // 随从生命当拍设回基数,同结算处:放弃后回到选层页会走原版暂停,等下一拍的话要到玩家关掉面板才设回 | minion life is set back to base on this very tick, as at completion: after abandoning, returning to the level-selection page goes through the original's pause, and waiting for the next tick would delay it until the player closes the panel
|
||||
return; }
|
||||
@@ -1209,8 +1269,8 @@ 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 && id != K.guard) { 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); } } }
|
||||
dmg_probe_pump(G, t);
|
||||
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); } } }
|
||||
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
|
||||
{ static int il = -1; if (il < 0) il = getenv("DM_RIFT_TEST_ILVL") != NULL;
|
||||
@@ -1220,7 +1280,7 @@ 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 = find_unit(G, 1, K.guard); 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)) { 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); }
|
||||
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; } }
|
||||
@@ -1233,11 +1293,27 @@ void dm_rift_tick(uint64_t G, uint64_t player, uint8_t *main_base) {
|
||||
// 守护者
|
||||
// Guardian
|
||||
if (!K.guard && atomic_load(&K.score) >= atomic_load(&K.need) && in_rift_map(lv)) {
|
||||
int x, y; unit_xy(player, &x, &y); int32_t pos[2] = { x + 6, y + 6 }; uint64_t rr = free_spot(G, unit_room(player), pos);
|
||||
K.guard_cls = k_guard[rnd(5)];
|
||||
uint64_t u = rr ? ((uint64_t (*)(uint64_t, uint64_t, int, int, int, int, int, int, uint64_t))(B + 0x7ce630))(G, rr, 1, K.guard_cls, pos[0], pos[1], 1, 0, 0x10) : 0;
|
||||
if (u) { K.guard = *(uint32_t *)(uintptr_t)(u + 8); if (lowhp) ss(u, 6, 256); else if (K.tier >= 9) scale_monster(G, u, target_level(player) + 3, dm_rift_tier_level(9, gs(player, 12)) + 3); // 守护者 = 本层怪物等级 + 3(110 封顶),起算层也按 + 3 算,同吃本层总倍率 | Guardian = this level's monster level + 3 (capped at 110); the baseline level is computed with + 3 as well, and the same total multiplier of this level applies
|
||||
say("dmRiftSayGuardian"); LOG("秘境:拍 %u 刷守护者 类号 %d id %u 等级 %d 生命 %d", t, K.guard_cls, K.guard, gs(u, 12), gs(u, 7) >> 8); } }
|
||||
if (K.guard && !atomic_load(&K.guard_dead)) { uint64_t u = find_unit(G, 1, K.guard);
|
||||
if (u) { uint32_t m = *(uint32_t *)(uintptr_t)(u + 0xc); if (m == 0 || m == 12) { atomic_store(&K.guard_dead, 1); LOG("秘境:拍 %u 守护者死亡", t); finish(G, player, u); } } }
|
||||
// 一位:人右下 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();
|
||||
for (int i = 0; i < K.nplan && i < 2; i++) { int32_t pos[2] = { x + ox[K.nplan - 1][i], y + oy[K.nplan - 1][i] }; uint64_t rr = free_spot(G, unit_room(player), pos);
|
||||
uint64_t u = rr ? ((uint64_t (*)(uint64_t, uint64_t, int, int, int, int, int, int, uint64_t))(B + 0x7ce630))(G, rr, 1, K.gcls[i], pos[0], pos[1], 1, 0, 0x10) : 0;
|
||||
if (!u) { LOG("【红】秘境:守护者第 %d 位(类号 %d)没刷出来", i + 1, K.gcls[i]); continue; }
|
||||
K.guards[i] = *(uint32_t *)(uintptr_t)(u + 8); if (!K.guard) K.guard = K.guards[i]; n++;
|
||||
if (lowhp) ss(u, 6, 256); else if (K.tier >= 9) { g_hp_mul = K.nplan == 2 ? hi_duo_x1000(0) : 1000; scale_monster(G, u, target_level(player) + 3, dm_rift_tier_level(9, gs(player, 12)) + 3); g_hp_mul = 1000; }
|
||||
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"); }
|
||||
// 测试替身 DM_RIFT_TEST_DUMMY=<每秒点数>:对在场的每位守护者按固定输出扣当前生命(留 1 点,由随从补最后一下)——人物不用真打,用来出「承伤每秒峰值」的相对值
|
||||
// Test stand-in DM_RIFT_TEST_DUMMY=<points per second>: 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 && 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;
|
||||
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++; }
|
||||
if (!alive && last) { atomic_store(&K.guard_dead, 1); LOG("秘境:拍 %u 守护者全部死亡 → 结算", t); finish(G, player, last); } }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user