RandomKendal

[PkHonor] RDM SuperHeater

Jul 31st, 2015
507
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 7.29 KB | None | 0 0
  1. import java.awt.Color;
  2. import java.awt.Graphics;
  3. import java.awt.Graphics2D;
  4. import java.awt.Image;
  5. import java.io.IOException;
  6. import java.net.URL;
  7. import java.text.DecimalFormat;
  8. import java.util.ArrayList;
  9.  
  10. import javax.imageio.ImageIO;
  11.  
  12. import org.parabot.environment.api.interfaces.Paintable;
  13. import org.parabot.environment.api.utils.Time;
  14. import org.parabot.environment.api.utils.Timer;
  15. import org.parabot.environment.input.Mouse;
  16. import org.parabot.environment.scripts.Category;
  17. import org.parabot.environment.scripts.Script;
  18. import org.parabot.environment.scripts.ScriptManifest;
  19. import org.parabot.environment.scripts.framework.Strategy;
  20. import org.rev317.min.Loader;
  21. import org.rev317.min.api.methods.Game;
  22. import org.rev317.min.api.methods.Inventory;
  23. import org.rev317.min.api.methods.Menu;
  24. import org.rev317.min.api.methods.Npcs;
  25. import org.rev317.min.api.methods.SceneObjects;
  26. import org.rev317.min.api.methods.Skill;
  27. import org.rev317.min.api.wrappers.Item;
  28. import org.rev317.min.api.wrappers.Npc;
  29. import org.rev317.min.api.wrappers.SceneObject;
  30.  
  31. @ScriptManifest(
  32.         author = "Random (Kendal)",
  33.         category = Category.SMITHING,
  34.         description = "Super heats Rune Ore & Coal into Rune Bars. Start near a butler/bank with a Staff of Fire/Fire Runes and Nature Runes. Standard Spellbook is NOT required (Damn Mike, you have some sloppy coding).",
  35.         name = "RDM SuperHeater",
  36.         servers = { "PkHonor" },
  37.         version = 0.1
  38.         )
  39. public class RDMSuperHeater extends Script implements Paintable {
  40.  
  41.     private final ArrayList<Strategy> Strategies = new ArrayList<Strategy>();
  42.     private Timer scriptTimer = new Timer();
  43.     private ScriptManifest Manifest = (ScriptManifest) RDMSuperHeater.class.getAnnotation(ScriptManifest.class);
  44.  
  45.     DecimalFormat formatter = new DecimalFormat("#,###,###,###");
  46.    
  47.     int startExperience = Skill.SMITHING.getExperience();
  48.    
  49.     private static Image backgroundIMG;
  50.    
  51.     private static int COAL_ID = 454;
  52.     private static int RUNE_ORE_ID = 452;
  53.     private static int RUNE_BAR_ID = 2364;
  54.     private static int FIRE_RUNES_ID = 555;
  55.     private static int FIRE_STAFF_ID = 1388;
  56.     private static int NATURE_RUNES_ID = 562;
  57.    
  58.     private static int BANK_INTERFACE = 23350;
  59.     private static int WITHDRAW_ALL = 53;
  60.     private static int WITHDRAW_5 = 78;
  61.     private static int DEPOSIT_ALL = 432;
  62.    
  63.    
  64.     @Override
  65.     public boolean onExecute() {
  66.  
  67.         backgroundIMG = getImage("http://i.imgur.com/cciyTiy.png");
  68.        
  69.         Strategies.add(new OpenBank());
  70.         Strategies.add(new BankOre());
  71.         Strategies.add(new SuperHeat());
  72.        
  73.         provide(Strategies);
  74.        
  75.         int weaponID = Loader.getClient().getInterfaceCache()[1688].getItems()[3];
  76.         if(Inventory.getCount(true, NATURE_RUNES_ID) >= 1 && (weaponID == FIRE_STAFF_ID || Inventory.getCount(true, FIRE_RUNES_ID) >= 5))
  77.             return true;
  78.         else {
  79.             System.out.println("Make sure you got a Fire Staff or Fire Runes, and enough Natures!");
  80.             return false;
  81.         }
  82.     }
  83.    
  84.     public static Image getImage(String url) {
  85.         try {
  86.             return ImageIO.read(new URL(url));
  87.         } catch (IOException e) {
  88.             return null;
  89.         }
  90.     }
  91.    
  92.     @Override
  93.     public void onFinish() {
  94.         int endExperience = Skill.SMITHING.getExperience();
  95.         System.out.println("== " + Manifest.name() + " v" + Manifest.version() + " == ");
  96.        
  97.         System.out.println("Ran for: " + scriptTimer.toString());        
  98.         System.out.println("Experience gained: " + formatter.format((endExperience - startExperience)));
  99.         System.out.println("XP gained P/H: " + formatter.format(scriptTimer.getPerHour((endExperience - startExperience))));
  100.         System.out.println("=== Thanks for using! === ");
  101.     }
  102.    
  103.     @Override
  104.     public void paint(Graphics Graphs) {
  105.         Graphs.drawImage(backgroundIMG, 400, 5, null);
  106.        
  107.         Graphics2D g = (Graphics2D) Graphs;
  108.         g.setColor(Color.WHITE);
  109.         g.drawString(Manifest.name(), 407, 20);
  110.         g.drawString("Runtime: " + scriptTimer.toString(), 404, 36);
  111.         g.drawString("XP:", 405, 52);
  112.         g.drawString("P/H:", 404, 64);
  113.  
  114.         g.drawString(formatter.format((Skill.SMITHING.getExperience() - startExperience)), 434, 52);
  115.         g.drawString(formatter.format(scriptTimer.getPerHour((Skill.SMITHING.getExperience() - startExperience))), 434, 64);
  116.     }
  117.    
  118.     public class OpenBank implements Strategy {
  119.         @Override
  120.         public boolean activate() {
  121.             if((Inventory.getCount(COAL_ID) < 4 || Inventory.getCount(RUNE_ORE_ID) == 0) && Game.getOpenInterfaceId() != BANK_INTERFACE)
  122.                 return true;
  123.             return false;
  124.         }
  125.  
  126.         @Override
  127.         public void execute() {
  128.             SceneObject[] obj = SceneObjects.getNearest(2213);
  129.             if(obj.length > 0) {
  130.                 SceneObject bank = obj[0];
  131.                 bank.interact(0);
  132.                 sleep(bank.getLocation().distanceTo() * 500);
  133.                 return;
  134.             } else {
  135.                 Npc[] butler = Npcs.getNearest(4241);
  136.  
  137.                 if (butler.length > 0) {
  138.                     try {
  139.                         butler[0].interact(2);
  140.                         sleep(butler[0].getLocation().distanceTo() * 800);
  141.                         return;
  142.                     } catch(Exception _e) {
  143.                         System.out.println("Prevented an error! - Nulled NPC");
  144.                     }
  145.                 } else {
  146.                     System.out.println("Unable to find a valid bank/butler.");
  147.                 }
  148.             }
  149.             return;
  150.         }
  151.     }
  152.    
  153.     public class BankOre implements Strategy {
  154.         @Override
  155.         public boolean activate() {
  156.             if((Inventory.getCount(COAL_ID) < 4 || Inventory.getCount(RUNE_ORE_ID) == 0 || Inventory.getCount() != 28) && Game.getOpenInterfaceId() == BANK_INTERFACE)
  157.                 return true;
  158.             return false;
  159.         }
  160.  
  161.         @Override
  162.         public void execute() {        
  163.             if(Inventory.getCount(RUNE_BAR_ID) > 0) {
  164.                 Item[] RuneBar = Inventory.getItems(RUNE_BAR_ID);
  165.                 Menu.sendAction(DEPOSIT_ALL, RUNE_BAR_ID - 1, RuneBar[0].getSlot(), 5064);
  166.                 sleep(200);
  167.             } else if(Inventory.getCount(RUNE_ORE_ID) == 0) {
  168.                 if(Inventory.getCount(COAL_ID) > 0) {
  169.                     Item[] CoalOre = Inventory.getItems(COAL_ID);
  170.                     Menu.sendAction(DEPOSIT_ALL, COAL_ID - 1, CoalOre[0].getSlot(), 5064);
  171.                     sleep(200);
  172.                 }
  173.             }
  174.            
  175.             int[] bankIds = Loader.getClient().getInterfaceCache()[5382].getItems();
  176.             if(Inventory.getCount(RUNE_ORE_ID) == 0) {
  177.                 for (int i = 0; i < bankIds.length; i++) {
  178.                     if (bankIds[i] == RUNE_ORE_ID) {
  179.                         Menu.sendAction(WITHDRAW_5, RUNE_ORE_ID - 1, i, 5382);
  180.                         sleep(500);
  181.                         return;
  182.                     }
  183.                 }
  184.             } else {
  185.                 for (int i = 0; i < bankIds.length; i++) {
  186.                     if (bankIds[i] == COAL_ID) {
  187.                         Menu.sendAction(WITHDRAW_ALL, COAL_ID - 1, i, 5382);
  188.                         sleep(500);
  189.                         return;
  190.                     }
  191.                 }
  192.             }
  193.         }
  194.     }
  195.    
  196.     public class SuperHeat implements Strategy {
  197.         @Override
  198.         public boolean activate() {
  199.             if(Inventory.getCount(RUNE_ORE_ID) > 0 && Inventory.getCount(COAL_ID) >= 4 && Inventory.getCount(true, NATURE_RUNES_ID) >= 1)
  200.                 return true;
  201.             return false;
  202.         }
  203.  
  204.         @Override
  205.         public void execute() {
  206.             if (Game.getOpenInterfaceId() == 23350) {
  207.                 Mouse.getInstance().click(486, 27, true);
  208.                 sleep(200);
  209.                 return;
  210.             }
  211.            
  212.             Item[] RuneOre = Inventory.getItems(RUNE_ORE_ID);
  213.             if(RuneOre != null && Inventory.getCount(RUNE_ORE_ID) > 0) {
  214.                 try {
  215.                     Time.sleep(400);
  216.                     Menu.sendAction(626, RUNE_ORE_ID - 1, RuneOre.hashCode(), 1173);
  217.                     Time.sleep(400);
  218.                     Menu.sendAction(543, RUNE_ORE_ID - 1, RuneOre[RuneOre.length - 1].getSlot(), 3214);
  219.                     Time.sleep(400);
  220.                 } catch(Exception _e) {
  221.                     System.out.println("Prevented an error! - Nulled Items");
  222.                 }
  223.             }
  224.         }
  225.     }
  226. }
Advertisement
Add Comment
Please, Sign In to add comment