diff --git a/docs_dev/plans/2026-07-31-shelf-c-attribute-shop.md b/docs_dev/plans/2026-07-31-shelf-c-attribute-shop.md index 371721b..caddae7 100644 --- a/docs_dev/plans/2026-07-31-shelf-c-attribute-shop.md +++ b/docs_dev/plans/2026-07-31-shelf-c-attribute-shop.md @@ -371,8 +371,16 @@ func _apply_attr_purchases() -> void: continue var mode: String = String(sp.get("mode", "flat")) var step: float = float(sp.get("step", 0.0)) - # pct 合并:n 次 +step 在连乘下等价于单条 (1+step)^n − 1 - var merged: float = (pow(1.0 + step, float(n)) - 1.0) if mode == "pct" else (step * float(n)) + # pct 合并必须按属性的 combine 分支——AttributeFormula 对 hybrid 用 f=1+v、对 inverse 用 f=1-v, + # 故两者的等价单条值不同。写错会让 inverse 属性(cast_delay_mod)的曲线整体偏离且零诊断。 + var combine: String = String(_attr_def.get(id, {}).get("combine", "hybrid")) + var merged: float = 0.0 + if mode == "pct": + # hybrid: 需 f=(1+step)^n → merged=(1+step)^n−1 + # inverse: 需 f=(1−step)^n → merged=1−(1−step)^n + merged = (1.0 - pow(1.0 - step, float(n))) if combine == "inverse" else (pow(1.0 + step, float(n)) - 1.0) + else: + merged = step * float(n) # flat 线性可加,与 combine 无关 PlayerStats.add_modifier(id, mode, merged, MOD_SOURCE_SHOP_C) ## 存档:只存次数,加成是派生物(回读时经 _apply_attr_purchases 重建) diff --git a/docs_dev/specs/2026-07-31-shelf-c-attribute-shop-design.md b/docs_dev/specs/2026-07-31-shelf-c-attribute-shop-design.md index 05a4d11..94a850f 100644 --- a/docs_dev/specs/2026-07-31-shelf-c-attribute-shop-design.md +++ b/docs_dev/specs/2026-07-31-shelf-c-attribute-shop-design.md @@ -180,7 +180,8 @@ for id in _attr_purchases: var n: int = _attr_purchases[id] if n <= 0: continue var sp: Dictionary = - var merged: float = (pow(1.0 + step, n) - 1.0) if mode == "pct" else (step * n) + # pct 合并须按 combine 分支:AttributeFormula 对 hybrid 用 f=1+v、对 inverse 用 f=1−v + var merged: float = (1.0 - pow(1.0 - step, n)) if (mode == "pct" and combine == "inverse") else ((pow(1.0 + step, n) - 1.0) if mode == "pct" else (step * n)) PlayerStats.add_modifier(id, mode, merged, MOD_SOURCE_SHOP_C) ```