diff --git a/agility/src/main/java/io/reisub/openosrs/agility/AgilityPlugin.java b/agility/src/main/java/io/reisub/openosrs/agility/Agility.java similarity index 100% rename from agility/src/main/java/io/reisub/openosrs/agility/AgilityPlugin.java rename to agility/src/main/java/io/reisub/openosrs/agility/Agility.java diff --git a/agility/src/main/java/io/reisub/openosrs/agility/AgilityConfig.java b/agility/src/main/java/io/reisub/openosrs/agility/Config.java similarity index 100% rename from agility/src/main/java/io/reisub/openosrs/agility/AgilityConfig.java rename to agility/src/main/java/io/reisub/openosrs/agility/Config.java diff --git a/autodropper/src/main/java/io/reisub/openosrs/autodropper/Autodropper.java b/autodropper/src/main/java/io/reisub/openosrs/autodropper/Autodropper.java index d7ffa13..0fc300b 100644 --- a/autodropper/src/main/java/io/reisub/openosrs/autodropper/Autodropper.java +++ b/autodropper/src/main/java/io/reisub/openosrs/autodropper/Autodropper.java @@ -2,23 +2,26 @@ package io.reisub.openosrs.autodropper; import com.google.inject.Provides; import io.reisub.openosrs.util.Util; +import io.reisub.openosrs.util.enums.Activity; import lombok.extern.slf4j.Slf4j; import net.runelite.api.GameState; import net.runelite.api.events.ConfigButtonClicked; import net.runelite.api.events.ItemContainerChanged; import net.runelite.client.config.ConfigManager; +import net.runelite.client.config.Keybind; import net.runelite.client.eventbus.Subscribe; import net.runelite.client.events.ConfigChanged; +import net.runelite.client.input.KeyListener; +import net.runelite.client.input.KeyManager; import net.runelite.client.plugins.Plugin; import net.runelite.client.plugins.PluginDependency; import net.runelite.client.plugins.PluginDescriptor; import net.runelite.client.plugins.iutils.game.Game; -import net.runelite.client.plugins.iutils.game.InventoryItem; import net.runelite.client.plugins.iutils.iUtils; import org.pf4j.Extension; import javax.inject.Inject; -import java.util.List; +import java.awt.event.KeyEvent; import java.util.Locale; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -33,7 +36,7 @@ import java.util.concurrent.TimeUnit; enabledByDefault = false ) @Slf4j -public class Autodropper extends Plugin { +public class Autodropper extends Plugin implements KeyListener { @SuppressWarnings("unused") @Inject private Game game; @@ -42,6 +45,10 @@ public class Autodropper extends Plugin { @Inject private Config config; + @SuppressWarnings("unused") + @Inject + private KeyManager keyManager; + @SuppressWarnings("unused") @Provides Config provideConfig(ConfigManager configManager) { @@ -56,6 +63,10 @@ public class Autodropper extends Plugin { protected void startUp() { log.info("Starting Chaos Autodropper"); + itemNames = parseNames(); + itemIds = parseIds(); + + keyManager.registerKeyListener(this); executor = Executors.newSingleThreadScheduledExecutor(); } @@ -63,23 +74,20 @@ public class Autodropper extends Plugin { protected void shutDown() { log.info("Stopping Chaos Autodropper"); + keyManager.unregisterKeyListener(this); executor.shutdownNow(); } @SuppressWarnings("unused") @Subscribe private void onItemContainerChanged(ItemContainerChanged event) { - if (game.client().getGameState() != GameState.LOGGED_IN) return; + if (game.client().getGameState() != GameState.LOGGED_IN || config.dropMethod() == DropMethod.NONE) return; - if (!config.dropWhileItemSelected() && game.client().isItemSelected() == 1) return; - - if (itemNames == null) itemNames = parseNames(); - if (itemIds == null) itemIds = parseIds(); - - executor.schedule(() -> { - game.inventory().withName(itemNames).drop(); - game.inventory().withId(itemIds).drop(); - }, 0, TimeUnit.MILLISECONDS); + if (config.dropMethod() == DropMethod.ON_ADD) { + drop(); + } else if (config.dropMethod() == DropMethod.ON_FULL_INVENTORY && game.inventory().full()) { + drop(); + } } @Subscribe @@ -105,10 +113,18 @@ public class Autodropper extends Plugin { } private String[] parseNames() { - String[] names = config.itemNames().split(";"); + String[] itemNames = config.itemNames().split(";"); + String[] seedNames = config.seedNames().split(";"); + String[] names = new String[itemNames.length + seedNames.length]; - for (int i = 0; i < names.length; i++) { - names[i] = names[i].trim(); + int i = 0; + + for (String name : itemNames) { + names[i++] = name.trim(); + } + + for (String name : seedNames) { + names[i++] = name.trim(); } return names; @@ -126,4 +142,26 @@ public class Autodropper extends Plugin { return ids; } + + @Override + public void keyTyped(KeyEvent e) {} + + @Override + public void keyPressed(KeyEvent e) { + if (config.dropEnableHotkey() && config.dropHotkey().matches(e)) { + drop(); + } + } + + @Override + public void keyReleased(KeyEvent e) {} + + private void drop() { + if (!config.dropWhileItemSelected() && game.client().isItemSelected() == 1) return; + + executor.schedule(() -> { + game.inventory().withName(itemNames).drop(); + game.inventory().withId(itemIds).drop(); + }, 0, TimeUnit.MILLISECONDS); + } } \ No newline at end of file diff --git a/autodropper/src/main/java/io/reisub/openosrs/autodropper/Config.java b/autodropper/src/main/java/io/reisub/openosrs/autodropper/Config.java index 87bb121..c41e8e0 100644 --- a/autodropper/src/main/java/io/reisub/openosrs/autodropper/Config.java +++ b/autodropper/src/main/java/io/reisub/openosrs/autodropper/Config.java @@ -24,9 +24,11 @@ */ package io.reisub.openosrs.autodropper; -import net.runelite.client.config.Button; -import net.runelite.client.config.ConfigGroup; -import net.runelite.client.config.ConfigItem; +import io.reisub.openosrs.util.enums.Activity; +import net.runelite.client.config.*; + +import java.awt.event.InputEvent; +import java.awt.event.KeyEvent; @ConfigGroup("chaosautodropper") @@ -47,14 +49,57 @@ public interface Config extends net.runelite.client.config.Config { ) default String itemIds() { return ""; } + @ConfigItem( + keyName = "dropMethod", + name = "Auto drop method", + description = "Choose the automatic drop method.", + position = 3 + ) + default DropMethod dropMethod() { return DropMethod.NONE; } + + @ConfigItem( + keyName = "dropEnableHotkey", + name = "Enable hotkey", + description = "Enable dropping on hotkey.", + position = 4 + ) + default boolean dropEnableHotkey() { return false; } + + @ConfigItem( + keyName = "dropHotkey", + name = "Hotkey", + description = "Choose the hotkey.", + hidden = true, + unhide = "dropEnableHotkey", + position = 5 + ) + default Keybind dropHotkey() { return new Keybind(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK); } + @ConfigItem( keyName = "dropWhileItemSelected", name = "Drop while item selected", description = "If enabled, this will drop items even if an item is selected, resulting in deselecting the item.", - position = 2 + position = 6 ) default boolean dropWhileItemSelected() { return false; } + @ConfigSection( + keyName = "seedsConfig", + name = "Seeds configuration", + description = "Seeds configuration", + position = 70 + ) + String seedsConfig = "seedsConfig"; + + @ConfigItem( + keyName = "seedNames", + name = "Seed names", + description = "List of seeds to drop. This works the same as regular items but is an extra field to not clog the regular one.", + position = 71 + ) + default String seedNames() { return "Potato seed; Onion seed; Cabbage seed; Tomato seed; Sweetcorn seed; Marigold seed; Rosemary seed; Nasturtium seed; Woad seed; Redberry seed; Cadavaberry seed; Dwellberry seed; Acorn; Apple tree seed; Banana tree seed"; } + + @ConfigItem( keyName = "reloadButton", name = "Reload configuration", diff --git a/autodropper/src/main/java/io/reisub/openosrs/autodropper/DropMethod.java b/autodropper/src/main/java/io/reisub/openosrs/autodropper/DropMethod.java new file mode 100644 index 0000000..66b8773 --- /dev/null +++ b/autodropper/src/main/java/io/reisub/openosrs/autodropper/DropMethod.java @@ -0,0 +1,7 @@ +package io.reisub.openosrs.autodropper; + +public enum DropMethod { + NONE, + ON_ADD, + ON_FULL_INVENTORY; +} diff --git a/base/base.gradle.kts b/base/base.gradle.kts index debacb1..01791e3 100644 --- a/base/base.gradle.kts +++ b/base/base.gradle.kts @@ -25,8 +25,8 @@ version = "1.0.0" -project.extra["PluginName"] = "Chaos Base" // This is the name that is used in the external plugin manager panel -project.extra["PluginDescription"] = "" // This is the description that is used in the external plugin manager panel +project.extra["PluginName"] = "Chaos Bosshelper" // This is the name that is used in the external plugin manager panel +project.extra["PluginDescription"] = "Doesn't actually help bosses, it helps you against them!" // This is the description that is used in the external plugin manager panel dependencies { compileOnly(project(":util")) diff --git a/bosshelper/bosshelper.gradle.kts b/bosshelper/bosshelper.gradle.kts new file mode 100644 index 0000000..01791e3 --- /dev/null +++ b/bosshelper/bosshelper.gradle.kts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Owain van Brakel + * 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 Bosshelper" // This is the name that is used in the external plugin manager panel +project.extra["PluginDescription"] = "Doesn't actually help bosses, it helps you against them!" // 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"] + )) + } + } +} \ No newline at end of file diff --git a/bosshelper/src/main/java/io/reisub/openosrs/bosshelper/Bosshelper.java b/bosshelper/src/main/java/io/reisub/openosrs/bosshelper/Bosshelper.java new file mode 100644 index 0000000..5350270 --- /dev/null +++ b/bosshelper/src/main/java/io/reisub/openosrs/bosshelper/Bosshelper.java @@ -0,0 +1,48 @@ +package io.reisub.openosrs.bosshelper; + +import com.google.inject.Provides; + +import io.reisub.openosrs.util.CScript; +import io.reisub.openosrs.util.Task; +import io.reisub.openosrs.util.Util; +import io.reisub.openosrs.util.tasks.Eat; +import io.reisub.openosrs.util.tasks.KittenTask; +import io.reisub.openosrs.util.tasks.Run; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigButtonClicked; +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.scripts.iScript; +import org.pf4j.Extension; + +import java.util.ArrayList; +import java.util.List; + +@Extension +@PluginDependency(Util.class) +@PluginDependency(iUtils.class) +@PluginDescriptor( + name = "Chaos Bosshelper", + description = "Doesn't actually help bosses, it helps you against them!", + enabledByDefault = false +) +@Slf4j +public class Bosshelper extends CScript { + @Provides + Config provideConfig(ConfigManager configManager) { + return configManager.getConfig(Config.class); + } + + @Override + protected void onStart() { + super.onStart(); + + Run runTask = injector.getInstance(Run.class); + runTask.setInterval(70, 95); + tasks.add(runTask); + } +} \ No newline at end of file diff --git a/bosshelper/src/main/java/io/reisub/openosrs/bosshelper/Config.java b/bosshelper/src/main/java/io/reisub/openosrs/bosshelper/Config.java new file mode 100644 index 0000000..4b5eaa6 --- /dev/null +++ b/bosshelper/src/main/java/io/reisub/openosrs/bosshelper/Config.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018, Andrew EP | 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.bosshelper; + +import net.runelite.client.config.Button; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("chaosbosshelper") + +public interface Config extends net.runelite.client.config.Config { + @ConfigItem( + keyName = "startButton", + name = "Start/Stop", + description = "Start the script", + position = 100 + ) + default Button startButton() { + return new Button(); + } +} \ No newline at end of file diff --git a/cooker/src/main/java/io/reisub/openosrs/cooker/Activity.java b/cooker/src/main/java/io/reisub/openosrs/cooker/Activity.java deleted file mode 100644 index 9614e5b..0000000 --- a/cooker/src/main/java/io/reisub/openosrs/cooker/Activity.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.reisub.openosrs.cooker; - -public enum Activity { - IDLE, - COOKING; -} diff --git a/cooker/src/main/java/io/reisub/openosrs/cooker/tasks/SkipLevel.java b/cooker/src/main/java/io/reisub/openosrs/cooker/tasks/SkipLevel.java deleted file mode 100644 index 667e9a2..0000000 --- a/cooker/src/main/java/io/reisub/openosrs/cooker/tasks/SkipLevel.java +++ /dev/null @@ -1,22 +0,0 @@ -package io.reisub.openosrs.cooker.tasks; - -import io.reisub.openosrs.util.Task; -import net.runelite.client.plugins.iutils.ui.Chatbox; - -public class SkipLevel extends Task { - @Override - public String getStatus() { - return "Skipping level chatbox"; - } - - @Override - public boolean validate() { - return chatbox.chatState() == Chatbox.ChatState.LEVEL_UP; - } - - @Override - public void execute() { - chatbox.continueChats(); - game.tick(); - } -} diff --git a/fighter/fighter.gradle.kts b/fighter/fighter.gradle.kts new file mode 100644 index 0000000..0674b13 --- /dev/null +++ b/fighter/fighter.gradle.kts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Owain van Brakel + * 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 Fighter" // This is the name that is used in the external plugin manager panel +project.extra["PluginDescription"] = "Wham! Bam! Thank you Ma'am!" // 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"] + )) + } + } +} \ No newline at end of file diff --git a/fighter/src/main/java/io/reisub/openosrs/fighter/Config.java b/fighter/src/main/java/io/reisub/openosrs/fighter/Config.java new file mode 100644 index 0000000..c844b21 --- /dev/null +++ b/fighter/src/main/java/io/reisub/openosrs/fighter/Config.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2018, Andrew EP | 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.fighter; + +import net.runelite.client.config.*; + +@ConfigGroup("chaosfighter") + +public interface Config extends net.runelite.client.config.Config { + @ConfigSection( + keyName = "targetConfiguration", + name = "Target Configuration", + description = "Configure target to fight", + position = 0 + ) + String targetConfiguration = "targetConfiguration"; + + @ConfigItem( + keyName = "targetNames", + name = "Target names", + description = "The names of your targets, separated with a semicolon.", + section = "targetConfiguration", + position = 1 + ) + default String targetNames() { + return ""; + } + + @ConfigItem( + keyName = "targetIds", + name = "Target IDs", + description = "The IDs of your targets, separated with a semicolon.", + section = "targetConfiguration", + position = 2 + ) + default String targetIds() { + return ""; + } + + @Range( + min = 1, + max = 64 + ) + @ConfigItem( + keyName = "searchRadius", + name = "Search radius", + description = "Search radius in which to search the target NPC.", + section = "targetConfiguration", + position = 3 + ) + default int searchRadius() { + return 20; + } + + @ConfigItem( + keyName = "usePathfinding", + name = "Use pathfinding", + description = "Use pathfinding to find nearest target. This is a lot more expensive CPU-wise but is recommended when fighting in an area with obstacles.", + section = "targetConfiguration", + position = 4 + ) + default boolean usePathfinding() { + return false; + } + + @Range( + min = 1, + max = 64 + ) + @ConfigItem( + keyName = "pathfindingSearchRadius", + name = "Pathfinding search radius", + description = "Search radius in which to search the target NPC using pathfinding. Be careful, setting this too high will freeze the game. If no NPC is found within the pathfinding radius it will fall back to the non-pathfinding radius.", + section = "targetConfiguration", + hidden = true, + unhide = "usePathfinding", + position = 5 + ) + default int pathfindingSearchRadius() { + return 8; + } + + @ConfigItem( + keyName = "startButton", + name = "Start/Stop", + description = "Start the script", + position = 100 + ) + default Button startButton() { + return new Button(); + } +} \ No newline at end of file diff --git a/fighter/src/main/java/io/reisub/openosrs/fighter/Fighter.java b/fighter/src/main/java/io/reisub/openosrs/fighter/Fighter.java new file mode 100644 index 0000000..82ba961 --- /dev/null +++ b/fighter/src/main/java/io/reisub/openosrs/fighter/Fighter.java @@ -0,0 +1,116 @@ +package io.reisub.openosrs.fighter; + +import com.google.inject.Provides; +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.NPC; +import net.runelite.api.events.ActorDeath; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.events.ConfigChanged; +import net.runelite.client.plugins.PluginDependency; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.iutils.game.iNPC; +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 Fighter", + description = "Wham! Bam! Thank you Ma'am!", + enabledByDefault = false +) +@Slf4j +public class Fighter extends CScript { + @Inject + @Getter + private Config config; + + @Provides + Config provideConfig(ConfigManager configManager) { + return configManager.getConfig(Config.class); + } + + @Getter + private String[] targetNames; + + @Getter + private int[] targetIds; + + @Getter + @Setter + private iNPC currentTarget; + + @Override + protected void onStart() { + super.onStart(); + + parseTargets(); + + Run runTask = injector.getInstance(Run.class); + runTask.setInterval(70, 95); + tasks.add(runTask); + } + + @SuppressWarnings("unused") + @Subscribe + private void onConfigChanged(ConfigChanged event) { + if (!event.getGroup().equals("chaosfighter")) return; + + if (event.getKey().equals("targetNames") || event.getKey().equals("targetIds")) { + parseTargets(); + } + } + + @SuppressWarnings("unused") + @Subscribe + private void onActorDeath(ActorDeath event) { + if (!(event.getActor() instanceof NPC)) return; + + NPC actor = (NPC) event.getActor(); + + if (actor.getIndex() == currentTarget.index()) { + log.info("Our target died"); + currentTarget = null; + } + } + + private void parseTargets() { + if (!config.targetIds().equals("")) { + String[] rawTargetIds = config.targetIds().split(";"); + targetIds = new int[rawTargetIds.length]; + int i = 0; + + for (String id : rawTargetIds) { + try { + targetIds[i++] = Integer.parseInt(id.trim()); + } catch (NumberFormatException e) { + log.error("Error parsing target ID: " + id.trim()); + targetIds[i-1] = 0; + } + } + } else { + targetIds = new int[0]; + } + + if (!config.targetNames().equals("")) { + String[] rawTargetNames = config.targetNames().split(";"); + targetNames = new String[rawTargetNames.length]; + int i = 0; + + for (String name : rawTargetNames) { + targetNames[i++] = name.trim(); + } + } else { + targetNames = new String[0]; + } + } +} \ No newline at end of file diff --git a/fighter/src/main/java/io/reisub/openosrs/fighter/tasks/Fight.java b/fighter/src/main/java/io/reisub/openosrs/fighter/tasks/Fight.java new file mode 100644 index 0000000..2de9735 --- /dev/null +++ b/fighter/src/main/java/io/reisub/openosrs/fighter/tasks/Fight.java @@ -0,0 +1,48 @@ +package io.reisub.openosrs.fighter.tasks; + +import io.reisub.openosrs.fighter.Fighter; +import io.reisub.openosrs.util.Task; +import io.reisub.openosrs.util.enums.Activity; +import net.runelite.client.plugins.iutils.actor.NpcStream; +import net.runelite.client.plugins.iutils.game.iNPC; + +import javax.inject.Inject; +import java.util.stream.Stream; + +public class Fight extends Task { + @Inject + private Fighter plugin; + + @Override + public String getStatus() { + return "Fighting"; + } + + @Override + public boolean validate() { + if (plugin.getCurrentActivity() != Activity.IDLE) return false; + + NpcStream idStream = game.npcs().withId(plugin.getTargetIds()).withoutTarget(); + NpcStream nameStream = game.npcs().withName(plugin.getTargetNames()).withoutTarget(); + + NpcStream targetStream = (NpcStream) Stream.concat(idStream, nameStream); + + if (plugin.getConfig().usePathfinding()) { + plugin.setCurrentTarget(targetStream.within(plugin.getConfig().pathfindingSearchRadius()).nearestPath()); + } + + if (plugin.getCurrentActivity() == null) { + plugin.setCurrentTarget(targetStream.within(plugin.getConfig().searchRadius()).nearest()); + } + + return plugin.getCurrentTarget() != null; + } + + @Override + public void execute() { + if (plugin.getCurrentTarget() == null) return; + + plugin.getCurrentTarget().interact(0); + game.waitUntil(() -> game.localPlayer().target() != null && game.localPlayer().target().name().equals(plugin.getCurrentTarget().name()), 15); + } +} diff --git a/fisher/src/main/java/io/reisub/openosrs/fisher/FisherConfig.java b/fisher/src/main/java/io/reisub/openosrs/fisher/Config.java similarity index 100% rename from fisher/src/main/java/io/reisub/openosrs/fisher/FisherConfig.java rename to fisher/src/main/java/io/reisub/openosrs/fisher/Config.java diff --git a/fisher/src/main/java/io/reisub/openosrs/fisher/FisherPlugin.java b/fisher/src/main/java/io/reisub/openosrs/fisher/Fisher.java similarity index 100% rename from fisher/src/main/java/io/reisub/openosrs/fisher/FisherPlugin.java rename to fisher/src/main/java/io/reisub/openosrs/fisher/Fisher.java diff --git a/fisher/src/main/java/io/reisub/openosrs/fisher/tasks/DoBank.java b/fisher/src/main/java/io/reisub/openosrs/fisher/tasks/HandleBank.java similarity index 97% rename from fisher/src/main/java/io/reisub/openosrs/fisher/tasks/DoBank.java rename to fisher/src/main/java/io/reisub/openosrs/fisher/tasks/HandleBank.java index 8a08032..0ae1074 100644 --- a/fisher/src/main/java/io/reisub/openosrs/fisher/tasks/DoBank.java +++ b/fisher/src/main/java/io/reisub/openosrs/fisher/tasks/HandleBank.java @@ -8,9 +8,6 @@ import net.runelite.client.plugins.iutils.ui.Bank; import javax.inject.Inject; public class DoBank extends Task { - @Inject - public Bank bank; - @Override public String getStatus() { return "Banking"; diff --git a/herblore/herblore.gradle.kts b/herblore/herblore.gradle.kts new file mode 100644 index 0000000..e2035fd --- /dev/null +++ b/herblore/herblore.gradle.kts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Owain van Brakel + * 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"] + )) + } + } +} \ No newline at end of file diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/Config.java b/herblore/src/main/java/io/reisub/openosrs/herblore/Config.java new file mode 100644 index 0000000..aaf022d --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/Config.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2018, Andrew EP | 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(); + } +} \ No newline at end of file diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/Herb.java b/herblore/src/main/java/io/reisub/openosrs/herblore/Herb.java new file mode 100644 index 0000000..6cac31c --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/Herb.java @@ -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; + } +} diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/Herblore.java b/herblore/src/main/java/io/reisub/openosrs/herblore/Herblore.java new file mode 100644 index 0000000..956bea6 --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/Herblore.java @@ -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() }; + } + } +} \ No newline at end of file diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/HerbloreTask.java b/herblore/src/main/java/io/reisub/openosrs/herblore/HerbloreTask.java new file mode 100644 index 0000000..f02dd67 --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/HerbloreTask.java @@ -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; +} diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/Potion.java b/herblore/src/main/java/io/reisub/openosrs/herblore/Potion.java new file mode 100644 index 0000000..96cab70 --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/Potion.java @@ -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; + } + } +} diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/Clean.java b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/Clean.java new file mode 100644 index 0000000..f6e26e4 --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/Clean.java @@ -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(); + } +} diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/HandleBank.java b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/HandleBank.java new file mode 100644 index 0000000..727385e --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/HandleBank.java @@ -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; + } +} diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/MakePotion.java b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/MakePotion.java new file mode 100644 index 0000000..b948f71 --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/MakePotion.java @@ -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 secondaries = game.inventory().withId(plugin.getSecondaryIds()).all(); + List 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(); + } +} diff --git a/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/MakeUnfinished.java b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/MakeUnfinished.java new file mode 100644 index 0000000..e89e2bb --- /dev/null +++ b/herblore/src/main/java/io/reisub/openosrs/herblore/tasks/MakeUnfinished.java @@ -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 herbs = game.inventory().withId(plugin.getCleanHerbIds()).all(); + List 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(); + } +} diff --git a/mtahelper/mtahelper.gradle.kts b/mtahelper/mtahelper.gradle.kts new file mode 100644 index 0000000..33c97be --- /dev/null +++ b/mtahelper/mtahelper.gradle.kts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Owain van Brakel + * 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 MTA Helper" // This is the name that is used in the external plugin manager panel +project.extra["PluginDescription"] = "Makes Mage Training Arena slightly less terrible." // 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"] + )) + } + } +} \ No newline at end of file diff --git a/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/Config.java b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/Config.java new file mode 100644 index 0000000..18d8ed6 --- /dev/null +++ b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/Config.java @@ -0,0 +1,76 @@ +/* + * Copyright (c) 2018, Andrew EP | 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.mtahelper; + +import net.runelite.client.config.Button; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; +import net.runelite.client.config.Keybind; + +import java.awt.event.KeyEvent; + +@ConfigGroup("chaosmtahelper") + +public interface Config extends net.runelite.client.config.Config { + @ConfigItem( + keyName = "spellHotkey", + name = "Spell hotkey", + description = "Use this hotkey to cast telegrab or bones to bananas depending on the minigame.", + position = 0 + ) + default Keybind spellHotkey() { + return new Keybind(KeyEvent.VK_Q, 0); + } + + @ConfigItem( + keyName = "enableTelegrabHotkey", + name = "Enable telegrab hotkey", + description = "Enable the hotkey for telegrabs.", + position = 1 + ) + default boolean enableTelegrabHotkey() { + return true; + } + + @ConfigItem( + keyName = "enableBonesHotkey", + name = "Enable B2B hotkey", + description = "Enable the hotkey for bones to bananas.", + position = 2 + ) + default boolean enableBonesHotkey() { + return true; + } + + @ConfigItem( + keyName = "startButton", + name = "Start/Stop", + description = "Start the script", + position = 100 + ) + default Button startButton() { + return new Button(); + } +} \ No newline at end of file diff --git a/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/MTAHelper.java b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/MTAHelper.java new file mode 100644 index 0000000..1201c54 --- /dev/null +++ b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/MTAHelper.java @@ -0,0 +1,144 @@ +package io.reisub.openosrs.mtahelper; + +import com.google.inject.Provides; + +import io.reisub.openosrs.mtahelper.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.*; +import net.runelite.api.coords.Direction; +import net.runelite.api.coords.LocalPoint; +import net.runelite.api.coords.WorldPoint; +import net.runelite.api.events.*; +import net.runelite.api.widgets.WidgetID; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.eventbus.Subscribe; +import net.runelite.client.input.KeyListener; +import net.runelite.client.input.KeyManager; +import net.runelite.client.plugins.PluginDependency; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.iutils.iUtils; +import net.runelite.client.plugins.mta.telekinetic.Maze; +import org.pf4j.Extension; + +import javax.inject.Inject; +import java.awt.*; +import java.awt.event.KeyEvent; +import java.time.Duration; +import java.time.Instant; +import java.util.ArrayList; +import java.util.List; +import java.util.Stack; + +@Extension +@PluginDependency(Util.class) +@PluginDependency(iUtils.class) +@PluginDescriptor( + name = "Chaos MTA Helper", + description = "Makes Mage Training Arena slightly less terrible.", + enabledByDefault = false +) +@Slf4j +public class MTAHelper extends CScript implements KeyListener { + @Inject + private Config config; + + @Inject + private KeyManager keyManager; + + private Instant lastAction = Instant.EPOCH; + + @Provides + Config provideConfig(ConfigManager configManager) { + return configManager.getConfig(Config.class); + } + + public static final int MTA_REGION = 13462; + + @Getter + @Setter + private boolean castTelekineticGrab; + + @Getter + @Setter + private boolean castBonesToBananas; + + @Getter + @Setter + private long lastHighAlchemy; + + @Override + protected void onStart() { + super.onStart(); + + keyManager.registerKeyListener(this); + + Run runTask = injector.getInstance(Run.class); + runTask.setInterval(70, 95); + tasks.add(runTask); + + addTask(CastTelekineticGrab.class); + addTask(CastEnchant.class); + addTask(CastHighAlch.class); + addTask(EatPeach.class); + addTask(CastBonesToBananas.class); + } + + @Override + protected void onStop() { + super.onStop(); + keyManager.unregisterKeyListener(this); + } + + @SuppressWarnings("unused") + @Subscribe + private void onGameTick(GameTick event) { + if (!isLoggedIn()) return; + + + } + + @SuppressWarnings("unused") + @Subscribe + private void onItemContainerChanged(ItemContainerChanged event) { + + } + + @SuppressWarnings("unused") + @Subscribe + private void onStatChanged(StatChanged event) { + if (event.getSkill() == Skill.MAGIC) { + lastHighAlchemy = game.ticks(); + } + } + + @Override + public void keyTyped(KeyEvent e) { + + } + + @Override + public void keyPressed(KeyEvent e) { + if (Duration.between(lastAction, Instant.now()).getSeconds() < 2) return; + lastAction = Instant.now(); + + if (config.enableTelegrabHotkey() + && config.spellHotkey().matches(e) + && game.widget(WidgetID.MTA_TELEKINETIC_GROUP_ID, 0) != null) { + castTelekineticGrab = true; + } else if (config.enableBonesHotkey() + && config.spellHotkey().matches(e) + && game.widget(WidgetID.MTA_GRAVEYARD_GROUP_ID, 0) != null) { + castBonesToBananas = true; + } + } + + @Override + public void keyReleased(KeyEvent e) { + + } +} \ No newline at end of file diff --git a/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastBonesToBananas.java b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastBonesToBananas.java new file mode 100644 index 0000000..ee906a5 --- /dev/null +++ b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastBonesToBananas.java @@ -0,0 +1,41 @@ +package io.reisub.openosrs.mtahelper.tasks; + +import io.reisub.openosrs.mtahelper.MTAHelper; +import io.reisub.openosrs.util.Task; +import net.runelite.client.plugins.iutils.api.Spells; +import net.runelite.client.plugins.iutils.game.iObject; +import net.runelite.client.plugins.iutils.game.iWidget; + +import javax.inject.Inject; + +public class CastBonesToBananas extends Task { + @Inject + private MTAHelper plugin; + + @Override + public String getStatus() { + return "Casting bones to bananas and depositing"; + } + + @Override + public boolean validate() { + return plugin.isCastBonesToBananas(); + } + + @Override + public void execute() { + iObject foodChute = game.objects().withName("Food chute").nearest(); + if (foodChute == null) return; + + foodChute.interact("Deposit"); + game.sleepDelay(); + game.sleepDelay(); + + iWidget spellWidget = game.widget(Spells.BONES_TO_BANANAS.getInfo()); + if (spellWidget == null) return; + + spellWidget.interact("Cast"); + + plugin.setCastBonesToBananas(false); + } +} diff --git a/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastEnchant.java b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastEnchant.java new file mode 100644 index 0000000..64535fc --- /dev/null +++ b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastEnchant.java @@ -0,0 +1,51 @@ +package io.reisub.openosrs.mtahelper.tasks; + +import io.reisub.openosrs.mtahelper.MTAHelper; +import io.reisub.openosrs.util.Task; +import net.runelite.client.plugins.iutils.api.Spells; +import net.runelite.client.plugins.iutils.game.InventoryItem; +import net.runelite.client.plugins.iutils.game.iWidget; + +import javax.inject.Inject; +import java.util.Set; + +public class CastEnchant extends Task { + @Inject + private MTAHelper plugin; + + private final String[] enchantItems = new String[]{ + "Pentamid", + "Cube", + "Cylinder", + "Icosahedron", + "Dragonstone" + }; + + private long last = 0; + + @Override + public String getStatus() { + return "Casting enchant spell"; + } + + @Override + public boolean validate() { + return plugin.isInRegion(MTAHelper.MTA_REGION) + && game.localPlayer().position().z == 0 + && game.inventory().withName(enchantItems).exists() + && game.ticks() > last + 3; + } + + @Override + public void execute() { + InventoryItem item = game.inventory().withName(enchantItems).first(); + if (item == null) return; + + iWidget spellWidget = game.widget(Spells.LVL5_ENCHANT.getInfo()); + if (spellWidget == null) return; + + spellWidget.useOn(item); + + last = game.ticks(); + } +} diff --git a/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastHighAlch.java b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastHighAlch.java new file mode 100644 index 0000000..3152485 --- /dev/null +++ b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastHighAlch.java @@ -0,0 +1,66 @@ +package io.reisub.openosrs.mtahelper.tasks; + +import io.reisub.openosrs.mtahelper.MTAHelper; +import io.reisub.openosrs.util.Task; +import net.runelite.api.widgets.WidgetID; +import net.runelite.client.plugins.iutils.api.Spells; +import net.runelite.client.plugins.iutils.game.InventoryItem; +import net.runelite.client.plugins.iutils.game.iWidget; +import net.runelite.client.plugins.mta.alchemy.AlchemyItem; + +import javax.inject.Inject; + +public class CastHighAlch extends Task { + @Inject + private MTAHelper plugin; + + private long last; + private AlchemyItem best = null; + + @Override + public String getStatus() { + return "Casting high alchemy"; + } + + @Override + public boolean validate() { + best = getBest(); + + return plugin.isInRegion(MTAHelper.MTA_REGION) + && game.localPlayer().position().z == 2 + && game.ticks() >= plugin.getLastHighAlchemy() + 5 + && best != null + && (!game.inventory().withName("Coins").exists() || (game.inventory().withName("Coins").exists() && game.inventory().withName("Coins").quantity() < 10000)) + && game.inventory().withId(best.getId()).exists(); + } + + @Override + public void execute() { + InventoryItem item = game.inventory().withId(best.getId()).first(); + if (item == null) return; + + iWidget spellWidget = game.widget(Spells.HIGH_LEVEL_ALCHEMY.getInfo()); + if (spellWidget == null) return; + + spellWidget.useOn(item); + + plugin.setLastHighAlchemy(game.ticks()); + } + + private AlchemyItem getBest() { + for (int i = 0; i < 5; i++) { // 12 + iWidget textWidget = game.widget(WidgetID.MTA_ALCHEMY_GROUP_ID, 7 + i); + if (textWidget == null) return null; + + String item = textWidget.text(); + iWidget pointsWidget = game.widget(WidgetID.MTA_ALCHEMY_GROUP_ID, 12 + i); + int points = Integer.parseInt(pointsWidget.text()); + + if (points == 30) { + return AlchemyItem.find(item); + } + } + + return null; + } +} diff --git a/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastTelekineticGrab.java b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastTelekineticGrab.java new file mode 100644 index 0000000..73bc91b --- /dev/null +++ b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/CastTelekineticGrab.java @@ -0,0 +1,37 @@ +package io.reisub.openosrs.mtahelper.tasks; + +import io.reisub.openosrs.mtahelper.MTAHelper; +import io.reisub.openosrs.util.Task; +import net.runelite.client.plugins.iutils.api.Spells; +import net.runelite.client.plugins.iutils.game.iNPC; +import net.runelite.client.plugins.iutils.game.iWidget; + +import javax.inject.Inject; + +public class CastTelekineticGrab extends Task { + @Inject + private MTAHelper plugin; + + @Override + public String getStatus() { + return "Casting telekinetic grab"; + } + + @Override + public boolean validate() { + return plugin.isCastTelekineticGrab(); + } + + @Override + public void execute() { + plugin.setCastTelekineticGrab(false); + + iNPC mazeGuardian = game.npcs().withName("Maze Guardian").first(); + if (mazeGuardian == null) return; + + iWidget spellWidget = game.widget(Spells.TELEKINETIC_GRAB.getInfo()); + if (spellWidget == null) return; + + spellWidget.useOn(mazeGuardian); + } +} diff --git a/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/EatPeach.java b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/EatPeach.java new file mode 100644 index 0000000..b2b031f --- /dev/null +++ b/mtahelper/src/main/java/io/reisub/openosrs/mtahelper/tasks/EatPeach.java @@ -0,0 +1,35 @@ +package io.reisub.openosrs.mtahelper.tasks; + +import io.reisub.openosrs.util.Task; +import net.runelite.api.Skill; +import net.runelite.client.plugins.iutils.game.InventoryItem; + +public class EatPeach extends Task { + private long last; + + @Override + public String getStatus() { + return "Eating a peach"; + } + + @Override + public boolean validate() { + int missingHp = game.baseLevel(Skill.HITPOINTS) - game.modifiedLevel(Skill.HITPOINTS); + + return game.inventory().withName("Peach").exists() + && missingHp >= 8 + && game.ticks() >= last + 3; + + } + + @Override + public void execute() { + InventoryItem peach = game.inventory().withName("Peach").first(); + if (peach == null) return; + + peach.interact("Eat"); + game.tick(); + + last = game.ticks(); + } +} diff --git a/release/agility-1.0.0.jar b/release/agility-1.0.0.jar new file mode 100644 index 0000000..db2b8f4 Binary files /dev/null and b/release/agility-1.0.0.jar differ diff --git a/release/autobones-1.0.0.jar b/release/autobones-1.0.0.jar index a48bb3c..796a4ab 100644 Binary files a/release/autobones-1.0.0.jar and b/release/autobones-1.0.0.jar differ diff --git a/release/autodropper-1.0.0.jar b/release/autodropper-1.0.0.jar index 623b76d..5d08cde 100644 Binary files a/release/autodropper-1.0.0.jar and b/release/autodropper-1.0.0.jar differ diff --git a/release/birdhouse-1.0.0.jar b/release/birdhouse-1.0.0.jar index 7b87b6a..0a24554 100644 Binary files a/release/birdhouse-1.0.0.jar and b/release/birdhouse-1.0.0.jar differ diff --git a/release/bosshelper-1.0.0.jar b/release/bosshelper-1.0.0.jar new file mode 100644 index 0000000..9545d98 Binary files /dev/null and b/release/bosshelper-1.0.0.jar differ diff --git a/release/consume-1.0.0.jar b/release/consume-1.0.0.jar index 64c23b7..a619906 100644 Binary files a/release/consume-1.0.0.jar and b/release/consume-1.0.0.jar differ diff --git a/release/cooker-1.0.0.jar b/release/cooker-1.0.0.jar new file mode 100644 index 0000000..f19edd3 Binary files /dev/null and b/release/cooker-1.0.0.jar differ diff --git a/release/fighter-1.0.0.jar b/release/fighter-1.0.0.jar new file mode 100644 index 0000000..b7d1633 Binary files /dev/null and b/release/fighter-1.0.0.jar differ diff --git a/release/fisher-1.0.0.jar b/release/fisher-1.0.0.jar new file mode 100644 index 0000000..cbd25e9 Binary files /dev/null and b/release/fisher-1.0.0.jar differ diff --git a/release/glassblower-1.0.0.jar b/release/glassblower-1.0.0.jar index 5e49601..8f7704b 100644 Binary files a/release/glassblower-1.0.0.jar and b/release/glassblower-1.0.0.jar differ diff --git a/release/herblore-1.0.0.jar b/release/herblore-1.0.0.jar new file mode 100644 index 0000000..89bcdfc Binary files /dev/null and b/release/herblore-1.0.0.jar differ diff --git a/release/masterthiever-0.0.1.jar b/release/masterthiever-0.0.1.jar new file mode 100644 index 0000000..270cce1 Binary files /dev/null and b/release/masterthiever-0.0.1.jar differ diff --git a/release/masterthiever-1.0.0.jar b/release/masterthiever-1.0.0.jar index fb7e3d5..e02a64e 100644 Binary files a/release/masterthiever-1.0.0.jar and b/release/masterthiever-1.0.0.jar differ diff --git a/release/miner-1.0.0.jar b/release/miner-1.0.0.jar index 143df8a..3b29f0e 100644 Binary files a/release/miner-1.0.0.jar and b/release/miner-1.0.0.jar differ diff --git a/release/mtahelper-1.0.0.jar b/release/mtahelper-1.0.0.jar new file mode 100644 index 0000000..b80697c Binary files /dev/null and b/release/mtahelper-1.0.0.jar differ diff --git a/release/prayerflick-1.1.0.jar b/release/prayerflick-1.1.0.jar index 208a3ba..fb0fd9f 100644 Binary files a/release/prayerflick-1.1.0.jar and b/release/prayerflick-1.1.0.jar differ diff --git a/release/shopper-1.0.0.jar b/release/shopper-1.0.0.jar index 921dd74..fe08dd9 100644 Binary files a/release/shopper-1.0.0.jar and b/release/shopper-1.0.0.jar differ diff --git a/release/smelter-1.0.0.jar b/release/smelter-1.0.0.jar index 1314e6a..df9ebf3 100644 Binary files a/release/smelter-1.0.0.jar and b/release/smelter-1.0.0.jar differ diff --git a/release/smither-1.0.0.jar b/release/smither-1.0.0.jar new file mode 100644 index 0000000..6ecd0c0 Binary files /dev/null and b/release/smither-1.0.0.jar differ diff --git a/release/superglassmake-1.0.0.jar b/release/superglassmake-1.0.0.jar new file mode 100644 index 0000000..ed7f7f3 Binary files /dev/null and b/release/superglassmake-1.0.0.jar differ diff --git a/release/tempoross-1.0.0.jar b/release/tempoross-1.0.0.jar index 1c40daa..b9ba9c2 100644 Binary files a/release/tempoross-1.0.0.jar and b/release/tempoross-1.0.0.jar differ diff --git a/release/test-0.0.1.jar b/release/test-0.0.1.jar index 2f27e38..5685512 100644 Binary files a/release/test-0.0.1.jar and b/release/test-0.0.1.jar differ diff --git a/release/util-1.0.0.jar b/release/util-1.0.0.jar index c9e824a..454ae5a 100644 Binary files a/release/util-1.0.0.jar and b/release/util-1.0.0.jar differ diff --git a/release/volcanicashminer-1.0.0.jar b/release/volcanicashminer-1.0.0.jar new file mode 100644 index 0000000..2f7419e Binary files /dev/null and b/release/volcanicashminer-1.0.0.jar differ diff --git a/release/wintertodt-0.0.1.jar b/release/wintertodt-0.0.1.jar index 412b7dc..0831179 100644 Binary files a/release/wintertodt-0.0.1.jar and b/release/wintertodt-0.0.1.jar differ diff --git a/release/woodcutter-1.0.0.jar b/release/woodcutter-1.0.0.jar new file mode 100644 index 0000000..20ec1df Binary files /dev/null and b/release/woodcutter-1.0.0.jar differ diff --git a/smelter/src/main/java/io/reisub/openosrs/smelter/Activity.java b/smelter/src/main/java/io/reisub/openosrs/smelter/Activity.java deleted file mode 100644 index beadc35..0000000 --- a/smelter/src/main/java/io/reisub/openosrs/smelter/Activity.java +++ /dev/null @@ -1,6 +0,0 @@ -package io.reisub.openosrs.smelter; - -public enum Activity { - IDLE, - SMELTING; -} diff --git a/smither/smither.gradle.kts b/smither/smither.gradle.kts new file mode 100644 index 0000000..a7f2ace --- /dev/null +++ b/smither/smither.gradle.kts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Owain van Brakel + * 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 Smither" // This is the name that is used in the external plugin manager panel +project.extra["PluginDescription"] = "I shall make weapons from your bones!" // 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"] + )) + } + } +} \ No newline at end of file diff --git a/smither/src/main/java/io/reisub/openosrs/smither/Config.java b/smither/src/main/java/io/reisub/openosrs/smither/Config.java new file mode 100644 index 0000000..09d2490 --- /dev/null +++ b/smither/src/main/java/io/reisub/openosrs/smither/Config.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2018, Andrew EP | 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.smither; + +import net.runelite.client.config.Button; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("chaossmither") + +public interface Config extends net.runelite.client.config.Config { + @ConfigItem( + keyName = "metalType", + name = "Type", + description = "Choose metal type", + position = 0 + ) + default Metal metalType() { return Metal.MITHRIL; } + + @ConfigItem( + keyName = "product", + name = "Product", + description = "Choose product", + position = 1 + ) + default Product product() { return Product.PLATEBODY; } + + @ConfigItem( + keyName = "startButton", + name = "Start/Stop", + description = "Start the script", + position = 100 + ) + default Button startButton() { + return new Button(); + } +} \ No newline at end of file diff --git a/smither/src/main/java/io/reisub/openosrs/smither/Metal.java b/smither/src/main/java/io/reisub/openosrs/smither/Metal.java new file mode 100644 index 0000000..ac08ebf --- /dev/null +++ b/smither/src/main/java/io/reisub/openosrs/smither/Metal.java @@ -0,0 +1,18 @@ +package io.reisub.openosrs.smither; + +import lombok.AllArgsConstructor; +import lombok.Getter; +import net.runelite.api.ItemID; + +@AllArgsConstructor +@Getter +public enum Metal { + BRONZE(ItemID.BRONZE_BAR), + IRON(ItemID.IRON_BAR), + STEEL(ItemID.STEEL_BAR), + MITHRIL(ItemID.MITHRIL_BAR), + ADAMANTITE(ItemID.ADAMANTITE_BAR), + RUNITE(ItemID.RUNITE_BAR); + + private final int barId; +} diff --git a/smither/src/main/java/io/reisub/openosrs/smither/Product.java b/smither/src/main/java/io/reisub/openosrs/smither/Product.java new file mode 100644 index 0000000..c2ba0c8 --- /dev/null +++ b/smither/src/main/java/io/reisub/openosrs/smither/Product.java @@ -0,0 +1,13 @@ +package io.reisub.openosrs.smither; + +import lombok.AllArgsConstructor; +import lombok.Getter; + +@AllArgsConstructor +@Getter +public enum Product { + PLATEBODY(5, 22); + + private final int requiredBars; + private final int interfaceId; +} diff --git a/smither/src/main/java/io/reisub/openosrs/smither/Smither.java b/smither/src/main/java/io/reisub/openosrs/smither/Smither.java new file mode 100644 index 0000000..98901bd --- /dev/null +++ b/smither/src/main/java/io/reisub/openosrs/smither/Smither.java @@ -0,0 +1,89 @@ +package io.reisub.openosrs.smither; + +import com.google.inject.Provides; + +import io.reisub.openosrs.smither.tasks.HandleBank; +import io.reisub.openosrs.smither.tasks.Smith; +import io.reisub.openosrs.util.CScript; +import io.reisub.openosrs.util.Task; +import io.reisub.openosrs.util.Util; +import io.reisub.openosrs.util.enums.Activity; +import io.reisub.openosrs.util.tasks.Eat; +import io.reisub.openosrs.util.tasks.KittenTask; +import io.reisub.openosrs.util.tasks.Run; +import lombok.Getter; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.AnimationID; +import net.runelite.api.events.AnimationChanged; +import net.runelite.api.events.ChatMessage; +import net.runelite.api.events.ConfigButtonClicked; +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 net.runelite.client.plugins.iutils.scripts.iScript; +import org.pf4j.Extension; + +import javax.inject.Inject; +import java.time.Duration; +import java.util.ArrayList; +import java.util.List; + +@Extension +@PluginDependency(Util.class) +@PluginDependency(iUtils.class) +@PluginDescriptor( + name = "Chaos Smither", + description = "I shall make weapons from your bones!", + enabledByDefault = false +) +@Slf4j +public class Smither extends CScript { + @Inject + private Config config; + + @Provides + Config provideConfig(ConfigManager configManager) { + return configManager.getConfig(Config.class); + } + + @Override + protected void onStart() { + super.onStart(); + + lastActionTimeout = Duration.ofSeconds(5); + + Run runTask = injector.getInstance(Run.class); + runTask.setInterval(70, 95); + tasks.add(runTask); + + addTask(HandleBank.class); + addTask(Smith.class); + } + + @SuppressWarnings("unused") + @Subscribe + private void onItemContainerChanged(ItemContainerChanged event) { + int bars = (int) game.inventory().withId(config.metalType().getBarId()).count(); + + if (bars < config.product().getRequiredBars() && currentActivity == Activity.SMITHING) { + setActivity(Activity.IDLE); + } + } + + @SuppressWarnings("unused") + @Subscribe + private void onAnimationChanged(AnimationChanged event) { + if (!isLoggedIn()) return; + + int animId = game.localPlayer().animation(); + switch (animId) { + case AnimationID.SMITHING_ANVIL: + case AnimationID.SMITHING_IMCANDO_HAMMER: + setActivity(Activity.SMITHING); + break; + } + } +} \ No newline at end of file diff --git a/smither/src/main/java/io/reisub/openosrs/smither/tasks/HandleBank.java b/smither/src/main/java/io/reisub/openosrs/smither/tasks/HandleBank.java new file mode 100644 index 0000000..b3953c3 --- /dev/null +++ b/smither/src/main/java/io/reisub/openosrs/smither/tasks/HandleBank.java @@ -0,0 +1,69 @@ +package io.reisub.openosrs.smither.tasks; + +import io.reisub.openosrs.smither.Config; +import io.reisub.openosrs.smither.Smither; +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 Smither 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 + && game.inventory().withId(config.metalType().getBarId()).count() < config.product().getRequiredBars() + && 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", "Bank chest").nearest(); + if (bankObj == null) return; + + if (bankObj.actions().contains("Bank")) { + bankObj.interact("Bank"); + } else if (bankObj.actions().contains("Use")) { + bankObj.interact("Use"); + } else { + bankObj.interact(0); + } + + game.waitUntil(() -> bank.isOpen(), 15); + } + + int barCount = bank.quantity(config.metalType().getBarId()) + (int) game.inventory().withId(config.metalType().getBarId()).count(); + + if (barCount < config.product().getRequiredBars()) { + plugin.stop("Out of bars, stopping plugin."); + } + + bank.depositExcept(false, ItemID.HAMMER, ItemID.IMCANDO_HAMMER, config.metalType().getBarId()); + game.sleepDelay(); + + bank.withdraw(config.metalType().getBarId(), 28, false); + game.sleepDelay(); + + bank.close(); + game.sleepDelay(); + + lastBanking = Instant.now(); + } +} diff --git a/smither/src/main/java/io/reisub/openosrs/smither/tasks/Smith.java b/smither/src/main/java/io/reisub/openosrs/smither/tasks/Smith.java new file mode 100644 index 0000000..c5c4274 --- /dev/null +++ b/smither/src/main/java/io/reisub/openosrs/smither/tasks/Smith.java @@ -0,0 +1,50 @@ +package io.reisub.openosrs.smither.tasks; + +import io.reisub.openosrs.smither.Config; +import io.reisub.openosrs.smither.Smither; +import io.reisub.openosrs.util.Task; +import io.reisub.openosrs.util.enums.Activity; +import net.runelite.api.AnimationID; +import net.runelite.api.widgets.WidgetInfo; +import net.runelite.client.plugins.iutils.game.iObject; +import net.runelite.client.plugins.iutils.game.iWidget; + +import javax.inject.Inject; + +public class Smith extends Task { + @Inject + private Smither plugin; + + @Inject + private Config config; + + @Override + public String getStatus() { + return "Smithing"; + } + + @Override + public boolean validate() { + return plugin.getCurrentActivity() == Activity.IDLE + && !bank.isOpen() + && game.inventory().withId(config.metalType().getBarId()).count() >= config.product().getRequiredBars(); + } + + @Override + public void execute() { + iObject anvil = game.objects().withName("Anvil").withAction("Smith").nearest(); + if (anvil == null) return; + + anvil.interact("Smith"); + game.waitUntil(() -> game.widget(WidgetInfo.SMITHING_INVENTORY_ITEMS_CONTAINER) != null, 15); + + iWidget productWidget = game.widget(312, config.product().getInterfaceId()); + if (productWidget == null) return; + + productWidget.interact("Smith"); + + game.waitUntil(() -> game.localPlayer().animation() == AnimationID.SMITHING_ANVIL + || game.localPlayer().animation() == AnimationID.SMITHING_IMCANDO_HAMMER, 10); + game.tick(); + } +} diff --git a/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/Config.java b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/Config.java new file mode 100644 index 0000000..d2ab189 --- /dev/null +++ b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/Config.java @@ -0,0 +1,53 @@ +/* + * Copyright (c) 2018, Andrew EP | 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.superglassmake; + +import net.runelite.client.config.Button; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("chaossuperglassmake") + +public interface Config extends net.runelite.client.config.Config { + @ConfigItem( + keyName = "pickupGlass", + name = "Pickup glass", + description = "Pickup any glass spilling out of the inventory.", + position = 0 + ) + default boolean pickupGlass() { + return true; + } + + @ConfigItem( + keyName = "startButton", + name = "Start/Stop", + description = "Start the script", + position = 100 + ) + default Button startButton() { + return new Button(); + } +} \ No newline at end of file diff --git a/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/SuperglassMake.java b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/SuperglassMake.java new file mode 100644 index 0000000..024848c --- /dev/null +++ b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/SuperglassMake.java @@ -0,0 +1,44 @@ +package io.reisub.openosrs.superglassmake; + +import com.google.inject.Provides; +import io.reisub.openosrs.superglassmake.tasks.CastSuperglassMake; +import io.reisub.openosrs.superglassmake.tasks.HandleBank; +import io.reisub.openosrs.superglassmake.tasks.PickupGlass; +import io.reisub.openosrs.util.CScript; +import io.reisub.openosrs.util.Util; +import io.reisub.openosrs.util.tasks.Run; +import lombok.extern.slf4j.Slf4j; +import net.runelite.client.config.ConfigManager; +import net.runelite.client.plugins.PluginDependency; +import net.runelite.client.plugins.PluginDescriptor; +import net.runelite.client.plugins.iutils.iUtils; +import org.pf4j.Extension; + +@Extension +@PluginDependency(Util.class) +@PluginDependency(iUtils.class) +@PluginDescriptor( + name = "Chaos Superglass Make", + description = "A super Superglass Make caster", + enabledByDefault = false +) +@Slf4j +public class SuperglassMake extends CScript { + @Provides + Config provideConfig(ConfigManager configManager) { + return configManager.getConfig(Config.class); + } + + @Override + protected void onStart() { + super.onStart(); + + Run runTask = injector.getInstance(Run.class); + runTask.setInterval(70, 95); + tasks.add(runTask); + + addTask(PickupGlass.class); + addTask(CastSuperglassMake.class); + addTask(HandleBank.class); + } +} \ No newline at end of file diff --git a/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/CastSuperglassMake.java b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/CastSuperglassMake.java new file mode 100644 index 0000000..6186d66 --- /dev/null +++ b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/CastSuperglassMake.java @@ -0,0 +1,31 @@ +package io.reisub.openosrs.superglassmake.tasks; + +import io.reisub.openosrs.util.Task; +import net.runelite.api.ItemID; +import net.runelite.client.plugins.iutils.api.Spells; +import net.runelite.client.plugins.iutils.game.iWidget; + +public class CastSuperglassMake extends Task { + @Override + public String getStatus() { + return "Casting Superglass Make"; + } + + @Override + public boolean validate() { + return game.inventory().withId(ItemID.BUCKET_OF_SAND).exists() + && (game.inventory().withId(ItemID.SODA_ASH).exists() || (game.inventory().withId(ItemID.GIANT_SEAWEED).exists())) + && game.inventory().withId(ItemID.ASTRAL_RUNE).exists() + && !bank.isOpen(); + } + + @Override + public void execute() { + iWidget spellWidget = game.widget(Spells.SUPERGLASS_MAKE.getInfo()); + if (spellWidget == null) return; + + spellWidget.interact("Cast"); + game.waitUntil(() -> game.inventory().withId(ItemID.MOLTEN_GLASS).exists(), 5); + game.tick(3); + } +} diff --git a/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/HandleBank.java b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/HandleBank.java new file mode 100644 index 0000000..2b1c929 --- /dev/null +++ b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/HandleBank.java @@ -0,0 +1,73 @@ +package io.reisub.openosrs.superglassmake.tasks; + +import io.reisub.openosrs.superglassmake.SuperglassMake; +import io.reisub.openosrs.util.Task; +import net.runelite.api.ItemID; +import net.runelite.client.plugins.iutils.game.iObject; +import net.runelite.client.plugins.iutils.scene.Position; + +import javax.inject.Inject; +import java.time.Duration; +import java.time.Instant; + +public class HandleBank extends Task { + @Inject + private SuperglassMake plugin; + + private Instant last = Instant.EPOCH; + + @Override + public String getStatus() { + return "Banking"; + } + + @Override + public boolean validate() { + return !game.inventory().withId(ItemID.BUCKET_OF_SAND).exists(); + } + + @Override + public void execute() { + if (!bank.isOpen()) { + iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck", "Bank chest").withPosition(new Position(2098, 3920, 0)).nearest(); + if (bankObj == null) return; + + if (bankObj.actions().contains("Bank")) { + bankObj.interact("Bank"); + } else if (bankObj.actions().contains("Use")) { + bankObj.interact("Use"); + } else { + bankObj.interact(0); + } + + game.waitUntil(() -> bank.isOpen(), 3); + } + + bank.depositExcept(false, ItemID.ASTRAL_RUNE); + game.sleepDelay(); + + if (bank.quantity(ItemID.BUCKET_OF_SAND) == 0 || (bank.quantity(ItemID.SODA_ASH) == 0 && bank.quantity(ItemID.GIANT_SEAWEED) == 0)) { + plugin.stop("Out of materials, stopping plugin"); + } + + if (bank.contains(ItemID.SODA_ASH)) { + bank.withdraw(ItemID.BUCKET_OF_SAND, 13, false); + game.sleepDelay(); + + bank.withdraw(ItemID.SODA_ASH, 13, false); + game.sleepDelay(); + } else { + bank.withdraw(ItemID.BUCKET_OF_SAND, 18, false); + game.sleepDelay(); + + for (int i = 0; i < 3; i++) { + bank.withdraw(ItemID.GIANT_SEAWEED, 1, false); + game.sleepDelay(); + } + } + + bank.close(); + game.waitUntil(() -> game.inventory().withId(ItemID.BUCKET_OF_SAND).exists(), 5); + last = Instant.now(); + } +} diff --git a/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/PickupGlass.java b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/PickupGlass.java new file mode 100644 index 0000000..23cff39 --- /dev/null +++ b/superglassmake/src/main/java/io/reisub/openosrs/superglassmake/tasks/PickupGlass.java @@ -0,0 +1,39 @@ +package io.reisub.openosrs.superglassmake.tasks; + +import io.reisub.openosrs.superglassmake.Config; +import io.reisub.openosrs.util.Task; +import net.runelite.api.ItemID; +import net.runelite.client.plugins.iutils.game.iGroundItem; + +import javax.inject.Inject; +import java.time.Duration; +import java.time.Instant; + +public class PickupGlass extends Task { + @Inject + private Config config; + + private Instant last = Instant.EPOCH; + + @Override + public String getStatus() { + return "Picking up glass"; + } + + @Override + public boolean validate() { + return config.pickupGlass() + && Duration.between(last, Instant.now()).getSeconds() > 5 + && game.groundItems().withId(ItemID.MOLTEN_GLASS).withPosition(game.localPlayer().position()).exists(); + } + + @Override + public void execute() { + for (iGroundItem glass : game.groundItems().withId(ItemID.MOLTEN_GLASS).withPosition(game.localPlayer().position()).all()) { + glass.interact(0); + game.sleepDelay(); + } + + last = Instant.now(); + } +} diff --git a/superglassmake/superglassmake.gradle.kts b/superglassmake/superglassmake.gradle.kts new file mode 100644 index 0000000..40a0239 --- /dev/null +++ b/superglassmake/superglassmake.gradle.kts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Owain van Brakel + * 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 Superglass Make" // This is the name that is used in the external plugin manager panel +project.extra["PluginDescription"] = "A super Superglass Make caster" // 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"] + )) + } + } +} \ No newline at end of file diff --git a/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/Config.java b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/Config.java new file mode 100644 index 0000000..997c5a7 --- /dev/null +++ b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/Config.java @@ -0,0 +1,43 @@ +/* + * Copyright (c) 2018, Andrew EP | 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.volcanicashminer; + +import net.runelite.client.config.Button; +import net.runelite.client.config.ConfigGroup; +import net.runelite.client.config.ConfigItem; + +@ConfigGroup("chaosvolcanicashminer") + +public interface Config extends net.runelite.client.config.Config { + @ConfigItem( + keyName = "startButton", + name = "Start/Stop", + description = "Start the script", + position = 100 + ) + default Button startButton() { + return new Button(); + } +} \ No newline at end of file diff --git a/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/VolcanicAshMiner.java b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/VolcanicAshMiner.java new file mode 100644 index 0000000..553edcd --- /dev/null +++ b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/VolcanicAshMiner.java @@ -0,0 +1,96 @@ +package io.reisub.openosrs.volcanicashminer; + +import com.google.inject.Provides; +import io.reisub.openosrs.util.CScript; +import io.reisub.openosrs.util.Util; +import io.reisub.openosrs.util.enums.Activity; +import io.reisub.openosrs.util.tasks.Run; +import io.reisub.openosrs.volcanicashminer.tasks.Drop; +import io.reisub.openosrs.volcanicashminer.tasks.Mine; +import lombok.extern.slf4j.Slf4j; +import net.runelite.api.AnimationID; +import net.runelite.api.GameObject; +import net.runelite.api.GameState; +import net.runelite.api.events.AnimationChanged; +import net.runelite.api.events.GameObjectDespawned; +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; + +@Extension +@PluginDependency(Util.class) +@PluginDependency(iUtils.class) +@PluginDescriptor( + name = "Chaos Volcanic Ash Miner", + description = "Mines volcanic ash.", + enabledByDefault = false +) +@Slf4j +public class VolcanicAshMiner extends CScript { + @Provides + Config provideConfig(ConfigManager configManager) { + return configManager.getConfig(Config.class); + } + + @Override + protected void onStart() { + super.onStart(); + + Run runTask = injector.getInstance(Run.class); + runTask.setInterval(70, 95); + tasks.add(runTask); + addTask(Drop.class); + addTask(Mine.class); + } + + @SuppressWarnings("unused") + @Subscribe + private void onAnimationChanged(AnimationChanged event) { + if (game.client().getGameState() != GameState.LOGGED_IN) return; + if (event.getActor() == null || event.getActor().getName() == null) return; + + if (!event.getActor().getName().equals(game.localPlayer().name())) return; + + switch (game.localPlayer().animation()) { + case AnimationID.MINING_BRONZE_PICKAXE: + case AnimationID.MINING_IRON_PICKAXE: + case AnimationID.MINING_STEEL_PICKAXE: + case AnimationID.MINING_BLACK_PICKAXE: + case AnimationID.MINING_MITHRIL_PICKAXE: + case AnimationID.MINING_ADAMANT_PICKAXE: + case AnimationID.MINING_RUNE_PICKAXE: + case AnimationID.MINING_GILDED_PICKAXE: + case AnimationID.MINING_DRAGON_PICKAXE: + case AnimationID.MINING_DRAGON_PICKAXE_UPGRADED: + case AnimationID.MINING_INFERNAL_PICKAXE: + case AnimationID.MINING_CRYSTAL_PICKAXE: + setActivity(Activity.MINING); + break; + } + } + + @SuppressWarnings("unused") + @Subscribe + private void onGameObjectDespawned(GameObjectDespawned event) { + if (game.client().getGameState() != GameState.LOGGED_IN) return; + GameObject object = event.getGameObject(); + + if (object.getName().equals("Ash pile") && game.client().getLocalPlayer().getWorldLocation().distanceTo(object.getWorldLocation()) < 3) { + setActivity(Activity.IDLE); + } + } + + @SuppressWarnings("unused") + @Subscribe + private void onItemContainerChanged(ItemContainerChanged event) { + if (game.client().getGameState() != GameState.LOGGED_IN) return; + + if (game.inventory().withName("Soda ash").exists()) { + setActivity(Activity.IDLE); + } + } +} \ No newline at end of file diff --git a/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/tasks/Drop.java b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/tasks/Drop.java new file mode 100644 index 0000000..08c657b --- /dev/null +++ b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/tasks/Drop.java @@ -0,0 +1,21 @@ +package io.reisub.openosrs.volcanicashminer.tasks; + +import io.reisub.openosrs.util.Task; + +public class Drop extends Task { + @Override + public String getStatus() { + return "Dropping soda ash"; + } + + @Override + public boolean validate() { + return game.inventory().withName("Soda ash").exists(); + } + + @Override + public void execute() { + game.inventory().withName("Soda ash").drop(); + game.tick(); + } +} diff --git a/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/tasks/Mine.java b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/tasks/Mine.java new file mode 100644 index 0000000..65dbda9 --- /dev/null +++ b/volcanicashminer/src/main/java/io/reisub/openosrs/volcanicashminer/tasks/Mine.java @@ -0,0 +1,42 @@ +package io.reisub.openosrs.volcanicashminer.tasks; + +import io.reisub.openosrs.util.Task; +import io.reisub.openosrs.util.enums.Activity; +import io.reisub.openosrs.volcanicashminer.VolcanicAshMiner; +import net.runelite.client.plugins.iutils.game.iObject; +import net.runelite.client.plugins.iutils.scene.Position; + +import javax.inject.Inject; + +public class Mine extends Task { + @Inject + private VolcanicAshMiner plugin; + + private final Position[] ASH_PILE_POSITIONS = new Position[]{ + new Position(3794, 3773, 0), + new Position(3789, 3769, 0), + new Position(3781, 3774, 0) + }; + + @Override + public String getStatus() { + return "Mining"; + } + + @Override + public boolean validate() { + iObject ashPile = game.objects().withPosition(ASH_PILE_POSITIONS).withName("Ash pile").nearest(); + + return plugin.getCurrentActivity() == Activity.IDLE + && game.localPlayer().isIdle() + && ashPile != null; + } + + @Override + public void execute() { + iObject ashPile = game.objects().withPosition(ASH_PILE_POSITIONS).withName("Ash pile").nearest(); + + ashPile.interact("Mine"); + game.waitUntil(() -> game.localPlayer().animation() != -1, 15); + } +} diff --git a/volcanicashminer/volcanicashminer.gradle.kts b/volcanicashminer/volcanicashminer.gradle.kts new file mode 100644 index 0000000..75fb6d3 --- /dev/null +++ b/volcanicashminer/volcanicashminer.gradle.kts @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2019 Owain van Brakel + * 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 Volcanic Ash Miner" // This is the name that is used in the external plugin manager panel +project.extra["PluginDescription"] = "Mines volcanic ash" // 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"] + )) + } + } +} \ No newline at end of file diff --git a/wintertodt/src/main/java/io/reisub/openosrs/wintertodt/Activity.java b/wintertodt/src/main/java/io/reisub/openosrs/wintertodt/Activity.java deleted file mode 100644 index e28879d..0000000 --- a/wintertodt/src/main/java/io/reisub/openosrs/wintertodt/Activity.java +++ /dev/null @@ -1,17 +0,0 @@ -package io.reisub.openosrs.wintertodt; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -@AllArgsConstructor -@Getter -public enum Activity { - IDLE("Idle"), - WOODCUTTING("Woodcutting"), - FLETCHING("Fletching"), - FEEDING_BRAZIER("Feeding"), - FIXING_BRAZIER("Fixing"), - LIGHTING_BRAZIER("Lighting"); - - private final String actionString; -} diff --git a/woodcutter/src/main/java/io/reisub/openosrs/woodcutter/WoodcutterConfig.java b/woodcutter/src/main/java/io/reisub/openosrs/woodcutter/Config.java similarity index 100% rename from woodcutter/src/main/java/io/reisub/openosrs/woodcutter/WoodcutterConfig.java rename to woodcutter/src/main/java/io/reisub/openosrs/woodcutter/Config.java diff --git a/woodcutter/src/main/java/io/reisub/openosrs/woodcutter/WoodcutterPlugin.java b/woodcutter/src/main/java/io/reisub/openosrs/woodcutter/Woodcutter.java similarity index 100% rename from woodcutter/src/main/java/io/reisub/openosrs/woodcutter/WoodcutterPlugin.java rename to woodcutter/src/main/java/io/reisub/openosrs/woodcutter/Woodcutter.java