游戏接管
game-takeover
by canyang335100
接管游戏角色控制。当需要:接管游戏角色、发送移动指令、发送聊天消息、与NPC交互、获取感知数据时使用。游戏为「口袋冒险大陆」,通过WebSocket桥接(端口18765)控制AI角色。项目路径 F:\maoxiandalu\。
安装
claude skill add --url https://github.com/openclaw/skills文档
Game Takeover
通过 OpenClaw 接管「口袋冒险大陆」游戏角色的控制权。
游戏信息
| 项目 | 值 |
|---|---|
| 游戏 URL | https://www.mxdl.online/index2.html |
| 桥接端口 | 18765(WebSocket) |
| 玩家 UID | 280181a14_10001 |
| 地图信息 | gridInfo[x][y] = true 可通行,false 障碍 |
| 示例地图 | mapId=5004, size=100×110 |
准备工作
⚠️ 操作顺序(必须严格遵守)
- 先启动桥接服务(端口 18765)
- 再打开游戏
- 玩家点托管(由用户手动操作)
顺序错误会导致玩家无法连接桥接。
1. AI 自动启动桥接
收到「接管游戏」指令时,第一步先启动桥接:
cd <skill目录>/scripts
npm install
node start_game_bridge.js
等待桥接就绪(约 1-2 秒)。
2. AI 自动打开游戏
桥接启动后,第二步打开游戏:
游戏 URL:https://www.mxdl.online/index2.html
3. 用户操作(AI 打开游戏后)
- 在浏览器中登录自己的账号
- 点击游戏内的「托管」按钮,让 AIController 连接桥接服务
注意:必须由用户在游戏内主动点击「托管」,这一步无法由 AI 代完成。
2. 获取玩家 UID
AI 注册时使用 OPENCLAW,但这只是标识符。游戏客户端的真实 UID 由桥接服务通知:
{ "type": "ai_client_connected", "playerUid": "280181a14_10001", ... }
后续发送指令时需使用这个真实 UID。
自动启动桥接流程
每次收到控制指令时,AI 会自动按此流程执行:
Step 1:检查桥接是否运行
const net = require('net');
const isPortInUse = (port) => new Promise((resolve) => {
const client = new net.Socket();
client.once('connect', () => { client.destroy(); resolve(true); });
client.once('error', () => resolve(false));
client.connect(port, '127.0.0.1');
});
Step 2:桥接未运行则启动
cd <skill目录>/scripts
npm install
node start_game_bridge.js
Step 3:等待桥接就绪后注册
{ "type": "ai_register", "playerUid": "OPENCLAW" }
等待 ai_client_connected 消息,记录真实 playerUid(如 8b7c7119c_10001)。
Step 4:感知当前位置
发 get_perception 获取 self.position,这是角色的当前坐标,移动指令必须基于此坐标在 ±20 范围内。
⚠️ 如果有多个游戏客户端同时连接,以桥接日志中最新注册的客户端为准。日志中
当前保存的客户端: [...]列表的最后一项就是最新加入的。
控制指令
移动指令
{
"type": "ai_send_to_player",
"targetPlayerUid": "280181a14_10001",
"command": { "type": "move", "x": 12, "y": 39 }
}
⚠️ 移动前必须先感知当前位置(get_perception 获取 self.position),A* 寻路单次移动范围建议控制在 ±20 格以内。
聊天指令
{
"type": "ai_send_to_player",
"targetPlayerUid": "280181a14_10001",
"command": { "type": "sendDialogue", "message": "大家好!" }
}
NPC 交互
{
"type": "ai_send_to_player",
"targetPlayerUid": "280181a14_10001",
"command": { "type": "interact", "npcId": "npc_001" }
}
获取感知数据
{
"type": "ai_send_to_player",
"targetPlayerUid": "280181a14_10001",
"command": { "type": "get_perception" }
}
返回周围玩家、怪物、NPC 等信息。
完整通信流程
OpenClaw → Bridge(18765) → AIController → 游戏客户端
↓
执行指令(移动/聊天/交互)
- OpenClaw 发送
ai_register到 Bridge - Bridge 转发到游戏客户端
- 游戏客户端回复
ai_client_connected(含真实UID) - OpenClaw 发送
ai_send_to_player+command控制游戏角色 - 如需感知数据,发送
get_perception
注意事项
- 必须用户先点击托管:AI 无法替代用户在游戏内操作
- gridInfo 格式:
true= 可通行,false= 障碍 - playerUid 每次可能不同:重新连接后需重新获取真实 UID
- 聊天字段名:用
content,不是message - 地图切换:桥接收到
ai_map_changed消息时表示地图已切换,gridInfo 会自动更新
资源
scripts/
OpenClawGameBridge.js- 桥接核心(WebSocket 服务端)start_game_bridge.js- 启动脚本package.json- 依赖配置(ws)
相关 Skills
面试体系设计
by alirezarezvani
按岗位、级别和团队设计面试流程,生成能力矩阵、题库与评分标准,分析面试官偏差并校准招聘门槛,适合搭建或优化企业招聘体系。
✎ 团队招人没章法时,用它快速搭建岗位化面试流程、题库与评分标准,还能兼顾校准面试偏差,招聘更稳更准。
UTXO工具
by BytesAgain
Utxo reference tool. Use when working with utxo in blockchain contexts.
会计工具
by MCF Agentic
Financial management with invoices, expenses, job costing, P&L reports, and QuickBooks sync — built for AI agents.
相关 MCP 服务
by boosted-chat
Flight search & booking for AI agents. 400+ airlines, $20-50 cheaper than OTAs.
by jjlabsio
Search company disclosures and financial statements from the Korean market. Retrieve stock profiles, market classifications, and historical trading data across major exchanges. Accelerate equity research with accurate, date-specific insights for Korean securities.
✎ 做韩国股研时,用它能一站查公司披露、财报和历史行情,按日期精确追溯关键信息,比手动翻交易所高效太多。
by jjlabsio
检索韩国市场公司的披露文件与财务报表,并获取股票概况等关键信息。
✎ 想研究韩股公司时,它能一站式拉取披露、财报和股票概况,省去跨站查资料的麻烦,对跨境投研尤其省时。