Vlad 216 Share Posted November 24, 2014 This could have probably been made in a better way but I'm a fucking noob. Feel free to make suggestions on improving this below. package VladsRooftopAgility; import org.dreambot.api.methods.Calculations; import org.dreambot.api.methods.event.EventHandler; import org.dreambot.api.methods.event.PaintEvent; import org.dreambot.api.methods.map.Area; import org.dreambot.api.methods.map.Tile; import org.dreambot.api.methods.skills.Skill; import org.dreambot.api.methods.walking.WalkingImpl; import org.dreambot.api.script.AbstractScript; import org.dreambot.api.script.Category; import org.dreambot.api.script.ScriptManifest; import org.dreambot.api.utilities.Timer; import org.dreambot.api.utilities.impl.Condition; import org.dreambot.api.utilities.impl.Filter; import org.dreambot.api.wrappers.interactive.GameObject; import org.dreambot.api.wrappers.items.GroundItem; import java.awt.*; @ScriptManifest(name = "Vlad's Rooftop Agility", author = "Vlad", description = "Trains Agility on the rooftop courses.", version = 1.0, category = Category.AGILITY) public class VladsRooftopAgility extends AbstractScript { private Timer t = new Timer(); private String course = "Seer's Village"; private boolean start = true; private int marks = 0; @Override public void onStart() { } @Override public int onLoop() throws InterruptedException { if (!getClient().isLoggedIn()) { return 600; } if (start) { getSkillTracker().start(Skill.AGILITY); marks = getInventory().getCount("Mark of grace"); start = false; return 600; } GroundItem mark = getGroundItems().getClosest("Mark of grace"); if (course.equals("Seer's Village")) { final Area startArea = new Area(new Tile(2731, 3490, 0), new Tile( 2728, 3487, 0)); final Area area1 = new Area(new Tile(2730, 3497, 3), new Tile(2722, 3490, 3)); final Area area2 = new Area(new Tile(2714, 3496, 2), new Tile(2705, 3482, 2)); final Area area3 = new Area(new Tile(2716, 3482, 2), new Tile(2710, 3477, 2)); final Area area4 = new Area(new Tile(2716, 3476, 2), new Tile(2700, 3469, 2)); final Area area5 = new Area(new Tile(2703, 3466, 2), new Tile(2698, 3460, 2)); if (area5.contains(getLocalPlayer().getTile())) { if (mark != null && area5.contains(mark.getTile())) { mark.interact("Take"); sleepUntil(new Condition() { @Override public boolean verify() { return getGroundItems().getClosest("Mark of grace") == null; } }, Calculations.random(3000, 4000)); } else { GameObject edge = getGameObjects().getClosest("Edge"); if (edge != null) { if (edge.interact("Jump")) { sleepUntil(new Condition() { @Override public boolean verify() { return !area5.contains(getLocalPlayer() .getTile()); } }, Calculations.random(4000, 5000)); } } } } else if (area4.contains(getLocalPlayer().getTile())) { if (mark != null && area4.contains(mark.getTile())) { mark.interact("Take"); sleepUntil(new Condition() { @Override public boolean verify() { return getGroundItems().getClosest("Mark of grace") == null; } }, Calculations.random(3000, 4000)); } else { GameObject gap = getGameObjects().getClosest( new Filter<GameObject>() { @Override public boolean match(GameObject go) { return go != null && go.getName().equals("Gap") && go.getActions().length > 0 && area4.contains(go.getTile()); } }); if (gap != null) { if (gap.interact("Jump")) { sleepUntil(new Condition() { @Override public boolean verify() { return area5.contains(getLocalPlayer() .getTile()); } }, Calculations.random(5500, 6500)); } } } } else if (area3.contains(getLocalPlayer().getTile())) { if (mark != null && area3.contains(mark.getTile())) { mark.interact("Take"); sleepUntil(new Condition() { @Override public boolean verify() { return getGroundItems().getClosest("Mark of grace") == null; } }, Calculations.random(3000, 4000)); } else { GameObject gap = getGameObjects().getClosest("Gap"); if (gap != null) { if (gap.interact("Jump")) { sleepUntil(new Condition() { @Override public boolean verify() { return area4.contains(getLocalPlayer() .getTile()); } }, Calculations.random(5500, 6500)); } } } } else if (area2.contains(getLocalPlayer().getTile())) { if (mark != null && area2.contains(mark.getTile())) { mark.interact("Take"); sleepUntil(new Condition() { @Override public boolean verify() { return getGroundItems().getClosest("Mark of grace") == null; } }, Calculations.random(4000, 5000)); } else { GameObject rope = getGameObjects().getClosest("Tightrope"); if (rope != null) { if (rope.interact("Cross")) { sleepUntil(new Condition() { @Override public boolean verify() { return area3.contains(getLocalPlayer() .getTile()); } }, Calculations.random(9500, 10500)); } } } } else if (area1.contains(getLocalPlayer().getTile())) { if (mark != null && area1.contains(mark.getTile())) { mark.interact("Take"); sleepUntil(new Condition() { @Override public boolean verify() { return getGroundItems().getClosest("Mark of grace") == null; } }, Calculations.random(4000, 5000)); } else { GameObject gap = getGameObjects().getClosest("Gap"); if (gap != null) { if (gap.interact("Jump")) { sleepUntil(new Condition() { @Override public boolean verify() { return area2.contains(getLocalPlayer() .getTile()); } }, Calculations.random(6500, 7500)); } } } } else if (startArea.contains(getLocalPlayer().getTile())) { GameObject wall = getGameObjects().getClosest("Wall"); if (wall != null) { if (wall.interact("Climb-up")) { sleepUntil(new Condition() { @Override public boolean verify() { return area1.contains(getLocalPlayer() .getTile()); } }, Calculations.random(5000, 6000)); } } } else { getWalking().walkLocalTile(startArea.getRandomTile(), 0, 0, false); sleep(300); if (((((WalkingImpl) getWalking()).getDestination()) != null) && startArea.contains(((WalkingImpl) getWalking()) .getDestination())) { sleepUntil(new Condition() { @Override public boolean verify() { return !getLocalPlayer().isMoving(); } }, Calculations.random(5000, 6000)); } else { return Calculations.random(1800, 2400); } } } return Calculations.random(300, 600); } @EventHandler public void onPaint(PaintEvent e) { Graphics g = e.getGraphics(); g.setColor(Color.WHITE); g.setFont(new Font("Arial", 1, 11)); g.drawString("Time Running: " + t.formatTime(), 25, 50); g.drawString("Level: " + getSkills().getRealLevel(Skill.AGILITY) + " [+" + getSkillTracker().getGainedLevels(Skill.AGILITY) + "]", 25, 65); g.drawString( "XP Gained: " + getSkillTracker().getGainedExperience(Skill.AGILITY) + " [" + t.getHourlyRate((int) getSkillTracker() .getGainedExperience(Skill.AGILITY)) + "]", 25, 80); g.drawString( "Marks of Grace: " + (marks - getInventory().getCount("Mark of grace")) + " [" + t.getHourlyRate(marks - getInventory().getCount("Mark of grace")) + "]", 25, 95); } @Override public void onExit() { } } Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted November 24, 2014 This could have probably been made in a better way but I'm a fucking noob. Feel free to make suggestions on improving this below. final Area startArea = new Area(new Tile(2731, 3490, 0), new Tile( 2728, 3487, 0)); final Area area1 = new Area(new Tile(2730, 3497, 3), new Tile(2722, 3490, 3)); final Area area2 = new Area(new Tile(2714, 3496, 2), new Tile(2705, 3482, 2)); final Area area3 = new Area(new Tile(2716, 3482, 2), new Tile(2710, 3477, 2)); final Area area4 = new Area(new Tile(2716, 3476, 2), new Tile(2700, 3469, 2)); final Area area5 = new Area(new Tile(2703, 3466, 2), new Tile(2698, 3460, 2)); You should probably store that all in an enum or make them class properties. It makes no sense to recreate a constant every single script loop. With an enum you could create a value, such as SEERS, and store an array of obstacle properties in it (think that terminology makes sense I haven't done anything with Java in awhile). This way every script loop you can iterate over all of the selected courses properties and delegate off which one currently needs handling in a simple for loop. Also, you could literally shorten your code down by 200 lines if you'd just make a generic obstacle handling method.... Vlad 1 Link to comment Share on other sites More sharing options...
GoldenGates 72 Share Posted November 24, 2014 (edited) Lmao you created that every loop, try again Toph. And damn, that's kinda clusterfuck, you should clean the code up as Swizzboob said. Edited November 24, 2014 by GoldenGates Link to comment Share on other sites More sharing options...
Explicit 213 Share Posted November 24, 2014 Lmao you created that every loop, try again Toph. And damn, that's kinda clusterfuck, you should clean the code up as Swizzboob said. i prefer to be called jizzbeat goldengoober Link to comment Share on other sites More sharing options...
GoldenGates 72 Share Posted November 24, 2014 i prefer to be called jizzbeat goldengoober It's Goofy Goober for you. http://www.youtube.com/watch?v=VeNxh5t5dHg Link to comment Share on other sites More sharing options...
Nuclear Nezz 1993 Share Posted November 24, 2014 You should change this to use States. Make an enum for the roof tops. it'd be like public enum Roofs{ FIRST_ROOF(new Area(your tile stuff), "Obstacle name", "Obstacle action"); Roofs(Area roofArea, String obstacleName, String obstacleAction){constructor stuff}} ofc with your other getters and such. Then you'd have a getRoof() method which would loop through your Roofs enum. for(Roofs r : Roofs.values()){if(r.getArea().contains(getLocalPlayer().getTile()) return r;} return null; Then in your onLoop you'd have something like int onLoop(){login stuffRoofs r = getRoof(); GameObject obst = getGameObjects().getClosest(r.getObstacleName());if(obst != null){obst.interact("r.getObstacleAction());} return Calculations.random(600,900); } Once you expand to other roofs you of course would have to change your enum around. raptor and pharaoh 2 Link to comment Share on other sites More sharing options...
Vlad 216 Author Share Posted November 24, 2014 Thanks for the great feedback! After the next client update I'll update this with a better framework. I'll be making it AIO but the rest of it will not be open source. I'll only be updating this Seer's part. Nuclear Nezz 1 Link to comment Share on other sites More sharing options...
Chris 154 Share Posted November 24, 2014 The way I structured mine on the original OSBot: I made a class to store all of the course data, which used enums. From there, I loaded the course I wished to use. Each course used the same formatting so it was the same logic between all courses. The actual roof areas were easy to distinguish, as each area was located on a different level so none overlapped. I looped though the course areas to find which obstacle I was on. From there, I grabbed the location of the obstacle along with the name and action and used that to interact with it. Once my interact was complete, I positioned the camera in the direction of the next obstacle Link to comment Share on other sites More sharing options...
Glitch 73 Share Posted November 24, 2014 This will be a massive help for my first script! Thanks!!! Link to comment Share on other sites More sharing options...
Dogerina 330 Share Posted November 27, 2014 You should change this to use States. Make an enum for the roof tops. it'd be like public enum Roofs{ FIRST_ROOF(new Area(your tile stuff), "Obstacle name", "Obstacle action"); Roofs(Area roofArea, String obstacleName, String obstacleAction){constructor stuff} } ofc with your other getters and such. Then you'd have a getRoof() method which would loop through your Roofs enum. for(Roofs r : Roofs.values()){if(r.getArea().contains(getLocalPlayer().getTile()) return r;} return null; Then in your onLoop you'd have something like int onLoop(){ login stuff Roofs r = getRoof(); GameObject obst = getGameObjects().getClosest(r.getObstacleName()); if(obst != null){ obst.interact("r.getObstacleAction()); } return Calculations.random(600,900); } Once you expand to other roofs you of course would have to change your enum around. nice plural enum name cya nerds brb in 1 week _Josh 1 Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now