fix(lib): 坦克位置改为多级字段探测(修复雷达/透视为空)
- 根因:物理组件的位置向量字段每构建都平移,本次 pz7_1→gzh_1→rzf_1 的映射全都指错(gzh_1 是 TerminatorCC、rzf_1 是 RicochetSfxData) - GetTankPosition 改为多级探测:先试一组成员字段(xzq_1/uzq_1/azr_1/bzr_1/dzr_1/izr_1/jzr_1…),再兜底遍历组件找带 f20_1/g20_1/h20_1 的 O\$ 向量 - 透视的坦克绘制与金箱位置都改用 GetTankPosition
This commit is contained in:
1 parent
1cc1afdb08
commit
67b2ff4a80
4 files changed
+102
-63
No files matched your search
@@ -262,18 +262,39 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
// ===== 获取坦克位置(G$t 物理组件的 rzf_1 = O$向量) =====
|
||||
// ===== 获取坦克位置(物理组件里的位置向量) =====
|
||||
// 物理组件的字段名每个构建都可能平移,这里按"含 f20_1/g20_1/h20_1 的 O$ 向量"做多级探测:
|
||||
// ejt(tankPhysics)里可能的候选字段都试一遍,命中即用。
|
||||
// 返回 {x, y, z},x/y 水平面,z 高度
|
||||
var POS_FIELDS = ['xzq_1', 'uzq_1', 'azr_1', 'bzr_1', 'dzr_1', 'izr_1', 'jzr_1', 'rzf_1', 'gzh_1', 'pz7_1'];
|
||||
function GetTankPosition(tank) {
|
||||
var physicsComp = FindComponentByField(tank, 'rzf_1');
|
||||
if (physicsComp && physicsComp.rzf_1) {
|
||||
return {
|
||||
x: physicsComp.rzf_1.f20_1,
|
||||
y: physicsComp.rzf_1.g20_1,
|
||||
z: physicsComp.rzf_1.h20_1
|
||||
};
|
||||
for (var i = 0; i < POS_FIELDS.length; i++) {
|
||||
var Key = POS_FIELDS[i];
|
||||
var Comp = null;
|
||||
try { Comp = FindComponentByField(tank, Key); } catch (e) { Comp = null; }
|
||||
if (Comp && Comp[Key] && typeof Comp[Key].f20_1 === 'number') {
|
||||
return { x: Comp[Key].f20_1, y: Comp[Key].g20_1, z: Comp[Key].h20_1 };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// 兜底:遍历坦克全部组件,找任意"带 O$ 向量"的组件(位置向量通常会每帧更新,取第一个数值合理的)
|
||||
var Found = null;
|
||||
try {
|
||||
tank.qz1_1.s2a_1.forEach(function (valueList) {
|
||||
if (Found) return;
|
||||
var comp = (valueList && typeof valueList.g1 === 'function') ? valueList.g1(0) : valueList;
|
||||
if (!comp) return;
|
||||
for (var K in comp) {
|
||||
var V = comp[K];
|
||||
if (V && typeof V === 'object' && typeof V.f20_1 === 'number' && typeof V.g20_1 === 'number' && typeof V.h20_1 === 'number') {
|
||||
if (Math.abs(V.f20_1) < 1e6 && Math.abs(V.g20_1) < 1e6 && Math.abs(V.h20_1) < 1e6) {
|
||||
Found = { x: V.f20_1, y: V.g20_1, z: V.h20_1 };
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
return Found;
|
||||
}
|
||||
|
||||
// ===== 获取坦克状态值(Yjt 组件的 vzr_1.k3_1) =====
|
||||
@@ -2290,10 +2311,8 @@
|
||||
|
||||
// 金箱位置:优先物理组件(与坦克同款 rzf_1),否则退到 bonusData 里的节点世界矩阵/向量
|
||||
function GetGoldBoxPosition(Entity) {
|
||||
var Phys = FindComponentByField(Entity, 'rzf_1');
|
||||
if (Phys && Phys.rzf_1) {
|
||||
return { x: Phys.rzf_1.f20_1, y: Phys.rzf_1.g20_1, z: Phys.rzf_1.h20_1 };
|
||||
}
|
||||
var PhysPos = GetTankPosition(Entity); // 多级探测物理组件位置
|
||||
if (PhysPos) return PhysPos;
|
||||
var Bonus = Entity.j10q_1;
|
||||
for (var K in Bonus) {
|
||||
try {
|
||||
@@ -2434,18 +2453,12 @@
|
||||
if (!tank || tank === playerTank) continue;
|
||||
if (!EntityProtoHooked) InstallEntityHook(tank); // 借坦克实例找到实体基类原型,挂补给观察钩子
|
||||
|
||||
var physicsComp = FindComponentByField(tank, 'rzf_1');
|
||||
if (!physicsComp || !physicsComp.rzf_1) continue;
|
||||
var pos = GetTankPosition(tank); // 多级探测物理组件位置(字段名每个构建会平移)
|
||||
if (!pos) continue;
|
||||
var tankState = GetTankState(tank);
|
||||
// 可见坦克 = ACTIVE(3) 或 SEMI_ACTIVE(2)(引擎 s14j() 判定),0/1/4 才跳过
|
||||
if (tankState !== 2 && tankState !== 3) continue;
|
||||
|
||||
var pos = {
|
||||
x: physicsComp.rzf_1.f20_1,
|
||||
y: physicsComp.rzf_1.g20_1,
|
||||
z: physicsComp.rzf_1.h20_1
|
||||
};
|
||||
|
||||
// 本帧该坦克是否在移动(供「残留节点」检测:坦克在动而节点矩阵不动 = 旧位置遗留)
|
||||
// 用位移的指数滑动平均,而不是「单帧位移 > 10 单位」——后者对慢速移动几乎永远为假,
|
||||
// 会让残留检测形同虚设(残留漏掉的根因就在这里)
|
||||
|
||||
+34
-21
@@ -262,18 +262,39 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
// ===== 获取坦克位置(G$t 物理组件的 rzf_1 = O$向量) =====
|
||||
// ===== 获取坦克位置(物理组件里的位置向量) =====
|
||||
// 物理组件的字段名每个构建都可能平移,这里按"含 f20_1/g20_1/h20_1 的 O$ 向量"做多级探测:
|
||||
// ejt(tankPhysics)里可能的候选字段都试一遍,命中即用。
|
||||
// 返回 {x, y, z},x/y 水平面,z 高度
|
||||
var POS_FIELDS = ['xzq_1', 'uzq_1', 'azr_1', 'bzr_1', 'dzr_1', 'izr_1', 'jzr_1', 'rzf_1', 'gzh_1', 'pz7_1'];
|
||||
function GetTankPosition(tank) {
|
||||
var physicsComp = FindComponentByField(tank, 'rzf_1');
|
||||
if (physicsComp && physicsComp.rzf_1) {
|
||||
return {
|
||||
x: physicsComp.rzf_1.f20_1,
|
||||
y: physicsComp.rzf_1.g20_1,
|
||||
z: physicsComp.rzf_1.h20_1
|
||||
};
|
||||
for (var i = 0; i < POS_FIELDS.length; i++) {
|
||||
var Key = POS_FIELDS[i];
|
||||
var Comp = null;
|
||||
try { Comp = FindComponentByField(tank, Key); } catch (e) { Comp = null; }
|
||||
if (Comp && Comp[Key] && typeof Comp[Key].f20_1 === 'number') {
|
||||
return { x: Comp[Key].f20_1, y: Comp[Key].g20_1, z: Comp[Key].h20_1 };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// 兜底:遍历坦克全部组件,找任意"带 O$ 向量"的组件(位置向量通常会每帧更新,取第一个数值合理的)
|
||||
var Found = null;
|
||||
try {
|
||||
tank.qz1_1.s2a_1.forEach(function (valueList) {
|
||||
if (Found) return;
|
||||
var comp = (valueList && typeof valueList.g1 === 'function') ? valueList.g1(0) : valueList;
|
||||
if (!comp) return;
|
||||
for (var K in comp) {
|
||||
var V = comp[K];
|
||||
if (V && typeof V === 'object' && typeof V.f20_1 === 'number' && typeof V.g20_1 === 'number' && typeof V.h20_1 === 'number') {
|
||||
if (Math.abs(V.f20_1) < 1e6 && Math.abs(V.g20_1) < 1e6 && Math.abs(V.h20_1) < 1e6) {
|
||||
Found = { x: V.f20_1, y: V.g20_1, z: V.h20_1 };
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
return Found;
|
||||
}
|
||||
|
||||
// ===== 获取坦克状态值(Yjt 组件的 vzr_1.k3_1) =====
|
||||
@@ -2290,10 +2311,8 @@
|
||||
|
||||
// 金箱位置:优先物理组件(与坦克同款 rzf_1),否则退到 bonusData 里的节点世界矩阵/向量
|
||||
function GetGoldBoxPosition(Entity) {
|
||||
var Phys = FindComponentByField(Entity, 'rzf_1');
|
||||
if (Phys && Phys.rzf_1) {
|
||||
return { x: Phys.rzf_1.f20_1, y: Phys.rzf_1.g20_1, z: Phys.rzf_1.h20_1 };
|
||||
}
|
||||
var PhysPos = GetTankPosition(Entity); // 多级探测物理组件位置
|
||||
if (PhysPos) return PhysPos;
|
||||
var Bonus = Entity.j10q_1;
|
||||
for (var K in Bonus) {
|
||||
try {
|
||||
@@ -2434,18 +2453,12 @@
|
||||
if (!tank || tank === playerTank) continue;
|
||||
if (!EntityProtoHooked) InstallEntityHook(tank); // 借坦克实例找到实体基类原型,挂补给观察钩子
|
||||
|
||||
var physicsComp = FindComponentByField(tank, 'rzf_1');
|
||||
if (!physicsComp || !physicsComp.rzf_1) continue;
|
||||
var pos = GetTankPosition(tank); // 多级探测物理组件位置(字段名每个构建会平移)
|
||||
if (!pos) continue;
|
||||
var tankState = GetTankState(tank);
|
||||
// 可见坦克 = ACTIVE(3) 或 SEMI_ACTIVE(2)(引擎 s14j() 判定),0/1/4 才跳过
|
||||
if (tankState !== 2 && tankState !== 3) continue;
|
||||
|
||||
var pos = {
|
||||
x: physicsComp.rzf_1.f20_1,
|
||||
y: physicsComp.rzf_1.g20_1,
|
||||
z: physicsComp.rzf_1.h20_1
|
||||
};
|
||||
|
||||
// 本帧该坦克是否在移动(供「残留节点」检测:坦克在动而节点矩阵不动 = 旧位置遗留)
|
||||
// 用位移的指数滑动平均,而不是「单帧位移 > 10 单位」——后者对慢速移动几乎永远为假,
|
||||
// 会让残留检测形同虚设(残留漏掉的根因就在这里)
|
||||
|
||||
@@ -773,10 +773,8 @@
|
||||
|
||||
// 金箱位置:优先物理组件(与坦克同款 rzf_1),否则退到 bonusData 里的节点世界矩阵/向量
|
||||
function GetGoldBoxPosition(Entity) {
|
||||
var Phys = FindComponentByField(Entity, 'rzf_1');
|
||||
if (Phys && Phys.rzf_1) {
|
||||
return { x: Phys.rzf_1.f20_1, y: Phys.rzf_1.g20_1, z: Phys.rzf_1.h20_1 };
|
||||
}
|
||||
var PhysPos = GetTankPosition(Entity); // 多级探测物理组件位置
|
||||
if (PhysPos) return PhysPos;
|
||||
var Bonus = Entity.j10q_1;
|
||||
for (var K in Bonus) {
|
||||
try {
|
||||
@@ -917,18 +915,12 @@
|
||||
if (!tank || tank === playerTank) continue;
|
||||
if (!EntityProtoHooked) InstallEntityHook(tank); // 借坦克实例找到实体基类原型,挂补给观察钩子
|
||||
|
||||
var physicsComp = FindComponentByField(tank, 'rzf_1');
|
||||
if (!physicsComp || !physicsComp.rzf_1) continue;
|
||||
var pos = GetTankPosition(tank); // 多级探测物理组件位置(字段名每个构建会平移)
|
||||
if (!pos) continue;
|
||||
var tankState = GetTankState(tank);
|
||||
// 可见坦克 = ACTIVE(3) 或 SEMI_ACTIVE(2)(引擎 s14j() 判定),0/1/4 才跳过
|
||||
if (tankState !== 2 && tankState !== 3) continue;
|
||||
|
||||
var pos = {
|
||||
x: physicsComp.rzf_1.f20_1,
|
||||
y: physicsComp.rzf_1.g20_1,
|
||||
z: physicsComp.rzf_1.h20_1
|
||||
};
|
||||
|
||||
// 本帧该坦克是否在移动(供「残留节点」检测:坦克在动而节点矩阵不动 = 旧位置遗留)
|
||||
// 用位移的指数滑动平均,而不是「单帧位移 > 10 单位」——后者对慢速移动几乎永远为假,
|
||||
// 会让残留检测形同虚设(残留漏掉的根因就在这里)
|
||||
|
||||
+30
-9
@@ -47,18 +47,39 @@
|
||||
return result;
|
||||
}
|
||||
|
||||
// ===== 获取坦克位置(G$t 物理组件的 rzf_1 = O$向量) =====
|
||||
// ===== 获取坦克位置(物理组件里的位置向量) =====
|
||||
// 物理组件的字段名每个构建都可能平移,这里按"含 f20_1/g20_1/h20_1 的 O$ 向量"做多级探测:
|
||||
// ejt(tankPhysics)里可能的候选字段都试一遍,命中即用。
|
||||
// 返回 {x, y, z},x/y 水平面,z 高度
|
||||
var POS_FIELDS = ['xzq_1', 'uzq_1', 'azr_1', 'bzr_1', 'dzr_1', 'izr_1', 'jzr_1', 'rzf_1', 'gzh_1', 'pz7_1'];
|
||||
function GetTankPosition(tank) {
|
||||
var physicsComp = FindComponentByField(tank, 'rzf_1');
|
||||
if (physicsComp && physicsComp.rzf_1) {
|
||||
return {
|
||||
x: physicsComp.rzf_1.f20_1,
|
||||
y: physicsComp.rzf_1.g20_1,
|
||||
z: physicsComp.rzf_1.h20_1
|
||||
};
|
||||
for (var i = 0; i < POS_FIELDS.length; i++) {
|
||||
var Key = POS_FIELDS[i];
|
||||
var Comp = null;
|
||||
try { Comp = FindComponentByField(tank, Key); } catch (e) { Comp = null; }
|
||||
if (Comp && Comp[Key] && typeof Comp[Key].f20_1 === 'number') {
|
||||
return { x: Comp[Key].f20_1, y: Comp[Key].g20_1, z: Comp[Key].h20_1 };
|
||||
}
|
||||
}
|
||||
return null;
|
||||
// 兜底:遍历坦克全部组件,找任意"带 O$ 向量"的组件(位置向量通常会每帧更新,取第一个数值合理的)
|
||||
var Found = null;
|
||||
try {
|
||||
tank.qz1_1.s2a_1.forEach(function (valueList) {
|
||||
if (Found) return;
|
||||
var comp = (valueList && typeof valueList.g1 === 'function') ? valueList.g1(0) : valueList;
|
||||
if (!comp) return;
|
||||
for (var K in comp) {
|
||||
var V = comp[K];
|
||||
if (V && typeof V === 'object' && typeof V.f20_1 === 'number' && typeof V.g20_1 === 'number' && typeof V.h20_1 === 'number') {
|
||||
if (Math.abs(V.f20_1) < 1e6 && Math.abs(V.g20_1) < 1e6 && Math.abs(V.h20_1) < 1e6) {
|
||||
Found = { x: V.f20_1, y: V.g20_1, z: V.h20_1 };
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
} catch (e) {}
|
||||
return Found;
|
||||
}
|
||||
|
||||
// ===== 获取坦克状态值(Yjt 组件的 vzr_1.k3_1) =====
|
||||
|
||||
Reference in new issue
Block a user