Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Apr 10th, 2013  |  syntax: Groovy  |  size: 7.14 KB  |  views: 133  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. import java.awt.*
  2.  
  3. import org.osbot.script.Script
  4. import org.osbot.script.ScriptManifest
  5. import org.osbot.script.mouse.*
  6. import org.osbot.script.rs2.*
  7. import org.osbot.script.rs2.map.Position
  8. import org.osbot.script.rs2.model.GroundItem
  9. import org.osbot.script.rs2.model.Item
  10. import org.osbot.script.rs2.model.PrimaryObject
  11. import org.osbot.script.rs2.model.RS2Object
  12. import org.osbot.script.rs2.ui.*
  13.  
  14. import java.rmi.server.LogStream
  15.  
  16. @ScriptManifest(name = "LmapleChopper", author = "Linkcg0", version = 1.1D, info="Cuts maples at seers and banks them for you. Supports Bird's Nests. Made by Link.")
  17. class LmapleChopper extends Script {
  18.  
  19.     private final Color color = new Color(0, 0, 0)
  20.     private final Color rectColor = new Color(0.6f, 0.7f, 0.4f, 0.7f)
  21.     private final Font font = new Font("Georgia", 0, 18)
  22.         private final Image img1 = getImage("http://oi48.tinypic.com/29kw4rr.jpg")
  23.    
  24.     private Image getImage(String url) {
  25.         try {
  26.             return ImageIO.read(new URL(url))
  27.         } catch(IOException e) {
  28.             return null;
  29.         }
  30.             }
  31.  
  32.     void onExit() {
  33.         log("Maplechopper by link")
  34.     }
  35.  
  36.     int[] bankId = 25808
  37.     int[] axeIds = [1352, 1360, 1350, 1354, 1362, 1358, 1356]
  38.     int[] treeId = 1307
  39.     int[] nests = [5071, 5072, 5073, 5074, 5075, 5070, 7413, 5076]
  40.  
  41.     enum State {
  42.         IDLE, CHOPPING, WALK_TO_BANK, PIN, BANKING, WALK_TO_MAPLES, CLOSE_BANK
  43.     }
  44.     def nearestevilTree = null
  45.     def evilTree = 1735
  46.     def maples = 0
  47.     def state = State.IDLE
  48.     def currentTree = !null
  49.     def starttime = null;
  50.  
  51.     void onStart() {
  52.  
  53.         starttime = System.currentTimeMillis()
  54.  
  55.         if (client.getInventory().isFull())
  56.             state = State.WALK_TO_BANK
  57.     }
  58.  
  59.     int onLoop() {
  60.  
  61.         switch (state) {
  62.             case State.IDLE:
  63.                 return onIdle()
  64.             case State.CHOPPING:
  65.                 return onChopping()
  66.             case State.WALK_TO_BANK:
  67.                 return walkToBank()
  68.             case State.BANKING:
  69.             return bank()
  70.             case State.CLOSE_BANK:
  71.                 return closeBank()
  72.             case State.WALK_TO_MAPLES:
  73.                 return walkToMaples()
  74.         }
  75.         return 300 + random(500)
  76.     }
  77.  
  78.     int onIdle() {
  79.         if (!client.getMyPlayer().isAnimating()) {
  80.             state = State.WALK_TO_MAPLES
  81.         }
  82.         else if (client.getBank().isOpen()) {
  83.             client.getBank().close()
  84.             state = State.WALK_TO_MAPLES
  85.         }
  86.         else if (client.getInventory().isFull()) {
  87.             state = State.WALK_TO_BANK
  88.             //client.moveCameraToEntity(closestObject(bankId))
  89.             return 500 + gRandom(100, 400)
  90.         }
  91.             if (random(10) == 0) {
  92.                 client.moveCameraToEntity(currentTree)
  93.                 sleep(3000 + gRandom(500, 200))
  94.             }
  95.         return 100 + gRandom(600, 500);
  96.     }
  97.  
  98.     int onChopping() {
  99.         nearestevilTree = closestObject(evilTree)
  100.  
  101.         if (client.getInventory().isFull()) {
  102.             state = State.WALK_TO_BANK
  103.             //client.moveCameraToEntity(closestObject(bankId))
  104.             return 300 + gRandom(100, 400)
  105.         }
  106.         if (random(60) == 0 && currentTree != null && currentTree.exists())
  107.             antiban()
  108.             client.moveCameraToEntity(currentTree)
  109.         if (currentTree == null) {
  110.             state = State.IDLE
  111.             log("Chopped down Maple!")
  112.             return 500 + gRandom(1000, 500)
  113.         }
  114.         if (!currentTree.exists()) {
  115.             state = State.IDLE
  116.             currentTree = null
  117.             log("Chopped down Maple!")
  118.         }
  119.         if (nearestevilTree != null) {
  120.             log("Found Evil tree. Banking logs.")
  121.             state = State.WALK_TO_BANK
  122.         }
  123.         return 500 + gRandom(100, 500)
  124.     }
  125.  
  126.     int walkToBank() {
  127.         selectEntityOption(closestObject(bankId), "Bank", "Bank booth")
  128.         sleep(8000 + gRandom(300, 50))
  129.         if (client.getBank().isOpen())
  130.             state = State.BANKING
  131.         return 200 + gRandom(100, 200)
  132.     }
  133.  
  134.     int bank() {
  135.         selectInventoryOption(client.inventory.getSlotForId(1518), "Store All")
  136.         state = State.CLOSE_BANK
  137.         return 500 + gRandom(200, 300)
  138.     }
  139.     int closeBank() {
  140.         client.getBank().close()
  141.         state = State.WALK_TO_MAPLES
  142.         return 500 + gRandom(200, 300)
  143.     }
  144.  
  145.     int antiban() {
  146.         log("Starting antiban.")
  147.         if (currentTab() != Tab.SETTINGS){
  148.             openTab(Tab.SETTINGS)
  149.             sleep(5000 + gRandom(300, 50))
  150.             openTab(Tab.MUSIC)
  151.         }
  152.         return 500 + gRandom(200, 300)
  153.     }
  154.  
  155.     int walkToMaples() {
  156.         log("Walking to Maple trees")
  157.         currentTree = closestObject(treeId)
  158.         if (currentTree != null) {
  159.             log("Found Maple tree.")
  160.             selectEntityOption(currentTree, "Chop down", "Maple tree")
  161.             client.moveCameraToEntity(currentTree)
  162.             sleep(3000 + gRandom(500, 200))
  163.  
  164.         }
  165.         return 200 + gRandom(800, 300)
  166.     }
  167.  
  168.     void onPaint(Graphics g) {
  169.         g.setColor(rectColor)
  170.         g.fillRect(250, 200, 266, 138)
  171.         g.setFont(font)
  172.         g.setColor(color)
  173.                 g.drawImage(img1, 1, 339, null)
  174.         g.drawString("Maples Cut: ${maples}", 290, 300)
  175.        g.drawString("Time: " + format(System.currentTimeMillis() - starttime), 290, 330)
  176.     }
  177.  
  178.        
  179.  
  180.     String format(final long time) {
  181.         final StringBuilder t = new StringBuilder();
  182.         final long total_secs = time / 1000;
  183.         final long total_mins = total_secs / 60;
  184.         final long total_hrs = total_mins / 60;
  185.         final int secs = (int) total_secs % 60;
  186.         final int mins = (int) total_mins % 60;
  187.         final int hrs = (int) total_hrs % 24;
  188.         if (hrs < 10) {
  189.             t.append("0");
  190.         }
  191.         t.append(hrs);
  192.         t.append(":");
  193.         if (mins < 10) {
  194.             t.append("0");
  195.         }
  196.         t.append(mins);
  197.         t.append(":");
  198.         if (secs < 10) {
  199.             t.append("0");
  200.         }
  201.         else if (secs < 0){
  202.             t.append("0")
  203.         }
  204.         else{
  205.             t.append(secs);
  206.         }
  207.         return t.toString();
  208.     }
  209.  
  210.  
  211.     void onMessage(String message) {
  212.         if (message == "You swing your axe at the tree.") {
  213.             log("Chopping down tree!")
  214.             state = State.CHOPPING
  215.         } else if (message == "You get some logs.") {
  216.             state = State.IDLE
  217.         } else if (message == "Your inventory is too full to hold any more logs.") {
  218.             log("Banking!")
  219.             state = State.WALK_TO_BANK
  220.         } else if (message == "You get some maple logs.") {
  221.             maples++
  222.         } else if (message == "A bird's nest falls out of the tree.") {
  223.             //selectEntityOption(nests, "Pick up", "Bird's nest")
  224.             log("Found Bird's Nest!")
  225.             sleep(1000 + gRandom(300, 50))
  226.             log("Hook is currently broken...")
  227.             sleep(1000 + gRandom(300, 50))
  228.             log("Oh well...no nest for you.")
  229.             state = State.IDLE
  230.  
  231.         }
  232.     }
  233. }
clone this paste RAW Paste Data