Skip to content

内核探针 API (Woozy Kernel)

内核探针模块通过 TankiDebug.kernel 暴露,提供游戏对象层面的数据访问与修改能力。

模块对象

TankiDebug.kernel

内核探针的主模块对象。

类型: object

示例:

javascript
// 打开探针面板
TankiDebug.kernel.openInspector();

// 获取缓存数据
const cache = TankiDebug.kernel.getCache();

核心属性

kernel.base

存储动态发现的路径键值,用于内部状态追踪。

类型: object

结构:

javascript
{
  ReactContainer: string | undefined,
  Root: { Key1: string | undefined, Key2: string | undefined },
  _TOState: { Key1: string | undefined },
  TOState: object,
  isGameReady: { isReady: boolean | undefined, isReadyKey: string | undefined },
  World: { Key1: string | undefined, Key2: string | undefined, Key3: string | undefined, Key4: string | undefined, Key5: string | undefined },
  LocalTank: { Key1: string | undefined, Key2: string | undefined }
}

说明: 这些值由内核探针自动填充,不同游戏版本可能不同。一般不需要直接访问。


window.tankiKeysCache

坦克物理数据的代理对象,实时同步游戏内存。

类型: object

结构:

javascript
{
  position: { x: number, y: number, z: number },   // 坐标
  Quaternion: { x: number, y: number, z: number, w: number }, // 四元数旋转
  velocity: { x: number, y: number, z: number },   // 速度
  _defined: object  // 内部标记,请勿修改
}

示例:

javascript
// 读取当前位置
const x = tankiKeysCache.position.x;
const y = tankiKeysCache.position.y;
const z = tankiKeysCache.position.z;

// 修改位置(瞬移)
tankiKeysCache.position.x = 100;
tankiKeysCache.position.y = 200;
tankiKeysCache.position.z = 50;

// 清空速度防止回弹
tankiKeysCache.velocity.x = 0;
tankiKeysCache.velocity.y = 0;
tankiKeysCache.velocity.z = 0;

window.cheatsBase

存储通过 React 状态树挖掘到的游戏对象引用。

类型: object

结构:

javascript
{
  Root: object | undefined,      // React 状态根节点
  World: object | undefined,     // 世界对象
  GameMode: object | undefined,  // 游戏模式
  LocalTank: object | undefined  // 本地坦克对象
}

说明: 这些是原始游戏对象,直接操作可能产生不可预知的结果。建议通过 tankiKeysCache 代理进行修改。


核心方法

kernel.openInspector()

打开内核探针的 UI 面板。

参数:

返回值: void

示例:

javascript
TankiDebug.kernel.openInspector();

面板提供:

  • 实时坐标显示与修改
  • 实时旋转显示与修改
  • 速度归零按钮
  • 数据复制按钮

kernel.writePhysical(type, axis, value)

写入物理属性值(UI 面板的底层实现)。

参数:

