Add walking and finetune CMiner
This commit is contained in:
parent
6d525c618a
commit
415e6bf211
@ -1,11 +1,12 @@
|
||||
package io.reisub.dreambot.cminer;
|
||||
|
||||
import io.reisub.dreambot.cminer.tasks.Mine;
|
||||
import io.reisub.dreambot.cminer.tasks.Superheat;
|
||||
import io.reisub.dreambot.cminer.tasks.*;
|
||||
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;
|
||||
@ -14,6 +15,11 @@ import org.dreambot.api.script.TaskNode;
|
||||
public class CMiner extends CTaskScript {
|
||||
@Override
|
||||
public void onStart() {
|
||||
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
|
||||
|
||||
getUI().addSkills(Skill.MINING);
|
||||
getUI().addSkills(Skill.MAGIC);
|
||||
|
||||
TaskNode kittenTask = KittenTask.getInstance();
|
||||
if (kittenTask != null) {
|
||||
addNodes(kittenTask);
|
||||
@ -22,7 +28,12 @@ public class CMiner extends CTaskScript {
|
||||
addNodes(
|
||||
new Run(),
|
||||
new Superheat(),
|
||||
new Mine()
|
||||
new Mine(true),
|
||||
new GoToBank(),
|
||||
new OpenBank(),
|
||||
new DoBank(),
|
||||
new Teleport(),
|
||||
new GoToSpot()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
31
CMiner/src/io/reisub/dreambot/cminer/tasks/DoBank.java
Normal file
31
CMiner/src/io/reisub/dreambot/cminer/tasks/DoBank.java
Normal file
@ -0,0 +1,31 @@
|
||||
package io.reisub.dreambot.cminer.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
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() && Inventory.isFull();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
Bank.depositAll(Constants.IRON_BAR);
|
||||
MethodProvider.sleep(0, 400);
|
||||
Bank.depositAll(Constants.UNCUT_GEMS_FILTER);
|
||||
|
||||
if (!MethodProvider.sleepUntil(() -> !Inventory.contains(Constants.UNCUT_GEMS_FILTER) && !Inventory.contains(Constants.IRON_BAR), Calculations.random(1200, 1500))) {
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
|
||||
Bank.close();
|
||||
MethodProvider.sleepUntil(() -> !Bank.isOpen(), Calculations.random(1800, 2100));
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
31
CMiner/src/io/reisub/dreambot/cminer/tasks/GoToBank.java
Normal file
31
CMiner/src/io/reisub/dreambot/cminer/tasks/GoToBank.java
Normal file
@ -0,0 +1,31 @@
|
||||
package io.reisub.dreambot.cminer.tasks;
|
||||
|
||||
import org.dreambot.api.methods.Calculations;
|
||||
import org.dreambot.api.methods.container.impl.Inventory;
|
||||
import org.dreambot.api.methods.interactive.Players;
|
||||
import org.dreambot.api.methods.map.Area;
|
||||
import org.dreambot.api.methods.map.Tile;
|
||||
import org.dreambot.api.methods.walking.impl.Walking;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public class GoToBank extends TaskNode {
|
||||
public static final Area BANK_AREA = new Area(
|
||||
new Tile(2651, 3287, 0),
|
||||
new Tile(2651, 3280, 0),
|
||||
new Tile(2656, 3280, 0),
|
||||
new Tile(2656, 3287, 0));
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return Inventory.isFull() && !BANK_AREA.contains(Players.localPlayer());
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
if (Walking.shouldWalk(Calculations.random(5, 8))) {
|
||||
Walking.walk(BANK_AREA);
|
||||
}
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
51
CMiner/src/io/reisub/dreambot/cminer/tasks/GoToSpot.java
Normal file
51
CMiner/src/io/reisub/dreambot/cminer/tasks/GoToSpot.java
Normal file
@ -0,0 +1,51 @@
|
||||
package io.reisub.dreambot.cminer.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.interactive.Players;
|
||||
import org.dreambot.api.methods.map.Tile;
|
||||
import org.dreambot.api.methods.walking.impl.Walking;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public class GoToSpot extends TaskNode {
|
||||
private final Tile[] SPOTS = new Tile[]{
|
||||
new Tile(2602, 3235, 0),
|
||||
new Tile(2605, 3234, 0)
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
Tile playerTile = Players.localPlayer().getTile();
|
||||
double closestDist = Double.MAX_VALUE;
|
||||
|
||||
for (Tile t : SPOTS) {
|
||||
if (t.equals(playerTile)) return false;
|
||||
|
||||
closestDist = Math.min(t.distance(), closestDist);
|
||||
}
|
||||
|
||||
return !Inventory.isFull() && closestDist < 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
Tile target = SPOTS[Calculations.random(SPOTS.length)];
|
||||
|
||||
while (target.distance() > 8) {
|
||||
if (Walking.shouldWalk(Calculations.random(3, 5))) {
|
||||
Walking.walk(target);
|
||||
}
|
||||
|
||||
MethodProvider.sleep(300, 500);
|
||||
}
|
||||
|
||||
MethodProvider.sleepUntil(() -> !Players.localPlayer().isMoving(), Calculations.random(4000, 5000));
|
||||
|
||||
Walking.walkExact(target);
|
||||
MethodProvider.sleepUntil(() -> Players.localPlayer().getTile().equals(target), Calculations.random(4000, 5000));
|
||||
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
@ -18,15 +18,28 @@ import org.dreambot.api.wrappers.widgets.WidgetChild;
|
||||
import java.util.List;
|
||||
|
||||
public class Mine extends TaskNode {
|
||||
private final boolean superheat;
|
||||
private boolean depleted = false;
|
||||
|
||||
public Mine(boolean superheat) {
|
||||
this.superheat = superheat;
|
||||
}
|
||||
|
||||
public Mine() {
|
||||
this(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return !Inventory.isFull() &&
|
||||
(Util.playerIsIdle() || Players.localPlayer().getAnimation() == Constants.SUPERHEAT) &&
|
||||
(Util.playerIsIdle() || Players.localPlayer().getAnimation() == Constants.SUPERHEAT || depleted) &&
|
||||
!getRocks(Constants.IRON_ROCKS_COLOR).isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
depleted = false;
|
||||
|
||||
List<GameObject> rocks = getRocks(Constants.IRON_ROCKS_COLOR);
|
||||
if (rocks.isEmpty()) return Calculations.random(250, 400);
|
||||
|
||||
@ -35,19 +48,28 @@ public class Mine extends TaskNode {
|
||||
final GameObject rock = rocks.get(0);
|
||||
rock.interactForceLeft(Constants.MINE);
|
||||
|
||||
if (Tabs.isOpen(Tab.MAGIC)) {
|
||||
hoverSuperheat();
|
||||
if (!MethodProvider.sleepUntil(() -> Players.localPlayer().isAnimating(), Calculations.random(1500, 2000))) {
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
|
||||
if (superheat) {
|
||||
selectSuperheat();
|
||||
}
|
||||
|
||||
MethodProvider.sleepUntil(() -> {
|
||||
short[] colors = GameObjects.getTopObjectOnTile(rock.getTile()).getModelColors();
|
||||
return colors == null || colors.length == 0 || count < Inventory.count(Constants.IRON_ORE);
|
||||
if (colors == null || colors.length == 0) {
|
||||
depleted = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
return count < Inventory.count(Constants.IRON_ORE);
|
||||
}, Calculations.random(10000, 11000));
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
|
||||
private List<GameObject> getRocks(int colorID) {
|
||||
public static List<GameObject> getRocks(int colorID) {
|
||||
return GameObjects.all(gameObject -> {
|
||||
if (gameObject.getModelColors() == null || gameObject.getModelColors().length == 0) return false;
|
||||
|
||||
@ -57,10 +79,17 @@ public class Mine extends TaskNode {
|
||||
});
|
||||
}
|
||||
|
||||
private void hoverSuperheat() {
|
||||
private void selectSuperheat() {
|
||||
if (!Tabs.isOpen(Tab.MAGIC)) {
|
||||
Tabs.open(Tab.MAGIC);
|
||||
}
|
||||
|
||||
WidgetChild superheat = Widgets.getChildWidget(218, 30);
|
||||
if (superheat != null) {
|
||||
Mouse.move(superheat.getRectangle());
|
||||
}
|
||||
if (superheat == null) return;
|
||||
|
||||
superheat.interact();
|
||||
MethodProvider.sleepUntil(() -> Tabs.isOpen(Tab.INVENTORY), Calculations.random(1200, 1500));
|
||||
|
||||
Mouse.move(Inventory.slotBounds(Inventory.getFirstEmptySlot()));
|
||||
}
|
||||
}
|
||||
|
26
CMiner/src/io/reisub/dreambot/cminer/tasks/OpenBank.java
Normal file
26
CMiner/src/io/reisub/dreambot/cminer/tasks/OpenBank.java
Normal file
@ -0,0 +1,26 @@
|
||||
package io.reisub.dreambot.cminer.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
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.Players;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
|
||||
public class OpenBank extends TaskNode {
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return !Bank.isOpen() &&
|
||||
Bank.getClosestBankLocation().distance(Players.localPlayer().getTile()) < Calculations.random(6, 10) &&
|
||||
(Inventory.contains(Constants.IRON_BAR) || Inventory.contains(Constants.UNCUT_GEMS_FILTER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
Bank.open();
|
||||
MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(10000, 12000));
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
@ -2,16 +2,24 @@ package io.reisub.dreambot.cminer.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
import io.reisub.dreambot.util.Util;
|
||||
import org.dreambot.api.input.Mouse;
|
||||
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.Players;
|
||||
import org.dreambot.api.methods.magic.Magic;
|
||||
import org.dreambot.api.methods.magic.Normal;
|
||||
import org.dreambot.api.methods.map.Area;
|
||||
import org.dreambot.api.methods.tabs.Tab;
|
||||
import org.dreambot.api.methods.tabs.Tabs;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.interactive.GameObject;
|
||||
import org.dreambot.api.wrappers.items.Item;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class Superheat extends TaskNode {
|
||||
@Override
|
||||
public boolean accept() {
|
||||
@ -27,13 +35,35 @@ public class Superheat extends TaskNode {
|
||||
|
||||
if (ore == null) return Calculations.random(250, 400);
|
||||
|
||||
if (!Magic.isSpellSelected() || !Magic.getSelectedSpellName().contains("Superheat")) {
|
||||
Magic.castSpell(Normal.SUPERHEAT_ITEM);
|
||||
MethodProvider.sleepUntil(() -> Tabs.isOpen(Tab.INVENTORY), Calculations.random(1200, 1500));
|
||||
} else {
|
||||
MethodProvider.sleep(50, 150);
|
||||
}
|
||||
|
||||
ore.interact();
|
||||
Util.sleepUntilAnimating();
|
||||
MethodProvider.sleepUntil(() -> Inventory.count(Constants.IRON_ORE) < count || Util.playerIsIdle() || Tabs.isOpen(Tab.MAGIC), Calculations.random(1200, 1500));
|
||||
|
||||
if (!Inventory.isFull()) {
|
||||
hoverRock();
|
||||
}
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
|
||||
private void hoverRock() {
|
||||
if (!Mine.getRocks(Constants.IRON_ROCKS_COLOR).isEmpty()) return;
|
||||
|
||||
List<GameObject> rocks = GameObjects.all(gameObject -> gameObject.getName().equals(Constants.ROCKS) &&
|
||||
gameObject.getInteractableFrom().contains(Players.localPlayer().getTile()));
|
||||
|
||||
for (GameObject rock : rocks) {
|
||||
if (!Util.isLookingAt(rock)) {
|
||||
Mouse.move(rock);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
61
CMiner/src/io/reisub/dreambot/cminer/tasks/Teleport.java
Normal file
61
CMiner/src/io/reisub/dreambot/cminer/tasks/Teleport.java
Normal file
@ -0,0 +1,61 @@
|
||||
package io.reisub.dreambot.cminer.tasks;
|
||||
|
||||
import io.reisub.dreambot.util.Constants;
|
||||
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.interactive.Players;
|
||||
import org.dreambot.api.methods.map.Area;
|
||||
import org.dreambot.api.methods.map.Tile;
|
||||
import org.dreambot.api.methods.tabs.Tab;
|
||||
import org.dreambot.api.methods.tabs.Tabs;
|
||||
import org.dreambot.api.script.TaskNode;
|
||||
import org.dreambot.api.wrappers.items.Item;
|
||||
|
||||
public class Teleport extends TaskNode {
|
||||
private final Area TELEPORT_AREA = new Area(
|
||||
new Tile(2599, 3216, 0),
|
||||
new Tile(2613, 3216, 0),
|
||||
new Tile(2613, 3227, 0),
|
||||
new Tile(2599, 3227, 0));
|
||||
|
||||
@Override
|
||||
public boolean accept() {
|
||||
return GoToBank.BANK_AREA.contains(Players.localPlayer()) &&
|
||||
!Inventory.isFull() &&
|
||||
(Inventory.contains(Constants.ARDOUGNE_CLOAK_FILTER) || Equipment.contains(Constants.ARDOUGNE_CLOAK_FILTER));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int execute() {
|
||||
if (Bank.isOpen()) {
|
||||
Bank.close();
|
||||
if (!MethodProvider.sleepUntil(() -> !Bank.isOpen(), Calculations.random(1800, 2100))) {
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
||||
|
||||
Item cloak;
|
||||
|
||||
if (Inventory.contains(Constants.ARDOUGNE_CLOAK_FILTER)) {
|
||||
cloak = Inventory.get(Constants.ARDOUGNE_CLOAK_FILTER);
|
||||
if (!Tabs.isOpen(Tab.INVENTORY)) {
|
||||
Tabs.open(Tab.INVENTORY);
|
||||
}
|
||||
} else {
|
||||
cloak = Equipment.get(Constants.ARDOUGNE_CLOAK_FILTER);
|
||||
if (!Tabs.isOpen(Tab.EQUIPMENT)) {
|
||||
Tabs.open(Tab.EQUIPMENT);
|
||||
}
|
||||
}
|
||||
|
||||
if (cloak != null) {
|
||||
cloak.interact(Constants.MONASTERY_TELEPORT);
|
||||
MethodProvider.sleepUntil(() -> TELEPORT_AREA.contains(Players.localPlayer()), Calculations.random(4000, 5000));
|
||||
}
|
||||
|
||||
return Calculations.random(250, 400);
|
||||
}
|
||||
}
|
@ -1,5 +1,8 @@
|
||||
package io.reisub.dreambot.util;
|
||||
|
||||
import org.dreambot.api.methods.filter.Filter;
|
||||
import org.dreambot.api.wrappers.items.Item;
|
||||
|
||||
public class Constants {
|
||||
public static final String AUTHOR = "ChaosEnergy";
|
||||
|
||||
@ -56,6 +59,9 @@ public class Constants {
|
||||
public static final String ROCKS = "Rocks";
|
||||
public static final int IRON_ROCKS_COLOR = 2576;
|
||||
public static final String IRON_ORE = "Iron ore";
|
||||
public static final String IRON_BAR = "Iron bar";
|
||||
public static final Filter<Item> UNCUT_GEMS_FILTER = item -> item.getName().startsWith("Uncut");
|
||||
public static final Filter<Item> ARDOUGNE_CLOAK_FILTER = item -> item.getName().startsWith("Ardougne cloak");
|
||||
|
||||
// Actions
|
||||
public static final String USE = "Use";
|
||||
@ -71,6 +77,7 @@ public class Constants {
|
||||
public static final String FIX = "Fix";
|
||||
public static final String TRADE = "Trade";
|
||||
public static final String MINE = "Mine";
|
||||
public static final String MONASTERY_TELEPORT = "Monastery Teleport";
|
||||
|
||||
// Messages
|
||||
public static final String KITTEN_WANTS_ATTENTION_MSG = "Your kitten wants attention.";
|
||||
|
Loading…
x
Reference in New Issue
Block a user