Jump to content

PshYouLost

Members
  • Posts

    21
  • Joined

  • Last visited

  • Feedback

    0%

Profile Information

  • Gender
    Male

Recent Profile Visitors

705 profile views

PshYouLost's Achievements

Bronze Poster

Bronze Poster (2/10)

5

Reputation

  1. I finally got it to work!! private RS2Object ironRocks = null; private RS2Object currentIronRock = null; private Filter<Item> nameFilter = new NameFilter<Item>("Iron ore"); int[] dropOrderVertical = {0, 4, 8, 12, 16, 20, 24, 1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15, 19, 23, 27}; int[] dropOrderHorizontal = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}; private long startedAt; private int currentYaw = 0; @Override public final int onLoop() throws InterruptedException { if (size(screenshotFolder) >= Double.valueOf("5e+10").longValue()) { stop(true); } else if ((System.currentTimeMillis() - startedAt) > 600000) { int randomDegree = random(1, 15); if (currentYaw + randomDegree > 270) { currentYaw = 0; } getCamera().moveYaw(currentYaw + randomDegree); currentYaw = getCamera().getYawAngle(); startedAt = System.currentTimeMillis(); } else { switch (getState()) { case MINE: ironRocks = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == 3286 && n.getY() == 3369) || (n.getX() == 3285 && n.getY() == 3368))); if (ironRocks != null) { //log(ironRocks.getX() + " " + ironRocks.getY()); log("Mine"); labelImages("mineIronOre"); ironRocks.interact("Mine"); new ConditionalSleep(5000) { @Override public boolean condition() { currentIronRock = getObjects().get(ironRocks.getX(), ironRocks.getY()).get(0); return myPlayer().isAnimating() || currentIronRock.getId() != 7488; } }.sleep(); } else { log("Wait"); labelImages("doNothing"); } break; case DROP: log("Drop"); getKeyboard().pressKey(VK_SHIFT); for (int slot = 0; slot < 28; slot++) { //for (int slot : dropOrderVertical) { Item itemInSlot = getInventory().getItemInSlot(slot); if (itemInSlot != null && nameFilter.match(itemInSlot)) { labelImages("dropIronOre"); getInventory().interact(slot); sleep(random(25, 100)); } } getKeyboard().releaseKey(VK_SHIFT); break; case WAIT: log("Wait"); labelImages("doNothing"); break; } } return 100; } private enum State { MINE, DROP, WAIT; } private State getState() { if (ironRocks != null) { currentIronRock = getObjects().get(ironRocks.getX(), ironRocks.getY()).get(0); } if (inventory.isFull()) { return State.DROP; } else if ((!myPlayer().isAnimating() && !myPlayer().isMoving()) || currentIronRock.getId() != 7488) { log("TRY TO MINE"); return State.MINE; } else { return State.WAIT; } } Thanks everyone!
  2. So I realized that the currentIronRock never updated to check so it was always not null. So this is what I came up with case MINE: ironRocks = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == 3286 && n.getY() == 3369) || (n.getX() == 3285 && n.getY() == 3368))); if (ironRocks != null) { //log(ironRocks.getX() + " " + ironRocks.getY()); log("Mine"); labelImages("mineIronOre"); ironRocks.interact("Mine"); Sleep.sleepUntil(() -> myPlayer().isAnimating() || getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == ironRocks.getX() && n.getY() == ironRocks.getY()))) == null, 5000); } else { log("Wait"); labelImages("doNothing"); } break; But now I occasionally get an error After someone stole my rock
  3. Sorry, I don't think I'm following. What's wrong with the code I'm currently using? It's checking to see if it's null, which is the same thing as checking to see if it has a modified color? Anyway, this is code I currently have but it's still causing some problems case MINE: ironRocks = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == 3286 && n.getY() == 3369) || (n.getX() == 3285 && n.getY() == 3368))); if (ironRocks != null) { log("Mine"); labelImages("mineIronOre"); ironRocks.interact("Mine"); RS2Object currentIronRock = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == ironRocks.getX() && n.getY() == ironRocks.getY()))); Sleep.sleepUntil(() -> myPlayer().isAnimating() || currentIronRock == null, 5000); } else { log("Wait"); labelImages("doNothing"); } break;
  4. I changed it up but I still can't get it to work for some reason! case MINE: ironRocks = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == 3286 && n.getY() == 3369) || (n.getX() == 3285 && n.getY() == 3368))); if (ironRocks != null) { log("Mine"); labelImages("mineIronOre"); ironRocks.interact("Mine"); Sleep.sleepUntil(() -> myPlayer().isAnimating() || !ironRocks.exists(), 5000); } else { log("Wait"); labelImages("doNothing"); } break; What's the difference between what I'm doing at using modifiedcolor?
  5. This is the code private RS2Object ironRocks = null; private Filter<Item> nameFilter = new NameFilter<Item>("Iron ore"); int[] dropOrderVertical = {0, 4, 8, 12, 16, 20, 24, 1, 5, 9, 13, 17, 21, 25, 2, 6, 10, 14, 18, 22, 26, 3, 7, 11, 15, 19, 23, 27}; int[] dropOrderHorizontal = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27}; private long startedAt; private int currentYaw = 0; @Override public final int onLoop() throws InterruptedException { if (size(screenshotFolder) >= Double.valueOf("5e+10").longValue()) { stop(true); } else if ((System.currentTimeMillis() - startedAt) > 600000) { int randomDegree = random(1, 15); if (currentYaw + randomDegree > 270) { currentYaw = 0; } getCamera().moveYaw(currentYaw + randomDegree); currentYaw = getCamera().getYawAngle(); startedAt = System.currentTimeMillis(); } else { switch (getState()) { case MINE: ironRocks = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == 3286 && n.getY() == 3369) || (n.getX() == 3285 && n.getY() == 3368))); if (ironRocks != null) { log("Mine"); labelImages("mineIronOre"); ironRocks.interact("Mine"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return (myPlayer().isAnimating()); } }.sleep(); } else { log("Wait"); labelImages("doNothing"); } break; case DROP: log("Drop"); getKeyboard().pressKey(VK_SHIFT); for (int slot = 0; slot < 28; slot++) { //for (int slot : dropOrderVertical) { Item itemInSlot = getInventory().getItemInSlot(slot); if (itemInSlot != null && nameFilter.match(itemInSlot)) { labelImages("dropIronOre"); getInventory().interact(slot); sleep(random(25, 100)); } } getKeyboard().releaseKey(VK_SHIFT); break; case WAIT: log("Wait"); labelImages("doNothing"); break; } } return 100; } private enum State { MINE, DROP, WAIT; } private State getState() { if (inventory.isFull()) { return State.DROP; } else if ((!myPlayer().isAnimating() && !myPlayer().isMoving()) || (ironRocks == null)) { return State.MINE; } else { return State.WAIT; } } @Override public final void onStart() throws InterruptedException { log("Script Started"); startedAt = System.currentTimeMillis(); camera.toTop(); } } I've tried a solid amount of different things butI'm still just not able to make my bot realize the rock it's mining is currently empty. } else if ((!myPlayer().isAnimating() && !myPlayer().isMoving()) || (ironRocks == null)) { This line makes so much sense to me but it's obviously not working. Either check to see if the player is NOT animating and is NOT moving. meaning i'm just standing there then mine OR check to see if the current rock that we're mining is no longer an iron rock. But for some reason it doesn't seem to work. Any ideas?
  6. Yeah I know that's correct :P The reason I wanted to see the actual method was because I wanted to make the code do something in the middle of each drop action. Thanks tho!
  7. I figured it out. Mine just assumes shiftdrop is enabled case DROP: getKeyboard().pressKey(VK_SHIFT); for (int slot = 0; slot < 28; slot++) { Item itemInSlot = getInventory().getItemInSlot(slot); if (itemInSlot != null && nameFilter.match(itemInSlot)) { getInventory().interact(slot); sleep(random(25, 100)); } } getKeyboard().releaseKey(VK_SHIFT);
  8. Hey guys! I'm trying to find the code that implements getInventory().dropAll(String itemName); I looked over the forums and I found private Filter < Item > nameFilter = new NameFilter < Item > ("Iron ore"); for (int slot = 0; slot < 28; slot++) { Item itemInSlot = getInventory().getItemInSlot(slot); if (itemInSlot != null && nameFilter.match(itemInSlot)) { getInventory().interact(slot, "Drop"); sleep(random(25, 100)); } } Except this doesn't activate the shiftdrop which is what I'm looking for. Any ideas? I just want to code it so that something happens before a single drop.
  9. Okay I officially did it! Thanks everyone for all your help! ironRocks = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == 3286 && n.getY() == 3369) || (n.getX() == 3285 && n.getY() == 3368)));
  10. Holy shit. Okay, I'm definitely getting closer public final int onLoop() throws InterruptedException { ironRocks = getObjects().closest(n -> n.getId() == 7488 && ((n.getX() == 1234 && n.getY() == 1234) || (n.getX() == 1234 && n.getY() == 1234))); switch (getState()) { case MINE: labelImages("mineIronOre"); ironRocks.interact("Mine"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); break; case DROP: labelImages("dropIronOre"); inventory.dropAll("Iron ore"); break; case WAIT: labelImages("doNothing"); break; } return 100; }
  11. I'm almost certain I'm doing this wrong.. =/ But this is what I attempted to do List<RS2Object> availableIronRock = getObjects().filter(t -> t.getPosition() == ironRocks.getPosition() && t.getId() == 7488); availableIronRock.get(0).interact("Mine"); But that obviously doesn't work lol. And I couldn't figure out how to use a filter after the `.closest` part
  12. Uhh. I'll look into it! private State getState() { log(ironRocks.hasAction("Mine")); log(!myPlayer().isAnimating()); log(!myPlayer().isMoving()); if (inventory.isFull()) { return State.DROP; } else if (!myPlayer().isAnimating() && !myPlayer().isMoving()) { return State.MINE; } else { return State.WAIT; } } After my bot mines the initial rock, it just keeps printing Every 5 seconds. Which I think means it's stuck at case MINE: labelImages("mineIronOre"); ironRocks.interact("Mine"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); break;
  13. Because if I set the ironRocks = getObjects().closest(7488); in the onLoop area, then the bot will run around to other rocks and I don't want that. I only want it to wait for the rock north and west of me
  14. This is the script import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.api.util.Utilities; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import java.awt.*; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.nio.file.StandardCopyOption; import java.util.Date; @ScriptManifest(author = "PshYouLost", name = "labelCollector", info = "Get Runescape Info", version = 0.1, logo = "") public final class dataCollector extends Script { private Path screenshotFile = Paths.get("C:\\Users\\PshYouLost\\OSBot\\Data\\screenshots\\screenshot_1.png"); private void labelImages(String folderName) { Utilities.takeScreenshot(); java.util.Date date = new Date(); Path destinationFile = Paths.get("C:\\Users\\PshYouLost\\OSBot\\Data\\screenshots\\varrockEastIronPowerMiner\\" + folderName + "\\" + date.getTime() + ".png"); try { Files.move(screenshotFile, destinationFile, StandardCopyOption.REPLACE_EXISTING); } catch (IOException e) { e.printStackTrace(); log(e); } } private RS2Object ironRocks = null; @Override public final int onLoop() throws InterruptedException { switch (getState()) { case MINE: labelImages("mineIronOre"); ironRocks.interact("Mine"); new ConditionalSleep(5000) { @Override public boolean condition() throws InterruptedException { return myPlayer().isAnimating(); } }.sleep(); break; case DROP: labelImages("dropIronOre"); inventory.dropAll("Iron ore"); break; case WAIT: labelImages("doNothing"); break; } return 100; } private enum State { MINE, DROP, WAIT; } private State getState() { if (inventory.isFull()) { return State.DROP; } else if (!myPlayer().isAnimating() && !myPlayer().isMoving() && ironRocks.hasAction("Mine")) { return State.MINE; } else { return State.WAIT; } } @Override public final void onStart() throws InterruptedException { log("Script Started"); if (getObjects().closest(7488) != null) { ironRocks = getObjects().closest(7488); } else if (ironRocks == null) { log("There are no iron rocks in this area!"); stop(); } camera.toTop(); } @Override public void onPaint(Graphics2D g) { } } The goal is to only power mine iron from these two specific rocks I don't want it to look for any other rocks at the moment. The ID for those 2 specific iron rocks is `7488` There are two issues. At the moment, the issue is that when I click run, the bot clicks an iron ore, and then stops and doesnt do anything else. Any ideas?
×
×
  • Create New...