Hopewelljnj 46 Share Posted May 25, 2016 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;} Link to comment Share on other sites More sharing options...
Decipher 124 Share Posted May 25, 2016 git gud great work Link to comment Share on other sites More sharing options...
Constuck 13 Share Posted May 25, 2016 So it supposedly works for all of the rooftops except Draynor? I kinda wanna try it out 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? Link to comment Share on other sites More sharing options...
Dogerina 330 Share Posted May 26, 2016 So it supposedly works for all of the rooftops except Draynor? I kinda wanna try it out 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 More sharing options...
Hopewelljnj 46 Author Share Posted May 26, 2016 So it supposedly works for all of the rooftops except Draynor? I kinda wanna try it out 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 More sharing options...
Constuck 13 Share Posted May 26, 2016 Oh cool, never knew you could do that. Thanks for the info! Link to comment Share on other sites More sharing options...
jeppe116 0 Share Posted July 15, 2016 ok Link to comment Share on other sites More sharing options...
142512 0 Share Posted December 21, 2016 How do you use it? is it free? Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.