Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- package scripts;
- import java.awt.Color;
- import java.awt.Container;
- import java.awt.FlowLayout;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.Interfaces;
- import org.tribot.api2007.Inventory;
- import org.tribot.api2007.NPCs;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Skills;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.WebWalking;
- import org.tribot.api2007.types.RSInterfaceChild;
- import org.tribot.api2007.types.RSInterfaceMaster;
- import org.tribot.api2007.types.RSNPC;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import javax.swing.*;
- /**
- *
- * @author Spencer
- */
- @ScriptManifest(authors = { "Deluxes" }, category = "Money Making", name = "DeluxesTANNER")
- public class DeluxesTANNER extends Script implements Painting {
- RSTile tanner = new RSTile(3275, 3191);
- State state = State.TO_BANK;
- RSArea tanArea = new RSArea(new RSTile(3274, 3192), 3);
- RSArea bankArea = new RSArea(new RSTile(3270, 3167), 3);
- DeluxesGUI gui;
- JFrame f;
- JComboBox list;
- boolean inGUI = true;
- //int leatherID = 1741;
- ZybezRSItem hide;
- ZybezRSItem tanned;
- int cowhideID = 1739;
- int moneyID = 995;
- int cowhidePrice;
- int leatherPrice;
- int[] hideID = new int[] { 1739, 1739, 2861, 2861, 1753, 1751, 1749, 1747};
- int[] leatherID = new int[] {1741, 1743, 6289, 6289, 1745, 2505, 2507, 2509};
- int[] payment = new int[] {1, 3, 20, 15, 20, 20, 20, 20};
- String[] hideName = new String[] {"Cowhide", "Cowhide", "Snake hide", "Snake hide", "Green dragonhide", "Blue dragonhide", "Red dragonhide", "Black dragonhide" };
- String[] tannedName = new String[] {"Leather", "Hard Leather", "Snakeskin", "Snakeskin", "Green d-leather", "Blue d-leather", "Red d-leather", "Black d-leather" };
- int tanType = 108;
- int selectedHide = 0;
- int tanOffset = 108;
- String typeToTan = "";
- int hidesTanned = 0;
- long failSafeTimeoutLow = 3250;
- long failSafeTimeoutHigh = 4000;
- long startTime = System.currentTimeMillis();
- public enum State
- {
- TO_BANK, BANK, TO_TANNER, TAN
- }
- public static void main(String[] args) {
- // TODO code application logic here
- }
- @Override
- public void onPaint(Graphics g)
- {
- int profit = ((hidesTanned * leatherPrice) - (hidesTanned * cowhidePrice) - (hidesTanned * payment[selectedHide]));
- Graphics2D g1 = (Graphics2D)g;
- g1.drawString("STATE: " + state, 236, 225);
- g1.drawString("HIDES TANNED: " + hidesTanned, 236, 245);
- g1.drawString("TANNING: " + typeToTan, 236, 265);
- g1.drawString("PROFIT: " + profit, 236, 285);
- g1.drawString("TIME RAN: " + Timing.msToString(System.currentTimeMillis() - startTime), 236, 305);
- g1.drawString("HIDES PER HOUR: " + (hidesTanned * (3600000 / Timing.timeFromMark(startTime))), 236, 325);
- g1.drawString("GOLD PER HOUR: " + (profit * (3600000 / Timing.timeFromMark(startTime))), 236, 345);
- }
- boolean atBank()
- {
- return bankArea.contains(Player.getPosition());
- }
- boolean atTanner()
- {
- return tanArea.contains(Player.getPosition());
- }
- State getState()
- {
- if (atBank() && Inventory.getCount(hideID[selectedHide]) != 0)
- return State.TO_TANNER;
- else if (atTanner() && Inventory.getCount(hideID[selectedHide]) != 0)
- return State.TAN;
- else if (atBank())
- return State.BANK;
- else if (Inventory.getCount(hideID[selectedHide]) != 0)
- return State.TO_TANNER;
- else
- return State.TO_BANK;
- }
- @Override
- public void run()
- {
- try
- {
- SwingUtilities.invokeAndWait(new Runnable() {
- public void run()
- {
- System.out.print("MAKE GUI");
- gui = new DeluxesGUI();
- f.setVisible(true);
- }});
- } catch(Exception e)
- {
- }
- while (inGUI)
- sleep(100, 150);
- hide = new ZybezRSItem(hideName[selectedHide]);
- tanned = new ZybezRSItem(tannedName[selectedHide]);
- cowhidePrice = hide.getAveragePrice();
- leatherPrice = tanned.getAveragePrice();
- Walking.control_click = true;
- WebWalking.setUseRun(true);
- while (true)
- {
- state = getState();
- switch (state)
- {
- case TAN:
- tan();
- break;
- case BANK:
- bank();
- break;
- case TO_BANK:
- walkToBank();
- break;
- case TO_TANNER:
- walkToTanner();
- break;
- }
- }
- }
- void walkToBank()
- {
- WebWalking.walkToBank();
- while (!bankArea.contains(Player.getPosition()) && Player.isMoving())
- sleep(50, 150);
- }
- void walkToTanner()
- {
- WebWalking.setUseRun(true);
- WebWalking.walkTo(tanner);
- while (!tanArea.contains(Player.getPosition()) && Player.isMoving())
- sleep(50, 150);
- }
- void tan()
- {
- RSNPC[] tanner = NPCs.find("Ellis");
- if (tanner.length > 0)
- {
- if (Interfaces.get(324) == null)
- {
- if (DynamicClicking.clickRSNPC(tanner[0], "Trade"))
- {
- Timing.waitCondition(new Condition()
- {
- public boolean active()
- {
- return Interfaces.get(324) != null;
- }
- }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
- }
- }
- if (Interfaces.get(324) != null)
- {
- RSInterfaceMaster master = Interfaces.get(324);
- while (Inventory.getCount(leatherID[selectedHide]) == 0)
- {
- master.getChild(tanType).click("All");
- Timing.waitCondition(new Condition()
- {
- public boolean active()
- {
- return Inventory.getCount(leatherID[selectedHide]) != 0;
- }
- }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
- hidesTanned += Inventory.getCount(leatherID);
- }
- }
- }
- }
- void bank()
- {
- RSObject[] bankBooths = Objects.findNearest(10, "Bank Booth");
- if(bankBooths.length > 0)
- {
- if (!bankBooths[0].isOnScreen())
- {
- Camera.turnToTile(bankArea.getRandomTile());
- sleep(200, 300);
- }
- if (DynamicClicking.clickRSObject(bankBooths[0], "Bank"))
- {
- Timing.waitCondition(new Condition()
- {
- public boolean active()
- {
- return Banking.isBankScreenOpen();
- }
- }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
- }
- if (Banking.isBankScreenOpen())
- {
- Banking.depositAllExcept(moneyID);
- Banking.withdraw(0, hideID[selectedHide]);
- Timing.waitCondition(new Condition()
- {
- public boolean active()
- {
- return Inventory.getCount(cowhideID) > 0;
- }
- }, General.random((int)failSafeTimeoutLow, (int)failSafeTimeoutHigh));
- }
- }
- }
- class DeluxesGUI
- {
- public DeluxesGUI()
- {
- f = new JFrame("This is a test");
- f.setSize(250, 100);
- f.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
- Container content = f.getContentPane();
- content.setBackground(Color.white);
- content.setLayout(new FlowLayout());
- String[] petStrings = { "Soft Leather", "Hard Leather", "Snakeskin Light", "Snakeskin Dark", "Green d'hide", "Blue d'hide", "Red d'hide", "Black d'hide" };
- list = new JComboBox(petStrings);
- JButton start = new JButton("Start");
- list.setSelectedIndex(0);
- list.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- JComboBox combo = (JComboBox) e.getSource();
- tanType = tanOffset + combo.getSelectedIndex();
- selectedHide = combo.getSelectedIndex();
- typeToTan = (String)combo.getSelectedItem();
- }});
- start.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- tanType = tanOffset + list.getSelectedIndex();
- selectedHide = list.getSelectedIndex();
- typeToTan = (String)list.getSelectedItem();
- inGUI = false;
- f.dispose();
- }});
- f.add(list);
- f.add(start);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement