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
+27 -4
View File
@@ -48,6 +48,12 @@ const FUNC_COMBO := 3
const FUNC_MOB_SKILL := 4
const FUNC_EMOTION := 5
const FUNC_SKILL := 0x80
# packet.h EWalkModes(GC_WALK_MODE / GC_CHARACTER_ADD_INFO.bWalkMode)
const WALKMODE_RUN := 0
const WALKMODE_WALK := 1
# CActorInstance c_fDefaultRotationSpeed / c_fDefaultHorseRotationSpeed(度/秒)
const ROTATION_SPEED := 1200.0
const ROTATION_SPEED_HORSE := 300.0
# EDamageFlag / IsShowDamage / ProcessDamage 分类见 damage_effect.gd(DamageEffect.DAMAGE_*)。
@@ -423,12 +429,26 @@ func _on_spawn(d: Dictionary) -> void:
_refresh_shop_sign(node, str(d.get("shop_sign", "")))
_refresh_pvp_tag(vid)
_apply_field_updates(node, d)
_push_motion_speeds(vid, node)
_apply_name_color(vid)
_apply_text_tail(vid)
entity_added.emit(node, vid)
if vid == _main_vid:
main_entity_ready.emit(node, vid)
# CActorInstance::Move -> SetLoopMotion(WALK/RUN, .., m_fMovSpd):远端位移按动作根运动
# 累计(.msa Accumulation / MotionDuration × movSpd/100)推进。模型建好后把走 / 跑
# 速度交给 EntityStore;占位胶囊 / 骑马(马的动作不在 general 目录)不推,EntityStore
# 退回按服务端 duration 线性插值。
func _push_motion_speeds(vid: int, n: Node3D) -> void:
if not n.has_method("get_move_motion_speeds") or not client.has_method("set_entity_motion_speed"):
return
if int(n.get_meta("mount_vnum", 0)) != 0:
return
var sp: Vector2 = n.call("get_move_motion_speeds")
if sp.x > 0.0 or sp.y > 0.0:
client.call("set_entity_motion_speed", vid, sp.x, sp.y)
# GC_CHAR_ADD_INFO 到了:刷新头顶名字 / HP 上限(节点已存在)。
func _on_info(vid: int, d: Dictionary) -> void:
var n: Node3D = _by_vid.get(vid, null)
@@ -1287,12 +1307,15 @@ func _process(dt: float) -> void:
want = _pushed_position(vid, e, dt, want)
n.position = want
# 朝向:Metin2 heading(度) -> Godot yaw。经验换算,真机再校准。
# CActorInstance::RotationProcess:匀角速度转向 c_fDefaultRotationSpeed 1200°/s,
# 骑马 c_fDefaultHorseRotationSpeed 300°/s(而不是指数逼近)。
var yaw := MapCoord.heading_to_yaw(float(e.get("angle_deg", 0.0)))
n.rotation.y = lerp_angle(n.rotation.y, yaw, clampf(10.0 * dt, 0.0, 1.0))
var turn_rate := ROTATION_SPEED_HORSE if int(n.get_meta("mount_vnum", 0)) != 0 else ROTATION_SPEED
n.rotation.y = rotate_toward(n.rotation.y, yaw, deg_to_rad(turn_rate) * dt)
# 动画状态
var f := int(e.get("func", FUNC_WAIT))
var moving := bool(e.get("moving", false))
var walk_mode := int(e.get("walk_mode", 1))
var walk_mode := int(e.get("walk_mode", WALKMODE_RUN))
var dead := bool(e.get("dead", false))
if f != int(n.get_meta("func", -1)) or moving != bool(n.get_meta("moving", false)) \
or walk_mode != int(n.get_meta("walk_mode", -1)) or dead != bool(n.get_meta("dead", false)):
@@ -1303,13 +1326,13 @@ func _process(dt: float) -> void:
_apply_anim(n, f, moving, walk_mode, dead)
_update_hp_bars()
func _apply_anim(n: Node3D, f: int, moving: bool, walk_mode := 1, dead := false) -> void:
func _apply_anim(n: Node3D, f: int, moving: bool, walk_mode := WALKMODE_RUN, dead := false) -> void:
var state := "wait"
if dead:
# CActorInstance::__SetMotion:IsDead() 时拒绝 DEAD/DAMAGE_FLYING 以外的动作。
state = "dead"
elif f == FUNC_MOVE or (f == FUNC_WAIT and moving):
state = "walk" if walk_mode == 0 else "run"
state = "walk" if walk_mode == WALKMODE_WALK else "run"
elif f == FUNC_ATTACK or f == FUNC_COMBO:
state = "attack"
elif f == FUNC_MOB_SKILL or (f & FUNC_SKILL) != 0: