Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import com.kbotpro.scriptsystem.events.PaintEventListener;
- import com.kbotpro.scriptsystem.fetch.Bank;
- import com.kbotpro.scriptsystem.fetch.Game;
- import com.kbotpro.scriptsystem.fetch.Skills;
- import com.kbotpro.scriptsystem.interfaces.Looped;
- import com.kbotpro.scriptsystem.runnable.Script;
- import com.kbotpro.scriptsystem.wrappers.IComponent;
- import com.kbotpro.scriptsystem.wrappers.Interface;
- import com.kbotpro.scriptsystem.wrappers.Item;
- import com.kbotpro.scriptsystem.wrappers.PhysicalObject;
- import java.awt.*;
- /**
- * Created by IntelliJ IDEA.
- * User: Liked
- * Date: 22-Dec-2009
- * Time: 23:49:30
- * To change this template use File | Settings | File Templates.
- */
- public class SuperGlassMaker extends Script implements PaintEventListener {
- //Stuff we need
- private final int[] Staffs = {1381}; // Staffs of air
- private final int[] Runes = {9075, 554}; // Astral Runes and Fire Runes.
- int Seaweed = 401;
- int BucketOfSand = 1783; //Seaweed and Bucket of Sand.
- //Stuff we want
- private int MoltenGlass = 1775; // A product of the spell
- //Bank
- private int BankChest = -23344; // Bank Chest in Soul Wars, no randoms!
- //Paint
- private final long SCRIPT_START = System.currentTimeMillis(); // gets the start time
- private int onStartExp; // gets the start exp
- private int craftStartExp;
- //Bank Withdrawing
- private final int WITHDRAW_ALL = 0;
- private final int WITHDRAW_X = 1;
- private final int WITHDRAW_ALL_BUT_ONE = 2;
- public String getName() {
- return "LKSuperGlassMaker";
- }
- public boolean canStart() {
- return true;
- }
- public void onStart() {
- craftStartExp = skills.getExperience(Skills.SKILL_CRAFTING);
- onStartExp = skills.getExperience(Skills.SKILL_MAGIC);
- }
- public void pause() {
- // We don't need to care about this method for now
- }
- public void stop() {
- // We wont do anything here for now
- }
- public void registerWorkers() {
- createWorker(new Looped() {// Lets create a basic worker
- public int loop() {
- if (bank.isOpen()) {
- if (bank.contains(Seaweed) && bank.contains(BucketOfSand))
- if (bank.getCount(Seaweed) < 13 || bank.getCount(BucketOfSand) < 13) {
- game.logout();
- return -1;
- }
- } else {
- game.logout();
- return -1;
- }
- if (game.getCurrentTab() != Game.TAB_INVENTORY) {
- game.openTab(Game.TAB_INVENTORY);
- sleep(150);
- }
- if (!inventory.contains(Runes)) {//If we have no Astrals or Fires in our inventory log out.
- game.logout();
- return -1;
- }
- if (inventory.contains(Seaweed) && (inventory.contains(BucketOfSand))) { //Spell time.
- if (game.getCurrentTab() != Game.TAB_MAGIC) {
- game.openTab(Game.TAB_MAGIC);
- sleep(500);
- IComponent SuperGlassMakerSpell = interfaces.getComponent(430, 47);
- SuperGlassMakerSpell.doAction("Cast");
- sleep(2000, 3000);
- }
- }
- if (inventory.contains(MoltenGlass)) { //If we have molten glass in our inventory, bank it.
- PhysicalObject bankObj = objects.getClosestObject(4, BankChest);
- if (bankObj == null) return 100;
- bankObj.doAction("Use Bank Chest");
- sleep(500, 1000);
- Item Glass = inventory.getItems(MoltenGlass)[1];
- Glass.doAction("Deposit-All");
- sleep(500, 1000);
- withdraw(401, 13);
- sleep(500, 1000);
- withdrawAll(1783);
- close();
- }
- if (!inventory.contains(Seaweed) && (!inventory.contains(BucketOfSand))) { //If we don't have any Seaweed and Sand, get them out of bank.
- PhysicalObject bankObj = objects.getClosestObject(4, BankChest);
- if (bankObj == null) return 100;
- bankObj.doAction("Use Bank Chest");
- sleep(500, 1000);
- withdraw(401, 13);
- sleep(500, 1000);
- withdrawAll(1783);
- close();
- }
- if (inventory.contains(Seaweed) && (!inventory.contains(BucketOfSand))) { //If we don't have any Seaweed and Sand, get them out of bank.
- PhysicalObject bankObj = objects.getClosestObject(4, BankChest);
- if (bankObj == null) return 100;
- bankObj.doAction("Use Bank Chest");
- sleep(500, 1000);
- Item Glass = inventory.getItems(MoltenGlass)[1];
- Glass.doAction("Deposit-All");
- close();
- }
- return 1000;
- }
- });
- }
- /**
- * @param id Id of the item you want to withdraw.
- */
- public void withdrawAll(int id) {
- withdraw(id, 0, WITHDRAW_ALL);
- }
- /**
- * @param id Id of the item you want to withdraw.
- * @param amount Amount of the item you want to withdraw.
- */
- public void withdraw(int id, int amount) {
- withdraw(id, amount, WITHDRAW_X);
- }
- /**
- * @param id Id of the item you want to withdraw.
- * @param amount Amount of the item you want to withdraw.
- * @param type Withdraw type - withdraw-x, all, all-but-one
- */
- private void withdraw(int id, int amount, int type) {
- boolean doAction = false;
- Item item = bank.getItem(id);
- if (bank.contains(id) && item != null) {
- if (bank.getCount(id) >= amount) {
- IComponent visible = interfaces.getComponent(Bank.BANK_INTERFACE_ID, 3);
- if (visible != null) {
- if (visible.getBounds().contains(item.getBounds())) { //visible
- doAction = true;
- } else while (!visible.getBounds().contains(item.getBounds())) {
- item = bank.getItem(id);
- int scroll;
- if (item.getCenter().y < visible.getCenter().y) { //scroll up
- scroll = Bank.BANK_SCROLLBAR_UP;
- } else scroll = Bank.BANK_SCROLLBAR_DOWN;
- IComponent button = interfaces.getComponent(Bank.BANK_INTERFACE_ID, Bank.BANK_SCROLLBAR);
- if (button != null) {
- button.getChildren()[scroll].doClick();
- } else return;
- }
- doAction = true;
- }
- }
- }
- if (doAction) {
- Rectangle r = item.getBounds();
- mouse.moveMouse(new Point(random(r.x + 2, r.x + r.width - 2), random(r.y + 2, r.y + r.height - 2)));
- String action = "Withdraw-" + amount + " ";
- if (type == WITHDRAW_ALL) {
- action = "Withdraw-All";
- } else if (type == WITHDRAW_ALL_BUT_ONE) {
- action = "Withdraw-All but one";
- }
- if (menu.contains(action)) {
- menu.atMenu(action);
- } else { //withdraw X
- menu.atMenu("Withdraw-X");
- sleep(random(1000, 2000));
- keyboard.writeText(Integer.toString(amount), true);
- }
- }
- }
- public boolean close() {
- if (!bank.isOpen()) return true;
- Interface bankIFace = interfaces.getInterface(Bank.BANK_INTERFACE_ID);
- if (bankIFace != null && bankIFace.isValid()) {
- IComponent closeButton = interfaces.getComponent(Bank.BANK_INTERFACE_ID, Bank.BANK_BUTTON_CLOSE);
- Point closeUL = closeButton.getUpperLeftScreenPos();
- try {
- mouse.moveMouse(new Point((int) closeUL.getX() + random(0, (int) closeButton.getBounds().getWidth()), (int) closeUL.getY() + random(0, (int) closeButton.getBounds().getHeight())));
- sleep(10, 20);
- if (menu.atMenu("Close"))
- return true;
- } catch (Exception e) {
- }
- }
- return false;
- }
- public void onRepaint(Graphics g) {
- float expPerHour = 0;
- float moneyPerHour = 0;
- float craftExpPerHour = 0;
- int xpGained = skills.getExperience(Skills.SKILL_MAGIC) - onStartExp;
- int craftXpGained = skills.getExperience(Skills.SKILL_CRAFTING) - craftStartExp;
- long runTime = System.currentTimeMillis() - SCRIPT_START;
- int secs = ((int) ((runTime / 1000) % 60));
- int mins = ((int) (((runTime / 1000) / 60) % 60));
- int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
- int casts = ((skills.getExperience(Skills.SKILL_MAGIC) - onStartExp) / 78);
- int profit = ((int) ((461 * 17.5) - (255 + 239) * 13) * casts);
- if ((mins > 0 || hours > 0 || secs > 0) && (craftXpGained) > 0) {
- craftExpPerHour = ((float) (craftXpGained) / (float) (secs + (mins * 60) + (hours * 60 * 60)));
- }
- if ((mins > 0 || hours > 0 || secs > 0) && (xpGained) > 0) {
- expPerHour = ((float) (xpGained) / (float) (secs + (mins * 60) + (hours * 60 * 60)));
- }
- if ((mins > 0 || hours > 0 || secs > 0) && (profit) > 0) {
- moneyPerHour = ((float) (profit) / (float) (secs + (mins * 60) + (hours * 60 * 60)));
- }
- int x = 20;
- int y = 40;
- g.setColor(new Color(230, 230, 50, 80));
- y += 18;
- g.setColor(Color.red);
- g.setFont(new Font("Comic Sans", Font.BOLD, 12));
- y += 15;
- g.drawString("Liked's SuperGlass Maker 0.1", x, y);
- y += 15;
- g.drawString("Run Time: " + hours + "." + mins + "." + secs, x, y);
- y += 15;
- g.drawString("Current Level: " + skills.getLevel(Skills.SKILL_MAGIC), x, y);
- y += 15;
- g.drawString(("Profit: " + profit), x, y);
- y += 15;
- g.drawString(("Profit P/H: " + moneyPerHour), x, y);
- y += 15;
- g.drawString(("Magic Exp P/H: " + expPerHour), x, y);
- y += 15;
- g.drawString("Craft Exp P/H: " + craftExpPerHour, x, y);
- y += 15;
- g.drawString(("Casts: " + (casts)), x, y);
- }
- }
Add Comment
Please, Sign In to add comment