Updates and rework to use CScript
This commit is contained in:
parent
78786709eb
commit
7efda7494a
@ -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;
|
||||
|
||||
|
@ -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; }
|
||||
}
|
@ -25,8 +25,8 @@
|
||||
|
||||
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
|
||||
project.extra["PluginName"] = "Chaos Base" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "" // This is the description that is used in the external plugin manager panel
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
|
@ -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);
|
||||
@ -87,17 +93,34 @@ public class Birdhouse extends CScript {
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
if (isLoggedIn()
|
||||
&& game.localPlayer().position().regionID() == 14908) {
|
||||
if (!active && game.localPlayer().position().distanceTo(hillHousePosition) < 10 && game.inventory().withNamePart("logs").count() == 4) {
|
||||
execute();
|
||||
} else if (active && game.inventory().all().isEmpty() && !bank.isOpen() && game.localPlayer().position().distanceTo(islandPosition) < 10) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
// if (isLoggedIn()
|
||||
// && game.localPlayer().position().regionID() == 14908) {
|
||||
// if (!active && game.localPlayer().position().distanceTo(hillHousePosition) < 10 && game.inventory().withNamePart("logs").count() == 4) {
|
||||
// execute();
|
||||
// } else if (active && game.inventory().all().isEmpty() && !bank.isOpen() && game.localPlayer().position().distanceTo(islandPosition) < 10) {
|
||||
// execute();
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
public boolean hasRecentlyBeenEmptied(BirdhouseSpace space) {
|
||||
return Duration.between(getBirdhouseTimers().get(space), Instant.now()).getSeconds() < 2000;
|
||||
}
|
||||
|
||||
@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);
|
||||
|
@ -24,9 +24,11 @@
|
||||
*/
|
||||
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;
|
||||
|
||||
@ConfigGroup("ChaosConsumeConfig")
|
||||
@ConfigGroup("chaosconsume")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigSection(
|
||||
@ -384,4 +386,45 @@ 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; }
|
||||
|
||||
|
||||
}
|
@ -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.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;
|
||||
@ -17,11 +16,16 @@ 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.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.ui.Bank;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@ -33,18 +37,21 @@ import java.util.Set;
|
||||
)
|
||||
@Slf4j
|
||||
public class Consume extends Plugin {
|
||||
@Inject
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
private Game game;
|
||||
|
||||
@Inject
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Inject
|
||||
@SuppressWarnings("unused")
|
||||
@Inject
|
||||
private Calculations calc;
|
||||
|
||||
@Inject
|
||||
private Bank bank;
|
||||
|
||||
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 +90,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 +112,10 @@ public class Consume extends Plugin {
|
||||
private long lastRanged;
|
||||
private boolean shouldDrinkMagic;
|
||||
private long lastMagic;
|
||||
private boolean shouldUseSpecial;
|
||||
|
||||
@Provides
|
||||
@SuppressWarnings("unused")
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
@ -114,25 +123,120 @@ public class Consume extends Plugin {
|
||||
@Override
|
||||
protected void startUp() {
|
||||
log.info("Starting Chaos Consume");
|
||||
|
||||
generateNewEatThreshold();
|
||||
generateNewPrayerThreshold();
|
||||
|
||||
executor = Executors.newSingleThreadScheduledExecutor();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void shutDown() {
|
||||
log.info("Stopping Chaos Consume");
|
||||
|
||||
executor.shutdownNow();
|
||||
}
|
||||
|
||||
@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()) > config.specialCost()) {
|
||||
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);
|
||||
|
||||
@ -160,6 +264,19 @@ public class Consume extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
if (shouldUseSpecial && game.client().getVarpValue(VarPlayer.SPECIAL_ATTACK_ENABLED.getId()) == 0) {
|
||||
shouldUseSpecial = false;
|
||||
|
||||
if (game.client().getVar(Varbits.PVP_SPEC_ORB) == 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!");
|
||||
@ -240,84 +357,6 @@ public class Consume extends Plugin {
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
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);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onGameStateChanged(GameStateChanged event) {
|
||||
if (event.getGameState() == GameState.LOGGED_IN) {
|
||||
timeout = 5;
|
||||
}
|
||||
}
|
||||
|
||||
@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;
|
||||
}
|
||||
}
|
||||
|
||||
private void generateNewEatThreshold() {
|
||||
eatThreshold = calc.random(config.minEatHP(), config.maxEatHP() + 1);
|
||||
}
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
|
@ -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",
|
||||
|
@ -3,23 +3,15 @@ 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.CScript;
|
||||
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)
|
||||
@ -29,62 +21,17 @@ import java.util.List;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class FisherPlugin extends iScript {
|
||||
private List<Task> tasks;
|
||||
|
||||
private KittenTask kittenTask;
|
||||
|
||||
public class Fisher extends CScript {
|
||||
@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();
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Fisher");
|
||||
super.onStart();
|
||||
|
||||
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);
|
||||
}
|
||||
addTask(Drop.class);
|
||||
addTask(Fish.class);
|
||||
}
|
||||
}
|
@ -3,11 +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 {
|
||||
public class HandleBank extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Banking";
|
||||
|
@ -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;
|
||||
@ -47,6 +47,8 @@ public class Blow extends Task {
|
||||
game.tick();
|
||||
}
|
||||
|
||||
if (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,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);
|
||||
}
|
||||
}
|
||||
|
@ -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,96 +1,81 @@
|
||||
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) {
|
||||
return configManager.getConfig(Config.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 Master Thiever");
|
||||
super.onStart();
|
||||
|
||||
Eat eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setInterval(14, 24);
|
||||
eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setInterval(config.minEatHP(), config.maxEatHP());
|
||||
|
||||
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;
|
||||
addTask(HandleBank.class);
|
||||
addTask(Steal.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(chatMessage);
|
||||
private void onStatChanged(StatChanged event) {
|
||||
if (event.getSkill() == Skill.THIEVING) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
|
@ -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,7 +81,7 @@ 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(
|
||||
@ -90,4 +91,76 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
position = 23
|
||||
)
|
||||
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 = 24
|
||||
)
|
||||
default boolean allowToggleOff() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "jadPrayerFlick",
|
||||
name = "Jad Auto Prayer Flick",
|
||||
description = "Automatically swap prayers against Jad.",
|
||||
position = 30
|
||||
)
|
||||
default boolean jadPrayerFlick() { return true; }
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hesporiPrayerFlick",
|
||||
name = "Hespori Auto Prayer Flick",
|
||||
description = "Automatically swap prayers against Hespori.",
|
||||
position = 31
|
||||
)
|
||||
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.events.VarbitChanged;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.callback.ClientThread;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
@ -34,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Prayer Flicking",
|
||||
description = "",
|
||||
description = "Infinite power!",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
@ -62,10 +61,16 @@ 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 ProtectFrom currently;
|
||||
|
||||
@Override
|
||||
protected void startUp() {
|
||||
@ -94,19 +99,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(ProtectFrom.MAGIC, false);
|
||||
game.utils.sendGameMessage("Pray against magic!");
|
||||
break;
|
||||
case AnimationID.TZTOK_JAD_RANGE_ATTACK:
|
||||
case JALTOK_JAD_RANGE_ATTACK:
|
||||
setPrayer(ProtectFrom.MISSILES, false);
|
||||
game.utils.sendGameMessage("Pray against missiles!");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (config.hesporiPrayerFlick()) {
|
||||
switch (actor.getAnimation()) {
|
||||
case HESPORI_MAGE_ATTACK:
|
||||
setPrayer(ProtectFrom.MAGIC, false);
|
||||
break;
|
||||
case HESPORI_RANGE_ATTACK:
|
||||
setPrayer(ProtectFrom.MISSILES, false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -121,7 +158,7 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.hotkey().matches(e)) {
|
||||
if (config.prayerFlickHotkey().matches(e)) {
|
||||
if (toggleFlicking) {
|
||||
toggledOff = true;
|
||||
} else {
|
||||
@ -130,18 +167,26 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
|
||||
toggleFlicking = !toggleFlicking;
|
||||
} else if (config.hotkeyMelee().matches(e)) {
|
||||
setPrayer(14);
|
||||
setPrayer(ProtectFrom.MELEE, config.allowToggleOff());
|
||||
} else if (config.hotkeyMissiles().matches(e)) {
|
||||
setPrayer(13);
|
||||
setPrayer(ProtectFrom.MISSILES, config.allowToggleOff());
|
||||
} else if (config.hotkeyMagic().matches(e)) {
|
||||
setPrayer(12);
|
||||
setPrayer(ProtectFrom.MAGIC, config.allowToggleOff());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {}
|
||||
|
||||
private void setPrayer(int childId) {
|
||||
private void setPrayer(ProtectFrom protectFrom, boolean allowToggleOff) {
|
||||
if (!allowToggleOff && protectFrom == currently) return;
|
||||
|
||||
if (currently == protectFrom) {
|
||||
currently = ProtectFrom.NONE;
|
||||
} else {
|
||||
currently = protectFrom;
|
||||
}
|
||||
|
||||
executor.schedule(() -> {
|
||||
iWidget quickPrayers = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||
if (quickPrayers == null) return;
|
||||
@ -152,7 +197,7 @@ public class Prayerflick extends Plugin implements KeyListener {
|
||||
return w != null && !w.hidden();
|
||||
});
|
||||
|
||||
iWidget protection = game.widget(77, 4, childId);
|
||||
iWidget protection = game.widget(77, 4, protectFrom.getChildId());
|
||||
if (protection == null) return;
|
||||
|
||||
protection.interact(0);
|
||||
|
@ -0,0 +1,15 @@
|
||||
package io.reisub.openosrs.prayerflick;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ProtectFrom {
|
||||
NONE(0),
|
||||
MAGIC(12),
|
||||
MISSILES(13),
|
||||
MELEE(14);
|
||||
|
||||
private final int childId;
|
||||
}
|
@ -30,20 +30,27 @@ include(":autobones")
|
||||
include(":autodropper")
|
||||
include(":birdhouse")
|
||||
include(":blackjack")
|
||||
include(":bosshelper")
|
||||
include(":consume")
|
||||
include(":cooker")
|
||||
include(":fighter")
|
||||
include(":fisher")
|
||||
include(":glassblower")
|
||||
include(":herblore")
|
||||
include(":masterthiever")
|
||||
include(":miner")
|
||||
include(":mtahelper")
|
||||
include(":prayerflick")
|
||||
include(":shopper")
|
||||
include(":smelter")
|
||||
include(":smither")
|
||||
include(":superglassmake")
|
||||
include(":tempoross")
|
||||
include(":test")
|
||||
include(":util")
|
||||
include(":volcanicashminer")
|
||||
include(":wintertodt")
|
||||
include(":woodcutter")
|
||||
//include(":woodcutter")
|
||||
|
||||
for (project in rootProject.children) {
|
||||
project.apply {
|
||||
|
@ -29,7 +29,7 @@ import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.ConfigSection;
|
||||
|
||||
@ConfigGroup("ChaosShopperConfig")
|
||||
@ConfigGroup("chaosshopper")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
@ -54,6 +54,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemOneEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
section = "itemOne",
|
||||
position = 11
|
||||
)
|
||||
default boolean itemOneEnabled() {
|
||||
@ -61,19 +62,21 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemOneName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
keyName = "itemOneId",
|
||||
name = "ID",
|
||||
description = "ID of the item",
|
||||
section = "itemOne",
|
||||
position = 12
|
||||
)
|
||||
default String itemOneName() {
|
||||
return "";
|
||||
default int itemOneId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemOneAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
section = "itemOne",
|
||||
position = 13
|
||||
)
|
||||
default int itemOneAmount() {
|
||||
@ -84,6 +87,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemOneMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
section = "itemOne",
|
||||
position = 14
|
||||
)
|
||||
default int itemOneMinInStore() {
|
||||
@ -103,6 +107,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemTwoEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
section = "itemTwo",
|
||||
position = 21
|
||||
)
|
||||
default boolean itemTwoEnabled() {
|
||||
@ -110,19 +115,21 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemTwoName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
keyName = "itemTwoId",
|
||||
name = "ID",
|
||||
description = "ID of the item",
|
||||
section = "itemTwo",
|
||||
position = 22
|
||||
)
|
||||
default String itemTwoName() {
|
||||
return "";
|
||||
default int itemTwoId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemTwoAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
section = "itemTwo",
|
||||
position = 23
|
||||
)
|
||||
default int itemTwoAmount() {
|
||||
@ -133,6 +140,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemTwoMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
section = "itemTwo",
|
||||
position = 24
|
||||
)
|
||||
default int itemTwoMinInStore() {
|
||||
@ -152,6 +160,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemThreeEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
section = "itemThree",
|
||||
position = 31
|
||||
)
|
||||
default boolean itemThreeEnabled() {
|
||||
@ -159,19 +168,21 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemThreeName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
keyName = "itemThreeId",
|
||||
name = "ID",
|
||||
description = "ID of the item",
|
||||
section = "itemThree",
|
||||
position = 32
|
||||
)
|
||||
default String itemThreeName() {
|
||||
return "";
|
||||
default int itemThreeId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemThreeAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
section = "itemThree",
|
||||
position = 33
|
||||
)
|
||||
default int itemThreeAmount() {
|
||||
@ -182,6 +193,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemThreeMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
section = "itemThree",
|
||||
position = 34
|
||||
)
|
||||
default int itemThreeMinInStore() {
|
||||
@ -201,6 +213,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemFourEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
section = "itemFour",
|
||||
position = 41
|
||||
)
|
||||
default boolean itemFourEnabled() {
|
||||
@ -208,19 +221,21 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFourName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
keyName = "itemFourId",
|
||||
name = "ID",
|
||||
description = "ID of the item",
|
||||
section = "itemFour",
|
||||
position = 42
|
||||
)
|
||||
default String itemFourName() {
|
||||
return "";
|
||||
default int itemFourId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFourAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
section = "itemFour",
|
||||
position = 43
|
||||
)
|
||||
default int itemFourAmount() {
|
||||
@ -231,6 +246,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemFourMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
section = "itemFour",
|
||||
position = 44
|
||||
)
|
||||
default int itemFourMinInStore() {
|
||||
@ -250,6 +266,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemFiveEnabled",
|
||||
name = "Enable",
|
||||
description = "Enable the buying of this item",
|
||||
section = "itemFive",
|
||||
position = 51
|
||||
)
|
||||
default boolean itemFiveEnabled() {
|
||||
@ -257,19 +274,21 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFiveName",
|
||||
name = "Name",
|
||||
description = "Name of the item",
|
||||
keyName = "itemFiveId",
|
||||
name = "ID",
|
||||
description = "ID of the item",
|
||||
section = "itemFive",
|
||||
position = 52
|
||||
)
|
||||
default String itemFiveName() {
|
||||
return "";
|
||||
default int itemFiveId() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "itemFiveAmount",
|
||||
name = "Amount",
|
||||
description = "Amount of the item to buy",
|
||||
section = "itemFive",
|
||||
position = 53
|
||||
)
|
||||
default int itemFiveAmount() {
|
||||
@ -280,6 +299,7 @@ public interface Config extends net.runelite.client.config.Config {
|
||||
keyName = "itemFiveMinInStore",
|
||||
name = "Min in store",
|
||||
description = "Amount to keep in store to prevent overpaying",
|
||||
section = "itemFive",
|
||||
position = 54
|
||||
)
|
||||
default int itemFiveMinInStore() {
|
||||
|
@ -2,15 +2,15 @@ package io.reisub.openosrs.shopper;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public class Item {
|
||||
@Getter
|
||||
private final String name;
|
||||
|
||||
@Getter
|
||||
private final int amount;
|
||||
|
||||
@Getter
|
||||
private final int id;
|
||||
private final int amountToBuy;
|
||||
private final int minInShop;
|
||||
|
||||
@Setter
|
||||
private int amountBought;
|
||||
}
|
||||
|
@ -1,21 +1,22 @@
|
||||
package io.reisub.openosrs.shopper;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.shopper.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.events.ConfigButtonClicked;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.events.GameTick;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@ -28,12 +29,10 @@ import java.util.List;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Shopper extends iScript {
|
||||
public class Shopper extends CScript {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
private List<Task> tasks;
|
||||
|
||||
@Getter
|
||||
private List<Item> items;
|
||||
|
||||
@ -41,69 +40,61 @@ public class Shopper extends iScript {
|
||||
@Setter
|
||||
private boolean hop;
|
||||
|
||||
private Hop hopTask;
|
||||
|
||||
@Provides
|
||||
@SuppressWarnings("unused")
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.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 Shopper");
|
||||
super.onStart();
|
||||
|
||||
loadItems();
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
}
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Shopper");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
hopTask = injector.getInstance(Hop.class);
|
||||
|
||||
tasks.add(hopTask);
|
||||
tasks.add(runTask);
|
||||
addTask(Buy.class);
|
||||
addTask(HandleBank.class);
|
||||
addTask(CloseShop.class);
|
||||
addTask(OpenShop.class);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
private void onGameTick(GameTick event) {
|
||||
if (!isLoggedIn()) return;
|
||||
|
||||
if (hopTask != null) hopTask.onGameTick();
|
||||
}
|
||||
|
||||
private void loadItems() {
|
||||
items = new ArrayList<>();
|
||||
|
||||
if (config.itemOneEnabled()) {
|
||||
items.add(new Item(config.itemOneName(), config.itemOneAmount(), config.itemOneMinInStore()));
|
||||
items.add(new Item(config.itemOneId(), config.itemOneAmount(), config.itemOneMinInStore(), 0));
|
||||
}
|
||||
|
||||
if (config.itemTwoEnabled()) {
|
||||
items.add(new Item(config.itemTwoName(), config.itemTwoAmount(), config.itemTwoMinInStore()));
|
||||
items.add(new Item(config.itemTwoId(), config.itemTwoAmount(), config.itemTwoMinInStore(), 0));
|
||||
}
|
||||
|
||||
if (config.itemThreeEnabled()) {
|
||||
items.add(new Item(config.itemThreeName(), config.itemThreeAmount(), config.itemThreeMinInStore()));
|
||||
items.add(new Item(config.itemThreeId(), config.itemThreeAmount(), config.itemThreeMinInStore(), 0));
|
||||
}
|
||||
|
||||
if (config.itemFourEnabled()) {
|
||||
items.add(new Item(config.itemFourName(), config.itemFourAmount(), config.itemFourMinInStore()));
|
||||
items.add(new Item(config.itemFourId(), config.itemFourAmount(), config.itemFourMinInStore(), 0));
|
||||
}
|
||||
|
||||
if (config.itemFiveEnabled()) {
|
||||
items.add(new Item(config.itemFiveName(), config.itemFiveAmount(), config.itemFiveMinInStore()));
|
||||
items.add(new Item(config.itemFiveId(), config.itemFiveAmount(), config.itemFiveMinInStore(), 0));
|
||||
}
|
||||
}
|
||||
}
|
@ -1,11 +1,13 @@
|
||||
package io.reisub.openosrs.shopper.tasks;
|
||||
|
||||
import io.reisub.openosrs.shopper.Item;
|
||||
import io.reisub.openosrs.shopper.Shopper;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.mixins.Inject;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Buy extends Task {
|
||||
@Inject
|
||||
private Shopper plugin;
|
||||
@ -15,17 +17,57 @@ public class Buy extends Task {
|
||||
return "Buying";
|
||||
}
|
||||
|
||||
private int currentItemId;
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
iWidget shop = game.widget(WidgetInfo.SHOP_ITEMS_CONTAINER);
|
||||
iWidget shop = game.widget(300, 1);
|
||||
if (shop == null || shop.hidden()) return false;
|
||||
|
||||
return shop != null
|
||||
&& !shop.hidden()
|
||||
currentItemId = -1;
|
||||
|
||||
for (Item item : plugin.getItems()) {
|
||||
if (item.getAmountBought() > item.getAmountToBuy()) continue;
|
||||
|
||||
int shopCount = getShopCount(item.getId());
|
||||
|
||||
if (shopCount > item.getMinInShop()) {
|
||||
currentItemId = item.getId();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return currentItemId != -1
|
||||
&& !game.inventory().full();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
Widget widget = game.client().getWidget(300, 16);
|
||||
|
||||
for (Widget child : widget.getChildren()) {
|
||||
if (child.getItemId() == currentItemId) {
|
||||
iWidget itemWidget = game.widget(300, 16, child.getIndex());
|
||||
if (itemWidget == null) return;
|
||||
|
||||
itemWidget.interact("Buy 50");
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
game.tick();
|
||||
}
|
||||
|
||||
private int getShopCount(int id) {
|
||||
Widget widget = game.client().getWidget(300, 16);
|
||||
|
||||
for (Widget child : widget.getChildren()) {
|
||||
if (child.getItemId() == id) {
|
||||
return child.getItemQuantity();
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,37 @@
|
||||
package io.reisub.openosrs.shopper.tasks;
|
||||
|
||||
import io.reisub.openosrs.shopper.Shopper;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class CloseShop extends Task {
|
||||
@Inject
|
||||
private Shopper plugin;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Closing shop";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
iWidget shop = game.widget(300, 1);
|
||||
|
||||
return shop != null && !shop.hidden();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iWidget close = game.widget(300,1, 11);
|
||||
if (close == null) return;
|
||||
close.interact("Close");
|
||||
game.tick();
|
||||
|
||||
if (!game.inventory().full()) {
|
||||
plugin.setHop(true);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,59 @@
|
||||
package io.reisub.openosrs.shopper.tasks;
|
||||
|
||||
import io.reisub.openosrs.shopper.Item;
|
||||
import io.reisub.openosrs.shopper.Shopper;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
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 Shopper plugin;
|
||||
|
||||
private Instant lastBanking = Instant.EPOCH;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Banking";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.inventory().full()
|
||||
&& Duration.between(lastBanking, Instant.now()).getSeconds() > 3;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (!bank.isOpen()) {
|
||||
iObject bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck", "Bank chest").nearest();
|
||||
if (bankObj == null) return;
|
||||
|
||||
if (bankObj.actions().contains("Bank")) {
|
||||
bankObj.interact("Bank");
|
||||
} else if (bankObj.actions().contains("Use")) {
|
||||
bankObj.interact("Use");
|
||||
} else {
|
||||
bankObj.interact(0);
|
||||
}
|
||||
|
||||
game.waitUntil(() -> bank.isOpen(), 15);
|
||||
}
|
||||
|
||||
for (Item item : plugin.getItems()) {
|
||||
int quantity = bank.quantity(item.getId()) + (int) game.inventory().withId(item.getId()).count();
|
||||
item.setAmountBought(quantity);
|
||||
|
||||
bank.depositExcept(false, ItemID.COINS, ItemID.COINS_995, ItemID.COINS_6964, ItemID.COINS_8890);
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
bank.close();
|
||||
game.sleepDelay();
|
||||
lastBanking = Instant.now();
|
||||
}
|
||||
}
|
132
shopper/src/main/java/io/reisub/openosrs/shopper/tasks/Hop.java
Normal file
132
shopper/src/main/java/io/reisub/openosrs/shopper/tasks/Hop.java
Normal file
@ -0,0 +1,132 @@
|
||||
package io.reisub.openosrs.shopper.tasks;
|
||||
|
||||
import io.reisub.openosrs.shopper.Config;
|
||||
import io.reisub.openosrs.shopper.Shopper;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.client.game.WorldService;
|
||||
import net.runelite.client.util.WorldUtil;
|
||||
import net.runelite.http.api.worlds.World;
|
||||
import net.runelite.http.api.worlds.WorldType;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
public class Hop extends Task {
|
||||
@Inject
|
||||
private Shopper plugin;
|
||||
|
||||
@Inject
|
||||
public WorldService worldService;
|
||||
|
||||
private Queue<World> worldQueue;
|
||||
private net.runelite.api.World quickHopTargetWorld;
|
||||
private int displaySwitcherAttempts = 0;
|
||||
private Instant lastAttempt = Instant.EPOCH;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Hopping to next world";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return plugin.isHop() && Duration.between(lastAttempt, Instant.now()).getSeconds() > 5;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
if (worldQueue == null) initializeWorldQueue();
|
||||
|
||||
World world = worldQueue.poll();
|
||||
if (world == null) return;
|
||||
|
||||
worldQueue.add(world);
|
||||
|
||||
final net.runelite.api.World rsWorld = game.client().createWorld();
|
||||
rsWorld.setActivity(world.getActivity());
|
||||
rsWorld.setAddress(world.getAddress());
|
||||
rsWorld.setId(world.getId());
|
||||
rsWorld.setPlayerCount(world.getPlayers());
|
||||
rsWorld.setLocation(world.getLocation());
|
||||
rsWorld.setTypes(WorldUtil.toWorldTypes(world.getTypes()));
|
||||
|
||||
if (game.client().getGameState() == GameState.LOGIN_SCREEN) {
|
||||
game.client().changeWorld(rsWorld);
|
||||
return;
|
||||
}
|
||||
|
||||
quickHopTargetWorld = rsWorld;
|
||||
displaySwitcherAttempts = 0;
|
||||
lastAttempt = Instant.now();
|
||||
plugin.setHop(false);
|
||||
game.tick(3);
|
||||
}
|
||||
|
||||
public void onGameTick() {
|
||||
if (quickHopTargetWorld == null) return;
|
||||
|
||||
if (game.client().getWidget(WidgetInfo.WORLD_SWITCHER_LIST) == null) {
|
||||
game.client().openWorldHopper();
|
||||
if (++displaySwitcherAttempts >= 5) {
|
||||
logWarn("Failed to hop after 5 attempts");
|
||||
displaySwitcherAttempts = 0;
|
||||
quickHopTargetWorld = null;
|
||||
}
|
||||
} else {
|
||||
game.client().hopToWorld(quickHopTargetWorld);
|
||||
plugin.setLastHop(Instant.now());
|
||||
quickHopTargetWorld = null;
|
||||
}
|
||||
}
|
||||
|
||||
private void initializeWorldQueue() {
|
||||
if (worldService.getWorlds() == null) return;
|
||||
|
||||
int current = game.client().getWorld();
|
||||
if (current == 0 || current == -1) return;
|
||||
|
||||
worldQueue = new LinkedList<>();
|
||||
|
||||
for (World world : worldService.getWorlds().getWorlds()) {
|
||||
if (!world.getTypes().contains(WorldType.MEMBERS)) continue;
|
||||
|
||||
if (world.getTypes().contains(WorldType.BOUNTY)
|
||||
|| world.getTypes().contains(WorldType.DEADMAN)
|
||||
|| world.getTypes().contains(WorldType.HIGH_RISK)
|
||||
|| world.getTypes().contains(WorldType.LAST_MAN_STANDING)
|
||||
|| world.getTypes().contains(WorldType.NOSAVE_MODE)
|
||||
|| world.getTypes().contains(WorldType.PVP)
|
||||
|| world.getTypes().contains(WorldType.SEASONAL)
|
||||
|| world.getTypes().contains(WorldType.TOURNAMENT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (world.getTypes().contains(WorldType.SKILL_TOTAL)) {
|
||||
try {
|
||||
int totalRequirement = Integer.parseInt(world.getActivity().substring(0, world.getActivity().indexOf(" ")));
|
||||
|
||||
if (game.client().getTotalLevel() < totalRequirement) {
|
||||
continue;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
logWarn("Failed to parse total level requirement for world " + world.getId());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
worldQueue.add(world);
|
||||
}
|
||||
|
||||
while (true) {
|
||||
World world = worldQueue.poll();
|
||||
worldQueue.add(world);
|
||||
|
||||
if (world == null || world.getId() == current) break;
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,43 @@
|
||||
package io.reisub.openosrs.shopper.tasks;
|
||||
|
||||
import io.reisub.openosrs.shopper.Config;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class OpenShop extends Task {
|
||||
@Inject
|
||||
private Config config;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Opening shop";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
iWidget shop = game.widget(300, 1);
|
||||
|
||||
return !bank.isOpen()
|
||||
&& !game.inventory().full()
|
||||
&& (shop == null || shop.hidden());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iNPC npc = game.npcs().withName(config.npcName()).nearest();
|
||||
if (npc == null) {
|
||||
walking.walkTo(new Position(2669, 3150, 0).areaWithin(2));
|
||||
}
|
||||
|
||||
npc = game.npcs().withName(config.npcName()).nearest();
|
||||
if (npc == null) return;
|
||||
|
||||
npc.interact("Trade");
|
||||
game.waitUntil(() -> game.widget(300, 1) != null
|
||||
&& !game.widget(300, 1).hidden(), 20);
|
||||
}
|
||||
}
|
@ -28,7 +28,7 @@ import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosSmelterConfig")
|
||||
@ConfigGroup("chaossmelter")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
|
@ -1,11 +1,9 @@
|
||||
package io.reisub.openosrs.smelter;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.Value;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@Value
|
||||
public class Ingredient {
|
||||
private final int id;
|
||||
private final int amount;
|
||||
int id;
|
||||
int amount;
|
||||
}
|
||||
|
@ -5,14 +5,17 @@ import net.runelite.api.ItemID;
|
||||
|
||||
@Getter
|
||||
public enum Product {
|
||||
MOLTEN_GLASS(ItemID.MOLTEN_GLASS, new Ingredient(ItemID.SODA_ASH, 14), new Ingredient(ItemID.BUCKET_OF_SAND, 14)),
|
||||
CANNONBALLS(ItemID.CANNONBALL, new Ingredient(ItemID.STEEL_BAR, 27));
|
||||
STEEL_BAR(ItemID.STEEL_BAR, 4, new Ingredient(ItemID.IRON_ORE, 9), new Ingredient(ItemID.COAL, 28)),
|
||||
MOLTEN_GLASS(ItemID.MOLTEN_GLASS, 0, new Ingredient(ItemID.SODA_ASH, 14), new Ingredient(ItemID.BUCKET_OF_SAND, 14)),
|
||||
CANNONBALLS(ItemID.CANNONBALL, 0, new Ingredient(ItemID.STEEL_BAR, 27));
|
||||
|
||||
private final int id;
|
||||
private final int index;
|
||||
private final Ingredient[] ingredients;
|
||||
|
||||
Product(int id, Ingredient... ingredients) {
|
||||
Product(int id, int index, Ingredient... ingredients) {
|
||||
this.id = id;
|
||||
this.index = index;
|
||||
this.ingredients = ingredients;
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +1,23 @@
|
||||
package io.reisub.openosrs.smelter;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import io.reisub.openosrs.smelter.tasks.HandleBank;
|
||||
import io.reisub.openosrs.smelter.tasks.Smelt;
|
||||
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.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.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.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)
|
||||
@PluginDependency(iUtils.class)
|
||||
@ -41,64 +27,22 @@ import static net.runelite.api.AnimationID.IDLE;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Smelter extends iScript {
|
||||
private List<Task> tasks;
|
||||
private KittenTask kittenTask;
|
||||
|
||||
@Getter
|
||||
private Activity currentActivity;
|
||||
|
||||
private Instant lastActionTime;
|
||||
|
||||
public class Smelter extends CScript {
|
||||
@Provides
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
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 Smelter");
|
||||
|
||||
Eat eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setInterval(14, 24);
|
||||
super.onStart();
|
||||
|
||||
Run runTask = injector.getInstance(Run.class);
|
||||
runTask.setInterval(70, 95);
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
|
||||
currentActivity = Activity.IDLE;
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(eatTask);
|
||||
tasks.add(runTask);
|
||||
tasks.add(kittenTask);
|
||||
tasks.add(injector.getInstance(HandleBank.class));
|
||||
tasks.add(injector.getInstance(Smelt.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Smelter");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
addTask(HandleBank.class);
|
||||
addTask(Smelt.class);
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -116,46 +60,4 @@ public class Smelter extends iScript {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(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(5);
|
||||
Duration sinceAction = Duration.between(lastActionTime, Instant.now());
|
||||
|
||||
if (sinceAction.compareTo(timeout) >= 0) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
}
|
@ -1,10 +1,10 @@
|
||||
package io.reisub.openosrs.smelter.tasks;
|
||||
|
||||
import io.reisub.openosrs.smelter.Activity;
|
||||
import io.reisub.openosrs.smelter.Config;
|
||||
import io.reisub.openosrs.smelter.Ingredient;
|
||||
import io.reisub.openosrs.smelter.Smelter;
|
||||
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.ui.Chatbox;
|
||||
|
||||
@ -52,7 +52,7 @@ public class Smelt extends Task {
|
||||
}
|
||||
}
|
||||
|
||||
chatbox.make(0, quantity);
|
||||
chatbox.make(config.targetProduct().getIndex(), quantity);
|
||||
game.waitUntil(() -> plugin.getCurrentActivity() == Activity.SMELTING, 5);
|
||||
}
|
||||
}
|
||||
|
@ -28,7 +28,7 @@ import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosTemporossConfig")
|
||||
@ConfigGroup("chaostempoross")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
|
@ -2,7 +2,6 @@ package io.reisub.openosrs.tempoross;
|
||||
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import io.reisub.openosrs.tempoross.tasks.*;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
|
@ -4,7 +4,6 @@ import io.reisub.openosrs.tempoross.Activity;
|
||||
import io.reisub.openosrs.tempoross.Tempoross;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.ItemID;
|
||||
import net.runelite.api.ObjectID;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
|
@ -24,14 +24,34 @@
|
||||
*/
|
||||
package io.reisub.openosrs.test;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.*;
|
||||
|
||||
import java.awt.event.InputEvent;
|
||||
import java.awt.event.KeyEvent;
|
||||
|
||||
@ConfigGroup("ChaosTestConfig")
|
||||
|
||||
public interface TestConfig extends Config {
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyOne",
|
||||
name = "Hotkey one",
|
||||
description = "",
|
||||
position = 0
|
||||
)
|
||||
default Keybind hotkeyOne() {
|
||||
return new Keybind(KeyEvent.VK_Q, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "hotkeyTwo",
|
||||
name = "Hotkey two",
|
||||
description = "",
|
||||
position = 1
|
||||
)
|
||||
default Keybind hotkeyTwo() {
|
||||
return new Keybind(KeyEvent.VK_A, InputEvent.CTRL_DOWN_MASK);
|
||||
}
|
||||
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
|
@ -5,19 +5,32 @@ import io.reisub.openosrs.test.tasks.Test;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Actor;
|
||||
import net.runelite.api.MenuAction;
|
||||
import net.runelite.api.MenuEntry;
|
||||
import net.runelite.api.Prayer;
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.api.widgets.Widget;
|
||||
import net.runelite.api.widgets.WidgetInfo;
|
||||
import net.runelite.api.widgets.WidgetItem;
|
||||
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.game.iWidget;
|
||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||
import org.apache.commons.lang3.tuple.Pair;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.awt.event.KeyEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@ -28,7 +41,13 @@ import java.util.List;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class TestPlugin extends iScript {
|
||||
public class TestPlugin extends iScript implements KeyListener {
|
||||
@Inject
|
||||
private TestConfig config;
|
||||
|
||||
@Inject
|
||||
private KeyManager keyManager;
|
||||
|
||||
private List<Task> tasks;
|
||||
|
||||
@Provides
|
||||
@ -53,8 +72,7 @@ public class TestPlugin extends iScript {
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Test");
|
||||
|
||||
log.info("selected itemt slot: " + game.client.getSelectedItemSlot());
|
||||
log.info("is item selected: " + game.client().isItemSelected());
|
||||
keyManager.registerKeyListener(this);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(injector.getInstance(Test.class));
|
||||
@ -66,6 +84,13 @@ public class TestPlugin extends iScript {
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
keyManager.unregisterKeyListener(this);
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onGameTick(GameTick event) {
|
||||
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@ -85,6 +110,17 @@ public class TestPlugin extends iScript {
|
||||
|
||||
@Subscribe
|
||||
private void onAnimationChanged(AnimationChanged event) {
|
||||
Actor actor = event.getActor();
|
||||
if (actor == null || actor.getName() == null) return;
|
||||
|
||||
if (actor.getName().equals(game.localPlayer().name())) {
|
||||
log.info("player anim: " + actor.getAnimation());
|
||||
}
|
||||
|
||||
if (actor.getName().toLowerCase(Locale.ROOT).contains("hespori")) {
|
||||
log.info("hespori anim: " + actor.getAnimation());
|
||||
}
|
||||
|
||||
// if (event.getActor() != null) {
|
||||
// log.info("actor: " + event.getActor().getName());
|
||||
// log.info("id: " + event.getActor().getAnimation());
|
||||
@ -103,5 +139,24 @@ public class TestPlugin extends iScript {
|
||||
private void onHitsplatApplied(HitsplatApplied event) {
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyTyped(KeyEvent e) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent e) {
|
||||
if (config.hotkeyOne().matches(e)) {
|
||||
log.info("hotkey 1 pressed: magic");
|
||||
} else if (config.hotkeyTwo().matches(e)) {
|
||||
log.info("hotkey 2 pressed: ranged");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent e) {
|
||||
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package io.reisub.openosrs.test.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||
|
||||
public class Test extends Task {
|
||||
|
@ -3,15 +3,15 @@ package io.reisub.openosrs.util;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.ChatMessageType;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.InventoryID;
|
||||
import net.runelite.api.Skill;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ConfigButtonClicked;
|
||||
import net.runelite.api.events.GameStateChanged;
|
||||
import net.runelite.api.events.StatChanged;
|
||||
import net.runelite.api.events.*;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.iutils.game.iPlayer;
|
||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -30,12 +30,22 @@ public abstract class CScript extends iScript {
|
||||
protected KittenTask kittenTask;
|
||||
|
||||
@Getter
|
||||
protected Activity currentActivity = Activity.IDLE;
|
||||
protected Activity currentActivity;
|
||||
|
||||
@Getter
|
||||
protected Activity previousActivity;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
private Instant lastHop;
|
||||
|
||||
protected Instant lastLogin = Instant.EPOCH;
|
||||
protected Instant lastActionTime = Instant.EPOCH;
|
||||
protected Duration lastActionTimeout = Duration.ofSeconds(3);
|
||||
protected Instant lastExperience = Instant.EPOCH;
|
||||
protected Instant lastInventoryChange = Instant.EPOCH;
|
||||
protected final Map<Skill, Activity> idleCheckSkills = new HashMap<>();
|
||||
protected boolean idleCheckInventoryChange = false;
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
@ -54,6 +64,10 @@ public abstract class CScript extends iScript {
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting " + this.getName());
|
||||
|
||||
previousActivity = Activity.IDLE;
|
||||
currentActivity = Activity.IDLE;
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
}
|
||||
|
||||
@ -62,6 +76,9 @@ public abstract class CScript extends iScript {
|
||||
log.info("Stopping " + this.getName());
|
||||
tasks.clear();
|
||||
|
||||
previousActivity = Activity.IDLE;
|
||||
currentActivity = Activity.IDLE;
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
}
|
||||
|
||||
@ -103,6 +120,15 @@ public abstract class CScript extends iScript {
|
||||
}
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||
if (!isLoggedIn() || event.getItemContainer() != game.client().getItemContainer(InventoryID.INVENTORY)) return;
|
||||
|
||||
if (idleCheckInventoryChange) {
|
||||
lastInventoryChange = Instant.now();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@SuppressWarnings("unused")
|
||||
@ -112,7 +138,11 @@ public abstract class CScript extends iScript {
|
||||
}
|
||||
}
|
||||
|
||||
protected void setActivity(Activity action) {
|
||||
public void setActivity(Activity action) {
|
||||
if (action == Activity.IDLE && currentActivity != Activity.IDLE) {
|
||||
previousActivity = currentActivity;
|
||||
}
|
||||
|
||||
currentActivity = action;
|
||||
|
||||
if (action != Activity.IDLE) {
|
||||
@ -123,15 +153,16 @@ public abstract class CScript extends iScript {
|
||||
protected void checkActionTimeout() {
|
||||
if (currentActivity == Activity.IDLE) return;
|
||||
|
||||
if (Duration.between(lastExperience, Instant.now()).getSeconds() < 5) return;
|
||||
if (Duration.between(lastExperience, Instant.now()).compareTo(lastActionTimeout) < 0) return;
|
||||
|
||||
if (Duration.between(lastInventoryChange, Instant.now()).compareTo(lastActionTimeout) < 0) return;
|
||||
|
||||
int animId = game.localPlayer().animation();
|
||||
if (animId != IDLE || lastActionTime == null) return;
|
||||
|
||||
Duration timeout = Duration.ofSeconds(5);
|
||||
Duration sinceAction = Duration.between(lastActionTime, Instant.now());
|
||||
|
||||
if (sinceAction.compareTo(timeout) >= 0) {
|
||||
if (sinceAction.compareTo(lastActionTimeout) >= 0) {
|
||||
setActivity(Activity.IDLE);
|
||||
}
|
||||
}
|
||||
@ -140,7 +171,18 @@ public abstract class CScript extends iScript {
|
||||
return game.client() != null && game.client().getGameState() == GameState.LOGGED_IN;
|
||||
}
|
||||
|
||||
public final boolean isLoggedInForLongerThan(int seconds) {
|
||||
return Duration.between(lastLogin, Instant.now()).getSeconds() >= seconds;
|
||||
public final boolean isLoggedInForLongerThan(Duration duration) {
|
||||
return Duration.between(lastLogin, Instant.now()).compareTo(duration) >= 0;
|
||||
}
|
||||
|
||||
public final boolean isInRegion(int regionId) {
|
||||
iPlayer player = game.localPlayer();
|
||||
return player != null
|
||||
&& player.position().regionID() == regionId;
|
||||
}
|
||||
|
||||
public final void stop(String message) {
|
||||
game.utils.sendGameMessage(message);
|
||||
this.execute();
|
||||
}
|
||||
}
|
||||
|
@ -1,8 +1,8 @@
|
||||
package io.reisub.openosrs.util;
|
||||
|
||||
import net.runelite.client.config.*;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
|
||||
@ConfigGroup("ChaosUtilConfig")
|
||||
@ConfigGroup("chaosutil")
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
|
||||
}
|
||||
|
@ -11,7 +11,6 @@ import net.runelite.client.plugins.iutils.ui.Equipment;
|
||||
import net.runelite.client.plugins.iutils.walking.Walking;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public abstract class Task {
|
||||
|
@ -2,5 +2,18 @@ package io.reisub.openosrs.util.enums;
|
||||
|
||||
public enum Activity {
|
||||
IDLE,
|
||||
GLASSBLOWING;
|
||||
COOKING,
|
||||
GLASSBLOWING,
|
||||
SMELTING,
|
||||
WOODCUTTING(),
|
||||
FLETCHING(),
|
||||
FEEDING_BRAZIER(),
|
||||
FIXING_BRAZIER(),
|
||||
LIGHTING_BRAZIER(),
|
||||
THIEVING(),
|
||||
MINING(),
|
||||
CLEANING_HERBS(),
|
||||
CREATING_UNFINISHED_POTIONS(),
|
||||
CREATING_POTIONS(),
|
||||
SMITHING();
|
||||
}
|
||||
|
17
util/src/main/java/io/reisub/openosrs/util/enums/Food.java
Normal file
17
util/src/main/java/io/reisub/openosrs/util/enums/Food.java
Normal file
@ -0,0 +1,17 @@
|
||||
package io.reisub.openosrs.util.enums;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import net.runelite.api.ItemID;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum Food {
|
||||
TROUT(ItemID.TROUT, 7, 1),
|
||||
SALMON(ItemID.SALMON, 9, 1),
|
||||
LOBSTER(ItemID.LOBSTER, 12, 1);
|
||||
|
||||
private final int id;
|
||||
private final int hp;
|
||||
private final int bites;
|
||||
}
|
@ -1,26 +1,31 @@
|
||||
package io.reisub.openosrs.util.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import net.runelite.api.Skill;
|
||||
|
||||
public class Eat extends Task {
|
||||
private long last = 0;
|
||||
private int min = 5;
|
||||
private int max = 10;
|
||||
|
||||
@Setter
|
||||
private boolean wait = true;
|
||||
|
||||
@Getter
|
||||
private int threshold = 5;
|
||||
private int mean = 5;
|
||||
private int sigma = 1;
|
||||
|
||||
public void setInterval(int min, int max) {
|
||||
mean = (min + max) / 2;
|
||||
sigma = mean - min;
|
||||
|
||||
if (sigma <= 0) threshold = min;
|
||||
this.min = min;
|
||||
this.max = max;
|
||||
|
||||
threshold = getNewThreshold();
|
||||
}
|
||||
|
||||
public void setWait(boolean wait) {
|
||||
this.wait = wait;
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Eating";
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -50,15 +55,6 @@ public class Eat extends Task {
|
||||
}
|
||||
|
||||
private int getNewThreshold() {
|
||||
if (sigma <= 0) {
|
||||
return threshold;
|
||||
}
|
||||
|
||||
return calc.randomGauss(1, 99, sigma, mean, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Eating";
|
||||
return calc.random(min, max + 1);
|
||||
}
|
||||
}
|
||||
|
@ -29,7 +29,7 @@ import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
import net.runelite.client.config.Range;
|
||||
|
||||
@ConfigGroup("ChaosWintertodtConfig")
|
||||
@ConfigGroup("chaoswintertodt")
|
||||
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@Range(min = 1, max = 99)
|
||||
|
@ -2,10 +2,10 @@ package io.reisub.openosrs.wintertodt;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Provides;
|
||||
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.wintertodt.tasks.*;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
@ -19,10 +19,8 @@ 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.time.Duration;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@ -42,7 +40,7 @@ import static net.runelite.api.ItemID.BRUMA_ROOT;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class Wintertodt extends iScript {
|
||||
public class Wintertodt extends CScript {
|
||||
@Inject
|
||||
public Config config;
|
||||
|
||||
@ -50,12 +48,6 @@ public class Wintertodt extends iScript {
|
||||
public static final int WINTERTODT_HEALTH_PACKED_ID = 25952277;
|
||||
public static final int WINTERTODT_GAME_TIMER_ID = 25952259;
|
||||
|
||||
@Getter
|
||||
private Activity currentActivity = Activity.IDLE;
|
||||
|
||||
@Getter
|
||||
private Activity previousActivity = Activity.IDLE;
|
||||
|
||||
@Getter
|
||||
private int respawnTimer;
|
||||
|
||||
@ -73,12 +65,9 @@ public class Wintertodt extends iScript {
|
||||
@Getter
|
||||
private final List<WintertodtProjectile> projectiles = new ArrayList<>();
|
||||
|
||||
private List<Task> tasks;
|
||||
private KittenTask kittenTask;
|
||||
private Hop hopTask;
|
||||
private Scouter scouter;
|
||||
private int fmLevel, wcLevel, fletchLevel;
|
||||
private Instant lastActionTime;
|
||||
private int previousTimerValue;
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@ -87,22 +76,9 @@ public class Wintertodt 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;
|
||||
}
|
||||
}
|
||||
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Wintertodt");
|
||||
super.onStart();
|
||||
|
||||
fmLevel = game.baseLevel(Skill.FIREMAKING);
|
||||
wcLevel = game.baseLevel(Skill.WOODCUTTING);
|
||||
@ -113,52 +89,36 @@ public class Wintertodt extends iScript {
|
||||
Eat eatTask = injector.getInstance(Eat.class);
|
||||
eatTask.setInterval(config.minEatHP(), config.maxEatHP());
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(eatTask);
|
||||
tasks.add(kittenTask);
|
||||
if (config.dodgeProjectiles()) {
|
||||
tasks.add(injector.getInstance(DodgeProjectile.class));
|
||||
addTask(DodgeProjectile.class);
|
||||
}
|
||||
tasks.add(injector.getInstance(OpenInventory.class));
|
||||
tasks.add(injector.getInstance(EatWhileWaiting.class));
|
||||
tasks.add(injector.getInstance(OpenCrates.class));
|
||||
tasks.add(injector.getInstance(GoToBank.class));
|
||||
tasks.add(injector.getInstance(HandleBank.class));
|
||||
tasks.add(injector.getInstance(GoToWintertodt.class));
|
||||
addTask(OpenInventory.class);
|
||||
addTask(EatWhileWaiting.class);
|
||||
addTask(OpenCrates.class);
|
||||
addTask(GoToBank.class);
|
||||
addTask(HandleBank.class);
|
||||
addTask(GoToWintertodt.class);
|
||||
if (config.hop()) {
|
||||
hopTask = injector.getInstance(Hop.class);
|
||||
tasks.add(hopTask);
|
||||
}
|
||||
tasks.add(injector.getInstance(MoveToBrazier.class));
|
||||
tasks.add(injector.getInstance(Fix.class));
|
||||
tasks.add(injector.getInstance(Light.class));
|
||||
tasks.add(injector.getInstance(Fletch.class));
|
||||
tasks.add(injector.getInstance(ChangeSide.class));
|
||||
tasks.add(injector.getInstance(Burn.class));
|
||||
tasks.add(injector.getInstance(Chop.class));
|
||||
addTask(MoveToBrazier.class);
|
||||
addTask(Fix.class);
|
||||
addTask(Light.class);
|
||||
addTask(Fletch.class);
|
||||
addTask(ChangeSide.class);
|
||||
addTask(Burn.class);
|
||||
addTask(Chop.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Wintertodt");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
super.onStop();
|
||||
scouter = null;
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onStatChanged(StatChanged event) {
|
||||
@ -203,10 +163,6 @@ public class Wintertodt extends iScript {
|
||||
@SuppressWarnings("unused")
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(chatMessage);
|
||||
}
|
||||
|
||||
if (!isInWintertodtRegion()) return;
|
||||
|
||||
ChatMessageType chatMessageType = chatMessage.getType();
|
||||
@ -407,32 +363,6 @@ public class Wintertodt extends iScript {
|
||||
}
|
||||
}
|
||||
|
||||
private void setActivity(Activity action) {
|
||||
if (action == Activity.IDLE && currentActivity != Activity.IDLE) {
|
||||
previousActivity = currentActivity;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
private void parseBossHealth() {
|
||||
Widget healthWidget = game.client.getWidget(WINTERTODT_HEALTH_PACKED_ID);
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.reisub.openosrs.wintertodt.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.wintertodt.Activity;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.wintertodt.Side;
|
||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.reisub.openosrs.wintertodt.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.wintertodt.Activity;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.wintertodt.Config;
|
||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.reisub.openosrs.wintertodt.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.wintertodt.Activity;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.reisub.openosrs.wintertodt.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.wintertodt.Activity;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.reisub.openosrs.wintertodt.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.wintertodt.Activity;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.wintertodt.Config;
|
||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
@ -1,7 +1,7 @@
|
||||
package io.reisub.openosrs.wintertodt.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.wintertodt.Activity;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
@ -2,7 +2,7 @@ package io.reisub.openosrs.wintertodt.tasks;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.wintertodt.Activity;
|
||||
import io.reisub.openosrs.util.enums.Activity;
|
||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
|
||||
|
@ -25,13 +25,12 @@
|
||||
package io.reisub.openosrs.woodcutter;
|
||||
|
||||
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("ChaosWoodcutterConfig")
|
||||
@ConfigGroup("chaoswoodcutter")
|
||||
|
||||
public interface WoodcutterConfig extends Config {
|
||||
public interface Config extends net.runelite.client.config.Config {
|
||||
@ConfigItem(
|
||||
keyName = "burnLogs",
|
||||
name = "Burn logs",
|
||||
|
@ -1,25 +1,17 @@
|
||||
package io.reisub.openosrs.woodcutter;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.CScript;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.woodcutter.tasks.Chop;
|
||||
import io.reisub.openosrs.woodcutter.tasks.Drop;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.Client;
|
||||
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 javax.inject.Inject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@ -29,47 +21,17 @@ import java.util.List;
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class WoodcutterPlugin extends iScript {
|
||||
@Inject
|
||||
private Client client;
|
||||
|
||||
private List<Task> tasks;
|
||||
|
||||
public class Woodcutter extends CScript {
|
||||
@Provides
|
||||
WoodcutterConfig provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(WoodcutterConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
t.execute();
|
||||
}
|
||||
}
|
||||
|
||||
game.tickDelay();
|
||||
Config provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(Config.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Woodcutter");
|
||||
super.onStart();
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(injector.getInstance(Chop.class));
|
||||
tasks.add(injector.getInstance(Drop.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Woodcutter");
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
addTask(Chop.class);
|
||||
addTask(Drop.class);
|
||||
}
|
||||
}
|
@ -1,13 +1,13 @@
|
||||
package io.reisub.openosrs.woodcutter.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.woodcutter.WoodcutterConfig;
|
||||
import io.reisub.openosrs.woodcutter.Config;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class Drop extends Task {
|
||||
@Inject
|
||||
private WoodcutterConfig config;
|
||||
private Config config;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
|
@ -23,10 +23,10 @@
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "0.0.1"
|
||||
version = "1.0.0"
|
||||
|
||||
project.extra["PluginName"] = "Chaos Woodcutter" // This is the name that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "Chops wood" // This is the description that is used in the external plugin manager panel
|
||||
project.extra["PluginDescription"] = "How much wood would a woodcutter cut if a woodcutter could cut wood?" // This is the description that is used in the external plugin manager panel
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
|
Loading…
x
Reference in New Issue
Block a user