extends SceneTree const AssetRoot = preload("res://asset_root.gd") const PlayerView = preload("res://ui/player_view.gd") func _init() -> void: call_deferred("_run") func _run() -> void: print("=== Running test_warrior_mental_skills_regression ===") var fails := 0 var check = func(cond: bool, msg: String): if not cond: fails += 1 print("FAIL: ", msg) else: print("OK: ", msg) var root_dir := AssetRoot.path() var pv := PlayerView.new() get_root().add_child(pv) var ok = pv.build(root_dir, 0) # warrior male check.call(ok, "warrior PlayerView built") var skills = ["gigongcham", "gyeoksan", "daejin", "cheongeun", "geompung"] for sname in skills: print("\n--- Testing skill: ", sname, " ---") var finished := [false] var on_finished = func(): finished[0] = true pv.anim.playback_finished.connect(on_finished, CONNECT_ONE_SHOT) var cast_ok = pv.play_skill_motion(sname, 0) check.call(cast_ok, "play_skill_motion(%s) returned true" % sname) check.call(pv._state == "__skill", "pv._state is '__skill'") check.call(bool(pv.anim.get("playing")), "anim.playing is true at start") var dur = float(pv.anim.get_duration()) if pv.anim.has_method("get_duration") else 2.0 # Run frames until playback_finished or timeout var frames = 0 while not finished[0] and frames < 400: await process_frame frames += 1 check.call(finished[0], "%s emitted playback_finished (frames=%d)" % [sname, frames]) check.call(pv._state == "wait", "pv._state reset to 'wait'") check.call(bool(pv.anim.get("playing")), "anim.playing is true after playback_finished") # Transition to run pv.set_anim_state("run") check.call(pv._state == "run", "pv._state changed to 'run'") check.call(bool(pv.anim.get("playing")), "anim.playing is true during run") var t0 = float(pv.anim.get_time()) if pv.anim.has_method("get_time") else 0.0 for f in range(15): await process_frame var t1 = float(pv.anim.get_time()) if pv.anim.has_method("get_time") else 0.0 check.call(t1 > t0, "run animation is advancing (t0=%.3f, t1=%.3f)" % [t0, t1]) # Reset to wait for next skill pv.set_anim_state("wait") for f in range(5): await process_frame # Clean up if is_instance_valid(pv.anim): pv.anim.free() if is_instance_valid(pv.model): pv.model.free() pv.free() if ClassDB.class_exists("Metin2Model"): var m_dummy: Object = ClassDB.instantiate("Metin2Model") m_dummy.call("clear_texture_cache") m_dummy.free() await process_frame await process_frame print("\n=== Completed test_warrior_mental_skills_regression with %d failures ===" % fails) if fails == 0: print("ALL PASS") quit(fails)