Initial commit
This commit is contained in:
52
miner/miner.gradle.kts
Normal file
52
miner/miner.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Miner" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Mines stuff" // This is the description that is used in the external plugin manager panel
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes(mapOf(
|
||||
"Plugin-Version" to project.version,
|
||||
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
|
||||
"Plugin-Provider" to project.extra["PluginProvider"],
|
||||
"Plugin-Description" to project.extra["PluginDescription"],
|
||||
"Plugin-Dependencies" to
|
||||
arrayOf(
|
||||
nameToId("Chaos Util"),
|
||||
nameToId("iUtils")
|
||||
).joinToString(),
|
||||
"Plugin-License" to project.extra["PluginLicense"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
78
miner/src/main/java/io/reisub/openosrs/miner/Config.java
Normal file
78
miner/src/main/java/io/reisub/openosrs/miner/Config.java
Normal file
@ -0,0 +1,78 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.miner;
|
||||
|
||||
import io.reisub.openosrs.util.enums.Log;
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("chaosminer")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "3t4g",
|
||||
name = "3t4g mining",
|
||||
description = "Enable three tick, four granite mining.",
|
||||
position = 0
|
||||
)
|
||||
default boolean threeTickFourGranite() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "3t4s",
|
||||
name = "3t4s mining",
|
||||
description = "Enable three tick, four sandstone mining.",
|
||||
position = 1
|
||||
)
|
||||
default boolean threeTickFourSandstone() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "prepareBirdhouseRun",
|
||||
name = "Prepare for birdhouse run",
|
||||
description = "When enabled, will teleport away when out of water and withdraw materials needed for a birdhouse run. Either do the run manually or use the Chaos Birdhouse plugin.",
|
||||
position = 10
|
||||
)
|
||||
default boolean prepareBirdhouseRun() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "birdhouseLogs",
|
||||
name = "Logs",
|
||||
description = "What log type to take out of the bank for birdhouse runs.",
|
||||
hidden = true,
|
||||
unhide = "prepareBirdhouseRun",
|
||||
position = 11
|
||||
)
|
||||
default Log birdhouseLogs() { return Log.YEW; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
147
miner/src/main/java/io/reisub/openosrs/miner/Miner.java
Normal file
147
miner/src/main/java/io/reisub/openosrs/miner/Miner.java
Normal file
@ -0,0 +1,147 @@
|
||||
package io.reisub.openosrs.miner;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.miner.tasks.*;
|
||||
import io.reisub.openosrs.util.CScript;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.util.tasks.Run;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Miner",
|
||||
description = "Mines stuff",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Miner extends CScript {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean startedCycle;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean interrupted;
|
||||
|
||||
private int ticks;
|
||||
|
||||
@Getter
|
||||
private int ticksWithoutSuccess;
|
||||
|
||||
private Mine mineTask;
|
||||
private ScheduledExecutorService executor;
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
ticks = 0;
|
||||
|
||||
tasks.add(runTask);
|
||||
addTask(TpAway.class);
|
||||
addTask(PrepareMining.class);
|
||||
addTask(PrepareBirdhouseRun.class);
|
||||
//addTask(Drop.class);
|
||||
if (!config.threeTickFourSandstone() && !config.threeTickFourGranite()) {
|
||||
addTask(Mine.class);
|
||||
} else {
|
||||
mineTask = injector.getInstance(Mine.class);
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
addTask(WalkToStartPosition.class);
|
||||
}
|
||||
addTask(Deposit.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
mineTask = null;
|
||||
executor = null;
|
||||
}
|
||||
|
||||
public boolean hasWaterSkins() {
|
||||
return game.inventory().withId(
|
||||
ItemID.WATERSKIN1,
|
||||
ItemID.WATERSKIN2,
|
||||
ItemID.WATERSKIN3,
|
||||
ItemID.WATERSKIN4
|
||||
).exists();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (mineTask != null && executor != null) {
|
||||
if (ticksWithoutSuccess++ > 15) {
|
||||
ticks = -6;
|
||||
ticksWithoutSuccess = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
executor.schedule(() -> {
|
||||
ticks++;
|
||||
if (ticks == 3) ticks = 0;
|
||||
|
||||
if (ticks == 0 && mineTask.validate()) {
|
||||
mineTask.execute();
|
||||
}
|
||||
}, calc.random(245, 250), TimeUnit.MILLISECONDS);
|
||||
//}, calc.random(245, 250), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
game.inventory().withNamePart("Granite").drop();
|
||||
if (game.inventory().withId(ItemID.WATERSKIN0).exists()) {
|
||||
game.inventory().withId(ItemID.WATERSKIN0).drop();
|
||||
interrupted = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage event) {
|
||||
if (event.getMessage().equals("You take a drink of water.")) {
|
||||
interrupted = true;
|
||||
}
|
||||
|
||||
if (event.getMessage().startsWith("You manage to quarry")) {
|
||||
ticksWithoutSuccess = 0;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,10 @@
|
||||
package io.reisub.openosrs.miner;
|
||||
|
||||
import lombok.Value;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
@Value
|
||||
public class RockPosition {
|
||||
Position rock;
|
||||
Position interactFrom;
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.miner.Config;
|
||||
import io.reisub.openosrs.miner.Miner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Deposit extends Task {
|
||||
@Inject
|
||||
private Miner plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Depositing grinder";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (!plugin.hasWaterSkins() && game.inventory().withNamePart("Sandstone").exists()) return true;
|
||||
|
||||
return game.inventory().full()
|
||||
&& !game.inventory().withNamePart("Granite").exists()
|
||||
&& game.localPlayer().position().regionID() == 12589
|
||||
&& (game.localPlayer().isIdle() || plugin.isInterrupted());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (plugin.isInterrupted()) {
|
||||
plugin.setInterrupted(false);
|
||||
}
|
||||
|
||||
if (config.threeTickFourGranite() || config.threeTickFourSandstone()) {
|
||||
walking.setRun(false);
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
iObject grinder = game.objects().withName("Grinder").nearest();
|
||||
if (grinder == null) return;
|
||||
|
||||
grinder.interact(0);
|
||||
plugin.setStartedCycle(false);
|
||||
game.waitUntil(() -> !game.inventory().withNamePart("Sandstone").exists() || plugin.isInterrupted(), 10);
|
||||
}
|
||||
}
|
37
miner/src/main/java/io/reisub/openosrs/miner/tasks/Drop.java
Normal file
37
miner/src/main/java/io/reisub/openosrs/miner/tasks/Drop.java
Normal file
@ -0,0 +1,37 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
public class Drop extends Task {
|
||||
private Instant lastDrop = Instant.EPOCH;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Dropping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return Duration.between(lastDrop, Instant.now()).getSeconds() > 1
|
||||
&& (game.inventory().withNamePart("Granite").exists()
|
||||
|| game.inventory().withId(ItemID.WATERSKIN0).exists());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
boolean inventoryIsFull = game.inventory().full();
|
||||
|
||||
game.inventory().withNamePart("Granite").drop();
|
||||
game.inventory().withId(ItemID.WATERSKIN0).drop();
|
||||
|
||||
if (inventoryIsFull) {
|
||||
game.waitUntil(() -> !game.inventory().full(), 5);
|
||||
}
|
||||
|
||||
lastDrop = Instant.now();
|
||||
}
|
||||
}
|
175
miner/src/main/java/io/reisub/openosrs/miner/tasks/Mine.java
Normal file
175
miner/src/main/java/io/reisub/openosrs/miner/tasks/Mine.java
Normal file
@ -0,0 +1,175 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.miner.Config;
|
||||
import io.reisub.openosrs.miner.Miner;
|
||||
import io.reisub.openosrs.miner.RockPosition;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
|
||||
public class Mine extends Task {
|
||||
@Inject
|
||||
private Miner plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
private final List<Position> positions = new ArrayList<>() {
|
||||
{
|
||||
add(new Position(3167, 2913, 0));
|
||||
add(new Position(3166, 2913, 0));
|
||||
add(new Position(3167, 2915, 0));
|
||||
add(new Position(3166, 2915, 0));
|
||||
}
|
||||
};
|
||||
|
||||
private final Queue<Position> threeTickGranitePositions = new LinkedList<>() {
|
||||
{
|
||||
add(new Position(3165, 2908, 0));
|
||||
add(new Position(3165, 2909, 0));
|
||||
add(new Position(3165, 2910, 0));
|
||||
add(new Position(3167, 2911, 0));
|
||||
}
|
||||
};
|
||||
|
||||
private final Position sandstoneStartPosition = new Position(3165, 2914, 0);
|
||||
private final Queue<RockPosition> threeTickSandstonePositions = new LinkedList<>() {
|
||||
{
|
||||
add(new RockPosition(new Position(3166, 2913, 0), new Position(3166, 2914, 0)));
|
||||
add(new RockPosition(new Position(3164, 2915, 0), new Position(3165, 2915, 0)));
|
||||
add(new RockPosition(new Position(3164, 2914, 0), new Position(3165, 2914, 0)));
|
||||
add(new RockPosition(new Position(3167, 2913, 0), new Position(3166, 2914, 0)));
|
||||
}
|
||||
};
|
||||
|
||||
private RockPosition currentRockPosition;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Mining";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (isThreeTick()
|
||||
&& !plugin.isStartedCycle()
|
||||
&& !game.localPlayer().position().equals(sandstoneStartPosition)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return !game.inventory().full()
|
||||
&& plugin.hasWaterSkins()
|
||||
&& game.localPlayer().position().regionID() == 12589
|
||||
&& (game.localPlayer().isIdle() || isThreeTick());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject rock = getRock();
|
||||
|
||||
if (isThreeTick() && !walking.isRunning()) {
|
||||
walking.setRun(true);
|
||||
}
|
||||
|
||||
if (isThreeTick() && plugin.isStartedCycle()) {
|
||||
InventoryItem knife = game.inventory().withId(ItemID.KNIFE).first();
|
||||
InventoryItem logs = game.inventory().withId(ItemID.TEAK_LOGS, ItemID.MAHOGANY_LOGS).first();
|
||||
if (knife == null || logs == null) return;
|
||||
|
||||
knife.useOn(logs);
|
||||
if (rock == null) {
|
||||
game.walkUtils.sceneWalk(currentRockPosition.getInteractFrom(), 0, 0);
|
||||
}
|
||||
}
|
||||
|
||||
while (rock == null && isThreeTick()) {
|
||||
rock = game.objects().withPosition(currentRockPosition.getRock()).withId(11386, 11387).first();
|
||||
}
|
||||
|
||||
if (rock == null || game.inventory().full()) return;
|
||||
rock.interact(0);
|
||||
|
||||
if (!isThreeTick()) {
|
||||
iObject finalRock = rock;
|
||||
game.waitUntil(() -> {
|
||||
iObject emptyRock = game.objects().withPosition(finalRock.position()).withId(11390, 11391).first();
|
||||
return emptyRock != null;
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
private iObject getRock() {
|
||||
if (isThreeTick()) {
|
||||
if (!plugin.isStartedCycle()) {
|
||||
plugin.setStartedCycle(true);
|
||||
resetQueue();
|
||||
}
|
||||
|
||||
Position position;
|
||||
|
||||
if (config.threeTickFourSandstone()) {
|
||||
currentRockPosition = threeTickSandstonePositions.poll();
|
||||
threeTickSandstonePositions.add(currentRockPosition);
|
||||
position = currentRockPosition.getRock();
|
||||
} else {
|
||||
position = threeTickGranitePositions.poll();
|
||||
threeTickGranitePositions.add(position);
|
||||
}
|
||||
|
||||
return game.objects().withPosition(position).withId(11386, 11387).first();
|
||||
} else {
|
||||
List<iObject> rocks = game.objects().withId(11386, 11387).filter(o -> {
|
||||
for (Position p : positions) {
|
||||
if (p.equals(o.position())) return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}).all();
|
||||
|
||||
if (rocks == null || rocks.isEmpty()) return null;
|
||||
|
||||
int x = game.localPlayer().position().x;
|
||||
|
||||
for (iObject r : rocks) {
|
||||
if (r.position().x == x) {
|
||||
return r;
|
||||
}
|
||||
}
|
||||
|
||||
return rocks.get(calc.random(0, rocks.size()));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean isThreeTick() {
|
||||
return config.threeTickFourGranite() || config.threeTickFourSandstone();
|
||||
}
|
||||
|
||||
private void resetQueue() {
|
||||
if (config.threeTickFourSandstone()) {
|
||||
resetThreeTickSandstone();
|
||||
} else {
|
||||
resetThreeTickGranite();
|
||||
}
|
||||
}
|
||||
|
||||
private void resetThreeTickGranite() {
|
||||
threeTickGranitePositions.clear();
|
||||
threeTickGranitePositions.add(new Position(3165, 2908, 0));
|
||||
threeTickGranitePositions.add(new Position(3165, 2909, 0));
|
||||
threeTickGranitePositions.add(new Position(3165, 2910, 0));
|
||||
threeTickGranitePositions.add(new Position(3167, 2911, 0));
|
||||
}
|
||||
|
||||
private void resetThreeTickSandstone() {
|
||||
threeTickSandstonePositions.clear();
|
||||
threeTickSandstonePositions.add(new RockPosition(new Position(3166, 2913, 0), new Position(3166, 2914, 0)));
|
||||
threeTickSandstonePositions.add(new RockPosition(new Position(3164, 2915, 0), new Position(3165, 2915, 0)));
|
||||
threeTickSandstonePositions.add(new RockPosition(new Position(3164, 2914, 0), new Position(3165, 2914, 0)));
|
||||
threeTickSandstonePositions.add(new RockPosition(new Position(3167, 2913, 0), new Position(3166, 2914, 0)));
|
||||
}
|
||||
}
|
@ -0,0 +1,187 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.miner.Config;
|
||||
import io.reisub.openosrs.miner.Miner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.ItemQuantity;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.Set;
|
||||
|
||||
public class PrepareBirdhouseRun extends Task {
|
||||
@Inject
|
||||
private Miner plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
private Instant lastBank = Instant.EPOCH;
|
||||
|
||||
private final Set<Integer> PENDANTS = Set.of(
|
||||
ItemID.DIGSITE_PENDANT_1,
|
||||
ItemID.DIGSITE_PENDANT_2,
|
||||
ItemID.DIGSITE_PENDANT_3,
|
||||
ItemID.DIGSITE_PENDANT_4,
|
||||
ItemID.DIGSITE_PENDANT_5
|
||||
);
|
||||
|
||||
private final Set<Integer> BIRDHOUSE_SEEDS = Set.of(
|
||||
ItemID.BARLEY_SEED,
|
||||
ItemID.HAMMERSTONE_SEED,
|
||||
ItemID.ASGARNIAN_SEED,
|
||||
ItemID.JUTE_SEED,
|
||||
ItemID.YANILLIAN_SEED,
|
||||
ItemID.KRANDORIAN_SEED
|
||||
);
|
||||
|
||||
private final Set<Integer> RINGS = Set.of(
|
||||
ItemID.RING_OF_DUELING1,
|
||||
ItemID.RING_OF_DUELING2,
|
||||
ItemID.RING_OF_DUELING3,
|
||||
ItemID.RING_OF_DUELING4,
|
||||
ItemID.RING_OF_DUELING5,
|
||||
ItemID.RING_OF_DUELING6,
|
||||
ItemID.RING_OF_DUELING7,
|
||||
ItemID.RING_OF_DUELING8
|
||||
);
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Preparing for birdhouse run";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return Duration.between(lastBank, Instant.now()).getSeconds() > 5
|
||||
&& game.localPlayer().position().regionID() == 9776
|
||||
&& (
|
||||
!game.inventory().withId(PENDANTS).exists()
|
||||
|| !game.inventory().withId(ItemID.CHISEL).exists()
|
||||
|| !game.inventory().withId(ItemID.HAMMER).exists()
|
||||
|| game.inventory().withId(config.birdhouseLogs().getId()).count() < 4
|
||||
|| game.inventory().withId(BIRDHOUSE_SEEDS).quantity() < 40
|
||||
|| (!game.inventory().withId(RINGS).exists() && !game.equipment().withId(RINGS).exists())
|
||||
);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!bank.isOpen()) {
|
||||
iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck").nearest();
|
||||
if (bankObj == null) return;
|
||||
|
||||
bankObj.interact(0);
|
||||
game.waitUntil(() -> bank.isOpen(), 15);
|
||||
}
|
||||
|
||||
if (!game.inventory().all().isEmpty()) {
|
||||
bank.depositInventory();
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
withdrawPendant();
|
||||
withdrawRing();
|
||||
withdrawTools();
|
||||
withdrawLogs();
|
||||
withdrawSeeds();
|
||||
|
||||
bank.close();
|
||||
game.sleepDelay();
|
||||
|
||||
game.inventory().withId(RINGS).findFirst().ifPresent((ring) -> {
|
||||
game.waitUntil(() -> !bank.isOpen(), 5);
|
||||
ring.interact(0);
|
||||
game.waitUntil(() -> !game.inventory().withId(RINGS).exists(), 5);
|
||||
});
|
||||
|
||||
teleportToFossilIsland();
|
||||
|
||||
lastBank = Instant.now();
|
||||
}
|
||||
|
||||
private void withdrawPendant() {
|
||||
if (!game.inventory().withId(PENDANTS).exists()) {
|
||||
|
||||
for (Integer id : PENDANTS) {
|
||||
if (bank.contains(id)) {
|
||||
bank.withdraw(id, 1, false);
|
||||
game.sleepDelay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void withdrawRing() {
|
||||
if (!game.equipment().withId(RINGS).exists() && !game.inventory().withId(RINGS).exists()) {
|
||||
for (Integer id : RINGS) {
|
||||
if (bank.contains(id)) {
|
||||
bank.withdraw(id, 1, false);
|
||||
game.sleepDelay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void withdrawTools() {
|
||||
if (!game.inventory().withId(ItemID.CHISEL).exists()) {
|
||||
bank.withdraw(ItemID.CHISEL, 1, false);
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
if (!game.inventory().withId(ItemID.HAMMER).exists()) {
|
||||
bank.withdraw(ItemID.HAMMER, 1, false);
|
||||
game.sleepDelay();
|
||||
}
|
||||
}
|
||||
|
||||
private void withdrawLogs() {
|
||||
int requiredLogs = 4 - (int) game.inventory().withId(config.birdhouseLogs().getId()).count();
|
||||
|
||||
if (requiredLogs > 0) {
|
||||
bank.withdraw(config.birdhouseLogs().getId(), requiredLogs, false);
|
||||
}
|
||||
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
private void withdrawSeeds() {
|
||||
if (game.inventory().withId(BIRDHOUSE_SEEDS).quantity() < 40) {
|
||||
for (Integer id : BIRDHOUSE_SEEDS) {
|
||||
if (bank.contains(new ItemQuantity(id, 40))) {
|
||||
bank.withdraw(id, 40, false);
|
||||
game.sleepDelay();
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void teleportToFossilIsland() {
|
||||
if (!game.waitUntil(() -> (
|
||||
game.inventory().withId(PENDANTS).exists()
|
||||
&& game.inventory().withId(ItemID.CHISEL).exists()
|
||||
&& game.inventory().withId(ItemID.HAMMER).exists()
|
||||
&& game.inventory().withId(config.birdhouseLogs().getId()).count() >= 4
|
||||
&& game.inventory().withId(BIRDHOUSE_SEEDS).quantity() >= 40
|
||||
&& (game.inventory().withId(RINGS).exists() || game.equipment().withId(RINGS).exists())
|
||||
), 5)) return;
|
||||
|
||||
game.inventory().withId(PENDANTS).findFirst().ifPresent((pendant) -> {
|
||||
pendant.interact("Rub");
|
||||
game.tick();
|
||||
});
|
||||
|
||||
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.OPTIONS_CHAT, 5);
|
||||
|
||||
chatbox.chooseOption(2);
|
||||
game.waitUntil(() -> game.localPlayer().position().regionID() == 14908, 15);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,41 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
public class PrepareMining extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Preparing for mining";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 14908
|
||||
&& game.inventory().all().isEmpty()
|
||||
&& !bank.isOpen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!bank.isOpen()) {
|
||||
iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck").nearest();
|
||||
if (bankObj == null) return;
|
||||
|
||||
bankObj.interact(0);
|
||||
game.waitUntil(() -> bank.isOpen(), 15);
|
||||
}
|
||||
|
||||
bank.withdraw(ItemID.KNIFE, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.TEAK_LOGS, 1, false);
|
||||
|
||||
bank.withdraw(ItemID.WATERSKIN4, 10, false);
|
||||
game.tick();
|
||||
|
||||
bank.close();
|
||||
game.waitUntil(() -> !bank.isOpen(), 5);
|
||||
}
|
||||
}
|
@ -0,0 +1,38 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.miner.Config;
|
||||
import io.reisub.openosrs.miner.Miner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.EquipmentItem;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class TpAway extends Task {
|
||||
@Inject
|
||||
private Miner plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Teleporting away from quarry";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return config.prepareBirdhouseRun()
|
||||
&& !plugin.hasWaterSkins()
|
||||
&& !game.inventory().withNamePart("Sandstone").exists()
|
||||
&& game.localPlayer().position().regionID() == 12589;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
EquipmentItem ring = game.equipment().withNamePart("Ring of dueling").first();
|
||||
if (ring == null) return;
|
||||
|
||||
ring.interact("Castle Wars");
|
||||
game.waitUntil(() -> game.localPlayer().position().regionID() == 9776);
|
||||
}
|
||||
}
|
@ -0,0 +1,22 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
|
||||
public class TpToQuarry extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Teleporting to Quarry or Al-Kharid";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 14908
|
||||
&& game.equipment().withNamePart("Ring of dueling").exists()
|
||||
&& game.equipment().withName("Camulet").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
|
||||
}
|
||||
}
|
21
miner/src/main/java/io/reisub/openosrs/miner/tasks/Wait.java
Normal file
21
miner/src/main/java/io/reisub/openosrs/miner/tasks/Wait.java
Normal file
@ -0,0 +1,21 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
public class Wait extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Waiting";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return !game.inventory().withId(ItemID.WATERSKIN1, ItemID.WATERSKIN2, ItemID.WATERSKIN3, ItemID.WATERSKIN4).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.tick(3);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package io.reisub.openosrs.miner.tasks;
|
||||
|
||||
import io.reisub.openosrs.miner.Config;
|
||||
import io.reisub.openosrs.miner.Miner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class WalkToStartPosition extends Task {
|
||||
@Inject
|
||||
private Miner plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
public static final Position sandstoneStartPosition = new Position(3165, 2914, 0);
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Walking to starting position";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return config.threeTickFourSandstone()
|
||||
&& !plugin.isStartedCycle()
|
||||
&& !game.localPlayer().position().equals(sandstoneStartPosition)
|
||||
&& game.localPlayer().position().regionID() == 12589
|
||||
&& !game.inventory().withNamePart("Sandstone").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (game.energy() > 25) {
|
||||
walking.setRun(true);
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
walking.walkTo(sandstoneStartPosition);
|
||||
game.waitUntil(() -> game.localPlayer().position().equals(sandstoneStartPosition));
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user