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

Feature: AFK Questing Loop #93

Merged
merged 28 commits into from
Jan 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
a7fc382
add initial questing
daredoes Jan 20, 2023
fa8f1d8
Add bmp
daredoes Jan 20, 2023
7061bf7
select quest and cancel
daredoes Jan 20, 2023
3a04c1a
attempt to add quest app basics
daredoes Jan 20, 2023
82c7ece
Add Quest Mode
daredoes Jan 20, 2023
7c9c505
reorder quest
daredoes Jan 21, 2023
57ada12
add experimental quest finder
daredoes Jan 22, 2023
fc90ea3
add experimental quest finder
daredoes Jan 22, 2023
71896aa
support entering any found level
daredoes Jan 22, 2023
5ff48bc
support multiple quest modes
daredoes Jan 22, 2023
e28980d
mostly get quest level lookup working
daredoes Jan 22, 2023
cb07a98
find boss level
daredoes Jan 22, 2023
cf766c0
refactor
daredoes Jan 22, 2023
80a2113
update version
daredoes Jan 22, 2023
4326a99
modify screen select
daredoes Jan 25, 2023
544b2e7
start adding confirmation of level select
daredoes Jan 26, 2023
b94125b
use energy to confirm level choice
daredoes Jan 26, 2023
247ac60
revert unused changes
daredoes Jan 27, 2023
ed11841
remove unused files
daredoes Jan 27, 2023
1120f4f
auto bat file
daredoes Jan 27, 2023
fa15071
auto bat file
daredoes Jan 27, 2023
b37b794
minor lint changes
daredoes Jan 27, 2023
458f011
convert to long
daredoes Jan 27, 2023
7942019
increase description on settings app
daredoes Jan 27, 2023
701ef4b
update quest to prevent leave dungeon and image quality
daredoes Jan 29, 2023
cf8dc62
swap image name
daredoes Jan 29, 2023
ae26800
merge
daredoes Jan 29, 2023
385b575
bump version in pom file and reject version file
daredoes Jan 29, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
start adding confirmation of level select
  • Loading branch information
daredoes committed Jan 26, 2023
commit 544b2e762aac9e6a70d150dde70c0da174ae5822
120 changes: 64 additions & 56 deletions src/main/java/bh/bot/app/AbstractApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -1341,73 +1341,85 @@ protected boolean tryEnterQuest(boolean doQuest, UserConfig userConfig, Supplier
}
BwMatrixMeta.Metas.Dungeons.Labels.zones.setLastMatchPoint(coord.x, coord.y);
debug("Trying to detect a valid level");
boolean triedBossCoords = false;
boolean triedStarCoords = false;
boolean triedEmptyStarCoords = false;
boolean triedNextLevelCoords = false;
// First check for the Boss level
// Second check for any place with a star
// Third check for any place without a star
// Fourth check for any level
// Todo: Scan in a few areas
ArrayList<Point> levelCoords = null;
debug("Looking for boss level");
ArrayList<Point> bossCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.bossLevel, 63, 96, 96, 115);
boolean foundBossCoords = false;
boolean foundStarCoords = false;
boolean foundEmptyStarCoords = false;
boolean foundNextLevelCoords = false;
try {
foundBossCoords = bossCoords.get(0) == null;
} catch (IndexOutOfBoundsException e) {}
if (!foundBossCoords) {
debug("Looking for stars level");
ArrayList<Point> starCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.star, 63, 96, 36, 115);
try {
foundStarCoords = starCoords.get(0) == null;
} catch (IndexOutOfBoundsException e) {}
if (!foundStarCoords) {
debug("Looking for empty stars level");
ArrayList<Point> emptyStarCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.emptyStar, 63, 96, 36,
115);

ArrayList<Point> levelCoords = null;

