Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import impsoft.bots.ColorBot;
- import impsoft.scripting.ibot.enums.BotStates;
- import impsoft.scripting.ibot.enums.Skill;
- import impsoft.scripting.types.ColorRandom;
- import impsoft.utils.general.Timer;
- import java.awt.Rectangle;
- import java.awt.image.BufferedImage;
- import java.io.File;
- import java.io.IOException;
- import javax.imageio.ImageIO;
- public class AutoScreenshot extends ColorRandom {
- public AutoScreenshot(ColorBot ava) {
- super(ava);
- }
- public final String author = "Avaryan";
- public final double version = 2.10;
- int[] levels = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0 };
- public void random() throws InterruptedException {
- Timer t = new Timer(10000);
- boolean complete = false;
- log("Starting AutoScreenshot");
- while (!complete && t.isNotUp()) {
- for (int i = 0; i < levels.length; i++) {
- if (levels[i] != getLevels()[i]) {
- log(getName()[i] + " increased from "
- + (getLevels()[i] - 1) + " to " + getLevels()[i]);
- openSkillBanner(i);
- takeShot(getName()[i], modLevel(getLevels()[i]));
- closeSkillBanner();
- }
- t.reset();
- }
- complete = true;
- }
- levels = getLevels();
- }
- enum skill {
- ATTACK(0, "Attack", Skill.ATTACK, 1), STRENGTH(1, "Strength",
- Skill.STRENGTH, 4), DEFENSE(2, "Defense", Skill.DEFENSE, 21), RANGED(
- 3, "Ranged", Skill.RANGED, 45), PRAYER(4, "Prayer",
- Skill.PRAYER, 69), MAGIC(5, "Magic", Skill.MAGIC, 86), RUNECRAFTING(
- 6, "Runecrafting", Skill.RUNECRAFTING, 103), CONSTRUCTION(7,
- "Construction", Skill.CONSTRUCTION, 127), DUNGEONEERING(8,
- "Dungeoneering", Skill.DUNGEONEERING, 151), CONSTITUTION(9,
- "Constitution", Skill.HITPOINTS, 2), AGILITY(10, "Agility",
- Skill.AGILITY, 12), HERBLORE(11, "Herblore", Skill.HERBLORE, 29), THIEVING(
- 12, "Thieving", Skill.THIEVING, 53), CRAFTING(13, "Crafting",
- Skill.CRAFTING, 77), FLETCHING(14, "Fletching",
- Skill.FLETCHING, 94), SLAYER(15, "Slayer", Skill.SLAYER, 111), HUNTER(
- 16, "Hunter", Skill.HUNTER, 135), MINING(17, "Mining",
- Skill.MINING, 3), SMITHING(18, "Smithing", Skill.SMITHING, 20), FISHING(
- 19, "Fishing", Skill.FISHING, 37), COOKING(20, "Cooking",
- Skill.COOKING, 61), FIREMAKING(21, "Firemaking",
- Skill.FIREMAKING, 85), WOODCUTTING(22, "Woodcutting",
- Skill.WOODCUTTING, 102), FARMING(23, "Farming", Skill.FARMING,
- 119), SUMMONING(24, "Summoning", Skill.SUMMONING, 143);
- private int index;
- private String name;
- private Skill s;
- private int sub;
- skill(int index, String name, Skill s, int sub) {
- this.index = index;
- this.name = name;
- this.s = s;
- this.sub = sub;
- }
- public int getIndex() {
- return index;
- }
- public String getName() {
- return name;
- }
- public Skill getSkill() {
- return s;
- }
- public int getSubIndex() {
- return sub;
- }
- }
- public String modLevel(int i) {
- if (i < 10) {
- return "0" + i;
- } else
- return "" + i;
- }
- public boolean isSkillBannerUp() throws InterruptedException {
- if (isInterfaceNotNullAndValid(741, 5)) {
- try {
- if (getAllInterfaces()[741][5].getText().contains("Congrat")) {
- return true;
- } else
- return false;
- } catch (ArrayIndexOutOfBoundsException e) {
- return false;
- }
- } else
- return false;
- }
- public void closeSkillBanner() throws InterruptedException {
- Timer t = new Timer(3000);
- while (isSkillBannerUp() && t.isNotUp()) {
- try {
- if (isInterfaceNotNullAndValid(741, 9)) {
- mouseClickLeft(getAllInterfaces()[741][9]
- .getCalculatedArea3());
- }
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- }
- }
- public String getPlayerName() {
- String s = "";
- String t = "";
- if (isInterfaceNotNullAndValid(137, 55)) {
- try {
- if (getAllInterfaces()[137][55].getText().contains("<img")) {
- t = getAllInterfaces()[137][55].getText();
- int i = t.length() - 21;
- s = t.substring(0, i);
- }
- } catch (ArrayIndexOutOfBoundsException e) {
- }
- }
- return s;
- }
- public void openSkillBanner(int i) throws InterruptedException {
- Timer t = new Timer(5000);
- while (!isSkillBannerUp() && t.isNotUp()) {
- if (!theTabs.Statistics.isSelected()) {
- theTabs.Statistics.setSelected();
- }
- if (theTabs.Statistics.isSelected()) {
- mouseClickLeft(getRectangles()[i]);
- sleep(random(30, 100));
- }
- }
- }
- public Rectangle[] getRectangles() throws InterruptedException {
- Rectangle[] temp = new Rectangle[25];
- for (int i = 0; i < temp.length; i++) {
- if (getAllInterfaces()[320][skill.values()[i].getSubIndex()]
- .isValid()) {
- temp[i] = getAllInterfaces()[320][skill.values()[i]
- .getSubIndex()].getCalculatedArea3();
- }
- }
- return temp;
- }
- public int[] getLevels() throws InterruptedException {
- int[] temp = new int[25];
- for (int i = 0; i < temp.length; i++) {
- temp[i] = getLevel(skill.values()[i].getSkill());
- }
- return temp;
- }
- public String[] getName() throws InterruptedException {
- String[] temp = new String[25];
- for (int i = 0; i < temp.length; i++) {
- temp[i] = skill.values()[i].getName();
- }
- return temp;
- }
- public int getLevel(Skill s) throws InterruptedException {
- return theTabs.Statistics.getStatBottom(s);
- }
- public void directoryExists(String s) {
- File file = new File(s + "/");
- boolean exists = file.exists();
- if (!exists) {
- log("Directory " + s + "does not exist");
- boolean dir = (new File(s)).mkdir();
- if (dir) {
- log("Directory " + s + " created successfully");
- } else
- log("Failed to create directory");
- }
- }
- public void takeShot(String skill, String level) {
- String s = skill + level;
- log("Taking Screenshot");
- BufferedImage image = theClientScreenGrabber.getBufferedImage(100);
- log("Creating file");
- directoryExists("AutoScreenshot");
- directoryExists("AutoScreenshot/" + getPlayerName());
- File file = new File("AutoScreenshot/" + getPlayerName() + "/" + s
- + ".png");
- try {
- log("Saving Screenshot to file");
- ImageIO.write(image, "png", file);
- } catch (IOException e) {
- }
- }
- public boolean startUp() throws InterruptedException {
- setNextRun(3000);
- if (getColorBot().theBotStates.contains(BotStates.LOGGED_IN)) {
- if (levels[0] != 0 && levels[24] != 0) {
- for (int i = 0; i < levels.length; i++) {
- if (levels[i] != getLevels()[i]) {
- if (!inCombat()) {
- return true;
- }
- }
- }
- } else
- levels = getLevels();
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement