Initial commit
This commit is contained in:
52
birdhouse/birdhouse.gradle.kts
Normal file
52
birdhouse/birdhouse.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 Birdhouse" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Automatic bird massacre" // 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,103 @@
|
||||
package io.reisub.openosrs.birdhouse;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.birdhouse.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.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.GameTick;
|
||||
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 net.runelite.client.plugins.iutils.scene.Position;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Birdhouse",
|
||||
description = "Automatic bird massacre",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Birdhouse extends CScript {
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Getter
|
||||
private Map<BirdhouseSpace, Instant> birdhouseTimers;
|
||||
|
||||
@Getter
|
||||
private final Position islandPosition = new Position(3769, 3898, 0);
|
||||
|
||||
private final Position hillHousePosition = new Position(3764, 3869, 1);
|
||||
|
||||
private boolean active;
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
active = true;
|
||||
|
||||
birdhouseTimers = new HashMap<>();
|
||||
birdhouseTimers.put(BirdhouseSpace.MEADOW_NORTH, Instant.EPOCH);
|
||||
birdhouseTimers.put(BirdhouseSpace.MEADOW_SOUTH, Instant.EPOCH);
|
||||
birdhouseTimers.put(BirdhouseSpace.VALLEY_NORTH, Instant.EPOCH);
|
||||
birdhouseTimers.put(BirdhouseSpace.VALLEY_SOUTH, Instant.EPOCH);
|
||||
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
tasks.add(runTask);
|
||||
addTask(AddSeeds.class);
|
||||
addTask(BankSpores.class);
|
||||
addTask(BuildBirdhouse.class);
|
||||
addTask(CraftBirdhouse.class);
|
||||
addTask(EmptyBirdhouse.class);
|
||||
addTask(GetTools.class);
|
||||
addTask(GoToBirdhouse.class);
|
||||
addTask(GoToIsland.class);
|
||||
addTask(GoToMushroomMeadow.class);
|
||||
addTask(GoToVerdantValley.class);
|
||||
addTask(PickupSeed.class);
|
||||
addTask(PlantSeaweed.class);
|
||||
addTask(NoteSeaweed.class);
|
||||
addTask(HarvestSeaweed.class);
|
||||
addTask(Deposit.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
super.onStop();
|
||||
active = false;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (isLoggedIn()
|
||||
&& game.localPlayer().position().regionID() == 14908) {
|
||||
if (!active && game.localPlayer().position().distanceTo(hillHousePosition) < 10 && game.inventory().withNamePart("logs").count() == 4) {
|
||||
execute();
|
||||
} else if (active && game.inventory().all().isEmpty() && !bank.isOpen() && game.localPlayer().position().distanceTo(islandPosition) < 10) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasRecentlyBeenEmptied(BirdhouseSpace space) {
|
||||
return Duration.between(getBirdhouseTimers().get(space), Instant.now()).getSeconds() < 2000;
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package io.reisub.openosrs.birdhouse;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.VarPlayer;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BirdhouseSpace {
|
||||
// declaration order should not be changed, this is the order we do the birdhouses in
|
||||
VALLEY_SOUTH(VarPlayer.BIRD_HOUSE_VALLEY_SOUTH, new Position(3763, 3755, 0)),
|
||||
VALLEY_NORTH(VarPlayer.BIRD_HOUSE_VALLEY_NORTH, new Position(3768, 3761, 0)),
|
||||
MEADOW_NORTH(VarPlayer.BIRD_HOUSE_MEADOW_NORTH, new Position(3677, 3882, 0)),
|
||||
MEADOW_SOUTH(VarPlayer.BIRD_HOUSE_MEADOW_SOUTH, new Position(3679, 3815, 0));
|
||||
|
||||
// 3681 3819 == near south meadow
|
||||
|
||||
private final VarPlayer varp;
|
||||
private final Position position;
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package io.reisub.openosrs.birdhouse;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BirdhouseState {
|
||||
SEEDED(),
|
||||
BUILT(),
|
||||
EMPTY(),
|
||||
UNKNOWN();
|
||||
|
||||
public static BirdhouseState fromVarpValue(int varp) {
|
||||
if (varp < 0 || varp > BirdhouseType.values().length * 3) {
|
||||
return UNKNOWN;
|
||||
} else if (varp == 0) {
|
||||
return EMPTY;
|
||||
} else if (varp % 3 == 0) {
|
||||
return SEEDED;
|
||||
} else {
|
||||
return BUILT;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,34 @@
|
||||
package io.reisub.openosrs.birdhouse;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BirdhouseType {
|
||||
NORMAL("Bird House", ItemID.BIRD_HOUSE),
|
||||
OAK("Oak Bird House", ItemID.OAK_BIRD_HOUSE),
|
||||
WILLOW("Willow Bird House", ItemID.WILLOW_BIRD_HOUSE),
|
||||
TEAK("Teak Bird House", ItemID.TEAK_BIRD_HOUSE),
|
||||
MAPLE("Maple Bird House", ItemID.MAPLE_BIRD_HOUSE),
|
||||
MAHOGANY("Mahogany Bird House", ItemID.MAHOGANY_BIRD_HOUSE),
|
||||
YEW("Yew Bird House", ItemID.YEW_BIRD_HOUSE),
|
||||
MAGIC("Magic Bird House", ItemID.MAGIC_BIRD_HOUSE),
|
||||
REDWOOD("Redwood Bird House", ItemID.REDWOOD_BIRD_HOUSE);
|
||||
|
||||
private final String name;
|
||||
private final int itemID;
|
||||
|
||||
@Nullable
|
||||
static BirdhouseType fromVarpValue(int varp) {
|
||||
int index = (varp - 1) / 3;
|
||||
|
||||
if (varp <= 0 || index >= values().length) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return values()[index];
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
/*
|
||||
* 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.birdhouse;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("chaosbirdhouse")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "farmSeaweed",
|
||||
name = "Farm seaweed",
|
||||
description = "Harvest and plant seaweed after a birdhouse run.",
|
||||
position = 0
|
||||
)
|
||||
default boolean farmSeaweed() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Force Start/Stop",
|
||||
description = "The script should automatically start and stop. Use this button for manual overrides.",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
@ -0,0 +1,29 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
public class AddSeeds extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Adding seeds to birdhouse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.objects().filter(iObject -> iObject.name().endsWith("(empty)")).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject birdhouse = game.objects().filter(iObject -> iObject.name().endsWith("(empty)")).nearest();
|
||||
InventoryItem seeds = game.inventory().withNamePart("seed").first();
|
||||
if (birdhouse == null || seeds == null) return;
|
||||
|
||||
int quantity = seeds.quantity();
|
||||
seeds.useOn(birdhouse);
|
||||
|
||||
game.waitUntil(() -> game.inventory().withNamePart("seed").first() == null || game.inventory().withNamePart("seed").first().quantity() < quantity, 5);
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.birdhouse.Birdhouse;
|
||||
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.ui.Chatbox;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class BankSpores extends Task {
|
||||
@Inject
|
||||
private Birdhouse plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Depositing everything and withdrawing spores";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().distanceTo(plugin.getIslandPosition()) < 10
|
||||
&& game.inventory().withNamePart("nest").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
for (InventoryItem nest : game.inventory().withNamePart("nest").withAction("Search").all()) {
|
||||
nest.interact("Search");
|
||||
game.tick();
|
||||
}
|
||||
|
||||
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.depositInventory();
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.SEAWEED_SPORE, 2, false);
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.FISHBOWL_HELMET, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.DIVING_APPARATUS, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.close();
|
||||
game.waitUntil(() -> !bank.isOpen(), 5);
|
||||
|
||||
game.inventory().withId(ItemID.FISHBOWL_HELMET).findFirst().ifPresent((helmet) -> helmet.interact("Wear"));
|
||||
game.tick();
|
||||
|
||||
game.inventory().withId(ItemID.DIVING_APPARATUS).findFirst().ifPresent((apparatus) -> apparatus.interact("Wear"));
|
||||
game.tick();
|
||||
iObject rowboat = game.objects().withName("Rowboat").nearest();
|
||||
if (rowboat == null) return;
|
||||
|
||||
rowboat.interact("Dive");
|
||||
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.OPTIONS_CHAT
|
||||
|| game.localPlayer().position().regionID() == 15008, 10);
|
||||
|
||||
if (chatbox.chatState() == Chatbox.ChatState.OPTIONS_CHAT) {
|
||||
chatbox.chooseOption(1);
|
||||
game.waitUntil(() -> game.localPlayer().position().regionID() == 15008, 10);
|
||||
}
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
public class BuildBirdhouse extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Building birdhouse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.inventory().withNamePart("bird house").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject space = game.objects().withName("Space").withAction("Build").nearest();
|
||||
if (space == null) return;
|
||||
|
||||
space.interact("Build");
|
||||
game.waitUntil(() -> !game.inventory().withNamePart("bird house").exists(), 5);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
|
||||
public class CraftBirdhouse extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Crafting birdhouse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.inventory().withId(ItemID.CLOCKWORK).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
InventoryItem chisel = game.inventory().withId(ItemID.CHISEL).first();
|
||||
InventoryItem logs = game.inventory().withNamePart("logs").first();
|
||||
if (chisel == null || logs == null) return;
|
||||
|
||||
chisel.useOn(logs);
|
||||
game.waitUntil(() -> !game.inventory().withId(ItemID.CLOCKWORK).exists(), 5);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,93 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.birdhouse.Birdhouse;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Deposit extends Task {
|
||||
@Inject
|
||||
private Birdhouse plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Depositing everything";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 15008
|
||||
&& game.objects().withName("Seaweed").count() == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iNPC leprechaun = game.npcs().withName("Tool Leprechaun").first();
|
||||
if (leprechaun == null) return;
|
||||
|
||||
leprechaun.interact("Exchange");
|
||||
game.waitUntil(() -> game.widget(125, 0) != null, 30);
|
||||
game.tick();
|
||||
|
||||
iWidget dibber = game.widget(126, 2);
|
||||
if (dibber == null) return;
|
||||
dibber.interact("Store-1");
|
||||
game.tick();
|
||||
|
||||
iWidget spade = game.widget(126, 3);
|
||||
if (spade == null) return;
|
||||
spade.interact("Store-1");
|
||||
game.tick();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
iWidget bucket = game.widget(126, 9);
|
||||
if (bucket == null) return;
|
||||
bucket.interact("Store-1");
|
||||
game.sleepDelay();
|
||||
}
|
||||
game.tick();
|
||||
|
||||
iWidget close = game.widget(125, 1, 11);
|
||||
if (close == null) return;
|
||||
close.interact("Close");
|
||||
|
||||
game.waitUntil(() -> game.widget(125, 0) == null, 5);
|
||||
|
||||
iObject rope = game.objects().withName("Anchor rope").first();
|
||||
if (rope == null) return;
|
||||
|
||||
rope.interact("Climb");
|
||||
game.tick();
|
||||
|
||||
if (game.inventory().withAction("Wear").exists()) {
|
||||
for (InventoryItem gear : game.inventory().withAction("Wear").all()) {
|
||||
gear.interact("Wear");
|
||||
game.tick(3);
|
||||
}
|
||||
|
||||
game.tick();
|
||||
rope.interact("Climb");
|
||||
}
|
||||
|
||||
game.waitUntil(() -> game.localPlayer().position().regionID() == 14908, 30);
|
||||
game.tick();
|
||||
|
||||
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.depositInventory();
|
||||
game.sleepDelay();
|
||||
|
||||
bank.close();
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.birdhouse.Birdhouse;
|
||||
import io.reisub.openosrs.birdhouse.BirdhouseSpace;
|
||||
import io.reisub.openosrs.birdhouse.BirdhouseState;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
public class EmptyBirdhouse extends Task {
|
||||
@Inject
|
||||
private Birdhouse plugin;
|
||||
|
||||
private BirdhouseSpace space = null;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Emptying birdhouse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
space = getNext();
|
||||
if (space == null) return false;
|
||||
|
||||
return game.objects().withPosition(space.getPosition()).withAction("Empty").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject birdhouse = game.objects().withPosition(space.getPosition()).withAction("Empty").first();
|
||||
if (birdhouse == null) return;
|
||||
|
||||
birdhouse.interact("Empty");
|
||||
if (!game.waitUntil(() -> !game.objects().withPosition(space.getPosition()).withAction("Empty").exists(), 15)) return;
|
||||
|
||||
plugin.getBirdhouseTimers().put(space, Instant.now());
|
||||
space = null;
|
||||
}
|
||||
|
||||
private BirdhouseSpace getNext() {
|
||||
for (BirdhouseSpace space : BirdhouseSpace.values()) {
|
||||
int varp = game.client().getVar(space.getVarp());
|
||||
|
||||
if (BirdhouseState.fromVarpValue(varp) == BirdhouseState.SEEDED
|
||||
&& !plugin.hasRecentlyBeenEmptied(space)) {
|
||||
return space;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
@ -0,0 +1,53 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
public class GetTools extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Getting farming tools";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 15008
|
||||
&& !game.inventory().withId(ItemID.SEED_DIBBER).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iNPC leprechaun = game.npcs().withName("Tool Leprechaun").nearest();
|
||||
if (leprechaun == null) return;
|
||||
|
||||
leprechaun.interact("Exchange");
|
||||
game.waitUntil(() -> game.widget(125, 0) != null, 30);
|
||||
game.tick();
|
||||
|
||||
iWidget dibber = game.widget(125, 9);
|
||||
if (dibber == null) return;
|
||||
dibber.interact("Remove-1");
|
||||
game.tick();
|
||||
|
||||
iWidget spade = game.widget(125, 10);
|
||||
if (spade == null) return;
|
||||
spade.interact("Remove-1");
|
||||
game.tick();
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
iWidget compost = game.widget(125, 19);
|
||||
if (compost == null) return;
|
||||
compost.interact("Remove-1");
|
||||
game.sleepDelay();
|
||||
}
|
||||
game.tick();
|
||||
|
||||
iWidget close = game.widget(125, 1, 11);
|
||||
if (close == null) return;
|
||||
close.interact("Close");
|
||||
|
||||
game.waitUntil(() -> game.widget(125, 0) == null, 5);
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.birdhouse.Birdhouse;
|
||||
import io.reisub.openosrs.birdhouse.BirdhouseSpace;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class GoToBirdhouse extends Task {
|
||||
@Inject
|
||||
private Birdhouse plugin;
|
||||
|
||||
private final Position target = new Position(3681, 3819, 0);
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Going to southern birdhouse";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.hasRecentlyBeenEmptied(BirdhouseSpace.MEADOW_NORTH)
|
||||
&& !plugin.hasRecentlyBeenEmptied(BirdhouseSpace.MEADOW_SOUTH)
|
||||
&& game.localPlayer().position().distanceTo(target) > 15;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
walking.walkTo(target.areaWithin(1));
|
||||
}
|
||||
}
|
@ -0,0 +1,56 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.birdhouse.Birdhouse;
|
||||
import io.reisub.openosrs.birdhouse.BirdhouseSpace;
|
||||
import io.reisub.openosrs.birdhouse.Config;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class GoToIsland extends Task {
|
||||
@Inject
|
||||
private Birdhouse plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
private final Position target = new Position(3731, 3892, 0);
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Going to northern island";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
for (BirdhouseSpace space : BirdhouseSpace.values()) {
|
||||
if (!plugin.hasRecentlyBeenEmptied(space)) return false;
|
||||
}
|
||||
|
||||
if (!config.farmSeaweed()) return false;
|
||||
|
||||
int region = game.localPlayer().position().regionID();
|
||||
|
||||
return region == 14651 || region == 14652;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
walking.walkTo(target.areaWithin(1));
|
||||
|
||||
iObject rowboat = game.objects().withName("Rowboat").withAction("Travel").nearest();
|
||||
if (rowboat == null) return;
|
||||
|
||||
while (game.localPlayer().position().distanceTo(plugin.getIslandPosition()) > 10) {
|
||||
rowboat.interact("Travel");
|
||||
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.OPTIONS_CHAT, 15);
|
||||
|
||||
chatbox.chooseOption(3);
|
||||
game.waitUntil(() -> game.localPlayer().position().distanceTo(plugin.getIslandPosition()) < 10, 5);
|
||||
}
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
public class GoToMushroomMeadow extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Going to Mushroom Meadow";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 14906
|
||||
&& game.inventory().withNamePart("logs").count() == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject tree = game.objects().withName("Magic Mushtree").nearest();
|
||||
if (tree == null) return;
|
||||
|
||||
tree.interact(0);
|
||||
game.waitUntil(() -> game.widget(WidgetInfo.FOSSIL_MUSHROOM_TELEPORT) != null, 15);
|
||||
game.tick();
|
||||
|
||||
iWidget teleportWidget = game.widget(WidgetInfo.FOSSIL_MUSHROOM_MEADOW);
|
||||
if (teleportWidget == null) return;
|
||||
teleportWidget.select();
|
||||
|
||||
game.waitUntil(() -> game.localPlayer().position().regionID() == 14652, 5);
|
||||
game.tick(2);
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
public class GoToVerdantValley extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Going to Verdant Valley";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 14908
|
||||
&& game.inventory().withNamePart("logs").count() == 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject tree = game.objects().withName("Magic Mushtree").nearest();
|
||||
if (tree == null) return;
|
||||
|
||||
tree.interact(0);
|
||||
game.waitUntil(() -> game.widget(WidgetInfo.FOSSIL_MUSHROOM_TELEPORT) != null, 15);
|
||||
game.tick();
|
||||
|
||||
iWidget teleportWidget = game.widget(WidgetInfo.FOSSIL_MUSHROOM_VALLEY);
|
||||
if (teleportWidget == null) return;
|
||||
teleportWidget.select();
|
||||
|
||||
game.waitUntil(() -> game.localPlayer().position().regionID() == 14906, 5);
|
||||
game.tick(2);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
public class HarvestSeaweed extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Harvesting seaweed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 15008
|
||||
&& game.inventory().withId(ItemID.SEED_DIBBER).exists()
|
||||
&& !game.inventory().full()
|
||||
&& (game.objects().withName("Dead seaweed").exists() || game.objects().withAction("Pick").withName("Seaweed").exists());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject deadSeaweed = game.objects().withName("Dead seaweed").first();
|
||||
if (deadSeaweed != null) {
|
||||
int count = (int) game.objects().withName("Dead seaweed").count();
|
||||
deadSeaweed.interact("Clear");
|
||||
|
||||
game.waitUntil(() -> game.objects().withName("Dead seaweed").count() < count, 30);
|
||||
return;
|
||||
}
|
||||
|
||||
iObject seaweed = game.objects().withName("Seaweed").withAction("Pick").nearest();
|
||||
if (seaweed == null) return;
|
||||
|
||||
int count = (int) game.objects().withName("Seaweed").withAction("Pick").count();
|
||||
seaweed.interact("Pick");
|
||||
game.waitUntil(() -> game.objects().withName("Seaweed").withAction("Pick").count() < count
|
||||
|| game.groundItems().withId(ItemID.SEAWEED_SPORE).exists()
|
||||
|| game.inventory().full(), 120);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
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.iNPC;
|
||||
|
||||
public class NoteSeaweed extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Noting seaweed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 15008
|
||||
&& game.inventory().withId(ItemID.GIANT_SEAWEED).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
InventoryItem seaweed = game.inventory().withId(ItemID.GIANT_SEAWEED).first();
|
||||
iNPC leprechaun = game.npcs().withName("Tool Leprechaun").first();
|
||||
if (seaweed == null || leprechaun == null) return;
|
||||
|
||||
seaweed.useOn(leprechaun);
|
||||
game.waitUntil(() -> !game.inventory().withId(ItemID.GIANT_SEAWEED).exists(), 30);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,33 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iGroundItem;
|
||||
|
||||
public class PickupSeed extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Picking up seaweed spore";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 15008
|
||||
&& game.groundItems().withId(ItemID.SEAWEED_SPORE).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iGroundItem item = game.groundItems().withId(ItemID.SEAWEED_SPORE).nearest();
|
||||
if (item == null) return;
|
||||
|
||||
int quantity = game.inventory().withId(ItemID.SEAWEED_SPORE).quantity();
|
||||
|
||||
do {
|
||||
item.interact("Take");
|
||||
game.sleepDelay();
|
||||
} while (!game.localPlayer().isMoving());
|
||||
|
||||
game.waitUntil(() -> game.inventory().withId(ItemID.SEAWEED_SPORE).quantity() > quantity, 30);
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package io.reisub.openosrs.birdhouse.tasks;
|
||||
|
||||
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;
|
||||
|
||||
public class PlantSeaweed extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Planting seaweed";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.localPlayer().position().regionID() == 15008
|
||||
&& game.objects().withName("Seaweed patch").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject patch = game.objects().withName("Seaweed patch").nearest();
|
||||
if (patch == null) return;
|
||||
|
||||
InventoryItem seed = game.inventory().withId(ItemID.SEAWEED_SPORE).first();
|
||||
if (seed == null) return;
|
||||
|
||||
int quantity = seed.quantity();
|
||||
|
||||
seed.useOn(patch);
|
||||
game.waitUntil(() -> game.inventory().withId(ItemID.SEAWEED_SPORE).first() == null
|
||||
|| game.inventory().withId(ItemID.SEAWEED_SPORE).first().quantity() < quantity, 10);
|
||||
game.tick(3);
|
||||
|
||||
|
||||
InventoryItem ultraCompost = game.inventory().withId(ItemID.ULTRACOMPOST).first();
|
||||
if (ultraCompost == null) return;
|
||||
|
||||
patch = game.objects().withName("Seaweed").nearest();
|
||||
if (patch == null) return;
|
||||
|
||||
ultraCompost.useOn(patch);
|
||||
game.tick(3);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user