Add CMiner

This commit is contained in:
Yuri Moens 2021-10-20 16:34:54 +02:00
parent 9de32663fb
commit 9dea119a7d
Signed by: ymo
GPG Key ID: F6D51D6FE15BE924
7 changed files with 164 additions and 0 deletions

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

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

1
.idea/modules.xml generated
View File

@ -6,6 +6,7 @@
<module fileurl="file://$PROJECT_DIR$/CBlackjack/CBlackjack.iml" filepath="$PROJECT_DIR$/CBlackjack/CBlackjack.iml" />
<module fileurl="file://$PROJECT_DIR$/CDebug/CDebug.iml" filepath="$PROJECT_DIR$/CDebug/CDebug.iml" />
<module fileurl="file://$PROJECT_DIR$/CFisher/CFisher.iml" filepath="$PROJECT_DIR$/CFisher/CFisher.iml" />
<module fileurl="file://$PROJECT_DIR$/CMiner/CMiner.iml" filepath="$PROJECT_DIR$/CMiner/CMiner.iml" />
<module fileurl="file://$PROJECT_DIR$/CShopper/CShopper.iml" filepath="$PROJECT_DIR$/CShopper/CShopper.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" />

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);
}
}

View File

@ -50,8 +50,12 @@ public class Constants {
public static final String BURNING_BRAZIER = "Burning brazier";
public static final String MARK_OF_GRACE = "Mark of grace";
public static final String LUNDAIL = "Lundail";
public static final String FIRE_RUNE = "Fire rune";
public static final String COSMIC_RUNE = "Cosmic rune";
public static final String NATURE_RUNE = "Nature rune";
public static final String ROCKS = "Rocks";
public static final int IRON_ROCKS_COLOR = 2576;
public static final String IRON_ORE = "Iron ore";
// Actions
public static final String USE = "Use";
@ -66,6 +70,7 @@ public class Constants {
public static final String LIGHT = "Light";
public static final String FIX = "Fix";
public static final String TRADE = "Trade";
public static final String MINE = "Mine";
// Messages
public static final String KITTEN_WANTS_ATTENTION_MSG = "Your kitten wants attention.";
@ -78,4 +83,7 @@ public class Constants {
// Dialog options
public static final String STROKE = "Stroke";
// Animations
public static final int SUPERHEAT = 725;
}