Compare commits

...

37 Commits

Author SHA1 Message Date
7536ae4db3 Add GUI support 2021-10-28 16:30:07 +02:00
03b882635e Fix unnecessary wait after banking 2021-10-28 09:37:11 +02:00
25844dad61 Add hover functionality 2021-10-28 09:33:53 +02:00
aaee43be4c Add hover functions 2021-10-28 09:33:35 +02:00
ab50d739c1 Add CSmelter script 2021-10-28 00:01:08 +02:00
1aa793b4bf Optimize Seers agility course 2021-10-28 00:00:55 +02:00
7f44187e6b Optimize imports 2021-10-28 00:00:31 +02:00
4f764a4eb9 Add support for non-stackable items 2021-10-28 00:00:11 +02:00
75ab1e7fe8 Optimize imports 2021-10-27 23:59:50 +02:00
b26c38cbcc Enable keyboard input on start 2021-10-27 23:58:24 +02:00
84da7e108a Check if bank is open before wearing ring 2021-10-27 11:17:26 +02:00
76b25c5b04 Add pickup nest task 2021-10-27 11:04:04 +02:00
f6d2593f8a Don't manually close bank 2021-10-27 11:03:53 +02:00
d7f98826b1 Fix wearing ring and wait for scene load after traveling 2021-10-27 10:44:09 +02:00
8623509eb4 Optimize bank opening 2021-10-27 10:43:34 +02:00
1122205220 Add CAshMiner, CPlanker and CThiever scripts 2021-10-27 10:18:20 +02:00
06333b3364 Optimize imports 2021-10-25 11:10:22 +02:00
df82a9be82 Bump JDK version to 11 2021-10-21 15:02:28 +02:00
23125b2711 Sleep until login screen is reached 2021-10-21 14:37:12 +02:00
4c3cde1647 Optimize walking to spot 2021-10-21 00:20:47 +02:00
415e6bf211 Add walking and finetune CMiner 2021-10-20 20:25:46 +02:00
6d525c618a Add isLookingAt function 2021-10-20 20:25:10 +02:00
1523cb0289 Deselect spell if one is selected 2021-10-20 20:24:33 +02:00
9dea119a7d Add CMiner 2021-10-20 16:34:54 +02:00
9de32663fb Logout when stopping script 2021-10-20 14:41:20 +02:00
17f2a005ca Add general Run task 2021-10-20 13:54:35 +02:00
a9ef578e50 Finish CShopper 2021-10-20 13:45:18 +02:00
7a12e2d60a Add start condition for obstacle at Seers 2021-10-20 13:45:02 +02:00
8e72c90252 Handle misclicks 2021-10-20 11:21:55 +02:00
3fce3be950 Optimize imports 2021-10-20 11:21:41 +02:00
0cb56342ee Optimize walking and add custom starting condition 2021-10-20 10:39:10 +02:00
7cae9e07d0 Optimize picking up mark 2021-10-20 10:38:31 +02:00
deaba10e18 Don't walk right after walking custom path 2021-10-20 00:16:03 +02:00
aa5d3627a2 Don't draw strings when UI is hidden 2021-10-20 00:15:43 +02:00
0392d2dddd Fix missing semicolon 2021-10-19 23:51:02 +02:00
3e27bf8a08 Finetuning walking between obstacles 2021-10-19 23:49:37 +02:00
cd6ec994fd Rename KittenTask singleton instantiator and fix NPE 2021-10-19 23:48:06 +02:00
66 changed files with 2328 additions and 61 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/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>

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/CSmelter_jar.xml generated Normal file
View File

@ -0,0 +1,9 @@
<component name="ArtifactManager">
<artifact type="jar" name="CSmelter:jar">
<output-path>$USER_HOME$/DreamBot/Scripts</output-path>
<root id="archive" name="CSmelter.jar">
<element id="module-output" name="CSmelter" />
<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>

2
.idea/misc.xml generated
View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

5
.idea/modules.xml generated
View File

@ -3,10 +3,15 @@
<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$/CSmelter/CSmelter.iml" filepath="$PROJECT_DIR$/CSmelter/CSmelter.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" />

View File

@ -2,16 +2,16 @@ package io.reisub.dreambot.cagility;
import io.reisub.dreambot.cagility.tasks.HandleObstacle;
import io.reisub.dreambot.cagility.tasks.PickupMark;
import io.reisub.dreambot.cagility.tasks.TurnOnRun;
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.Eat;
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.utilities.Timer;
import org.dreambot.api.script.TaskNode;
import java.awt.*;
@ -25,10 +25,14 @@ public class CAgility extends CTaskScript {
getUI().addSkills(Skill.AGILITY);
getUI().setCustomLines(1);
TaskNode kittenTask = KittenTask.getInstance();
if (kittenTask != null) {
addNodes(kittenTask);
}
addNodes(
new Eat(),
KittenTask.createKittenTask(),
new TurnOnRun(),
new Run(),
new HandleObstacle(HandleObstacle.Course.SEERS),
new PickupMark()
);
@ -40,5 +44,9 @@ public class CAgility extends CTaskScript {
int marks = PickupMark.marksPickedUp;
getUI().drawString("Marks picked up: " + marks + " (" + getUI().getHourlyRate(marks) + " per hour)");
if (HandleObstacle.current != null && HandleObstacle.current.getGameObject() != null && HandleObstacle.current.getGameObject().getModel() != null) {
HandleObstacle.current.getGameObject().getModel().drawWireFrame(g);
}
}
}

View File

