 | public void Amove() {
try {
// 一次连续移动 2~3 格(模拟真人走路节奏)
int stepsToMove = 2 + random.nextInt(2); // 随机2或3格
for (int step = 0; step < stepsToMove; step++) {
if (pc.get_parentListSize() <= 0) break; // 路径走完
Node _next = pc.get_autoparent();
if (_next.x == pc.getX() && _next.y == pc.getY()) {
break;
}
int dir = NodeToDir(_next, pc.getX(), pc.getY());
if (dir != -1) {
setDirectionMove(pc, dir); // 人物移动
// 移动过程中的延迟要短(30~50ms),模拟"脚步连续"
if (step < stepsToMove - 1) {
Thread.sleep(35 + random.nextInt(15));
}
} else {
break;
}
}
// 连续移动结束后,加入"人类化停顿"(看周围/犹豫)
int baseDelay = getRightInterval(2);
int hesitation = (random.nextInt(100) < 15) ? (random.nextInt(300) + 200) : 0; // 15%概率停顿0.2~0.5秒
if (random.nextInt(100) < 5) {
hesitation = random.nextInt(700) + 800; // 5%概率大幅停顿0.8~1.5秒
}
Thread.sleep(Math.max(30, baseDelay + hesitation));
} catch (Exception e) {
pc.clear_parentList();
openList.clear();
closeList.clear();
if (target != null) {
pc.addTargetList(target.getId());
}
}
}
| |