Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • Try asking for help in the chatbox
  • Herb runner script


    smy
     Share

    Recommended Posts

    How everybody is doing ?

    I've actually always wanted to have herb runner script but I thought it would be too hard to make. But it actually happend and it wasn't that hard. Tbh the hardest part was GUI:

    paveikslas.png.99cf6c81cac7e07fcb5074ceb302d1ea.png yes, I forgot to add start button....

    It's not finished yet. But what can it do is to use different compost, plant different herb seed and it supports 3 locations ( my bot account does not have requirements for other locations, but I'll try to get them as soon as posible).

    My future goals:

    • Finish GUI functionality. It actually does nothing right now even if you change something.
    • Rework preparing system. Now it does not check if theres items in inventory or item equiped, script just takes everything from the bank.
    • Rework walking system. Bunch of ifs.... I would need to put every location in enum and take location from that.
    • Add support for teleporting. Now teleport to camelot is hard coded, would need to make that it would use teleport that user specified.
    • Stamina support.
    • Graceful support.
    • Muling.
    • GE restocking.

    I don't really know if I will release this script. At the moment I'm making it for fun and of course because I'm bored. And I guess that is for now. Cya and good luck!

     

    Edited by smy
    New bulletpoints
    Link to comment
    Share on other sites

    Update #1. Config class refactoring

    Before working on GUI Functionality first of all I need to rework my config class. It look something like this:

    Spoiler
    public static final Area DRAYNOR_BANK = new Area(0, 0, 0, 0);
    
    public static final Area FALADOR_PATCH = new Area(0, 0, 0, 0);
    public static final Area CATHERBY_PATCH = new Area(0, 0, 0, 0);
    public static final Area ARDOUGNE_PATCH = new Area(0, 0, 0, 0);
    
    public static boolean IS_PREPARED = false;
    public static Herbs HERBS_RUNNING = Herbs.HARRALANDER;
    public static Compost COMPOST_USING = Compost.ULTRACOMPOST;
    
    public static final Map<String, Integer> ITEM_TO_HAVE = new HashMap<>();
    
    public static int WHICH_CHARGE = 6;
    
    public static int FARMING_PATCH = 1; // 1 - falador, 2 - caterby, 3 - ardonge
    public static int PLANTING_STATE = 0;
    
    public static boolean HAVE_TELEPORTED = false;
    
    public static boolean IS_SLEEPING = false;
    public static long SLEEP_UNTIL = 0;

     

    This kind of config class can work, but if it works it does't mean that it can't be improved. First of all I moved Areas to enum:

    Spoiler
    public enum Locations {
        FALADOR_PATCH(new Area(0, 0, 0, 0)),
        CATHERBY_PATCH(new Area(0, 0, 0, 0)),
        ARDOUGNE_PATCH(new Area(0, 0, 0, 0));
    
        private Area area;
    
        Locations(Area area) { this.area = area; }
    
        public Area GetArea() { return area; }
    }

    Also for GUI I needed to create enum for all teleports:

    public enum  Teleports {
        NONE,
        FALADOR_TELEPORT_TABLET,
        FALADOR_TELEPORT_MAGIC,
        CAMELOT_TELEPORT_TABLET,
        CAMELOT_TELEPORT_MAGIC,
        ARDOUGNE_TELEPORT_TABLET,
        ARDOUGNE_TELEPORT_MAGIC
    }

     

    So just not to have two lists of Teleports and Locations (I'll need to save which locations user specified and which teleport they want to use to go there) I created class that combines those two enums:

    Spoiler
    public class LocationModel {
        public Locations location;
        public Teleports teleport;
    }

     

    Now I can add List<LocationModel> to the config class and delete all of the area variables. Later I'll remove static access to the variables, now it's just for testing.

    I know this is stuff is basic and self explanatory, but I always forgot to refactor a code and this is one of the reminders to refactor it.

    Link to comment
    Share on other sites

    Update #2. Finished with GUI and reworked walking system.

    GUI is finished. Nothing really changed just added a Start button and that button parses all the user input to config class.

    Also reworked walking system. Instead of ~150 lines of code it shrunk to 63. At first I had a int that would hold in which location player should be and walking script looked like this:

    Spoiler
    if(Constants.FARMING_PATCH == 0)
    {
      if(!Constants.HAVE_TELEPORTED)
    	doTeleport....
    
      if(Players.localPlayer().distance(Constants.SOME_PATCH.getCenter()) > 15)
        if(Walking.walk(Constants.SOME_PATCH.getCenter()))
        
    } else if(Constants.FARMING_PATCH == 1)
    {
      sameAsAbove....
    }
    ......

     

    In update #1 I made a LocationModel class which stores location and teleport enums and I said that in config class I store list of LocationModels. So now I can iterate thought the list and get individual LocationModel. After walking there I just pop from the list and take the next one.

    I haven't tested if it works it probably don't lol, but at this moment it does not really matters since I will be testing everything again.

    Link to comment
    Share on other sites

    Update #3. Reworked preparing system.

    This update will be pretty short. It was a simple step to rework it, just needed to check if all of the required items exist in inventory or equipment, if it don't just take it from the bank.

    I've also added support for teleporting. The way I did it it was to put all the teleportation methods in enum (look at update #1 for that) and then create a helper method that does something given the right enum value:

    Spoiler
    public static void ExecuteTeleport(Teleports teleport)
    {
    	switch (teleport)
    	{
    		case FALADOR_TELEPORT_TABLET:
    			....
    			break;
    		case FALADOR_TELEPORT_MAGIC:
    			....
    			break;
    		case CAMELOT_TELEPORT_TABLET:
    			....
    			break;
    		case CAMELOT_TELEPORT_MAGIC:
    			....
    			break;
    		...................
    	}
    }

     

    The problem with this is that I don't really know how to add support of teleporting, because maybe some user will want to use staff of air instead of air runes for camelot teleport. I think it limits the user and it looks more bot like. I will have to figure it out somehow.

    Now since all bullet points are done I'll need new ones. Need to add support for stamina potions for sure, as well support for graceful set. Mulling and GE restocking would be great. I'll put new bullet points if I came up with something new. So that's it for this update.

    Link to comment
    Share on other sites

    Update #4. Stamina support added.

    That one was pretty simple. I just took stamina from the bank and make it drink every 2 minutes. I don't know if it's the best way, but after drinking I just save current time + 2 minutes and if that time passes it drink it again. Maybe there are varbits for that ? Please let me know.

    I won't probably do any updates during the holidays I'll probably will be grinding for graceful set.

    Happy holidays!

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
     Share

    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.