Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bot for new BH version (Fishing + ReRun) #81

Merged
merged 16 commits into from
Nov 16, 2022
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,19 @@
# IMPORTANT: Sadly, bot no longer works with new update Nov 16th, 2022
## I don't know if I can fix this or not, haven't know why atm
### Fixed functions:
- [x] Fishing
- [x] ReRun
- [ ] PVP
- [ ] WB Solo
- [ ] WB Team
- [ ] Raid
- [ ] GVG
- [ ] Invasion
- [ ] Expedition 1
- [ ] Expedition 2
- [ ] Expedition 3
- [ ] Expedition 4
- [ ] Trials
- [ ] Gauntlet

**Upgrade notes:** copy configuration files `user-config.properties` and `readonly.*.user-config.properties` from previous bot version's directory _(if you update the bot via auto-update method then no need to do this)_
___
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>bh.bot</groupId>
<artifactId>99bot</artifactId>
<version>2.10.1</version>
<version>2.11.0</version>

<dependencies>
<dependency>
Expand Down
27 changes: 20 additions & 7 deletions src/main/java/bh/bot/app/AbstractApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -1237,7 +1237,8 @@ protected boolean tryEnterRaid(boolean doRaid, UserConfig userConfig, Supplier<B
mouseMoveAndClickAndHide(coord);
BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog.setLastMatchPoint(coord.x, coord.y);
Tuple2<Point[], Byte> result = detectRadioButtons(
Configuration.screenResolutionProfile.getRectangleRadioButtonsOfRaid());
Configuration.screenResolutionProfile.getRectangleRadioButtonsOfRaid()
);
Point[] points = result._1;
int selectedLevel = result._2 + 1;
info("Found %d raid levels, selected %s", points.length, UserConfig.getRaidLevelDesc(selectedLevel));
Expand Down Expand Up @@ -1265,16 +1266,28 @@ protected boolean tryEnterRaid(boolean doRaid, UserConfig userConfig, Supplier<B
sleep(5_000);
if (UserConfig.isNormalMode(userConfig.raidMode)) {
mouseMoveAndClickAndHide(
fromRelativeToAbsoluteBasedOnPreviousResult(BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord, Configuration.screenResolutionProfile.getOffsetButtonEnterNormalRaid()));
fromRelativeToAbsoluteBasedOnPreviousResult(
BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord,
Configuration.screenResolutionProfile.getOffsetButtonEnterNormalRaid()
)
);
} else if (UserConfig.isHardMode(userConfig.raidMode)) {
mouseMoveAndClickAndHide(
fromRelativeToAbsoluteBasedOnPreviousResult(BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord, Configuration.screenResolutionProfile.getOffsetButtonEnterHardRaid()));
fromRelativeToAbsoluteBasedOnPreviousResult(
BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord,
Configuration.screenResolutionProfile.getOffsetButtonEnterHardRaid()
)
);
} else if (UserConfig.isHeroicMode(userConfig.raidMode)) {
mouseMoveAndClickAndHide(
fromRelativeToAbsoluteBasedOnPreviousResult(BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord, Configuration.screenResolutionProfile.getOffsetButtonEnterHeroicRaid()));
fromRelativeToAbsoluteBasedOnPreviousResult(
BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord,
Configuration.screenResolutionProfile.getOffsetButtonEnterHeroicRaid()
)
);
} else {
throw new InvalidDataException("Unknown raid mode value: %d", userConfig.raidMode);
}
Expand Down
30 changes: 18 additions & 12 deletions src/main/java/bh/bot/app/FishingApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ private void doLoopFishing(int loopCount, final AtomicBoolean masterSwitch, fina
} else if (curScreen == screenCast) {
debug("On screen CAST");

Offset offsetScanCastingFish = Configuration.screenResolutionProfile
.getOffsetScanCastingFish();
Size scanSizeCastingFish = Configuration.screenResolutionProfile
.getScanSizeCastingFish();
BufferedImage sc = captureScreen(anchorPoint.x + offsetScanCastingFish.X,
anchorPoint.y + offsetScanCastingFish.Y, scanSizeCastingFish.W, scanSizeCastingFish.H);
Offset offsetScanCastingFish = Configuration.screenResolutionProfile.getOffsetScanCastingFish();
Size scanSizeCastingFish = Configuration.screenResolutionProfile.getScanSizeCastingFish();
BufferedImage sc = captureScreen(
anchorPoint.x + offsetScanCastingFish.X, anchorPoint.y + offsetScanCastingFish.Y,
scanSizeCastingFish.W, scanSizeCastingFish.H
);
final int black = 0x000000;
try {
final int offset1 = 0;
Expand Down Expand Up @@ -336,9 +336,12 @@ private boolean isContains(BufferedImage sc, BwMatrixMeta im, @SuppressWarnings(
blackPixelDRgb, //
sc.getRGB(offsetX + px[0], offsetY + px[1]) & 0xFFFFFF, //
colorTolerant, im.getOriginalPixelPart(px[0], px[1]))) {
optionalDebug(debug, "Fail (1) at %3d, %3d (offset=%3d, %3d, coord=%3d, %3d) with color: %d vs %d",
offsetX + px[0], offsetY + px[1], offsetX, offsetY, px[0], px[1], blackPixelRgb,
sc.getRGB(offsetX + px[0], offsetY + px[1]) & 0xFFFFFF);
optionalDebug(
debug,
"Fail (1) at %3d, %3d (offset=%3d, %3d, coord=%3d, %3d) with color: %s vs %s",
offsetX + px[0], offsetY + px[1], offsetX, offsetY, px[0], px[1],
String.format("%06X", blackPixelRgb), String.format("%06X", sc.getRGB(offsetX + px[0], offsetY + px[1]) & 0xFFFFFF)
);
return false;
}
}
Expand All @@ -348,9 +351,12 @@ private boolean isContains(BufferedImage sc, BwMatrixMeta im, @SuppressWarnings(
blackPixelRgb, //
sc.getRGB(offsetX + px[0], offsetY + px[1]) & 0xFFFFFF, //
colorTolerant)) {
optionalDebug(debug, "Fail (2) at %3d, %3d (offset=%3d, %3d, coord=%3d, %3d) with color: %d vs %d",
offsetX + px[0], offsetY + px[1], offsetX, offsetY, px[0], px[1], blackPixelRgb,
sc.getRGB(offsetX + px[0], offsetY + px[1]) & 0xFFFFFF);
optionalDebug(
debug,
"Fail (2) at %3d, %3d (offset=%3d, %3d, coord=%3d, %3d) with color: %s vs %s",
offsetX + px[0], offsetY + px[1], offsetX, offsetY, px[0], px[1],
String.format("%06X", blackPixelRgb), String.format("%06X", sc.getRGB(offsetX + px[0], offsetY + px[1]) & 0xFFFFFF)
);
return false;
}
}
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/bh/bot/app/dev/TestApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ public class TestApp extends AbstractApplication {
protected void internalRun(String[] args) {
adjustScreenOffset();

System.out.println("Clicked = " + clickImage(BwMatrixMeta.Metas.Raid.Buttons.accept));
System.out.println("Clicked = " + clickImage(BwMatrixMeta.Metas.Raid.Dialogs.notEnoughShards));

//
}

Expand Down
19 changes: 18 additions & 1 deletion src/main/java/bh/bot/common/types/AttendablePlace.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,25 @@ public AttendablePlace(String name, int id, String imgName, boolean left) throws
public AttendablePlace(String name, int id, String imgCode, boolean left, int procedureTicketMinutes) throws IOException {
this.name = name;
this.id = id;

String imgFile;
switch(imgCode) {
case "pvp":
case "world-boss":
case "raid":
case "gvg":
case "trials":
imgFile = imgCode + "2";
break;
case "expedition":
case "gauntlet":
case "invasion":
default:
imgFile = imgCode;
break;
}
this.img = BwMatrixMeta.from(
String.format("labels/attendable-places/%s?", imgCode),
String.format("labels/attendable-places/%s?", imgFile),
new Offset(0, 0),
0xFFFFFF
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ public Offset getOffsetButtonReconnect() {

@Override
public Offset getOffsetLabelFishing() {
return new Offset(355, 13);
return new Offset(356, 13);
}

@Override
Expand Down
46 changes: 24 additions & 22 deletions src/main/java/bh/bot/common/types/images/BwMatrixMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ public static class Buttons {
public static BwMatrixMeta autoG;
public static BwMatrixMeta autoR;
public static BwMatrixMeta radioButton;
public static BwMatrixMeta close;
// public static BwMatrixMeta close;
public static BwMatrixMeta mapButtonOnFamiliarUi;
public static BwMatrixMeta persuade;
public static BwMatrixMeta persuadeBribe;
Expand Down Expand Up @@ -372,47 +372,49 @@ public static class Dialogs {

public static void load() throws IOException {
Metas.Globally.Buttons.talkRightArrow = BwMatrixMeta.from(//
"buttons/globally.talkRightArrow?",
"buttons/globally.talkRightArrow2?",
Configuration.screenResolutionProfile.getOffsetButtonTalkRightArrow(), //
0x000000
);
Metas.Globally.Buttons.reconnect = BwMatrixMeta.from(//
"buttons/globally.reconnect?",
"buttons/globally.reconnect2?",
Configuration.screenResolutionProfile.getOffsetButtonReconnect(), //
0xFFFFFF
);
Metas.Globally.Buttons.autoG = BwMatrixMeta.from(//
"buttons/globally.auto-green?",
"buttons/globally.auto-green2?",
Configuration.screenResolutionProfile.getOffsetButtonAuto(), //
0xFFFFFF
);
Metas.Globally.Buttons.autoR = BwMatrixMeta.from(//
"buttons/globally.auto-red?",
"buttons/globally.auto-red2?",
Configuration.screenResolutionProfile.getOffsetButtonAuto(), //
0xFFFFFF
);
Metas.Globally.Buttons.radioButton = BwMatrixMeta.from(//
"buttons/globally.radio-button?",
Offset.none(), //
0x000000
);
Metas.Globally.Buttons.close = BwMatrixMeta.from(//
"buttons/globally.close?",
"buttons/globally.radio-button2?",
Offset.none(), //
0x000000
);
/*
Metas.Globally.Buttons.close = BwMatrixMeta.from(//
"buttons/globally.close?",
Offset.none(), //
0x000000
);
*/
Metas.Globally.Buttons.mapButtonOnFamiliarUi = BwMatrixMeta.from(//
"buttons/globally.map-on-familiar-ui?",
"buttons/globally.map-on-familiar-ui2?",
Configuration.screenResolutionProfile.getOffsetButtonMapOnFamiliarUi(), //
0x000000
);
Metas.Globally.Buttons.persuade = BwMatrixMeta.from(//
"buttons/globally.persuade?",
"buttons/globally.persuade2?",
Configuration.screenResolutionProfile.getOffsetButtonPersuade(), //
0xFFFFFF
);
Metas.Globally.Buttons.persuadeBribe = BwMatrixMeta.from(//
"buttons/globally.persuade-bribe?",
"buttons/globally.persuade-bribe2?",
Configuration.screenResolutionProfile.getOffsetButtonBribePersuade(), //
0xFFFFFF
);
Expand Down Expand Up @@ -442,7 +444,7 @@ public static void load() throws IOException {
0xFFFFFF
);
Metas.Dungeons.Buttons.rerun = BwMatrixMeta.from(//
"buttons/dungeons.rerun?",
"buttons/dungeons.rerun2?",
Configuration.screenResolutionProfile.getOffsetButtonDungeonReRun(), //
0xFFFFFF);

Expand Down Expand Up @@ -495,22 +497,22 @@ public static void load() throws IOException {

// Fishing
Metas.Fishing.Labels.fishing = BwMatrixMeta.from(//
"labels/fishing?",
"labels/fishing.fishing2?",
Configuration.screenResolutionProfile.getOffsetLabelFishing(), //
0xFFFFFF
);
Metas.Fishing.Buttons.start = BwMatrixMeta.from(//
"buttons/fishing.start?",
"buttons/fishing.start2?",
Configuration.screenResolutionProfile.getOffsetButtonFishingStart(), //
0xFFFFFF
);
Metas.Fishing.Buttons.cast = BwMatrixMeta.from(//
"buttons/fishing.cast?",
"buttons/fishing.cast2?",
Configuration.screenResolutionProfile.getOffsetButtonFishingCast(), //
0xFFFFFF
);
Metas.Fishing.Buttons.catch_ = BwMatrixMeta.from(//
"buttons/fishing.catch?",
"buttons/fishing.catch2?",
Configuration.screenResolutionProfile.getOffsetButtonFishingCatch(), //
0xFFFFFF
);
Expand Down Expand Up @@ -756,17 +758,17 @@ public static void load() throws IOException {

// Raid
Metas.Raid.Buttons.town = BwMatrixMeta.from(//
"buttons/raid.town?", //
"buttons/raid.town2?", //
Configuration.screenResolutionProfile.getOffsetButtonTownWhenDefeatedInRaid(), //
0xFFFFFF
);
Metas.Raid.Buttons.accept = BwMatrixMeta.from(//
"buttons/raid.accept-tp.bmp", //
"buttons/raid.accept2?", //
Configuration.screenResolutionProfile.getOffsetButtonAcceptTeamOfRaid(), //
0xFFFFFF
);
Metas.Raid.Labels.labelInSummonDialog = BwMatrixMeta.from(//
"labels/raid-tp.bmp", //
"labels/raid.raid2?", //
Configuration.screenResolutionProfile.getOffsetLabelRaidInSummonDialog(), //
0xFFFFFF
);
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion web/json/reject-versions-2.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"bv":["2.8.3"],"bf":{"0.0.2":["tp"],"2.3.0":["afk","expedition"],"2.4.0":["afk","expedition"],"2.8.0":["world-boss-team"]}}
{"bv":["2.10.1","2.10.0","2.9.3","2.9.2","2.9.1","2.9.0","2.8.6","2.8.5","2.8.4","2.8.3","2.8.2","2.8.1","2.8.0"],"bf":{"0.0.2":["tp"],"2.3.0":["afk","expedition"],"2.4.0":["afk","expedition"],"2.11.0":["afk","pvp","world-boss","world-boss-team","raid","expedition","invasion","gvg","trials","gauntlet"]}}