Add CAshMiner, CPlanker and CThiever scripts

This commit is contained in:
2021-10-27 10:18:20 +02:00
parent 06333b3364
commit 1122205220
20 changed files with 541 additions and 0 deletions

13
CPlanker/CPlanker.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,39 @@
package io.reisub.dreambot.cplanker;
import io.reisub.dreambot.cplanker.tasks.*;
import io.reisub.dreambot.util.CTaskScript;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.randomevents.GenieSolver;
import org.dreambot.api.methods.skills.Skill;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import java.awt.*;
@ScriptManifest(category = Category.MISC, name = "CPlanker", description = "Chops oaks at sawmill, planks and banks at CW.", author = Constants.AUTHOR, version = 1.0)
public class CPlanker extends CTaskScript {
@Override
public void onStart() {
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
getUI().addSkills(Skill.WOODCUTTING);
getUI().setCustomLines(1);
addNodes(
new Chop(),
new BuyPlanks(),
new Teleport(),
new OpenBank(),
new Deposit(),
new GoToSawmill()
);
}
@Override
public void onPaint(Graphics g) {
super.onPaint(g);
int planks = BuyPlanks.planksMade;
getUI().drawString("Planks made: " + planks + " (" + getUI().getHourlyRate(planks) + " per hour)");
}
}

View File

