refactor(attr): cpu_limit 守卫移至换杖处;cast_delay_mod 改在开火时生效
守卫从 execute_compiled 搬到 equip_wand:诊断应放在能导致故障的状态转换处, 而非 2 次/秒的使用点——施法端刷屏会埋掉根因,换杖处每局只跑几次且拿得到杖名。 maxi(..., 1) 保留:错误已在换杖处大声报出,退化不再静默,而去掉它会让法术硬瘫。 订正原注释的事实错误:它声称兜住「attributes.json 缺失」与「attr_id 打错」, 但这两种 player_stats.gd:173/191 早已各自报错,守卫零覆盖。真正无人管的是 「新调用点忘了注入」(正是 combat_test 修前的样子)与「cores.json 某杖配成 0」。 cast_delay_mod 由 equip_wand 快照改为开火时相乘:_cast_timer 语义两种写法一致 (总是从上次写入值倒数),代价仅每次施法一次浮点乘法,但「下一个周期」由下次 换杖变为下次施法——玩家买急速道具期待的是后者。随之删去解释延迟生效的注释。 另在 _rebuild_wand 注入处记下 remove-before-add 为何 load-bearing:漏了会让 cpu_limit 随 install_spell 累积,而 hard: 50 会把它封成一个看起来合理的数字。 Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -14,8 +14,7 @@ var _player_node: Node2D = null
|
||||
var _equipped_core: CoreDefinition = null
|
||||
var _equipped_compiled: CompiledDeck = null
|
||||
var _cast_timer: float = 0.0
|
||||
var _cast_interval: float = 0.5 # equip_wand 时快照 core.cast_interval × cast_delay_mod;
|
||||
# 中途改 cast_delay_mod 要到下次 equip_wand(每波开战 _transition_to_battle)才生效
|
||||
var _cast_interval: float = 0.5 # 法杖基准间隔(core.cast_interval);实际间隔在开火时 × cast_delay_mod
|
||||
|
||||
var _is_moving: bool = false
|
||||
var _stationary_time: float = 0.0
|
||||
@@ -79,19 +78,24 @@ func _handle_auto_cast(delta: float) -> void:
|
||||
return
|
||||
_cast_timer -= delta
|
||||
if _cast_timer <= 0.0:
|
||||
_cast_timer = _cast_interval
|
||||
_cast_timer = _cast_interval * PlayerStats.cast_delay_mod
|
||||
SpellEvaluator.execute_compiled(_equipped_compiled, 0, _position)
|
||||
|
||||
func equip_wand(core: CoreDefinition, compiled: CompiledDeck) -> void:
|
||||
_equipped_core = core
|
||||
_equipped_compiled = compiled
|
||||
_cast_interval = (core.cast_interval if core else 0.5) * PlayerStats.cast_delay_mod
|
||||
_cast_interval = core.cast_interval if core else 0.5
|
||||
_cast_timer = 0.0
|
||||
if core:
|
||||
PlayerStats.set_mana_pool(core.base_mana_max, core.base_mana_regen)
|
||||
else:
|
||||
PlayerStats.set_mana_pool(100.0, 5.0)
|
||||
PlayerStats.mana_heat = 0.0
|
||||
# 0 守卫:cpu_limit=0 → MAX_OPS 退化,法术近乎全静默。放在换杖处而非施法处——施法端 2 次/秒
|
||||
# 会刷屏埋掉根因,且此处拿得到杖名。兜的是「新调用点忘了注入」与「cores.json 某杖配成 0」,
|
||||
# 二者上游无任何报错(缺 attributes.json / attr_id 打错已分别由 player_stats.gd:173/191 报出)
|
||||
if PlayerStats.cpu_limit <= 0:
|
||||
push_error("PlayerManager: 装备「%s」后 cpu_limit=0,法术执行预算将退化为 40 步;检查该杖 cores.json 的 cpu_limit 与 source=\"core\" 加成注入" % (core.display_name if core else "—"))
|
||||
|
||||
func get_position() -> Vector2:
|
||||
return _position
|
||||
|
||||
Reference in New Issue
Block a user