while (!triedBossCoords && !triedStarCoords && !triedEmptyStarCoords && !triedNextLevelCoords) {
if (!triedBossCoords) {
debug("Looking for boss level");
ArrayList<Point> searchCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.bossLevel, 63, 96, 96, 115);
try {
foundEmptyStarCoords = emptyStarCoords.get(0) == null;
foundBossCoords = searchCoords.get(0) != null;
} catch (IndexOutOfBoundsException e) {}
if (!foundEmptyStarCoords) {
debug("Looking for next level");
ArrayList<Point> nextLevelCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.questLevel, 63,
96, 36, 115);
try {
foundNextLevelCoords = nextLevelCoords.get(0) == null;
} catch (IndexOutOfBoundsException e) {}
if (!foundNextLevelCoords) {
} else {
levelCoords = nextLevelCoords;
}
} else {
levelCoords = emptyStarCoords;
if (foundBossCoords) {
levelCoords = searchCoords;
triedBossCoords = true;
}
} else if (!triedStarCoords) {
debug("Looking for stars for a level");
ArrayList<Point> searchCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.star, 63, 96, 36, 115);
try {
foundStarCoords = searchCoords.get(0) != null;
} catch (IndexOutOfBoundsException e) {}
if (foundStarCoords) {
levelCoords = searchCoords;
triedStarCoords = true;
}
} else if (!triedEmptyStarCoords) {
debug("Looking for empty stars for a level");
ArrayList<Point> searchCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.emptyStar, 63, 96, 36, 115);
try {
foundEmptyStarCoords = searchCoords.get(0) != null;
} catch (IndexOutOfBoundsException e) {}
if (foundEmptyStarCoords) {
levelCoords = searchCoords;
triedEmptyStarCoords = true;
}
} else if (!triedNextLevelCoords) {
debug("Looking for next level");
ArrayList<Point> searchCoords = game.findByScanScreen(BwMatrixMeta.Metas.Dungeons.Buttons.questLevel, 63, 96, 36, 115);
try {
foundNextLevelCoords = searchCoords.get(0) != null;
} catch (IndexOutOfBoundsException e) {}
if (foundNextLevelCoords) {
levelCoords = searchCoords;
triedNextLevelCoords = true;
}
}
if (levelCoords == null) {
return false;
}
debug("Found some valid possible levels");
debug(levelCoords);
for (int i = 0; i < levelCoords.size(); i++) {
Point level = levelCoords.get(i);
debug("Trying to enter level " + level);
mouseMoveAndClickAndHide(level);
sleep(getDefaultMainLoopInterval());
// TODO: If (quest header of some sort clickable) breakLoop
if (clickImage(BwMatrixMeta.Metas.Dungeons.Dialogs.notEnoughEnergy)) {
break;
}
} else {
levelCoords = starCoords;
}
} else {
levelCoords = bossCoords;
}
if (levelCoords == null) {
return false;
}
debug("Found some valid possible levels");
debug(levelCoords);
for (int i = 0; i < levelCoords.size(); i++) {
Point level = levelCoords.get(i);
debug("Trying to enter level " + level);
mouseMoveAndClickAndHide(level);
sleep(2_000);
// TODO: If (quest header of some sort clickable) breakLoop
}
Point difficultyCoords = findImage(BwMatrixMeta.Metas.Dungeons.Labels.enterLevel);
if (difficultyCoords != null) {
debug("Clicking to enter level");
mouseMoveAndClickAndHide(difficultyCoords);

debug("Clicking to enter level");
if (clickImage(BwMatrixMeta.Metas.Dungeons.Labels.enterLevel)) {
return true;
}

BwMatrixMeta im = null;
if (UserConfig.isNormalMode(userConfig.questMode)) {
im = BwMatrixMeta.Metas.Dungeons.Buttons.difficultyNormal;
Expand All @@ -1418,13 +1430,9 @@ protected boolean tryEnterQuest(boolean doQuest, UserConfig userConfig, Supplier
} else {
throw new InvalidDataException("Unknown quest mode value: %d", userConfig.questMode);
}
Point difficultyModeCoords = findImage(im);
if (difficultyModeCoords != null) {
debug("Clicking to enter level");
mouseMoveAndClickAndHide(difficultyModeCoords);
if (clickImage(im)) {
return true;
}
debug("Failed to enter level");
return false;
}

Expand Down
1 change: 1 addition & 0 deletions src/main/java/bh/bot/common/types/images/BwMatrixMeta.java
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ public static class Buttons {

public static class Dialogs {
public static BwMatrixMeta notEnoughEnergy;
public static BwMatrixMeta level;
}

public static class Labels {
Expand Down