Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.Script;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSInterface;
- import org.rsbot.script.methods.Mouse;
- import org.rsbot.script.methods.Interfaces;
- import org.rsbot.script.wrappers.RSObject;
- import java.awt.*;
- @ScriptManifest(authors = { "Nickers" }, keywords = { "Wise Old Man tinder collector" }, name = "WiseTinderCollector", version = 1.00, description = "Start at Draynor bank.")
- public class WiseTinder extends Script implements PaintListener, MessageListener {
- private final int DEPOSIT_BOX_ID = 2045;
- private final int BOOK_SHELF_ID = 2702;
- private final int TINDER_BOX_ID = 590;
- private final int DOOR_CLOSED_ID = 1239;
- private final int VOID_VARIABLE = 1;
- private int amountDropped;
- private long START_TIME;
- private int totalProfit;
- public int tindersCollected;
- private RSObject depositBox;
- private RSObject bookShelf;
- private RSObject tinderBox;
- private RSObject closedDoor;
- private RSObject groundTinder;
- private final BasicStroke stroke1 = new BasicStroke(1);
- private final Font font1 = new Font("Microsoft Sans Serif", 1, 22);
- private final Font font2 = new Font("Microsoft Sans Serif", 1, 16);
- private final RSTile BANK_TILE = new RSTile(3092, 3245);
- private final RSTile SHELF_TILE = new RSTile(3087, 3253);
- private final RSTile COLLECTING_TILE = new RSTile(3088,3253);
- private final RSTile DOOR_TILE = new RSTile(3088, 3250);
- public enum State {
- TO_BANK,
- TO_SHELF,
- COLLECTING_TINDER,
- PICKUP_TINDER,
- BANKING_TINDER,
- WAITING,
- NO_STATUS,
- OPEN_DOOR,
- DROP_TINDER
- }
- @Override
- public boolean onStart() {
- System.out.println("Thank you for using WiseTinder!");
- System.out.println("Please start at Draynor bank.");
- mouse.setSpeed(4);
- return true;
- }
- public void collectTinder(){
- if(!inventory.contains(TINDER_BOX_ID) && bookShelf != null && bookShelf.isOnScreen()){
- bookShelf.interact("Search Bookcase");
- }
- }
- public void dropTinder(){
- if(inventory.contains(TINDER_BOX_ID) && inventory.getCount() == 1){
- inventory.dropAllExcept(VOID_VARIABLE);
- amountDropped++;
- }
- }
- public void pickupTinder(){
- if(groundTinder != null && groundTinder.isOnScreen()){
- groundTinder.interact("Take Tinderbox");
- }
- }
- public void bankingTinders(){
- if(depositBox != null){
- depositBox.doClick();
- bank.depositAll();
- bank.close();
- }
- }
- public void toBank(){
- walking.walkTileMM(BANK_TILE);
- if(closedDoor != null && closedDoor.getLocation() == DOOR_TILE){
- closedDoor.interact("Open Door");
- }
- }
- public void toShelf(){
- walking.walkTileMM(COLLECTING_TILE);
- if(closedDoor != null && closedDoor.getLocation() == DOOR_TILE){
- closedDoor.interact("Open Door");
- }
- }
- public State currentStatus(){
- if(amountDropped < 28){
- return State.COLLECTING_TINDER;
- } if(amountDropped == 28){
- return State.PICKUP_TINDER;
- }
- if(inventory.isFull() && !depositBox.isOnScreen()){
- return State.TO_BANK;
- }
- if(inventory.isFull() && depositBox != null && depositBox.isOnScreen()){
- return State.BANKING_TINDER;
- }
- if(!inventory.contains(TINDER_BOX_ID) && depositBox != null && depositBox.isOnScreen()){
- return State.TO_SHELF;
- }
- return null;
- }
- public void onRepaint(Graphics g1) {
- long runningTime = System.currentTimeMillis() - START_TIME;
- int seconds = (int)(runningTime / 1000) % 60; //I think this works...
- int minutes = (int)(runningTime / (1000 * 60)) % 60; //Same...
- int hours = (int)(runningTime / (1000 * 60 * 60)); //Hours doesn't get capped.
- float hoursWorked = ((float)runningTime / (1000 * 60 * 60)) + 1.0f;
- int profitPerHour = (int) ((float)totalProfit / hoursWorked);
- StringBuilder bldr = new StringBuilder();
- bldr.append(hours < 10 ? ("0" + hours) : hours);
- bldr.append(":");
- bldr.append(minutes < 10 ? ("0" + minutes) : minutes);
- bldr.append(":");
- bldr.append(seconds < 10 ? ("0" + seconds) : seconds);
- Graphics2D g = (Graphics2D)g1;
- g.setColor(new Color(51, 0, 255));
- g.fillRect(6, 341, 504, 133);
- g.setColor(Color.BLACK);
- g.setStroke(stroke1);
- g.drawRect(6, 341, 504, 133);
- g.setFont(font1);
- g.setColor(new Color(255, 255, 51));
- g.drawString("Nicker's WiseTinder! V. 1.00", 12, 375);
- g.setFont(font2);
- g.setColor(Color.YELLOW);
- g.drawString("Running for:" + bldr.toString(), 17, 407);
- g.drawString("Profit gained:" + totalProfit, 17, 430);
- g.drawString("Tinder's collected: " + tindersCollected, 270, 410);
- }
- @Override
- public int loop() {
- bookShelf = objects.getNearest(BOOK_SHELF_ID);
- depositBox = objects.getNearest(DEPOSIT_BOX_ID);
- tinderBox = objects.getNearest(TINDER_BOX_ID);
- closedDoor = objects.getNearest(DOOR_CLOSED_ID);
- State state = currentStatus();
- log.info("State:" + state.name());
- switch (currentStatus()){
- case TO_BANK:
- toBank();
- break;
- case TO_SHELF:
- toShelf();
- break;
- case COLLECTING_TINDER:
- collectTinder();
- dropTinder();
- break;
- case PICKUP_TINDER:
- pickupTinder();
- break;
- case DROP_TINDER:
- dropTinder();
- break;
- case BANKING_TINDER:
- bankingTinders();
- amountDropped = 0;
- break;
- }
- return (random(500, 1000));
- }
- @Override
- public void messageReceived(MessageEvent arg0) {
- // TODO Auto-generated method stub
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement