diag_tp_probe3.py 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. """诊断3: 挂机声明三连 → CS3031 → CS1011@act_move,2 — 验证 SC643 是否出现。"""
  2. from __future__ import annotations
  3. import json
  4. import sys
  5. import time
  6. from pathlib import Path
  7. ROOT = Path(__file__).resolve().parents[2]
  8. sys.path.insert(0, str(ROOT / "protocol_bot" / "src"))
  9. import requests
  10. from pbot.config import Account
  11. from pbot.game.session import enter_world
  12. from pbot.login.box_client import enter_game_client, login
  13. from pbot.transport.gateway import login_gate_with_retry
  14. from pbot.world.update import WorldUpdater
  15. PORTS = (8021, 8061, 8001, 8041)
  16. def main() -> int:
  17. http = requests.Session()
  18. http.trust_env = False
  19. http.verify = False
  20. jwt, uid = login(Account(username="longwu988", password="Longwu1988"))
  21. _ = enter_game_client(http, jwt, 14558825)
  22. key32, sid, rname, tkey, gport = login_gate_with_retry(
  23. 14558825, jwt, uid, "凌风踏雪", PORTS)
  24. stop = [False]
  25. conn, world, updater = enter_world(14558825, rname, tkey, sid, gport, uid,
  26. stop=stop)
  27. print(f"[出生] {world.me.map_name} @({world.me.x},{world.me.y})")
  28. try:
  29. # 挂机声明三连(kill.py:356 同源)
  30. _ = conn.send_frame(3199, 0, 0, 0, sid,
  31. json.dumps({"act": "@startguaji", "index": 104,
  32. "subid": 2},
  33. separators=(",", ":")).encode())
  34. _ = conn.send_frame(5286, 0, 0, 0, sid)
  35. _ = conn.send_frame(9102, 1, 0, 0, sid)
  36. print("[挂机声明] @startguaji+5286+9102 已发, 等 5s")
  37. t = time.time()
  38. while time.time() - t < 5:
  39. for f in conn.recv_frames(0.2):
  40. updater.apply(world, f)
  41. _ = conn.send_frame(
  42. 3031, 0, 0, 0, sid,
  43. (ROOT / "protocol_bot" / "assets" / "cs3031_full.bin").read_bytes())
  44. print("[CS3031] 已发, 等 5s")
  45. t = time.time()
  46. while time.time() - t < 5:
  47. for f in conn.recv_frames(0.2):
  48. updater.apply(world, f)
  49. if f.msg_id == 643:
  50. dlg = world.npc_dialog or {}
  51. print(f"[SC643] 弹窗到达! index={dlg.get('index')}")
  52. _ = conn.send_frame(
  53. 1011, 0, 0, 0, sid,
  54. b'{"UserID":"999999999","Act":"@act_move,2","index":999999999}')
  55. print("[CS1011 @act_move,2] 已发, 等 30s")
  56. t = time.time()
  57. while time.time() - t < 30:
  58. for f in conn.recv_frames(0.2):
  59. updater.apply(world, f)
  60. if f.msg_id in (643, 800, 634, 20102):
  61. print(f" << 关键帧 {f.msg_id}")
  62. if world.me.map_name != "盟重土城":
  63. break
  64. print(f"[终态] {world.me.map_name} @({world.me.x},{world.me.y})")
  65. finally:
  66. stop[0] = True
  67. conn.close()
  68. return 0
  69. if __name__ == "__main__":
  70. sys.exit(main())