Jump to content

intel64x

Members
  • Posts

    5
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

intel64x's Achievements

Newbie

Newbie (1/10)

0

Reputation

  1. Much appreciated you taking the time to write this message. I'll be going over it all to better myself. Thanks!
  2. Hey all. I'm having trouble getting my flow of the Onloop right in regards to fishing the trout and salmon, cooking them, and then banking them. Any tips would be appreciated. import java.awt.Graphics2D; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.map.constants.Banks; import org.osbot.rs07.api.model.NPC; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.ui.Message; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "Max-A-Million", info = "First Fly Fishing Script", name = "DatFisher", version = 0.01, logo = "https://s3.amazonaws.com/peoplepng/wp-content/uploads/2018/06/26125326/Queen-Crown-PNG-Free-Download.png") public class Main extends Script { // make sure to find the x,y,z position of edgevile bank. private long startTime; final long runTime = System.currentTimeMillis() - startTime; String[] ITEMS = new String[2]; private final Area FlyFishArea = new Area(3109, 3437, 3101, 3420); @Override public void onStart() { startTime = System.currentTimeMillis(); log("Let's get started!"); } @Override public int onLoop() throws InterruptedException { //Step 1: Check for essential items. if(!canFlyFish()) {//dont have required items? stop(true); log("User does not have the required items to fly fish."); } //Step 2: Check if user is in Barbarian Village area if(!isInLocation()) { walkToSpot(); } //Step 3: Go Fish & Wait until full of fish if (!inventory.isFull()) { log("Inventory is not full and I am going to fish"); fishingTime(); } //Step 4: Check requirements for cooking & Direct to proper method for cooking. if (!CanCookSalmon()) { if(!CanCookTrout()) { stop(true); log("Cant cook trout because dont have the levels."); } cookTrout(); } else { cookAll(); } //Step 5: Bank everything once all items(that are able to be cooked) are cooked. return random(300, 400); } private boolean isInLocation() { if (FlyFishArea.contains(myPlayer().getPosition())) { return true; } return false; } public void cookTrout() throws InterruptedException { RS2Object fire = getObjects().closest("Fire"); log("Found a fire for cook trout method"); if (fire != null && !myPlayer().isAnimating()) { inventory.getItem("Raw trout").interact("Use"); fire.hover(); sleep(random(1000,2000)); mouse.click(true); sleep(random(1000,2000)); fire.interact("Use"); sleep(random(2000,4000)); RS2Widget cookiconbutton = getWidgets().get(270, 14); cookiconbutton.interact(); new ConditionalSleep(600000) { @Override public boolean condition() { return !inventory.contains("Raw trout") || widgets.isVisible(233) || getDialogues().isPendingContinuation(); } }.sleep(); } } public void cookAll() throws InterruptedException { RS2Object fire = getObjects().closest("Fire"); log("Found a fire for cook all method"); if (fire != null && !myPlayer().isAnimating()) { inventory.getItem("Raw trout").interact("Use"); fire.hover(); sleep(random(1000,2000)); mouse.click(true); sleep(random(1000,2000)); fire.interact("Use"); sleep(random(2000,4000)); RS2Widget cookiconbutton = getWidgets().get(270, 14); cookiconbutton.interact(); new ConditionalSleep(600000) { @Override public boolean condition() { return !inventory.contains("Raw trout") || widgets.isVisible(233) || getDialogues().isPendingContinuation(); } }.sleep(); } if (fire != null && !myPlayer().isAnimating()) { inventory.getItem("Raw salmon").interact("Use"); fire.hover(); sleep(random(1000,2000)); mouse.click(true); sleep(random(1000,2000)); fire.interact("Use"); sleep(random(2000,4000)); RS2Widget cookiconbutton = getWidgets().get(270, 14); cookiconbutton.interact(); new ConditionalSleep(600000) { @Override public boolean condition() { return !inventory.contains("Raw salmon") || widgets.isVisible(233) || getDialogues().isPendingContinuation(); } }.sleep(); } } public void walkToSpot() { getWalking().webWalk(new Area(3106, 3433, 3108, 3434)); } public boolean CanCookSalmon() { if ((getSkills().getDynamic(Skill.COOKING) >= 25)) { return true; } return false; } public boolean CanCookTrout() { if ((getSkills().getDynamic(Skill.COOKING) >= 15) && (getSkills().getDynamic(Skill.COOKING) < 25)) { return true; } return false; } private boolean canFlyFish() { ITEMS[0] = "Feather"; ITEMS[1] = "Fly fishing rod"; for (String item : ITEMS) { if (!inventory.contains(item)) { return false; } } return true; } public void fishingTime() throws InterruptedException { NPC fishingspot = npcs.closest("Rod Fishing spot"); //finds closest fishing npc named that if (fishingspot != null && !myPlayer().isAnimating()) { fishingspot.interact("Lure"); sleep(random(2000,3000));//sleep randomly after luring so it doesn't constantly spam. log("Now fishing...."); new ConditionalSleep(120000) {//120 second conditional sleep that only wakes up if inv is full, @Override //you get a level up or the player stops making cooking animation. public boolean condition() { return inventory.isFull() || widgets.isVisible(233) || !myPlayer().isAnimating(); } }.sleep(); } } public void bankEverything() throws InterruptedException { walking.webWalk(Banks.EDGEVILLE); // walk to the bank log("Walking to bank because there are no empty slots"); RS2Object bankbooth = getObjects().closest("Bank booth"); if (bankbooth != null) { bankbooth.interact("Bank"); // open the bank sleep(3000); if (getBank().isOpen()) { getBank().depositAllExcept("Feather", "Fly Fishing rod"); // figure out how to make slower. sleep(random(300,400)); getBank().close(); sleep(random(300,400)); } } } public void MoveMouseOffScreen() throws InterruptedException { } public void MovingCamera() throws InterruptedException { } @Override public final void onMessage(final Message message) { log("A message arrived in the chatbox: " + message.getMessage()); } @Override public void onExit() { log("WHAT HAPPENED?!"); } public final String formatTime(final long ms){ long s = ms / 1000, m = s / 60, h = m / 60; s %= 60; m %= 60; h %= 24; return String.format("%02d:%02d:%02d", h, m, s); } @Override public void onPaint(Graphics2D g) { String fishinglevel = Integer.toString(getSkills().getDynamic(Skill.FISHING)); String cookinglevel = Integer.toString(getSkills().getDynamic(Skill.COOKING)); g.drawString("datFisher", 40, 365);//(x,y) x being horizontal movement, y being vertical movement g.drawString("Version: 0.1", 40, 385); g.drawString("Fishing:", 40, 405); // same y but g.drawString(fishinglevel, 120, 405); g.drawString("Cooking", 40, 425); g.drawString(cookinglevel, 120, 425); //g.drawString(formatTime(runTime), 180, 480); } }
×
×
  • Create New...