Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package core;
- import java.awt.Graphics2D;
- import java.util.Arrays;
- import org.osbot.rs07.api.Trade;
- import org.osbot.rs07.api.filter.Filter;
- import org.osbot.rs07.api.map.Area;
- import org.osbot.rs07.api.map.Position;
- import org.osbot.rs07.api.model.NPC;
- import org.osbot.rs07.api.model.RS2Object;
- import org.osbot.rs07.api.ui.RS2Widget;
- import org.osbot.rs07.event.WalkingEvent;
- import org.osbot.rs07.script.Script;
- import org.osbot.rs07.script.ScriptManifest;
- import utils.Sleep;
- @ScriptManifest(author = "Fury Shark", info = "Essence Runner ZMI", name = "EssenceRunnerZMI", version = 0, logo = "https://i.imgur.com/3OidXbh.jpg")
- public class Main extends Script {
- Area tradeArea = new Area(3055, 5585, 3065, 5574);
- Area bankArea = new Area(3011, 5626, 3016, 5623);
- Area tradeArea2 = new Area(
- new int[][]{
- { 3057, 5587 },
- { 3055, 5585 },
- { 3055, 5574 },
- { 3065, 5573 },
- { 3065, 5582 },
- { 3066, 5583 }
- }
- );
- private WalkingEvent myEvent;
- Position crackPos = new Position(3055, 5585, 0);
- Position[] pathToBank = {
- new Position(3052, 5587, 0),
- new Position(3042, 5587, 0),
- new Position(3041, 5587, 0),
- new Position(3037, 5589, 0),
- new Position(3028, 5585, 0),
- new Position(3024, 5586, 0),
- new Position(3023, 5590, 0),
- new Position(3028, 5594, 0),
- new Position(3033, 5597, 0),
- new Position(3043, 5596, 0),
- new Position(3043, 5596, 0),
- new Position(3053, 5596, 0),
- new Position(3054, 5596, 0),
- new Position(3062, 5596, 0),
- new Position(3063, 5601, 0),
- new Position(3054, 5603, 0),
- new Position(3048, 5603, 0),
- new Position(3042, 5601, 0),
- new Position(3035, 5604, 0),
- new Position(3029, 5599, 0),
- new Position(3022, 5602, 0),
- new Position(3022, 5607, 0),
- new Position(3026, 5612, 0),
- new Position(3022, 5620, 0),
- new Position(3019, 5624, 0)
- };
- Position[] pathToAltar = {
- new Position(3019, 5623, 0),
- new Position(3023, 5616, 0),
- new Position(3026, 5612, 0),
- new Position(3021, 5605, 0),
- new Position(3025, 5600, 0),
- new Position(3031, 5601, 0),
- new Position(3038, 5603, 0),
- new Position(3044, 5601, 0),
- new Position(3051, 5604, 0),
- new Position(3060, 5602, 0),
- new Position(3064, 5598, 0),
- new Position(3054, 5596, 0),
- new Position(3052, 5595, 0),
- new Position(3042, 5595, 0),
- new Position(3039, 5595, 0),
- new Position(3034, 5597, 0),
- new Position(3025, 5593, 0),
- new Position(3023, 5587, 0),
- new Position(3026, 5584, 0),
- new Position(3033, 5587, 0),
- new Position(3038, 5589, 0),
- new Position(3047, 5587, 0),
- new Position(3052, 5587, 0)
- };
- Position[] path = {
- new Position(3056, 5584, 0),
- new Position(3059, 5582, 0)
- };
- Area bankArea2 = new Area(
- new int[][]{
- { 3054, 5589 },
- { 3052, 5585 },
- { 3049, 5586 },
- { 3051, 5590 }
- }
- );
- @SuppressWarnings("unchecked")
- public RS2Widget getWidgetWithAction(int rootId, String... interactions) {
- Filter<RS2Widget> filt = arg0 -> {
- if (arg0 == null) {
- return false;
- }
- if (arg0.getInteractActions() == null) {
- return false;
- }
- boolean b = false;
- for (String s : arg0.getInteractActions()) {
- for (String s2 : interactions) {
- if (s.equalsIgnoreCase(s2)) {
- b = true;
- }
- }
- }
- return b;
- };
- return getWidgets().singleFilter(rootId, filt);
- }
- @Override
- public void onStart() throws InterruptedException {
- log("Started");
- }
- @Override
- public int onLoop() throws InterruptedException {
- if (getInventory().contains("Pure essence") || getTrade().isCurrentlyTrading()) {
- if (tradeArea.contains(myPlayer())) {
- tradeMain();
- } else {
- runToTradeArea();
- }
- } else {
- if (bankArea.contains(myPlayer())) {
- bank();
- } else {
- runToBankArea();
- }
- }
- return random(200, 300);
- }
- private void runToBankArea() throws InterruptedException {
- RS2Object crack = getObjects().closest(29627);
- int x = random(3014,3016);
- int y = random(5624,5626);
- Position nearBank = new Position(x, y, 0);
- if (tradeArea2.contains(myPlayer())) {
- myEvent = new WalkingEvent(crackPos);
- myEvent.setMinDistanceThreshold(0);
- execute(myEvent);
- crack.interact("Squeeze-through");
- Sleep.sleepUntil(() -> !myPlayer().isAnimating() && !myPlayer().isMoving(), 25000);
- sleep(random(2500,3500));
- } else {
- getWalking().walkPath(Arrays.asList(pathToBank));
- myEvent = new WalkingEvent(nearBank);
- myEvent.setMinDistanceThreshold(0);
- execute(myEvent);
- }
- }
- private void bank() {
- NPC banker = npcs.closest("Eniola");
- if (!getBank().isOpen()) {
- banker.interact("Bank");
- Sleep.sleepUntil(() -> getBank().isOpen(), 25000);
- }
- if (!getInventory().onlyContains("Air rune")) {
- getBank().depositAllExcept("Air rune");
- }
- getBank().withdraw("Pure essence", 26);
- getBank().close();
- Sleep.sleepUntil(!getBank().isOpen(), 25000);
- }
- private void runToTradeArea() throws InterruptedException {
- RS2Object crack = getObjects().closest(29626);
- if (bankArea2.contains(myPlayer())) {
- crack.interact("Squeeze-through");
- Sleep.sleepUntil(() -> !myPlayer().isAnimating() && !myPlayer().isMoving(), 25000);
- sleep(random(2500,3500));
- getWalking().walkPath(Arrays.asList(path));
- } else {
- getWalking().walkPath(Arrays.asList(pathToAltar));
- sleep(random(2000,2500));
- }
- }
- private void tradeMain() {
- RS2Widget accept = getWidgetWithAction(334, "Accept");
- int k = 0;
- if (!getTrade().isCurrentlyTrading()) {
- getPlayers().closest("World365").interact("Trade with");
- Sleep.sleepUntil(() -> getTrade().isCurrentlyTrading(), 25000);;
- }
- else if (getTrade().isFirstInterfaceOpen() && !getTrade().getOurOffers().contains("Pure essence")) {
- getTrade().offer("Pure essence", 13);
- Sleep.sleepUntil(() -> getTrade().getOurOffers().contains("Pure essence"), 25000);
- getTrade().acceptTrade();
- }
- else if (getTrade().isSecondInterfaceOpen()) {
- while(accept == null) {
- k++;
- if(k==10) {
- log("cant find accept widget");
- return; // or exit if you want
- }
- accept = getWidgetWithAction(Trade.SECOND_INTERFACE_ID, "Accept");
- }
- accept.interact();
- }
- }
- @Override
- public void onExit() {
- log(":(");
- }
- @Override
- public void onPaint(Graphics2D g) {
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement