Advertisement
Guest User

Untitled

a guest
Jun 28th, 2017
67
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 6.51 KB | None | 0 0
  1. import impsoft.bots.ColorBot;
  2. import impsoft.scripting.ibot.enums.BotStates;
  3. import impsoft.scripting.ibot.enums.Skill;
  4. import impsoft.scripting.types.ColorRandom;
  5. import impsoft.utils.general.Timer;
  6.  
  7. import java.awt.Rectangle;
  8. import java.awt.image.BufferedImage;
  9. import java.io.File;
  10. import java.io.IOException;
  11.  
  12. import javax.imageio.ImageIO;
  13.  
  14. public class AutoScreenshot extends ColorRandom {
  15.  
  16.     public AutoScreenshot(ColorBot ava) {
  17.         super(ava);
  18.     }
  19.  
  20.     public final String author = "Avaryan";
  21.     public final double version = 2.10;
  22.  
  23.     int[] levels = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  24.             0, 0, 0, 0, 0, 0 };
  25.  
  26.     public void random() throws InterruptedException {
  27.         Timer t = new Timer(10000);
  28.         boolean complete = false;
  29.         log("Starting AutoScreenshot");
  30.         while (!complete && t.isNotUp()) {
  31.             for (int i = 0; i < levels.length; i++) {
  32.                 if (levels[i] != getLevels()[i]) {
  33.                     log(getName()[i] + " increased from "
  34.                             + (getLevels()[i] - 1) + " to " + getLevels()[i]);
  35.                     openSkillBanner(i);
  36.                     takeShot(getName()[i], modLevel(getLevels()[i]));
  37.                     closeSkillBanner();
  38.                 }
  39.                 t.reset();
  40.             }
  41.             complete = true;
  42.         }
  43.         levels = getLevels();
  44.     }
  45.  
  46.     enum skill {
  47.         ATTACK(0, "Attack", Skill.ATTACK, 1), STRENGTH(1, "Strength",
  48.                 Skill.STRENGTH, 4), DEFENSE(2, "Defense", Skill.DEFENSE, 21), RANGED(
  49.                 3, "Ranged", Skill.RANGED, 45), PRAYER(4, "Prayer",
  50.                 Skill.PRAYER, 69), MAGIC(5, "Magic", Skill.MAGIC, 86), RUNECRAFTING(
  51.                 6, "Runecrafting", Skill.RUNECRAFTING, 103), CONSTRUCTION(7,
  52.                 "Construction", Skill.CONSTRUCTION, 127), DUNGEONEERING(8,
  53.                 "Dungeoneering", Skill.DUNGEONEERING, 151), CONSTITUTION(9,
  54.                 "Constitution", Skill.HITPOINTS, 2), AGILITY(10, "Agility",
  55.                 Skill.AGILITY, 12), HERBLORE(11, "Herblore", Skill.HERBLORE, 29), THIEVING(
  56.                 12, "Thieving", Skill.THIEVING, 53), CRAFTING(13, "Crafting",
  57.                 Skill.CRAFTING, 77), FLETCHING(14, "Fletching",
  58.                 Skill.FLETCHING, 94), SLAYER(15, "Slayer", Skill.SLAYER, 111), HUNTER(
  59.                 16, "Hunter", Skill.HUNTER, 135), MINING(17, "Mining",
  60.                 Skill.MINING, 3), SMITHING(18, "Smithing", Skill.SMITHING, 20), FISHING(
  61.                 19, "Fishing", Skill.FISHING, 37), COOKING(20, "Cooking",
  62.                 Skill.COOKING, 61), FIREMAKING(21, "Firemaking",
  63.                 Skill.FIREMAKING, 85), WOODCUTTING(22, "Woodcutting",
  64.                 Skill.WOODCUTTING, 102), FARMING(23, "Farming", Skill.FARMING,
  65.                 119), SUMMONING(24, "Summoning", Skill.SUMMONING, 143);
  66.  
  67.         private int index;
  68.         private String name;
  69.         private Skill s;
  70.         private int sub;
  71.  
  72.         skill(int index, String name, Skill s, int sub) {
  73.             this.index = index;
  74.             this.name = name;
  75.             this.s = s;
  76.             this.sub = sub;
  77.         }
  78.  
  79.         public int getIndex() {
  80.             return index;
  81.         }
  82.  
  83.         public String getName() {
  84.             return name;
  85.         }
  86.  
  87.         public Skill getSkill() {
  88.             return s;
  89.         }
  90.  
  91.         public int getSubIndex() {
  92.             return sub;
  93.         }
  94.  
  95.     }
  96.  
  97.     public String modLevel(int i) {
  98.         if (i < 10) {
  99.             return "0" + i;
  100.         } else
  101.             return "" + i;
  102.     }
  103.  
  104.     public boolean isSkillBannerUp() throws InterruptedException {
  105.         if (isInterfaceNotNullAndValid(741, 5)) {
  106.             try {
  107.                 if (getAllInterfaces()[741][5].getText().contains("Congrat")) {
  108.                     return true;
  109.                 } else
  110.                     return false;
  111.             } catch (ArrayIndexOutOfBoundsException e) {
  112.                 return false;
  113.             }
  114.         } else
  115.             return false;
  116.     }
  117.  
  118.     public void closeSkillBanner() throws InterruptedException {
  119.         Timer t = new Timer(3000);
  120.         while (isSkillBannerUp() && t.isNotUp()) {
  121.             try {
  122.                 if (isInterfaceNotNullAndValid(741, 9)) {
  123.                     mouseClickLeft(getAllInterfaces()[741][9]
  124.                             .getCalculatedArea3());
  125.                 }
  126.             } catch (ArrayIndexOutOfBoundsException e) {
  127.             }
  128.         }
  129.     }
  130.  
  131.     public String getPlayerName() {
  132.         String s = "";
  133.         String t = "";
  134.         if (isInterfaceNotNullAndValid(137, 55)) {
  135.             try {
  136.                 if (getAllInterfaces()[137][55].getText().contains("<img")) {
  137.                     t = getAllInterfaces()[137][55].getText();
  138.                     int i = t.length() - 21;
  139.                     s = t.substring(0, i);
  140.                 }
  141.             } catch (ArrayIndexOutOfBoundsException e) {
  142.             }
  143.         }
  144.         return s;
  145.     }
  146.  
  147.     public void openSkillBanner(int i) throws InterruptedException {
  148.         Timer t = new Timer(5000);
  149.         while (!isSkillBannerUp() && t.isNotUp()) {
  150.             if (!theTabs.Statistics.isSelected()) {
  151.                 theTabs.Statistics.setSelected();
  152.             }
  153.             if (theTabs.Statistics.isSelected()) {
  154.                 mouseClickLeft(getRectangles()[i]);
  155.                 sleep(random(30, 100));
  156.             }
  157.         }
  158.     }
  159.  
  160.     public Rectangle[] getRectangles() throws InterruptedException {
  161.         Rectangle[] temp = new Rectangle[25];
  162.         for (int i = 0; i < temp.length; i++) {
  163.             if (getAllInterfaces()[320][skill.values()[i].getSubIndex()]
  164.                     .isValid()) {
  165.                 temp[i] = getAllInterfaces()[320][skill.values()[i]
  166.                         .getSubIndex()].getCalculatedArea3();
  167.             }
  168.         }
  169.         return temp;
  170.     }
  171.  
  172.     public int[] getLevels() throws InterruptedException {
  173.         int[] temp = new int[25];
  174.         for (int i = 0; i < temp.length; i++) {
  175.             temp[i] = getLevel(skill.values()[i].getSkill());
  176.         }
  177.         return temp;
  178.     }
  179.  
  180.     public String[] getName() throws InterruptedException {
  181.         String[] temp = new String[25];
  182.         for (int i = 0; i < temp.length; i++) {
  183.             temp[i] = skill.values()[i].getName();
  184.         }
  185.         return temp;
  186.     }
  187.  
  188.     public int getLevel(Skill s) throws InterruptedException {
  189.         return theTabs.Statistics.getStatBottom(s);
  190.     }
  191.  
  192.     public void directoryExists(String s) {
  193.         File file = new File(s + "/");
  194.         boolean exists = file.exists();
  195.         if (!exists) {
  196.             log("Directory " + s + "does not exist");
  197.             boolean dir = (new File(s)).mkdir();
  198.             if (dir) {
  199.                 log("Directory " + s + " created successfully");
  200.             } else
  201.                 log("Failed to create directory");
  202.         }
  203.     }
  204.  
  205.     public void takeShot(String skill, String level) {
  206.         String s = skill + level;
  207.         log("Taking Screenshot");
  208.         BufferedImage image = theClientScreenGrabber.getBufferedImage(100);
  209.         log("Creating file");
  210.         directoryExists("AutoScreenshot");
  211.         directoryExists("AutoScreenshot/" + getPlayerName());
  212.         File file = new File("AutoScreenshot/" + getPlayerName() + "/" + s
  213.                 + ".png");
  214.         try {
  215.             log("Saving Screenshot to file");
  216.             ImageIO.write(image, "png", file);
  217.         } catch (IOException e) {
  218.         }
  219.     }
  220.  
  221.     public boolean startUp() throws InterruptedException {
  222.         setNextRun(3000);
  223.         if (getColorBot().theBotStates.contains(BotStates.LOGGED_IN)) {
  224.             if (levels[0] != 0 && levels[24] != 0) {
  225.                 for (int i = 0; i < levels.length; i++) {
  226.                     if (levels[i] != getLevels()[i]) {
  227.                         if (!inCombat()) {
  228.                             return true;
  229.                         }
  230.                     }
  231.                 }
  232.             } else
  233.                 levels = getLevels();
  234.  
  235.         }
  236.         return false;
  237.     }
  238. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement