User: "数值应参考 CH 迁移,不要自己写." Contract 2.2 requires inheriting CH's formula families and magnitude. Previously relic strength (0.06+tier*0.008), commission targets/rewards, and partner coefficients were invented. Now: - cf_formulas.py/.gd: implements CH's real formula families (linear10=0.10*L, diminishingReturns, exponential/polynomial1_5 costs) and reads CF source tables copied to data/cf_reference/numeric_tables.json (27 relics/30 ancients/ 10 outsiders/6 daily tasks/9 skills). check_cf_formulas_parity PASS 25 cases. - Relics: strength = CH linear10 @level=tier (0.1..6.0, genuine CH magnitude); effect TYPE from CH relic effectDescription keyword (idle->shield, click-> damage, chest->summon...). 56 combat relic signatures unique. - Commissions: target steps from CH daily_tasks (kills=50/boss=3/upgrades=5/ quests=2), reward = CH rubies=5 (crystal) for all. - Partners: P01=0.10 (CH linear10), P03=0.15 (linear15), P05=0.25 (linear25). - PRODUCTION/52-cf-numeric-provenance.md documents every number's CH source and honestly flags the few remaining new-game tuning parameters. - Full P2_CHECKS_PASS (93 gates), identity preserved. Numbers now trace to CH source tables instead of being invented. Owner gates (human feel/device/release) remain open. prototype/ untracked.
96 lines
3.6 KiB
GDScript
96 lines
3.6 KiB
GDScript
class_name RelicEffects
|
|
extends RefCounted
|
|
|
|
## GDScript mirror of tools/fullgame/relic_effects.py (Stage F). Each relic gets
|
|
## a distinct combat effect; meta relics are out-of-combat and not faked.
|
|
## Values come from CH's real relic-bonus formula families (cf_formulas.gd).
|
|
|
|
const CfFormulas = preload("res://scripts/cf_formulas.gd")
|
|
|
|
const COMBAT_PRIMS := ["damage", "chain", "poison", "summon", "buff",
|
|
"energy", "execute", "debuff", "stun", "slow"]
|
|
const META_RELICS := ["L57", "L58", "L59", "L60"]
|
|
const KEYS := ["type", "value", "jumps", "duration", "threshold", "stat"]
|
|
# CH effectDescription keyword -> combat primitive (faithful semantic migration)
|
|
const CH_EFFECT_KEYWORDS := [
|
|
["boss life", "execute"], ["boss fight timers", "slow"],
|
|
["skill cooldowns", "energy"], ["primal boss", "debuff"],
|
|
["click damage", "damage"], ["critical clicks", "damage"],
|
|
["dps per click combo", "chain"], ["when idle", "shield"],
|
|
["hero soul dps", "damage"], ["gilded damage", "damage"],
|
|
["primal hero souls", "energy"], ["monsters required", "execute"],
|
|
["treasure chests", "summon"], ["10x gold", "chain"],
|
|
["gold dropped", "buff"], ["gold gained", "buff"],
|
|
["gold from", "buff"], ["starting zone", "summon"],
|
|
["duration of", "energy"], ["level-up cost", "cleanse"],
|
|
["double rubies", "chain"], ["chance", "debuff"],
|
|
]
|
|
const CH_STRENGTH_FAMILY := "linear10"
|
|
|
|
|
|
static func ch_effect_primitive(description: String) -> String:
|
|
var low := description.to_lower()
|
|
for pair in CH_EFFECT_KEYWORDS:
|
|
var kw := str((pair as Array)[0])
|
|
if low.contains(kw):
|
|
return str((pair as Array)[1])
|
|
return "damage"
|
|
|
|
|
|
static func relic_strength(tier: int) -> float:
|
|
# CH linear10 relic formula at level=tier -> genuine CH magnitude.
|
|
return snappedf(CfFormulas.bonus_at(CH_STRENGTH_FAMILY, float(tier)), 0.0001)
|
|
|
|
|
|
static func relic_effect(tier: int) -> Dictionary:
|
|
var ch_relic_id := (tier - 1) % 27 + 1
|
|
var strength := relic_strength(tier)
|
|
var tables := CfFormulas.tables()
|
|
var relics: Array = tables.get("relics", [])
|
|
var desc := str((relics[ch_relic_id - 1] as Dictionary).get("effectDescription", ""))
|
|
var prim := ch_effect_primitive(desc)
|
|
var eff := {"type": prim, "value": strength}
|
|
if prim == "chain":
|
|
eff["jumps"] = 1 + tier / 20
|
|
elif prim == "poison" or prim == "debuff" or prim == "slow":
|
|
eff["duration"] = snappedf(2.0 + float(tier) * 0.1, 0.0001)
|
|
elif prim == "execute":
|
|
eff["threshold"] = snappedf(0.12 + float(tier % 10) * 0.02, 0.0001)
|
|
elif prim == "buff":
|
|
eff["stat"] = "def" if tier % 2 == 0 else "atk"
|
|
return eff
|
|
|
|
|
|
static func relic_defs() -> Dictionary:
|
|
var out := {}
|
|
for tier in range(1, 61):
|
|
var rid := "L%02d" % tier
|
|
out[rid] = {"tier": tier,
|
|
"kind": "meta" if META_RELICS.has(rid) else "combat",
|
|
"effect": relic_effect(tier)}
|
|
return out
|
|
|
|
|
|
static func apply(hero_skills: Array, active_relics: Dictionary, dps: float) -> Array:
|
|
var defs := relic_defs()
|
|
var out: Array = []
|
|
for sk0 in hero_skills:
|
|
var sk: Dictionary = (sk0 as Dictionary).duplicate(true)
|
|
var effects: Array = []
|
|
for e in sk.get("effects", []):
|
|
effects.append((e as Dictionary).duplicate())
|
|
sk["effects"] = effects
|
|
if str(sk.get("hero_id", "")).ends_with(":a1"):
|
|
for rid in active_relics.keys():
|
|
if not bool(active_relics[rid]):
|
|
continue
|
|
var d: Dictionary = defs.get(str(rid), {})
|
|
if d.is_empty() or str(d.get("kind", "")) != "combat":
|
|
continue
|
|
var eff: Dictionary = (d["effect"] as Dictionary).duplicate()
|
|
if eff.has("value") and eff["value"] is float:
|
|
eff["value"] = snappedf(float(eff["value"]) * dps, 0.0001)
|
|
(sk["effects"] as Array).append(eff)
|
|
out.append(sk)
|
|
return out
|