Initial commit

This commit is contained in:
2022-01-08 19:46:18 +01:00
commit 57ba5a5858
207 changed files with 12402 additions and 0 deletions

View File

@ -0,0 +1,52 @@
/*
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
version = "0.0.1"
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
dependencies {
compileOnly(project(":util"))
}
tasks {
jar {
manifest {
attributes(mapOf(
"Plugin-Version" to project.version,
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
"Plugin-Provider" to project.extra["PluginProvider"],
"Plugin-Description" to project.extra["PluginDescription"],
"Plugin-Dependencies" to
arrayOf(
nameToId("Chaos Util"),
nameToId("iUtils")
).joinToString(),
"Plugin-License" to project.extra["PluginLicense"]
))
}
}
}

View File

@ -0,0 +1,70 @@
/*
* Copyright (c) 2018, Andrew EP | ElPinche256 <https://github.com/ElPinche256>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this
* list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package io.reisub.openosrs.agility;
import net.runelite.client.config.Button;
import net.runelite.client.config.Config;
import net.runelite.client.config.ConfigGroup;
import net.runelite.client.config.ConfigItem;
@ConfigGroup("ChaosAgilityConfig")
public interface AgilityConfig extends Config {
@ConfigItem(
position = 0,
keyName = "courseSelection",
name = "Select course",
description = "Select a course to run."
)
default Course courseSelection()
{
return Course.SEERS_VILLAGE;
}
@ConfigItem(
position = 10,
keyName = "highAlch",
name = "High alch",
description = "Enable to high alch between obstacles."
)
default boolean highAlch() { return false; }
@ConfigItem(
position = 11,
keyName = "alchItems",
name = "High alch items",
description = "Names of items to alch, multiple items separated with a comma"
)
default String alchItems() { return ""; }
@ConfigItem(
keyName = "startButton",
name = "Start/Stop",
description = "Start the script",
position = 100
)
default Button startButton() {
return new Button();
}
}

View File

@ -0,0 +1,159 @@
package io.reisub.openosrs.agility;
import com.google.inject.Provides;
import io.reisub.openosrs.agility.tasks.Alch;
import io.reisub.openosrs.agility.tasks.HandleObstacle;
import io.reisub.openosrs.agility.tasks.PickupMark;
import io.reisub.openosrs.util.Task;
import io.reisub.openosrs.util.Util;
import io.reisub.openosrs.util.tasks.Eat;
import io.reisub.openosrs.util.tasks.KittenTask;
import io.reisub.openosrs.util.tasks.Run;
import lombok.extern.slf4j.Slf4j;
import net.runelite.api.events.*;
import net.runelite.client.config.ConfigManager;
import net.runelite.client.eventbus.Subscribe;
import net.runelite.client.plugins.PluginDependency;
import net.runelite.client.plugins.PluginDescriptor;
import net.runelite.client.plugins.iutils.iUtils;
import net.runelite.client.plugins.iutils.scripts.iScript;
import org.pf4j.Extension;
import javax.inject.Inject;
import java.util.ArrayList;
import java.util.List;
@Extension
@PluginDependency(Util.class)
@PluginDependency(iUtils.class)
@PluginDescriptor(
name = "Chaos Agility",
description = "Hippity hoppity, jumps on your property",
enabledByDefault = false
)
@Slf4j
public class AgilityPlugin extends iScript {
@Inject
private AgilityConfig config;
private List<Task> tasks;
private KittenTask kittenTask;
private Alch alchTask;
private HandleObstacle handleObstacleTask;
private PickupMark pickupMarkTask;
@Provides
AgilityConfig provideConfig(ConfigManager configManager) {
return configManager.getConfig(AgilityConfig.class);
}
@Override
protected void loop() {
for (Task t : tasks) {
if (t.validate()) {
log.info(t.getStatus());
t.execute();
break;
}
}
game.sleepDelay();
}
@Override
protected void onStart() {
log.info("Starting Chaos Agility");
Eat eatTask = injector.getInstance(Eat.class);
eatTask.setInterval(14, 24);
Run runTask = injector.getInstance(Run.class);
runTask.setInterval(70, 95);
kittenTask = KittenTask.getInstance(injector);
handleObstacleTask = injector.getInstance(HandleObstacle.class);
pickupMarkTask = injector.getInstance(PickupMark.class);
if (config.highAlch()) {
alchTask = injector.getInstance(Alch.class);
}
tasks = new ArrayList<>();
tasks.add(eatTask);
tasks.add(runTask);
tasks.add(kittenTask);
tasks.add(pickupMarkTask);
if (config.highAlch()) {
tasks.add(alchTask);
}
tasks.add(handleObstacleTask);
handleObstacleTask.setReady(true);
}
@Override
protected void onStop() {
log.info("Stopping Chaos Agility");
if (tasks != null) {
tasks.clear();
}
KittenTask.handleKitten = false;
}
@Subscribe
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
if (configButtonClicked.getKey().equals("startButton")) {
execute();
}
}
@Subscribe
private void onHitsplatApplied(HitsplatApplied event) {
if (handleObstacleTask != null) {
handleObstacleTask.onHitsplatApplied(event);
}
if (pickupMarkTask != null) {
pickupMarkTask.onHitsplatApplied(event);
}
}
@Subscribe
private void onStatChanged(StatChanged event) {
if (handleObstacleTask != null) {
handleObstacleTask.onStatChanged(event);
}
if (pickupMarkTask != null) {
pickupMarkTask.onStatChanged(event);
}
if (alchTask != null) {
alchTask.onStatChanged(event);
}
}
@Subscribe
private void onGameTick(GameTick event) {
if (handleObstacleTask != null) {
handleObstacleTask.onGameTick(event);
}
if (alchTask != null) {
alchTask.onGameTick(event);
}
}
@Subscribe
private void onChatMessage(ChatMessage chatMessage) {
if (kittenTask != null) {
kittenTask.onChatMessage(chatMessage);
}
if (handleObstacleTask != null) {
handleObstacleTask.onChatMessage(chatMessage);
}
}
}

View File

@ -0,0 +1,71 @@
package io.reisub.openosrs.agility;
import net.runelite.client.plugins.iutils.scene.Position;
public enum Course {
SEERS_VILLAGE(
new ObstacleArea(2704,2733,3456,3495,0,14927),
new ObstacleArea(2721,2730,3490,3497,3,14928),
new ObstacleArea(2704,2714,3487,3497,2,14932),
new ObstacleArea(2709,2716,3476,3482,2,14929),
new ObstacleArea(2700,2715,3470,3475,3,14930),
new ObstacleArea(2690,2703,3459,3466,2,14931)
),
POLLNIVNEACH(
new ObstacleArea(3345,3375,2957,3003,0,14935),
new ObstacleArea(3346,3351,2963,2968,1,14936),
new ObstacleArea(3352,3355,2973,2976,1,14937),
new ObstacleArea(3360,3362,2977,2979,1,14938),
new ObstacleArea(3366,3370,2974,2976,1,14939),
new ObstacleArea(3365,3369,2982,2986,1,14940),
new ObstacleArea(3355,3365,2980,2985,2,14941),
new ObstacleArea(3357,3370,2990,2995,2,14944),
new ObstacleArea(3356,3364,3000,3004,2,14945)
),
RELEKKA(
new ObstacleArea(2622,2653,3656,3682,0,14946),
new ObstacleArea(2622,2626,3672,3676,3,14947),
new ObstacleArea(2615,2622,3658,3668,3,14987),
new ObstacleArea(2626,2630,3651,3655,3,14990),
new ObstacleArea(2639,2644,3649,3653,3,14991),
new ObstacleArea(2643,2650,3657,3662,3,14992),
new ObstacleArea(2655,2666,3665,3685,3,14994)
),
ARDOUGNE(
new ObstacleArea(2650,2674,3293,3319,0,15608),
new ObstacleArea(2671,2671,3299,3309,3,15609),
new ObstacleArea(2662,2665,3318,3318,3,26635),
new ObstacleArea(2654,2657,3318,3318,3,15610),
new ObstacleArea(2653,2653,3310,3314,3,15611),
new ObstacleArea(2651,2653,3300,3309,3,28912),
new ObstacleArea(2656,2656,3297,3297,3,15612)
);
private final ObstacleArea[] areas;
Course(ObstacleArea... area) {
areas = area;
}
public int getNextObstacleID(Position current) {
for (ObstacleArea area : areas) {
if (area.contains(current)) {
return area.getId();
}
}
return 0;
}
public boolean markIsReachable(Position player, Position mark) {
if (player == null || mark == null) return false;
for (ObstacleArea area : areas) {
if (area.contains(player) && area.contains(mark)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,32 @@
package io.reisub.openosrs.agility;
import lombok.Getter;
import net.runelite.client.plugins.iutils.scene.Position;
public class ObstacleArea {
private final int minX;
private final int maxX;
private final int minY;
private final int maxY;
private final int z;
@Getter
private final int id;
public ObstacleArea(int minX, int maxX, int minY, int maxY, int z, int id) {
this.minX = minX;
this.maxX = maxX;
this.minY = minY;
this.maxY = maxY;
this.z = z;
this.id = id;
}
public boolean contains(Position position) {
return position.x >= minX
&& position.x <= maxX
&& position.y >= minY
&& position.y <= maxY
&& position.z == z;
}
}

View File

@ -0,0 +1,70 @@
package io.reisub.openosrs.agility.tasks;
import io.reisub.openosrs.agility.AgilityConfig;
import io.reisub.openosrs.util.Task;
import net.runelite.api.Skill;
import net.runelite.api.events.GameTick;
import net.runelite.api.events.StatChanged;
import net.runelite.api.widgets.WidgetInfo;
import net.runelite.client.plugins.iutils.api.Spells;
import net.runelite.client.plugins.iutils.game.InventoryItem;
import net.runelite.client.plugins.iutils.game.iWidget;
import javax.inject.Inject;
public class Alch extends Task {
@Inject
private AgilityConfig config;
private boolean ready;
private long lastAlchTick;
private String[] items;
@Override
public String getStatus() {
return "High alching";
}
@Override
public boolean validate() {
if (items == null) {
items = config.alchItems().split(",");
for (int i = 0; i < items.length; i++) {
items[i] = items[i].trim();
}
}
return config.highAlch()
&& game.inventory().withName(items).exists()
&& game.inventory().withName("Nature rune").exists()
&& ready;
}
@Override
public void execute() {
ready = false;
lastAlchTick = game.ticks();
iWidget magicTab = game.widget(WidgetInfo.RESIZABLE_VIEWPORT_MAGIC_TAB);
if (magicTab == null || magicTab.hidden()) {
game.openInterface(3);
game.tick();
}
InventoryItem item = game.inventory().withName(items).first();
game.widget(Spells.HIGH_LEVEL_ALCHEMY.getInfo()).useOn(item);
game.sleepDelay();
}
public void onStatChanged(StatChanged event) {
if (event.getSkill().equals(Skill.AGILITY)) {
ready = true;
}
}
public void onGameTick(GameTick event) {
if (game.ticks() - lastAlchTick >= 5 && game.localPlayer().position().z == 0) {
ready = true;
}
}
}

View File

@ -0,0 +1,104 @@
package io.reisub.openosrs.agility.tasks;
import io.reisub.openosrs.agility.AgilityConfig;
import io.reisub.openosrs.util.Task;
import net.runelite.api.Skill;
import net.runelite.api.events.*;
import net.runelite.client.plugins.iutils.game.iObject;
import javax.inject.Inject;
public class HandleObstacle extends Task {
@Inject
private AgilityConfig config;
private boolean ready;
private int timeout = 10;
private int idleTicks;
@Override
public String getStatus() {
return "Handling obstacle";
}
@Override
public boolean validate() {
return ready;
}
@Override
public void execute() {
int id = config.courseSelection().getNextObstacleID(game.localPlayer().position());
if (id == 0) return;
iObject object = game.objects().withId(id).first();
if (object == null) return;
game.sleepDelay();
object.interact(object.actions().get(0));
game.tick();
ready = false;
}
public void setReady(boolean ready) {
this.ready = ready;
}
public void onHitsplatApplied(HitsplatApplied event) {
if (event.getHitsplat() != null && event.getHitsplat().isMine()) {
timeout = calc.random(2, 3);
}
}
public void onStatChanged(StatChanged event) {
if (event.getSkill().equals(Skill.AGILITY)) {
ready = true;
}
if (event.getSkill().equals(Skill.MAGIC)) {
if (game.localPlayer().position().z == 0) {
if (!game.localPlayer().isMoving()) {
ready = true;
}
int id = config.courseSelection().getNextObstacleID(game.localPlayer().position());
iObject object = game.objects().withId(id).first();
if (object != null && game.localPlayer().position().distanceTo(object.position()) < 4) {
ready = true;
}
} else {
ready = true;
}
}
}
public void onGameTick(GameTick event) {
if (game.localPlayer().isIdle()) {
idleTicks++;
if (idleTicks >= timeout) {
ready = true;
timeout = calc.random(7, 13);
}
} else {
idleTicks = 0;
}
}
public void onChatMessage(ChatMessage chatMessage) {
if (chatMessage.getMessage().contains("Can't reach that")) {
timeout = calc.random(1, 3);
}
if (chatMessage.getMessage().contains("You softly stroke your cat.")) {
ready = true;
}
}
public void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
if (configButtonClicked.getKey().equals("startButton")) {
ready = true;
}
}
}

View File

@ -0,0 +1,62 @@
package io.reisub.openosrs.agility.tasks;
import io.reisub.openosrs.agility.AgilityConfig;
import io.reisub.openosrs.util.Task;
import net.runelite.api.Skill;
import net.runelite.api.events.HitsplatApplied;
import net.runelite.api.events.StatChanged;
import net.runelite.client.plugins.iutils.game.iGroundItem;
import net.runelite.client.plugins.iutils.scene.Position;
import javax.inject.Inject;
public class PickupMark extends Task {
@Inject
private AgilityConfig config;
private boolean failed;
@Override
public String getStatus() {
return "Picking up mark";
}
@Override
public boolean validate() {
if (failed) return false;
iGroundItem mark = game.groundItems().withName("Mark of grace").nearest();
Position markPos = null;
try {
markPos = mark.position();
} catch (NullPointerException ignored) {}
return mark != null
&& config.courseSelection().markIsReachable(game.localPlayer().position(), markPos);
}
@Override
public void execute() {
game.waitUntil(() -> game.localPlayer().isIdle(), 10);
game.groundItems().withName("Mark of grace").findFirst().ifPresent(mark -> {
mark.interact(mark.actions().get(0));
game.tick();
});
game.waitUntil(() -> !game.groundItems().withName("Mark of grace").exists(), 10);
}
public void onHitsplatApplied(HitsplatApplied event) {
if (event.getHitsplat() != null && event.getHitsplat().isMine()) {
failed = true;
}
}
public void onStatChanged(StatChanged event) {
if (event.getSkill().equals(Skill.AGILITY)) {
failed = false;
}
}
}