Skip to content

Commit

Permalink
组包更新,捡物优化
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuapeng committed Jan 8, 2024
1 parent 2b7609e commit e5dc4b8
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 20 deletions.
30 changes: 20 additions & 10 deletions src/main/java/com/dnf/game/AutoThread.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@
*/
@Component
public class AutoThread extends Base {
static boolean firstEnterMap; // 首次进图
// 首次进图
static boolean firstEnterMap;

// static int completedNum; // 完成次数
// 完成次数
// static int completedNum;

@Resource
private MapData mapData;
Expand Down Expand Up @@ -95,34 +97,45 @@ private void autoThread() {
int nextInt = random.nextInt(9999999 - 5201314 + 1) + 5201314;
memory.writeLong(memory.readLong(Address.PFAddr) + Address.CEPfAddr, nextInt);
firstEnterMap = true;
continue;
}

// 跟随怪物
if (iniUtils.read("自动配置", "跟随打怪", Integer.class) > 0) {
logger.debug("开始跟随怪物");
traverse.followMonster();
continue;
}

// 过图
if (mapData.isOpenDoor() && !mapData.isBossRoom()) {
// 捡物品
traverse.packPickup();
if (traverse.isExistsItem()) {
// 捡物品
logger.debug("过图捡物");
traverse.packPickup();
continue;
}
// 过图
passMap();
continue;
}

if (mapData.isBossRoom() && mapData.isPass()) {
// 捡物品
traverse.packPickup();
if (traverse.isExistsItem()) {
logger.debug("boss房捡物");
traverse.packPickup();
continue;
}

// 刷图计次
passBoss();
// 退出副本
quitMap();
firstEnterMap = false;
}
}
} catch (Exception ignore) {
} catch (Exception exception) {
logger.error("自动线程出错 {}", exception.getMessage());
}
}
}
Expand Down Expand Up @@ -312,14 +325,11 @@ private void quitMap() {
while (GlobalData.autoSwitch) {
logger.debug("退出副本-处理");
Timer.sleep(200);
// 捡物品
traverse.packPickup();
if (outMap == 0) {
Timer.sleep(3000);
}
// 退出地图
sendPack.leaveMap();

// 在城镇或者选图跳出循环
if (mapData.getStat() == 1) {
break;
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/com/dnf/game/SendPack.java
Original file line number Diff line number Diff line change
Expand Up @@ -169,9 +169,10 @@ public void moveMap(Long maxMap, Long mixMap, Long x, Long y) {
jmCall(y, 2);
jmCall(5, 1);
jmCall(38, 4);
jmCall(0, 2);
jmCall(1, 2);
jmCall(0, 4);
jmCall(0, 1);
jmCall(5, 1);
fbCall();
}

Expand All @@ -188,13 +189,14 @@ public void pickUp(long addr) {
jmCall(addr, 4);
jmCall(0, 1);
jmCall(1, 1);
jmCall(566, 2);
jmCall(291, 2);
jmCall(9961, 2);
jmCall(553, 2);
jmCall(285, 2);
jmCall(18802, 2);
jmCall(24743, 2);
jmCall(420, 2);
jmCall(254, 2);
jmCall(4501, 2);
jmCall(435, 2);
jmCall(271, 2);
jmCall(22624, 2);
jmCall(28402, 2);
jmCall(0, 1);
fbCall();
}

Expand Down
41 changes: 39 additions & 2 deletions src/main/java/com/dnf/game/Traverse.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ public MapTraversalType getMapData() {
return data;
}

protected String[] getItemConfig() {
String itemStr = iniUtils.read("自动配置", "过滤物品", String.class);
return itemStr.split(",");
}

/**
* 组包拾取
*/
Expand All @@ -45,8 +50,7 @@ public void packPickup() {
return;
}

String itemStr = iniUtils.read("自动配置", "过滤物品", String.class);
String[] itemArr = itemStr.split(",");
String[] itemArr = this.getItemConfig();

// 地图遍历数据
MapTraversalType data = getMapData();
Expand Down Expand Up @@ -170,4 +174,37 @@ public void followMonster() {
}
}
}

/**
* 是否存在物品
*
* @return boolean
*/
public boolean isExistsItem() {
if (mapData.getStat() != 3) {
return false;
}

String[] itemArr = this.getItemConfig();
MapTraversalType data = getMapData();
for (data.objTmp = 1; data.objTmp < data.objNum; data.objTmp++) {
data.objPtr = mapData.getTraversalPtr(data.start, data.objTmp, 2);
data.objTypeA = memory.readInt(data.objPtr + Address.LxPyAddr);
data.objCamp = memory.readInt(data.objPtr + Address.ZyPyAddr);
if ((data.objTypeA == 289 || data.objTypeB == 289) && data.objCamp == 200) {
int[] goodsNameByte = memory.readByte(memory.readLong(memory.readLong(data.objPtr + Address.DmWpAddr) + Address.WpMcAddr), 100);
data.objNameB = Strings.unicodeToAscii(goodsNameByte);

if (Arrays.asList(itemArr).contains(data.objNameB)) {
continue;
}

if (data.objPtr != data.rwAddr) {
return true;
}
}
}

return false;
}
}

0 comments on commit e5dc4b8

Please sign in to comment.