dampoe40 Posted October 29, 2021 Share Posted October 29, 2021 (edited) Is it possible to fetch the coordinates for each item in inventory after it has checked if the previous item has been dropped. What i suggest is, get X,Y from "Oak-logs" (in boundaries of clickable box) move mouse to x,y drop item check if item has dropped get x y from second item etc.. What i currently have for this is only 1 inventory slot, by using the mousehover debug setting and randomzing X/Y in those boundaries. I could do it manually for each and every inventory slot but it seems to me this is a really ineffective way of coding. Conditional sleeps is something I have trouble understanding, if (tree.hover() == true) { new ConditionalSleep(73, 1352) { @Override public boolean condition() { return mouse.click(false); } }.sleep(); } Does it start sleeping after the click? or before the click? And something I also want to ask can i increase the clickspeed/mousevelocity of newmouse? It feels slower which might be better but at the same time if dropping it feels really inefficient. Im not asking for you to provide a solution, rather to send me in the right direction. Edited October 29, 2021 by dampoe40 Quote Link to comment Share on other sites More sharing options...
Gunman Posted October 29, 2021 Share Posted October 29, 2021 @dampoe40 Is there a reason you're doing it like that instead of using the drop API? And for mouse https://osbot.org/api/org/osbot/rs07/event/interaction/MouseMoveProfile.html Quote Link to comment Share on other sites More sharing options...
dampoe40 Posted October 29, 2021 Author Share Posted October 29, 2021 @GunmanI thought by being able to do this you deviate your script from other scripts since ( I assume) most wil use the drop api for this task. However maybe I'm naïve and believe things rather quick without having experience in scripting/botting. I'm not able to conclude for myself wether it would make sense to implement or not. If going by Preventing RS Botting Bans V3, it wouldn't make sense to add this. But yeah, the reason for wanting to do it this way is antiban. Quote Link to comment Share on other sites More sharing options...
Gunman Posted October 29, 2021 Share Posted October 29, 2021 38 minutes ago, dampoe40 said: @GunmanI thought by being able to do this you deviate your script from other scripts since ( I assume) most wil use the drop api for this task. However maybe I'm naïve and believe things rather quick without having experience in scripting/botting. I'm not able to conclude for myself wether it would make sense to implement or not. If going by Preventing RS Botting Bans V3, it wouldn't make sense to add this. But yeah, the reason for wanting to do it this way is antiban. I mean, I guess you change some patterns if you use a custom pattern instead of the default left right starting at top left Tree.hover() already returns a boolean, you don't need to check if it == true this is redundant. You're also using the Conditional Sleep wrong. Conditional Sleeps will sleep the time provided or until the condition returns true. For dropping if you wait until the item is gone that will make dropping very slow because it will have to wait a fully game tick (roughly 600MS) for every item if you're power mining for example. Quote Link to comment Share on other sites More sharing options...
dampoe40 Posted October 30, 2021 Author Share Posted October 30, 2021 (edited) Thanks for some feedback, wondering what you would do different without implementing a lot more to this script. I'm still relative new to writing methods and so i'm not sure if they are written correct, and are usefull the way they are. This is also my first script after reading through the tutorial. Edit: There's also some useless imports im pretty sure since this was also the class i made to fool around ;/ package core; import java.awt.*; import Utils.MouseCursor; import org.osbot.rs07.input.mouse.InventorySlotDestination; import org.osbot.rs07.input.mouse.MouseDestination; import org.osbot.rs07.api.Mouse; import org.osbot.rs07.api.map.Area; import org.osbot.rs07.api.model.RS2Object; import org.osbot.rs07.input.mouse.MouseDestination; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; import org.osbot.rs07.api.Camera; import java.util.function.BooleanSupplier; import javax.imageio.ImageIO; @ScriptManifest(author = "You", info = "My first script", name = "WoodcuttingV2", version = 2, logo = "") public class WoodcuttingV2 extends Script { private MouseCursor cursor = new MouseCursor(255, 1, Color.white, this); int invValue = 28; int i = 0; boolean canChop = false; @Override public int onLoop() throws InterruptedException { if (inventoryFull()) { drop(getRs2ObjectTree()); } else { chop(); } return random(150, 200); } private void chop() throws InterruptedException { RS2Object tree = getRs2ObjectTree(); moveMouseOutsideScreen(); Sleep.sleepUntil(this::isPlayerAnimating,3000); if (areaHasTree(tree) && !isPlayerAnimating()) { sleep(random(1000, 5000)); if (!isVisible(tree)) { panCameraToObject(tree); hoverObject(tree); interactWithObject(); Sleep.sleepUntil(this::isPlayerAnimating,3000); } else if (hoverObject(tree)) { interactWithObject(); Sleep.sleepUntil(this::isPlayerAnimating,3000); } moveMouseOutsideScreen(); } } private void drop(RS2Object tree) throws InterruptedException { sleep(random(1000,11000)); dropRowInventory1(); dropRowInventory2(); dropRowInventory3(); dropRowInventory4(); hoverObject(tree); interactWithObject(); } private void interactWithObject() { Sleep.sleepUntil(this::isChopDownVisible, random(73,192)); clickLeftButton(); } private boolean isChopDownVisible() { return getWidgets().getWidgetContainingText("Chop down") != null; } private boolean isPlayerAnimating() { return myPlayer().isAnimating(); } private boolean moveMouseOutsideScreen() { return mouse.moveOutsideScreen(); } private boolean clickLeftButton() { return mouse.click(false); } private boolean hoverObject(RS2Object tree) { return tree.hover(); } private void panCameraToObject(RS2Object tree) { getCamera().toEntity(tree); } private boolean isVisible(RS2Object tree) { return tree.isVisible(); } private boolean areaHasTree(RS2Object tree) { return (getRadius().contains(tree)); } private boolean inventoryFull() { return getInventory().isFull(); } private Area getRadius() { Area radius = myPlayer().getArea(10); return radius; } private RS2Object getRs2ObjectTree() { RS2Object tree = getObjects().closest("Oak"); return tree; } @Override public void onPaint(Graphics2D g) { cursor.paint(g); } private void dropRowInventory1() { keyboard.pressKey(16); for (i = 3; i < 28; i += 4) { if (mouse.move(new InventorySlotDestination(getBot(), i))) { new ConditionalSleep(24, 191) { @Override public boolean condition() { return !mouse.move(new InventorySlotDestination(getBot(), i)); } }.sleep(); mouse.click(false); } } } private void dropRowInventory2() { for (i = 26; i > 1; i -= 4) { if (mouse.move(new InventorySlotDestination(getBot(), i))) { new ConditionalSleep(12, 241) { @Override public boolean condition() { return !mouse.move(new InventorySlotDestination(getBot(), i)); } }.sleep(); mouse.click(false); } } } private void dropRowInventory3() { for (i = 1; i <= 25; i += 4) { if (mouse.move(new InventorySlotDestination(getBot(), i))) { new ConditionalSleep(2, 112) { @Override public boolean condition() { return !mouse.move(new InventorySlotDestination(getBot(), i)); } }.sleep(); mouse.click(false); } } } private void dropRowInventory4() { for (i = 24; i >= 4; i -= 4) { if (mouse.move(new InventorySlotDestination(getBot(), i))) { new ConditionalSleep(7, 192) { @Override public boolean condition() { return !mouse.move(new InventorySlotDestination(getBot(), i)); } }.sleep(); mouse.click(false); } } keyboard.releaseKey(16); } } class Sleep extends ConditionalSleep { private final BooleanSupplier condition; public Sleep(final BooleanSupplier condition, final int timeout) { super(timeout); this.condition = condition; } @Override public final boolean condition() throws InterruptedException { return condition.getAsBoolean(); } public static boolean sleepUntil(final BooleanSupplier condition, final int timeout) { return new Sleep(condition, timeout).sleep(); } } Edited October 30, 2021 by dampoe40 Adding extra info Quote Link to comment Share on other sites More sharing options...