Add CAshMiner, CPlanker and CThiever scripts

This commit is contained in:
Yuri Moens 2021-10-27 10:18:20 +02:00
parent 06333b3364
commit 1122205220
Signed by: ymo
GPG Key ID: F6D51D6FE15BE924
20 changed files with 541 additions and 0 deletions

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

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

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

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

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

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

3
.idea/modules.xml generated
View File

@ -3,11 +3,14 @@
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/CAgility/CAgility.iml" filepath="$PROJECT_DIR$/CAgility/CAgility.iml" />
<module fileurl="file://$PROJECT_DIR$/CAshMiner/CAshMiner.iml" filepath="$PROJECT_DIR$/CAshMiner/CAshMiner.iml" />
<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$/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$/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$/DreambotScripts.iml" filepath="$PROJECT_DIR$/DreambotScripts.iml" />
<module fileurl="file://$PROJECT_DIR$/Util/Util.iml" filepath="$PROJECT_DIR$/Util/Util.iml" />

13
CAshMiner/CAshMiner.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,19 @@
package io.reisub.dreambot.cashminer;
import io.reisub.dreambot.cashminer.tasks.Drop;
import io.reisub.dreambot.cashminer.tasks.Mine;
import io.reisub.dreambot.util.CTaskScript;
import io.reisub.dreambot.util.Constants;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
@ScriptManifest(category = Category.MINING, name = "CAshMiner", author = Constants.AUTHOR, version = 1.0)
public class CAshMiner extends CTaskScript {
@Override
public void onStart() {
addNodes(
new Mine(),
new Drop()
);
}
}

View File

@ -0,0 +1,21 @@
package io.reisub.dreambot.cashminer.tasks;
import io.reisub.dreambot.util.CInventory;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.script.TaskNode;
public class Drop extends TaskNode {
@Override
public boolean accept() {
return Inventory.isFull();
}
@Override
public int execute() {
Inventory.setDropPattern(CInventory.verticalSnakeDropPattern);
Inventory.dropAll("Soda ash");
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,53 @@
package io.reisub.dreambot.cashminer.tasks;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.Calculations;
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.methods.walking.impl.Walking;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
public class Mine extends TaskNode {
private final Area AREA = new Area(
new Tile(3787, 3767, 0),
new Tile(3787, 3775, 0),
new Tile(3803, 3775, 0),
new Tile(3802, 3765, 0));
@Override
public boolean accept() {
GameObject pile = GameObjects.closest(gameObject -> AREA.contains(gameObject) && gameObject.getName().equals("Ash pile"));
if (pile != null && pile.distance() < 3) {
return !Inventory.isFull()
&& Util.playerIsIdle(1200);
} else {
return !Inventory.isFull()
&& Util.playerIsIdle();
}
}
@Override
public int execute() {
GameObject pile = GameObjects.closest(gameObject -> AREA.contains(gameObject) && gameObject.getName().equals("Ash pile"));
if (pile == null) return Calculations.random(250, 400);
if (!pile.isOnScreen()) {
if (Walking.shouldWalk(Calculations.random(4, 6))) {
Walking.walk(pile);
}
Util.sleepUntilMoving();
return Calculations.random(250, 400);
}
pile.interactForceLeft(Constants.MINE);
Util.sleepUntilMovingAndAnimating();
return Calculations.random(250, 400);
}
}

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

13
CThiever/CThiever.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,19 @@
package io.reisub.dreambot.cthiever;
import io.reisub.dreambot.cthiever.tasks.Pickpocket;
import io.reisub.dreambot.util.CTaskScript;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.tasks.Eat;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
@ScriptManifest(category = Category.THIEVING, name = "CThiever", description = "Steals like a black man", author = Constants.AUTHOR, version = 1.0)
public class CThiever extends CTaskScript {
@Override
public void onStart() {
addNodes(
new Eat(),
new Pickpocket()
);
}
}

View File

@ -0,0 +1,6 @@
package io.reisub.dreambot.cthiever.tasks;
import io.reisub.dreambot.util.TaskNodeParent;
public class Bank extends TaskNodeParent {
}

View File

@ -0,0 +1,54 @@
package io.reisub.dreambot.cthiever.tasks;
import io.reisub.dreambot.util.Util;
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.Players;
import org.dreambot.api.script.ScriptManager;
import org.dreambot.api.script.TaskNode;
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.widgets.message.Message;
public class Pickpocket extends TaskNode {
private boolean attempt, failed, stole;
public Pickpocket() {
ScriptManager.getScriptManager().addListener(new ChatListener() {
@Override
public void onMessage(Message message) {
if (message.getMessage().startsWith("You attempt")) {
attempt = true;
stole = false;
} else if (message.getMessage().startsWith("You fail")) {
failed = true;
} else if (message.getMessage().startsWith("You steal")) {
stole = true;
}
}
});
}
@Override
public boolean accept() {
NPC target = NPCs.closest("Master farmer");
return (Util.playerIsIdle() || stole)
&& !(Players.localPlayer().isInCombat() && Players.localPlayer().getInteractingCharacter() != null)
&& Players.localPlayer().getRenderableHeight() != 1000
&& target != null
&& target.isOnScreen();
}
@Override
public int execute() {
NPC target = NPCs.closest("Master farmer");
if (target == null) return Calculations.random(250, 400);
target.interact("Pickpocket");
Util.sleepUntilMovingOrAnimating();
return Calculations.random(250, 400);
}
}