no message

This commit is contained in:
shenlei
2026-09-16 22:15:52 +09:00
parent 400e3e8ea5
commit 1db9e9a129
11 changed files with 458 additions and 30 deletions
+44
View File
@@ -5,9 +5,11 @@ extends SceneTree
const MobView = preload("res://ui/mob_view.gd")
const Audio = preload("res://audio.gd")
const MsaMotion = preload("res://ui/msa_motion.gd")
var _fail := 0
var _resolution_done := false
var _move_speed_done := false
func _ck(c: bool, m: String) -> void:
if not c:
_fail += 1
@@ -26,6 +28,7 @@ class FakeAnim:
extends Node
var anim_path := ""
var loop := false
var time_scale := 1.0
# 纯解析:不需要扩展和资产。旧客户端 CRaceData::GetMotionKey 找不到动作时
# SetLoopMotion/InterceptMotion 直接返回、保留当前动作;不能静默换成 WAIT。
@@ -57,8 +60,49 @@ func _check_motion_resolution() -> void:
mv.free()
_resolution_done = true
# CActorInstance::Move:走 / 跑按 m_fMovSpd = movSpd/100 播放;根运动速度
# = |.msa Accumulation| / MotionDurationwolf 03.msa255.45 / 0.6 = 425.75 cm/s)。
func _write_msa(path: String, duration: float, ay: float) -> void:
var f := FileAccess.open(path, FileAccess.WRITE)
f.store_string("ScriptType MotionData\n\nMotionFileName \"x.gr2\"\n" +
"MotionDuration %f\nAccumulation 0.00\t%.2f\t0.00\n" % [duration, ay])
f.close()
func _check_move_speed() -> void:
var walk_p := "user://__mob_view_test_walk.msa"
var run_p := "user://__mob_view_test_run.msa"
_write_msa(walk_p, 0.866667, -75.81)
_write_msa(run_p, 0.6, -255.45)
_ck(absf(MsaMotion.move_speed(run_p) - 425.75) < 0.01, "run msa 速度 425.75%f" % MsaMotion.move_speed(run_p))
_ck(absf(MsaMotion.move_speed(walk_p) - 87.47) < 0.01, "walk msa 速度 87.47%f" % MsaMotion.move_speed(walk_p))
_ck(MsaMotion.move_speed("user://__no_such.msa") == 0.0, "缺文件 -> 0")
var mv: Node3D = MobView.new()
mv._dir = "res://__no_such_mob_dir__"
mv._motions = {"WAIT": "wait.msa", "WALK": walk_p, "RUN": run_p}
var sp: Vector2 = mv.get_move_motion_speeds()
_ck(absf(sp.x - 87.47) < 0.01 and absf(sp.y - 425.75) < 0.01, "get_move_motion_speeds%s" % sp)
var anim := FakeAnim.new()
mv.anim = anim
mv.set_move_speed(200)
mv.set_anim_state("wait")
_ck(anim.time_scale == 1.0, "wait 不受移动速度影响")
mv.set_anim_state("run")
_ck(anim.anim_path == run_p and anim.time_scale == 2.0, "run 按 movSpd/100 播放(%f" % anim.time_scale)
mv.set_move_speed(150)
_ck(anim.time_scale == 1.5, "跑动中改速立即生效(%f" % anim.time_scale)
mv.set_move_speed(1200)
_ck(anim.time_scale == 1.0, ">1100 保持原速(%f" % anim.time_scale)
mv.anim = null
anim.free()
mv.free()
DirAccess.remove_absolute(ProjectSettings.globalize_path(walk_p))
DirAccess.remove_absolute(ProjectSettings.globalize_path(run_p))
_move_speed_done = true
func _run() -> void:
_check_motion_resolution()
_check_move_speed()
_ck(_move_speed_done, "移动速度断言全部执行")
# 脚本运行时错误只会中止函数、不计失败;用哨兵保证整段断言都执行过。
_ck(_resolution_done, "动作解析断言全部执行")
if not ClassDB.class_exists("Metin2Model") or not ClassDB.class_exists("Metin2Proto"):