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
+39
View File
@@ -24,6 +24,9 @@ class FakeClient extends Node:
signal entity_dead(vid: int)
signal damage(vid: int, amount: int, flag: int)
var ents := {}
var motion_speeds := {} # vid -> Vector2(walk, run)
func set_entity_motion_speed(vid: int, walk: float, run: float) -> void:
motion_speeds[vid] = Vector2(walk, run)
func get_entity(vid: int) -> Dictionary: return ents.get(vid, {})
func get_entities() -> Array: return ents.values()
func get_pvp_relations() -> Array: return []
@@ -126,6 +129,7 @@ func _run() -> void:
_ck(int(added.get(2, 0)) == 2, "entity 2 rebuilt exactly once on re-entry")
await _dead_motion(fc, nw)
await _walk_mode_motion(fc, nw)
class AnimView extends Node3D:
var states: Array[String] = []
@@ -159,3 +163,38 @@ func _dead_motion(fc: FakeClient, nw: Node) -> void:
fc.entity_dead.emit(7)
await create_tween().tween_interval(0.4).finished
_ck(placeholder != null and placeholder.rotation.x < -1.0, "placeholder capsule (no motions) still falls over as its only death cue")
class MoveView extends AnimView:
func get_move_motion_speeds() -> Vector2:
return Vector2(87.5, 425.75)
# packet.h WALKMODE_RUN = 0 / WALKMODE_WALK = 1;CActorInstance::Move 按 m_isWalking
# 选 WALK / RUN。模型建好后把走 / 跑根运动速度推给 EntityStore(骑马不推)。
func _walk_mode_motion(fc: FakeClient, nw: Node) -> void:
nw.set_model_factory(func(_d: Dictionary) -> Node3D: return MoveView.new())
var walker := fc.add(8, NEAR_CM + Vector2(900, 0), {"race": 101, "ch_type": 2, "func": 1, "walk_mode": 1})
fc.entity_spawned.emit(walker)
var runner := fc.add(9, NEAR_CM + Vector2(1200, 0), {"race": 101, "ch_type": 2, "func": 1, "walk_mode": 0})
fc.entity_spawned.emit(runner)
var rider := fc.add(10, NEAR_CM + Vector2(1500, 0), {"race": 101, "ch_type": 0, "mount_vnum": 20030})
fc.entity_spawned.emit(rider)
await process_frame
await process_frame # process_frame 在节点 _process 之前发
var wv := nw.node_for(8) as AnimView
var rv := nw.node_for(9) as AnimView
_ck(wv != null and wv.states.back() == "walk", "walk_mode 1 (WALKMODE_WALK) -> walk: %s" % [wv.states if wv else []])
_ck(rv != null and rv.states.back() == "run", "walk_mode 0 (WALKMODE_RUN) -> run: %s" % [rv.states if rv else []])
_ck(fc.motion_speeds.get(8, Vector2.ZERO) == Vector2(87.5, 425.75), "spawn pushes walk/run motion speeds: %s" % [fc.motion_speeds])
_ck(not fc.motion_speeds.has(10), "mounted actor keeps the duration lerp (no push)")
walker["walk_mode"] = 0
await process_frame
await process_frame
_ck(wv.states.back() == "run", "GC_WALK_MODE flip to run re-selects RUN: %s" % [wv.states])
# 匀角速度转向:一帧转角不超过 1200°/s × dt。
var before := wv.rotation.y
walker["angle_deg"] = 180.0
await process_frame
var t0 := Time.get_ticks_usec()
await process_frame
var dt := float(Time.get_ticks_usec() - t0) / 1e6
_ck(absf(angle_difference(before, wv.rotation.y)) <= deg_to_rad(1200.0) * (dt + 0.05), "turn limited to 1200deg/s")