Compare commits

...

6 Commits

Author SHA1 Message Date
ab50d739c1 Add CSmelter script 2021-10-28 00:01:08 +02:00
1aa793b4bf Optimize Seers agility course 2021-10-28 00:00:55 +02:00
7f44187e6b Optimize imports 2021-10-28 00:00:31 +02:00
4f764a4eb9 Add support for non-stackable items 2021-10-28 00:00:11 +02:00
75ab1e7fe8 Optimize imports 2021-10-27 23:59:50 +02:00
b26c38cbcc Enable keyboard input on start 2021-10-27 23:58:24 +02:00
26 changed files with 469 additions and 25 deletions

9
.idea/artifacts/CSmelter_jar.xml generated Normal file
View File

@ -0,0 +1,9 @@
<component name="ArtifactManager">
<artifact type="jar" name="CSmelter:jar">
<output-path>$USER_HOME$/DreamBot/Scripts</output-path>
<root id="archive" name="CSmelter.jar">
<element id="module-output" name="CSmelter" />
<element id="module-output" name="Util" />
</root>
</artifact>
</component>

2
.idea/misc.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project version="4"> <project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="11" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" /> <output url="file://$PROJECT_DIR$/out" />
</component> </component>
</project> </project>

1
.idea/modules.xml generated
View File

@ -10,6 +10,7 @@
<module fileurl="file://$PROJECT_DIR$/CMiner/CMiner.iml" filepath="$PROJECT_DIR$/CMiner/CMiner.iml" /> <module fileurl="file://$PROJECT_DIR$/CMiner/CMiner.iml" filepath="$PROJECT_DIR$/CMiner/CMiner.iml" />
<module fileurl="file://$PROJECT_DIR$/CPlanker/CPlanker.iml" filepath="$PROJECT_DIR$/CPlanker/CPlanker.iml" /> <module fileurl="file://$PROJECT_DIR$/CPlanker/CPlanker.iml" filepath="$PROJECT_DIR$/CPlanker/CPlanker.iml" />
<module fileurl="file://$PROJECT_DIR$/CShopper/CShopper.iml" filepath="$PROJECT_DIR$/CShopper/CShopper.iml" /> <module fileurl="file://$PROJECT_DIR$/CShopper/CShopper.iml" filepath="$PROJECT_DIR$/CShopper/CShopper.iml" />
<module fileurl="file://$PROJECT_DIR$/CSmelter/CSmelter.iml" filepath="$PROJECT_DIR$/CSmelter/CSmelter.iml" />
<module fileurl="file://$PROJECT_DIR$/CThiever/CThiever.iml" filepath="$PROJECT_DIR$/CThiever/CThiever.iml" /> <module fileurl="file://$PROJECT_DIR$/CThiever/CThiever.iml" filepath="$PROJECT_DIR$/CThiever/CThiever.iml" />
<module fileurl="file://$PROJECT_DIR$/CWintertodt/CWintertodt.iml" filepath="$PROJECT_DIR$/CWintertodt/CWintertodt.iml" /> <module fileurl="file://$PROJECT_DIR$/CWintertodt/CWintertodt.iml" filepath="$PROJECT_DIR$/CWintertodt/CWintertodt.iml" />
<module fileurl="file://$PROJECT_DIR$/DreambotScripts.iml" filepath="$PROJECT_DIR$/DreambotScripts.iml" /> <module fileurl="file://$PROJECT_DIR$/DreambotScripts.iml" filepath="$PROJECT_DIR$/DreambotScripts.iml" />

View File

@ -44,5 +44,9 @@ public class CAgility extends CTaskScript {
int marks = PickupMark.marksPickedUp; int marks = PickupMark.marksPickedUp;
getUI().drawString("Marks picked up: " + marks + " (" + getUI().getHourlyRate(marks) + " per hour)"); getUI().drawString("Marks picked up: " + marks + " (" + getUI().getHourlyRate(marks) + " per hour)");
if (HandleObstacle.current != null && HandleObstacle.current.getGameObject() != null && HandleObstacle.current.getGameObject().getModel() != null) {
HandleObstacle.current.getGameObject().getModel().drawWireFrame(g);
}
} }
} }

View File

