Initial commit
This commit is contained in:
52
fisher/fisher.gradle.kts
Normal file
52
fisher/fisher.gradle.kts
Normal file
@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (c) 2019 Owain van Brakel <https://github.com/Owain94>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright notice, this
|
||||
* list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
||||
* this list of conditions and the following disclaimer in the documentation
|
||||
* and/or other materials provided with the distribution.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
|
||||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
version = "0.0.1"
|
||||
|
||||
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
|
||||
|
||||
dependencies {
|
||||
compileOnly(project(":util"))
|
||||
}
|
||||
|
||||
tasks {
|
||||
jar {
|
||||
manifest {
|
||||
attributes(mapOf(
|
||||
"Plugin-Version" to project.version,
|
||||
"Plugin-Id" to nameToId(project.extra["PluginName"] as String),
|
||||
"Plugin-Provider" to project.extra["PluginProvider"],
|
||||
"Plugin-Description" to project.extra["PluginDescription"],
|
||||
"Plugin-Dependencies" to
|
||||
arrayOf(
|
||||
nameToId("Chaos Util"),
|
||||
nameToId("iUtils")
|
||||
).joinToString(),
|
||||
"Plugin-License" to project.extra["PluginLicense"]
|
||||
))
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* 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.fisher;
|
||||
|
||||
import net.runelite.client.config.Button;
|
||||
import net.runelite.client.config.Config;
|
||||
import net.runelite.client.config.ConfigGroup;
|
||||
import net.runelite.client.config.ConfigItem;
|
||||
|
||||
@ConfigGroup("ChaosFisherConfig")
|
||||
|
||||
public interface FisherConfig extends Config {
|
||||
@ConfigItem(
|
||||
keyName = "startButton",
|
||||
name = "Start/Stop",
|
||||
description = "Start the script",
|
||||
position = 100
|
||||
)
|
||||
default Button startButton() {
|
||||
return new Button();
|
||||
}
|
||||
}
|
@ -0,0 +1,90 @@
|
||||
package io.reisub.openosrs.fisher;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
import io.reisub.openosrs.fisher.tasks.Drop;
|
||||
import io.reisub.openosrs.fisher.tasks.Fish;
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import io.reisub.openosrs.util.Util;
|
||||
import io.reisub.openosrs.util.tasks.KittenTask;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import net.runelite.api.events.ChatMessage;
|
||||
import net.runelite.api.events.ConfigButtonClicked;
|
||||
import net.runelite.client.config.ConfigManager;
|
||||
import net.runelite.client.eventbus.Subscribe;
|
||||
import net.runelite.client.plugins.PluginDependency;
|
||||
import net.runelite.client.plugins.PluginDescriptor;
|
||||
import net.runelite.client.plugins.iutils.iUtils;
|
||||
import net.runelite.client.plugins.iutils.scripts.iScript;
|
||||
import org.pf4j.Extension;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Extension
|
||||
@PluginDependency(Util.class)
|
||||
@PluginDependency(iUtils.class)
|
||||
@PluginDescriptor(
|
||||
name = "Chaos Fisher",
|
||||
description = "Frantically fishes fish",
|
||||
enabledByDefault = false
|
||||
)
|
||||
@Slf4j
|
||||
public class FisherPlugin extends iScript {
|
||||
private List<Task> tasks;
|
||||
|
||||
private KittenTask kittenTask;
|
||||
|
||||
@Provides
|
||||
FisherConfig provideConfig(ConfigManager configManager) {
|
||||
return configManager.getConfig(FisherConfig.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void loop() {
|
||||
for (Task t : tasks) {
|
||||
if (t.validate()) {
|
||||
log.info(t.getStatus());
|
||||
t.execute();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
game.sleepDelay();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStart() {
|
||||
log.info("Starting Chaos Fisher");
|
||||
|
||||
kittenTask = KittenTask.getInstance(injector);
|
||||
|
||||
tasks = new ArrayList<>();
|
||||
tasks.add(kittenTask);
|
||||
tasks.add(injector.getInstance(Drop.class));
|
||||
tasks.add(injector.getInstance(Fish.class));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onStop() {
|
||||
log.info("Stopping Chaos Fisher");
|
||||
if (tasks != null) {
|
||||
tasks.clear();
|
||||
}
|
||||
|
||||
KittenTask.handleKitten = false;
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onConfigButtonPressed(ConfigButtonClicked configButtonClicked) {
|
||||
if (configButtonClicked.getKey().equals("startButton")) {
|
||||
execute();
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
private void onChatMessage(ChatMessage chatMessage) {
|
||||
if (kittenTask != null) {
|
||||
kittenTask.onChatMessage(chatMessage);
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
package io.reisub.openosrs.fisher.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
import net.runelite.client.plugins.iutils.scene.Position;
|
||||
import net.runelite.client.plugins.iutils.ui.Bank;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class DoBank extends Task {
|
||||
@Inject
|
||||
public Bank bank;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Banking";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.inventory().full();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
iNPC banker = game.npcs().withName("Banker").nearest();
|
||||
|
||||
if (banker == null) {
|
||||
Position pos = new Position(2852, 2957, 0);
|
||||
game.walkUtils.sceneWalk(pos, 1, calc.random(50, 250));
|
||||
game.tick();
|
||||
|
||||
game.waitUntil(() -> pos.distanceTo(game.localPlayer().position()) < calc.random(6, 9));
|
||||
} else if (banker.position().distanceTo(game.localPlayer().position()) > 8) {
|
||||
Position pos = banker.position();
|
||||
game.walkUtils.sceneWalk(pos,1, calc.random(50, 250));
|
||||
game.tick();
|
||||
|
||||
game.waitUntil(() -> pos.distanceTo(game.localPlayer().position()) < calc.random(6, 9));
|
||||
}
|
||||
|
||||
banker = game.npcs().withName("Banker").nearest();
|
||||
|
||||
banker.interact("Bank");
|
||||
game.tick();
|
||||
|
||||
game.waitUntil(() -> bank.isOpen(), 10);
|
||||
bank.depositAll(true, 335, 331);
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,25 @@
|
||||
package io.reisub.openosrs.fisher.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
|
||||
public class Drop extends Task {
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Dropping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
return game.inventory().full();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.inventory().withNamePart("Leaping").forEach((item) -> {
|
||||
item.interact("Drop");
|
||||
game.sleepDelay();
|
||||
});
|
||||
|
||||
game.tick();
|
||||
}
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
package io.reisub.openosrs.fisher.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.client.plugins.iutils.game.iActor;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
|
||||
public class Fish extends Task {
|
||||
private iNPC spot;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Fishing";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
spot = game.npcs().withName("Fishing spot")
|
||||
.filter(iNPC -> iNPC.position().y < 3513 && iNPC.position().y > 3504).nearest();
|
||||
|
||||
iActor target = game.localPlayer().target();
|
||||
if (target != null && (target.position().y >= 3513 || target.position().y <= 3504)) return true;
|
||||
|
||||
return !game.inventory().full()
|
||||
&& spot != null
|
||||
&& (game.localPlayer().isIdle() || game.localPlayer().target() == null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
spot.interact("Use-rod");
|
||||
game.tick(calc.random(2, 4));
|
||||
|
||||
game.waitUntil(() -> game.localPlayer().animation() != -1, 10);
|
||||
spot = null;
|
||||
}
|
||||
}
|
@ -0,0 +1,66 @@
|
||||
package io.reisub.openosrs.fisher.tasks;
|
||||
|
||||
import io.reisub.openosrs.util.Task;
|
||||
import net.runelite.api.GameState;
|
||||
import net.runelite.api.World;
|
||||
import net.runelite.api.WorldType;
|
||||
import net.runelite.client.plugins.iutils.game.iNPC;
|
||||
|
||||
import java.util.EnumSet;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Queue;
|
||||
|
||||
public class Hop extends Task {
|
||||
private Queue<World> worlds;
|
||||
|
||||
@Override
|
||||
public String getStatus() {
|
||||
return "Hopping";
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean validate() {
|
||||
iNPC spot = game.npcs().filter(iNPC -> iNPC.name().equals("Rod Fishing spot") && iNPC.position().x > 2850 && iNPC.position().y <= 2974).nearest();
|
||||
|
||||
return spot == null && !game.inventory().full();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
game.client().hopToWorld(getNextWorld());
|
||||
game.sleepApproximately(3000);
|
||||
|
||||
game.waitUntil(() -> game.client().getGameState() == GameState.LOGGED_IN);
|
||||
}
|
||||
|
||||
private World getNextWorld() {
|
||||
if (worlds == null) {
|
||||
generateWorldsQueue();
|
||||
}
|
||||
|
||||
World w = worlds.poll();
|
||||
worlds.add(w);
|
||||
|
||||
return w;
|
||||
}
|
||||
|
||||
private void generateWorldsQueue() {
|
||||
worlds = new LinkedList<>();
|
||||
|
||||
for (World w : game.client().getWorldList()) {
|
||||
EnumSet<WorldType> types = w.getTypes();
|
||||
|
||||
if (types.contains(WorldType.MEMBERS)
|
||||
&& !types.contains(WorldType.BOUNTY)
|
||||
&& !types.contains(WorldType.TOURNAMENT_WORLD)
|
||||
&& !types.contains(WorldType.DEADMAN)
|
||||
&& !types.contains(WorldType.HIGH_RISK)
|
||||
&& !types.contains(WorldType.LAST_MAN_STANDING)
|
||||
&& !types.contains(WorldType.NOSAVE_MODE)
|
||||
&& !types.contains(WorldType.SEASONAL)
|
||||
&& !types.contains(WorldType.PVP)) {
|
||||
worlds.add(w);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user