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
attempt to add quest app basics
  • Loading branch information
daredoes committed Jan 20, 2023
commit 3a04c1a204076e90e4852557a63dda0dabf484a0
51 changes: 51 additions & 0 deletions src/main/java/bh/bot/app/AbstractApplication.java
Original file line number Diff line number Diff line change
Expand Up @@ -1315,6 +1315,57 @@ protected boolean tryEnterWorldBoss(boolean doWorldBoss, UserConfig userConfig,
return clickImage(BwMatrixMeta.Metas.WorldBoss.Buttons.summonOnListingWorldBosses);
}

protected boolean tryEnterQuest(boolean doQuest, UserConfig userConfig, Supplier<Boolean> isBlocked) {
// TODO: Add Label Image(s) to confirm quest window is open (ZONES)
Point coord = findImage(BwMatrixMeta.Metas.Dungeons.Labels.zones);
if (coord == null)
return false;

if (isBlocked.get() || !doQuest) {
spamEscape(1);
return false;
}
// mouseMoveAndClickAndHide(coord);
BwMatrixMeta.Metas.Dungeons.Labels.enterLevel.setLastMatchPoint(coord.x, coord.y);
Point starCoords = findImage(BwMatrixMeta.Metas.Dungeons.Labels.zones);
if (starCoords == null)
return false;
sleep(500);
// TODO: Find if difficulty is an option to use, otherwise enter
Point difficultyCoords = findImage(BwMatrixMeta.Metas.Dungeons.Labels.enterLevel);
if (difficultyCoords != null) {
mouseMoveAndClickAndHide(difficultyCoords);
}
if (UserConfig.isNormalMode(userConfig.questMode)) {
mouseMoveAndClickAndHide(
fromRelativeToAbsoluteBasedOnPreviousResult(
BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord,
Configuration.screenResolutionProfile.getOffsetButtonEnterNormalRaid()
)
);
} else if (UserConfig.isHardMode(userConfig.questMode)) {
mouseMoveAndClickAndHide(
fromRelativeToAbsoluteBasedOnPreviousResult(
BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord,
Configuration.screenResolutionProfile.getOffsetButtonEnterHardRaid()
)
);
} else if (UserConfig.isHeroicMode(userConfig.questMode)) {
mouseMoveAndClickAndHide(
fromRelativeToAbsoluteBasedOnPreviousResult(
BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog,
coord,
Configuration.screenResolutionProfile.getOffsetButtonEnterHeroicRaid()
)
);
} else {
throw new InvalidDataException("Unknown quest mode value: %d", userConfig.questMode);
}
return true;
}