@ -4,6 +4,9 @@ import io.reisub.dreambot.cagility.Obstacle;
import io.reisub.dreambot.util.Constants; import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.Util; import io.reisub.dreambot.util.Util;
import org.dreambot.api.input.Mouse; import org.dreambot.api.input.Mouse;
import org.dreambot.api.input.event.impl.InteractionEvent;
import org.dreambot.api.input.event.impl.InteractionSetting;
import org.dreambot.api.input.mouse.destination.impl.EntityDestination;
import org.dreambot.api.input.mouse.destination.impl.MiniMapTileDestination; import org.dreambot.api.input.mouse.destination.impl.MiniMapTileDestination;
import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext; import org.dreambot.api.methods.MethodContext;
@ -84,7 +87,8 @@ public class HandleObstacle extends TaskNode {
new Tile(2721, 3489, 3), new Tile(2721, 3489, 3),
new Tile(2730, 3489, 3), new Tile(2730, 3489, 3),
new Tile(2730, 3497, 3), new Tile(2730, 3497, 3),
new Tile(2721, 3497, 3))), new Tile(2721, 3497, 3)),
() -> Players.localPlayer().getTile().equals(new Tile(2729, 3491, 3))),
new Obstacle(14932, new Area( new Obstacle(14932, new Area(
new Tile(2715, 3487, 2), new Tile(2715, 3487, 2),
new Tile(2715, 3498, 2), new Tile(2715, 3498, 2),
@ -145,7 +149,7 @@ public class HandleObstacle extends TaskNode {
private final Course course; private final Course course;
private final Map<Integer, Rectangle> hoverMap; private final Map<Integer, Rectangle> hoverMap;
private Obstacle current; public static Obstacle current;
private int retries = 0; private int retries = 0;
public HandleObstacle(Course course) { public HandleObstacle(Course course) {
@ -196,6 +200,7 @@ public class HandleObstacle extends TaskNode {
} }
Tile finalTarget = target; Tile finalTarget = target;
if (!MethodProvider.sleepUntil(() -> Players.localPlayer().isMoving(), Calculations.random(1200, 1500))) continue;
MethodContext.sleepUntil(() -> finalTarget.distance(Players.localPlayer()) < Calculations.random(4, 7), Calculations.random(14000, 15000)); MethodContext.sleepUntil(() -> finalTarget.distance(Players.localPlayer()) < Calculations.random(4, 7), Calculations.random(14000, 15000));
} }
} }
@ -221,6 +226,10 @@ public class HandleObstacle extends TaskNode {
Mouse.move(hoverRect); Mouse.move(hoverRect);
} }
if (!Util.sleepUntilMoving(Calculations.random(1200, 1500))) {
return Calculations.random(180, 350);
}
if (isWalking) { if (isWalking) {
Util.sleepUntilMovingAndAnimating(Calculations.random(12000, 13000)); Util.sleepUntilMovingAndAnimating(Calculations.random(12000, 13000));
} else { } else {
@ -232,7 +241,10 @@ public class HandleObstacle extends TaskNode {
public void interact(GameObject currentObject, boolean shouldHop) { public void interact(GameObject currentObject, boolean shouldHop) {
Mouse.setAlwaysHop(shouldHop); Mouse.setAlwaysHop(shouldHop);
currentObject.interactForceLeft(currentObject.getActions()[0]); EntityDestination ed = new EntityDestination(currentObject);
InteractionEvent ie = new InteractionEvent(ed);
ie.interact(currentObject.getActions()[0], InteractionSetting.EMPTY_SETTING, InteractionSetting.FORCE_LEFT_CLICK);
//currentObject.interactForceLeft(currentObject.getActions()[0]);
Mouse.setAlwaysHop(false); Mouse.setAlwaysHop(false);
Tile dest = null; Tile dest = null;
@ -244,8 +256,10 @@ public class HandleObstacle extends TaskNode {
dest = Walking.getDestination(); dest = Walking.getDestination();
} }
if (dest == null) return;
if (!currentObject.getObjectTiles().contains(dest) && !currentObject.getInteractableFrom().contains(dest)) { if (!currentObject.getObjectTiles().contains(dest) && !currentObject.getInteractableFrom().contains(dest)) {
MethodProvider.log("Misclick, trying again"); MethodProvider.log("Misclick, trying again ");
interact(currentObject, true); interact(currentObject, true);
} }
} }

View File

@ -4,7 +4,6 @@ import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.Util; import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.map.Tile;

View File

@ -1,11 +1,8 @@
package io.reisub.dreambot.cplanker.tasks; package io.reisub.dreambot.cplanker.tasks;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.Util; import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.Calculations; 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.Inventory;
import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.map.Tile;

View File

@ -8,7 +8,6 @@ import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.container.impl.bank.Bank; import org.dreambot.api.methods.container.impl.bank.Bank;
import org.dreambot.api.methods.filter.Filter; import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.methods.interactive.GameObjects; import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.methods.interactive.Players; import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.methods.walking.impl.Walking; import org.dreambot.api.methods.walking.impl.Walking;

View File

@ -3,7 +3,6 @@ package io.reisub.dreambot.cplanker.tasks;
import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodProvider; import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.methods.container.impl.Inventory; import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.methods.item.GroundItems; import org.dreambot.api.methods.item.GroundItems;
import org.dreambot.api.script.TaskNode; import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.items.GroundItem; import org.dreambot.api.wrappers.items.GroundItem;

View File

@ -1,9 +1,6 @@
package io.reisub.dreambot.cshopper; package io.reisub.dreambot.cshopper;
import io.reisub.dreambot.cshopper.tasks.Buy; import io.reisub.dreambot.cshopper.tasks.*;
import io.reisub.dreambot.cshopper.tasks.Hop;
import io.reisub.dreambot.cshopper.tasks.Open;
import io.reisub.dreambot.cshopper.tasks.Stop;
import io.reisub.dreambot.util.CTaskScript; import io.reisub.dreambot.util.CTaskScript;
import io.reisub.dreambot.util.Constants; import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.tasks.Run; import io.reisub.dreambot.util.tasks.Run;
@ -18,9 +15,14 @@ import java.awt.*;
@ScriptManifest(category = Category.MISC, name = "CShopper", description = "Shops like a woman with an unlimited Visa card", author = Constants.AUTHOR, version = 1.0) @ScriptManifest(category = Category.MISC, name = "CShopper", description = "Shops like a woman with an unlimited Visa card", author = Constants.AUTHOR, version = 1.0)
public class CShopper extends CTaskScript { public class CShopper extends CTaskScript {
private static final Configuration configuration = new Configuration( private static final Configuration configuration = new Configuration(
Constants.LUNDAIL, "Ordan",
new ItemWrapper(Constants.COSMIC_RUNE, -1), new ItemWrapper("Gold ore", 2600, 73, false)
new ItemWrapper(Constants.NATURE_RUNE, 6000) //new ItemWrapper("Hammerstone seed", -1),
//new ItemWrapper("Asgarnian seed", -1),
//new ItemWrapper("Jute seed", -1),
//new ItemWrapper("Yanillian seed", -1),
//new ItemWrapper("Krandorian seed", -1),
//new ItemWrapper("Barley seed", 2000)
); );
private Buy buyTask; private Buy buyTask;
@ -36,6 +38,7 @@ public class CShopper extends CTaskScript {
buyTask = new Buy(); buyTask = new Buy();
addNodes( addNodes(
new Deposit(),
new Stop(), new Stop(),
new Run(), new Run(),
new Open(), new Open(),

View File

@ -3,15 +3,25 @@ package io.reisub.dreambot.cshopper;
public class ItemWrapper { public class ItemWrapper {
private final String name; private final String name;
private final int buyTotal, minimumInShop; private final int buyTotal, minimumInShop;
private final boolean stackable;
public ItemWrapper(String name, int buyTotal, int minimumInShop) { public ItemWrapper(String name, int buyTotal, int minimumInShop, boolean stackable) {
this.name = name; this.name = name;
this.buyTotal = buyTotal; this.buyTotal = buyTotal;
this.minimumInShop = minimumInShop; this.minimumInShop = minimumInShop;
this.stackable = stackable;
}
public ItemWrapper(String name, int buyTotal, boolean stackable) {
this(name, buyTotal, 0, stackable);
}
public ItemWrapper(String name, int buyTotal, int minimumInShop) {
this(name, buyTotal, minimumInShop, false);
} }
public ItemWrapper(String name, int buyTotal) { public ItemWrapper(String name, int buyTotal) {
this(name, buyTotal, 0); this(name, buyTotal, 0, false);
} }
public String getName() { public String getName() {
@ -25,4 +35,8 @@ public class ItemWrapper {
public int getMinimumInShop() { public int getMinimumInShop() {
return minimumInShop; return minimumInShop;
} }
public boolean isStackable() {
return stackable;
}
} }

View File

@ -21,7 +21,7 @@ public class Buy extends TaskNode {
@Override @Override
public boolean accept() { public boolean accept() {
if (!Shop.isOpen()) return false; if (!Shop.isOpen() || Inventory.isFull() || Hop.shouldHop) return false;
for (ItemWrapper iw : CShopper.getConfiguration().getItems()) { for (ItemWrapper iw : CShopper.getConfiguration().getItems()) {
int shopCount = Shop.get(iw.getName()).getAmount(); int shopCount = Shop.get(iw.getName()).getAmount();
@ -54,7 +54,7 @@ public class Buy extends TaskNode {
int toBuy = buyTotal - inventoryCount; int toBuy = buyTotal - inventoryCount;
int canBuy = iw.getMinimumInShop() == 0 ? 50 : shopCount - iw.getMinimumInShop(); int canBuy = iw.getMinimumInShop() == 0 ? 50 : shopCount - iw.getMinimumInShop();
if (toBuy >= 50 && canBuy >= 50) { if ((toBuy >= 50 && canBuy >= 50) || (toBuy >= 27 && canBuy >= 27 && !iw.isStackable())) {
shopItem.interact("Buy 50"); shopItem.interact("Buy 50");
} else if (toBuy >= 10 && canBuy >= 10) { } else if (toBuy >= 10 && canBuy >= 10) {
shopItem.interact("Buy 10"); shopItem.interact("Buy 10");

View File

@ -0,0 +1,45 @@
package io.reisub.dreambot.cshopper.tasks;
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.Shop;
import org.dreambot.api.methods.container.impl.bank.Bank;
import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
public class Deposit extends TaskNode {
@Override
public boolean accept() {
return Inventory.isFull();
}
@Override
public int execute() {
GameObject bank = GameObjects.closest("Bank chest");
if (bank == null) return Calculations.random(250, 400);
if (Shop.isOpen()) {
Shop.close();
MethodProvider.sleepUntil(() -> !Shop.isOpen(), Calculations.random(2000, 2500));
}
bank.interact();
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
if (!MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(5000, 5500))) return Calculations.random(250, 400);
MethodProvider.sleep(300, 500);
Bank.depositAllExcept("Coins");
MethodProvider.sleepUntil(() -> Inventory.onlyContains("Coins"), Calculations.random(5000, 5500));
Bank.close();
MethodProvider.sleepUntil(() -> !Bank.isOpen(), Calculations.random(2000, 2500));
Hop.shouldHop = true;
return Calculations.random(250, 400);
}
}

View File

@ -20,6 +20,7 @@ import java.util.List;
import java.util.Queue; import java.util.Queue;
public class Hop extends TaskNode { public class Hop extends TaskNode {
public static boolean shouldHop;
private final Queue<World> worlds; private final Queue<World> worlds;
public Hop(boolean members) { public Hop(boolean members) {
@ -42,6 +43,8 @@ public class Hop extends TaskNode {
@Override @Override
public boolean accept() { public boolean accept() {
if (Hop.shouldHop) return true;
if (!Shop.isOpen()) return false; if (!Shop.isOpen()) return false;
for (ItemWrapper iw : CShopper.getConfiguration().getItems()) { for (ItemWrapper iw : CShopper.getConfiguration().getItems()) {
@ -60,6 +63,7 @@ public class Hop extends TaskNode {
@Override @Override
public int execute() { public int execute() {
shouldHop = false;
Shop.close(); Shop.close();
MethodProvider.sleepUntil(() -> !Shop.isOpen(), Calculations.random(2000, 2500)); MethodProvider.sleepUntil(() -> !Shop.isOpen(), Calculations.random(2000, 2500));

View File

@ -4,6 +4,7 @@ import io.reisub.dreambot.cshopper.CShopper;
import io.reisub.dreambot.util.Constants; import io.reisub.dreambot.util.Constants;
import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext; import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.container.impl.Shop; import org.dreambot.api.methods.container.impl.Shop;
import org.dreambot.api.methods.interactive.NPCs; import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.script.TaskNode; import org.dreambot.api.script.TaskNode;
@ -12,7 +13,9 @@ import org.dreambot.api.wrappers.interactive.NPC;
public class Open extends TaskNode { public class Open extends TaskNode {
@Override @Override
public boolean accept() { public boolean accept() {
return !Shop.isOpen(); return !Shop.isOpen()
&& !Inventory.isFull()
&& !Hop.shouldHop;
} }
@Override @Override

13
CSmelter/CSmelter.iml Normal file
View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" name="client" level="project" />
<orderEntry type="module" module-name="Util" />
</component>
</module>

View File

@ -0,0 +1,45 @@
package io.reisub.dreambot.csmelter;
import io.reisub.dreambot.csmelter.tasks.DoBank;
import io.reisub.dreambot.csmelter.tasks.OpenBank;
import io.reisub.dreambot.csmelter.tasks.SetCamera;
import io.reisub.dreambot.csmelter.tasks.Smelt;
import io.reisub.dreambot.util.CTaskScript;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.randomevents.GenieSolver;
import io.reisub.dreambot.util.tasks.Run;
import io.reisub.dreambot.util.tasks.kitten.KittenTask;
import org.dreambot.api.methods.skills.Skill;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.script.TaskNode;
@ScriptManifest(category = Category.SMITHING, name = "CSmelter", author = Constants.AUTHOR, version = 1.0)
public class CSmelter extends CTaskScript {
public static SmeltingOption smeltingOption = SmeltingOption.GOLD_BRACELET;
@Override
public void onStart() {
super.onStart();
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
if (smeltingOption.getMould().equals("")) {
getUI().addSkills(Skill.SMITHING);
} else {
getUI().addSkills(Skill.CRAFTING);
}
TaskNode kittenTask = KittenTask.getInstance();
if (kittenTask != null) {
addNodes(kittenTask);
}
addNodes(
new SetCamera(),
new Run(),
new Smelt(),
new OpenBank(),
new DoBank()
);
}
}

View File

@ -0,0 +1,23 @@
package io.reisub.dreambot.csmelter;
public class Ingredient {
private final String name;
private final int amount;
public Ingredient(String name, int amount) {
this.name = name;
this.amount = amount;
}
public Ingredient(String name) {
this(name, 1);
}
public String getName() {
return name;
}
public int getAmount() {
return amount;
}
}

View File

@ -0,0 +1,71 @@
package io.reisub.dreambot.csmelter;
public enum SmeltingOption {
GOLD_BAR(new Ingredient("Gold ore"), "Gold bar", 6),
GOLD_BRACELET(new Ingredient("Gold bar"), "Gold bracelet", 46, "Bracelet mould");
private final Ingredient[] ingredients;
private final String endProduct, mould;
private final int hotkey, maxCraftsPerInventory;
SmeltingOption(Ingredient[] ingredients, String endProduct, int hotkey, String mould) {
this.ingredients = ingredients;
this.endProduct = endProduct;
this.hotkey = hotkey;
this.mould = mould;
int totalIngredientsRequired = 0;
for (Ingredient i : ingredients) {
totalIngredientsRequired += i.getAmount();
}
if (mould.equals("")) {
maxCraftsPerInventory = Math.floorDiv(28, totalIngredientsRequired);
} else {
maxCraftsPerInventory = Math.floorDiv(27, totalIngredientsRequired);
}
}
SmeltingOption(Ingredient[] ingredients, String endProduct, int hotkey) {
this(ingredients, endProduct, hotkey, "");
}
SmeltingOption(Ingredient ingredient, String endProduct, int hotkey, String mould) {
this(new Ingredient[]{ingredient}, endProduct, hotkey, mould);
}
SmeltingOption(Ingredient ingredient, String endProduct, int hotkey) {
this(new Ingredient[]{ingredient}, endProduct, hotkey, "");
}
public Ingredient[] getIngredients() {
return ingredients;
}
public String[] getIngredientsNames() {
String[] ingredientNames = new String[ingredients.length];
for (int i = 0; i < ingredients.length; i++) {
ingredientNames[i] = ingredients[i].getName();
}
return ingredientNames;
}
public int getMaxCraftsPerInventory() {
return maxCraftsPerInventory;
}
public String getEndProduct() {
return endProduct;
}
public int getHotkey() {
return hotkey;
}
public String getMould() {
return mould;
}
}

View File

@ -0,0 +1,53 @@
package io.reisub.dreambot.csmelter.tasks;
import io.reisub.dreambot.csmelter.CSmelter;
import io.reisub.dreambot.csmelter.Ingredient;
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.script.TaskNode;
public class DoBank extends TaskNode {
@Override
public boolean accept() {
return Bank.isOpen();
}
@Override
public int execute() {
if (Inventory.contains(CSmelter.smeltingOption.getEndProduct())) {
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);
}
String mould = CSmelter.smeltingOption.getMould();
if (!mould.equals("")) {
if (!Inventory.contains(mould)) {
Bank.withdraw(mould, 1);
if (!MethodProvider.sleepUntil(() -> Inventory.contains(mould), Calculations.random(2000, 2500))) {
return Calculations.random(250, 400);
}
}
}
String[] names = CSmelter.smeltingOption.getIngredientsNames();
if (CSmelter.smeltingOption.getIngredients().length == 1) {
Bank.withdrawAll(CSmelter.smeltingOption.getIngredients()[0].getName());
} else {
int craftsPerInventory = CSmelter.smeltingOption.getMaxCraftsPerInventory();
for (Ingredient i : CSmelter.smeltingOption.getIngredients()) {
if (Inventory.count(i.getName()) < i.getAmount() * craftsPerInventory) {
Bank.withdraw(i.getName(), i.getAmount() * craftsPerInventory);
}
MethodProvider.sleep(200, 400);
}
}
MethodProvider.sleepUntil(() -> Inventory.containsAll(names), Calculations.random(2000, 2500));
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,42 @@
package io.reisub.dreambot.csmelter.tasks;
import io.reisub.dreambot.csmelter.CSmelter;
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.interactive.GameObjects;
import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
public class OpenBank extends TaskNode {
@Override
public boolean accept() {
return !Bank.isOpen()
&& !Inventory.containsAll(CSmelter.smeltingOption.getIngredientsNames())
&& Util.playerIsIdle();
}
@Override
public int execute() {
GameObject bank = GameObjects.closest("Bank booth");
if (bank == null) return Calculations.random(250, 400);
if (!bank.isOnScreen()) {
while (bank.distance() > Calculations.random(6, 9)) {
if (Walking.shouldWalk(Calculations.random(4, 6))) {
Walking.walk(bank);
}
}
}
bank.interactForceLeft("Bank");
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(10000, 11000));
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,19 @@
package io.reisub.dreambot.csmelter.tasks;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.input.Camera;
import org.dreambot.api.script.TaskNode;
public class SetCamera extends TaskNode {
@Override
public boolean accept() {
return Camera.getPitch() <= 380;
}
@Override
public int execute() {
Camera.mouseRotateTo(Calculations.random(60, 302), 383);
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,71 @@
package io.reisub.dreambot.csmelter.tasks;
import io.reisub.dreambot.csmelter.CSmelter;
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.input.Keyboard;
import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.methods.widget.Widgets;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.widgets.WidgetChild;
public class Smelt extends TaskNode {
private boolean firstTime = true;
@Override
public boolean accept() {
return Inventory.containsAll(CSmelter.smeltingOption.getIngredientsNames())
&& Util.playerIsIdle(1000);
}
@Override
public int execute() {
GameObject furnace = GameObjects.closest("Furnace");
if (furnace == null) return Calculations.random(250, 400);
if (Bank.isOpen()) {
Walking.walk(furnace);
MethodProvider.sleep(300, 600);
}
furnace.interact();
if (!furnace.getInteractableFrom().contains(Players.localPlayer().getTile())) {
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
}
MethodProvider.sleepWhile(() -> furnace.distance() > Calculations.random(2, 4), Calculations.random(10000, 11000));
if (CSmelter.smeltingOption.getMould().equals("")) {
if (!firstTime) Keyboard.holdSpace(() -> {
WidgetChild w = Widgets.getChildWidget(270, 13);
return (w != null && w.isVisible()) || Players.localPlayer().isAnimating();
}, Calculations.random(4000, 4500));
if (!MethodProvider.sleepUntil(() -> {
WidgetChild w = Widgets.getChildWidget(270, 13);
return w != null && w.isVisible();
}, Calculations.random(5000, 5500))) return Calculations.random(250, 400);
Keyboard.type(CSmelter.smeltingOption.getHotkey(), false, false);
if (Util.sleepUntilAnimating()) firstTime = false;
} else {
if (!MethodProvider.sleepUntil(() -> {
WidgetChild w = Widgets.getChildWidget(446, CSmelter.smeltingOption.getHotkey());
return w != null && w.isVisible();
}, Calculations.random(3000, 3500))) return Calculations.random(250, 400);
WidgetChild w = Widgets.getChildWidget(446, CSmelter.smeltingOption.getHotkey());
w.interact();
Util.sleepUntilAnimating();
}
return Calculations.random(250, 400);
}
}

View File

@ -2,13 +2,11 @@ package io.reisub.dreambot.cthiever.tasks;
import io.reisub.dreambot.util.Util; import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.methods.interactive.NPCs; import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.methods.interactive.Players; import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.script.ScriptManager; import org.dreambot.api.script.ScriptManager;
import org.dreambot.api.script.TaskNode; import org.dreambot.api.script.TaskNode;
import org.dreambot.api.script.listener.ChatListener; import org.dreambot.api.script.listener.ChatListener;
import org.dreambot.api.wrappers.interactive.Character;
import org.dreambot.api.wrappers.interactive.NPC; import org.dreambot.api.wrappers.interactive.NPC;
import org.dreambot.api.wrappers.widgets.message.Message; import org.dreambot.api.wrappers.widgets.message.Message;

View File

@ -1,7 +1,9 @@
package io.reisub.dreambot.util; package io.reisub.dreambot.util;
import io.reisub.dreambot.util.ui.UI; import io.reisub.dreambot.util.ui.UI;
import org.dreambot.api.Client;
import org.dreambot.api.methods.MethodContext; import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.AbstractScript;
import java.awt.*; import java.awt.*;
@ -25,6 +27,12 @@ public abstract class CAbstractScript extends AbstractScript implements MouseLis
ui.draw(g); ui.draw(g);
} }
@Override
public void onStart() {
MethodProvider.sleep(1000);
Client.getInstance().setKeyboardInputEnabled(true);
}
@Override @Override
public void onPause() { public void onPause() {
ui.pause(); ui.pause();
@ -32,6 +40,7 @@ public abstract class CAbstractScript extends AbstractScript implements MouseLis
@Override @Override
public void onResume() { public void onResume() {
Client.getInstance().setKeyboardInputEnabled(true);
ui.resume(); ui.resume();
} }

View File

@ -1,7 +1,9 @@
package io.reisub.dreambot.util; package io.reisub.dreambot.util;
import io.reisub.dreambot.util.ui.UI; import io.reisub.dreambot.util.ui.UI;
import org.dreambot.api.Client;
import org.dreambot.api.methods.MethodContext; import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.script.impl.TaskScript; import org.dreambot.api.script.impl.TaskScript;
import java.awt.*; import java.awt.*;
@ -25,6 +27,12 @@ public abstract class CTaskScript extends TaskScript implements MouseListener {
ui.draw(g); ui.draw(g);
} }
@Override
public void onStart() {
MethodProvider.sleep(1000);
Client.getInstance().setKeyboardInputEnabled(true);
}
@Override @Override
public void onPause() { public void onPause() {
ui.pause(); ui.pause();
@ -32,6 +40,7 @@ public abstract class CTaskScript extends TaskScript implements MouseListener {
@Override @Override
public void onResume() { public void onResume() {
Client.getInstance().setKeyboardInputEnabled(true);
ui.resume(); ui.resume();
} }