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.
|
* 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["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
|
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.Alch;
|
||||||
import io.reisub.openosrs.agility.tasks.HandleObstacle;
|
import io.reisub.openosrs.agility.tasks.HandleObstacle;
|
||||||
import io.reisub.openosrs.agility.tasks.PickupMark;
|
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.Util;
|
||||||
import io.reisub.openosrs.util.tasks.Eat;
|
import io.reisub.openosrs.util.tasks.Eat;
|
||||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
|
||||||
import io.reisub.openosrs.util.tasks.Run;
|
import io.reisub.openosrs.util.tasks.Run;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@ -32,38 +31,22 @@ import java.util.List;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class AgilityPlugin extends iScript {
|
public class Agility extends CScript {
|
||||||
@Inject
|
@Inject
|
||||||
private AgilityConfig config;
|
private Config config;
|
||||||
|
|
||||||
private List<Task> tasks;
|
|
||||||
|
|
||||||
private KittenTask kittenTask;
|
|
||||||
private Alch alchTask;
|
private Alch alchTask;
|
||||||
private HandleObstacle handleObstacleTask;
|
private HandleObstacle handleObstacleTask;
|
||||||
private PickupMark pickupMarkTask;
|
private PickupMark pickupMarkTask;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
AgilityConfig provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(AgilityConfig.class);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Agility");
|
super.onStart();
|
||||||
|
|
||||||
Eat eatTask = injector.getInstance(Eat.class);
|
Eat eatTask = injector.getInstance(Eat.class);
|
||||||
eatTask.setInterval(14, 24);
|
eatTask.setInterval(14, 24);
|
||||||
@ -71,7 +54,6 @@ public class AgilityPlugin extends iScript {
|
|||||||
Run runTask = injector.getInstance(Run.class);
|
Run runTask = injector.getInstance(Run.class);
|
||||||
runTask.setInterval(70, 95);
|
runTask.setInterval(70, 95);
|
||||||
|
|
||||||
kittenTask = KittenTask.getInstance(injector);
|
|
||||||
handleObstacleTask = injector.getInstance(HandleObstacle.class);
|
handleObstacleTask = injector.getInstance(HandleObstacle.class);
|
||||||
pickupMarkTask = injector.getInstance(PickupMark.class);
|
pickupMarkTask = injector.getInstance(PickupMark.class);
|
||||||
|
|
||||||
@ -79,10 +61,8 @@ public class AgilityPlugin extends iScript {
|
|||||||
alchTask = injector.getInstance(Alch.class);
|
alchTask = injector.getInstance(Alch.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
|
||||||
tasks.add(eatTask);
|
tasks.add(eatTask);
|
||||||
tasks.add(runTask);
|
tasks.add(runTask);
|
||||||
tasks.add(kittenTask);
|
|
||||||
tasks.add(pickupMarkTask);
|
tasks.add(pickupMarkTask);
|
||||||
if (config.highAlch()) {
|
if (config.highAlch()) {
|
||||||
tasks.add(alchTask);
|
tasks.add(alchTask);
|
||||||
@ -92,23 +72,6 @@ public class AgilityPlugin extends iScript {
|
|||||||
handleObstacleTask.setReady(true);
|
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
|
@Subscribe
|
||||||
private void onHitsplatApplied(HitsplatApplied event) {
|
private void onHitsplatApplied(HitsplatApplied event) {
|
||||||
if (handleObstacleTask != null) {
|
if (handleObstacleTask != null) {
|
||||||
@ -148,10 +111,6 @@ public class AgilityPlugin extends iScript {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onChatMessage(ChatMessage chatMessage) {
|
private void onChatMessage(ChatMessage chatMessage) {
|
||||||
if (kittenTask != null) {
|
|
||||||
kittenTask.onChatMessage(chatMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (handleObstacleTask != null) {
|
if (handleObstacleTask != null) {
|
||||||
handleObstacleTask.onChatMessage(chatMessage);
|
handleObstacleTask.onChatMessage(chatMessage);
|
||||||
}
|
}
|
||||||
|
@ -24,13 +24,12 @@
|
|||||||
*/
|
*/
|
||||||
package io.reisub.openosrs.agility;
|
package io.reisub.openosrs.agility;
|
||||||
import net.runelite.client.config.Button;
|
import net.runelite.client.config.Button;
|
||||||
import net.runelite.client.config.Config;
|
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
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(
|
@ConfigItem(
|
||||||
position = 0,
|
position = 0,
|
||||||
keyName = "courseSelection",
|
keyName = "courseSelection",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.reisub.openosrs.agility.tasks;
|
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 io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
@ -14,7 +14,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
public class Alch extends Task {
|
public class Alch extends Task {
|
||||||
@Inject
|
@Inject
|
||||||
private AgilityConfig config;
|
private Config config;
|
||||||
|
|
||||||
private boolean ready;
|
private boolean ready;
|
||||||
private long lastAlchTick;
|
private long lastAlchTick;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.reisub.openosrs.agility.tasks;
|
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 io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.api.events.*;
|
import net.runelite.api.events.*;
|
||||||
@ -10,7 +10,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
public class HandleObstacle extends Task {
|
public class HandleObstacle extends Task {
|
||||||
@Inject
|
@Inject
|
||||||
private AgilityConfig config;
|
private Config config;
|
||||||
|
|
||||||
private boolean ready;
|
private boolean ready;
|
||||||
private int timeout = 10;
|
private int timeout = 10;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package io.reisub.openosrs.agility.tasks;
|
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 io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.api.events.HitsplatApplied;
|
import net.runelite.api.events.HitsplatApplied;
|
||||||
@ -12,7 +12,7 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
public class PickupMark extends Task {
|
public class PickupMark extends Task {
|
||||||
@Inject
|
@Inject
|
||||||
private AgilityConfig config;
|
private Config config;
|
||||||
|
|
||||||
private boolean failed;
|
private boolean failed;
|
||||||
|
|
||||||
|
@ -7,6 +7,7 @@ import net.runelite.api.ItemID;
|
|||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public enum Ashes {
|
public enum Ashes {
|
||||||
|
NONE(-1),
|
||||||
FIENDISH_ASHES(ItemID.FIENDISH_ASHES),
|
FIENDISH_ASHES(ItemID.FIENDISH_ASHES),
|
||||||
VILE_ASHES(ItemID.VILE_ASHES),
|
VILE_ASHES(ItemID.VILE_ASHES),
|
||||||
MALICIOUS_ASHES(ItemID.MALICIOUS_ASHES),
|
MALICIOUS_ASHES(ItemID.MALICIOUS_ASHES),
|
||||||
@ -14,4 +15,21 @@ public enum Ashes {
|
|||||||
INFERNAL_ASHES(ItemID.INFERNAL_ASHES);
|
INFERNAL_ASHES(ItemID.INFERNAL_ASHES);
|
||||||
|
|
||||||
private final int id;
|
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 io.reisub.openosrs.util.Util;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.events.ConfigButtonClicked;
|
|
||||||
import net.runelite.api.events.ItemContainerChanged;
|
import net.runelite.api.events.ItemContainerChanged;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
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.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.game.Game;
|
import net.runelite.client.plugins.iutils.game.Game;
|
||||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Locale;
|
|
||||||
import java.util.concurrent.Executors;
|
import java.util.concurrent.Executors;
|
||||||
import java.util.concurrent.ScheduledExecutorService;
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -48,12 +44,16 @@ public class Autobones extends Plugin {
|
|||||||
return configManager.getConfig(Config.class);
|
return configManager.getConfig(Config.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int[] itemIds;
|
||||||
|
|
||||||
private ScheduledExecutorService executor;
|
private ScheduledExecutorService executor;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp() {
|
protected void startUp() {
|
||||||
log.info("Starting Chaos Autobones");
|
log.info("Starting Chaos Autobones");
|
||||||
|
|
||||||
|
itemIds = parseItemIds();
|
||||||
|
|
||||||
executor = Executors.newSingleThreadScheduledExecutor();
|
executor = Executors.newSingleThreadScheduledExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,9 +61,19 @@ public class Autobones extends Plugin {
|
|||||||
protected void shutDown() {
|
protected void shutDown() {
|
||||||
log.info("Stopping Chaos Autobones");
|
log.info("Stopping Chaos Autobones");
|
||||||
|
|
||||||
|
itemIds = null;
|
||||||
|
|
||||||
executor.shutdownNow();
|
executor.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unused")
|
||||||
|
@Subscribe
|
||||||
|
private void onConfigChanged(ConfigChanged event) {
|
||||||
|
if (event.getGroup().equals("chaosautobones")) {
|
||||||
|
itemIds = parseItemIds();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onItemContainerChanged(ItemContainerChanged event) {
|
private void onItemContainerChanged(ItemContainerChanged event) {
|
||||||
@ -72,7 +82,34 @@ public class Autobones extends Plugin {
|
|||||||
if (config.bones().getId() == -1 && config.ashes().getId() == -1) return;
|
if (config.bones().getId() == -1 && config.ashes().getId() == -1) return;
|
||||||
|
|
||||||
executor.schedule(() -> {
|
executor.schedule(() -> {
|
||||||
game.inventory().withId(config.bones().getId(), config.ashes().getId()).first().interact(0);
|
game.inventory().withId(itemIds).first().interact(0);
|
||||||
}, 0, TimeUnit.MILLISECONDS);
|
}, 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);
|
SUPERIOR_DRAGON_BONES(ItemID.SUPERIOR_DRAGON_BONES);
|
||||||
|
|
||||||
private final int id;
|
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
|
position = 1
|
||||||
)
|
)
|
||||||
default Ashes ashes() { return Ashes.VILE_ASHES; }
|
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"
|
version = "1.0.0"
|
||||||
|
|
||||||
project.extra["PluginName"] = "Chaos Bosshelper" // This is the name 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"] = "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["PluginDescription"] = "" // This is the description that is used in the external plugin manager panel
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
compileOnly(project(":util"))
|
compileOnly(project(":util"))
|
||||||
|
@ -30,10 +30,10 @@ import java.util.List;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class BasePlugin extends iScript {
|
public class BasePlugin extends CScript {
|
||||||
@Provides
|
@Provides
|
||||||
Config provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(BaseConfig.class);
|
return configManager.getConfig(Config.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -10,12 +10,15 @@ import lombok.extern.slf4j.Slf4j;
|
|||||||
import net.runelite.api.events.GameTick;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.input.KeyListener;
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.time.Duration;
|
import java.time.Duration;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -30,7 +33,10 @@ import java.util.Map;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Birdhouse extends CScript {
|
public class Birdhouse extends CScript implements KeyListener {
|
||||||
|
@Inject
|
||||||
|
private Config config;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
Config provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(Config.class);
|
return configManager.getConfig(Config.class);
|
||||||
@ -87,17 +93,34 @@ public class Birdhouse extends CScript {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onGameTick(GameTick event) {
|
private void onGameTick(GameTick event) {
|
||||||
if (isLoggedIn()
|
// if (isLoggedIn()
|
||||||
&& game.localPlayer().position().regionID() == 14908) {
|
// && game.localPlayer().position().regionID() == 14908) {
|
||||||
if (!active && game.localPlayer().position().distanceTo(hillHousePosition) < 10 && game.inventory().withNamePart("logs").count() == 4) {
|
// if (!active && game.localPlayer().position().distanceTo(hillHousePosition) < 10 && game.inventory().withNamePart("logs").count() == 4) {
|
||||||
execute();
|
// execute();
|
||||||
} else if (active && game.inventory().all().isEmpty() && !bank.isOpen() && game.localPlayer().position().distanceTo(islandPosition) < 10) {
|
// } else if (active && game.inventory().all().isEmpty() && !bank.isOpen() && game.localPlayer().position().distanceTo(islandPosition) < 10) {
|
||||||
execute();
|
// execute();
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasRecentlyBeenEmptied(BirdhouseSpace space) {
|
public boolean hasRecentlyBeenEmptied(BirdhouseSpace space) {
|
||||||
return Duration.between(getBirdhouseTimers().get(space), Instant.now()).getSeconds() < 2000;
|
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;
|
package io.reisub.openosrs.birdhouse;
|
||||||
|
|
||||||
import javax.annotation.Nullable;
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
|
|
||||||
|
import javax.annotation.Nullable;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
public enum BirdhouseType {
|
public enum BirdhouseType {
|
||||||
|
@ -27,15 +27,29 @@ package io.reisub.openosrs.birdhouse;
|
|||||||
import net.runelite.client.config.Button;
|
import net.runelite.client.config.Button;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
import net.runelite.client.config.Keybind;
|
||||||
|
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
@ConfigGroup("chaosbirdhouse")
|
@ConfigGroup("chaosbirdhouse")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
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(
|
@ConfigItem(
|
||||||
keyName = "farmSeaweed",
|
keyName = "farmSeaweed",
|
||||||
name = "Farm seaweed",
|
name = "Farm seaweed",
|
||||||
description = "Harvest and plant seaweed after a birdhouse run.",
|
description = "Harvest and plant seaweed after a birdhouse run.",
|
||||||
position = 0
|
position = 1
|
||||||
)
|
)
|
||||||
default boolean farmSeaweed() { return true; }
|
default boolean farmSeaweed() { return true; }
|
||||||
|
|
||||||
|
@ -42,7 +42,9 @@ public class BankSpores extends Task {
|
|||||||
bank.depositInventory();
|
bank.depositInventory();
|
||||||
game.tick();
|
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();
|
game.tick();
|
||||||
|
|
||||||
bank.withdraw(ItemID.FISHBOWL_HELMET, 1, false);
|
bank.withdraw(ItemID.FISHBOWL_HELMET, 1, false);
|
||||||
@ -51,6 +53,9 @@ public class BankSpores extends Task {
|
|||||||
bank.withdraw(ItemID.DIVING_APPARATUS, 1, false);
|
bank.withdraw(ItemID.DIVING_APPARATUS, 1, false);
|
||||||
game.tick();
|
game.tick();
|
||||||
|
|
||||||
|
bank.withdraw(ItemID.FLIPPERS, 1, false);
|
||||||
|
game.tick();
|
||||||
|
|
||||||
bank.close();
|
bank.close();
|
||||||
game.waitUntil(() -> !bank.isOpen(), 5);
|
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.inventory().withId(ItemID.DIVING_APPARATUS).findFirst().ifPresent((apparatus) -> apparatus.interact("Wear"));
|
||||||
game.tick();
|
game.tick();
|
||||||
|
|
||||||
|
game.inventory().withId(ItemID.FLIPPERS).findFirst().ifPresent((flippers) -> flippers.interact("Wear"));
|
||||||
|
game.tick();
|
||||||
iObject rowboat = game.objects().withName("Rowboat").nearest();
|
iObject rowboat = game.objects().withName("Rowboat").nearest();
|
||||||
if (rowboat == null) return;
|
if (rowboat == null) return;
|
||||||
|
|
||||||
|
@ -7,7 +7,6 @@ import io.reisub.openosrs.util.Task;
|
|||||||
import net.runelite.client.plugins.iutils.game.iObject;
|
import net.runelite.client.plugins.iutils.game.iObject;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
|
||||||
public class EmptyBirdhouse extends Task {
|
public class EmptyBirdhouse extends Task {
|
||||||
|
@ -23,7 +23,7 @@ public class GetTools extends Task {
|
|||||||
if (leprechaun == null) return;
|
if (leprechaun == null) return;
|
||||||
|
|
||||||
leprechaun.interact("Exchange");
|
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();
|
game.tick();
|
||||||
|
|
||||||
iWidget dibber = game.widget(125, 9);
|
iWidget dibber = game.widget(125, 9);
|
||||||
|
@ -24,9 +24,11 @@
|
|||||||
*/
|
*/
|
||||||
package io.reisub.openosrs.consume;
|
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 {
|
public interface Config extends net.runelite.client.config.Config {
|
||||||
@ConfigSection(
|
@ConfigSection(
|
||||||
@ -384,4 +386,45 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
default boolean magicWarnings() {
|
default boolean magicWarnings() {
|
||||||
return true;
|
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.Calculations;
|
||||||
import io.reisub.openosrs.util.Util;
|
import io.reisub.openosrs.util.Util;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.*;
|
||||||
import net.runelite.api.ItemID;
|
|
||||||
import net.runelite.api.Skill;
|
|
||||||
import net.runelite.api.VarPlayer;
|
|
||||||
import net.runelite.api.events.*;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.events.ConfigChanged;
|
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.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.game.Game;
|
import net.runelite.client.plugins.iutils.game.Game;
|
||||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
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.iUtils;
|
||||||
|
import net.runelite.client.plugins.iutils.ui.Bank;
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.Executors;
|
||||||
|
import java.util.concurrent.ScheduledExecutorService;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@ -33,18 +37,21 @@ import java.util.Set;
|
|||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Consume extends Plugin {
|
public class Consume extends Plugin {
|
||||||
@Inject
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@Inject
|
||||||
private Game game;
|
private Game game;
|
||||||
|
|
||||||
@Inject
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@Inject
|
||||||
private Config config;
|
private Config config;
|
||||||
|
|
||||||
@Inject
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@Inject
|
||||||
private Calculations calc;
|
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> 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> 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,
|
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_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);
|
ItemID.DIVINE_BATTLEMAGE_POTION1, ItemID.DIVINE_BATTLEMAGE_POTION2, ItemID.DIVINE_BATTLEMAGE_POTION3, ItemID.DIVINE_BATTLEMAGE_POTION4);
|
||||||
|
|
||||||
|
private ScheduledExecutorService executor;
|
||||||
private long lastAte;
|
private long lastAte;
|
||||||
private long lastPot;
|
private long lastPot;
|
||||||
private int timeout;
|
private int timeout;
|
||||||
@ -104,9 +112,10 @@ public class Consume extends Plugin {
|
|||||||
private long lastRanged;
|
private long lastRanged;
|
||||||
private boolean shouldDrinkMagic;
|
private boolean shouldDrinkMagic;
|
||||||
private long lastMagic;
|
private long lastMagic;
|
||||||
|
private boolean shouldUseSpecial;
|
||||||
|
|
||||||
@Provides
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@Provides
|
||||||
Config provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(Config.class);
|
return configManager.getConfig(Config.class);
|
||||||
}
|
}
|
||||||
@ -114,25 +123,120 @@ public class Consume extends Plugin {
|
|||||||
@Override
|
@Override
|
||||||
protected void startUp() {
|
protected void startUp() {
|
||||||
log.info("Starting Chaos Consume");
|
log.info("Starting Chaos Consume");
|
||||||
|
|
||||||
|
generateNewEatThreshold();
|
||||||
|
generateNewPrayerThreshold();
|
||||||
|
|
||||||
|
executor = Executors.newSingleThreadScheduledExecutor();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void shutDown() {
|
protected void shutDown() {
|
||||||
log.info("Stopping Chaos Consume");
|
log.info("Stopping Chaos Consume");
|
||||||
|
|
||||||
|
executor.shutdownNow();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
|
@Subscribe
|
||||||
private void onGameTick(GameTick event) {
|
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) {
|
if (timeout > 0) {
|
||||||
timeout--;
|
timeout--;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (eatThreshold == 0) generateNewEatThreshold();
|
executor.schedule(this::tick, calc.random(50, 80), TimeUnit.MILLISECONDS);
|
||||||
if (prayerThreshold == 0) generateNewPrayerThreshold();
|
}
|
||||||
|
|
||||||
|
@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);
|
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 (shouldDrinkAntiPoison && canPot()) {
|
||||||
if (!drinkPotion(ANTI_POISON_IDS) && config.antiPoisonWarnings()) {
|
if (!drinkPotion(ANTI_POISON_IDS) && config.antiPoisonWarnings()) {
|
||||||
game.utils.sendGameMessage("Poisoned but you don't have anti-poison!");
|
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() {
|
private void generateNewEatThreshold() {
|
||||||
eatThreshold = calc.random(config.minEatHP(), config.maxEatHP() + 1);
|
eatThreshold = calc.random(config.minEatHP(), config.maxEatHP() + 1);
|
||||||
}
|
}
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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["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
|
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.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
|
||||||
@ConfigGroup("ChaosCookerConfig")
|
@ConfigGroup("chaoscooker")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
public interface Config extends net.runelite.client.config.Config {
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
|
@ -3,34 +3,23 @@ package io.reisub.openosrs.cooker;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import io.reisub.openosrs.cooker.tasks.Cook;
|
import io.reisub.openosrs.cooker.tasks.Cook;
|
||||||
import io.reisub.openosrs.cooker.tasks.HandleBank;
|
import io.reisub.openosrs.cooker.tasks.HandleBank;
|
||||||
import io.reisub.openosrs.cooker.tasks.SkipLevel;
|
import io.reisub.openosrs.util.CScript;
|
||||||
import io.reisub.openosrs.util.Task;
|
|
||||||
import io.reisub.openosrs.util.Util;
|
import io.reisub.openosrs.util.Util;
|
||||||
|
import io.reisub.openosrs.util.enums.Activity;
|
||||||
import io.reisub.openosrs.util.tasks.Run;
|
import io.reisub.openosrs.util.tasks.Run;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.AnimationID;
|
import net.runelite.api.AnimationID;
|
||||||
import net.runelite.api.ChatMessageType;
|
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.events.AnimationChanged;
|
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.api.events.ItemContainerChanged;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
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
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@ -41,14 +30,7 @@ import static net.runelite.api.AnimationID.IDLE;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Cooker extends iScript {
|
public class Cooker extends CScript {
|
||||||
private List<Task> tasks;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private Activity currentActivity;
|
|
||||||
|
|
||||||
private Instant lastActionTime;
|
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
private Config config;
|
private Config config;
|
||||||
|
|
||||||
@ -57,50 +39,16 @@ public class Cooker extends iScript {
|
|||||||
return configManager.getConfig(Config.class);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Cooker");
|
super.onStart();
|
||||||
|
|
||||||
Run runTask = injector.getInstance(Run.class);
|
Run runTask = injector.getInstance(Run.class);
|
||||||
runTask.setInterval(70, 95);
|
runTask.setInterval(70, 95);
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
|
||||||
tasks.add(runTask);
|
tasks.add(runTask);
|
||||||
tasks.add(injector.getInstance(SkipLevel.class));
|
addTask(HandleBank.class);
|
||||||
tasks.add(injector.getInstance(HandleBank.class));
|
addTask(Cook.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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -124,36 +72,4 @@ public class Cooker extends iScript {
|
|||||||
setActivity(Activity.IDLE);
|
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;
|
package io.reisub.openosrs.cooker.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.cooker.Activity;
|
|
||||||
import io.reisub.openosrs.cooker.Config;
|
import io.reisub.openosrs.cooker.Config;
|
||||||
import io.reisub.openosrs.cooker.Cooker;
|
import io.reisub.openosrs.cooker.Cooker;
|
||||||
import io.reisub.openosrs.util.Task;
|
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.InventoryItem;
|
||||||
import net.runelite.client.plugins.iutils.game.iObject;
|
import net.runelite.client.plugins.iutils.game.iObject;
|
||||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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["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
|
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;
|
package io.reisub.openosrs.fisher;
|
||||||
|
|
||||||
import net.runelite.client.config.Button;
|
import net.runelite.client.config.Button;
|
||||||
import net.runelite.client.config.Config;
|
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
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(
|
@ConfigItem(
|
||||||
keyName = "startButton",
|
keyName = "startButton",
|
||||||
name = "Start/Stop",
|
name = "Start/Stop",
|
||||||
|
@ -3,23 +3,15 @@ package io.reisub.openosrs.fisher;
|
|||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
import io.reisub.openosrs.fisher.tasks.Drop;
|
import io.reisub.openosrs.fisher.tasks.Drop;
|
||||||
import io.reisub.openosrs.fisher.tasks.Fish;
|
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.Util;
|
||||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@PluginDependency(iUtils.class)
|
@PluginDependency(iUtils.class)
|
||||||
@ -29,62 +21,17 @@ import java.util.List;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class FisherPlugin extends iScript {
|
public class Fisher extends CScript {
|
||||||
private List<Task> tasks;
|
|
||||||
|
|
||||||
private KittenTask kittenTask;
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
FisherConfig provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(FisherConfig.class);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Fisher");
|
super.onStart();
|
||||||
|
|
||||||
kittenTask = KittenTask.getInstance(injector);
|
addTask(Drop.class);
|
||||||
|
addTask(Fish.class);
|
||||||
tasks = new ArrayList<>();
|
|
||||||
tasks.add(kittenTask);
|
|
||||||
tasks.add(injector.getInstance(Drop.class));
|
|
||||||
tasks.add(injector.getInstance(Fish.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
log.info("Stopping Chaos Fisher");
|
|
||||||
if (tasks != null) {
|
|
||||||
tasks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
KittenTask.handleKitten = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
|
||||||
if (configButtonClicked.getKey().equals("startButton")) {
|
|
||||||
execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
private void onChatMessage(ChatMessage chatMessage) {
|
|
||||||
if (kittenTask != null) {
|
|
||||||
kittenTask.onChatMessage(chatMessage);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,11 +3,8 @@ package io.reisub.openosrs.fisher.tasks;
|
|||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
import net.runelite.client.plugins.iutils.ui.Bank;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
public class HandleBank extends Task {
|
||||||
|
|
||||||
public class DoBank extends Task {
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return "Banking";
|
return "Banking";
|
||||||
|
@ -4,9 +4,9 @@ import com.google.inject.Provides;
|
|||||||
import io.reisub.openosrs.glassblower.tasks.Blow;
|
import io.reisub.openosrs.glassblower.tasks.Blow;
|
||||||
import io.reisub.openosrs.glassblower.tasks.HandleBank;
|
import io.reisub.openosrs.glassblower.tasks.HandleBank;
|
||||||
import io.reisub.openosrs.glassblower.tasks.PickupSeed;
|
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.CScript;
|
||||||
import io.reisub.openosrs.util.Util;
|
import io.reisub.openosrs.util.Util;
|
||||||
|
import io.reisub.openosrs.util.enums.Activity;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.AnimationID;
|
import net.runelite.api.AnimationID;
|
||||||
import net.runelite.api.GameState;
|
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.Config;
|
||||||
import io.reisub.openosrs.glassblower.Glassblower;
|
import io.reisub.openosrs.glassblower.Glassblower;
|
||||||
import io.reisub.openosrs.util.enums.Activity;
|
|
||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
|
import io.reisub.openosrs.util.enums.Activity;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
import net.runelite.client.plugins.iutils.game.InventoryItem;
|
||||||
import net.runelite.client.plugins.iutils.game.iObject;
|
import net.runelite.client.plugins.iutils.game.iObject;
|
||||||
@ -47,6 +47,8 @@ public class Blow extends Task {
|
|||||||
game.tick();
|
game.tick();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (game.groundItems().withId(ItemID.SEAWEED_SPORE).exists()) return;
|
||||||
|
|
||||||
InventoryItem pipe = game.inventory().withId(ItemID.GLASSBLOWING_PIPE).first();
|
InventoryItem pipe = game.inventory().withId(ItemID.GLASSBLOWING_PIPE).first();
|
||||||
InventoryItem moltenGlass = game.inventory().withId(ItemID.MOLTEN_GLASS).first();
|
InventoryItem moltenGlass = game.inventory().withId(ItemID.MOLTEN_GLASS).first();
|
||||||
if (pipe == null || moltenGlass == null) return;
|
if (pipe == null || moltenGlass == null) return;
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package io.reisub.openosrs.glassblower.tasks;
|
package io.reisub.openosrs.glassblower.tasks;
|
||||||
|
|
||||||
|
import io.reisub.openosrs.glassblower.Glassblower;
|
||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.client.plugins.iutils.game.iGroundItem;
|
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();
|
int quantity = game.inventory().withId(ItemID.SEAWEED_SPORE).quantity();
|
||||||
|
|
||||||
item.interact("Take");
|
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;
|
package io.reisub.openosrs.masterthiever;
|
||||||
|
|
||||||
|
import io.reisub.openosrs.util.enums.Food;
|
||||||
import net.runelite.client.config.Button;
|
import net.runelite.client.config.Button;
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
|
||||||
@ConfigGroup("ChaosMasterThieverConfig")
|
@ConfigGroup("chaosmasterthiever")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
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(
|
@ConfigItem(
|
||||||
keyName = "startButton",
|
keyName = "startButton",
|
||||||
name = "Start/Stop",
|
name = "Start/Stop",
|
||||||
|
@ -1,96 +1,81 @@
|
|||||||
package io.reisub.openosrs.masterthiever;
|
package io.reisub.openosrs.masterthiever;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
import io.reisub.openosrs.masterthiever.tasks.HandleBank;
|
import io.reisub.openosrs.masterthiever.tasks.HandleBank;
|
||||||
import io.reisub.openosrs.masterthiever.tasks.Steal;
|
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.Util;
|
||||||
|
import io.reisub.openosrs.util.enums.Activity;
|
||||||
import io.reisub.openosrs.util.tasks.Eat;
|
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 lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.Actor;
|
||||||
import net.runelite.api.events.ConfigButtonClicked;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import javax.inject.Inject;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@PluginDependency(iUtils.class)
|
@PluginDependency(iUtils.class)
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Chaos Master Thiever",
|
name = "Chaos Master Thiever",
|
||||||
description = "Steals seeds from master farmers.",
|
description = "Cor blimey mate, what are ye doing in me pockets?",
|
||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class MasterThiever extends iScript {
|
public class MasterThiever extends CScript {
|
||||||
private List<Task> tasks;
|
@Inject
|
||||||
private KittenTask kittenTask;
|
private Config config;
|
||||||
|
|
||||||
|
private Eat eatTask;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
Config provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(Config.class);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Master Thiever");
|
super.onStart();
|
||||||
|
|
||||||
Eat eatTask = injector.getInstance(Eat.class);
|
eatTask = injector.getInstance(Eat.class);
|
||||||
eatTask.setInterval(14, 24);
|
eatTask.setInterval(config.minEatHP(), config.maxEatHP());
|
||||||
|
|
||||||
kittenTask = KittenTask.getInstance(injector);
|
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
|
||||||
tasks.add(eatTask);
|
tasks.add(eatTask);
|
||||||
tasks.add(kittenTask);
|
addTask(HandleBank.class);
|
||||||
tasks.add(injector.getInstance(HandleBank.class));
|
addTask(Steal.class);
|
||||||
tasks.add(injector.getInstance(Steal.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
log.info("Stopping Chaos Master Thiever");
|
|
||||||
if (tasks != null) {
|
|
||||||
tasks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
KittenTask.handleKitten = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
private void onAnimationChanged(AnimationChanged event) {
|
||||||
if (configButtonClicked.getKey().equals("startButton")) {
|
Actor actor = event.getActor();
|
||||||
execute();
|
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
|
@Subscribe
|
||||||
private void onChatMessage(ChatMessage chatMessage) {
|
private void onStatChanged(StatChanged event) {
|
||||||
if (kittenTask != null) {
|
if (event.getSkill() == Skill.THIEVING) {
|
||||||
kittenTask.onChatMessage(chatMessage);
|
setActivity(Activity.IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getEatThreshold() {
|
||||||
|
return eatTask.getThreshold();
|
||||||
|
}
|
||||||
}
|
}
|
@ -1,15 +1,23 @@
|
|||||||
package io.reisub.openosrs.masterthiever.tasks;
|
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 io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.client.plugins.iutils.api.Interactable;
|
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 net.runelite.client.plugins.iutils.scene.Position;
|
||||||
|
|
||||||
import java.util.function.Predicate;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class HandleBank extends Task {
|
public class HandleBank extends Task {
|
||||||
|
@Inject
|
||||||
|
private MasterThiever plugin;
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
private Config config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return "Banking";
|
return "Banking";
|
||||||
@ -19,21 +27,22 @@ public class HandleBank extends Task {
|
|||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
return game.client().getLocalPlayer().getModelHeight() != 1000
|
return game.client().getLocalPlayer().getModelHeight() != 1000
|
||||||
&& (game.inventory().full()
|
&& (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
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
game.tick();
|
game.tick();
|
||||||
if (!bank.isOpen()) {
|
if (!bank.isOpen()) {
|
||||||
Interactable bankObj;
|
iObject bankObj = game.objects().withAction("Bank").withPosition(new Position(3091, 3245, 0)).first();
|
||||||
if (calc.random(0, 1) == 0) {
|
if (bankObj == null) {
|
||||||
bankObj = game.objects().filter(obj -> obj.name().equals("Bank booth") && obj.position().equals(new Position(3091, 3245, 0))).first();
|
bankObj = game.objects().withName("Bank chest", "Bank booth", "Bank Chest-wreck").withAction("Bank").nearest();
|
||||||
} else {
|
|
||||||
bankObj = game.npcs().filter(npc -> npc.name().equals("Banker") && npc.position().equals(new Position(3090, 3245, 0))).first();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (bankObj == null) return;
|
if (bankObj == null) {
|
||||||
|
walking.walkTo(new Position(3090, 3248, 0).areaWithin(2));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
bankObj.interact("Bank");
|
bankObj.interact("Bank");
|
||||||
game.waitUntil(() -> bank.isOpen(), 15);
|
game.waitUntil(() -> bank.isOpen(), 15);
|
||||||
@ -42,12 +51,21 @@ public class HandleBank extends Task {
|
|||||||
bank.depositInventory();
|
bank.depositInventory();
|
||||||
game.tick();
|
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);
|
bank.withdraw(ItemID.SALMON, quantity, false);
|
||||||
game.waitUntil(() -> game.inventory().withAction("Eat", "Drink").count() > 1, 6);
|
game.waitUntil(() -> game.inventory().withAction("Eat", "Drink").count() > 1, 6);
|
||||||
|
|
||||||
bank.close();
|
bank.close();
|
||||||
game.waitUntil(() -> !bank.isOpen(), 3);
|
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;
|
package io.reisub.openosrs.masterthiever.tasks;
|
||||||
|
|
||||||
|
import io.reisub.openosrs.masterthiever.MasterThiever;
|
||||||
import io.reisub.openosrs.util.Task;
|
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.NpcID;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class Steal extends Task {
|
public class Steal extends Task {
|
||||||
|
@Inject
|
||||||
|
private MasterThiever plugin;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
return "Pickpocketing";
|
return "Pickpocketing";
|
||||||
@ -14,8 +22,9 @@ public class Steal extends Task {
|
|||||||
@Override
|
@Override
|
||||||
public boolean validate() {
|
public boolean validate() {
|
||||||
return !game.inventory().full()
|
return !game.inventory().full()
|
||||||
|
&& plugin.getCurrentActivity() == Activity.IDLE
|
||||||
&& game.client().getLocalPlayer().getModelHeight() != 1000
|
&& 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
|
@Override
|
||||||
@ -24,8 +33,9 @@ public class Steal extends Task {
|
|||||||
|
|
||||||
if (farmer == null) return;
|
if (farmer == null) return;
|
||||||
|
|
||||||
|
|
||||||
farmer.interact("Pickpocket");
|
farmer.interact("Pickpocket");
|
||||||
game.tick(calc.random(0, 2));
|
plugin.setActivity(Activity.THIEVING);
|
||||||
game.sleepDelay();
|
game.tick();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,7 +10,10 @@ import net.runelite.client.plugins.iutils.game.iObject;
|
|||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
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 {
|
public class Mine extends Task {
|
||||||
@Inject
|
@Inject
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
version = "1.1.0"
|
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["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 {
|
dependencies {
|
||||||
compileOnly(project(":util"))
|
compileOnly(project(":util"))
|
||||||
|
@ -28,19 +28,20 @@ import net.runelite.client.config.ConfigGroup;
|
|||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
import net.runelite.client.config.Keybind;
|
import net.runelite.client.config.Keybind;
|
||||||
|
|
||||||
|
import java.awt.event.InputEvent;
|
||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
@ConfigGroup("ChaosPrayerflickConfig")
|
@ConfigGroup("chaosprayerflicking")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
public interface Config extends net.runelite.client.config.Config {
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "hotkey",
|
keyName = "prayerFlickHotkey",
|
||||||
name = "Flick hotkey",
|
name = "Flick hotkey",
|
||||||
description = "When you press this key prayer flicking will start",
|
description = "When you press this key prayer flicking will start",
|
||||||
position = 0
|
position = 0
|
||||||
)
|
)
|
||||||
default Keybind hotkey() {
|
default Keybind prayerFlickHotkey() {
|
||||||
return new Keybind(KeyEvent.VK_BACK_SLASH, 0);
|
return new Keybind(KeyEvent.VK_BACK_QUOTE, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
@ -60,7 +61,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
position = 20
|
position = 20
|
||||||
)
|
)
|
||||||
default Keybind hotkeyMelee() {
|
default Keybind hotkeyMelee() {
|
||||||
return new Keybind(KeyEvent.VK_1, 0);
|
return new Keybind(KeyEvent.VK_1, InputEvent.CTRL_DOWN_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
@ -70,7 +71,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
position = 21
|
position = 21
|
||||||
)
|
)
|
||||||
default Keybind hotkeyMissiles() {
|
default Keybind hotkeyMissiles() {
|
||||||
return new Keybind(KeyEvent.VK_2, 0);
|
return new Keybind(KeyEvent.VK_2, InputEvent.CTRL_DOWN_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
@ -80,7 +81,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
position = 22
|
position = 22
|
||||||
)
|
)
|
||||||
default Keybind hotkeyMagic() {
|
default Keybind hotkeyMagic() {
|
||||||
return new Keybind(KeyEvent.VK_3, 0);
|
return new Keybind(KeyEvent.VK_3, InputEvent.CTRL_DOWN_MASK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
@ -90,4 +91,76 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
position = 23
|
position = 23
|
||||||
)
|
)
|
||||||
default boolean openInventory() { return true; }
|
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.Calculations;
|
||||||
import io.reisub.openosrs.util.Util;
|
import io.reisub.openosrs.util.Util;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.Client;
|
import net.runelite.api.*;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.events.AnimationChanged;
|
||||||
import net.runelite.api.MenuAction;
|
|
||||||
import net.runelite.api.events.GameTick;
|
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.api.widgets.WidgetInfo;
|
||||||
import net.runelite.client.callback.ClientThread;
|
import net.runelite.client.callback.ClientThread;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
@ -34,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@PluginDependency(iUtils.class)
|
@PluginDependency(iUtils.class)
|
||||||
@PluginDescriptor(
|
@PluginDescriptor(
|
||||||
name = "Chaos Prayer Flicking",
|
name = "Chaos Prayer Flicking",
|
||||||
description = "",
|
description = "Infinite power!",
|
||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@ -62,10 +61,16 @@ public class Prayerflick extends Plugin implements KeyListener {
|
|||||||
return configManager.getConfig(Config.class);
|
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 ScheduledExecutorService executor;
|
||||||
private boolean toggleFlicking;
|
private boolean toggleFlicking;
|
||||||
private boolean firstFlick;
|
private boolean firstFlick;
|
||||||
private boolean toggledOff;
|
private boolean toggledOff;
|
||||||
|
private volatile ProtectFrom currently;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void startUp() {
|
protected void startUp() {
|
||||||
@ -94,19 +99,51 @@ public class Prayerflick extends Plugin implements KeyListener {
|
|||||||
boolean active = quickPrayers.actions().get(0).equals("Deactivate");
|
boolean active = quickPrayers.actions().get(0).equals("Deactivate");
|
||||||
|
|
||||||
if (!active && !firstFlick) {
|
if (!active && !firstFlick) {
|
||||||
toggle(calc.random(1, 15), quickPrayers);
|
toggle(calc.random(config.onDelayMin(), config.onDelayMax()), quickPrayers);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
toggle(calc.random(1, 9), quickPrayers);
|
toggle(calc.random(config.onDelayMin(), config.offDelayMax()), quickPrayers);
|
||||||
toggle(calc.random(90, 100), quickPrayers);
|
toggle(calc.random(config.offDelayMin(), config.offDelayMax()), quickPrayers);
|
||||||
|
|
||||||
if (firstFlick) {
|
if (firstFlick) {
|
||||||
firstFlick = false;
|
firstFlick = false;
|
||||||
}
|
}
|
||||||
} else if (!toggleFlicking && toggledOff && config.deactivateAfterStopping()) {
|
} else if (!toggleFlicking && toggledOff && config.deactivateAfterStopping()) {
|
||||||
toggledOff = false;
|
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
|
@Override
|
||||||
public void keyPressed(KeyEvent e) {
|
public void keyPressed(KeyEvent e) {
|
||||||
if (config.hotkey().matches(e)) {
|
if (config.prayerFlickHotkey().matches(e)) {
|
||||||
if (toggleFlicking) {
|
if (toggleFlicking) {
|
||||||
toggledOff = true;
|
toggledOff = true;
|
||||||
} else {
|
} else {
|
||||||
@ -130,18 +167,26 @@ public class Prayerflick extends Plugin implements KeyListener {
|
|||||||
|
|
||||||
toggleFlicking = !toggleFlicking;
|
toggleFlicking = !toggleFlicking;
|
||||||
} else if (config.hotkeyMelee().matches(e)) {
|
} else if (config.hotkeyMelee().matches(e)) {
|
||||||
setPrayer(14);
|
setPrayer(ProtectFrom.MELEE, config.allowToggleOff());
|
||||||
} else if (config.hotkeyMissiles().matches(e)) {
|
} else if (config.hotkeyMissiles().matches(e)) {
|
||||||
setPrayer(13);
|
setPrayer(ProtectFrom.MISSILES, config.allowToggleOff());
|
||||||
} else if (config.hotkeyMagic().matches(e)) {
|
} else if (config.hotkeyMagic().matches(e)) {
|
||||||
setPrayer(12);
|
setPrayer(ProtectFrom.MAGIC, config.allowToggleOff());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent e) {}
|
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(() -> {
|
executor.schedule(() -> {
|
||||||
iWidget quickPrayers = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
iWidget quickPrayers = game.widget(WidgetInfo.MINIMAP_QUICK_PRAYER_ORB);
|
||||||
if (quickPrayers == null) return;
|
if (quickPrayers == null) return;
|
||||||
@ -152,7 +197,7 @@ public class Prayerflick extends Plugin implements KeyListener {
|
|||||||
return w != null && !w.hidden();
|
return w != null && !w.hidden();
|
||||||
});
|
});
|
||||||
|
|
||||||
iWidget protection = game.widget(77, 4, childId);
|
iWidget protection = game.widget(77, 4, protectFrom.getChildId());
|
||||||
if (protection == null) return;
|
if (protection == null) return;
|
||||||
|
|
||||||
protection.interact(0);
|
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(":autodropper")
|
||||||
include(":birdhouse")
|
include(":birdhouse")
|
||||||
include(":blackjack")
|
include(":blackjack")
|
||||||
|
include(":bosshelper")
|
||||||
include(":consume")
|
include(":consume")
|
||||||
include(":cooker")
|
include(":cooker")
|
||||||
|
include(":fighter")
|
||||||
include(":fisher")
|
include(":fisher")
|
||||||
include(":glassblower")
|
include(":glassblower")
|
||||||
|
include(":herblore")
|
||||||
include(":masterthiever")
|
include(":masterthiever")
|
||||||
include(":miner")
|
include(":miner")
|
||||||
|
include(":mtahelper")
|
||||||
include(":prayerflick")
|
include(":prayerflick")
|
||||||
include(":shopper")
|
include(":shopper")
|
||||||
include(":smelter")
|
include(":smelter")
|
||||||
|
include(":smither")
|
||||||
|
include(":superglassmake")
|
||||||
include(":tempoross")
|
include(":tempoross")
|
||||||
include(":test")
|
include(":test")
|
||||||
include(":util")
|
include(":util")
|
||||||
|
include(":volcanicashminer")
|
||||||
include(":wintertodt")
|
include(":wintertodt")
|
||||||
include(":woodcutter")
|
//include(":woodcutter")
|
||||||
|
|
||||||
for (project in rootProject.children) {
|
for (project in rootProject.children) {
|
||||||
project.apply {
|
project.apply {
|
||||||
|
@ -29,7 +29,7 @@ import net.runelite.client.config.ConfigGroup;
|
|||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
import net.runelite.client.config.ConfigSection;
|
import net.runelite.client.config.ConfigSection;
|
||||||
|
|
||||||
@ConfigGroup("ChaosShopperConfig")
|
@ConfigGroup("chaosshopper")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
public interface Config extends net.runelite.client.config.Config {
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
@ -54,6 +54,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemOneEnabled",
|
keyName = "itemOneEnabled",
|
||||||
name = "Enable",
|
name = "Enable",
|
||||||
description = "Enable the buying of this item",
|
description = "Enable the buying of this item",
|
||||||
|
section = "itemOne",
|
||||||
position = 11
|
position = 11
|
||||||
)
|
)
|
||||||
default boolean itemOneEnabled() {
|
default boolean itemOneEnabled() {
|
||||||
@ -61,19 +62,21 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemOneName",
|
keyName = "itemOneId",
|
||||||
name = "Name",
|
name = "ID",
|
||||||
description = "Name of the item",
|
description = "ID of the item",
|
||||||
|
section = "itemOne",
|
||||||
position = 12
|
position = 12
|
||||||
)
|
)
|
||||||
default String itemOneName() {
|
default int itemOneId() {
|
||||||
return "";
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemOneAmount",
|
keyName = "itemOneAmount",
|
||||||
name = "Amount",
|
name = "Amount",
|
||||||
description = "Amount of the item to buy",
|
description = "Amount of the item to buy",
|
||||||
|
section = "itemOne",
|
||||||
position = 13
|
position = 13
|
||||||
)
|
)
|
||||||
default int itemOneAmount() {
|
default int itemOneAmount() {
|
||||||
@ -84,6 +87,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemOneMinInStore",
|
keyName = "itemOneMinInStore",
|
||||||
name = "Min in store",
|
name = "Min in store",
|
||||||
description = "Amount to keep in store to prevent overpaying",
|
description = "Amount to keep in store to prevent overpaying",
|
||||||
|
section = "itemOne",
|
||||||
position = 14
|
position = 14
|
||||||
)
|
)
|
||||||
default int itemOneMinInStore() {
|
default int itemOneMinInStore() {
|
||||||
@ -103,6 +107,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemTwoEnabled",
|
keyName = "itemTwoEnabled",
|
||||||
name = "Enable",
|
name = "Enable",
|
||||||
description = "Enable the buying of this item",
|
description = "Enable the buying of this item",
|
||||||
|
section = "itemTwo",
|
||||||
position = 21
|
position = 21
|
||||||
)
|
)
|
||||||
default boolean itemTwoEnabled() {
|
default boolean itemTwoEnabled() {
|
||||||
@ -110,19 +115,21 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemTwoName",
|
keyName = "itemTwoId",
|
||||||
name = "Name",
|
name = "ID",
|
||||||
description = "Name of the item",
|
description = "ID of the item",
|
||||||
|
section = "itemTwo",
|
||||||
position = 22
|
position = 22
|
||||||
)
|
)
|
||||||
default String itemTwoName() {
|
default int itemTwoId() {
|
||||||
return "";
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemTwoAmount",
|
keyName = "itemTwoAmount",
|
||||||
name = "Amount",
|
name = "Amount",
|
||||||
description = "Amount of the item to buy",
|
description = "Amount of the item to buy",
|
||||||
|
section = "itemTwo",
|
||||||
position = 23
|
position = 23
|
||||||
)
|
)
|
||||||
default int itemTwoAmount() {
|
default int itemTwoAmount() {
|
||||||
@ -133,6 +140,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemTwoMinInStore",
|
keyName = "itemTwoMinInStore",
|
||||||
name = "Min in store",
|
name = "Min in store",
|
||||||
description = "Amount to keep in store to prevent overpaying",
|
description = "Amount to keep in store to prevent overpaying",
|
||||||
|
section = "itemTwo",
|
||||||
position = 24
|
position = 24
|
||||||
)
|
)
|
||||||
default int itemTwoMinInStore() {
|
default int itemTwoMinInStore() {
|
||||||
@ -152,6 +160,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemThreeEnabled",
|
keyName = "itemThreeEnabled",
|
||||||
name = "Enable",
|
name = "Enable",
|
||||||
description = "Enable the buying of this item",
|
description = "Enable the buying of this item",
|
||||||
|
section = "itemThree",
|
||||||
position = 31
|
position = 31
|
||||||
)
|
)
|
||||||
default boolean itemThreeEnabled() {
|
default boolean itemThreeEnabled() {
|
||||||
@ -159,19 +168,21 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemThreeName",
|
keyName = "itemThreeId",
|
||||||
name = "Name",
|
name = "ID",
|
||||||
description = "Name of the item",
|
description = "ID of the item",
|
||||||
|
section = "itemThree",
|
||||||
position = 32
|
position = 32
|
||||||
)
|
)
|
||||||
default String itemThreeName() {
|
default int itemThreeId() {
|
||||||
return "";
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemThreeAmount",
|
keyName = "itemThreeAmount",
|
||||||
name = "Amount",
|
name = "Amount",
|
||||||
description = "Amount of the item to buy",
|
description = "Amount of the item to buy",
|
||||||
|
section = "itemThree",
|
||||||
position = 33
|
position = 33
|
||||||
)
|
)
|
||||||
default int itemThreeAmount() {
|
default int itemThreeAmount() {
|
||||||
@ -182,6 +193,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemThreeMinInStore",
|
keyName = "itemThreeMinInStore",
|
||||||
name = "Min in store",
|
name = "Min in store",
|
||||||
description = "Amount to keep in store to prevent overpaying",
|
description = "Amount to keep in store to prevent overpaying",
|
||||||
|
section = "itemThree",
|
||||||
position = 34
|
position = 34
|
||||||
)
|
)
|
||||||
default int itemThreeMinInStore() {
|
default int itemThreeMinInStore() {
|
||||||
@ -201,6 +213,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemFourEnabled",
|
keyName = "itemFourEnabled",
|
||||||
name = "Enable",
|
name = "Enable",
|
||||||
description = "Enable the buying of this item",
|
description = "Enable the buying of this item",
|
||||||
|
section = "itemFour",
|
||||||
position = 41
|
position = 41
|
||||||
)
|
)
|
||||||
default boolean itemFourEnabled() {
|
default boolean itemFourEnabled() {
|
||||||
@ -208,19 +221,21 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemFourName",
|
keyName = "itemFourId",
|
||||||
name = "Name",
|
name = "ID",
|
||||||
description = "Name of the item",
|
description = "ID of the item",
|
||||||
|
section = "itemFour",
|
||||||
position = 42
|
position = 42
|
||||||
)
|
)
|
||||||
default String itemFourName() {
|
default int itemFourId() {
|
||||||
return "";
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemFourAmount",
|
keyName = "itemFourAmount",
|
||||||
name = "Amount",
|
name = "Amount",
|
||||||
description = "Amount of the item to buy",
|
description = "Amount of the item to buy",
|
||||||
|
section = "itemFour",
|
||||||
position = 43
|
position = 43
|
||||||
)
|
)
|
||||||
default int itemFourAmount() {
|
default int itemFourAmount() {
|
||||||
@ -231,6 +246,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemFourMinInStore",
|
keyName = "itemFourMinInStore",
|
||||||
name = "Min in store",
|
name = "Min in store",
|
||||||
description = "Amount to keep in store to prevent overpaying",
|
description = "Amount to keep in store to prevent overpaying",
|
||||||
|
section = "itemFour",
|
||||||
position = 44
|
position = 44
|
||||||
)
|
)
|
||||||
default int itemFourMinInStore() {
|
default int itemFourMinInStore() {
|
||||||
@ -250,6 +266,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemFiveEnabled",
|
keyName = "itemFiveEnabled",
|
||||||
name = "Enable",
|
name = "Enable",
|
||||||
description = "Enable the buying of this item",
|
description = "Enable the buying of this item",
|
||||||
|
section = "itemFive",
|
||||||
position = 51
|
position = 51
|
||||||
)
|
)
|
||||||
default boolean itemFiveEnabled() {
|
default boolean itemFiveEnabled() {
|
||||||
@ -257,19 +274,21 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemFiveName",
|
keyName = "itemFiveId",
|
||||||
name = "Name",
|
name = "ID",
|
||||||
description = "Name of the item",
|
description = "ID of the item",
|
||||||
|
section = "itemFive",
|
||||||
position = 52
|
position = 52
|
||||||
)
|
)
|
||||||
default String itemFiveName() {
|
default int itemFiveId() {
|
||||||
return "";
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
keyName = "itemFiveAmount",
|
keyName = "itemFiveAmount",
|
||||||
name = "Amount",
|
name = "Amount",
|
||||||
description = "Amount of the item to buy",
|
description = "Amount of the item to buy",
|
||||||
|
section = "itemFive",
|
||||||
position = 53
|
position = 53
|
||||||
)
|
)
|
||||||
default int itemFiveAmount() {
|
default int itemFiveAmount() {
|
||||||
@ -280,6 +299,7 @@ public interface Config extends net.runelite.client.config.Config {
|
|||||||
keyName = "itemFiveMinInStore",
|
keyName = "itemFiveMinInStore",
|
||||||
name = "Min in store",
|
name = "Min in store",
|
||||||
description = "Amount to keep in store to prevent overpaying",
|
description = "Amount to keep in store to prevent overpaying",
|
||||||
|
section = "itemFive",
|
||||||
position = 54
|
position = 54
|
||||||
)
|
)
|
||||||
default int itemFiveMinInStore() {
|
default int itemFiveMinInStore() {
|
||||||
|
@ -2,15 +2,15 @@ package io.reisub.openosrs.shopper;
|
|||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
public class Item {
|
public class Item {
|
||||||
@Getter
|
private final int id;
|
||||||
private final String name;
|
private final int amountToBuy;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final int amount;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final int minInShop;
|
private final int minInShop;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private int amountBought;
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,22 @@
|
|||||||
package io.reisub.openosrs.shopper;
|
package io.reisub.openosrs.shopper;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
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.Util;
|
||||||
|
import io.reisub.openosrs.util.tasks.Run;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.events.ConfigButtonClicked;
|
import net.runelite.api.events.GameTick;
|
||||||
import net.runelite.api.mixins.Inject;
|
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@ -28,12 +29,10 @@ import java.util.List;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Shopper extends iScript {
|
public class Shopper extends CScript {
|
||||||
@Inject
|
@Inject
|
||||||
private Config config;
|
private Config config;
|
||||||
|
|
||||||
private List<Task> tasks;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private List<Item> items;
|
private List<Item> items;
|
||||||
|
|
||||||
@ -41,69 +40,61 @@ public class Shopper extends iScript {
|
|||||||
@Setter
|
@Setter
|
||||||
private boolean hop;
|
private boolean hop;
|
||||||
|
|
||||||
|
private Hop hopTask;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
Config provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(Config.class);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Shopper");
|
super.onStart();
|
||||||
|
|
||||||
loadItems();
|
loadItems();
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
Run runTask = injector.getInstance(Run.class);
|
||||||
}
|
runTask.setInterval(70, 95);
|
||||||
|
|
||||||
@Override
|
hopTask = injector.getInstance(Hop.class);
|
||||||
protected void onStop() {
|
|
||||||
log.info("Stopping Chaos Shopper");
|
tasks.add(hopTask);
|
||||||
if (tasks != null) {
|
tasks.add(runTask);
|
||||||
tasks.clear();
|
addTask(Buy.class);
|
||||||
}
|
addTask(HandleBank.class);
|
||||||
|
addTask(CloseShop.class);
|
||||||
|
addTask(OpenShop.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@SuppressWarnings("unused")
|
private void onGameTick(GameTick event) {
|
||||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
if (!isLoggedIn()) return;
|
||||||
if (configButtonClicked.getKey().equals("startButton")) {
|
|
||||||
execute();
|
if (hopTask != null) hopTask.onGameTick();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadItems() {
|
private void loadItems() {
|
||||||
|
items = new ArrayList<>();
|
||||||
|
|
||||||
if (config.itemOneEnabled()) {
|
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()) {
|
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()) {
|
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()) {
|
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()) {
|
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;
|
package io.reisub.openosrs.shopper.tasks;
|
||||||
|
|
||||||
|
import io.reisub.openosrs.shopper.Item;
|
||||||
import io.reisub.openosrs.shopper.Shopper;
|
import io.reisub.openosrs.shopper.Shopper;
|
||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.api.mixins.Inject;
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
|
||||||
import net.runelite.client.plugins.iutils.game.iWidget;
|
import net.runelite.client.plugins.iutils.game.iWidget;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class Buy extends Task {
|
public class Buy extends Task {
|
||||||
@Inject
|
@Inject
|
||||||
private Shopper plugin;
|
private Shopper plugin;
|
||||||
@ -15,17 +17,57 @@ public class Buy extends Task {
|
|||||||
return "Buying";
|
return "Buying";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int currentItemId;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean validate() {
|
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
|
currentItemId = -1;
|
||||||
&& !shop.hidden()
|
|
||||||
|
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();
|
&& !game.inventory().full();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
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.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
|
||||||
@ConfigGroup("ChaosSmelterConfig")
|
@ConfigGroup("chaossmelter")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
public interface Config extends net.runelite.client.config.Config {
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
|
@ -1,11 +1,9 @@
|
|||||||
package io.reisub.openosrs.smelter;
|
package io.reisub.openosrs.smelter;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.Value;
|
||||||
import lombok.Getter;
|
|
||||||
|
|
||||||
@AllArgsConstructor
|
@Value
|
||||||
@Getter
|
|
||||||
public class Ingredient {
|
public class Ingredient {
|
||||||
private final int id;
|
int id;
|
||||||
private final int amount;
|
int amount;
|
||||||
}
|
}
|
||||||
|
@ -5,14 +5,17 @@ import net.runelite.api.ItemID;
|
|||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum Product {
|
public enum Product {
|
||||||
MOLTEN_GLASS(ItemID.MOLTEN_GLASS, new Ingredient(ItemID.SODA_ASH, 14), new Ingredient(ItemID.BUCKET_OF_SAND, 14)),
|
STEEL_BAR(ItemID.STEEL_BAR, 4, new Ingredient(ItemID.IRON_ORE, 9), new Ingredient(ItemID.COAL, 28)),
|
||||||
CANNONBALLS(ItemID.CANNONBALL, new Ingredient(ItemID.STEEL_BAR, 27));
|
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 id;
|
||||||
|
private final int index;
|
||||||
private final Ingredient[] ingredients;
|
private final Ingredient[] ingredients;
|
||||||
|
|
||||||
Product(int id, Ingredient... ingredients) {
|
Product(int id, int index, Ingredient... ingredients) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
|
this.index = index;
|
||||||
this.ingredients = ingredients;
|
this.ingredients = ingredients;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,37 +1,23 @@
|
|||||||
package io.reisub.openosrs.smelter;
|
package io.reisub.openosrs.smelter;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
import io.reisub.openosrs.smelter.tasks.HandleBank;
|
import io.reisub.openosrs.smelter.tasks.HandleBank;
|
||||||
import io.reisub.openosrs.smelter.tasks.Smelt;
|
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.Util;
|
||||||
import io.reisub.openosrs.util.tasks.Eat;
|
import io.reisub.openosrs.util.enums.Activity;
|
||||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
|
||||||
import io.reisub.openosrs.util.tasks.Run;
|
import io.reisub.openosrs.util.tasks.Run;
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.AnimationID;
|
import net.runelite.api.AnimationID;
|
||||||
import net.runelite.api.ChatMessageType;
|
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
import net.runelite.api.events.AnimationChanged;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
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
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@PluginDependency(iUtils.class)
|
@PluginDependency(iUtils.class)
|
||||||
@ -41,64 +27,22 @@ import static net.runelite.api.AnimationID.IDLE;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Smelter extends iScript {
|
public class Smelter extends CScript {
|
||||||
private List<Task> tasks;
|
|
||||||
private KittenTask kittenTask;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private Activity currentActivity;
|
|
||||||
|
|
||||||
private Instant lastActionTime;
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
Config provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(Config.class);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Smelter");
|
super.onStart();
|
||||||
|
|
||||||
Eat eatTask = injector.getInstance(Eat.class);
|
|
||||||
eatTask.setInterval(14, 24);
|
|
||||||
|
|
||||||
Run runTask = injector.getInstance(Run.class);
|
Run runTask = injector.getInstance(Run.class);
|
||||||
runTask.setInterval(70, 95);
|
runTask.setInterval(70, 95);
|
||||||
|
|
||||||
kittenTask = KittenTask.getInstance(injector);
|
|
||||||
|
|
||||||
currentActivity = Activity.IDLE;
|
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
|
||||||
tasks.add(eatTask);
|
|
||||||
tasks.add(runTask);
|
tasks.add(runTask);
|
||||||
tasks.add(kittenTask);
|
addTask(HandleBank.class);
|
||||||
tasks.add(injector.getInstance(HandleBank.class));
|
addTask(Smelt.class);
|
||||||
tasks.add(injector.getInstance(Smelt.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop() {
|
|
||||||
log.info("Stopping Chaos Smelter");
|
|
||||||
if (tasks != null) {
|
|
||||||
tasks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
KittenTask.handleKitten = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -116,46 +60,4 @@ public class Smelter extends iScript {
|
|||||||
break;
|
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;
|
package io.reisub.openosrs.smelter.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.smelter.Activity;
|
|
||||||
import io.reisub.openosrs.smelter.Config;
|
import io.reisub.openosrs.smelter.Config;
|
||||||
import io.reisub.openosrs.smelter.Ingredient;
|
import io.reisub.openosrs.smelter.Ingredient;
|
||||||
import io.reisub.openosrs.smelter.Smelter;
|
import io.reisub.openosrs.smelter.Smelter;
|
||||||
import io.reisub.openosrs.util.Task;
|
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.game.iObject;
|
||||||
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
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);
|
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.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
|
|
||||||
@ConfigGroup("ChaosTemporossConfig")
|
@ConfigGroup("chaostempoross")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
public interface Config extends net.runelite.client.config.Config {
|
||||||
@ConfigItem(
|
@ConfigItem(
|
||||||
|
@ -2,7 +2,6 @@ package io.reisub.openosrs.tempoross;
|
|||||||
|
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.google.inject.Provides;
|
import com.google.inject.Provides;
|
||||||
|
|
||||||
import io.reisub.openosrs.tempoross.tasks.*;
|
import io.reisub.openosrs.tempoross.tasks.*;
|
||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
import io.reisub.openosrs.util.Util;
|
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.tempoross.Tempoross;
|
||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
import net.runelite.api.ItemID;
|
import net.runelite.api.ItemID;
|
||||||
import net.runelite.api.ObjectID;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
@ -24,14 +24,34 @@
|
|||||||
*/
|
*/
|
||||||
package io.reisub.openosrs.test;
|
package io.reisub.openosrs.test;
|
||||||
|
|
||||||
import net.runelite.client.config.Button;
|
import net.runelite.client.config.*;
|
||||||
import net.runelite.client.config.Config;
|
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import java.awt.event.InputEvent;
|
||||||
import net.runelite.client.config.ConfigItem;
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
@ConfigGroup("ChaosTestConfig")
|
@ConfigGroup("ChaosTestConfig")
|
||||||
|
|
||||||
public interface TestConfig extends Config {
|
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(
|
@ConfigItem(
|
||||||
keyName = "startButton",
|
keyName = "startButton",
|
||||||
name = "Start/Stop",
|
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.Task;
|
||||||
import io.reisub.openosrs.util.Util;
|
import io.reisub.openosrs.util.Util;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.events.*;
|
||||||
|
import net.runelite.api.widgets.Widget;
|
||||||
import net.runelite.api.widgets.WidgetInfo;
|
import net.runelite.api.widgets.WidgetInfo;
|
||||||
|
import net.runelite.api.widgets.WidgetItem;
|
||||||
import net.runelite.client.config.ConfigManager;
|
import net.runelite.client.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
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.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
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.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||||
|
import org.apache.commons.lang3.tuple.Pair;
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Locale;
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@ -28,7 +41,13 @@ import java.util.List;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@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;
|
private List<Task> tasks;
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
@ -53,8 +72,7 @@ public class TestPlugin extends iScript {
|
|||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Test");
|
log.info("Starting Chaos Test");
|
||||||
|
|
||||||
log.info("selected itemt slot: " + game.client.getSelectedItemSlot());
|
keyManager.registerKeyListener(this);
|
||||||
log.info("is item selected: " + game.client().isItemSelected());
|
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
tasks = new ArrayList<>();
|
||||||
tasks.add(injector.getInstance(Test.class));
|
tasks.add(injector.getInstance(Test.class));
|
||||||
@ -66,6 +84,13 @@ public class TestPlugin extends iScript {
|
|||||||
if (tasks != null) {
|
if (tasks != null) {
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keyManager.unregisterKeyListener(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Subscribe
|
||||||
|
private void onGameTick(GameTick event) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
@ -85,6 +110,17 @@ public class TestPlugin extends iScript {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onAnimationChanged(AnimationChanged event) {
|
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) {
|
// if (event.getActor() != null) {
|
||||||
// log.info("actor: " + event.getActor().getName());
|
// log.info("actor: " + event.getActor().getName());
|
||||||
// log.info("id: " + event.getActor().getAnimation());
|
// log.info("id: " + event.getActor().getAnimation());
|
||||||
@ -103,5 +139,24 @@ public class TestPlugin extends iScript {
|
|||||||
private void onHitsplatApplied(HitsplatApplied event) {
|
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;
|
package io.reisub.openosrs.test.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
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;
|
import net.runelite.client.plugins.iutils.ui.Chatbox;
|
||||||
|
|
||||||
public class Test extends Task {
|
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.enums.Activity;
|
||||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
import io.reisub.openosrs.util.tasks.KittenTask;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.runelite.api.ChatMessageType;
|
import net.runelite.api.ChatMessageType;
|
||||||
import net.runelite.api.GameState;
|
import net.runelite.api.GameState;
|
||||||
|
import net.runelite.api.InventoryID;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
import net.runelite.api.events.ChatMessage;
|
import net.runelite.api.events.*;
|
||||||
import net.runelite.api.events.ConfigButtonClicked;
|
|
||||||
import net.runelite.api.events.GameStateChanged;
|
|
||||||
import net.runelite.api.events.StatChanged;
|
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
import net.runelite.client.eventbus.Subscribe;
|
||||||
|
import net.runelite.client.plugins.iutils.game.iPlayer;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
@ -30,12 +30,22 @@ public abstract class CScript extends iScript {
|
|||||||
protected KittenTask kittenTask;
|
protected KittenTask kittenTask;
|
||||||
|
|
||||||
@Getter
|
@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 lastLogin = Instant.EPOCH;
|
||||||
protected Instant lastActionTime = Instant.EPOCH;
|
protected Instant lastActionTime = Instant.EPOCH;
|
||||||
|
protected Duration lastActionTimeout = Duration.ofSeconds(3);
|
||||||
protected Instant lastExperience = Instant.EPOCH;
|
protected Instant lastExperience = Instant.EPOCH;
|
||||||
|
protected Instant lastInventoryChange = Instant.EPOCH;
|
||||||
protected final Map<Skill, Activity> idleCheckSkills = new HashMap<>();
|
protected final Map<Skill, Activity> idleCheckSkills = new HashMap<>();
|
||||||
|
protected boolean idleCheckInventoryChange = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void loop() {
|
protected void loop() {
|
||||||
@ -54,6 +64,10 @@ public abstract class CScript extends iScript {
|
|||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting " + this.getName());
|
log.info("Starting " + this.getName());
|
||||||
|
|
||||||
|
previousActivity = Activity.IDLE;
|
||||||
|
currentActivity = Activity.IDLE;
|
||||||
|
|
||||||
kittenTask = KittenTask.getInstance(injector);
|
kittenTask = KittenTask.getInstance(injector);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,6 +76,9 @@ public abstract class CScript extends iScript {
|
|||||||
log.info("Stopping " + this.getName());
|
log.info("Stopping " + this.getName());
|
||||||
tasks.clear();
|
tasks.clear();
|
||||||
|
|
||||||
|
previousActivity = Activity.IDLE;
|
||||||
|
currentActivity = Activity.IDLE;
|
||||||
|
|
||||||
KittenTask.handleKitten = false;
|
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
|
@Subscribe
|
||||||
@SuppressWarnings("unused")
|
@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;
|
currentActivity = action;
|
||||||
|
|
||||||
if (action != Activity.IDLE) {
|
if (action != Activity.IDLE) {
|
||||||
@ -123,15 +153,16 @@ public abstract class CScript extends iScript {
|
|||||||
protected void checkActionTimeout() {
|
protected void checkActionTimeout() {
|
||||||
if (currentActivity == Activity.IDLE) return;
|
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();
|
int animId = game.localPlayer().animation();
|
||||||
if (animId != IDLE || lastActionTime == null) return;
|
if (animId != IDLE || lastActionTime == null) return;
|
||||||
|
|
||||||
Duration timeout = Duration.ofSeconds(5);
|
|
||||||
Duration sinceAction = Duration.between(lastActionTime, Instant.now());
|
Duration sinceAction = Duration.between(lastActionTime, Instant.now());
|
||||||
|
|
||||||
if (sinceAction.compareTo(timeout) >= 0) {
|
if (sinceAction.compareTo(lastActionTimeout) >= 0) {
|
||||||
setActivity(Activity.IDLE);
|
setActivity(Activity.IDLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -140,7 +171,18 @@ public abstract class CScript extends iScript {
|
|||||||
return game.client() != null && game.client().getGameState() == GameState.LOGGED_IN;
|
return game.client() != null && game.client().getGameState() == GameState.LOGGED_IN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isLoggedInForLongerThan(int seconds) {
|
public final boolean isLoggedInForLongerThan(Duration duration) {
|
||||||
return Duration.between(lastLogin, Instant.now()).getSeconds() >= seconds;
|
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;
|
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 {
|
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 net.runelite.client.plugins.iutils.walking.Walking;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public abstract class Task {
|
public abstract class Task {
|
||||||
|
@ -2,5 +2,18 @@ package io.reisub.openosrs.util.enums;
|
|||||||
|
|
||||||
public enum Activity {
|
public enum Activity {
|
||||||
IDLE,
|
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;
|
package io.reisub.openosrs.util.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
import net.runelite.api.Skill;
|
import net.runelite.api.Skill;
|
||||||
|
|
||||||
public class Eat extends Task {
|
public class Eat extends Task {
|
||||||
private long last = 0;
|
private long last = 0;
|
||||||
|
private int min = 5;
|
||||||
|
private int max = 10;
|
||||||
|
|
||||||
|
@Setter
|
||||||
private boolean wait = true;
|
private boolean wait = true;
|
||||||
|
|
||||||
|
@Getter
|
||||||
private int threshold = 5;
|
private int threshold = 5;
|
||||||
private int mean = 5;
|
|
||||||
private int sigma = 1;
|
|
||||||
|
|
||||||
public void setInterval(int min, int max) {
|
public void setInterval(int min, int max) {
|
||||||
mean = (min + max) / 2;
|
this.min = min;
|
||||||
sigma = mean - min;
|
this.max = max;
|
||||||
|
|
||||||
if (sigma <= 0) threshold = min;
|
|
||||||
|
|
||||||
threshold = getNewThreshold();
|
threshold = getNewThreshold();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWait(boolean wait) {
|
@Override
|
||||||
this.wait = wait;
|
public String getStatus() {
|
||||||
|
return "Eating";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -50,15 +55,6 @@ public class Eat extends Task {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private int getNewThreshold() {
|
private int getNewThreshold() {
|
||||||
if (sigma <= 0) {
|
return calc.random(min, max + 1);
|
||||||
return threshold;
|
|
||||||
}
|
|
||||||
|
|
||||||
return calc.randomGauss(1, 99, sigma, mean, false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getStatus() {
|
|
||||||
return "Eating";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -29,7 +29,7 @@ import net.runelite.client.config.ConfigGroup;
|
|||||||
import net.runelite.client.config.ConfigItem;
|
import net.runelite.client.config.ConfigItem;
|
||||||
import net.runelite.client.config.Range;
|
import net.runelite.client.config.Range;
|
||||||
|
|
||||||
@ConfigGroup("ChaosWintertodtConfig")
|
@ConfigGroup("chaoswintertodt")
|
||||||
|
|
||||||
public interface Config extends net.runelite.client.config.Config {
|
public interface Config extends net.runelite.client.config.Config {
|
||||||
@Range(min = 1, max = 99)
|
@Range(min = 1, max = 99)
|
||||||
|
@ -2,10 +2,10 @@ package io.reisub.openosrs.wintertodt;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import com.google.inject.Provides;
|
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.Util;
|
||||||
|
import io.reisub.openosrs.util.enums.Activity;
|
||||||
import io.reisub.openosrs.util.tasks.Eat;
|
import io.reisub.openosrs.util.tasks.Eat;
|
||||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
|
||||||
import io.reisub.openosrs.wintertodt.tasks.*;
|
import io.reisub.openosrs.wintertodt.tasks.*;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
@ -19,10 +19,8 @@ import net.runelite.client.plugins.PluginDependency;
|
|||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import java.time.Duration;
|
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -42,7 +40,7 @@ import static net.runelite.api.ItemID.BRUMA_ROOT;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class Wintertodt extends iScript {
|
public class Wintertodt extends CScript {
|
||||||
@Inject
|
@Inject
|
||||||
public Config config;
|
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_HEALTH_PACKED_ID = 25952277;
|
||||||
public static final int WINTERTODT_GAME_TIMER_ID = 25952259;
|
public static final int WINTERTODT_GAME_TIMER_ID = 25952259;
|
||||||
|
|
||||||
@Getter
|
|
||||||
private Activity currentActivity = Activity.IDLE;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private Activity previousActivity = Activity.IDLE;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private int respawnTimer;
|
private int respawnTimer;
|
||||||
|
|
||||||
@ -73,12 +65,9 @@ public class Wintertodt extends iScript {
|
|||||||
@Getter
|
@Getter
|
||||||
private final List<WintertodtProjectile> projectiles = new ArrayList<>();
|
private final List<WintertodtProjectile> projectiles = new ArrayList<>();
|
||||||
|
|
||||||
private List<Task> tasks;
|
|
||||||
private KittenTask kittenTask;
|
|
||||||
private Hop hopTask;
|
private Hop hopTask;
|
||||||
private Scouter scouter;
|
private Scouter scouter;
|
||||||
private int fmLevel, wcLevel, fletchLevel;
|
private int fmLevel, wcLevel, fletchLevel;
|
||||||
private Instant lastActionTime;
|
|
||||||
private int previousTimerValue;
|
private int previousTimerValue;
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@ -87,22 +76,9 @@ public class Wintertodt extends iScript {
|
|||||||
return configManager.getConfig(Config.class);
|
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
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Wintertodt");
|
super.onStart();
|
||||||
|
|
||||||
fmLevel = game.baseLevel(Skill.FIREMAKING);
|
fmLevel = game.baseLevel(Skill.FIREMAKING);
|
||||||
wcLevel = game.baseLevel(Skill.WOODCUTTING);
|
wcLevel = game.baseLevel(Skill.WOODCUTTING);
|
||||||
@ -113,52 +89,36 @@ public class Wintertodt extends iScript {
|
|||||||
Eat eatTask = injector.getInstance(Eat.class);
|
Eat eatTask = injector.getInstance(Eat.class);
|
||||||
eatTask.setInterval(config.minEatHP(), config.maxEatHP());
|
eatTask.setInterval(config.minEatHP(), config.maxEatHP());
|
||||||
|
|
||||||
kittenTask = KittenTask.getInstance(injector);
|
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
|
||||||
tasks.add(eatTask);
|
tasks.add(eatTask);
|
||||||
tasks.add(kittenTask);
|
tasks.add(kittenTask);
|
||||||
if (config.dodgeProjectiles()) {
|
if (config.dodgeProjectiles()) {
|
||||||
tasks.add(injector.getInstance(DodgeProjectile.class));
|
addTask(DodgeProjectile.class);
|
||||||
}
|
}
|
||||||
tasks.add(injector.getInstance(OpenInventory.class));
|
addTask(OpenInventory.class);
|
||||||
tasks.add(injector.getInstance(EatWhileWaiting.class));
|
addTask(EatWhileWaiting.class);
|
||||||
tasks.add(injector.getInstance(OpenCrates.class));
|
addTask(OpenCrates.class);
|
||||||
tasks.add(injector.getInstance(GoToBank.class));
|
addTask(GoToBank.class);
|
||||||
tasks.add(injector.getInstance(HandleBank.class));
|
addTask(HandleBank.class);
|
||||||
tasks.add(injector.getInstance(GoToWintertodt.class));
|
addTask(GoToWintertodt.class);
|
||||||
if (config.hop()) {
|
if (config.hop()) {
|
||||||
hopTask = injector.getInstance(Hop.class);
|
hopTask = injector.getInstance(Hop.class);
|
||||||
tasks.add(hopTask);
|
tasks.add(hopTask);
|
||||||
}
|
}
|
||||||
tasks.add(injector.getInstance(MoveToBrazier.class));
|
addTask(MoveToBrazier.class);
|
||||||
tasks.add(injector.getInstance(Fix.class));
|
addTask(Fix.class);
|
||||||
tasks.add(injector.getInstance(Light.class));
|
addTask(Light.class);
|
||||||
tasks.add(injector.getInstance(Fletch.class));
|
addTask(Fletch.class);
|
||||||
tasks.add(injector.getInstance(ChangeSide.class));
|
addTask(ChangeSide.class);
|
||||||
tasks.add(injector.getInstance(Burn.class));
|
addTask(Burn.class);
|
||||||
tasks.add(injector.getInstance(Chop.class));
|
addTask(Chop.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop() {
|
||||||
log.info("Stopping Chaos Wintertodt");
|
super.onStop();
|
||||||
if (tasks != null) {
|
|
||||||
tasks.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
KittenTask.handleKitten = false;
|
|
||||||
scouter = null;
|
scouter = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
|
||||||
@Subscribe
|
|
||||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
|
||||||
if (configButtonClicked.getKey().equals("startButton")) {
|
|
||||||
execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onStatChanged(StatChanged event) {
|
private void onStatChanged(StatChanged event) {
|
||||||
@ -203,10 +163,6 @@ public class Wintertodt extends iScript {
|
|||||||
@SuppressWarnings("unused")
|
@SuppressWarnings("unused")
|
||||||
@Subscribe
|
@Subscribe
|
||||||
private void onChatMessage(ChatMessage chatMessage) {
|
private void onChatMessage(ChatMessage chatMessage) {
|
||||||
if (kittenTask != null) {
|
|
||||||
kittenTask.onChatMessage(chatMessage);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!isInWintertodtRegion()) return;
|
if (!isInWintertodtRegion()) return;
|
||||||
|
|
||||||
ChatMessageType chatMessageType = chatMessage.getType();
|
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() {
|
private void parseBossHealth() {
|
||||||
Widget healthWidget = game.client.getWidget(WINTERTODT_HEALTH_PACKED_ID);
|
Widget healthWidget = game.client.getWidget(WINTERTODT_HEALTH_PACKED_ID);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.reisub.openosrs.wintertodt.tasks;
|
package io.reisub.openosrs.wintertodt.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
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.Side;
|
||||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.reisub.openosrs.wintertodt.tasks;
|
package io.reisub.openosrs.wintertodt.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
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.Config;
|
||||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.reisub.openosrs.wintertodt.tasks;
|
package io.reisub.openosrs.wintertodt.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
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 io.reisub.openosrs.wintertodt.Wintertodt;
|
||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.reisub.openosrs.wintertodt.tasks;
|
package io.reisub.openosrs.wintertodt.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
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 io.reisub.openosrs.wintertodt.Wintertodt;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.reisub.openosrs.wintertodt.tasks;
|
package io.reisub.openosrs.wintertodt.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
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.Config;
|
||||||
import io.reisub.openosrs.wintertodt.Wintertodt;
|
import io.reisub.openosrs.wintertodt.Wintertodt;
|
||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package io.reisub.openosrs.wintertodt.tasks;
|
package io.reisub.openosrs.wintertodt.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
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 io.reisub.openosrs.wintertodt.Wintertodt;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
@ -2,7 +2,7 @@ package io.reisub.openosrs.wintertodt.tasks;
|
|||||||
|
|
||||||
import com.google.inject.Inject;
|
import com.google.inject.Inject;
|
||||||
import io.reisub.openosrs.util.Task;
|
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 io.reisub.openosrs.wintertodt.Wintertodt;
|
||||||
import net.runelite.client.plugins.iutils.scene.Position;
|
import net.runelite.client.plugins.iutils.scene.Position;
|
||||||
|
|
||||||
|
@ -25,13 +25,12 @@
|
|||||||
package io.reisub.openosrs.woodcutter;
|
package io.reisub.openosrs.woodcutter;
|
||||||
|
|
||||||
import net.runelite.client.config.Button;
|
import net.runelite.client.config.Button;
|
||||||
import net.runelite.client.config.Config;
|
|
||||||
import net.runelite.client.config.ConfigGroup;
|
import net.runelite.client.config.ConfigGroup;
|
||||||
import net.runelite.client.config.ConfigItem;
|
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(
|
@ConfigItem(
|
||||||
keyName = "burnLogs",
|
keyName = "burnLogs",
|
||||||
name = "Burn logs",
|
name = "Burn logs",
|
||||||
|
@ -1,25 +1,17 @@
|
|||||||
package io.reisub.openosrs.woodcutter;
|
package io.reisub.openosrs.woodcutter;
|
||||||
|
|
||||||
import com.google.inject.Provides;
|
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.Util;
|
||||||
import io.reisub.openosrs.woodcutter.tasks.Chop;
|
import io.reisub.openosrs.woodcutter.tasks.Chop;
|
||||||
import io.reisub.openosrs.woodcutter.tasks.Drop;
|
import io.reisub.openosrs.woodcutter.tasks.Drop;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
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.config.ConfigManager;
|
||||||
import net.runelite.client.eventbus.Subscribe;
|
|
||||||
import net.runelite.client.plugins.PluginDependency;
|
import net.runelite.client.plugins.PluginDependency;
|
||||||
import net.runelite.client.plugins.PluginDescriptor;
|
import net.runelite.client.plugins.PluginDescriptor;
|
||||||
import net.runelite.client.plugins.iutils.iUtils;
|
import net.runelite.client.plugins.iutils.iUtils;
|
||||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
|
||||||
import org.pf4j.Extension;
|
import org.pf4j.Extension;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
@Extension
|
@Extension
|
||||||
@PluginDependency(Util.class)
|
@PluginDependency(Util.class)
|
||||||
@PluginDependency(iUtils.class)
|
@PluginDependency(iUtils.class)
|
||||||
@ -29,47 +21,17 @@ import java.util.List;
|
|||||||
enabledByDefault = false
|
enabledByDefault = false
|
||||||
)
|
)
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class WoodcutterPlugin extends iScript {
|
public class Woodcutter extends CScript {
|
||||||
@Inject
|
|
||||||
private Client client;
|
|
||||||
|
|
||||||
private List<Task> tasks;
|
|
||||||
|
|
||||||
@Provides
|
@Provides
|
||||||
WoodcutterConfig provideConfig(ConfigManager configManager) {
|
Config provideConfig(ConfigManager configManager) {
|
||||||
return configManager.getConfig(WoodcutterConfig.class);
|
return configManager.getConfig(Config.class);
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void loop() {
|
|
||||||
for (Task t : tasks) {
|
|
||||||
if (t.validate()) {
|
|
||||||
t.execute();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
game.tickDelay();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart() {
|
||||||
log.info("Starting Chaos Woodcutter");
|
super.onStart();
|
||||||
|
|
||||||
tasks = new ArrayList<>();
|
addTask(Chop.class);
|
||||||
tasks.add(injector.getInstance(Chop.class));
|
addTask(Drop.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();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package io.reisub.openosrs.woodcutter.tasks;
|
package io.reisub.openosrs.woodcutter.tasks;
|
||||||
|
|
||||||
import io.reisub.openosrs.util.Task;
|
import io.reisub.openosrs.util.Task;
|
||||||
import io.reisub.openosrs.woodcutter.WoodcutterConfig;
|
import io.reisub.openosrs.woodcutter.Config;
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
public class Drop extends Task {
|
public class Drop extends Task {
|
||||||
@Inject
|
@Inject
|
||||||
private WoodcutterConfig config;
|
private Config config;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getStatus() {
|
public String getStatus() {
|
||||||
|
@ -23,10 +23,10 @@
|
|||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
* 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["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 {
|
dependencies {
|
||||||
compileOnly(project(":util"))
|
compileOnly(project(":util"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user