SHARE
TWEET

Astral RuneCrafter

SimmyProjects Aug 25th, 2019 (edited) 84 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.text.NumberFormat;
  2. import java.util.Locale;
  3. import java.awt.Color;
  4. import java.awt.Graphics;
  5. import xobot.script.wrappers.Widget;
  6. import xobot.script.wrappers.WidgetChild;
  7. import xobot.script.wrappers.interactive.GameObject;
  8. import xobot.script.wrappers.interactive.Item;
  9. import xobot.script.wrappers.interactive.NPC;
  10. import xobot.script.methods.GameObjects;
  11. import xobot.script.methods.NPCs;
  12. import xobot.script.methods.Bank;
  13. import xobot.script.methods.tabs.Inventory;
  14. import xobot.script.methods.tabs.Skills;
  15. import xobot.script.util.Time;
  16. import xobot.script.methods.Players;
  17. import xobot.script.methods.Packets;
  18. import xobot.script.methods.Widgets;
  19. import xobot.script.util.Timer;
  20. import xobot.script.Manifest;
  21. import xobot.client.callback.listeners.PaintListener;
  22. import xobot.script.ActiveScript;
  23.  
  24. @Manifest(authors = { "Simmy" }, name = "Astral Rune Crafter", description = "Will Make Astral Runes @ Home")
  25. public class AstralRuneCrafter extends ActiveScript implements PaintListener
  26. {
  27.     private Timer timer;
  28.     private int Item = 1436;
  29.     private int RCExp = 0;
  30.     public static int Rune_Crafted = 0;
  31.     String status = "Loading Data..";
  32.  
  33.     public boolean onStart() {
  34.         this.timer = new Timer();
  35.         this.RCExp = Skills.RUNECRAFTING.getCurrentExp();
  36.         return true;
  37.  }
  38.     //Add Variables Under Here
  39.     NPC Banker = NPCs.getNearest(494);
  40.     GameObject Altar = GameObjects.getNearest(17010);
  41.     Item Essence = Inventory.getItem(1436);
  42.            
  43.     public int loop() {
  44.         //FailSafe, If Not At Home;
  45.          if (Altar == null & Banker == null) {
  46.              status = "We Are Going Home!";
  47.              teleport("Edgeville");
  48.              Time.sleep(() -> Banker != null, 5000);
  49.              }
  50.           //Banking Stage;
  51.          if (Essence == null & Banker != null & Widgets.getOpenInterface() == -1) {
  52.              status = "Opening Banker!";
  53.              Banker.interact("Bank");
  54.              Time.sleep(() -> Widgets.getOpenInterface() == 5292, 3000);
  55.              }
  56.           //Withdrawing Stage;
  57.           if (Essence == null & Widgets.getOpenInterface() == 5292) {
  58.              status = "Withdrawing Essence!";
  59.              Time.sleep(850);
  60.              Bank.withdraw(Item, 28);
  61.              Time.sleep(() -> Inventory.isFull(), 600);
  62.              }
  63.            //Trying To Craft Rune;
  64.            if (Inventory.Contains(Item) & Altar != null & Players.getMyPlayer().getAnimation() == -1) {
  65.              status = "Attempting To Craft Runes!";
  66.              Altar.interact("Craft-rune");
  67.              Time.sleep(() -> Players.getMyPlayer().getAnimation() == 791, 2000);
  68.              }
  69.            //Pointless Wait Really;
  70.            if (Players.getMyPlayer().getAnimation() == 791) {
  71.               status = "Currently Runecrafting!";
  72.               Rune_Crafted += 27;
  73.               Time.sleep(() -> Essence == null, 500);
  74.          }
  75.        return 0;   
  76.    }
  77.    
  78.     //Paint Stage;
  79.     public void repaint(final Graphics g) {
  80.         final int RCXP = Skills.RUNECRAFTING.getCurrentExp() - this.RCExp;
  81.         final int RCXPs = (int) (RCXP * 3600000.0D / this.timer.getElapsed());
  82.         g.setColor(Color.white);
  83.         g.drawString("Runtime: " + this.timer.toElapsedString(), 330, 310);
  84.         g.drawString("Status: " + status, 330, 325);        
  85.         g.drawString("Astrals Crafted: " + Rune_Crafted, 330, 357);
  86.         g.drawString("RC Exp Gained: " + NumberFormat.getNumberInstance(Locale.US).format(RCXP), 330, 372);
  87.         g.drawString("RC Exp(hr): " + NumberFormat.getNumberInstance(Locale.US).format(RCXPs), 330, 387);
  88.         g.drawString("Astral Crafter by Simmy", 330, 402);
  89.     }
  90.    
  91.     //Teleporting Stage;
  92.     public boolean teleport(final String destination) {
  93.         final Widget container = Widgets.get(25411);
  94.         if (container != null) {
  95.             final WidgetChild[] children = container.getChildren();
  96.             WidgetChild[] array;
  97.             for (int length = (array = children).length, i = 0; i < length; ++i) {
  98.                 final WidgetChild child = array[i];
  99.                 final WidgetChild[] grandChildren = child.getChildren();
  100.                 WidgetChild[] array2;
  101.                 for (int length2 = (array2 = grandChildren).length, j = 0; j < length2; ++j) {
  102.                     final WidgetChild grandChild = array2[j];
  103.                     final String text = grandChild.getText();
  104.                     if (text != null && !text.isEmpty() && text.trim().toLowerCase().equals(destination.toLowerCase())) {
  105.                         Packets.sendAction(315, 0, 0, grandChild.getParentId() - 1);
  106.                         Time.sleep(500);
  107.                         return true;
  108.                     }
  109.                 }
  110.             }
  111.         }
  112.         return false;
  113.     }
  114. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top