From 25844dad617110c8ac9dbb780c1e72e966254184 Mon Sep 17 00:00:00 2001 From: Yuri Moens Date: Thu, 28 Oct 2021 09:33:53 +0200 Subject: [PATCH] Add hover functionality --- .../reisub/dreambot/csmelter/tasks/DoBank.java | 18 ++++++++++++++++++ .../dreambot/csmelter/tasks/OpenBank.java | 3 +++ .../reisub/dreambot/csmelter/tasks/Smelt.java | 7 ++++++- 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/CSmelter/src/io/reisub/dreambot/csmelter/tasks/DoBank.java b/CSmelter/src/io/reisub/dreambot/csmelter/tasks/DoBank.java index 48ac2e4..aeed37c 100644 --- a/CSmelter/src/io/reisub/dreambot/csmelter/tasks/DoBank.java +++ b/CSmelter/src/io/reisub/dreambot/csmelter/tasks/DoBank.java @@ -2,11 +2,15 @@ package io.reisub.dreambot.csmelter.tasks; import io.reisub.dreambot.csmelter.CSmelter; import io.reisub.dreambot.csmelter.Ingredient; +import io.reisub.dreambot.util.Util; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.MethodProvider; import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.container.impl.bank.Bank; +import org.dreambot.api.methods.widget.Widgets; import org.dreambot.api.script.TaskNode; +import org.dreambot.api.wrappers.items.Item; +import org.dreambot.api.wrappers.widgets.WidgetChild; public class DoBank extends TaskNode { @Override @@ -17,6 +21,18 @@ public class DoBank extends TaskNode { @Override public int execute() { if (Inventory.contains(CSmelter.smeltingOption.getEndProduct())) { + if (Util.getHoverEntry("deposit") == null) { + if (Inventory.contains(item -> item.getName().endsWith("mould"))) { + Item item = Inventory.get(CSmelter.smeltingOption.getEndProduct()); + Util.addHoverEntry("deposit", item.getDestination().getBoundingBox()); + } else { + WidgetChild depositAll = Widgets.getChildWidget(12, 42); + if (depositAll != null && depositAll.isVisible()) { + Util.addHoverEntry("deposit", depositAll.getRectangle()); + } + } + } + Bank.depositAllExcept(item -> item.getName().endsWith("mould")); if (!MethodProvider.sleepUntil(() -> Inventory.isEmpty() || Inventory.onlyContains(item -> item.getName().endsWith("mould")), Calculations.random(2000, 2500))) return Calculations.random(250, 400); } @@ -46,6 +62,8 @@ public class DoBank extends TaskNode { } } + Util.hover("minimapToFurnace"); + MethodProvider.sleepUntil(() -> Inventory.containsAll(names), Calculations.random(2000, 2500)); return Calculations.random(250, 400); diff --git a/CSmelter/src/io/reisub/dreambot/csmelter/tasks/OpenBank.java b/CSmelter/src/io/reisub/dreambot/csmelter/tasks/OpenBank.java index 90b7185..4fb32df 100644 --- a/CSmelter/src/io/reisub/dreambot/csmelter/tasks/OpenBank.java +++ b/CSmelter/src/io/reisub/dreambot/csmelter/tasks/OpenBank.java @@ -32,9 +32,12 @@ public class OpenBank extends TaskNode { } } + Util.addHoverEntry("bank", bank); + bank.interactForceLeft("Bank"); if (!Util.sleepUntilMoving()) return Calculations.random(250, 400); + Util.hover("deposit"); MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(10000, 11000)); return Calculations.random(250, 400); diff --git a/CSmelter/src/io/reisub/dreambot/csmelter/tasks/Smelt.java b/CSmelter/src/io/reisub/dreambot/csmelter/tasks/Smelt.java index 7985e9b..e98d802 100644 --- a/CSmelter/src/io/reisub/dreambot/csmelter/tasks/Smelt.java +++ b/CSmelter/src/io/reisub/dreambot/csmelter/tasks/Smelt.java @@ -21,7 +21,7 @@ public class Smelt extends TaskNode { @Override public boolean accept() { return Inventory.containsAll(CSmelter.smeltingOption.getIngredientsNames()) - && Util.playerIsIdle(1000); + && Util.playerIsIdle(1400); } @Override @@ -30,6 +30,7 @@ public class Smelt extends TaskNode { if (furnace == null) return Calculations.random(250, 400); if (Bank.isOpen()) { + Util.addHoverEntry("minimapToFurnace", furnace.getTile(), true); Walking.walk(furnace); MethodProvider.sleep(300, 600); } @@ -39,6 +40,7 @@ public class Smelt extends TaskNode { if (!Util.sleepUntilMoving()) return Calculations.random(250, 400); } + Util.hover("smeltWidget"); MethodProvider.sleepWhile(() -> furnace.distance() > Calculations.random(2, 4), Calculations.random(10000, 11000)); if (CSmelter.smeltingOption.getMould().equals("")) { @@ -61,11 +63,14 @@ public class Smelt extends TaskNode { }, Calculations.random(3000, 3500))) return Calculations.random(250, 400); WidgetChild w = Widgets.getChildWidget(446, CSmelter.smeltingOption.getHotkey()); + Util.addHoverEntry("smeltWidget", w.getRectangle()); w.interact(); Util.sleepUntilAnimating(); } + Util.hover("bank"); + return Calculations.random(250, 400); } }