[P1][T14] 实现 ItemRatio 品质判定:严格复刻整数截断顺序 #102
Labels
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: troytt/diablo2-web#102
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
问题
掉出基础物品后要决定它是普通 / 精良 / 魔法 / 稀有 / 套装 / 暗金。这套判定在
D2Game!6FC2FC40,本 issue 逐指令复刻。这个 issue 的价值全在「严格」二字 —— 社区流传的公式有至少两个版本,都不完全对。照抄任何一份都会得到位级不一致的结果。
金标准数据
判定顺序(立即数直接坐实)
代码里
mov $0x7 / $0x5 / $0x6 / $0x4 / $0x3 / $0x2的立即数顺序就是这个。前置短路:类型记录
+0x16 != 0→ 直接 normal;ItemsTxt+0x129 != 0→ 直接 unique;类型+0x14 != 0且 ItemsTxt+0x12A != 0→ unique。(三个标志对应的表列名未逐一比对,【高可信推断】为「不可附魔 / 任务物品」与「唯一基底」。)ItemRatio.txt 全 6 行(列序 = 内存序)
内存偏移(由
idivl 0x04/0x10/0x1C/0x28(%edi)反推):选行:按
(Version, Uber, Class Specific)三元组精确匹配。Function列只是人类可读名字,游戏不解析。Version:0 = Classic,1 = LoDUber:1 = 用于 exceptional / elite 基底(ubercode/ultracode档)Class Specific:1 = 职业专属物品(亚马逊弓、法师护身符、德鲁伊盔、圣骑士盾、刺客爪、死灵头颅)⭐ 确切公式
其余四档:
(Magic - D/MagicDiv) * 128,然后* 100 / (mf + 100)(HiQuality - D/HiQualityDiv) * 128(Normal - D/NormalDiv) * 128(用最初保存的 D)<= 0→ normal(2);否则Rand(chance) < 128 ? normal(2) : low(1)(低质子类型见LowQualityItems.txt,仅 1 行)。实现要求
ItemRatio.txt(6 行),按(Version, Uber, ClassSpecific)建索引。Math.trunc显式截断(JS 的/是浮点)。Rand走 T-23 的D2Rng,用怪物的 seed。陷阱
验收标准
(Version, Uber, ClsSpec)选行正确mf = 10与mf = 11的 EffectiveMF 分别为 110 和衰减值(base, D, divisor, mf, f)手算出期望 chance,逐位比对f = 1024时必定命中D为负时行为正确npm run typecheck0 errornpx vitest run全绿npx tsx scripts/verify-items.ts新增断言通过溯源
data\global\excel\下的ItemRatio.txt/LowQualityItems.txt(本机/usr/local/google/home/taodao/d2-data,挂载序 d2data → d2exp → Patch_D2,Patch_D2 优先)D2Game!6FC2FC40/D2Game!6FC2E130/D2Game!6FC2F2F0(objdump -d,D2Common 基址0x6FD50000、D2Game0x6FC10000)已完成并通过 1.13c ItemRatio.txt 判定实测验证(Unique/Set/Rare/Magic/Superior/Normal 6层阶梯判定、Diminishing MF 惩罚曲线、class-specific 调整、fallback 保底降级与 durability 衰减计算),合并入 main (commit
6991ffa)。