@ -0,0 +1,58 @@
package io.reisub.dreambot.cplanker.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.input.Keyboard;
import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.methods.widget.Widgets;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.NPC;
import org.dreambot.api.wrappers.widgets.WidgetChild;
public class BuyPlanks extends TaskNode {
private boolean madePlanks;
public static int planksMade = 0;
@Override
public boolean accept() {
return Inventory.isFull()
&& Inventory.contains("Oak logs");
}
@Override
public int execute() {
NPC operator = NPCs.closest("Sawmill operator");
if (operator == null) return Calculations.random(250, 400);
operator.interact("Buy-plank");
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
MethodProvider.sleepUntil(() -> operator.distance() < Calculations.random(4, 7), Calculations.random(3000, 3500));
if (madePlanks) {
Keyboard.holdSpace(() -> {
WidgetChild w = Widgets.getChildWidget(270, 15);
return w != null && w.isVisible();
}, Calculations.random(3000, 3500));
} else {
MethodProvider.sleepUntil(() -> {
WidgetChild w = Widgets.getChildWidget(270, 15);
return w != null && w.isVisible();
}, Calculations.random(5000, 5500));
WidgetChild w = Widgets.getChildWidget(270, 15);
if (w != null && w.isVisible()) {
Keyboard.type("2", false);
}
}
if (MethodProvider.sleepUntil(() -> Inventory.contains("Oak plank"), Calculations.random(5000, 5500))) {
madePlanks = true;
planksMade += Inventory.count("Oak plank");
}
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,44 @@
package io.reisub.dreambot.cplanker.tasks;
import io.reisub.dreambot.util.Constants;
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.filter.Filter;
import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.map.Area;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
public class Chop extends TaskNode {
private final Area AREA = new Area(
new Tile(3288, 3498, 0),
new Tile(3288, 3486, 0),
new Tile(3295, 3481, 0),
new Tile(3298, 3492, 0),
new Tile(3293, 3499, 0));
@Override
public boolean accept() {
return !Inventory.isFull()
&& findTree() != null
&& Util.playerIsIdle();
}
@Override
public int execute() {
GameObject tree = findTree();
if (tree == null) return Calculations.random(250, 400);
tree.interact("Chop down");
Util.sleepUntilMovingAndAnimating();
return Calculations.random(250, 400);
}
private GameObject findTree() {
return GameObjects.closest(gameObject -> AREA.contains(gameObject) && gameObject.getName().equals("Oak"));
}
}

View File

@ -0,0 +1,39 @@
package io.reisub.dreambot.cplanker.tasks;
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.container.impl.equipment.Equipment;
import org.dreambot.api.methods.container.impl.equipment.EquipmentSlot;
import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.items.Item;
public class Deposit extends TaskNode {
@Override
public boolean accept() {
return Bank.isOpen()
&& Inventory.isFull();
}
@Override
public int execute() {
Bank.depositAllExcept("Coins");
MethodProvider.sleepUntil(() -> Inventory.onlyContains("Coins"), Calculations.random(2000, 3000));
if (Equipment.getItemInSlot(EquipmentSlot.RING) == null) {
Filter<Item> ringFilter = item -> item.getName().startsWith("Ring of dueling");
while (!Inventory.contains(ringFilter)) {
Bank.withdraw(ringFilter, 1);
MethodProvider.sleepUntil(() -> Inventory.contains(ringFilter), Calculations.random(3000, 3500));
}
}
Bank.close();
MethodProvider.sleepUntil(() -> !Bank.isOpen(), Calculations.random(2000, 3000));
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,67 @@
package io.reisub.dreambot.cplanker.tasks;
import io.reisub.dreambot.util.Constants;
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.filter.Filter;
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.map.Tile;
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.items.Item;
import org.dreambot.api.wrappers.widgets.WidgetChild;
public class GoToSawmill extends TaskNode {
private final Tile NEAR_BALLOON = new Tile(2457, 3106, 0);
@Override
public boolean accept() {
return Inventory.onlyContains(item -> item.getName().equals("Coins") || item.getName().startsWith("Ring of dueling"))
&& NEAR_BALLOON.distance() < 50;
}
@Override
public int execute() {
GameObject basket = GameObjects.closest("Basket");
if (basket == null || basket.distance() > Calculations.random(6, 9)) {
if (Walking.shouldWalk(Calculations.random(4, 6))) {
Walking.walk(NEAR_BALLOON);
}
Filter<Item> ringFilter = item -> item.getName().startsWith("Ring of dueling");
if (Inventory.contains(ringFilter)) {
Item ring = Inventory.get(ringFilter);
ring.interact();
MethodProvider.sleepUntil(() -> !Inventory.contains(ringFilter), Calculations.random(2000, 3000));
}
Util.sleepUntilMoving();
} else {
basket.interactForceLeft(Constants.USE);
if (Util.sleepUntilMoving()) {
MethodProvider.sleepWhile(() -> Players.localPlayer().isMoving(), Calculations.random(4000, 4500));
} else {
return Calculations.random(250, 400);
}
MethodProvider.sleepUntil(() -> {
WidgetChild w = Widgets.getChildWidget(469, 18);
return w != null && w.isVisible();
}, Calculations.random(4000, 4500));
}
WidgetChild w = Widgets.getChildWidget(469, 18);
if (w != null && w.isVisible()) {
w.interact();
MethodProvider.sleepUntil(() -> NEAR_BALLOON.distance() > 50, Calculations.random(5000, 5500));
}
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,28 @@
package io.reisub.dreambot.cplanker.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.bank.Bank;
import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.script.TaskNode;
public class OpenBank extends TaskNode {
@Override
public boolean accept() {
return Inventory.contains("Oak plank")
&& !Bank.isOpen()
&& NPCs.closest("Sawmill operator") == null;
}
@Override
public int execute() {
Bank.openClosest();
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(4000, 4500));
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,25 @@
package io.reisub.dreambot.cplanker.tasks;
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.equipment.Equipment;
import org.dreambot.api.methods.container.impl.equipment.EquipmentSlot;
import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.script.TaskNode;
public class Teleport extends TaskNode {
@Override
public boolean accept() {
return Inventory.contains("Oak plank")
&& NPCs.closest("Sawmill operator") != null;
}
@Override
public int execute() {
Equipment.interact(EquipmentSlot.RING, "Castle Wars");
MethodProvider.sleepUntil(() -> NPCs.closest("Sawmill operator") == null, Calculations.random(2000, 3000));
return Calculations.random(250, 400);
}
}