Implement 40250 classic client port

This commit is contained in:
shenlei
2026-09-01 18:49:28 +09:00
parent 2277b1dd60
commit 8f61990a83
481 changed files with 169826 additions and 293 deletions
+22 -2
View File
@@ -52,6 +52,7 @@ var _attack_cd := 0.0
var _hitstun_until := 0.0
var _combo := 0
var _last_attack_t := 0.0
var _observer_mode := false
func setup(m2client: Node, player_ctl: Node, nw: Node, hud_node: Node = null) -> void:
client = m2client
@@ -74,6 +75,19 @@ func setup(m2client: Node, player_ctl: Node, nw: Node, hud_node: Node = null) ->
client.damage.connect(_on_damage)
if client.has_signal("fishing_event"):
client.fishing_event.connect(_on_fishing_event)
if client.has_signal("observer_mode_changed"):
client.observer_mode_changed.connect(_on_observer_mode)
if client.has_method("is_observer_mode"):
_observer_mode = bool(client.is_observer_mode())
func _on_observer_mode(enabled: bool) -> void:
_observer_mode = enabled
if enabled:
_target_vid = 0
_attack_cd = 0.0
target_changed.emit(0)
if hud and hud.has_method("clear_target"):
hud.clear_target()
# --- helpers --------------------------------------------------------------
@@ -125,7 +139,7 @@ func _entity_name(e: Dictionary) -> String:
# --- movement ----------------------------------------------------------------
func _on_local_moved(pos: Vector3) -> void:
if client == null or not client.is_in_game():
if _observer_mode or client == null or not client.is_in_game():
return
var now := Time.get_ticks_msec() / 1000.0
if pos.distance_to(_last_sent_pos) < SEND_DIST and now - _last_sent_t < SEND_INTERVAL:
@@ -137,6 +151,8 @@ func _on_local_moved(pos: Vector3) -> void:
_was_moving = true
func _on_anim_state(state: String) -> void:
if _observer_mode:
return
if state == "wait" and _was_moving:
_was_moving = false
if client and client.is_in_game() and pc.player:
@@ -174,6 +190,8 @@ func _on_points(p: Dictionary) -> void:
if hud.has_method("set_vitals"):
hud.set_vitals(int(p.get("hp", 0)), int(p.get("max_hp", 0)),
int(p.get("sp", 0)), int(p.get("max_sp", 0)))
if hud.has_method("set_stamina"):
hud.set_stamina(int(p.get("stamina", 0)), int(p.get("max_stamina", 0)))
if hud.has_method("set_exp"):
hud.set_exp(int(p.get("exp", 0)), int(p.get("next_exp", 0)))
if hud.has_method("set_level"):
@@ -198,6 +216,8 @@ func _on_net_moved(vid: int) -> void:
# --- targeting / attack -----------------------------------------------------
func _on_pick(node: Node3D) -> void:
if _observer_mode:
return
var vid := _vid_of(node)
if vid == 0 or vid == _main_vid:
return
@@ -266,7 +286,7 @@ func is_stunned() -> bool:
func _process(dt: float) -> void:
if pc:
pc.set("frozen", is_stunned())
if client == null or not client.is_in_game() or _target_vid == 0 or pc == null:
if _observer_mode or client == null or not client.is_in_game() or _target_vid == 0 or pc == null:
return
if is_stunned():
return # 硬直:不发攻击 / 移动