@ -1,21 +1,34 @@
package io.reisub.dreambot.cagility;
import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.interactive.GameObjects;
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.path.impl.LocalPath;
import org.dreambot.api.utilities.impl.Condition;
import org.dreambot.api.wrappers.interactive.GameObject;
public class Obstacle {
private final int id;
private final Area area;
private final Tile[] walkingTiles;
private final LocalPath<Tile> path;
private Condition startCondition;
private Obstacle next;
public Obstacle(int id, Area area, Tile... walkingTiles) {
this.id = id;
this.area = area;
this.walkingTiles = walkingTiles;
path = new LocalPath<>();
path.addAll(walkingTiles);
startCondition = Util::playerIsIdle;
}
public Obstacle(int id, Area area, Condition startCondition, Tile... walkingTiles) {
this(id, area, walkingTiles);
this.startCondition = startCondition;
}
public int getID() {
@ -38,7 +51,11 @@ public class Obstacle {
return area.contains(Players.localPlayer());
}
public Tile[] getWalkingTiles() {
return walkingTiles;
public LocalPath<Tile> getPath() {
return path;
}
public boolean canStart() {
return startCondition.verify();
}
}

View File

@ -4,17 +4,21 @@ import io.reisub.dreambot.cagility.Obstacle;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.Util;
import org.dreambot.api.input.Mouse;
import org.dreambot.api.input.event.impl.InteractionEvent;
import org.dreambot.api.input.event.impl.InteractionSetting;
import org.dreambot.api.input.mouse.destination.impl.EntityDestination;
import org.dreambot.api.input.mouse.destination.impl.MiniMapTileDestination;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.methods.item.GroundItems;
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.methods.walking.path.impl.LocalPath;
import org.dreambot.api.script.ScriptManager;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.utilities.impl.Condition;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.items.GroundItem;
@ -77,23 +81,32 @@ public class HandleObstacle extends TaskNode {
new Tile(2735, 3459, 0),
new Tile(2735, 3495, 0),
new Tile(2698, 3494, 0)),
new Tile(2719, 3472, 0),
new Tile(2727, 3482, 0)),
new Tile(2720, 3470, 0),
new Tile(2727, 3480, 0)),
new Obstacle(14928, new Area(
new Tile(2721, 3489, 3),
new Tile(2730, 3489, 3),
new Tile(2730, 3497, 3),
new Tile(2721, 3497, 3))),
new Tile(2721, 3497, 3)),
() -> Players.localPlayer().getTile().equals(new Tile(2729, 3491, 3))),
new Obstacle(14932, new Area(
new Tile(2715, 3487, 2),
new Tile(2715, 3498, 2),
new Tile(2704, 3498, 2),
new Tile(2704, 3487, 2))),
new Tile(2704, 3487, 2)),
() -> Players.localPlayer().getTile().equals(new Tile(2713, 3494, 2))),
new Obstacle(14929, new Area(
new Tile(2708, 3482, 2),
new Tile(2717, 3482, 2),
new Tile(2717, 3475, 2),
new Tile(2708, 3475, 2))),
new Tile(2708, 3475, 2),
new Tile(2716, 3475, 2),
new Tile(2716, 3484, 2),
new Tile(2708, 3484, 2)),
() -> {
Area startArea = new Area(
new Tile(2710, 3482, 2),
new Tile(2710, 3481, 2)
);
return startArea.contains(Players.localPlayer());
}),
new Obstacle(14930, new Area(
new Tile(2716, 3468, 3),
new Tile(2699, 3468, 3),
@ -136,6 +149,7 @@ public class HandleObstacle extends TaskNode {
private final Course course;
private final Map<Integer, Rectangle> hoverMap;
public static Obstacle current;
private int retries = 0;
public HandleObstacle(Course course) {
@ -147,46 +161,51 @@ public class HandleObstacle extends TaskNode {
public boolean accept() {
GroundItem mark = GroundItems.closest(Constants.MARK_OF_GRACE);
return Util.playerIsIdle() && (mark == null || !mark.canReach());
}
@Override
public int execute() {
Obstacle current = course.getCurrentObstacle();
current = course.getCurrentObstacle();
if (current == null) {
if (retries >= 10) {
if (retries >= 20) {
MethodContext.logError("Player is in an unsupported area: " + Players.localPlayer().getTile().toString() + ". Stopping.");
ScriptManager.getScriptManager().stop();
} else {
retries++;
}
return Calculations.random(300, 400);
return false;
}
retries = 0;
return (current.canStart() || Util.playerIsIdle()) && (mark == null || !mark.canReach());
}
@Override
public int execute() {
final GameObject currentObject = current.getGameObject();
if (currentObject == null) return Calculations.random(300, 500);
boolean isWalking = false;
if (current.getWalkingTiles() != null && currentObject.distance() > 20) {
LocalPath<Tile> path = current.getPath();
if (path.size() > 0 && currentObject.distance() > 20) {
isWalking = true;
if (hoverMap.get(current.getID()) == null) {
Tile t = current.getWalkingTiles()[0];
MiniMapTileDestination td = new MiniMapTileDestination(t);
MiniMapTileDestination td = new MiniMapTileDestination(path.first());
hoverMap.put(current.getID(), td.getBoundingBox());
}
for (Tile t : current.getWalkingTiles()) {
final Tile target = t.getRandomizedTile();
Walking.clickTileOnMinimap(target);
MethodContext.sleepUntil(() -> target.distance(Players.localPlayer()) < Calculations.random(4, 7), Calculations.random(12000, 13000));
for (Tile t : path) {
Tile target = t.getRandomizedTile(1);
while (!Walking.clickTileOnMinimap(target)) {
target = t.getRandomizedTile(2);
}
Tile finalTarget = target;
if (!MethodProvider.sleepUntil(() -> Players.localPlayer().isMoving(), Calculations.random(1200, 1500))) continue;
MethodContext.sleepUntil(() -> finalTarget.distance(Players.localPlayer()) < Calculations.random(4, 7), Calculations.random(14000, 15000));
}
}
while (!currentObject.isOnScreen() || currentObject.distance() > 15) {
while (!isWalking && (!currentObject.isOnScreen() || currentObject.distance() > 15)) {
isWalking = true;
Walking.walk(currentObject);
MethodContext.sleepUntil(() -> Players.localPlayer().distance(currentObject) < 3, Calculations.random(5000, 5500));
@ -196,17 +215,21 @@ public class HandleObstacle extends TaskNode {
hoverMap.put(current.getID(), currentObject.getBoundingBox());
}
if (!isWalking) {
if (!isWalking && !current.canStart()) {
MethodContext.sleepUntil(Util::playerIsIdle, Calculations.random(3000, 3500));
}
currentObject.interact();
interact(currentObject, isWalking);
Rectangle hoverRect = hoverMap.get(current.getNext().getID());
if (hoverRect != null) {
Mouse.move(hoverRect);
}
if (!Util.sleepUntilMoving(Calculations.random(1200, 1500))) {
return Calculations.random(180, 350);
}
if (isWalking) {
Util.sleepUntilMovingAndAnimating(Calculations.random(12000, 13000));
} else {
@ -215,4 +238,29 @@ public class HandleObstacle extends TaskNode {
return Calculations.random(180, 350);
}
public void interact(GameObject currentObject, boolean shouldHop) {
Mouse.setAlwaysHop(shouldHop);
EntityDestination ed = new EntityDestination(currentObject);
InteractionEvent ie = new InteractionEvent(ed);
ie.interact(currentObject.getActions()[0], InteractionSetting.EMPTY_SETTING, InteractionSetting.FORCE_LEFT_CLICK);
//currentObject.interactForceLeft(currentObject.getActions()[0]);
Mouse.setAlwaysHop(false);
Tile dest = null;
if (MethodProvider.sleepUntil(() -> {
Tile t = Walking.getDestination();
return t != null;
}, Calculations.random(1000, 1100))) {
dest = Walking.getDestination();
}
if (dest == null) return;
if (!currentObject.getObjectTiles().contains(dest) && !currentObject.getInteractableFrom().contains(dest)) {
MethodProvider.log("Misclick, trying again ");
interact(currentObject, true);
}
}
}

View File

@ -5,6 +5,7 @@ import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.methods.item.GroundItems;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.items.GroundItem;
@ -29,14 +30,14 @@ public class PickupMark extends TaskNode {
Item marks = Inventory.get(Constants.MARK_OF_GRACE);
final int count = marks == null ? 0 : marks.getAmount();
mark.interact();
mark.interactForceLeft(Constants.TAKE);
if (MethodContext.sleepUntil(() -> {
Item currentMarks = Inventory.get(Constants.MARK_OF_GRACE);
return currentMarks != null && currentMarks.getAmount() > count;
}, Calculations.random(5000, 5500))) {
}, () -> Players.localPlayer().isMoving(), Calculations.random(1200, 1300), 50)) {
marksPickedUp++;
}
};
return Calculations.random(250, 400);
}

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,52 @@
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.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);
}
}

View File

@ -18,7 +18,7 @@ public class CFisher extends TaskScript {
public void onStart() {
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
TaskNode kittenTask = KittenTask.createKittenTask();
TaskNode kittenTask = KittenTask.getInstance();
if (kittenTask != null) {
addNodes(kittenTask);
}

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,39 @@
package io.reisub.dreambot.cminer;
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;
@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() {
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
getUI().addSkills(Skill.MINING);
getUI().addSkills(Skill.MAGIC);
TaskNode kittenTask = KittenTask.getInstance();
if (kittenTask != null) {
addNodes(kittenTask);
}
addNodes(
new Run(),
new GoToSpot(),
new Superheat(),
new Mine(true),
new GoToBank(),
new OpenBank(),
new DoBank(),
new Teleport()
);
}
}

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

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

View File

@ -0,0 +1,118 @@
package io.reisub.dreambot.cminer.tasks;
import org.dreambot.api.Client;
import org.dreambot.api.data.GameState;
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.Players;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.methods.skills.Skills;
import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.methods.world.Location;
import org.dreambot.api.methods.world.World;
import org.dreambot.api.methods.world.Worlds;
import org.dreambot.api.methods.worldhopper.WorldHopper;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.Player;
import java.util.ArrayList;
import java.util.List;
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 < 20;
}
@Override
public int execute() {
List<Tile> freeSpots = getFreeSpots();
if (freeSpots.isEmpty()) {
hop();
return Calculations.random(250, 400);
}
Tile target = freeSpots.get(Calculations.random(0, freeSpots.size()));
while (target.distance() > 8) {
if (Walking.shouldWalk(Calculations.random(3, 5))) {
Walking.walk(target);
}
MethodProvider.sleep(300, 500);
}
if (!MethodProvider.sleepUntil(() -> !Players.localPlayer().isMoving(), Calculations.random(4500, 5500))) {
return Calculations.random(250, 400);
}
if (!Players.localPlayer().getTile().equals(target)) {
Walking.walkExact(target);
if (!MethodProvider.sleepUntil(() -> Players.localPlayer().isMoving(), Calculations.random(1000, 1500))) {
return Calculations.random(250, 400);
}
MethodProvider.sleepUntil(() -> Players.localPlayer().getTile().equals(target), Calculations.random(3500, 4500));
}
return Calculations.random(250, 400);
}
private List<Tile> getFreeSpots() {
List<Tile> freeSpots = new ArrayList<>();
List<Player> otherPlayers = Players.all(player -> !player.getName().equals(Players.localPlayer().getName()));
for (Tile t : SPOTS) {
boolean taken = false;
for (Player p : otherPlayers) {
if (p.getTile().equals(t)) {
taken = true;
break;
}
}
if (!taken) {
freeSpots.add(t);
}
}
return freeSpots;
}
private void hop() {
World world = Worlds.getRandomWorld(new Filter<World>() {
@Override
public boolean match(World world) {
return world.isMembers() &&
world.isNormal() &&
!world.isHighRisk() &&
!world.isPVP() &&
world.getMinimumLevel() <= Skills.getTotalLevel() &&
(world.getLocation().equals(Location.UK) || world.getLocation().equals(Location.GERMANY));
}
});
if (world != null) {
WorldHopper.hopWorld(world);
}
MethodProvider.sleepUntil(() -> Client.getGameState() == GameState.LOGGED_IN, Calculations.random(10000, 11000));
}
}

View File

@ -0,0 +1,95 @@
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 {
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 || 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);
int count = Inventory.count(Constants.IRON_ORE);
final GameObject rock = rocks.get(0);
rock.interactForceLeft(Constants.MINE);
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();
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);
}
public static 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 selectSuperheat() {
if (!Tabs.isOpen(Tab.MAGIC)) {
Tabs.open(Tab.MAGIC);
}
WidgetChild superheat = Widgets.getChildWidget(218, 30);
if (superheat == null) return;
superheat.interact();
MethodProvider.sleepUntil(() -> Tabs.isOpen(Tab.INVENTORY), Calculations.random(1200, 1500));
Mouse.move(Inventory.slotBounds(Inventory.getFirstEmptySlot()));
}
}

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

View File

@ -0,0 +1,67 @@
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.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.interactive.GameObject;
import org.dreambot.api.wrappers.items.Item;
import java.util.List;
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);
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;
}
}
}
}

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

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,40 @@
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 PickupNest(),
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,41 @@
package io.reisub.dreambot.cplanker.tasks;
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.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,36 @@
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));
}
}
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.container.impl.bank.Bank;
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.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) && !Bank.isOpen()) {
Inventory.interact(ringFilter, "Wear");
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));
MethodProvider.sleep(800, 1200);
}
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,33 @@
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.GameObjects;
import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
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() {
GameObject bank = GameObjects.closest("Bank chest");
if (bank == null) return Calculations.random(250, 400);
bank.interactForceLeft("Use");
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,30 @@
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.item.GroundItems;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.items.GroundItem;
public class PickupNest extends TaskNode {
@Override
public boolean accept() {
GroundItem nest = GroundItems.closest(groundItem -> groundItem.getName().contains("nest"));
return nest != null
&& !Inventory.isFull();
}
@Override
public int execute() {
int count = Inventory.fullSlotCount();
GroundItem nest = GroundItems.closest(groundItem -> groundItem.getName().contains("nest"));
if (nest == null) return Calculations.random(250, 400);
nest.interact();
MethodProvider.sleepUntil(() -> Inventory.fullSlotCount() > count, 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);
}
}

View File

@ -1,24 +1,93 @@
package io.reisub.dreambot.cshopper;
import io.reisub.dreambot.cshopper.tasks.*;
import io.reisub.dreambot.util.CTaskScript;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.tasks.Run;
import io.reisub.dreambot.util.ui.GUI;
import io.reisub.dreambot.util.ui.Parameter;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.randoms.RandomEvent;
import org.dreambot.api.script.Category;
import org.dreambot.api.script.ScriptManifest;
import org.dreambot.api.script.impl.TaskScript;
import org.dreambot.api.wrappers.items.Item;
import javax.swing.*;
import java.awt.*;
import java.lang.reflect.InvocationTargetException;
@SuppressWarnings("unused")
@ScriptManifest(category = Category.MISC, name = "CShopper", description = "Shops like a woman with an unlimited Visa card", author = Constants.AUTHOR, version = 1.0)
public class CShopper extends TaskScript {
public class CShopper extends CTaskScript {
private static final Configuration configuration = new Configuration(
Constants.LUNDAIL,
new ItemWrapper(Constants.NATURE_RUNE, 6000),
new ItemWrapper(Constants.COSMIC_RUNE, -1)
new ItemWrapper("Nature rune", 5000)
//new ItemWrapper("Gold ore", 2600, 73, false)
//new ItemWrapper("Hammerstone seed", -1),
//new ItemWrapper("Asgarnian seed", -1),
//new ItemWrapper("Jute seed", -1),
//new ItemWrapper("Yanillian seed", -1),
//new ItemWrapper("Krandorian seed", -1),
//new ItemWrapper("Barley seed", 2000)
);
private Buy buyTask;
private GUI gui;
public static Configuration getConfiguration() {
return configuration;
}
@Override
public void onStart() {
getUI().setCustomLines(configuration.getItems().length);
getRandomManager().disableSolver(RandomEvent.BREAK);
getRandomManager().disableSolver(RandomEvent.LOGIN);
buyTask = new Buy();
try {
SwingUtilities.invokeAndWait(() -> {
gui = new GUI(getSDNName());
gui.addComboBox("Trader", CShopperOptions.traders, new Parameter("Custom"));
gui.addComboBox("Items",
CShopperOptions.items,
true,
new Parameter("Custom"),
new Parameter("Buy total"),
new Parameter("Minimum in shop"),
new Parameter("Stackable", new JCheckBox()));
gui.init();
});
} catch (Exception ignored) {}
while (gui == null || !gui.isReady()) {
MethodProvider.sleep(500);
}
MethodProvider.log(gui.getOption("Trader").getName());
addNodes(
new Stop(),
new Run(),
new Open(),
buyTask,
new Hop()
);
}
@Override
public void onPaint(Graphics g) {
super.onPaint(g);
if (buyTask == null) return;
for (ItemWrapper iw : configuration.getItems()) {
String name = iw.getName();
Item item = Inventory.get(iw.getName());
int current = item == null ? 0 : item.getAmount();
getUI().drawString("Bought " + buyTask.getBought(name) + " " + name + " (" + current + ")");
}
}
}

View File

@ -0,0 +1,16 @@
package io.reisub.dreambot.cshopper;
import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.ui.Option;
public class CShopperOptions {
public final static Option[] traders = new Option[]{
new Option("custom"),
new Option("Lundail", "mage arena rune shop")
};
public final static Option[] items = new Option[]{
new Option("custom"),
new Option("Nature rune")
};
}

View File

@ -3,15 +3,25 @@ package io.reisub.dreambot.cshopper;
public class ItemWrapper {
private final String name;
private final int buyTotal, minimumInShop;
private final boolean stackable;
public ItemWrapper(String name, int buyTotal, int minimumInShop) {
public ItemWrapper(String name, int buyTotal, int minimumInShop, boolean stackable) {
this.name = name;
this.buyTotal = buyTotal;
this.minimumInShop = minimumInShop;
this.stackable = stackable;
}
public ItemWrapper(String name, int buyTotal, boolean stackable) {
this(name, buyTotal, 0, stackable);
}
public ItemWrapper(String name, int buyTotal, int minimumInShop) {
this(name, buyTotal, minimumInShop, false);
}
public ItemWrapper(String name, int buyTotal) {
this(name, buyTotal, 0);
this(name, buyTotal, 0, false);
}
public String getName() {
@ -25,4 +35,8 @@ public class ItemWrapper {
public int getMinimumInShop() {
return minimumInShop;
}
public boolean isStackable() {
return stackable;
}
}

View File

@ -0,0 +1,31 @@
package io.reisub.dreambot.cshopper;
public enum ShopperItem {
CUSTOM("custom..."),
NATURE_RUNE("Nature rune");
private final String name;
private String customName;
ShopperItem(String name) {
this.name = name;
}
public String getName() {
return name;
}
@Override
public String toString() {
return name;
}
public void setCustomName(String customName) {
this.customName = customName;
}
public String getCustomName() {
return customName;
}
}

View File

@ -0,0 +1,49 @@
package io.reisub.dreambot.cshopper;
public enum Trader {
CUSTOM("custom..."),
LUNDAIL("Lundail", "mage arena rune shop");
private final String name;
private final String info;
private String customName;
Trader(String name) {
this(name, "");
}
Trader(String name, String info) {
this.name = name;
this.info = info;
}
public String getName() {
if (customName == null || customName.equals("")) {
return name;
} else {
return customName;
}
}
public String getInfo() {
return info;
}
@Override
public String toString() {
if (info.equals("")) {
return name;
} else {
return name + " (" + info + ")";
}
}
public String getCustomName() {
return customName;
}
public void setCustomName(String customName) {
this.customName = customName;
}
}

View File

@ -2,14 +2,26 @@ package io.reisub.dreambot.cshopper.tasks;
import io.reisub.dreambot.cshopper.CShopper;
import io.reisub.dreambot.cshopper.ItemWrapper;
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.Shop;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.items.Item;
import java.util.HashMap;
import java.util.Map;
public class Buy extends TaskNode {
private final Map<String, Integer> boughtMap;
public Buy() {
this.boughtMap = new HashMap<>();
}
@Override
public boolean accept() {
if (!Shop.isOpen()) return false;
if (!Shop.isOpen() || Inventory.isFull() || Hop.shouldHop) return false;
for (ItemWrapper iw : CShopper.getConfiguration().getItems()) {
int shopCount = Shop.get(iw.getName()).getAmount();
@ -28,19 +40,53 @@ public class Buy extends TaskNode {
@Override
public int execute() {
for (ItemWrapper iw : CShopper.getConfiguration().getItems()) {
int shopCount = Shop.get(iw.getName()).getAmount();
Item shopItem = Shop.get(iw.getName());
int shopCount = shopItem.getAmount();
int inventoryCount = 0;
if (Inventory.get(iw.getName()) != null) {
inventoryCount = Inventory.get(iw.getName()).getAmount();
}
if (shopCount > iw.getMinimumInShop() && inventoryCount < iw.getBuyTotal()) {
int toBuy = shopCount - iw.getMinimumInShop();
// TODO finish while testing at shop
int buyTotal = iw.getBuyTotal() == -1 ? Integer.MAX_VALUE : iw.getBuyTotal();
if (shopCount > iw.getMinimumInShop() && inventoryCount < buyTotal) {
int toBuy = buyTotal - inventoryCount;
int canBuy = iw.getMinimumInShop() == 0 ? 50 : shopCount - iw.getMinimumInShop();
if ((toBuy >= 50 && canBuy >= 50) || (toBuy >= 27 && canBuy >= 27 && !iw.isStackable())) {
shopItem.interact("Buy 50");
} else if (toBuy >= 10 && canBuy >= 10) {
shopItem.interact("Buy 10");
} else if (toBuy >= 5 && canBuy >= 5) {
shopItem.interact("Buy 5");
} else {
shopItem.interact("Buy 1");
}
int finalInventoryCount = inventoryCount;
if (MethodProvider.sleepUntil(() -> {
Item inventoryItem = Inventory.get(iw.getName());
return inventoryItem != null && inventoryItem.getAmount() > finalInventoryCount;
}, Calculations.random(2000, 2500))) {
int count = Inventory.get(iw.getName()).getAmount();
bought(iw.getName(), count - inventoryCount);
}
}
}
return 0;
}
private void bought(String item, int amount) {
int old = getBought(item);
boughtMap.put(item, old + amount);
}
public int getBought(String item) {
Integer i = boughtMap.get(item);
if (i == null) return 0;
return i;
}
}

View File

@ -0,0 +1,45 @@
package io.reisub.dreambot.cshopper.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.Shop;
import org.dreambot.api.methods.container.impl.bank.Bank;
import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
public class Deposit extends TaskNode {
@Override
public boolean accept() {
return Inventory.isFull();
}
@Override
public int execute() {
GameObject bank = GameObjects.closest("Bank chest");
if (bank == null) return Calculations.random(250, 400);
if (Shop.isOpen()) {
Shop.close();
MethodProvider.sleepUntil(() -> !Shop.isOpen(), Calculations.random(2000, 2500));
}
bank.interact();
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
if (!MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(5000, 5500))) return Calculations.random(250, 400);
MethodProvider.sleep(300, 500);
Bank.depositAllExcept("Coins");
MethodProvider.sleepUntil(() -> Inventory.onlyContains("Coins"), Calculations.random(5000, 5500));
Bank.close();
MethodProvider.sleepUntil(() -> !Bank.isOpen(), Calculations.random(2000, 2500));
Hop.shouldHop = true;
return Calculations.random(250, 400);
}
}

View File

@ -2,25 +2,39 @@ package io.reisub.dreambot.cshopper.tasks;
import io.reisub.dreambot.cshopper.CShopper;
import io.reisub.dreambot.cshopper.ItemWrapper;
import org.dreambot.api.Client;
import org.dreambot.api.data.GameState;
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.Shop;
import org.dreambot.api.methods.skills.Skills;
import org.dreambot.api.methods.world.World;
import org.dreambot.api.methods.world.Worlds;
import org.dreambot.api.methods.worldhopper.WorldHopper;
import org.dreambot.api.script.TaskNode;
import java.util.Comparator;
import java.util.LinkedList;
import java.util.List;
import java.util.Queue;
public class Hop extends TaskNode {
public static boolean shouldHop;
private final Queue<World> worlds;
public Hop(boolean members) {
List<World> worldsList = Worlds.all(world -> world.isMembers() == members && world.isNormal() && !world.isHighRisk() && !world.isPVP());
List<World> worldsList = Worlds.all(world -> world.isMembers() == members && world.isNormal() && !world.isHighRisk() && !world.isPVP() && world.getMinimumLevel() <= Skills.getTotalLevel());
worldsList.sort(Comparator.comparingInt(World::getWorld));
worlds = new LinkedList<>(worldsList);
while (true) {
World w = worlds.poll();
worlds.add(w);
if (w == null || w.getWorld() == Worlds.getCurrentWorld()) break;
}
}
public Hop() {
@ -29,6 +43,8 @@ public class Hop extends TaskNode {
@Override
public boolean accept() {
if (Hop.shouldHop) return true;
if (!Shop.isOpen()) return false;
for (ItemWrapper iw : CShopper.getConfiguration().getItems()) {
@ -47,13 +63,19 @@ public class Hop extends TaskNode {
@Override
public int execute() {
shouldHop = false;
Shop.close();
MethodProvider.sleepUntil(() -> !Shop.isOpen(), Calculations.random(2000, 2500));
World world = worlds.poll();
worlds.add(world);
if (world != null) {
WorldHopper.hopWorld(world);
}
MethodProvider.sleepUntil(() -> Client.getGameState() == GameState.LOGGED_IN, Calculations.random(10000, 11000));
return Calculations.random(200, 400);
}
}

View File

@ -4,6 +4,7 @@ import io.reisub.dreambot.cshopper.CShopper;
import io.reisub.dreambot.util.Constants;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.container.impl.Shop;
import org.dreambot.api.methods.interactive.NPCs;
import org.dreambot.api.script.TaskNode;
@ -12,7 +13,9 @@ import org.dreambot.api.wrappers.interactive.NPC;
public class Open extends TaskNode {
@Override
public boolean accept() {
return !Shop.isOpen();
return !Shop.isOpen()
&& !Inventory.isFull()
&& !Hop.shouldHop;
}
@Override

View File

@ -0,0 +1,39 @@
package io.reisub.dreambot.cshopper.tasks;
import io.reisub.dreambot.cshopper.CShopper;
import io.reisub.dreambot.cshopper.ItemWrapper;
import org.dreambot.api.Client;
import org.dreambot.api.data.GameState;
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.tabs.Tabs;
import org.dreambot.api.script.ScriptManager;
import org.dreambot.api.script.TaskNode;
public class Stop extends TaskNode {
@Override
public boolean accept() {
for (ItemWrapper iw : CShopper.getConfiguration().getItems()) {
int inventoryCount = 0;
if (Inventory.get(iw.getName()) != null) {
inventoryCount = Inventory.get(iw.getName()).getAmount();
}
if (inventoryCount < iw.getBuyTotal()) return false;
}
return true;
}
@Override
public int execute() {
MethodProvider.log("Finished buying");
Tabs.logout();
MethodProvider.sleepUntil(() -> Client.getGameState() == GameState.LOGIN_SCREEN, Calculations.random(4000, 4500));
ScriptManager.getScriptManager().stop();
return 1000;
}
}

13
CSmelter/CSmelter.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,45 @@
package io.reisub.dreambot.csmelter;
import io.reisub.dreambot.csmelter.tasks.DoBank;
import io.reisub.dreambot.csmelter.tasks.OpenBank;
import io.reisub.dreambot.csmelter.tasks.SetCamera;
import io.reisub.dreambot.csmelter.tasks.Smelt;
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;
@ScriptManifest(category = Category.SMITHING, name = "CSmelter", author = Constants.AUTHOR, version = 1.0)
public class CSmelter extends CTaskScript {
public static SmeltingOption smeltingOption = SmeltingOption.GOLD_BRACELET;
@Override
public void onStart() {
super.onStart();
getRandomManager().registerSolver(new GenieSolver(GenieSolver.Skill.HERBLORE));
if (smeltingOption.getMould().equals("")) {
getUI().addSkills(Skill.SMITHING);
} else {
getUI().addSkills(Skill.CRAFTING);
}
TaskNode kittenTask = KittenTask.getInstance();
if (kittenTask != null) {
addNodes(kittenTask);
}
addNodes(
new SetCamera(),
new Run(),
new Smelt(),
new OpenBank(),
new DoBank()
);
}
}

View File

@ -0,0 +1,23 @@
package io.reisub.dreambot.csmelter;
public class Ingredient {
private final String name;
private final int amount;
public Ingredient(String name, int amount) {
this.name = name;
this.amount = amount;
}
public Ingredient(String name) {
this(name, 1);
}
public String getName() {
return name;
}
public int getAmount() {
return amount;
}
}

View File

@ -0,0 +1,71 @@
package io.reisub.dreambot.csmelter;
public enum SmeltingOption {
GOLD_BAR(new Ingredient("Gold ore"), "Gold bar", 6),
GOLD_BRACELET(new Ingredient("Gold bar"), "Gold bracelet", 46, "Bracelet mould");
private final Ingredient[] ingredients;
private final String endProduct, mould;
private final int hotkey, maxCraftsPerInventory;
SmeltingOption(Ingredient[] ingredients, String endProduct, int hotkey, String mould) {
this.ingredients = ingredients;
this.endProduct = endProduct;
this.hotkey = hotkey;
this.mould = mould;
int totalIngredientsRequired = 0;
for (Ingredient i : ingredients) {
totalIngredientsRequired += i.getAmount();
}
if (mould.equals("")) {
maxCraftsPerInventory = Math.floorDiv(28, totalIngredientsRequired);
} else {
maxCraftsPerInventory = Math.floorDiv(27, totalIngredientsRequired);
}
}
SmeltingOption(Ingredient[] ingredients, String endProduct, int hotkey) {
this(ingredients, endProduct, hotkey, "");
}
SmeltingOption(Ingredient ingredient, String endProduct, int hotkey, String mould) {
this(new Ingredient[]{ingredient}, endProduct, hotkey, mould);
}
SmeltingOption(Ingredient ingredient, String endProduct, int hotkey) {
this(new Ingredient[]{ingredient}, endProduct, hotkey, "");
}
public Ingredient[] getIngredients() {
return ingredients;
}
public String[] getIngredientsNames() {
String[] ingredientNames = new String[ingredients.length];
for (int i = 0; i < ingredients.length; i++) {
ingredientNames[i] = ingredients[i].getName();
}
return ingredientNames;
}
public int getMaxCraftsPerInventory() {
return maxCraftsPerInventory;
}
public String getEndProduct() {
return endProduct;
}
public int getHotkey() {
return hotkey;
}
public String getMould() {
return mould;
}
}

View File

@ -0,0 +1,71 @@
package io.reisub.dreambot.csmelter.tasks;
import io.reisub.dreambot.csmelter.CSmelter;
import io.reisub.dreambot.csmelter.Ingredient;
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.widget.Widgets;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.items.Item;
import org.dreambot.api.wrappers.widgets.WidgetChild;
public class DoBank extends TaskNode {
@Override
public boolean accept() {
return Bank.isOpen();
}
@Override
public int execute() {
if (Inventory.contains(CSmelter.smeltingOption.getEndProduct())) {
if (Util.getHoverEntry("deposit") == null) {
if (Inventory.contains(item -> item.getName().endsWith("mould"))) {
Item item = Inventory.get(CSmelter.smeltingOption.getEndProduct());
Util.addHoverEntry("deposit", item.getDestination().getBoundingBox());
} else {
WidgetChild depositAll = Widgets.getChildWidget(12, 42);
if (depositAll != null && depositAll.isVisible()) {
Util.addHoverEntry("deposit", depositAll.getRectangle());
}
}
}
Bank.depositAllExcept(item -> item.getName().endsWith("mould"));
if (!MethodProvider.sleepUntil(() -> Inventory.isEmpty() || Inventory.onlyContains(item -> item.getName().endsWith("mould")), Calculations.random(2000, 2500))) return Calculations.random(250, 400);
}
String mould = CSmelter.smeltingOption.getMould();
if (!mould.equals("")) {
if (!Inventory.contains(mould)) {
Bank.withdraw(mould, 1);
if (!MethodProvider.sleepUntil(() -> Inventory.contains(mould), Calculations.random(2000, 2500))) {
return Calculations.random(250, 400);
}
}
}
String[] names = CSmelter.smeltingOption.getIngredientsNames();
if (CSmelter.smeltingOption.getIngredients().length == 1) {
Bank.withdrawAll(CSmelter.smeltingOption.getIngredients()[0].getName());
} else {
int craftsPerInventory = CSmelter.smeltingOption.getMaxCraftsPerInventory();
for (Ingredient i : CSmelter.smeltingOption.getIngredients()) {
if (Inventory.count(i.getName()) < i.getAmount() * craftsPerInventory) {
Bank.withdraw(i.getName(), i.getAmount() * craftsPerInventory);
}
MethodProvider.sleep(200, 400);
}
}
Util.hover("minimapToFurnace");
MethodProvider.sleepUntil(() -> Inventory.containsAll(names), Calculations.random(2000, 2500));
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,45 @@
package io.reisub.dreambot.csmelter.tasks;
import io.reisub.dreambot.csmelter.CSmelter;
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.GameObjects;
import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.script.TaskNode;
import org.dreambot.api.wrappers.interactive.GameObject;
public class OpenBank extends TaskNode {
@Override
public boolean accept() {
return !Bank.isOpen()
&& !Inventory.containsAll(CSmelter.smeltingOption.getIngredientsNames())
&& Util.playerIsIdle();
}
@Override
public int execute() {
GameObject bank = GameObjects.closest("Bank booth");
if (bank == null) return Calculations.random(250, 400);
if (!bank.isOnScreen()) {
while (bank.distance() > Calculations.random(6, 9)) {
if (Walking.shouldWalk(Calculations.random(4, 6))) {
Walking.walk(bank);
}
}
}
Util.addHoverEntry("bank", bank);
bank.interactForceLeft("Bank");
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
Util.hover("deposit");
MethodProvider.sleepUntil(Bank::isOpen, Calculations.random(10000, 11000));
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,19 @@
package io.reisub.dreambot.csmelter.tasks;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.input.Camera;
import org.dreambot.api.script.TaskNode;
public class SetCamera extends TaskNode {
@Override
public boolean accept() {
return Camera.getPitch() <= 380;
}
@Override
public int execute() {
Camera.mouseRotateTo(Calculations.random(60, 302), 383);
return Calculations.random(250, 400);
}
}

View File

@ -0,0 +1,76 @@
package io.reisub.dreambot.csmelter.tasks;
import io.reisub.dreambot.csmelter.CSmelter;
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.input.Keyboard;
import org.dreambot.api.methods.interactive.GameObjects;
import org.dreambot.api.methods.interactive.Players;
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.widgets.WidgetChild;
public class Smelt extends TaskNode {
private boolean firstTime = true;
@Override
public boolean accept() {
return Inventory.containsAll(CSmelter.smeltingOption.getIngredientsNames())
&& (Bank.isOpen() || Util.playerIsIdle(1400));
}
@Override
public int execute() {
GameObject furnace = GameObjects.closest("Furnace");
if (furnace == null) return Calculations.random(250, 400);
if (Bank.isOpen()) {
Util.addHoverEntry("minimapToFurnace", furnace.getTile(), true);
Walking.walk(furnace);
MethodProvider.sleep(300, 600);
}
furnace.interact();
if (!furnace.getInteractableFrom().contains(Players.localPlayer().getTile())) {
if (!Util.sleepUntilMoving()) return Calculations.random(250, 400);
}
Util.hover("smeltWidget");
MethodProvider.sleepWhile(() -> furnace.distance() > Calculations.random(2, 4), Calculations.random(10000, 11000));
if (CSmelter.smeltingOption.getMould().equals("")) {
if (!firstTime) Keyboard.holdSpace(() -> {
WidgetChild w = Widgets.getChildWidget(270, 13);
return (w != null && w.isVisible()) || Players.localPlayer().isAnimating();
}, Calculations.random(4000, 4500));
if (!MethodProvider.sleepUntil(() -> {
WidgetChild w = Widgets.getChildWidget(270, 13);
return w != null && w.isVisible();
}, Calculations.random(5000, 5500))) return Calculations.random(250, 400);
Keyboard.type(CSmelter.smeltingOption.getHotkey(), false, false);
if (Util.sleepUntilAnimating()) firstTime = false;
} else {
if (!MethodProvider.sleepUntil(() -> {
WidgetChild w = Widgets.getChildWidget(446, CSmelter.smeltingOption.getHotkey());
return w != null && w.isVisible();
}, Calculations.random(3000, 3500))) return Calculations.random(250, 400);
WidgetChild w = Widgets.getChildWidget(446, CSmelter.smeltingOption.getHotkey());
Util.addHoverEntry("smeltWidget", w.getRectangle());
w.interact();
Util.sleepUntilAnimating();
}
Util.hover("bank");
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,52 @@
package io.reisub.dreambot.cthiever.tasks;
import io.reisub.dreambot.util.Util;
import org.dreambot.api.methods.Calculations;
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.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);
}
}

View File

@ -1,7 +1,9 @@
package io.reisub.dreambot.util;
import io.reisub.dreambot.util.ui.UI;
import org.dreambot.api.Client;
import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.script.AbstractScript;
import java.awt.*;
@ -25,6 +27,12 @@ public abstract class CAbstractScript extends AbstractScript implements MouseLis
ui.draw(g);
}
@Override
public void onStart() {
MethodProvider.sleep(1000);
Client.getInstance().setKeyboardInputEnabled(true);
}
@Override
public void onPause() {
ui.pause();
@ -32,6 +40,7 @@ public abstract class CAbstractScript extends AbstractScript implements MouseLis
@Override
public void onResume() {
Client.getInstance().setKeyboardInputEnabled(true);
ui.resume();
}

View File

@ -1,7 +1,9 @@
package io.reisub.dreambot.util;
import io.reisub.dreambot.util.ui.UI;
import org.dreambot.api.Client;
import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.MethodProvider;
import org.dreambot.api.script.impl.TaskScript;
import java.awt.*;
@ -25,6 +27,12 @@ public abstract class CTaskScript extends TaskScript implements MouseListener {
ui.draw(g);
}
@Override
public void onStart() {
MethodProvider.sleep(1000);
Client.getInstance().setKeyboardInputEnabled(true);
}
@Override
public void onPause() {
ui.pause();
@ -32,6 +40,7 @@ public abstract class CTaskScript extends TaskScript implements MouseListener {
@Override
public void onResume() {
Client.getInstance().setKeyboardInputEnabled(true);
ui.resume();
}

View File

@ -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";
@ -50,11 +53,19 @@ 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";
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";
public static final String TAKE = "Take";
public static final String USE_ROD = "Use-rod";
public static final String INTERACT = "Interact";
public static final String PICK_UP = "Pick-up";
@ -65,6 +76,8 @@ 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";
public static final String MONASTERY_TELEPORT = "Monastery Teleport";
// Messages
public static final String KITTEN_WANTS_ATTENTION_MSG = "Your kitten wants attention.";
@ -77,4 +90,7 @@ public class Constants {
// Dialog options
public static final String STROKE = "Stroke";
// Animations
public static final int SUPERHEAT = 725;
}

View File

@ -1,15 +1,26 @@
package io.reisub.dreambot.util;
import org.dreambot.api.input.Mouse;
import org.dreambot.api.input.mouse.destination.impl.MiniMapTileDestination;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.interactive.Players;
import org.dreambot.api.methods.map.Tile;
import org.dreambot.api.methods.skills.Skill;
import org.dreambot.api.methods.skills.Skills;
import org.dreambot.api.wrappers.interactive.Entity;
import org.dreambot.api.wrappers.interactive.GameObject;
import org.dreambot.api.wrappers.interactive.Player;
import org.w3c.dom.css.Rect;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
@SuppressWarnings("unused")
public class Util {
private static final String VERSION = "1.0.0";
private static final Map<String, Rectangle> hoverMap = new HashMap<>();
public static String getVersion() {
return VERSION;
@ -81,4 +92,71 @@ public class Util {
public static int getCurrentHP() {
return Skills.getBoostedLevels(Skill.HITPOINTS);
}
public static boolean isLookingAt(GameObject o) {
Tile playerTile = Players.localPlayer().getTile();
int px = playerTile.getX();
int py = playerTile.getY();
Tile objectTile = o.getTile();
int ox = objectTile.getX();
int oy = objectTile.getY();
switch (Players.localPlayer().getOrientation() / 256) {
case 0: // south
return oy < py;
case 1: // south-west
return oy <= py && ox <= px;
case 2: // west
return ox < px;
case 3: //north-west
return oy >= py && ox <= px;
case 4: // north
return oy > py;
case 5: // north-east
return oy >= py && ox >= px;
case 6: // east
return ox > px;
case 7: //south-east
return oy <= py && ox >= px;
}
return false;
}
public static Rectangle getHoverEntry(String name) {
return hoverMap.get(name);
}
public static void addHoverEntry(String name, Rectangle dest) {
hoverMap.putIfAbsent(name, dest);
}
public static void addHoverEntry(String name, Tile dest, boolean minimap) {
Rectangle rect;
if (minimap) {
MiniMapTileDestination td = new MiniMapTileDestination(dest);
rect = td.getBoundingBox();
} else {
rect = dest.getTileReference().getBoundaryObject().getBoundingBox();
}
addHoverEntry(name, rect);
}
public static void addHoverEntry(String name, Tile dest) {
addHoverEntry(name, dest, false);
}
public static void addHoverEntry(String name, Entity dest) {
addHoverEntry(name, dest.getBoundingBox());
}
public static void hover(String name) {
Rectangle dest = getHoverEntry(name);
if (dest != null) {
Mouse.move(dest);
}
}
}

View File

@ -1,20 +1,31 @@
package io.reisub.dreambot.cagility.tasks;
package io.reisub.dreambot.util.tasks;
import org.dreambot.api.methods.Calculations;
import org.dreambot.api.methods.MethodContext;
import org.dreambot.api.methods.walking.impl.Walking;
import org.dreambot.api.script.TaskNode;
public class TurnOnRun extends TaskNode {
public class Run extends TaskNode {
private final int min, max;
private int threshold;
public TurnOnRun() {
threshold = Calculations.random(75, 100);
public Run() {
this(75, 100);
}
public Run(int threshold) {
this(threshold, threshold+1);
}
public Run(int min, int max) {
this.min = min;
this.max = max;
this.threshold = Calculations.random(min, max);
}
@Override
public boolean accept() {
return !Walking.isRunEnabled() && Walking.getRunEnergy() > threshold;
return !Walking.isRunEnabled() && Walking.getRunEnergy() >= threshold;
}
@Override
@ -22,7 +33,7 @@ public class TurnOnRun extends TaskNode {
Walking.toggleRun();
if (MethodContext.sleepUntil(Walking::isRunEnabled, Calculations.random(1500, 2000))) {
threshold = Calculations.random(75, 100);
threshold = Calculations.random(min, max);
}
return Calculations.random(200, 400);

View File

@ -5,6 +5,7 @@ import io.reisub.dreambot.util.Constants;
import io.reisub.dreambot.util.TaskNodeParent;
import org.dreambot.api.methods.container.impl.Inventory;
import org.dreambot.api.methods.filter.Filter;
import org.dreambot.api.methods.magic.Magic;
import org.dreambot.api.script.ScriptManager;
import org.dreambot.api.script.listener.ChatListener;
import org.dreambot.api.wrappers.interactive.NPC;
@ -30,7 +31,7 @@ public class KittenTask extends TaskNodeParent {
};
@Nullable
public static KittenTask createKittenTask() {
public static KittenTask getInstance() {
KittenTask task = null;
if (Inventory.contains(Constants.KITTEN_INVENTORY)) {
@ -81,6 +82,15 @@ public class KittenTask extends TaskNodeParent {
});
}
@Override
public int execute() {
if (Magic.isSpellSelected()) {
Magic.deselect();
}
return super.execute();
}
public void setHungry(boolean hungry) {
this.hungry = hungry;
}

View File

@ -0,0 +1,208 @@
package io.reisub.dreambot.util.ui;
import org.dreambot.api.methods.MethodProvider;
import javax.swing.*;
import java.awt.*;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
public class GUI extends JFrame {
private final GridBagLayout layout;
private final GridBagConstraints constraints;
private final Map<String, Component> componentMap;
private final Map<String, java.util.List<Option>> optionMap;
private volatile boolean ready;
public GUI(String title) {
super(title);
layout = new GridBagLayout();
constraints = new GridBagConstraints();
constraints.insets = new Insets(6, 6, 6, 6);
componentMap = new HashMap<>();
optionMap = new HashMap<>();
}
public void init() {
setUndecorated(true);
Container contentPane = getContentPane();
contentPane.setLayout(layout);
addStart();
pack();
setLocationRelativeTo(getOwner());
setVisible(true);
}
private void addStart() {
JButton start = new JButton("Start");
start.setPreferredSize(new Dimension(100, 40));
constraints.fill = GridBagConstraints.VERTICAL;
constraints.weighty = 2.0;
layout.setConstraints(start, constraints);
getContentPane().add(start);
start.addActionListener((e) -> {
for (String key : componentMap.keySet()) {
Component component = componentMap.get(key);
java.util.List<Option> options = new ArrayList<>();
if (component instanceof JComboBox) {
Option option = (Option) ((JComboBox<?>) component).getSelectedItem();
options.add(option);
} else if (component instanceof JList) {
DefaultListModel<Option> listModel = (DefaultListModel<Option>) ((JList<?>) component).getModel();
for (int i = 0; i < listModel.size(); i++) {
options.add(listModel.get(i));
}
}
optionMap.put(key, options);
}
ready = true;
setVisible(false);
dispose();
});
}
public void addComboBox(String name, Option[] options, Parameter... parameters) {
addComboBox(name, options, false, parameters);
}
public void addComboBox(String name, Option[] options, boolean multiple, Parameter... parameters) {
JComboBox<Option> comboBox = new JComboBox<>();
for (Option option : options) {
comboBox.addItem(option);
}
JLabel label = new JLabel(name);
label.setLabelFor(comboBox);
JPanel parametersPanel = new JPanel();
GridBagLayout parametersPanelLayout = new GridBagLayout();
GridBagConstraints c = new GridBagConstraints();
c.insets = new Insets(0, 6, 6, 6);
parametersPanel.setLayout(parametersPanelLayout);
DefaultListModel<Option> optionsList = new DefaultListModel<>();
JList<Option> optionsJList = new JList<>(optionsList);
for (Parameter parameter : parameters) {
JLabel pLabel = new JLabel(parameter.getName());
pLabel.setLabelFor(parameter.getComponent());
componentMap.put(name + "." + parameter.getName(), parameter.getComponent());
c.fill = GridBagConstraints.HORIZONTAL;
c.weightx = 1;
c.gridwidth = 1;
parametersPanelLayout.setConstraints(pLabel, c);
parametersPanel.add(pLabel);
c.gridwidth = GridBagConstraints.REMAINDER;
parametersPanelLayout.setConstraints(parameter.getComponent(), c);
parametersPanel.add(parameter.getComponent());
}
if (multiple) {
c.gridwidth = 2;
JButton button = new JButton("Add");
button.addActionListener((e) -> {
Option option = (Option) comboBox.getSelectedItem();
assert option != null;
option = option.clone();
if (option.getName().equals("custom")) {
JTextField customField = (JTextField) componentMap.get(name + ".Custom");
MethodProvider.log(customField);
if (customField != null) {
option.setCustomName(customField.getText());
}
}
for (Parameter parameter : parameters) {
Component component = parameter.getComponent();
String value = "";
if (component instanceof JTextField) {
value = ((JTextField) component).getText();
} else if (component instanceof JCheckBox) {
if (((JCheckBox) component).isSelected()) {
value = "true";
} else {
value = "false";
}
}
option.setParameter(parameter.getName(), value);
}
optionsList.addElement(option);
});
parametersPanelLayout.setConstraints(button, c);
parametersPanel.add(button);
}
constraints.fill = GridBagConstraints.HORIZONTAL;
constraints.anchor = GridBagConstraints.NORTH;
constraints.gridwidth = 1;
layout.setConstraints(label, constraints);
getContentPane().add(label);
if (multiple) {
JPanel panel = new JPanel();
GridBagLayout panelLayout = new GridBagLayout();
GridBagConstraints panelConstraints = new GridBagConstraints();
panel.setLayout(panelLayout);
panelConstraints.weightx = 1;
panelConstraints.fill = GridBagConstraints.HORIZONTAL;
panelConstraints.gridwidth = GridBagConstraints.REMAINDER;
panelLayout.setConstraints(comboBox, panelConstraints);
panel.add(comboBox);
panelConstraints.fill = GridBagConstraints.BOTH;
panelLayout.setConstraints(optionsJList, panelConstraints);
panel.add(optionsJList);
layout.setConstraints(panel, constraints);
getContentPane().add(panel);
} else {
layout.setConstraints(comboBox, constraints);
getContentPane().add(comboBox);
}
constraints.gridwidth = GridBagConstraints.REMAINDER;
layout.setConstraints(parametersPanel, constraints);
getContentPane().add(parametersPanel);
if (multiple) {
componentMap.put(name, optionsJList);
} else {
componentMap.put(name, comboBox);
}
}
public boolean isReady() {
return ready;
}
public Option getOption(String name) {
return optionMap.get(name).get(0);
}
public java.util.List<Option> getOptions(String name) {
return optionMap.get(name);
}
}

View File

@ -0,0 +1,55 @@
package io.reisub.dreambot.util.ui;
import java.util.HashMap;
import java.util.Map;
public class Option implements Cloneable {
private final String name, info;
private final Map<String, String> parameters;
private String customName = "";
public Option(String name) {
this(name, "");
}
public Option(String name, String info) {
this.name = name;
this.info = info;
parameters = new HashMap<>();
}
public String getName() {
return name;
}
@Override
public String toString() {
if (!customName.equals("")) {
return customName;
}
if (info.equals("")) {
return name;
} else {
return name + " (" + info + ")";
}
}
public void setCustomName(String customName) {
this.customName = customName;
}
public void setParameter(String key, String value) {
parameters.put(key, value);
}
@Override
public Option clone() {
try {
return (Option) super.clone();
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
}

View File

@ -0,0 +1,29 @@
package io.reisub.dreambot.util.ui;
import javax.swing.*;
import java.awt.*;
public class Parameter {
private final String name;
private final Component component;
public Parameter(String name) {
JTextField textField = new JTextField(10);
this.name = name;
this.component = textField;
}
public Parameter(String name, Component component) {
this.name = name;
this.component = component;
}
public String getName() {
return name;
}
public Component getComponent() {
return component;
}
}

View File

@ -152,6 +152,8 @@ public class UI implements MouseListener {
}
public void drawString(String s, Color color, int xPadding) {
if (hide) return;
xPadding += 5;
int yPadding = 35;
int lineSpacing = 20;