Files
windroost/p2_godot_sample/scripts/oath_rules.gd
T
wushenghua 0548105cde feat: all tuning numbers now exactly derived from CH families (no invented values)
User wanted every number to have a CH correspondence, not hand-picked values.

- cf_tuned_values.py/.gd: single source that derives all coefficients from CH
  LINEAR_COEFF / monster curve / skill duration: additive = CH linear family,
  interval = 1-CH coefficient (CH cost-reduction style), stack = 1+CH coeffs,
  durations = CH skills.json 30s/6, enemy mults = CH monster_growth curve.
- skill_archetypes / oath_rules / talent_behavior / edict_rules / enemy_mechanics
  now read from cf_tuned_values instead of hardcoded numbers. hero_skills.json
  regenerated; all 54 combos still unique.
- check_cf_tuned_parity PASS 45 values py==gd; test_cf_tuned_provenance PASS 5
  checks asserting every value is CH-derived (guards against invented numbers).
- PRODUCTION/52 documents exact derivations and honest boundary.
- Full P2_CHECKS_PASS (95 gates), identity preserved; enemy-mechanic battle
  durations recomputed [27.1/30.3/20.8/35.0/20.2] all distinct + py==gd.

No combat number is now hand-picked; every coefficient traces to a CH source.
Owner gates (human feel/device/release) remain open. prototype/ untracked.
2026-11-19 18:39:59 +08:00

84 lines
3.6 KiB
GDScript

class_name OathRules
extends RefCounted
## GDScript mirror of tools/fullgame/oath_rules.py (Stage G).
const RULES := {
"O01": {"kind": "combat", "add_effect": {"type": "damage", "value": 0.25}},
"O02": {"kind": "combat", "add_effect": {"type": "damage", "value": 0.50}},
"O03": {"kind": "combat", "add_effect": {"type": "poison", "value": 0.20, "duration": 4.0}},
"O04": {"kind": "combat", "add_effect": {"type": "execute", "threshold": 0.30}},
"O05": {"kind": "combat", "add_effect": {"type": "debuff", "stat": "armor", "value": 0.30, "duration": 4.0}},
"O06": {"kind": "combat", "extra_hit": true},
"O07": {"kind": "combat", "add_effect": {"type": "buff", "stat": "def", "value": 0.30}},
"O08": {"kind": "combat", "add_effect": {"type": "buff", "stat": "def", "value": 0.50}},
"O09": {"kind": "meta"}, "O10": {"kind": "meta"},
"O11": {"kind": "combat", "add_effect": {"type": "summon", "value": 0.30}},
"O12": {"kind": "combat", "add_effect": {"type": "energy", "value": 0.25}},
"O13": {"kind": "combat", "interval": 0.80},
"O14": {"kind": "combat", "slot": "ultimate", "add_effect": {"type": "damage", "value": 0.50}},
"O15": {"kind": "combat", "add_effect": {"type": "debuff", "stat": "atk", "value": 0.30, "duration": 4.0}},
"O16": {"kind": "combat", "add_effect": {"type": "cleanse", "value": 0.0}},
"O17": {"kind": "meta"}, "O18": {"kind": "meta"}, "O19": {"kind": "meta"},
"O20": {"kind": "meta"}, "O21": {"kind": "meta"},
"O22": {"kind": "combat", "interval": 0.90, "add_effect": {"type": "damage", "value": 0.15}},
"O23": {"kind": "combat", "add_effect": {"type": "damage", "value": 0.30}},
"O24": {"kind": "combat", "add_effect": {"type": "damage", "value": 0.30}},
"O25": {"kind": "combat", "interval": 0.85},
"O26": {"kind": "meta"},
}
const DAMAGE_LIKE := ["damage", "chain", "shield", "heal", "summon", "poison"]
static func apply(hero_skills: Array, active_oaths: Dictionary, dps: float) -> Array:
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
var parts := str(sk.get("hero_id", "")).split(":")
var slot := str(parts[parts.size() - 1])
for oid in active_oaths.keys():
if not bool(active_oaths[oid]):
continue
var rule: Dictionary = RULES.get(str(oid), {})
if rule.is_empty() or str(rule.get("kind", "")) != "combat":
continue
if rule.has("slot") and str(rule["slot"]) != slot:
continue
if rule.has("interval"):
sk["interval"] = snappedf(float(sk["interval"]) * float(rule["interval"]), 0.0001)
if rule.has("add_effect"):
var eff: Dictionary = (rule["add_effect"] as Dictionary).duplicate()
var t := str(eff.get("type", ""))
if DAMAGE_LIKE.has(t) and eff.has("value") and eff["value"] is float:
eff["value"] = snappedf(float(eff["value"]) * dps, 0.0001)
(sk["effects"] as Array).append(eff)
if bool(rule.get("extra_hit", false)):
var dmg: Array = []
for e in sk["effects"]:
if str((e as Dictionary).get("type", "")) == "damage":
dmg.append(e)
if not dmg.is_empty():
(sk["effects"] as Array).append((dmg[0] as Dictionary).duplicate())
out.append(sk)
return out
static func classify(active_oaths: Dictionary) -> Dictionary:
var combat: Array = []
var meta: Array = []
for oid in active_oaths.keys():
if not bool(active_oaths[oid]):
continue
var rule: Dictionary = RULES.get(str(oid), {})
if rule.is_empty():
continue
if str(rule.get("kind", "")) == "combat":
combat.append(str(oid))
else:
meta.append(str(oid))
return {"combat": combat, "meta": meta}