Jump to content

Cheff

Trade With Caution
  • Posts

    5
  • Joined

  • Last visited

  • Feedback

    0%

Posts posted by Cheff

  1. 40 minutes ago, FrostBug said:

    I'd recommend creating a new class extending the default BreakManager, override shouldActivate with super.shouldActivate() && yourOwnCondition

    Then use RandomExecutor#overrideOSBotRandom to register your custom break manager.
    A few things to note when doing this:
    - It seems you must also override RandomSolver#getName
    - You should only attempt to override the break manager when the user has breaks enabled
    - You should remember to exchange contexts with your custom breakmanager instance before overriding

    Breaks are enabled when

    
    getRandomExecutor().forEvent(RandomEvent.BREAK_MANAGER)

    is not null

    Thanks for the reply, I have tried this but I keep getting this error when I stop the script. (Should activate is never called in the logs and only called once on stop before error trace)

    java.lang.NullPointerException
    	at org.osbot.rs07.randoms.BreakManager.shouldActivate(nk:108)
    	at CustomBreakManager.shouldActivate(CustomBreakManager.java:24)
    	at Runner.pause(Runner.java:205)
    	at org.osbot.rs07.event.ScriptExecutor.suspend(kl:433)
    	at org.osbot.rs07.event.ScriptExecutor.stop(kl:396)
    	at org.osbot.rs07.event.ScriptExecutor.stop(kl:324)
    	at org.osbot.Mb.run(rz:204)
    	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
    	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
    	at java.lang.Thread.run(Unknown Source)

    Also what do you mean by exchanging contexts? Perhaps it is related to this issue?

    This is my custom handler:

    import org.osbot.rs07.Bot;
    import org.osbot.rs07.randoms.BreakManager;
    import org.osbot.rs07.script.ScriptManifest;
    
    @ScriptManifest(
            name = "TestBreakManager",
            author = "Cheff",
            version = 1.1D,
            info = "Takes breaks",
            logo = ""
    )
    public class CustomBreakManager extends BreakManager {
    
        private Bot bot;
    
        public CustomBreakManager(Bot iIiiiiiiIiii) {
            super(iIiiiiiiIiii);
            this.bot = iIiiiiiiIiii;
        }
    
        @Override
        public boolean shouldActivate() {
            bot.getLogger().info("Pass");
            return super.shouldActivate() && true; //todo put logic here
        }
    
        @Override
        public String getName() {
            return "TestManager";
        }
    }

    and setting it up on start first thing like so:

    getBot().getRandomExecutor().overrideOSBotRandom(new CustomBreakManager(getBot()));

     

  2. 14 hours ago, Rays said:

    There's no way to use the inbuilt break handler when using combat scripts.

    Best write you own.

    To be sure we are on the same page, I am able to detect when the break manager failed to start. I want to be able to start it manually later when player is moved to a safe spot.

  3. 8 hours ago, Cheff said:

    New to the scene of scripting for oldschool and I have a couple of questions I have encountered during the development of my first script that I can't find an answer to on the site.

    1) Is there a way for the script to detect when a random event kicks in? Example BreakManager started

    2) When saving screenshots, is there a way to get a file stream of the saved image or the file name of the image? (method returns a bool only and cannot rely on the last image saved in folder if there are multiple bots running)

    3) More of a suggestion to follow up on 1), but I have the script fighting some NPCs which could take some time to kill, sometimes the break manager kicks in while the player is fighting and of course he cannot logout, after a few seconds it looks like the break manager is canceled, if I am able to detect when the script tried to fire the break manager, is there a way I can manually tell the script to trigger a break after the NPC died and I looted?

     

    To answer my own question:

    1)

    @Override
        public void pause() {
            if(bot.getRandomExecutor().forEvent(RandomEvent.BREAK_MANAGER).shouldActivate()) {
                isTakingABreak = true;
            }
        }

    2)

    getBot().getCanvas().getGameBuffer()

    3) Unsolved

  4. 4 minutes ago, Knuckolls said:

    joins 36 minutes ago, starts asking some questions directed at the Dev's without even knowing who they are. I'm gunna meme this and chock you up to:crown_gold.gif.44562d88e66cda63b7dda5023ef48fd3.gifwhen-jagex-bans-your-entire-bot-farm-spooky-runescape-memes-3204301.png.989c2f310145b4f0cb82340d5da93f24.png

    Had to create an account for me to post a thread, also by devs I mean other scripters (those developing a script) as well, dunno who the developers of Osbot are and didn't ask.

  5. New to the scene of scripting for oldschool and I have a couple of questions I have encountered during the development of my first script that I can't find an answer to on the site.

    1) Is there a way for the script to detect when a random event kicks in? Example BreakManager started

    2) When saving screenshots, is there a way to get a file stream of the saved image or the file name of the image? (method returns a bool only and cannot rely on the last image saved in folder if there are multiple bots running)

    3) More of a suggestion to follow up on 1), but I have the script fighting some NPCs which could take some time to kill, sometimes the break manager kicks in while the player is fighting and of course he cannot logout, after a few seconds it looks like the break manager is canceled, if I am able to detect when the script tried to fire the break manager, is there a way I can manually tell the script to trigger a break after the NPC died and I looted?

     

×
×
  • Create New...