Cockiezi Posted January 24, 2015 Share Posted January 24, 2015 (edited) Hi guys, I just made my first script and it's an agility script for canifis rooftop course. It has shitty paint and is probably shitty overall, but so far it seems to be working well enough. (I got 45-50 agility while testing it) Here's the DL link: http://www.gamefront.com/files/24754837/CANIFISROOFTOPAGILITYSCRIPTERINO.rar Here's the code if u dont wanna DL it: import org.osbot.rs07.api.LocalWalker; import org.osbot.rs07.api.map.Position; import org.osbot.rs07.api.model.Entity; import org.osbot.rs07.api.model.GroundItem; import org.osbot.rs07.script.Script; import org.osbot.rs07.script.ScriptManifest; import org.osbot.rs07.utility.Area; import org.osbot.rs07.api.ui.Skill; import java.awt.*; @ScriptManifest(author = "You", info = "My first script", name = "Canifis rooftop agility", version = 0, logo = "") public class main extends Script { Position gapEfail = new Position(3506, 3477, 0); Position gapCfail = new Position(3482, 3499, 0); Position resetMiddle = new Position(3495, 3491, 0); Position[] middlepath = { new Position(3492, 3493, 0), new Position(3500, 3491, 0) }; int waitCycles = 0; Area AREA_TREE1 = new Area(3500, 3494, 3503, 3484); Area AREA_TREE2 = new Area(3504, 3489, 3515, 3484); Area AREA_A1 = new Area(3505, 3497, 3508, 3495); Area AREA_A2 = new Area(3506, 3494, 3507, 3492); Area AREA_A3 = new Area(3509, 3496, 3510, 3495); Area AREA_A4 = new Area(3508, 3494, 3508, 3494); Area AREA_B1 = new Area(3497, 3506, 3503, 3504); Area AREA_C1 = new Area(3490, 3504, 3492, 3499); Area AREA_C2 = new Area(3487, 3501, 3489, 3499); Area AREA_D1 = new Area(3475, 3499, 3479, 3492); Area AREA_Pole1 = new Area(3478, 3486, 3480, 3482); Area AREA_Pole2 = new Area(3481, 3486, 3483, 3485); Area AREA_E1 = new Area(3489, 3476, 3503, 3472); Area AREA_E2 = new Area(3489, 3471, 3501, 3469); Area AREA_E3 = new Area(3491, 3478, 3497, 3477); Area AREA_F1 = new Area(3510, 3482, 3511, 3475); Area AREA_F2 = new Area(3512, 3482, 3515, 3476); Area AREA_F3 = new Area(3509, 3481, 3509, 3479); Area gapA = new Area(3505, 3500, 3506, 3497); Area gapB = new Area(3496, 3505, 3497, 3503); Area gapC = new Area(3485, 3500, 3486, 3498); Area gapD = new Area(3478, 3492, 3478, 3491); Area gapE = new Area(3503, 3477, 3504, 3475); Area gapF = new Area(3510, 3483, 3510, 3483); GroundItem mog = null; String gState = ""; private int beginningXP; private int currentXP; private int xpGained; @Override public void onStart() { log("Let's get started!"); mouse.setSpeed(3); beginningXP = skills.getExperience(Skill.AGILITY); } private enum State { TREE, GAP_A, GAP_B, GAP_C, GAP_D, POLE, GAP_E, GAP_F, RESTART, LOOT, WAIT }; public void JGap(Area gapArea) throws InterruptedException{ Entity GAP = objects.closest(gapArea, "Gap"); if (GAP != null){ if (!GAP.isVisible()){ double dist = ((GAP.getPosition().distance(myPlayer().getPosition()))); if (dist >=15){ if(!getLocalWalker().getSettings().isRunning()){ getLocalWalker().settings.setRunning(true); sleep(random(25,75)); } Position walkTo = new Position(gapArea.getRandomPosition(GAP.getPosition().getZ())); if (!walkTo.isOnMiniMap(this.bot)){ if (walkTo.getX() > myPlayer().getPosition().getX()){ walkTo = new Position((walkTo.getX()-(random(3, 5))), (walkTo.getY()), walkTo.getZ()); } if(walkTo.getX() < myPlayer().getPosition().getX()){ walkTo = new Position((walkTo.getX()+(random(3,5))), (walkTo.getY()), walkTo.getZ()); } getLocalWalker().walk(walkTo); } if(gapArea==gapE){ walkTo = new Position ((GAP.getPosition().getX() - (random(2, 5))), (GAP.getPosition().getY() + (random(-1, 2))), GAP.getPosition().getZ()); getLocalWalker().walk(walkTo); sleep(random(800, 1400)); } sleep(random(1000,1200)); } camera.toEntity(GAP); } sleep(random(100,200)); if (!myPlayer().isAnimating() && (!myPlayer().isMoving())){ GAP.interact("Jump"); sleep(random(700, 800)); while (myPlayer().isMoving()){ sleep(random(150,250)); if(!myPlayer().isMoving()){ sleep(random(800,1200)); } } } } GAP = null; } private State getState() { if (!myPlayer().isAnimating()){ mog = groundItems.closest(11849); if (AREA_TREE1.contains(myPlayer().getPosition()) || (AREA_TREE2.contains(myPlayer().getPosition()))){ if (mog != null){ if (AREA_TREE1.contains(mog) || (AREA_TREE2.contains(mog))){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.TREE; } if ((AREA_A1.contains(myPlayer().getPosition()) || (AREA_A2.contains(myPlayer().getPosition())) || (AREA_A3.contains(myPlayer().getPosition())) || (AREA_A4.contains(myPlayer().getPosition()))) && (myPlayer().getPosition().getZ() == 2)){ if (mog !=null){ if ((AREA_A1.contains(mog) || (AREA_A2.contains(mog)) || (AREA_A3.contains(mog)) || (AREA_A4.contains(mog))) && (mog.getPosition().getZ() == 2)){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.GAP_A; } if ((AREA_B1.contains(myPlayer().getPosition())) && (myPlayer().getPosition().getZ() == 2)){ if(mog!=null){ if ((AREA_B1.contains(mog)) && (mog.getPosition().getZ() == 2)){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.GAP_B; } if ((AREA_C1.contains(myPlayer().getPosition()) || (AREA_C2.contains(myPlayer().getPosition()))) && (myPlayer().getPosition().getZ() == 2)){ if (mog!=null){ if ((AREA_C1.contains(mog) || (AREA_C2.contains(mog))) && (mog.getPosition().getZ() == 2)){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.GAP_C; } if ((AREA_D1.contains(myPlayer().getPosition())) && (myPlayer().getPosition().getZ() == 3)){ if (mog!=null){ if ((AREA_D1.contains(mog)) && (mog.getPosition().getZ() == 3)){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.GAP_D; } if ((AREA_Pole1.contains(myPlayer().getPosition()) || (AREA_Pole2.contains(myPlayer().getPosition()))) && (myPlayer().getPosition().getZ() == 2)){ if(mog!=null){ if ((AREA_Pole1.contains(mog) || (AREA_Pole2.contains(mog))) && (mog.getPosition().getZ() == 2)){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.POLE; } if ((AREA_E1.contains(myPlayer().getPosition())) && (myPlayer().getPosition().getZ() == 3)){ if(mog!=null){ if ((AREA_E1.contains(mog)) && (mog.getPosition().getZ() == 3)){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.GAP_E; } if ((AREA_F1.contains(myPlayer().getPosition())) && (myPlayer().getPosition().getZ() == 2)){ if (mog!=null){ if ((AREA_F1.contains(mog)) && (mog.getPosition().getZ() == 2)){ waitCycles = 0; return State.LOOT; } } waitCycles = 0; return State.GAP_F; } if (gapCfail.equals(myPlayer().getPosition()) || waitCycles >80){ if(waitCycles>80){ log("Wait cycles: " + waitCycles); log("Setting state to RESTART"); } waitCycles = 0; return State.RESTART; } if(gapEfail.equals(myPlayer().getPosition())){ waitCycles = 0; return State.TREE; } Entity TREEcheck = objects.closest("Tall tree"); if(TREEcheck !=null ){ waitCycles = 0; return State.TREE; } } return State.WAIT; } @Override public int onLoop() throws InterruptedException { switch (getState()){ case WAIT: gState="WAIT"; sleep((random(200, 300))); if (myPlayer().isMoving() || (myPlayer().isAnimating())){ if (random(1,5)==3){ mouse.moveRandomly(random(100,300)); } sleep((random(200, 300))); } waitCycles++; break; case TREE: gState = "TREE"; Entity TREE = objects.closest("Tall tree"); if (TREE != null && (TREE.getPosition().getZ() == 0)){ if (!TREE.isVisible()){ camera.toEntity(TREE); sleep(random(200, 300)); } if (TREE.getPosition().distance(myPlayer().getPosition()) >=12){ getLocalWalker().walk(TREE.getPosition()); sleep(random(400,600)); } if (!myPlayer().isAnimating() && (!myPlayer().isMoving())){ TREE.interact("Climb"); sleep(random(1000,2000)); } } sleep(random(100,200)); break; case GAP_A: gState = "GAP_A"; JGap(gapA); break; case GAP_B: gState = "GAP_B"; JGap(gapB); break; case GAP_C: gState = "GAP_C"; JGap(gapC); break; case GAP_D: gState = "GAP_D"; JGap(gapD); break; case POLE: gState = "POLE"; Entity POLE = objects.closest("Pole-vault"); if (POLE != null){ while (!POLE.isVisible()){ camera.toEntity(POLE); sleep(random(300, 400)); } if (!myPlayer().isAnimating() && (!myPlayer().isMoving())){ int counts = 0; while (!myPlayer().isAnimating() || !myPlayer().isMoving()){ if (counts>1){ camera.moveYaw(random(-60, 60)); sleep(random(400,600)); } camera.toEntity(POLE); POLE.interact("Vault"); sleep(random(2000, 3000)); counts++; } } } break; case GAP_E: gState = "GAP_E"; JGap(gapE); break; case GAP_F: gState = "GAP_F"; JGap(gapF); break; case RESTART: gState = "RESTART: Run back to start"; LocalWalker lw = getLocalWalker(); lw.walkPath(middlepath); middlepath[0] = new Position((3492+(random(-3, 3))), (3493+(random(-3, 3))), 0); middlepath[1] = new Position((3500+(random(-3, 3))), (3491+(random(-3, 3))), 0); sleep(random(300,400)); break; case LOOT: if (mog!=null){ if (!mog.isVisible()){ camera.toEntity(mog); sleep(random(200,300)); } double sleepamt = (mog.getPosition().distance(myPlayer().getPosition())); if(getSettings().isRunning()){ sleepamt = sleepamt*0.3; } else { sleepamt = sleepamt*0.6; } sleepamt = (int) (random(-300, 300) + (1000*sleepamt)); log("Mark of grace found, interacting and sleeping for: " + (sleepamt) + "ms"); mog.interact("Take"); sleep((int)sleepamt); } sleep(random(300,500)); break; default: gState="default (WAIT)"; sleep((random(200, 300))); if (myPlayer().isMoving() || (myPlayer().isAnimating())){ if (random(1,5)==3){ mouse.moveRandomly(random(100,300)); } sleep(random(200, 300)); } break; } return random(100,200); } @Override public void onExit() { log("Thanks for running my RTA"); log("Experience gained: " + xpGained); } @Override public void onPaint(Graphics2D g) { currentXP = skills.getExperience(Skill.AGILITY); xpGained = currentXP - beginningXP; g.drawString("EXPERIENCE GAINED: " + xpGained, 50, 180); g.drawString(("State: " + gState), 50, 120); g.drawString(("Animation ID: " + myPlayer().getAnimation()), 50, 150); } } Edited January 24, 2015 by Cockiezi Link to comment Share on other sites More sharing options...
Novak Posted January 24, 2015 Share Posted January 24, 2015 put those areas in an enum Link to comment Share on other sites More sharing options...
Cockiezi Posted January 24, 2015 Author Share Posted January 24, 2015 put those areas in an enum I still don't understand how it works lolo Link to comment Share on other sites More sharing options...