Add various new scripts

This commit is contained in:
2022-01-19 12:35:11 +01:00
parent fb86f97efa
commit 78786709eb
84 changed files with 2674 additions and 76 deletions

View 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 Herblore" // This is the name that is used in the external plugin manager panel
project.extra["PluginDescription"] = "You put the lime in the coconut, you drank them both up" // 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"]
))
}
}
}

View File

@ -0,0 +1,75 @@
/*
* 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.herblore;
import net.runelite.client.config.Button;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("chaosherblore")
public interface Config extends net.runelite.client.config.Config {
@ConfigItem(
keyName = "herbloreTask",
name = "Task",
description = "Select what to do.",
position = 0
)
default HerbloreTask herbloreTask() { return HerbloreTask.CLEAN_HERBS; }
@ConfigItem(
keyName = "quantity",
name = "Quantity",
description = "Choose how many herbs to clean or potions to make. 0 is unlimited and will work until you're out of materials.",
position = 1
)
default int quantity() { return 0; }
@ConfigItem(
keyName = "herbType",
name = "Herb type",
description = "Select which herbs to clean or make unfinished potions with.",
position = 2
)
default Herb herbType() { return Herb.ALL; }
@ConfigItem(
keyName = "makePotion",
name = "Potion",
description = "Select which potions to make.",
position = 3
)
default Potion makePotion() { return Potion.SUPER_STRENGTH; }
@ConfigItem(
keyName = "startButton",
name = "Start/Stop",
description = "Start the script",
position = 100
)
default Button startButton() {
return new Button();
}
}

View File

@ -0,0 +1,53 @@
package io.reisub.openosrs.herblore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.ItemID;
@AllArgsConstructor
@Getter
public enum Herb {
ALL(-1, -1, -1),
GUAM_LEAF(ItemID.GRIMY_GUAM_LEAF, ItemID.GUAM_LEAF, ItemID.GUAM_POTION_UNF),
MARRENTILL(ItemID.GRIMY_MARRENTILL, ItemID.MARRENTILL, ItemID.MARRENTILL_POTION_UNF),
TARROMIN(ItemID.GRIMY_TARROMIN, ItemID.TARROMIN, ItemID.TARROMIN_POTION_UNF),
HARRALANDER(ItemID.GRIMY_HARRALANDER, ItemID.HARRALANDER, ItemID.HARRALANDER_POTION_UNF),
RANARR_WEED(ItemID.GRIMY_RANARR_WEED, ItemID.RANARR_WEED, ItemID.RANARR_POTION_UNF),
TOADFLAX(ItemID.GRIMY_TOADFLAX, ItemID.TOADFLAX, ItemID.TOADFLAX_POTION_UNF),
IRIT_LEAF(ItemID.GRIMY_IRIT_LEAF, ItemID.IRIT_LEAF, ItemID.IRIT_POTION_UNF),
AVANTOE(ItemID.GRIMY_AVANTOE, ItemID.AVANTOE, ItemID.AVANTOE_POTION_UNF),
KWUARM(ItemID.GRIMY_KWUARM, ItemID.KWUARM, ItemID.KWUARM_POTION_UNF),
SNAPDRAGON(ItemID.GRIMY_SNAPDRAGON, ItemID.SNAPDRAGON, ItemID.SNAPDRAGON_POTION_UNF),
CADANTINE(ItemID.GRIMY_CADANTINE, ItemID.CADANTINE, ItemID.CADANTINE_POTION_UNF),
LANTADYME(ItemID.GRIMY_LANTADYME, ItemID.LANTADYME, ItemID.LANTADYME_POTION_UNF),
DWARF_WEED(ItemID.GRIMY_DWARF_WEED, ItemID.DWARF_WEED, ItemID.DWARF_WEED_POTION_UNF),
TORSTOL(ItemID.GRIMY_TORSTOL, ItemID.TORSTOL, ItemID.TORSTOL_POTION_UNF);
private final int grimyId;
private final int cleanId;
private final int unfinishedId;
public static int[] getAllGrimyIds() {
final int[] ids = new int[Herb.values().length-1];
int i = 0;
for (Herb herb : Herb.values()) {
if (herb == Herb.ALL) continue;
ids[i++] = herb.getGrimyId();
}
return ids;
}
public static int[] getAllCleanIds() {
final int[] ids = new int[Herb.values().length-1];
int i = 0;
for (Herb herb : Herb.values()) {
if (herb == Herb.ALL) continue;
ids[i++] = herb.getCleanId();
}
return ids;
}
}

View File

@ -0,0 +1,149 @@
package io.reisub.openosrs.herblore;
import com.google.inject.Provides;
import io.reisub.openosrs.herblore.tasks.Clean;
import io.reisub.openosrs.herblore.tasks.HandleBank;
import io.reisub.openosrs.herblore.tasks.MakePotion;
import io.reisub.openosrs.herblore.tasks.MakeUnfinished;
import io.reisub.openosrs.util.CScript;
import io.reisub.openosrs.util.Util;
import io.reisub.openosrs.util.enums.Activity;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.InventoryID;
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;
@Extension
@PluginDependency(Util.class)
@PluginDependency(iUtils.class)
@PluginDescriptor(
name = "Chaos Herblore",
description = "You put the lime in the coconut, you drank them both up",
enabledByDefault = false
)
@Slf4j
public class Herblore extends CScript {
@Inject
private Config config;
@Provides
Config provideConfig(ConfigManager configManager) {
return configManager.getConfig(Config.class);
}
@Override
protected void onStart() {
super.onStart();
idleCheckInventoryChange = true;
addTask(Clean.class);
addTask(MakeUnfinished.class);
addTask(MakePotion.class);
addTask(HandleBank.class);
}
@SuppressWarnings("unused")
@Subscribe
private void onItemContainerChanged(ItemContainerChanged event) {
if (!isLoggedIn() || event.getItemContainer() != game.client().getItemContainer(InventoryID.INVENTORY)) return;
int grimyHerbs = (int) game.inventory().withId(getGrimyHerbIds()).count();
int cleanHerbs = (int) game.inventory().withId(getCleanHerbIds()).count();
int bases = (int) game.inventory().withId(getBaseIds()).count();
if (grimyHerbs == 0 && currentActivity == Activity.CLEANING_HERBS) {
setActivity(Activity.IDLE);
} else if (cleanHerbs == 0 && currentActivity == Activity.CREATING_UNFINISHED_POTIONS) {
setActivity(Activity.IDLE);
} else if (bases == 0 && currentActivity == Activity.CREATING_POTIONS) {
setActivity(Activity.IDLE);
}
}
public boolean shouldClean() {
HerbloreTask task = config.herbloreTask();
return task == HerbloreTask.CLEAN_HERBS
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED_AND_MAKE_POTION;
}
public boolean shouldMakeUnfinished() {
HerbloreTask task = config.herbloreTask();
return task == HerbloreTask.MAKE_UNFINISHED
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED
|| task == HerbloreTask.MAKE_UNFINISHED_AND_MAKE_POTION
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED_AND_MAKE_POTION;
}
public boolean shouldMakePotion() {
HerbloreTask task = config.herbloreTask();
return task == HerbloreTask.MAKE_POTION
|| task == HerbloreTask.MAKE_UNFINISHED_AND_MAKE_POTION
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED_AND_MAKE_POTION;
}
public Herb getHerb() {
Herb herb;
if (shouldMakePotion()) {
herb = config.makePotion().getHerb();
} else {
herb = config.herbType();
}
return herb;
}
public int[] getGrimyHerbIds() {
Herb herb = getHerb();
if (herb == null) {
return new int[]{};
} else if (herb == Herb.ALL) {
return Herb.getAllGrimyIds();
} else {
return new int[]{ herb.getGrimyId() };
}
}
public int[] getCleanHerbIds() {
Herb herb = getHerb();
if (herb == null) {
return new int[]{};
} else if (herb == Herb.ALL) {
return Herb.getAllCleanIds();
} else {
return new int[]{ herb.getCleanId() };
}
}
public int[] getBaseIds() {
Potion potion = config.makePotion();
if (potion.getHerb() == null || potion.getSecondaryId() == -1) {
return new int[]{ potion.getPotionBaseId() };
} else {
return new int[]{ potion.getHerb().getUnfinishedId() };
}
}
public int[] getSecondaryIds() {
if (config.makePotion().getSecondaryId() == -1) {
return new int[]{ config.makePotion().getHerb().getCleanId() };
} else {
return new int[]{ config.makePotion().getSecondaryId() };
}
}
}

View File

@ -0,0 +1,15 @@
package io.reisub.openosrs.herblore;
import lombok.AllArgsConstructor;
import lombok.Getter;
@AllArgsConstructor
@Getter
public enum HerbloreTask {
CLEAN_HERBS,
MAKE_UNFINISHED,
MAKE_POTION,
CLEAN_HERBS_AND_MAKE_UNFINISHED,
MAKE_UNFINISHED_AND_MAKE_POTION,
CLEAN_HERBS_AND_MAKE_UNFINISHED_AND_MAKE_POTION;
}

View File

@ -0,0 +1,66 @@
package io.reisub.openosrs.herblore;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.runelite.api.ItemID;
@AllArgsConstructor
@Getter
public enum Potion {
ATTACK_POTION(ItemID.VIAL_OF_WATER, Herb.GUAM_LEAF, ItemID.EYE_OF_NEWT),
ANTIPOISON(ItemID.VIAL_OF_WATER, Herb.MARRENTILL, ItemID.UNICORN_HORN_DUST),
STRENGTH_POTION(ItemID.VIAL_OF_WATER, Herb.TARROMIN, ItemID.LIMPWURT_ROOT),
COMPOST_POTION(ItemID.VIAL_OF_WATER, Herb.HARRALANDER, ItemID.VOLCANIC_ASH),
RESTORE_POTION(ItemID.VIAL_OF_WATER, Herb.HARRALANDER, ItemID.RED_SPIDERS_EGGS),
ENERGY_POTION(ItemID.VIAL_OF_WATER, Herb.HARRALANDER, ItemID.CHOCOLATE_DUST),
DEFENCE_POTION(ItemID.VIAL_OF_WATER, Herb.RANARR_WEED, ItemID.WHITE_BERRIES),
AGILITY_POTION(ItemID.VIAL_OF_WATER, Herb.TOADFLAX, ItemID.TOADS_LEGS),
COMBAT_POTION(ItemID.VIAL_OF_WATER, Herb.HARRALANDER, ItemID.GOAT_HORN_DUST),
PRAYER_POTION(ItemID.VIAL_OF_WATER, Herb.RANARR_WEED, ItemID.SNAPE_GRASS),
SUPER_ATTACK(ItemID.VIAL_OF_WATER, Herb.IRIT_LEAF, ItemID.EYE_OF_NEWT),
SUPERANTIPOISON(ItemID.VIAL_OF_WATER, Herb.IRIT_LEAF, ItemID.UNICORN_HORN_DUST),
FISHING_POTION(ItemID.VIAL_OF_WATER, Herb.AVANTOE, ItemID.SNAPE_GRASS),
SUPER_ENERGY(ItemID.VIAL_OF_WATER, Herb.AVANTOE, ItemID.MORT_MYRE_FUNGUS),
HUNTER_POTION(ItemID.VIAL_OF_WATER, Herb.AVANTOE, ItemID.KEBBIT_TEETH_DUST),
SUPER_STRENGTH(ItemID.VIAL_OF_WATER, Herb.KWUARM, ItemID.LIMPWURT_ROOT),
WEAPON_POISON(ItemID.VIAL_OF_WATER, Herb.KWUARM, ItemID.DRAGON_SCALE_DUST),
SUPER_RESTORE(ItemID.VIAL_OF_WATER, Herb.SNAPDRAGON, ItemID.RED_SPIDERS_EGGS),
SUPER_DEFENCE(ItemID.VIAL_OF_WATER, Herb.CADANTINE, ItemID.WHITE_BERRIES),
ANTIDOTE_PLUS(ItemID.COCONUT_MILK, Herb.TOADFLAX, ItemID.YEW_ROOTS),
ANTIFIRE_POTION(ItemID.VIAL_OF_WATER, Herb.LANTADYME, ItemID.DRAGON_SCALE_DUST),
DIVINE_SUPER_ATTACK_POTION(ItemID.SUPER_ATTACK4, null, ItemID.CRYSTAL_DUST),
DIVINE_SUPER_DEFENCE_POTION(ItemID.SUPER_DEFENCE4, null, ItemID.CRYSTAL_DUST),
DIVINE_SUPER_STRENGTH_POTION(ItemID.SUPER_STRENGTH4, null, ItemID.CRYSTAL_DUST),
RANGING_POTION(ItemID.VIAL_OF_WATER, Herb.DWARF_WEED, ItemID.WINE_OF_ZAMORAK),
DIVINE_RANGING_POTION(ItemID.RANGING_POTION4, null, ItemID.CRYSTAL_DUST),
MAGIC_POTION(ItemID.VIAL_OF_WATER, Herb.LANTADYME, ItemID.POTATO_CACTUS),
STAMINA_POTION(ItemID.SUPER_ENERGY4, null, ItemID.AMYLASE_CRYSTAL),
ZAMORAK_BREW(ItemID.VIAL_OF_WATER, Herb.TORSTOL, ItemID.JANGERBERRIES),
DIVINE_MAGIC_POTION(ItemID.MAGIC_POTION4, null, ItemID.CRYSTAL_DUST),
ANTIDOTE_PLUS_PLUS(ItemID.COCONUT_MILK, Herb.IRIT_LEAF, ItemID.MAGIC_ROOTS),
BASTION_POTION(ItemID.VIAL_OF_BLOOD, Herb.CADANTINE, ItemID.WINE_OF_ZAMORAK),
BATTLEMAGE_POTION(ItemID.VIAL_OF_BLOOD, Herb.CADANTINE, ItemID.POTATO_CACTUS),
SARADOMIN_BREW(ItemID.VIAL_OF_WATER, Herb.TOADFLAX, ItemID.CRUSHED_NEST),
EXTENDED_ANTIFIRE(ItemID.ANTIFIRE_POTION4, null, ItemID.LAVA_SCALE_SHARD),
ANCIENT_BREW(ItemID.VIAL_OF_WATER, Herb.DWARF_WEED, ItemID.NIHIL_DUST),
DIVINE_BASTION_POTION(ItemID.BASTION_POTION4, null, ItemID.CRYSTAL_DUST),
DIVINE_BATTLEMAGE_POTION(ItemID.BATTLEMAGE_POTION4, null, ItemID.CRYSTAL_DUST),
ANTI_VENOM(ItemID.ANTIDOTE4_5952, null, ItemID.ZULRAHS_SCALES),
//SUPER_COMBAT_POTION(),
SUPER_ANTIFIRE_POTION(ItemID.ANTIFIRE_POTION4, null, ItemID.CRUSHED_SUPERIOR_DRAGON_BONES),
ANTI_VENOM_PLUS(ItemID.ANTIVENOM4, Herb.TORSTOL, -1),
DIVINE_SUPER_COMBAT_POTION(ItemID.SUPER_COMBAT_POTION4, null, ItemID.CRYSTAL_DUST),
EXTENDED_SUPER_ANTIFIRE(ItemID.SUPER_ANTIFIRE_POTION4, null, ItemID.LAVA_SCALE_SHARD);
private final int potionBaseId;
private final Herb herb;
private final int secondaryId;
public int getQuantity() {
if (herb == null || secondaryId == -1) {
return 14;
} else {
return 9;
}
}
}

View File

@ -0,0 +1,32 @@
package io.reisub.openosrs.herblore.tasks;
import io.reisub.openosrs.herblore.Herblore;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.util.enums.Activity;
import javax.inject.Inject;
public class Clean extends Task {
@Inject
private Herblore plugin;
@Override
public String getStatus() {
return "Cleaning herbs";
}
@Override
public boolean validate() {
return plugin.shouldClean()
&& plugin.getCurrentActivity() == Activity.IDLE
&& game.inventory().withId(plugin.getGrimyHerbIds()).exists();
}
@Override
public void execute() {
plugin.setActivity(Activity.CLEANING_HERBS);
game.inventory().withId(plugin.getGrimyHerbIds()).forEach((herb) -> herb.interact("Clean"));
game.tick();
}
}

View File

@ -0,0 +1,156 @@
package io.reisub.openosrs.herblore.tasks;
import io.reisub.openosrs.herblore.Config;
import io.reisub.openosrs.herblore.Herblore;
import io.reisub.openosrs.herblore.Potion;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.util.enums.Activity;
import net.runelite.api.ItemID;
import net.runelite.client.plugins.iutils.game.iObject;
import javax.inject.Inject;
import java.time.Duration;
import java.time.Instant;
public class HandleBank extends Task {
@Inject
private Herblore plugin;
@Inject
private Config config;
private Instant lastBanking = Instant.EPOCH;
@Override
public String getStatus() {
return "Banking";
}
@Override
public boolean validate() {
return plugin.getCurrentActivity() == Activity.IDLE
& Duration.between(lastBanking, Instant.now()).getSeconds() > 5;
}
@Override
public void execute() {
if (!bank.isOpen()) {
iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck").nearest();
if (bankObj == null) return;
if (bankObj.actions().contains("Bank")) {
bankObj.interact("Bank");
} else {
bankObj.interact(0);
}
game.waitUntil(() -> bank.isOpen(), 15);
}
if (game.inventory().all().size() > 0) {
bank.depositInventory();
game.sleepDelay();
}
if (plugin.shouldClean() && plugin.shouldMakeUnfinished() && plugin.shouldMakePotion()) {
int quantity = withdraw(new int[]{config.makePotion().getPotionBaseId()}, 9);
if (quantity == 0) {
plugin.stop("Out of potion bases, stopping plugin.");
}
quantity = withdraw(plugin.getGrimyHerbIds(), 9);
if (quantity < 9) {
quantity = withdraw(plugin.getCleanHerbIds(), 9);
}
if (quantity == 0) {
plugin.stop("Out of herbs, stopping plugin.");
}
quantity = withdraw(plugin.getSecondaryIds(), 9);
if (quantity == 0) {
plugin.stop("Out of secondaries, stopping plugin.");
}
} else if (plugin.shouldClean() && plugin.shouldMakeUnfinished()) {
if (bank.quantity(ItemID.VIAL_OF_WATER) == 0) {
plugin.stop("Out of vials, stopping plugin.");
}
bank.withdraw(ItemID.VIAL_OF_WATER, 14, false);
game.sleepDelay();
int quantity = withdraw(plugin.getGrimyHerbIds(), 14);
if (quantity < 14) {
quantity = withdraw(plugin.getCleanHerbIds(), 14);
}
if (quantity == 0) {
plugin.stop("Out of herbs, stopping plugin.");
}
} else if (plugin.shouldClean()) {
int quantity = withdraw(plugin.getGrimyHerbIds(), 28);
if (quantity == 0) {
plugin.stop("Out of herbs, stopping plugin.");
}
} else if (plugin.shouldMakeUnfinished() && plugin.shouldMakePotion()) {
int quantity = withdraw(new int[]{config.makePotion().getPotionBaseId()}, 9);
if (quantity == 0) {
plugin.stop("Out of potion bases, stopping plugin.");
}
quantity = withdraw(plugin.getCleanHerbIds(), 9);
if (quantity == 0) {
plugin.stop("Out of clean herbs, stopping plugin.");
}
quantity = withdraw(plugin.getSecondaryIds(), 9);
if (quantity == 0) {
plugin.stop("Out of secondaries, stopping plugin.");
}
} else if (plugin.shouldMakeUnfinished()) {
if (bank.quantity(ItemID.VIAL_OF_WATER) == 0) {
plugin.stop("Out of vials, stopping plugin.");
}
bank.withdraw(ItemID.VIAL_OF_WATER, 14, false);
game.sleepDelay();
int quantity = withdraw(plugin.getCleanHerbIds(), 14);
if (quantity == 0) {
plugin.stop("Out of clean herbs, stopping plugin.");
}
} else if (plugin.shouldMakePotion()) {
int quantity = withdraw(plugin.getBaseIds(), 14);
if (quantity == 0) {
plugin.stop("Out of potion bases, stopping plugin.");
}
quantity = withdraw(plugin.getSecondaryIds(), 14);
if (quantity == 0) {
plugin.stop("Out of secondaries, stopping plugin.");
}
}
bank.close();
game.waitUntil(() -> !bank.isOpen(), 5);
lastBanking = Instant.now();
}
private int withdraw(int[] ids, int quantity) {
int available = 0;
for (int id : ids) {
available += bank.quantity(id);
bank.withdraw(id, quantity, false);
game.sleepDelay();
if (available >= quantity) break;
}
return available;
}
}

View File

@ -0,0 +1,46 @@
package io.reisub.openosrs.herblore.tasks;
import io.reisub.openosrs.herblore.Herblore;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.util.enums.Activity;
import net.runelite.client.plugins.iutils.game.InventoryItem;
import net.runelite.client.plugins.iutils.ui.Chatbox;
import javax.inject.Inject;
import java.util.List;
public class MakePotion extends Task {
@Inject
private Herblore plugin;
@Override
public String getStatus() {
return "Making potions";
}
@Override
public boolean validate() {
return plugin.shouldMakePotion()
&& plugin.getCurrentActivity() == Activity.IDLE
&& game.inventory().withId(plugin.getSecondaryIds()).exists()
&& game.inventory().withId(plugin.getBaseIds()).exists();
}
@Override
public void execute() {
plugin.setActivity(Activity.CREATING_POTIONS);
List<InventoryItem> secondaries = game.inventory().withId(plugin.getSecondaryIds()).all();
List<InventoryItem> bases = game.inventory().withId(plugin.getBaseIds()).all();
if (secondaries.size() == 0 || bases.size() == 0) return;
int quantity = Math.min(secondaries.size(), bases.size());
secondaries.get(0).useOn(bases.get(0));
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.MAKE, 5);
chatbox.make(0, quantity);
game.tick();
}
}

View File

@ -0,0 +1,47 @@
package io.reisub.openosrs.herblore.tasks;
import io.reisub.openosrs.herblore.Herblore;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.util.enums.Activity;
import net.runelite.api.ItemID;
import net.runelite.client.plugins.iutils.game.InventoryItem;
import net.runelite.client.plugins.iutils.ui.Chatbox;
import javax.inject.Inject;
import java.util.List;
public class MakeUnfinished extends Task {
@Inject
private Herblore plugin;
@Override
public String getStatus() {
return "Making unfinished potions";
}
@Override
public boolean validate() {
return plugin.shouldMakeUnfinished()
&& plugin.getCurrentActivity() == Activity.IDLE
&& game.inventory().withId(plugin.getCleanHerbIds()).exists()
&& game.inventory().withId(ItemID.VIAL_OF_WATER, ItemID.VIAL_OF_BLOOD, ItemID.COCONUT_MILK).exists();
}
@Override
public void execute() {
plugin.setActivity(Activity.CREATING_UNFINISHED_POTIONS);
List<InventoryItem> herbs = game.inventory().withId(plugin.getCleanHerbIds()).all();
List<InventoryItem> bases = game.inventory().withId(ItemID.VIAL_OF_WATER, ItemID.VIAL_OF_BLOOD, ItemID.COCONUT_MILK).all();
if (herbs.size() == 0 || bases.size() == 0) return;
int quantity = Math.min(herbs.size(), bases.size());
herbs.get(0).useOn(bases.get(0));
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.MAKE, 5);
chatbox.make(0, quantity);
game.tick();
}
}