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
  • 30(ish) Line Agility Script


    Hopewelljnj
     Share

    Recommended Posts

    Dream challenged me to make a 30 line agility script. Unfortunately this turned out a hair too complex and it ended up being about 35-40 lines. Ill put the code below. There are no comments or anything extra so if you have questions feel free to ask.

     

    ---Line constituted as 80 characters ---

     

    It should run any course and continue to run it in circles. As you can see in the code there were a few obstacles that required special treatment. It has only been tested on canifis and below though.

     

     

     

     

     

    **Doesn't include imports and there is no paint. Can only be started directly in front of the first obstacle.

    **Turns out the second to last obstacle in draynor breaks it somehow.

    List<Integer> XObjects = new ArrayList<>(),YObjects = new ArrayList<>(),curObjectY = new ArrayList<>(),curObjectX = new ArrayList<>();    
        GameObject testObject,testTile,curObj,curObject,firstObject;
        List<GameObject> curObjects = new ArrayList<>(),currentObjects = new ArrayList<>(),firstObjects = new ArrayList<>();
        List<Tile> myTiles = new ArrayList<>(); Timer timer;
        int x = 0,y = 0,initX = 0,initY = 0,curX = 0,curY=0,Test = 1,prevZ = 0,index = 0,objSize = 0,prevXP = 0,tileX = 0,tileY = 0,initYaw = 0,initPitch = 0;
        @Override public void onStart(){initX = getLocalPlayer().getX();initY = getLocalPlayer().getY();initYaw=getCamera().getYaw();initPitch = getCamera().getPitch();}
        @Override public int onLoop(){       
            if(XObjects.size() >= 2 && getLocalPlayer().getTile() != null && getLocalPlayer().getTile().getZ() <= 0 && Test != 0){
                XObjects.clear();YObjects.clear();getCamera().rotateTo(initYaw,initPitch);
                while(getLocalPlayer().distance(getMap().getWalkable(firstObject.getTile()))>=1){getWalking().walk(firstObject);sleep(500,700);}
                sleepUntil(() -> getLocalPlayer().isStandingStill(),20000); return 2000;}
                GroundItem mark = getGroundItems().closest(i -> i != null && i.getName().toLowerCase().contains("grace"));
                if(mark != null)mark.interact();
                if(Test!=0){for(x = 0; x <= 2; x++){for(int b = 0; b < 2; b++){x = x*-1;
                    for(y = 0; y <= 2; y++){for(int a = 0; a < 2; a++){y = y*-1;
                        testObject = getGameObjects().closest(o -> o != null && o.getActions() != null && !firstObjects.contains(o) && !curObjects.contains(o) && curObjects.size() <= 0 && Arrays.stream(o.getActions()).filter(f -> f != null && !"null".equals(f)).count() >= 1 && !(XObjects.contains(o.getTile().getX()) && YObjects.get(XObjects.indexOf(o.getTile().getX())) == o.getTile().getY()) && o.getName() != null && !o.getName().equalsIgnoreCase("null") && (o.getTile() == null?false:getMap().canReach(new Tile(o.getTile().getX() + x,o.getTile().getY() + y))));
                        if(testObject != null && !"null".equals(testObject.getName()) && testObject.getName() != null){
                            log(testObject.getName() + "," + testObject.getTile() + "," + testObject.distance());
                            if(XObjects.size() <=0){firstObjects.add(testObject);if(testObject.distance() > 2)return 0; firstObject = testObject; }                        
                            myTiles.add(new Tile(testObject.getTile().getX() + x,testObject.getTile().getY() + y));
                            XObjects.add(testObject.getTile().getX());
                            curObjects.add(testObject);
                            YObjects.add(testObject.getTile().getY());
                            return Test = (XObjects.size() >= 2||YObjects.size()>=2)? 1:0;}}}}}}
                if((curObjects != null && !curObjects.isEmpty())){curObj = curObjects.get(0);}
                if(curObj != null){
                if(!curObj.getName().equals("Ledge") && (prevXP=getSkills().getExperience(Skill.AGILITY))!=0){while((!curObj.isOnScreen() || getLocalPlayer().distance(curObj) >= 5)){getWalking().walk(curObj); sleep(400,500);}}
                if(!getLocalPlayer().isStandingStill())sleep(300,500);
                if(getMap().canReach(myTiles.get(index))){prevZ = getLocalPlayer().getZ(); if(curObj.interact()){sleep(1000,2000);timer = new Timer();tileX=getLocalPlayer().getX();tileY=getLocalPlayer().getY();}else{curObj.interact();}}
                if(sleepUntil(() -> !getLocalPlayer().isMoving() && !getLocalPlayer().isAnimating() && (!getMap().canReach(curObj) || prevXP < getSkills().getExperience(Skill.AGILITY) || prevZ != getLocalPlayer().getZ()), 20000))log("Not timed out.");
                curObjects.clear();myTiles.clear();}
                while(curObj.getName().equals("Wall") && getLocalPlayer().getZ()== prevZ)sleep(500,1000);
                sleep(300,500);
            return Test=1;}
    

     

     

    Edited by Hopewelljnj
    Link to comment
    Share on other sites

    So it supposedly works for all of the rooftops except Draynor? I kinda wanna try it out :P

    At the end of your onLoop() you call: return Test=1; Since that operator is = and is not ==, what are you returning here? You set Test to 1, and that returns an int?

    Edited by Constuck
    Link to comment
    Share on other sites

    So it supposedly works for all of the rooftops except Draynor? I kinda wanna try it out :P

    At the end of your onLoop() you call: return Test=1; Since that operator is = and is not ==, what are you returning here? You set Test to 1, and that returns an int?

    It returns the value of test, 1.
    Link to comment
    Share on other sites

    So it supposedly works for all of the rooftops except Draynor? I kinda wanna try it out :P

    At the end of your onLoop() you call: return Test=1; Since that operator is = and is not ==, what are you returning here? You set Test to 1, and that returns an int?

     

     

    It returns the value of test, 1.

     

     

    Yep. Basically it was a linesaver.

    Link to comment
    Share on other sites

    • 1 month later...
    • 5 months later...

    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.