Jump to content

Fanny

Members
  • Posts

    14
  • Joined

  • Last visited

  • Feedback

    0%

Everything posted by Fanny

  1. Still living in hope that we might get an answer on this - it is probably a simple config setting - feel like I have tried everything though Really surprised more people on here don't use linux Also wtf how are there so many MacOS threads? Like usually, this is the issue and the solution is use a different OS How is this happening with linux!?
  2. Excellent, thanks everyone! Back to babysitting the bot in my basement
  3. But then who will babysit the bot?!
  4. I did the unthinkable – I went outside and touched grass. Yep, actual grass. Turns out, it's green, soft, and kinda nice. Who knew?
  5. I have no way to test or find without waiting for a genie to spawn, so thought I'd ask here Does anyone know the widget code or have any existing scripts for handling the genie lamp? private void randomHandler() throws InterruptedException { randomGenie(); // Additional randoms } private void randomGenie() throws InterruptedException { final NPC genie = getNpcs().closest(npc -> npc != null && npc.getName().equals("Genie") && npc.getPosition().distance(myPosition()) <= 1); if (genie == null || !genie.exists()) { return; } log("Genie found. Attempting to talk..."); genie.interact("Talk-to"); if(Sleep.sleep(this,3000,() -> getInventory().contains("Lamp"))){ getInventory().getItem("Lamp").interact("Rub"); // Widget code } return; } Just decided to put this here for anyone else looking for the same - just call randomHandler() at the start of the onloop Feels like the Genie is definitely one people would actually click on, couple of others potentially depending on if the script is banking etc
  6. The client doesn't work at the moment anyway due to the update, I know Does anyone know how to get Jagex accounts working with linux? I have tried using the com.adamcake.Bolt launcher, initially launching runelite to create it, then patching the location at /home/{USER}/.var/app/com.adamcake.Bolt/bolt-something/ ... /runelite.jar Patching it seems to work, but then bolt just opens runelite. osbot.jar is created in the directory upon patching. If i rename runelite.jar to something else, then rename osbot.jar to runelite.jar it does open osbot... But then osbot fails to connect or something, won't load RS Edit: The error when swapping files looked like the current OSBot error from patch day (but this was tested before the patch, so unrelated)
  7. Thanks for sharing this - I genuinely hadn't thought of just looping with a short sleep, but this new approach, combined with understanding now static vs non-static has been extremely useful It has also allowed me to add additional functionality into the loop itself
  8. Anyone had any joy with this?
  9. Thanks! I think this is probably where I am getting stuck, static vs. non-static is a bit confusing to me still I'll try adapting this to suit my use cases & let you know how I get on
  10. Yeah that is basically the reason for it - for convenience I was hoping to make a more complex sleep so I can write (or copy-paste) less of my code Since this doesn't seem to work, I am currently writing out the ConditionalSleep, then adding additional sleeps after, and writing the mouse offscreen code each time, which, given the amount of sleeps code tends to do, is annoying! Trying to just call a single function that performs a sleep-cycle the way I want it to sleep - I can then make the function do things like consider fatigue & high intensity play periods, mouse offscreen, and even occasionally AFK-log, only by writing a simple function call I'm pretty new to Java tbh, it is not easy!
  11. I have been trying to write an effective custom sleep handler - I have commented through the method to make it clearer what the purpose of each stage is. I am having trouble with implementation on my latest attempt at a script - I find that when interacting it is tending to spam click when I don't expect that behaviour Any advice? (also free sample code if anyone can make use of it! :)) CS.java import org.osbot.rs07.utility.ConditionalSleep; import java.util.Random; import java.util.function.BooleanSupplier; import org.osbot.rs07.script.Script; public class CS extends ConditionalSleep { private final BooleanSupplier condition; private final Script script; private final int initialDurationMs; private final int additionalDurationMs; private final Random random = new Random(); public CS(Script script, int initialDurationMs, int additionalDurationMs, BooleanSupplier condition) { super(initialDurationMs + additionalDurationMs); this.initialDurationMs = initialDurationMs; this.additionalDurationMs = additionalDurationMs; this.condition = condition; this.script = script; } @Override public boolean condition() throws InterruptedException { boolean mouseOutOfScreen = false; // Small chance to move mouse out of screen immediately if (random.nextDouble() < 0.03) { script.getMouse().moveOutsideScreen(); mouseOutOfScreen = true; } // Capture the external condition to use inside the anonymous class BooleanSupplier localCondition = this.condition; // Small Sleep after action of ~ 300 - 800ms new ConditionalSleep(300 + random.nextInt(800 - 300), 100) { @Override public boolean condition() { return localCondition.getAsBoolean(); } }.sleep(); if(localCondition.getAsBoolean()) { // Small chance to move mouse out of screen after small wait if (random.nextDouble() < 0.10 && !mouseOutOfScreen) { script.getMouse().moveOutsideScreen(); mouseOutOfScreen = true; } // Sleep after the event is already true new ConditionalSleep(this.additionalDurationMs, 100) { @Override public boolean condition() { return false; } }.sleep(); } else { // Larger chance to move mouse out of screen after the condition is still not true if (random.nextDouble() < 0.50 && !mouseOutOfScreen) { script.getMouse().moveOutsideScreen(); mouseOutOfScreen = true; } // Sleep until the event is true, or until the timeout new ConditionalSleep(this.initialDurationMs, 100) { @Override public boolean condition() { return localCondition.getAsBoolean(); } }.sleep(); // Sleep after the event is already true new ConditionalSleep(this.additionalDurationMs, 100) { @Override public boolean condition() { return false; } }.sleep(); } return true; } } here is one example from the main script: (immediately inside onLoop method) for clarity: V just stores variables like V.worldBank is an area fatigueHandler is exactly what it sounds like - handles fatigue over time whilst playing which impacts the ms times it returns The minimum value for getSleepTimeMs() is 41ms However, clearly, from the script usage below, you can see that on bank.interact, it will either: 1) timeout after 5 seconds (in which case I haven't actually handled it yet) 2) succeed, in which case, it won't spam click anyway, since the bank will be open? Neither of these two possibilities involve spam clicking? Really appreciate any tips and advice on this if(V.worldBank.contains(myPlayer().getPosition()) && state == StateEngine.State.BANKING) { if(!getBank().isOpen()){ RS2Object bank = getNearestBank(); if(!bank.exists()){ log("Bank does not exist. Exiting."); onExit(); } bank.interact("Bank"); new CS(this, 5000, fatigueHandler.getSleepTimeMs(), () -> getBank().isOpen()); getBank().depositAll(); new CS(this, 3000, fatigueHandler.getShortSleepTimeMs(), () -> getInventory().isEmpty()); getBank().withdraw("Adamant pickaxe", 1); new CS(this, 3000, fatigueHandler.getShortSleepTimeMs(), () -> getInventory().contains("Adamant pickaxe")); getBank().close(); new CS(this, 3000, fatigueHandler.getShortSleepTimeMs(), () -> !getBank().isOpen()); return 20; } } Off topic, but bonus if anyone knows; regards random events, is there a way to implement only some specific ones and ignore the others? It seems awfully bot-like to just ignore all of them, particularly the genie and the free stuff ones like rick terpentine - don't want to solve any stupid events, but I know if I am playing legit I will just talk to those ones to get free stuff, would like to emulate that
  12. Thanks a lot for the tips, when I get enough gold for membership again I'l ltry that! Really appreciate the link; that randomGaussian method is a good idea for sleeps! Although I feel like I would add a base 50ms just because reaction time? I was also not aware of a conditionalSleep2 method - what is the difference?
  13. Never coded in Java before and first script! It's a really simple one, but hopefully somebody gets some use out of it Would really appreciate any feedback regards the code & methodology (but not planning to add features) *Note: membership ran out before I got widgets working, so its kind of a guess whether it works or not... Would appreciate widget help tips... It can be modified to just wait a period of time and then press 1 or something to bypass widgets (thats how I used it since they seem difficult to use) import java.util.List; import org.osbot.rs07.api.ui.Skill; import org.osbot.rs07.api.model.Item; import org.osbot.rs07.api.ui.RS2Widget; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.ConditionalSleep; @ScriptManifest(author = "Fanny", info = "Fletches arrow shafts and makes headless arrows", name = "Fanny Shafter", version = 1.0, logo = "") public class FannyShafter extends Script { private long startTime; private int startLevel; private long startXp; private final String[] logTypes = {"Logs", "Oak logs", "Willow logs", "Maple logs", "Yew logs", "Magic logs"}; private final int[] levelRequirements = {1, 15, 30, 45, 60, 75}; private String logType; private long lastAnimationTime = 0; @Override public void onStart() { // onStart logic remains unchanged } @Override public int onLoop() throws InterruptedException { if (shouldFletch()) { fletchArrowShafts(); } else if (shouldBank()) { handleBanking(); } else { stop(); } return random(200, 300); // Wait time before the loop starts over } private void handleBanking() throws InterruptedException { // Enhanced banking logic considering both logs and knife if (!getBank().isOpen() && !getBank().open()) return; new ConditionalSleep(5000, 1000) { @Override public boolean condition() throws InterruptedException { return getBank().isOpen(); } }.sleep(); if (!getInventory().contains("Knife") && getBank().contains("Knife")) { getBank().withdraw("Knife", 1); } else if(!getBank().contains("Knife") && !getInventory().contains("Knife")){ stop(); } for (String log : logTypes) { if (getBank().contains(log) && getSkills().getStatic(Skill.FLETCHING) >= getLevelRequirement(log)) { getBank().withdrawAll(log); break; } } getBank().close(); } private boolean shouldBank() { // Check if player needs to bank return !hasRequiredItemsForFletching(); } private boolean shouldFletch() { // Check if player can fletch return hasRequiredItemsForFletching(); } private boolean hasRequiredItemsForFletching() { // Check if the inventory contains a knife and any of the log types if (!getInventory().contains("Knife")) { return false; } for (String log : logTypes) { if (getInventory().contains(log) && getSkills().getStatic(Skill.FLETCHING) >= getLevelRequirement(log)) { return true; } } return false; } private int getLevelRequirement(String logType) { // Return the level requirement for the given log type for (int i = 0; i < logTypes.length; i++) { if (logTypes[i].equals(logType)) { return levelRequirements[i]; } } return 0; // Default to 0 if log type not found } private void fletchArrowShafts() throws InterruptedException { // Check bank is closed, then proceed to check logs & fletch if (getBank().isOpen()) closeBank(); for (String log : logTypes) { if (getInventory().contains(log) && getSkills().getStatic(Skill.FLETCHING) >= getLevelRequirement(log)) { Item logToUse = getInventory().getItem(log); handleFletching(logToUse); break; } } } private void handleFletching(Item log) throws InterruptedException { // Check if log is not null if (log == null) { return; } boolean knifeUsedFirst = random(0, 2) == 0; // Randomly decide whether to use the knife or the log first if (knifeUsedFirst ? getInventory().interact("Use", "Knife") : log.interact("Use")) { new ConditionalSleep(2000, 500) { @Override public boolean condition() throws InterruptedException { return getInventory().isItemSelected(); } }.sleep(); sleep(random(50, 300)); } if (knifeUsedFirst ? log.interact("Use") : getInventory().interact("Use", "Knife")) { sleep(random(100,300)); } new ConditionalSleep(5000, 1000) { @Override public boolean condition() throws InterruptedException { return isFletchingWidgetOpen(); } }.sleep(); sleep(random(100, 800)); RS2Widget fletchingWidget = getFletchingWidget(); if (fletchingWidget != null) { if (random(0, 100) < 25) { fletchingWidget.interact("15 arrow shafts"); } else { getKeyboard().typeKey((char) 49); } } sleep(random(800,2500)); getMouse().moveOutsideScreen(); final long[] lastAnimated = {System.currentTimeMillis()}; new ConditionalSleep(25000) { // Wait up to 25 seconds @Override public boolean condition() throws InterruptedException { // Check if the player is animating if(!getInventory().contains(logType)) { return true; } else if (myPlayer().isAnimating()) { // Update lastAnimated if the player is still animating lastAnimated[0] = System.currentTimeMillis(); } // Return true if more than 5 seconds have elapsed since lastAnimated return (System.currentTimeMillis() - lastAnimated[0]) > 5000; } }.sleep(); // AFK returning to screen exponentialBackoffSleep(); } private void exponentialBackoffSleep() throws InterruptedException{ final int duration = random(1,3) * random(1,3) * random(1,3) * random(1, 3) * random(100, 300); sleep(duration); } private boolean isFletchingWidgetOpen(){ if(getFletchingWidget() != null){ return true; } return false; } private RS2Widget getFletchingWidget() { List<RS2Widget> allWidgets = getWidgets().getAll(); RS2Widget storedWidget = allWidgets.stream().filter(w -> w.getWidth() == 52 && w.getHeight() == 52 && w.getItemId() == 52).findFirst().orElse(null); return storedWidget; } private void closeBank() throws InterruptedException { // Logic to close the bank getBank().close(); new ConditionalSleep(3000, 1000) { @Override public boolean condition() throws InterruptedException { return !getBank().isOpen(); } }.sleep(); } }
×
×
  • Create New...