Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.scripts;
- import java.awt.Color;
- import java.awt.Graphics;
- import java.awt.Point;
- import java.awt.*;
- import com.kbot2.handlers.eventSystem.eventListeners.PaintListener;
- import com.kbot2.handlers.eventSystem.eventListeners.ServerMessageListener;
- import com.kbot2.scriptable.Script;
- import com.kbot2.scriptable.methods.data.Walking;
- import com.kbot2.scriptable.methods.wrappers.Obj;
- import com.kbot2.scriptable.methods.wrappers.Tile;
- import com.kbot2.scriptable.methods.wrappers.Interface;
- public class StrifesFlaxPicker extends Script implements PaintListener,
- ServerMessageListener {
- // FLAX VARIABLES \\
- int FLAX_ID[] = { 2646 ,};
- int FLAX_PICKED = 0;
- // PAINT VARIABLES \\
- long startTime;
- String Status;
- // OBJECTS \\
- Obj flax;
- public static int BANK_BUTTON_DEPOSIT_CARRIED_ITEMS = 20;
- private final static int[] BANK_ID = new int[]{25808};
- private final static Tile[] FLAX_TO_BANK_PATH = new Tile[]{new Tile(2739,3447), new Tile(2736,3443), new Tile(2735,3448),new Tile(2731,3451), new Tile(2729,3456), new Tile(2726,3461),new Tile(2728,3466), new Tile(2728,3471), new Tile(2726,3476),new Tile(2727,3481), new Tile(2727,3486), new Tile(2726,3491), };
- private final static Tile[] BANK_TO_FLAX_PATH = Walking.reversePath(FLAX_TO_BANK_PATH);
- private final static Rectangle FLAX_FIELD = new Rectangle(2737, 3439, 13, 11);
- private final static Rectangle SEER_BANK_AREA = new Rectangle(2721, 3490, 9, 3);
- public boolean active() {
- return true;
- }
- @Override
- public boolean onStart() {
- Status = "Starting Up";
- log("Welcome to Strife's Flax Picker");
- startTime = System.currentTimeMillis();
- return true;
- }
- public void onServerMessage(String e) {
- if (e.contains("pick")) {
- FLAX_PICKED++;
- }
- }
- public int loop() {
- try {
- if(walking.getEnergy() > 50)
- walking.setRunning(true);
- Tile myLoc = getMyPlayer().getLocation();
- Point p = new Point(myLoc.getX(), myLoc.getY());
- if(inventory.getCount() == 28) {
- if(SEER_BANK_AREA.contains(p)) {
- log("we are in bank");
- Interface iface = interfaces.getInterface(109, 13);
- if(iface != null && iface.isValid())
- iface.doClick();
- if(bank.isOpen()) {
- bank.depositInventory();
- } else {
- Obj b = objects.getClosestObject(40, BANK_ID);
- if(b != null)
- if(b.getScreenPos().getX() != -1)
- b.doAction("quickly");
- else
- walking.walkToMM(b.getLocation());
- }
- } else {
- if(!getMyPlayer().isMoving())
- walking.walkPath(FLAX_TO_BANK_PATH);
- }
- } else {
- if(FLAX_FIELD.contains(p)) {
- if(getMyPlayer().getAnimation() == -1 && !getMyPlayer().isMoving()) {
- Obj t = objects.getClosestObject(15, FLAX_ID);
- if(t != null)
- if(t.getScreenPos().getX() != -1)
- t.doAction("Pick");
- else {
- if(FLAX_FIELD.contains(new Point(t.getLocation().getX(), t.getLocation().getY())))
- walking.walkToMM(t.getLocation());
- else if(t.getLocation().getY() < FLAX_FIELD.getY())
- walking.walkToMM(new Tile(t.getLocation().getX(), (int) FLAX_FIELD.getY()));
- else
- walking.walkToMM(new Tile(t.getLocation().getX(), (int) (
- FLAX_FIELD.getY() + FLAX_FIELD.getHeight())));
- }
- }
- } else {
- if(!getMyPlayer().isMoving())
- walking.walkPath(BANK_TO_FLAX_PATH);
- }
- }
- } catch (Exception failSafe) {
- log("Some exception thrown, probably Nullpointer from Calculations");
- failSafe.printStackTrace();
- }
- return random(1000, 2000);
- }
- /**
- * Move And Click Mouse With Randomness
- *
- * @param x
- * where on the x axis to move the mouse
- * @param y
- * where on the y axis to move the mouse
- * @param randX
- * maximum randomness X axes
- * @param randY
- * maximum randomness Y axes
- * @param randx
- * @param randy
- * @param button
- * boolean: true = left click, false = right click
- */
- void clickMouse(int x, int y, int randx, int randy, boolean button) {
- mouse.moveMouse(x, y, randx, randy);
- sleep(100);
- mouse.clickMouse(button);
- }
- public String getName() {
- return "Strife's FlaxPicker";
- }
- public String getAuthor() {
- return "Strife";
- }
- public String getDescription() {
- return "Picks Flax in Seers Village";
- }
- public void onRepaint(Graphics w) {
- long runTime = System.currentTimeMillis() - startTime;
- int secs = ((int) ((runTime / 1000) % 60));
- int mins = ((int) (((runTime / 1000) / 60) % 60));
- int hours = ((int) ((((runTime / 1000) / 60) / 60) % 60));
- String hourss, minss, secss;
- if (secs < 10)
- secss = "0" + secs;
- else
- secss = "" + secs;
- if (mins < 10)
- minss = "0" + mins;
- else
- minss = "" + mins;
- if (hours < 10)
- hourss = "0" + hours;
- else
- hourss = "" + hours;
- w.setColor(new Color(61, 61, 61, 100));
- w.fill3DRect(25, 25, 160, 83, true);
- w.setColor(new Color(61, 61, 61, 200));
- w.fill3DRect(30, 30, 150, 73, true);
- w.setColor(Color.white);
- w.drawString("Status: " + Status, 34, 43);
- w.drawString("Runtime: " + hourss + ":" + minss + ":" + secss, 34, 61);
- w.drawString("Flax Picked: " + FLAX_PICKED, 34, 97);
- }
- }
Add Comment
Please, Sign In to add comment