参数类型说明
typestringpos(坐标)或 quat(旋转)
axisstring轴名称(x/y/zw/x/y/z
valuenumber要设置的值

返回值: void

示例:

javascript
// 设置 X 坐标
TankiDebug.kernel.writePhysical('pos', 'x', 100);

// 设置四元数 W 分量
TankiDebug.kernel.writePhysical('quat', 'w', 0.707);

kernel.tick()

内核探针的主循环,用于持续探测游戏对象。由 setInterval 自动调用,通常不需要手动执行。

参数:

返回值: void

调用频率: 约 100ms/次


内部方法

以下方法由内核自动调用,一般不需要在插件中直接使用。

kernel.simpleName(obj)

提取对象中各属性的构造函数名。

参数: obj - 要分析的对象

返回值: object - { 构造函数名: 属性值, ... }

示例:

javascript
const names = TankiDebug.kernel.simpleName(someObject);
// 可能返回 { Vector3: {...}, Quaternion: {...} }

kernel.stateNode2()

获取 React 容器节点。

参数:

返回值: object | null - React 内部容器对象


kernel.getReactStateNode()

递归获取 React 状态节点。

参数:

返回值: object | undefined - 状态节点对象


kernel.findIsGameReady()

检测游戏是否已就绪(BattleStatistics 可用)。

参数:

返回值: boolean | undefined - 是否就绪


kernel.valuesFinder()

查找坦克物理属性并建立 tankiKeysCache 代理。

参数:

返回值: void


获取数据的方式

方式一:直接读取缓存(推荐)

javascript
if (window.tankiKeysCache) {
  const pos = window.tankiKeysCache.position;
  console.log(`当前位置: (${pos.x}, ${pos.y}, ${pos.z})`);
}

方式二:通过探针面板

javascript
TankiDebug.kernel.openInspector();

面板会实时刷新所有数据。

方式三:在插件中获取

javascript
// 插件 API 提供了 getKernel 方法
const kernel = api.getKernel();
if (kernel) {
  kernel.position.x = 500;  // 瞬移
}

使用示例

示例1:瞬移到指定坐标

javascript
function teleport(x, y, z) {
  if (!window.tankiKeysCache) {
    console.warn('内核未就绪');
    return;
  }
  tankiKeysCache.position.x = x;
  tankiKeysCache.position.y = y;
  tankiKeysCache.position.z = z;
  // 清空速度防止回弹
  tankiKeysCache.velocity.x = 0;
  tankiKeysCache.velocity.y = 0;
  tankiKeysCache.velocity.z = 0;
}

// 瞬移到 (100, 200, 500)
teleport(100, 200, 500);

示例2:获取当前位置

javascript
function getPosition() {
  if (!window.tankiKeysCache) return null;
  return {
    x: tankiKeysCache.position.x,
    y: tankiKeysCache.position.y,
    z: tankiKeysCache.position.z
  };
}

console.log(getPosition());

示例3:监听位置变化(轮询)

javascript
let lastPos = null;
setInterval(() => {
  if (!window.tankiKeysCache) return;
  const current = {
    x: tankiKeysCache.position.x,
    y: tankiKeysCache.position.y,
    z: tankiKeysCache.position.z
  };
  if (lastPos && (current.x !== lastPos.x || current.y !== lastPos.y || current.z !== lastPos.z)) {
    console.log('位置变化:', lastPos, '→', current);
  }
  lastPos = current;
}, 500);

示例4:在插件中使用

javascript
// 插件代码片段
const plugin = {
  onLoad: function(api) {
    const kernel = api.getKernel();
    if (kernel) {
      api.log('内核已就绪');
      // 保存原始坐标
      this.originalPos = {
        x: kernel.position.x,
        y: kernel.position.y,
        z: kernel.position.z
      };
    }
  },
  onUnload: function(api) {
    // 恢复坐标
    const kernel = api.getKernel();
    if (kernel && this.originalPos) {
      kernel.position.x = this.originalPos.x;
      kernel.position.y = this.originalPos.y;
      kernel.position.z = this.originalPos.z;
    }
  }
};

状态检测

检测内核是否就绪

javascript
function isKernelReady() {
  return !!(window.tankiKeysCache && window.cheatsBase && window.cheatsBase.LocalTank);
}

if (isKernelReady()) {
  console.log('内核探针已就绪');
} else {
  console.log('等待内核初始化...');
}

检测是否在战斗中

javascript
function isInBattle() {
  return window.tankiKeysCache !== undefined;
}

注意事项

注意说明
游戏版本依赖内核探针依赖特定的数据结构模式,游戏大版本更新可能导致失效
修改风险修改坐标、速度等物理属性可能被服务器检测并封号
使用场景建议仅在私人服务器或本地调试中使用
兼容性1.9.0 及以上版本支持,旧版本无此模块
初始化时机进入战斗后约 1-3 秒才会就绪

错误处理

安全读取

javascript
function safeGetPosition() {
  try {
    if (window.tankiKeysCache && window.tankiKeysCache.position) {
      return { ...window.tankiKeysCache.position };
    }
  } catch (e) {
    console.warn('读取位置失败:', e);
  }
  return null;
}

安全写入

javascript
function safeSetPosition(x, y, z) {
  try {
    if (!window.tankiKeysCache) {
      throw new Error('内核未就绪');
    }
    window.tankiKeysCache.position.x = x;
    window.tankiKeysCache.position.y = y;
    window.tankiKeysCache.position.z = z;
    window.tankiKeysCache.velocity.x = 0;
    window.tankiKeysCache.velocity.y = 0;
    window.tankiKeysCache.velocity.z = 0;
    return true;
  } catch (e) {
    console.error('写入位置失败:', e);
    return false;
  }
}

相关文档

内部技术交流 · 禁止外传