Add CMiner

This commit is contained in:
2021-10-20 16:34:54 +02:00
parent 9de32663fb
commit 9dea119a7d
7 changed files with 164 additions and 0 deletions

13
CMiner/CMiner.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,28 @@
package io.reisub.dreambot.cminer;
import io.reisub.dreambot.cminer.tasks.Mine;
import io.reisub.dreambot.cminer.tasks.Superheat;
import io.reisub.dreambot.util.CTaskScript;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.tasks.Run;
import io.reisub.dreambot.util.tasks.kitten.KittenTask;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.script.TaskNode;
@ScriptManifest(category = Category.MINIGAME, name = "CMiner", description = "Diggy diggy hole", author = Constants.AUTHOR, version = 1.0)
public class CMiner extends CTaskScript {
@Override
public void onStart() {
TaskNode kittenTask = KittenTask.getInstance();
if (kittenTask != null) {
addNodes(kittenTask);
}
addNodes(
new Run(),
new Superheat(),
new Mine()
);
}
}

View File

@ -0,0 +1,66 @@
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.interactive.GameObjects;
import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.methods.tabs.Tab;
import org.dreambot.api.methods.tabs.Tabs;
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;
import java.util.List;
public class Mine extends TaskNode {
@Override
public boolean accept() {
return !Inventory.isFull() &&
(Util.playerIsIdle() || Players.localPlayer().getAnimation() == Constants.SUPERHEAT) &&
!getRocks(Constants.IRON_ROCKS_COLOR).isEmpty();
}
@Override
public int execute() {
List<GameObject> rocks = getRocks(Constants.IRON_ROCKS_COLOR);
if (rocks.isEmpty()) return Calculations.random(250, 400);
int count = Inventory.count(Constants.IRON_ORE);
final GameObject rock = rocks.get(0);
rock.interactForceLeft(Constants.MINE);
if (Tabs.isOpen(Tab.MAGIC)) {
hoverSuperheat();
}
MethodProvider.sleepUntil(() -> {
short[] colors = GameObjects.getTopObjectOnTile(rock.getTile()).getModelColors();
return colors == null || colors.length == 0 || count < Inventory.count(Constants.IRON_ORE);
}, Calculations.random(10000, 11000));
return Calculations.random(250, 400);
}
private List<GameObject> getRocks(int colorID) {
return GameObjects.all(gameObject -> {
if (gameObject.getModelColors() == null || gameObject.getModelColors().length == 0) return false;
return gameObject.getModelColors()[0] == colorID &&
gameObject.hasAction(Constants.MINE) &&
gameObject.getInteractableFrom().contains(Players.localPlayer().getTile());
});
}
private void hoverSuperheat() {
WidgetChild superheat = Widgets.getChildWidget(218, 30);
if (superheat != null) {
Mouse.move(superheat.getRectangle());
}
}
}

View File

@ -0,0 +1,39 @@
package io.reisub.dreambot.cminer.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.magic.Magic;
import org.dreambot.api.methods.magic.Normal;
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 Superheat extends TaskNode {
@Override
public boolean accept() {
return Inventory.contains(Constants.IRON_ORE) &&
Magic.canCast(Normal.SUPERHEAT_ITEM) &&
Util.playerIsIdle();
}
@Override
public int execute() {
int count = Inventory.count(Constants.IRON_ORE);
Item ore = Inventory.get(Constants.IRON_ORE);
if (ore == null) return Calculations.random(250, 400);
Magic.castSpell(Normal.SUPERHEAT_ITEM);
MethodProvider.sleepUntil(() -> Tabs.isOpen(Tab.INVENTORY), Calculations.random(1200, 1500));
ore.interact();
Util.sleepUntilAnimating();
MethodProvider.sleepUntil(() -> Inventory.count(Constants.IRON_ORE) < count || Util.playerIsIdle() || Tabs.isOpen(Tab.MAGIC), Calculations.random(1200, 1500));
return Calculations.random(250, 400);
}
}