Compare commits
16 Commits
fb86f97efa
...
master
Author | SHA1 | Date | |
---|---|---|---|
d6af3d5b46
|
|||
4166c7fdf8
|
|||
2c015056fb
|
|||
5c1991fb1a
|
|||
344ee6cb24
|
|||
c0ee06e38a
|
|||
5948f13f06
|
|||
32807711f0
|
|||
7bdb37e031
|
|||
2e9808c32c
|
|||
9ec09e42d5
|
|||
01a71ba399
|
|||
08dde87681
|
|||
6ad5bc0465
|
|||
7efda7494a
|
|||
78786709eb
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "0.0.1"
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Agility" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Hippity hoppity, jumps on your property" // This is the description that is used in the external plugin manager panel
|
||||
|
@ -4,24 +4,23 @@ import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.agility.tasks.Alch;
|
||||
import io.reisub.openosrs.agility.tasks.HandleObstacle;
|
||||
import io.reisub.openosrs.agility.tasks.PickupMark;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.CScript;
|
||||
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.*;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.HitsplatApplied;
|
||||
import net.runelite.api.events.StatChanged;
|
||||
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.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@ -32,38 +31,22 @@ import java.util.List;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class AgilityPlugin extends iScript {
|
||||
public class Agility extends CScript {
|
||||
@Inject
|
||||
private AgilityConfig config;
|
||||
private Config config;
|
||||
|
||||
private List<Task> tasks;
|
||||
|
||||
private KittenTask kittenTask;
|
||||
private Alch alchTask;
|
||||
private HandleObstacle handleObstacleTask;
|
||||
private PickupMark pickupMarkTask;
|
||||
|
||||
@Provides
|
||||
AgilityConfig provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(AgilityConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
game.sleepDelay();
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Agility");
|
||||
super.onStart();
|
||||
|
||||
Eat eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setInterval(14, 24);
|
||||
@ -71,7 +54,6 @@ public class AgilityPlugin extends iScript {
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
handleObstacleTask = injector.getInstance(HandleObstacle.class);
|
||||
pickupMarkTask = injector.getInstance(PickupMark.class);
|
||||
|
||||
@ -79,10 +61,8 @@ public class AgilityPlugin extends iScript {
|
||||
alchTask = injector.getInstance(Alch.class);
|
||||
}
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(eatTask);
|
||||
tasks.add(runTask);
|
||||
tasks.add(kittenTask);
|
||||
tasks.add(pickupMarkTask);
|
||||
if (config.highAlch()) {
|
||||
tasks.add(alchTask);
|
||||
@ -92,23 +72,6 @@ public class AgilityPlugin extends iScript {
|
||||
handleObstacleTask.setReady(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Agility");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onHitsplatApplied(HitsplatApplied event) {
|
||||
if (handleObstacleTask != null) {
|
||||
@ -148,10 +111,6 @@ public class AgilityPlugin extends iScript {
|
||||
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(chatMessage);
|
||||
}
|
||||
|
||||
if (handleObstacleTask != null) {
|
||||
handleObstacleTask.onChatMessage(chatMessage);
|
||||
}
|
@ -24,13 +24,12 @@
|
||||
*/
|
||||
package io.reisub.openosrs.agility;
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosAgilityConfig")
|
||||
@ConfigGroup("chaosagility")
|
||||
|
||||
public interface AgilityConfig extends Config {
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
position = 0,
|
||||
keyName = "courseSelection",
|
@ -1,6 +1,6 @@
|
||||
package io.reisub.openosrs.agility.tasks;
|
||||
|
||||
import io.reisub.openosrs.agility.AgilityConfig;
|
||||
import io.reisub.openosrs.agility.Config;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.GameTick;
|
||||
@ -14,7 +14,7 @@ import javax.inject.Inject;
|
||||
|
||||
public class Alch extends Task {
|
||||
@Inject
|
||||
private AgilityConfig config;
|
||||
private Config config;
|
||||
|
||||
private boolean ready;
|
||||
private long lastAlchTick;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.reisub.openosrs.agility.tasks;
|
||||
|
||||
import io.reisub.openosrs.agility.AgilityConfig;
|
||||
import io.reisub.openosrs.agility.Config;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.*;
|
||||
@ -10,7 +10,7 @@ import javax.inject.Inject;
|
||||
|
||||
public class HandleObstacle extends Task {
|
||||
@Inject
|
||||
private AgilityConfig config;
|
||||
private Config config;
|
||||
|
||||
private boolean ready;
|
||||
private int timeout = 10;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package io.reisub.openosrs.agility.tasks;
|
||||
|
||||
import io.reisub.openosrs.agility.AgilityConfig;
|
||||
import io.reisub.openosrs.agility.Config;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.HitsplatApplied;
|
||||
@ -12,7 +12,7 @@ import javax.inject.Inject;
|
||||
|
||||
public class PickupMark extends Task {
|
||||
@Inject
|
||||
private AgilityConfig config;
|
||||
private Config config;
|
||||
|
||||
private boolean failed;
|
||||
|
||||
|
52
autoalcher/autoalcher.gradle.kts
Normal file
52
autoalcher/autoalcher.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Auto Alcher" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Gold! Always believe in your soul." // This is the description that is used in the external plugin manager panel
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes(mapOf(
|
||||
"Plugin-Version" to project.version,
|
||||
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
|
||||
"Plugin-Provider" to project.extra["PluginProvider"],
|
||||
"Plugin-Description" to project.extra["PluginDescription"],
|
||||
"Plugin-Dependencies" to
|
||||
arrayOf(
|
||||
nameToId("Chaos Util"),
|
||||
nameToId("iUtils")
|
||||
).joinToString(),
|
||||
"Plugin-License" to project.extra["PluginLicense"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,178 @@
|
||||
package io.reisub.openosrs.autoalcher;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Calculations;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Varbits;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.events.ConfigChanged;
|
||||
import net.runelite.client.game.RunepouchRune;
|
||||
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.api.Spells;
|
||||
import net.runelite.client.plugins.iutils.game.Game;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Auto Alcher",
|
||||
description = "Gold! Always believe in your soul.",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Autoalcher extends Plugin implements KeyListener {
|
||||
@Inject
|
||||
private Game game;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Inject
|
||||
private Calculations calc;
|
||||
|
||||
@Inject
|
||||
private KeyManager keyManager;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
private static final Varbits[] AMOUNT_VARBITS = {
|
||||
Varbits.RUNE_POUCH_AMOUNT1, Varbits.RUNE_POUCH_AMOUNT2, Varbits.RUNE_POUCH_AMOUNT3
|
||||
};
|
||||
private static final Varbits[] RUNE_VARBITS = {
|
||||
Varbits.RUNE_POUCH_RUNE1, Varbits.RUNE_POUCH_RUNE2, Varbits.RUNE_POUCH_RUNE3
|
||||
};
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
private boolean active;
|
||||
private long last;
|
||||
private String[] names;
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
log.info("Starting Chaos Auto Alcher");
|
||||
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
keyManager.registerKeyListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() {
|
||||
log.info("Stopping Chaos Auto Alcher");
|
||||
|
||||
executor.shutdownNow();
|
||||
keyManager.unregisterKeyListener(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (!active || last + 5 > game.ticks()) return;
|
||||
|
||||
if (names == null) parseItems();
|
||||
|
||||
if (names == null || names.length == 0) return;
|
||||
|
||||
if (game.inventory().withNamePart(names).exists()
|
||||
&& hasRunes()) {
|
||||
executor.schedule(this::alch, calc.random(100, 200), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigChanged(ConfigChanged event) {
|
||||
if (!event.getGroup().equals("chaosautoalcher")) return;
|
||||
|
||||
if (event.getKey().equals("alchItems")) {
|
||||
parseItems();
|
||||
}
|
||||
}
|
||||
|
||||
private void alch() {
|
||||
InventoryItem item = game.inventory().withNamePart(names).first();
|
||||
iWidget spellWidget = game.widget(Spells.HIGH_LEVEL_ALCHEMY.getInfo());
|
||||
if (item == null || spellWidget == null) return;
|
||||
|
||||
spellWidget.useOn(item);
|
||||
last = game.ticks();
|
||||
|
||||
game.tick(3);
|
||||
game.openInterface(3);
|
||||
}
|
||||
|
||||
private void parseItems() {
|
||||
names = config.alchItems().split(";");
|
||||
|
||||
for (int i = 0; i < names.length; i++) {
|
||||
names[i] = names[i].trim();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.autoalchHotkey().matches(e)) {
|
||||
active = !active;
|
||||
|
||||
if (active) {
|
||||
game.utils.sendGameMessage("Enabled Auto Alcher");
|
||||
} else {
|
||||
game.utils.sendGameMessage("Disabled Auto Alcher");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
|
||||
}
|
||||
|
||||
private boolean hasRunes() {
|
||||
int fireRunes = (int) game.inventory().withId(ItemID.FIRE_RUNE).count();
|
||||
int natureRunes = (int) game.inventory().withId(ItemID.NATURE_RUNE).count();
|
||||
|
||||
if (game.inventory().withId(ItemID.RUNE_POUCH).exists()) {
|
||||
for (int i = 0; i < AMOUNT_VARBITS.length; i++) {
|
||||
int amount = game.client().getVar(AMOUNT_VARBITS[i]);
|
||||
if (amount <= 0) continue;
|
||||
|
||||
RunepouchRune rune = RunepouchRune.getRune(game.client().getVar(RUNE_VARBITS[i]));
|
||||
|
||||
switch (rune) {
|
||||
case NATURE:
|
||||
natureRunes += amount;
|
||||
break;
|
||||
case FIRE:
|
||||
fireRunes += amount;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return fireRunes >= 5 && natureRunes >= 1;
|
||||
}
|
||||
}
|
@ -0,0 +1,65 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.autoalcher;
|
||||
|
||||
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.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ConfigGroup("chaosautoalcher")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "alchItems",
|
||||
name = "Items",
|
||||
description = "List of items to alch, separated by a semicolon. You can use a part of the name.",
|
||||
position = 0
|
||||
)
|
||||
default String alchItems() { return "Rune arrow"; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "autoalchHotkey",
|
||||
name = "Hotkey",
|
||||
description = "Press this key to toggle auto alching.",
|
||||
position = 2
|
||||
)
|
||||
default Keybind autoalchHotkey() {
|
||||
return new Keybind(KeyEvent.VK_F9, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import net.runelite.api.ItemID;
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Ashes {
|
||||
NONE(-1),
|
||||
FIENDISH_ASHES(ItemID.FIENDISH_ASHES),
|
||||
VILE_ASHES(ItemID.VILE_ASHES),
|
||||
MALICIOUS_ASHES(ItemID.MALICIOUS_ASHES),
|
||||
@ -14,4 +15,21 @@ public enum Ashes {
|
||||
INFERNAL_ASHES(ItemID.INFERNAL_ASHES);
|
||||
|
||||
private final int id;
|
||||
|
||||
static Ashes[] allBelow(Ashes ashes) {
|
||||
if (ashes == NONE) return new Ashes[0];
|
||||
|
||||
Ashes[] allBelow = new Ashes[ashes.ordinal()];
|
||||
int i = 0;
|
||||
|
||||
for (Ashes a : Ashes.values()) {
|
||||
if (a == NONE) continue;
|
||||
|
||||
allBelow[i++] = a;
|
||||
|
||||
if (a == ashes) break;
|
||||
}
|
||||
|
||||
return allBelow;
|
||||
}
|
||||
}
|
||||
|
@ -4,7 +4,6 @@ import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
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.eventbus.Subscribe;
|
||||
@ -13,13 +12,10 @@ 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.util.Locale;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@ -48,12 +44,16 @@ public class Autobones extends Plugin {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
private int[] itemIds;
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
log.info("Starting Chaos Autobones");
|
||||
|
||||
itemIds = parseItemIds();
|
||||
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
|
||||
@ -61,9 +61,19 @@ public class Autobones extends Plugin {
|
||||
protected void shutDown() {
|
||||
log.info("Stopping Chaos Autobones");
|
||||
|
||||
itemIds = null;
|
||||
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onConfigChanged(ConfigChanged event) {
|
||||
if (event.getGroup().equals("chaosautobones")) {
|
||||
itemIds = parseItemIds();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||
@ -72,7 +82,34 @@ public class Autobones extends Plugin {
|
||||
if (config.bones().getId() == -1 && config.ashes().getId() == -1) return;
|
||||
|
||||
executor.schedule(() -> {
|
||||
game.inventory().withId(config.bones().getId(), config.ashes().getId()).first().interact(0);
|
||||
game.inventory().withId(itemIds).first().interact(0);
|
||||
}, 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
private int[] parseItemIds() {
|
||||
int[] ids;
|
||||
|
||||
if (config.allBelow()) {
|
||||
Ashes[] allAshes = Ashes.allBelow(config.ashes());
|
||||
Bones[] allBones = Bones.allBelow(config.bones());
|
||||
|
||||
ids = new int[allAshes.length + allBones.length];
|
||||
int i = 0;
|
||||
|
||||
for (Ashes a : allAshes) {
|
||||
ids[i++] = a.getId();
|
||||
}
|
||||
|
||||
for (Bones b : allBones) {
|
||||
ids[i++] = b.getId();
|
||||
}
|
||||
} else {
|
||||
ids = new int[2];
|
||||
|
||||
ids[0] = config.ashes().getId();
|
||||
ids[1] = config.bones().getId();
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
}
|
@ -31,4 +31,21 @@ public enum Bones {
|
||||
SUPERIOR_DRAGON_BONES(ItemID.SUPERIOR_DRAGON_BONES);
|
||||
|
||||
private final int id;
|
||||
|
||||
static Bones[] allBelow(Bones bones) {
|
||||
if (bones == NONE) return new Bones[0];
|
||||
|
||||
Bones[] allBelow = new Bones[bones.ordinal()];
|
||||
int i = 0;
|
||||
|
||||
for (Bones b : Bones.values()) {
|
||||
if (b == NONE) continue;
|
||||
|
||||
allBelow[i++] = b;
|
||||
|
||||
if (b == bones) break;
|
||||
}
|
||||
|
||||
return allBelow;
|
||||
}
|
||||
}
|
||||
|
@ -45,4 +45,12 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
position = 1
|
||||
)
|
||||
default Ashes ashes() { return Ashes.VILE_ASHES; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "allBelow",
|
||||
name = "Bury/scatter all below threshold",
|
||||
description = "Bury/scatter all the bones/ashes of lower value including the chosen bones/ashes.",
|
||||
position = 2
|
||||
)
|
||||
default boolean allBelow() { return true; }
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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",
|
||||
|
@ -0,0 +1,7 @@
|
||||
package io.reisub.openosrs.autodropper;
|
||||
|
||||
public enum DropMethod {
|
||||
NONE,
|
||||
ON_ADD,
|
||||
ON_FULL_INVENTORY;
|
||||
}
|
@ -30,10 +30,10 @@ import java.util.List;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class BasePlugin extends iScript {
|
||||
public class BasePlugin extends CScript {
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(BaseConfig.class);
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,12 +10,15 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.input.KeyListener;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.HashMap;
|
||||
@ -30,7 +33,10 @@ import java.util.Map;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Birdhouse extends CScript {
|
||||
public class Birdhouse extends CScript implements KeyListener {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
@ -100,4 +106,21 @@ public class Birdhouse extends CScript {
|
||||
public boolean hasRecentlyBeenEmptied(BirdhouseSpace space) {
|
||||
return Duration.between(getBirdhouseTimers().get(space), Instant.now()).getSeconds() < 2000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.birdhouseHotkey().matches(e)) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
|
||||
}
|
||||
}
|
@ -1,10 +1,11 @@
|
||||
package io.reisub.openosrs.birdhouse;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum BirdhouseType {
|
||||
|
@ -27,15 +27,29 @@ package io.reisub.openosrs.birdhouse;
|
||||
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.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ConfigGroup("chaosbirdhouse")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "birdhouseHotkey",
|
||||
name = "Hotkey",
|
||||
description = "Press this key to start a birdhouse run.",
|
||||
position = 0
|
||||
)
|
||||
default Keybind birdhouseHotkey() {
|
||||
return new Keybind(KeyEvent.VK_F12, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "farmSeaweed",
|
||||
name = "Farm seaweed",
|
||||
description = "Harvest and plant seaweed after a birdhouse run.",
|
||||
position = 0
|
||||
position = 1
|
||||
)
|
||||
default boolean farmSeaweed() { return true; }
|
||||
|
||||
|
@ -42,7 +42,9 @@ public class BankSpores extends Task {
|
||||
bank.depositInventory();
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.SEAWEED_SPORE, 2, false);
|
||||
bank.withdraw(ItemID.SEAWEED_SPORE, 1, false);
|
||||
game.sleepDelay();
|
||||
bank.withdraw(ItemID.SEAWEED_SPORE, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.FISHBOWL_HELMET, 1, false);
|
||||
@ -51,6 +53,9 @@ public class BankSpores extends Task {
|
||||
bank.withdraw(ItemID.DIVING_APPARATUS, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.withdraw(ItemID.FLIPPERS, 1, false);
|
||||
game.tick();
|
||||
|
||||
bank.close();
|
||||
game.waitUntil(() -> !bank.isOpen(), 5);
|
||||
|
||||
@ -59,6 +64,9 @@ public class BankSpores extends Task {
|
||||
|
||||
game.inventory().withId(ItemID.DIVING_APPARATUS).findFirst().ifPresent((apparatus) -> apparatus.interact("Wear"));
|
||||
game.tick();
|
||||
|
||||
game.inventory().withId(ItemID.FLIPPERS).findFirst().ifPresent((flippers) -> flippers.interact("Wear"));
|
||||
game.tick();
|
||||
iObject rowboat = game.objects().withName("Rowboat").nearest();
|
||||
if (rowboat == null) return;
|
||||
|
||||
|
@ -7,7 +7,6 @@ import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
public class EmptyBirdhouse extends Task {
|
||||
|
@ -23,7 +23,7 @@ public class GetTools extends Task {
|
||||
if (leprechaun == null) return;
|
||||
|
||||
leprechaun.interact("Exchange");
|
||||
game.waitUntil(() -> game.widget(125, 0) != null, 30);
|
||||
game.waitUntil(() -> game.widget(125, 0) != null && !game.widget(125, 0).hidden(), 30);
|
||||
game.tick();
|
||||
|
||||
iWidget dibber = game.widget(125, 9);
|
||||
|
52
bosshelper/bosshelper.gradle.kts
Normal file
52
bosshelper/bosshelper.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.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();
|
||||
}
|
||||
}
|
@ -24,7 +24,7 @@
|
||||
*/
|
||||
|
||||
object ProjectVersions {
|
||||
const val openosrsVersion = "4.17.0"
|
||||
const val openosrsVersion = "4.19.0"
|
||||
const val apiVersion = "^1.0.0"
|
||||
}
|
||||
|
||||
|
@ -24,9 +24,15 @@
|
||||
*/
|
||||
package io.reisub.openosrs.consume;
|
||||
|
||||
import net.runelite.client.config.*;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.ConfigSection;
|
||||
import net.runelite.client.config.Keybind;
|
||||
|
||||
@ConfigGroup("ChaosConsumeConfig")
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ConfigGroup("chaosconsume")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigSection(
|
||||
@ -221,7 +227,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
unhide = "drinkStrength"
|
||||
)
|
||||
default int strengthLevel() {
|
||||
return 100;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -258,7 +264,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
unhide = "drinkAttack"
|
||||
)
|
||||
default int attackLevel() {
|
||||
return 100;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -295,7 +301,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
unhide = "drinkDefence"
|
||||
)
|
||||
default int defenceLevel() {
|
||||
return 100;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -332,7 +338,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
unhide = "drinkRanged"
|
||||
)
|
||||
default int rangedLevel() {
|
||||
return 100;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -369,7 +375,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
unhide = "drinkMagic"
|
||||
)
|
||||
default int magicLevel() {
|
||||
return 100;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -384,4 +390,69 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
default boolean magicWarnings() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ConfigSection(
|
||||
keyName = "specialConfig",
|
||||
name = "Weapon Special Configuration",
|
||||
description = "Configure weapon specials",
|
||||
position = 40
|
||||
)
|
||||
String specialConfig = "specialConfig";
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "useSpecial",
|
||||
name = "Use special",
|
||||
description = "Use weapon special",
|
||||
section = "specialConfig",
|
||||
position = 41
|
||||
)
|
||||
default boolean useSpecial() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "specialWeapon",
|
||||
name = "Weapon",
|
||||
description = "What weapon to use the special of. Leaving this empty will use the currently equipped weapon.",
|
||||
section = "specialConfig",
|
||||
hidden = true,
|
||||
unhide = "useSpecial",
|
||||
position = 42
|
||||
)
|
||||
default String specialWeapon() { return ""; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "specialCost",
|
||||
name = "Special cost",
|
||||
description = "Cost of the special attack.",
|
||||
section = "specialConfig",
|
||||
hidden = true,
|
||||
unhide = "useSpecial",
|
||||
position = 43
|
||||
)
|
||||
default int specialCost() { return 100; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "pkTeleport",
|
||||
name = "PK teleport hotkey",
|
||||
description = "Pressing the hotkey will toggle watching for skulled players or players attacking you and try to teleport away. Requires an equipped charged amulet of glory.",
|
||||
position = 50
|
||||
)
|
||||
default Keybind pkTeleport() {
|
||||
return new Keybind(KeyEvent.VK_F1, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "tpOnDangerousPlayer",
|
||||
name = "TP on dangerous player",
|
||||
description = "Attempt to teleport when a skulled player within level range appears.",
|
||||
position = 51
|
||||
)
|
||||
default boolean tpOnDangerousPlayer() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "tpOnPlayerAttack",
|
||||
name = "TP on player attack",
|
||||
description = "Attempt to teleport when we're being attacked by a player.",
|
||||
position = 52
|
||||
)
|
||||
default boolean tpOnPlayerAttack() { return true; }
|
||||
}
|
@ -4,24 +4,35 @@ import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Calculations;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.VarPlayer;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
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.EquipmentItem;
|
||||
import net.runelite.client.plugins.iutils.game.Game;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.ui.Bank;
|
||||
import net.runelite.client.plugins.iutils.ui.Equipment;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@ -32,19 +43,28 @@ import java.util.Set;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Consume extends Plugin {
|
||||
@Inject
|
||||
public class Consume extends Plugin implements KeyListener {
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
private Game game;
|
||||
|
||||
@Inject
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Inject
|
||||
private KeyManager keyManager;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
private Calculations calc;
|
||||
|
||||
@Inject
|
||||
private Bank bank;
|
||||
|
||||
@Inject
|
||||
private Equipment equipment;
|
||||
|
||||
private final Set<Integer> IGNORE_FOOD = Set.of(ItemID.DWARVEN_ROCK_CAKE, ItemID.DWARVEN_ROCK_CAKE_7510);
|
||||
private final Set<Integer> DRINK_SET = Set.of(ItemID.JUG_OF_WINE, ItemID.SARADOMIN_BREW1, ItemID.SARADOMIN_BREW2, ItemID.SARADOMIN_BREW3, ItemID.SARADOMIN_BREW4, ItemID.XERICS_AID_1, ItemID.XERICS_AID_2, ItemID.XERICS_AID_3, ItemID.XERICS_AID_4, ItemID.XERICS_AID_1_20977, ItemID.XERICS_AID_2_20978, ItemID.XERICS_AID_3_20979, ItemID.XERICS_AID_4_20980, ItemID.XERICS_AID_1_20981, ItemID.XERICS_AID_2_20982, ItemID.XERICS_AID_3_20983, ItemID.XERICS_AID_4_20984, ItemID.BANDAGES);
|
||||
private final Set<Integer> ANTI_POISON_IDS = Set.of(ItemID.ANTIPOISON1, ItemID.ANTIPOISON2, ItemID.ANTIPOISON3, ItemID.ANTIPOISON4, ItemID.SUPERANTIPOISON1, ItemID.SUPERANTIPOISON2, ItemID.SUPERANTIPOISON3, ItemID.SUPERANTIPOISON4,
|
||||
@ -83,6 +103,7 @@ public class Consume extends Plugin {
|
||||
ItemID.DIVINE_MAGIC_POTION1, ItemID.DIVINE_MAGIC_POTION2, ItemID.DIVINE_MAGIC_POTION3, ItemID.DIVINE_MAGIC_POTION4,
|
||||
ItemID.DIVINE_BATTLEMAGE_POTION1, ItemID.DIVINE_BATTLEMAGE_POTION2, ItemID.DIVINE_BATTLEMAGE_POTION3, ItemID.DIVINE_BATTLEMAGE_POTION4);
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
private long lastAte;
|
||||
private long lastPot;
|
||||
private int timeout;
|
||||
@ -104,9 +125,12 @@ public class Consume extends Plugin {
|
||||
private long lastRanged;
|
||||
private boolean shouldDrinkMagic;
|
||||
private long lastMagic;
|
||||
private boolean shouldUseSpecial;
|
||||
private long lastSpecial;
|
||||
private boolean pkTeleport;
|
||||
|
||||
@Provides
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
@ -114,26 +138,123 @@ public class Consume extends Plugin {
|
||||
@Override
|
||||
protected void startUp() {
|
||||
log.info("Starting Chaos Consume");
|
||||
|
||||
generateNewEatThreshold();
|
||||
generateNewPrayerThreshold();
|
||||
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
keyManager.registerKeyListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() {
|
||||
log.info("Stopping Chaos Consume");
|
||||
|
||||
executor.shutdownNow();
|
||||
keyManager.unregisterKeyListener(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (game.client() == null || game.localPlayer() == null || game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
if (game.client() == null || game.localPlayer() == null || game.client().getGameState() != GameState.LOGGED_IN || bank.isOpen()) return;
|
||||
|
||||
if (timeout > 0) {
|
||||
timeout--;
|
||||
return;
|
||||
}
|
||||
|
||||
if (eatThreshold == 0) generateNewEatThreshold();
|
||||
if (prayerThreshold == 0) generateNewPrayerThreshold();
|
||||
executor.schedule(this::tick, calc.random(50, 80), TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onVarbitChanged(VarbitChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
if (config.drinkAntiPoison()
|
||||
&& event.getIndex() == VarPlayer.POISON.getId()
|
||||
&& game.client().getVarpValue(VarPlayer.POISON.getId()) > 0) {
|
||||
shouldDrinkAntiPoison = true;
|
||||
}
|
||||
|
||||
if (config.useSpecial()
|
||||
&& event.getIndex() == VarPlayer.SPECIAL_ATTACK_PERCENT.getId()
|
||||
&& game.client().getVarpValue(VarPlayer.SPECIAL_ATTACK_PERCENT.getId()) / 10 >= config.specialCost()
|
||||
&& lastSpecial + 2000 < System.currentTimeMillis()) {
|
||||
shouldUseSpecial = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
|
||||
String BURN_MESSAGE = ("You're horribly burnt by the dragon fire!");
|
||||
String BURN_EXPIRE = ("antifire potion is about to expire.");
|
||||
|
||||
String message = event.getMessage();
|
||||
|
||||
if (config.drinkAntiFire() && (message.contains(BURN_MESSAGE) || message.contains(BURN_EXPIRE))) {
|
||||
shouldDrinkAntiFire = true;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onStatChanged(StatChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN || timeout > 0) return;
|
||||
|
||||
Skill skill = event.getSkill();
|
||||
int level = event.getBoostedLevel();
|
||||
|
||||
checkSkill(skill, level);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameStateChanged(GameStateChanged event) {
|
||||
if (event.getGameState() == GameState.LOGGED_IN) {
|
||||
timeout = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onConfigChanged(ConfigChanged event) {
|
||||
if (!event.getGroup().equals("chaosconsume")) return;
|
||||
|
||||
switch (event.getKey()) {
|
||||
case "minEatHP":
|
||||
case "maxEatHP":
|
||||
generateNewEatThreshold();
|
||||
break;
|
||||
case "minPrayerPoints":
|
||||
case "maxPrayerPoints":
|
||||
generateNewPrayerThreshold();
|
||||
case "drinkPrayer":
|
||||
checkSkill(Skill.PRAYER);
|
||||
break;
|
||||
case "strengthLevel":
|
||||
checkSkill(Skill.STRENGTH);
|
||||
break;
|
||||
case "attackLevel":
|
||||
checkSkill(Skill.ATTACK);
|
||||
break;
|
||||
case "defenceLevel":
|
||||
checkSkill(Skill.DEFENCE);
|
||||
break;
|
||||
case "rangedLevel":
|
||||
checkSkill(Skill.RANGED);
|
||||
break;
|
||||
case "magicLevel":
|
||||
checkSkill(Skill.MAGIC);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void tick() {
|
||||
int hp = game.modifiedLevel(Skill.HITPOINTS);
|
||||
|
||||
if (config.enableEating() && hp <= eatThreshold && canEat()) {
|
||||
@ -160,6 +281,20 @@ public class Consume extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldUseSpecial && game.client().getVarpValue(VarPlayer.SPECIAL_ATTACK_ENABLED.getId()) == 0) {
|
||||
shouldUseSpecial = false;
|
||||
lastSpecial = System.currentTimeMillis();
|
||||
|
||||
if (game.varb(Varbits.PVP_SPEC_ORB.getId()) == 0) {
|
||||
iWidget special = game.widget(WidgetInfo.MINIMAP_SPEC_CLICKBOX);
|
||||
if (special == null) return;
|
||||
|
||||
special.interact(0);
|
||||
} else {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldDrinkAntiPoison && canPot()) {
|
||||
if (!drinkPotion(ANTI_POISON_IDS) && config.antiPoisonWarnings()) {
|
||||
game.utils.sendGameMessage("Poisoned but you don't have anti-poison!");
|
||||
@ -241,81 +376,82 @@ public class Consume extends Plugin {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onVarbitChanged(VarbitChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
private void onPlayerSpawned(PlayerSpawned event) {
|
||||
if (!config.tpOnDangerousPlayer() || !pkTeleport || game.client().getVar(Varbits.IN_WILDERNESS) == 0 || event.getPlayer() == null) return;
|
||||
|
||||
if (config.drinkAntiPoison()
|
||||
&& event.getIndex() == VarPlayer.POISON.getId()
|
||||
&& game.client().getVarpValue(VarPlayer.POISON.getId()) > 0) {
|
||||
shouldDrinkAntiPoison = true;
|
||||
iWidget wildernessLevelWidget = game.widget(WidgetInfo.PVP_WILDERNESS_LEVEL);
|
||||
if (wildernessLevelWidget == null || wildernessLevelWidget.text() == null) return;
|
||||
|
||||
Pattern regex = Pattern.compile("\\d+-\\d+");
|
||||
Matcher levelMatcher = regex.matcher(wildernessLevelWidget.text());
|
||||
|
||||
if (levelMatcher.find()) {
|
||||
String[] levelRange = levelMatcher.group(0).split("-");
|
||||
int lowerLevel = Integer.parseInt(levelRange[0]);
|
||||
int upperLevel = Integer.parseInt(levelRange[1]);
|
||||
|
||||
int playerLevel = event.getPlayer().getCombatLevel();
|
||||
|
||||
if (event.getPlayer().getSkullIcon() != null && (playerLevel >= lowerLevel && playerLevel <= upperLevel)) {
|
||||
log.info("Dangerous player spawned: " + event.getPlayer().getName());
|
||||
executor.schedule(this::teleport, 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onChatMessage(ChatMessage event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN) return;
|
||||
private void onInteractingChanged(InteractingChanged event) {
|
||||
if (!config.tpOnPlayerAttack() || !pkTeleport || game.client().getVar(Varbits.IN_WILDERNESS) == 0) return;
|
||||
|
||||
String BURN_MESSAGE = ("You're horribly burnt by the dragon fire!");
|
||||
String BURN_EXPIRE = ("antifire potion is about to expire.");
|
||||
if (event.getSource() == null || event.getTarget() == null || event.getTarget().getName() == null) return;
|
||||
|
||||
String message = event.getMessage();
|
||||
|
||||
if (config.drinkAntiFire() && (message.contains(BURN_MESSAGE) || message.contains(BURN_EXPIRE))) {
|
||||
shouldDrinkAntiFire = true;
|
||||
if (event.getSource() instanceof Player && event.getTarget().equals(game.client().getLocalPlayer())) {
|
||||
log.info("Player attacking us: " + event.getSource().getName());
|
||||
executor.schedule(this::teleport, 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onStatChanged(StatChanged event) {
|
||||
if (game.client().getGameState() != GameState.LOGGED_IN || timeout > 0) return;
|
||||
private void teleport() {
|
||||
pkTeleport = false;
|
||||
|
||||
Skill skill = event.getSkill();
|
||||
int level = event.getBoostedLevel();
|
||||
iWidget wildernessLevelWidget = game.widget(WidgetInfo.PVP_WILDERNESS_LEVEL);
|
||||
if (wildernessLevelWidget == null || wildernessLevelWidget.text() == null) return;
|
||||
|
||||
checkSkill(skill, level);
|
||||
Pattern regex = Pattern.compile("Level: \\d+");
|
||||
Matcher levelMatcher = regex.matcher(wildernessLevelWidget.text());
|
||||
|
||||
if (!levelMatcher.find()) return;
|
||||
|
||||
if (Integer.parseInt(levelMatcher.group(0).split(" ")[1]) > 30) return;
|
||||
|
||||
EquipmentItem amuletOfGlory = game.equipment().withAction("Edgeville").first();
|
||||
if (amuletOfGlory == null) return;
|
||||
|
||||
amuletOfGlory.interact("Edgeville");
|
||||
game.tick(3);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onGameStateChanged(GameStateChanged event) {
|
||||
if (event.getGameState() == GameState.LOGGED_IN) {
|
||||
timeout = 5;
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.pkTeleport().matches(e)) {
|
||||
pkTeleport = !pkTeleport;
|
||||
|
||||
if (pkTeleport) {
|
||||
game.utils.sendGameMessage("Enabled PK teleport");
|
||||
} else {
|
||||
game.utils.sendGameMessage("Disabled PK teleport");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onConfigChanged(ConfigChanged event) {
|
||||
switch (event.getKey()) {
|
||||
case "minEatHP":
|
||||
case "maxEatHP":
|
||||
generateNewEatThreshold();
|
||||
break;
|
||||
case "minPrayerPoints":
|
||||
case "maxPrayerPoints":
|
||||
generateNewPrayerThreshold();
|
||||
case "drinkPrayer":
|
||||
checkSkill(Skill.PRAYER);
|
||||
break;
|
||||
case "strengthLevel":
|
||||
checkSkill(Skill.STRENGTH);
|
||||
break;
|
||||
case "attackLevel":
|
||||
checkSkill(Skill.ATTACK);
|
||||
break;
|
||||
case "defenceLevel":
|
||||
checkSkill(Skill.DEFENCE);
|
||||
break;
|
||||
case "rangedLevel":
|
||||
checkSkill(Skill.RANGED);
|
||||
break;
|
||||
case "magicLevel":
|
||||
checkSkill(Skill.MAGIC);
|
||||
break;
|
||||
}
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
|
||||
}
|
||||
|
||||
private void generateNewEatThreshold() {
|
||||
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "0.0.1"
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Cooker" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Cooks better than Gordon Ramsay" // This is the description that is used in the external plugin manager panel
|
||||
|
@ -1,6 +0,0 @@
|
||||
package io.reisub.openosrs.cooker;
|
||||
|
||||
public enum Activity {
|
||||
IDLE,
|
||||
COOKING;
|
||||
}
|
@ -28,7 +28,7 @@ import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosCookerConfig")
|
||||
@ConfigGroup("chaoscooker")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
|
@ -3,34 +3,23 @@ package io.reisub.openosrs.cooker;
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.cooker.tasks.Cook;
|
||||
import io.reisub.openosrs.cooker.tasks.HandleBank;
|
||||
import io.reisub.openosrs.cooker.tasks.SkipLevel;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
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 lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.GameState;
|
||||
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.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import static net.runelite.api.AnimationID.IDLE;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@ -41,14 +30,7 @@ import static net.runelite.api.AnimationID.IDLE;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Cooker extends iScript {
|
||||
private List<Task> tasks;
|
||||
|
||||
@Getter
|
||||
private Activity currentActivity;
|
||||
|
||||
private Instant lastActionTime;
|
||||
|
||||
public class Cooker extends CScript {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@ -57,50 +39,16 @@ public class Cooker extends iScript {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
checkActionTimeout();
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Cooker");
|
||||
super.onStart();
|
||||
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(runTask);
|
||||
tasks.add(injector.getInstance(SkipLevel.class));
|
||||
tasks.add(injector.getInstance(HandleBank.class));
|
||||
tasks.add(injector.getInstance(Cook.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Cooker");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
addTask(HandleBank.class);
|
||||
addTask(Cook.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -124,36 +72,4 @@ public class Cooker extends iScript {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (chatMessage.getType() == ChatMessageType.GAMEMESSAGE) {
|
||||
if (chatMessage.getMessage().startsWith("Congratulations, you've just advanced your")) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void setActivity(Activity action) {
|
||||
currentActivity = action;
|
||||
|
||||
if (action != Activity.IDLE) {
|
||||
lastActionTime = Instant.now();
|
||||
}
|
||||
}
|
||||
|
||||
private void checkActionTimeout() {
|
||||
if (currentActivity == Activity.IDLE) return;
|
||||
|
||||
int animId = game.localPlayer().animation();
|
||||
if (animId != IDLE || lastActionTime == null) return;
|
||||
|
||||
Duration timeout = Duration.ofSeconds(3);
|
||||
Duration sinceAction = Duration.between(lastActionTime, Instant.now());
|
||||
|
||||
if (sinceAction.compareTo(timeout) >= 0) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
package io.reisub.openosrs.cooker.tasks;
|
||||
|
||||
import io.reisub.openosrs.cooker.Activity;
|
||||
import io.reisub.openosrs.cooker.Config;
|
||||
import io.reisub.openosrs.cooker.Cooker;
|
||||
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.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
52
fighter/fighter.gradle.kts
Normal file
52
fighter/fighter.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
114
fighter/src/main/java/io/reisub/openosrs/fighter/Config.java
Normal file
114
fighter/src/main/java/io/reisub/openosrs/fighter/Config.java
Normal file
@ -0,0 +1,114 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.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();
|
||||
}
|
||||
}
|
116
fighter/src/main/java/io/reisub/openosrs/fighter/Fighter.java
Normal file
116
fighter/src/main/java/io/reisub/openosrs/fighter/Fighter.java
Normal file
@ -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];
|
||||
}
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -23,7 +23,7 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "0.0.1"
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Fisher" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Frantically fishes fish" // This is the description that is used in the external plugin manager panel
|
||||
|
@ -25,13 +25,12 @@
|
||||
package io.reisub.openosrs.fisher;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosFisherConfig")
|
||||
@ConfigGroup("chaosfisher")
|
||||
|
||||
public interface FisherConfig extends Config {
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
37
fisher/src/main/java/io/reisub/openosrs/fisher/Fisher.java
Normal file
37
fisher/src/main/java/io/reisub/openosrs/fisher/Fisher.java
Normal file
@ -0,0 +1,37 @@
|
||||
package io.reisub.openosrs.fisher;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.fisher.tasks.Drop;
|
||||
import io.reisub.openosrs.fisher.tasks.Fish;
|
||||
import io.reisub.openosrs.util.CScript;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
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 Fisher",
|
||||
description = "Frantically fishes fish",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Fisher extends CScript {
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
addTask(Drop.class);
|
||||
addTask(Fish.class);
|
||||
}
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
package io.reisub.openosrs.fisher;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.fisher.tasks.Drop;
|
||||
import io.reisub.openosrs.fisher.tasks.Fish;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
||||
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 Fisher",
|
||||
description = "Frantically fishes fish",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class FisherPlugin extends iScript {
|
||||
private List<Task> tasks;
|
||||
|
||||
private KittenTask kittenTask;
|
||||
|
||||
@Provides
|
||||
FisherConfig provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(FisherConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Fisher");
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(kittenTask);
|
||||
tasks.add(injector.getInstance(Drop.class));
|
||||
tasks.add(injector.getInstance(Fish.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Fisher");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(chatMessage);
|
||||
}
|
||||
}
|
||||
}
|
@ -3,14 +3,8 @@ package io.reisub.openosrs.fisher.tasks;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.ui.Bank;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DoBank extends Task {
|
||||
@Inject
|
||||
public Bank bank;
|
||||
|
||||
public class HandleBank extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Banking";
|
@ -39,6 +39,14 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
)
|
||||
default Product targetProduct() { return Product.LANTERN_LENS; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "farmSeaweedSpores",
|
||||
name = "Farm seaweed spores",
|
||||
description = "Go underwater at the Fossil Island to farm seaweed spores.",
|
||||
position = 1
|
||||
)
|
||||
default boolean farmSeaweedSpores() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
|
@ -4,9 +4,9 @@ import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.glassblower.tasks.Blow;
|
||||
import io.reisub.openosrs.glassblower.tasks.HandleBank;
|
||||
import io.reisub.openosrs.glassblower.tasks.PickupSeed;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
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.AnimationID;
|
||||
import net.runelite.api.GameState;
|
||||
|
@ -2,8 +2,8 @@ package io.reisub.openosrs.glassblower.tasks;
|
||||
|
||||
import io.reisub.openosrs.glassblower.Config;
|
||||
import io.reisub.openosrs.glassblower.Glassblower;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
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.game.iObject;
|
||||
@ -32,7 +32,7 @@ public class Blow extends Task {
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SMALL_ISLAND_REGION) {
|
||||
if (config.farmSeaweedSpores() && game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SMALL_ISLAND_REGION) {
|
||||
iObject rowboat = game.objects().withName("Rowboat").nearest();
|
||||
if (rowboat == null) return;
|
||||
|
||||
@ -47,6 +47,8 @@ public class Blow extends Task {
|
||||
game.tick();
|
||||
}
|
||||
|
||||
if (config.farmSeaweedSpores() && game.groundItems().withId(ItemID.SEAWEED_SPORE).exists()) return;
|
||||
|
||||
InventoryItem pipe = game.inventory().withId(ItemID.GLASSBLOWING_PIPE).first();
|
||||
InventoryItem moltenGlass = game.inventory().withId(ItemID.MOLTEN_GLASS).first();
|
||||
if (pipe == null || moltenGlass == null) return;
|
||||
|
@ -1,14 +1,17 @@
|
||||
package io.reisub.openosrs.glassblower.tasks;
|
||||
|
||||
import io.reisub.openosrs.glassblower.Config;
|
||||
import io.reisub.openosrs.glassblower.Glassblower;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.tasks.BankTask;
|
||||
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 {
|
||||
public class HandleBank extends BankTask {
|
||||
private Instant lastBanking = Instant.EPOCH;
|
||||
|
||||
@Override
|
||||
@ -39,13 +42,7 @@ public class HandleBank extends Task {
|
||||
game.tick();
|
||||
}
|
||||
|
||||
if (!bank.isOpen()) {
|
||||
iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck").nearest();
|
||||
if (bankObj == null) return;
|
||||
|
||||
bankObj.interact(0);
|
||||
game.waitUntil(() -> bank.isOpen(), 15);
|
||||
}
|
||||
openBank(5);
|
||||
|
||||
bank.depositExcept(false, ItemID.GLASSBLOWING_PIPE, ItemID.SEAWEED_SPORE);
|
||||
// bank.depositAll(false, ItemID.BEER_GLASS,
|
||||
|
@ -1,5 +1,6 @@
|
||||
package io.reisub.openosrs.glassblower.tasks;
|
||||
|
||||
import io.reisub.openosrs.glassblower.Glassblower;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.iGroundItem;
|
||||
@ -23,6 +24,7 @@ public class PickupSeed extends Task {
|
||||
int quantity = game.inventory().withId(ItemID.SEAWEED_SPORE).quantity();
|
||||
|
||||
item.interact("Take");
|
||||
game.waitUntil(() -> game.inventory().withId(ItemID.SEAWEED_SPORE).quantity() > quantity, 30);
|
||||
game.waitUntil(() -> game.inventory().withId(ItemID.SEAWEED_SPORE).quantity() > quantity
|
||||
|| (game.localPlayer() != null && game.localPlayer().position().regionID() == Glassblower.FOSSIL_ISLAND_SMALL_ISLAND_REGION), 30);
|
||||
}
|
||||
}
|
||||
|
52
herblore/herblore.gradle.kts
Normal file
52
herblore/herblore.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,75 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.herblore;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("chaosherblore")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "herbloreTask",
|
||||
name = "Task",
|
||||
description = "Select what to do.",
|
||||
position = 0
|
||||
)
|
||||
default HerbloreTask herbloreTask() { return HerbloreTask.CLEAN_HERBS; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "quantity",
|
||||
name = "Quantity",
|
||||
description = "Choose how many herbs to clean or potions to make. 0 is unlimited and will work until you're out of materials.",
|
||||
position = 1
|
||||
)
|
||||
default int quantity() { return 0; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "herbType",
|
||||
name = "Herb type",
|
||||
description = "Select which herbs to clean or make unfinished potions with.",
|
||||
position = 2
|
||||
)
|
||||
default Herb herbType() { return Herb.ALL; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "makePotion",
|
||||
name = "Potion",
|
||||
description = "Select which potions to make.",
|
||||
position = 3
|
||||
)
|
||||
default Potion makePotion() { return Potion.SUPER_STRENGTH; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
53
herblore/src/main/java/io/reisub/openosrs/herblore/Herb.java
Normal file
53
herblore/src/main/java/io/reisub/openosrs/herblore/Herb.java
Normal file
@ -0,0 +1,53 @@
|
||||
package io.reisub.openosrs.herblore;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Herb {
|
||||
ALL(-1, -1, -1),
|
||||
GUAM_LEAF(ItemID.GRIMY_GUAM_LEAF, ItemID.GUAM_LEAF, ItemID.GUAM_POTION_UNF),
|
||||
MARRENTILL(ItemID.GRIMY_MARRENTILL, ItemID.MARRENTILL, ItemID.MARRENTILL_POTION_UNF),
|
||||
TARROMIN(ItemID.GRIMY_TARROMIN, ItemID.TARROMIN, ItemID.TARROMIN_POTION_UNF),
|
||||
HARRALANDER(ItemID.GRIMY_HARRALANDER, ItemID.HARRALANDER, ItemID.HARRALANDER_POTION_UNF),
|
||||
RANARR_WEED(ItemID.GRIMY_RANARR_WEED, ItemID.RANARR_WEED, ItemID.RANARR_POTION_UNF),
|
||||
TOADFLAX(ItemID.GRIMY_TOADFLAX, ItemID.TOADFLAX, ItemID.TOADFLAX_POTION_UNF),
|
||||
IRIT_LEAF(ItemID.GRIMY_IRIT_LEAF, ItemID.IRIT_LEAF, ItemID.IRIT_POTION_UNF),
|
||||
AVANTOE(ItemID.GRIMY_AVANTOE, ItemID.AVANTOE, ItemID.AVANTOE_POTION_UNF),
|
||||
KWUARM(ItemID.GRIMY_KWUARM, ItemID.KWUARM, ItemID.KWUARM_POTION_UNF),
|
||||
SNAPDRAGON(ItemID.GRIMY_SNAPDRAGON, ItemID.SNAPDRAGON, ItemID.SNAPDRAGON_POTION_UNF),
|
||||
CADANTINE(ItemID.GRIMY_CADANTINE, ItemID.CADANTINE, ItemID.CADANTINE_POTION_UNF),
|
||||
LANTADYME(ItemID.GRIMY_LANTADYME, ItemID.LANTADYME, ItemID.LANTADYME_POTION_UNF),
|
||||
DWARF_WEED(ItemID.GRIMY_DWARF_WEED, ItemID.DWARF_WEED, ItemID.DWARF_WEED_POTION_UNF),
|
||||
TORSTOL(ItemID.GRIMY_TORSTOL, ItemID.TORSTOL, ItemID.TORSTOL_POTION_UNF);
|
||||
|
||||
private final int grimyId;
|
||||
private final int cleanId;
|
||||
private final int unfinishedId;
|
||||
|
||||
public static int[] getAllGrimyIds() {
|
||||
final int[] ids = new int[Herb.values().length-1];
|
||||
int i = 0;
|
||||
|
||||
for (Herb herb : Herb.values()) {
|
||||
if (herb == Herb.ALL) continue;
|
||||
ids[i++] = herb.getGrimyId();
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
|
||||
public static int[] getAllCleanIds() {
|
||||
final int[] ids = new int[Herb.values().length-1];
|
||||
int i = 0;
|
||||
|
||||
for (Herb herb : Herb.values()) {
|
||||
if (herb == Herb.ALL) continue;
|
||||
ids[i++] = herb.getCleanId();
|
||||
}
|
||||
|
||||
return ids;
|
||||
}
|
||||
}
|
149
herblore/src/main/java/io/reisub/openosrs/herblore/Herblore.java
Normal file
149
herblore/src/main/java/io/reisub/openosrs/herblore/Herblore.java
Normal file
@ -0,0 +1,149 @@
|
||||
package io.reisub.openosrs.herblore;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.herblore.tasks.Clean;
|
||||
import io.reisub.openosrs.herblore.tasks.HandleBank;
|
||||
import io.reisub.openosrs.herblore.tasks.MakePotion;
|
||||
import io.reisub.openosrs.herblore.tasks.MakeUnfinished;
|
||||
import io.reisub.openosrs.util.CScript;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Herblore",
|
||||
description = "You put the lime in the coconut, you drank them both up",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Herblore extends CScript {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
idleCheckInventoryChange = true;
|
||||
|
||||
addTask(Clean.class);
|
||||
addTask(MakeUnfinished.class);
|
||||
addTask(MakePotion.class);
|
||||
addTask(HandleBank.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||
if (!isLoggedIn() || event.getItemContainer() != game.client().getItemContainer(InventoryID.INVENTORY)) return;
|
||||
|
||||
int grimyHerbs = (int) game.inventory().withId(getGrimyHerbIds()).count();
|
||||
int cleanHerbs = (int) game.inventory().withId(getCleanHerbIds()).count();
|
||||
int bases = (int) game.inventory().withId(getBaseIds()).count();
|
||||
|
||||
if (grimyHerbs == 0 && currentActivity == Activity.CLEANING_HERBS) {
|
||||
setActivity(Activity.IDLE);
|
||||
} else if (cleanHerbs == 0 && currentActivity == Activity.CREATING_UNFINISHED_POTIONS) {
|
||||
setActivity(Activity.IDLE);
|
||||
} else if (bases == 0 && currentActivity == Activity.CREATING_POTIONS) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
public boolean shouldClean() {
|
||||
HerbloreTask task = config.herbloreTask();
|
||||
|
||||
return task == HerbloreTask.CLEAN_HERBS
|
||||
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED
|
||||
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED_AND_MAKE_POTION;
|
||||
}
|
||||
|
||||
public boolean shouldMakeUnfinished() {
|
||||
HerbloreTask task = config.herbloreTask();
|
||||
|
||||
return task == HerbloreTask.MAKE_UNFINISHED
|
||||
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED
|
||||
|| task == HerbloreTask.MAKE_UNFINISHED_AND_MAKE_POTION
|
||||
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED_AND_MAKE_POTION;
|
||||
}
|
||||
|
||||
public boolean shouldMakePotion() {
|
||||
HerbloreTask task = config.herbloreTask();
|
||||
|
||||
return task == HerbloreTask.MAKE_POTION
|
||||
|| task == HerbloreTask.MAKE_UNFINISHED_AND_MAKE_POTION
|
||||
|| task == HerbloreTask.CLEAN_HERBS_AND_MAKE_UNFINISHED_AND_MAKE_POTION;
|
||||
}
|
||||
|
||||
public Herb getHerb() {
|
||||
Herb herb;
|
||||
|
||||
if (shouldMakePotion()) {
|
||||
herb = config.makePotion().getHerb();
|
||||
} else {
|
||||
herb = config.herbType();
|
||||
}
|
||||
|
||||
return herb;
|
||||
}
|
||||
|
||||
public int[] getGrimyHerbIds() {
|
||||
Herb herb = getHerb();
|
||||
|
||||
if (herb == null) {
|
||||
return new int[]{};
|
||||
} else if (herb == Herb.ALL) {
|
||||
return Herb.getAllGrimyIds();
|
||||
} else {
|
||||
return new int[]{ herb.getGrimyId() };
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getCleanHerbIds() {
|
||||
Herb herb = getHerb();
|
||||
|
||||
if (herb == null) {
|
||||
return new int[]{};
|
||||
} else if (herb == Herb.ALL) {
|
||||
return Herb.getAllCleanIds();
|
||||
} else {
|
||||
return new int[]{ herb.getCleanId() };
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getBaseIds() {
|
||||
Potion potion = config.makePotion();
|
||||
|
||||
if (potion.getHerb() == null || potion.getSecondaryId() == -1) {
|
||||
return new int[]{ potion.getPotionBaseId() };
|
||||
} else {
|
||||
return new int[]{ potion.getHerb().getUnfinishedId() };
|
||||
}
|
||||
}
|
||||
|
||||
public int[] getSecondaryIds() {
|
||||
if (config.makePotion().getSecondaryId() == -1) {
|
||||
return new int[]{ config.makePotion().getHerb().getCleanId() };
|
||||
} else {
|
||||
return new int[]{ config.makePotion().getSecondaryId() };
|
||||
}
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -0,0 +1,46 @@
|
||||
package io.reisub.openosrs.herblore.tasks;
|
||||
|
||||
import io.reisub.openosrs.herblore.Herblore;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
public class MakePotion extends Task {
|
||||
@Inject
|
||||
private Herblore plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Making potions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.shouldMakePotion()
|
||||
&& plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& game.inventory().withId(plugin.getSecondaryIds()).exists()
|
||||
&& game.inventory().withId(plugin.getBaseIds()).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
plugin.setActivity(Activity.CREATING_POTIONS);
|
||||
|
||||
List<InventoryItem> secondaries = game.inventory().withId(plugin.getSecondaryIds()).all();
|
||||
List<InventoryItem> bases = game.inventory().withId(plugin.getBaseIds()).all();
|
||||
|
||||
if (secondaries.size() == 0 || bases.size() == 0) return;
|
||||
|
||||
int quantity = Math.min(secondaries.size(), bases.size());
|
||||
|
||||
secondaries.get(0).useOn(bases.get(0));
|
||||
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.MAKE, 5);
|
||||
|
||||
chatbox.make(0, quantity);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,47 @@
|
||||
package io.reisub.openosrs.herblore.tasks;
|
||||
|
||||
import io.reisub.openosrs.herblore.Herblore;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
public class MakeUnfinished extends Task {
|
||||
@Inject
|
||||
private Herblore plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Making unfinished potions";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.shouldMakeUnfinished()
|
||||
&& plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& game.inventory().withId(plugin.getCleanHerbIds()).exists()
|
||||
&& game.inventory().withId(ItemID.VIAL_OF_WATER, ItemID.VIAL_OF_BLOOD, ItemID.COCONUT_MILK).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
plugin.setActivity(Activity.CREATING_UNFINISHED_POTIONS);
|
||||
|
||||
List<InventoryItem> herbs = game.inventory().withId(plugin.getCleanHerbIds()).all();
|
||||
List<InventoryItem> bases = game.inventory().withId(ItemID.VIAL_OF_WATER, ItemID.VIAL_OF_BLOOD, ItemID.COCONUT_MILK).all();
|
||||
|
||||
if (herbs.size() == 0 || bases.size() == 0) return;
|
||||
|
||||
int quantity = Math.min(herbs.size(), bases.size());
|
||||
|
||||
herbs.get(0).useOn(bases.get(0));
|
||||
game.waitUntil(() -> chatbox.chatState() == Chatbox.ChatState.MAKE, 5);
|
||||
|
||||
chatbox.make(0, quantity);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -24,13 +24,50 @@
|
||||
*/
|
||||
package io.reisub.openosrs.masterthiever;
|
||||
|
||||
import io.reisub.openosrs.util.enums.Food;
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosMasterThieverConfig")
|
||||
@ConfigGroup("chaosmasterthiever")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "minEatHP",
|
||||
name = "Minimum Eat HP",
|
||||
description = "Minimum HP to eat or bank at.",
|
||||
position = 0
|
||||
)
|
||||
default int minEatHP() {
|
||||
return 10;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "maxEatHP",
|
||||
name = "Maximum Eat HP",
|
||||
description = "Highest HP to potentially eat or bank at.",
|
||||
position = 1
|
||||
)
|
||||
default int maxEatHP() {
|
||||
return 20;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "food",
|
||||
name = "Food",
|
||||
description = "Choose what food to eat.",
|
||||
position = 2
|
||||
)
|
||||
default Food food() { return Food.SALMON; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "healAtBank",
|
||||
name = "Heal at bank",
|
||||
description = "Heal at bank and don't take food with us when thieving.",
|
||||
position = 3
|
||||
)
|
||||
default boolean healAtBank() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
|
@ -1,40 +1,41 @@
|
||||
package io.reisub.openosrs.masterthiever;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import io.reisub.openosrs.masterthiever.tasks.HandleBank;
|
||||
import io.reisub.openosrs.masterthiever.tasks.Steal;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
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.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.api.Actor;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.ItemContainerChanged;
|
||||
import net.runelite.api.events.StatChanged;
|
||||
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;
|
||||
import javax.inject.Inject;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Master Thiever",
|
||||
description = "Steals seeds from master farmers.",
|
||||
description = "Cor blimey mate, what are ye doing in me pockets?",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class MasterThiever extends iScript {
|
||||
private List<Task> tasks;
|
||||
private KittenTask kittenTask;
|
||||
public class MasterThiever extends CScript {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
private Eat eatTask;
|
||||
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
@ -42,55 +43,39 @@ public class MasterThiever extends iScript {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setInterval(config.minEatHP(), config.maxEatHP());
|
||||
|
||||
tasks.add(eatTask);
|
||||
addTask(HandleBank.class);
|
||||
addTask(Steal.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event) {
|
||||
Actor actor = event.getActor();
|
||||
if (actor == null || actor.getName() == null) return;
|
||||
|
||||
if (!actor.getName().equals(game.localPlayer().name())) return;
|
||||
|
||||
switch (game.localPlayer().animation()) {
|
||||
case 388:
|
||||
setActivity(Activity.IDLE);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Master Thiever");
|
||||
|
||||
Eat eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setInterval(14, 24);
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(eatTask);
|
||||
tasks.add(kittenTask);
|
||||
tasks.add(injector.getInstance(HandleBank.class));
|
||||
tasks.add(injector.getInstance(Steal.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Master Thiever");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
private void onStatChanged(StatChanged event) {
|
||||
if (event.getSkill() == Skill.THIEVING) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(chatMessage);
|
||||
}
|
||||
public int getEatThreshold() {
|
||||
return eatTask.getThreshold();
|
||||
}
|
||||
}
|
@ -1,15 +1,23 @@
|
||||
package io.reisub.openosrs.masterthiever.tasks;
|
||||
|
||||
import io.reisub.openosrs.masterthiever.Config;
|
||||
import io.reisub.openosrs.masterthiever.MasterThiever;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.client.plugins.iutils.api.Interactable;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import java.util.function.Predicate;
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class HandleBank extends Task {
|
||||
@Inject
|
||||
private MasterThiever plugin;
|
||||
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Banking";
|
||||
@ -19,21 +27,22 @@ public class HandleBank extends Task {
|
||||
public boolean validate() {
|
||||
return game.client().getLocalPlayer().getModelHeight() != 1000
|
||||
&& (game.inventory().full()
|
||||
|| (!game.inventory().withAction("Eat").exists() && game.modifiedLevel(Skill.HITPOINTS) <= 35));
|
||||
|| (!game.inventory().withAction("Eat").exists() && game.modifiedLevel(Skill.HITPOINTS) <= plugin.getEatThreshold()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.tick();
|
||||
if (!bank.isOpen()) {
|
||||
Interactable bankObj;
|
||||
if (calc.random(0, 1) == 0) {
|
||||
bankObj = game.objects().filter(obj -> obj.name().equals("Bank booth") && obj.position().equals(new Position(3091, 3245, 0))).first();
|
||||
} else {
|
||||
bankObj = game.npcs().filter(npc -> npc.name().equals("Banker") && npc.position().equals(new Position(3090, 3245, 0))).first();
|
||||
iObject bankObj = game.objects().withAction("Bank").withPosition(new Position(3091, 3245, 0)).first();
|
||||
if (bankObj == null) {
|
||||
bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck").withAction("Bank").nearest();
|
||||
}
|
||||
|
||||
if (bankObj == null) return;
|
||||
if (bankObj == null) {
|
||||
walking.walkTo(new Position(3090, 3248, 0).areaWithin(2));
|
||||
return;
|
||||
}
|
||||
|
||||
bankObj.interact("Bank");
|
||||
game.waitUntil(() -> bank.isOpen(), 15);
|
||||
@ -42,12 +51,21 @@ public class HandleBank extends Task {
|
||||
bank.depositInventory();
|
||||
game.tick();
|
||||
|
||||
int quantity = 5 + (game.baseLevel(Skill.HITPOINTS) - game.modifiedLevel(Skill.HITPOINTS)) / 9;
|
||||
int missingHp = game.baseLevel(Skill.HITPOINTS) - game.modifiedLevel(Skill.HITPOINTS);
|
||||
|
||||
int quantity = config.healAtBank() ? missingHp / config.food().getHp() : 5 + (missingHp / config.food().getHp());
|
||||
|
||||
bank.withdraw(ItemID.SALMON, quantity, false);
|
||||
game.waitUntil(() -> game.inventory().withAction("Eat", "Drink").count() > 1, 6);
|
||||
|
||||
bank.close();
|
||||
game.waitUntil(() -> !bank.isOpen(), 3);
|
||||
|
||||
if (config.healAtBank()) {
|
||||
game.inventory().withId(config.food().getId()).forEach((food) -> {
|
||||
food.interact(0);
|
||||
game.tick(3);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,19 @@
|
||||
package io.reisub.openosrs.masterthiever.tasks;
|
||||
|
||||
import io.reisub.openosrs.masterthiever.MasterThiever;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.api.AnimationID;
|
||||
import net.runelite.api.NpcID;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Steal extends Task {
|
||||
@Inject
|
||||
private MasterThiever plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Pickpocketing";
|
||||
@ -14,8 +22,9 @@ public class Steal extends Task {
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return !game.inventory().full()
|
||||
&& plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& game.client().getLocalPlayer().getModelHeight() != 1000
|
||||
&& (game.inventory().withAction("Eat").exists() || game.modifiedLevel(Skill.HITPOINTS) > 35);
|
||||
&& (game.inventory().withAction("Eat").exists() || game.modifiedLevel(Skill.HITPOINTS) > plugin.getEatThreshold());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -24,8 +33,9 @@ public class Steal extends Task {
|
||||
|
||||
if (farmer == null) return;
|
||||
|
||||
|
||||
farmer.interact("Pickpocket");
|
||||
game.tick(calc.random(0, 2));
|
||||
game.sleepDelay();
|
||||
plugin.setActivity(Activity.THIEVING);
|
||||
game.tick();
|
||||
}
|
||||
}
|
||||
|
@ -10,7 +10,10 @@ import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Queue;
|
||||
|
||||
public class Mine extends Task {
|
||||
@Inject
|
||||
|
52
motherlodeminer/motherlodeminer.gradle.kts
Normal file
52
motherlodeminer/motherlodeminer.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Motherlode Miner" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Diggy, diggy hole" // This is the description that is used in the external plugin manager panel
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes(mapOf(
|
||||
"Plugin-Version" to project.version,
|
||||
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
|
||||
"Plugin-Provider" to project.extra["PluginProvider"],
|
||||
"Plugin-Description" to project.extra["PluginDescription"],
|
||||
"Plugin-Dependencies" to
|
||||
arrayOf(
|
||||
nameToId("Chaos Util"),
|
||||
nameToId("iUtils")
|
||||
).joinToString(),
|
||||
"Plugin-License" to project.extra["PluginLicense"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.motherlodeminer;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("chaosmotherlodeminer")
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
@ -0,0 +1,232 @@
|
||||
package io.reisub.openosrs.motherlodeminer;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.tasks.*;
|
||||
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.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.coords.LocalPoint;
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Motherlode Miner",
|
||||
description = "Diggy, diggy hole",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class MotherlodeMiner extends CScript {
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
private static final Set<Integer> MOTHERLODE_MAP_REGIONS = ImmutableSet.of(14679, 14680, 14681, 14935, 14936, 14937, 15191, 15192, 15193);
|
||||
private static final int UPPER_FLOOR_HEIGHT = -490;
|
||||
private static final int SACK_LARGE_SIZE = 162;
|
||||
private static final int SACK_SIZE = 81;
|
||||
|
||||
private int curSackSize, maxSackSize;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private boolean sackFull;
|
||||
|
||||
@Getter
|
||||
private boolean inMlm;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Position currentVeinPosition;
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
game.tick();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
|
||||
inMlm = checkInMlm();
|
||||
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
addTask(Mine.class);
|
||||
addTask(GoDown.class);
|
||||
addTask(Deposit.class);
|
||||
addTask(FixWheel.class);
|
||||
addTask(WithdrawSack.class);
|
||||
addTask(HandleBank.class);
|
||||
addTask(GoUp.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (currentVeinPosition != null && currentActivity == Activity.MINING) {
|
||||
if (game.objects().withPosition(currentVeinPosition).withAction("Mine").first() == null) {
|
||||
currentVeinPosition = null;
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
if (executor != null) {
|
||||
executor.schedule(() -> {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
checkActionTimeout();
|
||||
}, 0, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event) {
|
||||
Actor actor = event.getActor();
|
||||
if (actor == null || actor.getName() == null || !actor.getName().equals(game.localPlayer().name())) return;
|
||||
|
||||
int animId = game.localPlayer().animation();
|
||||
switch (animId) {
|
||||
case AnimationID.MINING_MOTHERLODE_BRONZE:
|
||||
case AnimationID.MINING_MOTHERLODE_IRON:
|
||||
case AnimationID.MINING_MOTHERLODE_STEEL:
|
||||
case AnimationID.MINING_MOTHERLODE_BLACK:
|
||||
case AnimationID.MINING_MOTHERLODE_MITHRIL:
|
||||
case AnimationID.MINING_MOTHERLODE_ADAMANT:
|
||||
case AnimationID.MINING_MOTHERLODE_RUNE:
|
||||
case AnimationID.MINING_MOTHERLODE_DRAGON:
|
||||
case AnimationID.MINING_MOTHERLODE_DRAGON_OR:
|
||||
case AnimationID.MINING_MOTHERLODE_DRAGON_UPGRADED:
|
||||
case AnimationID.MINING_MOTHERLODE_CRYSTAL:
|
||||
case AnimationID.MINING_MOTHERLODE_GILDED:
|
||||
case AnimationID.MINING_MOTHERLODE_INFERNAL:
|
||||
case AnimationID.MINING_MOTHERLODE_3A:
|
||||
setActivity(Activity.MINING);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameObjectDespawned(GameObjectDespawned event) {
|
||||
if (currentActivity == Activity.REPAIRING && event.getGameObject().getName().equals("Broken strut")) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||
if (currentActivity == Activity.DEPOSITING) {
|
||||
if (!game.inventory().withName("Pay-dirt").exists()) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
} else if (currentActivity == Activity.WITHDRAWING) {
|
||||
if (game.inventory().withId(
|
||||
ItemID.RUNITE_ORE,
|
||||
ItemID.ADAMANTITE_ORE,
|
||||
ItemID.MITHRIL_ORE,
|
||||
ItemID.GOLD_ORE,
|
||||
ItemID.COAL,
|
||||
ItemID.UNCUT_SAPPHIRE,
|
||||
ItemID.UNCUT_EMERALD,
|
||||
ItemID.UNCUT_RUBY,
|
||||
ItemID.UNCUT_DIAMOND,
|
||||
ItemID.UNCUT_DRAGONSTONE
|
||||
).exists()) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
} else if (currentActivity == Activity.MINING) {
|
||||
if (game.inventory().full()) {
|
||||
setActivity(Activity.IDLE);
|
||||
currentVeinPosition = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onVarbitChanged(VarbitChanged event) {
|
||||
if (inMlm) {
|
||||
refreshSackValues();
|
||||
if (curSackSize >= maxSackSize - 26) {
|
||||
sackFull = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameStateChanged(GameStateChanged event) {
|
||||
if (event.getGameState() == GameState.LOADING) {
|
||||
inMlm = checkInMlm();
|
||||
} else if (event.getGameState() == GameState.LOGIN_SCREEN) {
|
||||
inMlm = false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean checkInMlm() {
|
||||
GameState state = game.client.getGameState();
|
||||
if (state != GameState.LOGGED_IN && state != GameState.LOADING) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int[] currentMapRegions = game.client.getMapRegions();
|
||||
|
||||
for (int region : currentMapRegions) {
|
||||
if (!MOTHERLODE_MAP_REGIONS.contains(region)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
private void refreshSackValues() {
|
||||
curSackSize = game.client.getVar(Varbits.SACK_NUMBER);
|
||||
boolean sackUpgraded = game.client.getVar(Varbits.SACK_UPGRADED) == 1;
|
||||
maxSackSize = sackUpgraded ? SACK_LARGE_SIZE : SACK_SIZE;
|
||||
|
||||
if (curSackSize == 0) {
|
||||
sackFull = false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isUpstairs() {
|
||||
return Perspective.getTileHeight(game.client, game.client.getLocalPlayer().getLocalLocation(), 0) < UPPER_FLOOR_HEIGHT;
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
package io.reisub.openosrs.motherlodeminer.tasks;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.MotherlodeMiner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.scene.RectangularArea;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Deposit extends Task {
|
||||
@Inject
|
||||
private MotherlodeMiner plugin;
|
||||
|
||||
private final RectangularArea hopperArea = new RectangularArea(
|
||||
new Position(3741, 5657, 0),
|
||||
new Position(3755, 5674, 0)
|
||||
);
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Depositing in hopper";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& !plugin.isUpstairs()
|
||||
&& game.inventory().withName("Pay-dirt").exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject hopper = game.objects().withName("Hopper").nearest();
|
||||
if (hopper == null) return;
|
||||
|
||||
plugin.setActivity(Activity.DEPOSITING);
|
||||
|
||||
hopper.interact("Deposit");
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.IDLE, 15);
|
||||
game.tick(2);
|
||||
}
|
||||
}
|
@ -0,0 +1,39 @@
|
||||
package io.reisub.openosrs.motherlodeminer.tasks;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.MotherlodeMiner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class FixWheel extends Task {
|
||||
@Inject
|
||||
private MotherlodeMiner plugin;
|
||||
|
||||
private List<iObject> brokenStruts;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Fixing wheel";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (plugin.getCurrentActivity() != Activity.IDLE || plugin.isUpstairs()) return false;
|
||||
|
||||
brokenStruts = game.objects().withName("Broken strut").all();
|
||||
|
||||
return brokenStruts.size() == 2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
plugin.setActivity(Activity.REPAIRING);
|
||||
|
||||
brokenStruts.get(0).interact("Hammer");
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.IDLE, 30);
|
||||
}
|
||||
}
|
@ -0,0 +1,42 @@
|
||||
package io.reisub.openosrs.motherlodeminer.tasks;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.MotherlodeMiner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.scene.RectangularArea;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class GoDown extends Task {
|
||||
@Inject
|
||||
private MotherlodeMiner plugin;
|
||||
|
||||
private final RectangularArea miningArea = new RectangularArea(
|
||||
new Position(3748, 5676, 0),
|
||||
new Position(3754, 5684, 0)
|
||||
);
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Going down";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& plugin.isUpstairs()
|
||||
&& game.inventory().full();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject ladder = game.objects().withName("Ladder").nearest();
|
||||
if (ladder == null) return;
|
||||
|
||||
ladder.interact("Climb");
|
||||
game.waitUntil(() -> !plugin.isUpstairs(), 15);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,32 @@
|
||||
package io.reisub.openosrs.motherlodeminer.tasks;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.MotherlodeMiner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class GoUp extends Task {
|
||||
@Inject
|
||||
private MotherlodeMiner plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Going up";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return !plugin.isUpstairs();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject ladder = game.objects().withName("Ladder").withAction("Climb").nearest();
|
||||
if (ladder == null) return;
|
||||
|
||||
ladder.interact("Climb");
|
||||
game.waitUntil(() -> plugin.isUpstairs(), 15);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
package io.reisub.openosrs.motherlodeminer.tasks;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.MotherlodeMiner;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.util.tasks.BankTask;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
|
||||
public class HandleBank extends BankTask {
|
||||
@Inject
|
||||
private MotherlodeMiner plugin;
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (plugin.isUpstairs() || plugin.getCurrentActivity() != Activity.IDLE) return false;
|
||||
|
||||
return isLastBankDurationAgo(Duration.ofSeconds(2))
|
||||
&& game.inventory().withId(
|
||||
ItemID.RUNITE_ORE,
|
||||
ItemID.ADAMANTITE_ORE,
|
||||
ItemID.MITHRIL_ORE,
|
||||
ItemID.GOLD_ORE,
|
||||
ItemID.COAL,
|
||||
ItemID.UNCUT_SAPPHIRE,
|
||||
ItemID.UNCUT_EMERALD,
|
||||
ItemID.UNCUT_RUBY,
|
||||
ItemID.UNCUT_DIAMOND,
|
||||
ItemID.UNCUT_DRAGONSTONE
|
||||
).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
openBank();
|
||||
|
||||
bank.depositExcept(false, ItemID.HAMMER, ItemID.GOLDEN_NUGGET);
|
||||
bank.close();
|
||||
game.waitUntil(() -> !bank.isOpen(), 3);
|
||||
|
||||
last = Instant.now();
|
||||
}
|
||||
}
|
@ -0,0 +1,52 @@
|
||||
package io.reisub.openosrs.motherlodeminer.tasks;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.MotherlodeMiner;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import net.runelite.client.plugins.iutils.game.iObject;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.scene.RectangularArea;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Mine extends Task {
|
||||
@Inject
|
||||
private MotherlodeMiner plugin;
|
||||
|
||||
private final RectangularArea miningArea = new RectangularArea(
|
||||
new Position(3748, 5676, 0),
|
||||
new Position(3754, 5684, 0)
|
||||
);
|
||||
|
||||
private iObject oreVein;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Mining";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
if (plugin.getCurrentActivity() != Activity.IDLE) return false;
|
||||
|
||||
if (!plugin.isUpstairs()) return false;
|
||||
|
||||
oreVein = game.objects()
|
||||
.withName("Ore vein")
|
||||
.withAction("Mine")
|
||||
.filter((obj) -> miningArea.contains(obj.position()) && !obj.position().equals(new Position(3764, 5665, 0))).nearest();
|
||||
|
||||
return plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& !game.inventory().full()
|
||||
&& oreVein != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
plugin.setCurrentVeinPosition(oreVein.position());
|
||||
|
||||
oreVein.interact("Mine");
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.MINING, 15);
|
||||
|
||||
}
|
||||
}
|
@ -0,0 +1,50 @@
|
||||
package io.reisub.openosrs.motherlodeminer.tasks;
|
||||
|
||||
import io.reisub.openosrs.motherlodeminer.MotherlodeMiner;
|
||||
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;
|
||||
|
||||
public class WithdrawSack extends Task {
|
||||
@Inject
|
||||
private MotherlodeMiner plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Withdrawing from sack";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return !plugin.isUpstairs()
|
||||
&& plugin.getCurrentActivity() == Activity.IDLE
|
||||
&& plugin.isSackFull()
|
||||
&& !game.inventory().withId(
|
||||
ItemID.RUNITE_ORE,
|
||||
ItemID.ADAMANTITE_ORE,
|
||||
ItemID.MITHRIL_ORE,
|
||||
ItemID.GOLD_ORE,
|
||||
ItemID.COAL,
|
||||
ItemID.UNCUT_SAPPHIRE,
|
||||
ItemID.UNCUT_EMERALD,
|
||||
ItemID.UNCUT_RUBY,
|
||||
ItemID.UNCUT_DIAMOND,
|
||||
ItemID.UNCUT_DRAGONSTONE
|
||||
).exists();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iObject sack = game.objects().withName("Sack").withAction("Search").nearest();
|
||||
if (sack == null) return;
|
||||
|
||||
plugin.setActivity(Activity.WITHDRAWING);
|
||||
|
||||
sack.interact("Search");
|
||||
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.IDLE, 30);
|
||||
}
|
||||
}
|
52
mtahelper/mtahelper.gradle.kts
Normal file
52
mtahelper/mtahelper.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos 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"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,76 @@
|
||||
/*
|
||||
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package io.reisub.openosrs.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();
|
||||
}
|
||||
}
|
@ -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) {
|
||||
|
||||
}
|
||||
}
|
@ -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);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
@ -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;
|
||||
}
|
||||
}
|
@ -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("<col=ff9040>Maze Guardian</col>").first();
|
||||
if (mazeGuardian == null) return;
|
||||
|
||||
iWidget spellWidget = game.widget(Spells.TELEKINETIC_GRAB.getInfo());
|
||||
if (spellWidget == null) return;
|
||||
|
||||
spellWidget.useOn(mazeGuardian);
|
||||
}
|
||||
}
|
@ -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();
|
||||
}
|
||||
}
|
File diff suppressed because one or more lines are too long
@ -26,7 +26,7 @@
|
||||
version = "1.1.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Prayer Flicking" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Flicks prayer" // This is the description that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Infinite power!" // This is the description that is used in the external plugin manager panel
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
|
@ -28,19 +28,20 @@ import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.Keybind;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ConfigGroup("ChaosPrayerflickConfig")
|
||||
@ConfigGroup("chaosprayerflicking")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "hotkey",
|
||||
keyName = "prayerFlickHotkey",
|
||||
name = "Flick hotkey",
|
||||
description = "When you press this key prayer flicking will start",
|
||||
position = 0
|
||||
)
|
||||
default Keybind hotkey() {
|
||||
return new Keybind(KeyEvent.VK_BACK_SLASH, 0);
|
||||
default Keybind prayerFlickHotkey() {
|
||||
return new Keybind(KeyEvent.VK_BACK_QUOTE, 0);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -60,7 +61,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
position = 20
|
||||
)
|
||||
default Keybind hotkeyMelee() {
|
||||
return new Keybind(KeyEvent.VK_1, 0);
|
||||
return new Keybind(KeyEvent.VK_1, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -70,7 +71,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
position = 21
|
||||
)
|
||||
default Keybind hotkeyMissiles() {
|
||||
return new Keybind(KeyEvent.VK_2, 0);
|
||||
return new Keybind(KeyEvent.VK_2, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
@ -80,14 +81,116 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
position = 22
|
||||
)
|
||||
default Keybind hotkeyMagic() {
|
||||
return new Keybind(KeyEvent.VK_3, 0);
|
||||
return new Keybind(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyMeleeBuff",
|
||||
name = "Melee buff hotkey",
|
||||
description = "When you press this key melee buff(s) will be set as quickprayer",
|
||||
position = 23
|
||||
)
|
||||
default Keybind hotkeyMeleeBuff() {
|
||||
return new Keybind(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyRangedBuff",
|
||||
name = "Ranged buff hotkey",
|
||||
description = "When you press this key ranged buff will be set as quickprayer",
|
||||
position = 24
|
||||
)
|
||||
default Keybind hotkeyRangedBuff() {
|
||||
return new Keybind(KeyEvent.VK_W, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyMagicBuff",
|
||||
name = "Magic buff hotkey",
|
||||
description = "When you press this key magic buff will be set as quickprayer",
|
||||
position = 25
|
||||
)
|
||||
default Keybind hotkeyMagicBuff() {
|
||||
return new Keybind(KeyEvent.VK_E, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "openInventory",
|
||||
name = "Open inventory",
|
||||
description = "Open inventory after swapping quickprayers",
|
||||
position = 23
|
||||
position = 26
|
||||
)
|
||||
default boolean openInventory() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "allowToggleOff",
|
||||
name = "Allow toggling off",
|
||||
description = "Will allow turning the protect prayer off when pressing the hotkey for the current one.",
|
||||
position = 27
|
||||
)
|
||||
default boolean allowToggleOff() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "jadPrayerFlick",
|
||||
name = "Jad Auto Prayer Flick",
|
||||
description = "Automatically swap prayers against Jad.",
|
||||
position = 40
|
||||
)
|
||||
default boolean jadPrayerFlick() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hesporiPrayerFlick",
|
||||
name = "Hespori Auto Prayer Flick",
|
||||
description = "Automatically swap prayers against Hespori.",
|
||||
position = 41
|
||||
)
|
||||
default boolean hesporiPrayerFlick() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "showDebugOptions",
|
||||
name = "Show debug options",
|
||||
description = "Show debug options. Probably shouldn't touch these.",
|
||||
position = 90
|
||||
)
|
||||
default boolean showDebugOptions() { return false; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "onDelayMin",
|
||||
name = "On delay minimum",
|
||||
description = "Minimum wait time for toggling on quickprayers.",
|
||||
hidden = true,
|
||||
unhide = "showDebugOptions",
|
||||
position = 91
|
||||
)
|
||||
default int onDelayMin() { return 5; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "onDelayMax",
|
||||
name = "On delay maximum",
|
||||
description = "Maximum wait time for toggling on quickprayers.",
|
||||
hidden = true,
|
||||
unhide = "showDebugOptions",
|
||||
position = 92
|
||||
)
|
||||
default int onDelayMax() { return 10; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "offDelayMin",
|
||||
name = "Off delay minimum",
|
||||
description = "Minimum wait time for toggling off quickprayers.",
|
||||
hidden = true,
|
||||
unhide = "showDebugOptions",
|
||||
position = 93
|
||||
)
|
||||
default int offDelayMin() { return 70; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "offDelayMax",
|
||||
name = "Off delay maximum",
|
||||
description = "Maximum wait time for toggling off quickprayers.",
|
||||
hidden = true,
|
||||
unhide = "showDebugOptions",
|
||||
position = 94
|
||||
)
|
||||
default int offDelayMax() { return 80; }
|
||||
}
|
@ -4,11 +4,10 @@ import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Calculations;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.*;
|
||||
import net.runelite.api.events.AnimationChanged;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@ -18,6 +17,7 @@ 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.api.Prayers;
|
||||
import net.runelite.client.plugins.iutils.game.Game;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Prayer Flicking",
|
||||
description = "",
|
||||
description = "Infinite power!",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
@ -62,10 +62,17 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
private final int JALTOK_JAD_MAGE_ATTACK = 7592;
|
||||
private final int JALTOK_JAD_RANGE_ATTACK = 7593;
|
||||
private final int HESPORI_MAGE_ATTACK = 8223;
|
||||
private final int HESPORI_RANGE_ATTACK = 8224;
|
||||
|
||||
private ScheduledExecutorService executor;
|
||||
private boolean toggleFlicking;
|
||||
private boolean firstFlick;
|
||||
private boolean toggledOff;
|
||||
private volatile QuickPrayer currentOverhead;
|
||||
private int level;
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
@ -94,19 +101,51 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
boolean active = quickPrayers.actions().get(0).equals("Deactivate");
|
||||
|
||||
if (!active && !firstFlick) {
|
||||
toggle(calc.random(1, 15), quickPrayers);
|
||||
toggle(calc.random(config.onDelayMin(), config.onDelayMax()), quickPrayers);
|
||||
return;
|
||||
}
|
||||
|
||||
toggle(calc.random(1, 9), quickPrayers);
|
||||
toggle(calc.random(90, 100), quickPrayers);
|
||||
toggle(calc.random(config.onDelayMin(), config.offDelayMax()), quickPrayers);
|
||||
toggle(calc.random(config.offDelayMin(), config.offDelayMax()), quickPrayers);
|
||||
|
||||
if (firstFlick) {
|
||||
firstFlick = false;
|
||||
}
|
||||
} else if (!toggleFlicking && toggledOff && config.deactivateAfterStopping()) {
|
||||
toggledOff = false;
|
||||
toggle(calc.random(90, 110), quickPrayers);
|
||||
toggle(calc.random(config.offDelayMin() + 10, config.offDelayMax() + 10), quickPrayers);
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event) {
|
||||
Actor actor = event.getActor();
|
||||
if (actor == null) return;
|
||||
|
||||
if (config.jadPrayerFlick()) {
|
||||
switch (actor.getAnimation()) {
|
||||
case AnimationID.TZTOK_JAD_MAGIC_ATTACK:
|
||||
case JALTOK_JAD_MAGE_ATTACK:
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MAGIC);
|
||||
game.utils.sendGameMessage("Pray against magic!");
|
||||
break;
|
||||
case AnimationID.TZTOK_JAD_RANGE_ATTACK:
|
||||
case JALTOK_JAD_RANGE_ATTACK:
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MISSILES);
|
||||
game.utils.sendGameMessage("Pray against missiles!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.hesporiPrayerFlick()) {
|
||||
switch (actor.getAnimation()) {
|
||||
case HESPORI_MAGE_ATTACK:
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MAGIC);
|
||||
break;
|
||||
case HESPORI_RANGE_ATTACK:
|
||||
setPrayer(false, QuickPrayer.PROTECT_FROM_MISSILES);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +160,9 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.hotkey().matches(e)) {
|
||||
level = game.baseLevel(Skill.PRAYER);
|
||||
|
||||
if (config.prayerFlickHotkey().matches(e)) {
|
||||
if (toggleFlicking) {
|
||||
toggledOff = true;
|
||||
} else {
|
||||
@ -130,34 +171,52 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
|
||||
toggleFlicking = !toggleFlicking;
|
||||
} else if (config.hotkeyMelee().matches(e)) {
|
||||
setPrayer(14);
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.PROTECT_FROM_MELEE);
|
||||
} else if (config.hotkeyMissiles().matches(e)) {
|
||||
setPrayer(13);
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.PROTECT_FROM_MISSILES);
|
||||
} else if (config.hotkeyMagic().matches(e)) {
|
||||
setPrayer(12);
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.PROTECT_FROM_MAGIC);
|
||||
} else if (config.hotkeyMeleeBuff().matches(e)) {
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.getBestMeleeBuff(level));
|
||||
} else if (config.hotkeyRangedBuff().matches(e)) {
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.getBestRangedBuff(level));
|
||||
} else if (config.hotkeyMagicBuff().matches(e)) {
|
||||
setPrayer(config.allowToggleOff(), QuickPrayer.getBestMagicBuff(level));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {}
|
||||
|
||||
private void setPrayer(int childId) {
|
||||
executor.schedule(() -> {
|
||||
iWidget quickPrayers = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||
if (quickPrayers == null) return;
|
||||
private void setPrayer(boolean allowToggleOff, QuickPrayer... quickPrayers) {
|
||||
if (!allowToggleOff && quickPrayers[0] == currentOverhead) return;
|
||||
|
||||
quickPrayers.interact(1);
|
||||
if (currentOverhead == quickPrayers[0]) {
|
||||
currentOverhead = QuickPrayer.NONE;
|
||||
} else if (quickPrayers[0] == QuickPrayer.PROTECT_FROM_MAGIC
|
||||
|| quickPrayers[0] == QuickPrayer.PROTECT_FROM_MISSILES
|
||||
|| quickPrayers[0] == QuickPrayer.PROTECT_FROM_MELEE) {
|
||||
currentOverhead = quickPrayers[0];
|
||||
}
|
||||
|
||||
executor.schedule(() -> {
|
||||
iWidget quickPrayersWidget = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||
if (quickPrayersWidget == null) return;
|
||||
|
||||
quickPrayersWidget.interact(1);
|
||||
game.waitUntil(() -> {
|
||||
iWidget w = game.widget(77, 4);
|
||||
iWidget w = game.widget(WidgetID.QUICK_PRAYERS_GROUP_ID, 4);
|
||||
return w != null && !w.hidden();
|
||||
});
|
||||
|
||||
iWidget protection = game.widget(77, 4, childId);
|
||||
for (QuickPrayer quickPrayer : quickPrayers) {
|
||||
iWidget protection = game.widget(WidgetID.QUICK_PRAYERS_GROUP_ID, 4, quickPrayer.getChildId());
|
||||
if (protection == null) return;
|
||||
|
||||
protection.interact(0);
|
||||
}
|
||||
|
||||
iWidget update = game.widget(77, 5);
|
||||
iWidget update = game.widget(WidgetID.QUICK_PRAYERS_GROUP_ID, 5);
|
||||
if (update == null) return;
|
||||
|
||||
update.interact(0);
|
||||
|
@ -0,0 +1,132 @@
|
||||
package io.reisub.openosrs.prayerflick;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.widgets.WidgetID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum QuickPrayer {
|
||||
NONE(0, 0),
|
||||
THICK_SKIN(WidgetID.QuickPrayer.THICK_SKIN_CHILD_ID, 1),
|
||||
BURST_OF_STRENGTH(WidgetID.QuickPrayer.BURST_OF_STRENGTH_CHILD_ID, 4),
|
||||
CLARITY_OF_THOUGHT(WidgetID.QuickPrayer.CLARITY_OF_THOUGHT_CHILD_ID, 7),
|
||||
SHARP_EYE(WidgetID.QuickPrayer.SHARP_EYE_CHILD_ID, 8),
|
||||
MYSTIC_WILL(WidgetID.QuickPrayer.MYSTIC_WILL_CHILD_ID, 9),
|
||||
ROCK_SKIN(WidgetID.QuickPrayer.ROCK_SKIN_CHILD_ID, 10),
|
||||
SUPERHUMAN_STRENGTH(WidgetID.QuickPrayer.SUPERHUMAN_STRENGTH_CHILD_ID, 13),
|
||||
IMPROVED_REFLEXES(WidgetID.QuickPrayer.IMPROVED_REFLEXES_CHILD_ID, 16),
|
||||
RAPID_RESTORE(WidgetID.QuickPrayer.RAPID_RESTORE_CHILD_ID, 19),
|
||||
RAPID_HEAL(WidgetID.QuickPrayer.RAPID_HEAL_CHILD_ID, 22),
|
||||
PROTECT_ITEM(WidgetID.QuickPrayer.PROTECT_ITEM_CHILD_ID, 25),
|
||||
HAWK_EYE(WidgetID.QuickPrayer.HAWK_EYE_CHILD_ID, 26),
|
||||
MYSTIC_LORE(WidgetID.QuickPrayer.MYSTIC_LORE_CHILD_ID, 27),
|
||||
STEEL_SKIN(WidgetID.QuickPrayer.STEEL_SKIN_CHILD_ID, 28),
|
||||
ULTIMATE_STRENGTH(WidgetID.QuickPrayer.ULTIMATE_STRENGTH_CHILD_ID, 31),
|
||||
INCREDIBLE_REFLEXES(WidgetID.QuickPrayer.INCREDIBLE_REFLEXES_CHILD_ID, 34),
|
||||
PROTECT_FROM_MAGIC(WidgetID.QuickPrayer.PROTECT_FROM_MAGIC_CHILD_ID, 37),
|
||||
PROTECT_FROM_MISSILES(WidgetID.QuickPrayer.PROTECT_FROM_MISSILES_CHILD_ID, 40),
|
||||
PROTECT_FROM_MELEE(WidgetID.QuickPrayer.PROTECT_FROM_MELEE_CHILD_ID, 43),
|
||||
EAGLE_EYE(WidgetID.QuickPrayer.EAGLE_EYE_CHILD_ID, 44),
|
||||
MYSTIC_MIGHT(WidgetID.QuickPrayer.MYSTIC_MIGHT_CHILD_ID, 45),
|
||||
RETRIBUTION(WidgetID.QuickPrayer.RETRIBUTION_CHILD_ID, 46),
|
||||
REDEMPTION(WidgetID.QuickPrayer.REDEMPTION_CHILD_ID, 49),
|
||||
SMITE(WidgetID.QuickPrayer.SMITE_CHILD_ID, 52),
|
||||
PRESERVE(WidgetID.QuickPrayer.PRESERVE_CHILD_ID, 55),
|
||||
CHIVALRY(WidgetID.QuickPrayer.CHIVALRY_CHILD_ID, 60),
|
||||
PIETY(WidgetID.QuickPrayer.PIETY_CHILD_ID, 70),
|
||||
RIGOUR(WidgetID.QuickPrayer.RIGOUR_CHILD_ID, 74),
|
||||
AUGURY(WidgetID.QuickPrayer.AUGURY_CHILD_ID, 77);
|
||||
|
||||
private final int childId;
|
||||
private final int level;
|
||||
|
||||
public static QuickPrayer[] getBestMeleeBuff(int level) {
|
||||
if (level >= PIETY.level) {
|
||||
return new QuickPrayer[] { PIETY };
|
||||
} else if (level >= CHIVALRY.level) {
|
||||
return new QuickPrayer[] { CHIVALRY };
|
||||
} else {
|
||||
QuickPrayer[] quickPrayers;
|
||||
if (level >= 7) {
|
||||
quickPrayers = new QuickPrayer[3];
|
||||
quickPrayers[0] = getBestDefence(level);
|
||||
quickPrayers[1] = getBestStrength(level);
|
||||
quickPrayers[2] = getBestAttack(level);
|
||||
} else if (level >= 4) {
|
||||
quickPrayers = new QuickPrayer[2];
|
||||
quickPrayers[0] = getBestDefence(level);
|
||||
quickPrayers[1] = getBestStrength(level);
|
||||
} else {
|
||||
quickPrayers = new QuickPrayer[1];
|
||||
quickPrayers[0] = getBestDefence(level);
|
||||
}
|
||||
|
||||
return quickPrayers;
|
||||
}
|
||||
}
|
||||
|
||||
private static QuickPrayer getBestAttack(int level) {
|
||||
if (level >= INCREDIBLE_REFLEXES.level) {
|
||||
return INCREDIBLE_REFLEXES;
|
||||
} else if (level >= IMPROVED_REFLEXES.level) {
|
||||
return IMPROVED_REFLEXES;
|
||||
} else if (level >= CLARITY_OF_THOUGHT.level) {
|
||||
return CLARITY_OF_THOUGHT;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static QuickPrayer getBestStrength(int level) {
|
||||
if (level >= ULTIMATE_STRENGTH.level) {
|
||||
return ULTIMATE_STRENGTH;
|
||||
} else if (level >= SUPERHUMAN_STRENGTH.level) {
|
||||
return SUPERHUMAN_STRENGTH;
|
||||
} else if (level >= BURST_OF_STRENGTH.level) {
|
||||
return BURST_OF_STRENGTH;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private static QuickPrayer getBestDefence(int level) {
|
||||
if (level >= STEEL_SKIN.level) {
|
||||
return STEEL_SKIN;
|
||||
} else if (level >= ROCK_SKIN.level) {
|
||||
return ROCK_SKIN;
|
||||
} else if (level >= THICK_SKIN.level) {
|
||||
return THICK_SKIN;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static QuickPrayer[] getBestRangedBuff(int level) {
|
||||
if (level >= RIGOUR.level) {
|
||||
return new QuickPrayer[] { RIGOUR };
|
||||
} else if (level >= EAGLE_EYE.level) {
|
||||
return new QuickPrayer[] { EAGLE_EYE };
|
||||
} else if (level >= HAWK_EYE.level) {
|
||||
return new QuickPrayer[] { HAWK_EYE };
|
||||
} else if (level >= SHARP_EYE.level) {
|
||||
return new QuickPrayer[] { SHARP_EYE };
|
||||
}
|
||||
|
||||
return new QuickPrayer[]{};
|
||||
}
|
||||
|
||||
public static QuickPrayer[] getBestMagicBuff(int level) {
|
||||
if (level >= AUGURY.level) {
|
||||
return new QuickPrayer[] { AUGURY };
|
||||
} else if (level >= MYSTIC_MIGHT.level) {
|
||||
return new QuickPrayer[] { MYSTIC_MIGHT };
|
||||
} else if (level >= MYSTIC_LORE.level) {
|
||||
return new QuickPrayer[] { MYSTIC_LORE };
|
||||
} else if (level >= MYSTIC_WILL.level) {
|
||||
return new QuickPrayer[] { MYSTIC_WILL };
|
||||
}
|
||||
|
||||
return new QuickPrayer[]{};
|
||||
}
|
||||
}
|
BIN
release/agility-1.0.0.jar
Normal file
BIN
release/agility-1.0.0.jar
Normal file
Binary file not shown.
BIN
release/autoalcher-1.0.0.jar
Normal file
BIN
release/autoalcher-1.0.0.jar
Normal file
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
release/bosshelper-1.0.0.jar
Normal file
BIN
release/bosshelper-1.0.0.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
release/cooker-1.0.0.jar
Normal file
BIN
release/cooker-1.0.0.jar
Normal file
Binary file not shown.
BIN
release/fighter-1.0.0.jar
Normal file
BIN
release/fighter-1.0.0.jar
Normal file
Binary file not shown.
BIN
release/fisher-1.0.0.jar
Normal file
BIN
release/fisher-1.0.0.jar
Normal file
Binary file not shown.
Binary file not shown.
BIN
release/herblore-1.0.0.jar
Normal file
BIN
release/herblore-1.0.0.jar
Normal file
Binary file not shown.
BIN
release/masterthiever-0.0.1.jar
Normal file
BIN
release/masterthiever-0.0.1.jar
Normal file
Binary file not shown.
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user