protected boolean tryEnterRaid(boolean doRaid, UserConfig userConfig, Supplier<Boolean> isBlocked) {
Point coord = findImage(BwMatrixMeta.Metas.Raid.Labels.labelInSummonDialog);
if (coord == null)
Expand Down
37 changes: 35 additions & 2 deletions src/main/java/bh/bot/app/AfkApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ public class AfkApp extends AbstractApplication {
private final AtomicLong blockPvpUntil = new AtomicLong(0);
private final AtomicLong blockWorldBossUntil = new AtomicLong(0);
private final AtomicLong blockRaidUntil = new AtomicLong(0);
private final AtomicLong blockQuestUntil = new AtomicLong(0);
private final AtomicLong blockGvgAndInvasionAndExpeditionUntil = new AtomicLong(0);
private final AtomicLong blockTrialsAndGauntletUntil = new AtomicLong(0);
private final AtomicBoolean isOnPvp = new AtomicBoolean(false);
Expand All @@ -63,10 +64,11 @@ protected void internalRun(String[] args) {
eventList = getAttendablePlaces(getEventListFromArg(args));

boolean doRaid = eventList.contains(AttendablePlaces.raid);
boolean doQuest = eventList.contains(AttendablePlaces.quest);
boolean doWorldBoss = eventList.contains(AttendablePlaces.worldBoss);
boolean doExpedition = eventList.contains(AttendablePlaces.expedition);
boolean doPVP = eventList.contains(AttendablePlaces.pvp);
if (doRaid || doWorldBoss || doExpedition || doPVP) {
if (doRaid || doWorldBoss || doExpedition || doPVP || doQuest) {
userConfig = getPredefinedUserConfigFromProfileName("You want to do Raid/World Boss (Solo)/Expedition/PVP so you have to specific profile name first!\nSelect an existing profile:");

try {
Expand All @@ -75,6 +77,10 @@ protected void internalRun(String[] args) {
userConfig.getRaidLevelDesc());
}

if (doQuest) {
info(ColorizeUtil.formatInfo, "You have selected %s mode", userConfig.getQuestModeDesc());
}

if (doWorldBoss) {
info(ColorizeUtil.formatInfo, "You have selected world boss %s", userConfig.getWorldBossLevelDesc());
warn("World Boss is solo only and does not support select mode of World Boss (Normal/Hard/Heroic), only select by default So which boss do you want to hit? Choose it before turn this on");
Expand Down Expand Up @@ -110,6 +116,7 @@ protected void internalRun(String[] args) {
waitDone( //
() -> doLoop( //
masterSwitch, finalUserConfig, //
eventList.contains(AttendablePlaces.quest), //
eventList.contains(AttendablePlaces.pvp), //
eventList.contains(AttendablePlaces.worldBoss), //
eventList.contains(AttendablePlaces.raid), //
Expand Down Expand Up @@ -142,6 +149,7 @@ private void doLoop(//
boolean doPvp, //
boolean doWorldBoss, //
boolean doRaid, //
boolean doQuest, //
boolean doGvg, //
boolean doInvasion, //
boolean doExpedition, //
Expand Down Expand Up @@ -197,6 +205,9 @@ private void doLoop(//
if (doRaid)
taskList.add(new Tuple3<>(AttendablePlaces.raid, blockRaidUntil, RaidApp.getPredefinedImageActions()));

if (doQuest)
taskList.add(new Tuple3<>(AttendablePlaces.quest, blockQuestUntil, QuestApp.getPredefinedImageActions()));

for (Tuple3<AttendablePlace, AtomicLong, List<AbstractDoFarmingApp.NextAction>> tp : taskList) {
for (AbstractDoFarmingApp.NextAction na : tp._3) {
if (na.image == null)
Expand All @@ -206,6 +217,7 @@ private void doLoop(//
}

ArrayList<AbstractDoFarmingApp.NextAction> outOfTurnNextActionList = new ArrayList<>();
addOutOfTurnActionsToList(outOfTurnNextActionList, QuestApp.getPredefinedImageActions());
addOutOfTurnActionsToList(outOfTurnNextActionList, PvpApp.getPredefinedImageActions());
addOutOfTurnActionsToList(outOfTurnNextActionList, WorldBossApp.getPredefinedImageActions());
addOutOfTurnActionsToList(outOfTurnNextActionList, RaidApp.getPredefinedImageActions());
Expand All @@ -226,11 +238,14 @@ private void doLoop(//

final Supplier<Boolean> isWorldBossBlocked = () -> !isNotBlocked(blockWorldBossUntil);
final Supplier<Boolean> isRaidBlocked = () -> !isNotBlocked(blockRaidUntil);
final Supplier<Boolean> isQuestBlocked = () -> !isNotBlocked(blockQuestUntil);

Main.warningSupport();

if (doRaid)
info(ColorizeUtil.formatInfo, "Raid: %s of %s", userConfig.getRaidModeDesc(), userConfig.getRaidLevelDesc());
if (doQuest)
info(ColorizeUtil.formatInfo, "Quest: %s", userConfig.getQuestModeDesc());
if (doWorldBoss)
info(ColorizeUtil.formatInfo, "World Boss: %s", userConfig.getWorldBossLevelDesc());
if (doExpedition)
Expand Down Expand Up @@ -325,6 +340,13 @@ private void doLoop(//
continue ML;
}

if (tryEnterQuest(doQuest, userConfig, isQuestBlocked)) {
debug("tryEnterQuest");
continuousNotFound = 0;
moveCursor(coordinateHideMouse);
continue ML;
}

if (tryEnterWorldBoss(doWorldBoss, userConfig, isWorldBossBlocked)) {
debug("tryEnterWorldBoss");
continuousNotFound = 0;
Expand Down Expand Up @@ -461,6 +483,8 @@ else if (attendablePlace == AttendablePlaces.worldBoss)
x = blockWorldBossUntil;
else if (attendablePlace == AttendablePlaces.raid)
x = blockRaidUntil;
else if (attendablePlace == AttendablePlaces.quest)
x = blockQuestUntil;
else if (attendablePlace == AttendablePlaces.gvg || attendablePlace == AttendablePlaces.invasion
|| attendablePlace == AttendablePlaces.expedition)
x = blockGvgAndInvasionAndExpeditionUntil;
Expand All @@ -480,6 +504,7 @@ private ArrayList<AttendablePlace> getAttendablePlaces(AfkBatch afkBatch) {
AttendablePlaces.gvg, //
AttendablePlaces.gauntlet, //

AttendablePlaces.quest, //
AttendablePlaces.pvp, //
AttendablePlaces.worldBoss, //
AttendablePlaces.raid //
Expand All @@ -502,12 +527,15 @@ private ArrayList<AttendablePlace> getAttendablePlaces(AfkBatch afkBatch) {
eventList.add(AttendablePlaces.worldBoss);
if (argumentInfo.eRaid || afkBatch.doRaid)
eventList.add(AttendablePlaces.raid);
if (argumentInfo.eQuest || afkBatch.doQuest)
eventList.add(AttendablePlaces.quest);
//
if (eventList.size() == 0) {
final List<MenuItem> menuItems = Stream.of(
MenuItem.from(AttendablePlaces.pvp),
MenuItem.from(AttendablePlaces.worldBoss),
MenuItem.from(AttendablePlaces.raid),
MenuItem.from(AttendablePlaces.quest),
MenuItem.from("GVG/Expedition/Invasion", AttendablePlaces.gvg, AttendablePlaces.expedition, AttendablePlaces.invasion),
MenuItem.from("Trials/Gauntlet", AttendablePlaces.trials, AttendablePlaces.gauntlet),
MenuItem.from(AttendablePlaces.pvp, AttendablePlaces.worldBoss, AttendablePlaces.raid),
Expand Down Expand Up @@ -590,6 +618,7 @@ protected String getLimitationExplain() {
private static final char codeWorldBoss1 = 'B';
private static final char codeWorldBoss2 = 'W';
private static final char codeRaid = 'R';
private static final char codeQuest = 'Q';
private static final char codeInvasion = 'I';
private static final char codeExpedition = 'E';
private static final char codeGVG = 'V';
Expand All @@ -600,12 +629,13 @@ protected String getLimitationExplain() {
private static final char codeComboTrialsGauntlet = '3';
private static final char codeComboAll = 'A';

private static final String shortDescArg = String.format("%s (PVP), %s (World Boss), %s (Raid), %s (Invasion), %s (Expedition), %s (GVG), %s (Gauntlet), %s (Trials), %s (PVP/World Boss/Raid), %s (Invasion/GVG/Expedition), %s (Trials/Gauntlet), %s (All)", codePvp, codeWorldBoss1, codeRaid, codeInvasion, codeExpedition, codeGVG, codeGauntlet, codeTrials, codeComboPvpWorldBossRaid, codeComboInvasionGvgExpedition, codeComboTrialsGauntlet, codeComboAll);
private static final String shortDescArg = String.format("%s (PVP), %s (World Boss), %s (Raid), %s (Quest), %s (Invasion), %s (Expedition), %s (GVG), %s (Gauntlet), %s (Trials), %s (PVP/World Boss/Raid), %s (Invasion/GVG/Expedition), %s (Trials/Gauntlet), %s (All)", codePvp, codeWorldBoss1, codeRaid, codeQuest, codeInvasion, codeExpedition, codeGVG, codeGauntlet, codeTrials, codeComboPvpWorldBossRaid, codeComboInvasionGvgExpedition, codeComboTrialsGauntlet, codeComboAll);

private static class AfkBatch {
public boolean doPvp;
public boolean doWorldBoss;
public boolean doRaid;
public boolean doQuest;
public boolean doInvasion;
public boolean doExpedition;
public boolean doGvg;
Expand All @@ -622,6 +652,7 @@ private static AfkBatch getEventListFromArg(String[] args) {
result.doPvp = true;
result.doWorldBoss = true;
result.doRaid = true;
result.doQuest = true;
result.doInvasion = true;
result.doExpedition = true;
result.doGvg = true;
Expand All @@ -644,6 +675,8 @@ private static AfkBatch getEventListFromArg(String[] args) {
result.doWorldBoss = true;
} else if (c == codeRaid) {
result.doRaid = true;
} else if (c == codeQuest) {
result.doQuest = true;
} else if (c == codeInvasion) {
result.doInvasion = true;
} else if (c == codeGVG) {
Expand Down
12 changes: 7 additions & 5 deletions src/main/java/bh/bot/app/farming/QuestApp.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,16 @@
import java.io.IOException;
import java.util.Arrays;
import java.util.List;
import java.util.function.Supplier;

import static bh.bot.common.Log.err;
import static bh.bot.common.Log.info;

@AppMeta(code = "quest", name = "Quest", displayOrder = 1)
@RequireSingleInstance
public class QuestApp extends AbstractDoFarmingApp {
private final Supplier<Boolean> isQuestBlocked = () -> false;

@Override
protected boolean readMoreInput() throws IOException {
return true;
Expand All @@ -35,11 +38,10 @@ protected List<NextAction> getInternalPredefinedImageActions() {
return QuestApp.getPredefinedImageActions();
}

// @Override
// protected boolean doCustomAction() {
// return true;
// // return tryEnterWorldBoss(true, userConfig, isWorldBossBlocked);
// }
@Override
protected boolean doCustomAction() {
return tryEnterQuest(true, userConfig, isQuestBlocked);
}

public static List<NextAction> getPredefinedImageActions() {
return Arrays.asList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class ParseArgumentsResult {
public boolean ePvp;
public boolean eWorldBoss;
public boolean eRaid;
public boolean eQuest;
public ScreenResolutionProfile screenResolutionProfile;
public String cfgProfileName;
public ArrayList<Familiar> familiarToBribeWithGems;
Expand Down
21 changes: 21 additions & 0 deletions src/main/java/bh/bot/common/types/ScreenResolutionProfile.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ public abstract class ScreenResolutionProfile {

public abstract Offset getOffsetButtonDungeonReRun();

public abstract Offset getOffsetButtonDungeonStar();

public abstract Offset getOffsetButtonTalkRightArrow();

public abstract Offset getOffsetButtonReconnect();
Expand Down Expand Up @@ -157,6 +159,10 @@ public abstract class ScreenResolutionProfile {
public abstract Offset getOffsetDialogNotEnoughInvasionBadges();

public abstract Offset getOffsetDialogNotEnoughDungeonEnergy();

public abstract Offset getOffsetLabelDungeonEnterLevel();

public abstract Offset getOffsetLabelDungeonZones();

public abstract Offset getOffsetButtonPlayTrials();

Expand Down Expand Up @@ -260,6 +266,11 @@ public Offset getOffsetButtonDungeonReRun() {
return new Offset(309, 468);
}

@Override
public Offset getOffsetButtonDungeonStar() {
return new Offset(400, 260);
}

@Override
public Offset getOffsetButtonTalkRightArrow() {
return new Offset(718, 287);
Expand Down Expand Up @@ -460,6 +471,16 @@ public Offset getOffsetDialogNotEnoughDungeonEnergy() {
return new Offset(279, 231);
}

@Override
public Offset getOffsetLabelDungeonEnterLevel() {
return new Offset(415, 433);
}

@Override
public Offset getOffsetLabelDungeonZones() {
return new Offset(104, 62);
}

@Override
public Offset getOffsetButtonPlayTrials() {
return new Offset(517, 271);
Expand Down
9 changes: 8 additions & 1 deletion src/main/java/bh/bot/common/types/UserConfig.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
public class UserConfig {
public static final String raidLevelKey = "ig.user.raid.level";
public static final String raidModeKey = "ig.user.raid.mode";
public static final String questModeKey = "ig.user.quest.mode";
public static final String worldBossLevelKey = "ig.user.world-boss.level";
public static final String expeditionPlaceKey = "ig.user.expedition.place";
public static final String pvpTargetKey = "ig.user.pvp.target";
Expand All @@ -26,16 +27,18 @@ public class UserConfig {
public final String cfgProfileName;
public final byte raidLevel;
public final byte raidMode;
public final byte questMode;
public final byte worldBossLevel;
public final byte expeditionPlace;
public final byte pvpTarget;

public UserConfig(String cfgProfileName, byte raidLevel, byte raidMode, byte worldBossLevel, byte expeditionPlace, byte pvpTarget) {
public UserConfig(String cfgProfileName, byte raidLevel, byte raidMode, byte worldBossLevel, byte expeditionPlace, byte pvpTarget, byte questMode) {
this.cfgProfileName = cfgProfileName;
this.raidLevel = raidLevel;
this.raidMode = raidMode;
this.worldBossLevel = worldBossLevel;
this.expeditionPlace = expeditionPlace;
this.questMode = questMode;
this.pvpTarget = (byte)Math.max(pvpTargetMin, pvpTarget);
}

Expand Down Expand Up @@ -72,6 +75,10 @@ public String getRaidModeDesc() {
return getDifficultyModeDesc(raidMode, "Raid");
}

public String getQuestModeDesc() {
return getDifficultyModeDesc(questMode, "Quest");
}

public boolean isValidRaidLevel() {
return raidLevel >= raidLevelMin && raidLevel <= raidLevelMax;
}
Expand Down
Loading