Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package scripts;
- import java.awt.Graphics;
- import java.awt.Polygon;
- import org.tribot.api2007.types.RSGroundItem;
- import org.tribot.api2007.Camera;
- import org.tribot.api2007.Combat;
- import org.tribot.api2007.GameTab;
- import org.tribot.api2007.GameTab.TABS;
- import org.tribot.api2007.GroundItems;
- import org.tribot.api2007.Login;
- import org.tribot.api2007.Banking;
- import org.tribot.api2007.Objects;
- import org.tribot.api2007.Player;
- import org.tribot.api2007.Screen;
- import org.tribot.api2007.Walking;
- import org.tribot.api2007.types.RSObject;
- import org.tribot.api2007.types.RSTile;
- import org.tribot.api2007.types.RSItem;
- import org.tribot.api2007.Inventory;
- import org.tribot.api.DynamicClicking;
- import org.tribot.api.General;
- import org.tribot.api.Timing;
- import org.tribot.api.input.Mouse;
- import org.tribot.api.types.generic.Condition;
- import org.tribot.script.Script;
- import org.tribot.script.ScriptManifest;
- import org.tribot.script.interfaces.Painting;
- import org.tribot.script.interfaces.Pausing;
- import org.tribot.script.interfaces.RandomEvents;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- @ScriptManifest(authors = { "Okokokok" }, category = "ok_Scripts", name = "ok_spiderEgg")
- public class ok_spiderEgg extends Script implements Painting, Pausing, RandomEvents {
- private boolean paused = false;
- private final String gateName = "Gate",
- ladderName = "Ladder",
- trapdoorName = "Trapdoor",
- spiderEggName = "Red spiders' eggs",
- lobsterName = "Lobster";
- private int eatPercent = 0,
- withdrawFoodies = 0;
- private boolean eatFully = false,
- withdrawFoodTrue = false,
- waitGUI = true;
- private final RSTile EDGE_BANK = new RSTile(3093, 3491, 0),
- EDGE_TILE = new RSTile(3093, 3481, 0),
- TRAPDOOR_TILE_UP = new RSTile(3094, 3470, 0),
- LADDER_TILE_DOWN = new RSTile(3096, 9867, 0),
- FIRST_GATE_TILE = new RSTile(3101, 9909, 0),
- FIRST_GATE_TILE_R = new RSTile(3106, 9909, 0),
- SECOND_GATE_TILE = new RSTile(3131, 9917, 0),
- SECOND_GATE_TILE_R = new RSTile(3132, 9920, 0),
- SPIDER_AREA_TILE = new RSTile(3123, 9952, 0),
- FIRST_EGG_TILE = new RSTile(3118, 9948, 0),
- SECOND_EGG_TILE = new RSTile(3128, 9956, 0),
- OUT_OF_BOUND_TILE_NORTH = new RSTile(3120, 9964, 0),
- OUT_OF_BOUND_TILE_EAST = new RSTile (3107, 9953, 0),
- myPos = Player.getPosition();
- private final RSTile[] trapdoorPath = new RSTile[] { new RSTile(3089, 3490, 0),
- new RSTile(3090, 3485, 0),
- new RSTile(3093, 3481, 0),
- new RSTile(3094, 3476, 0),
- new RSTile(3094, 3470, 0)},
- bankPath = new RSTile[] { new RSTile(3094, 3476, 0),
- new RSTile(3093, 3481, 0),
- new RSTile(3090, 3485, 0),
- new RSTile(3089, 3490, 0),
- new RSTile(3093, 3493, 0)},
- firstGatePath = new RSTile[] { new RSTile(3096, 9872, 0),
- new RSTile(3096, 9878, 0),
- new RSTile(3096, 9883, 0),
- new RSTile(3095, 9888, 0),
- new RSTile(3095, 9894, 0),
- new RSTile(3095, 9900, 0),
- new RSTile(3098, 9905, 0),
- new RSTile(3102, 9909, 0)},
- firstGateRPath = new RSTile[] { new RSTile(3098, 9905, 0),
- new RSTile(3095, 9900, 0),
- new RSTile(3095, 9894, 0),
- new RSTile(3095, 9888, 0),
- new RSTile(3096, 9883, 0),
- new RSTile(3096, 9878, 0),
- new RSTile(3096, 9872, 0),
- new RSTile(3096, 9869, 0)},
- secondGatePath = new RSTile[] { new RSTile(3109, 9909, 0),
- new RSTile(3116, 9910, 0),
- new RSTile(3123, 9909, 0),
- new RSTile(3129, 9911, 0),
- new RSTile(3131, 9914, 0),
- new RSTile(3131, 9917, 0)},
- secondGateRPath = new RSTile[] { new RSTile(3131, 9914, 0),
- new RSTile(3129, 9911, 0),
- new RSTile(3123, 9909, 0),
- new RSTile(3116, 9910, 0),
- new RSTile(3109, 9909, 0),
- new RSTile(3105, 9911, 0)},
- spiderPath = new RSTile[] { new RSTile(3132, 9922, 0),
- new RSTile(3132, 9927, 0),
- new RSTile(3132, 9932, 0),
- new RSTile(3132, 9937, 0),
- new RSTile(3132, 9943, 0),
- new RSTile(3130, 9948, 0),
- new RSTile(3124, 9951, 0)},
- spiderRPath = new RSTile[] {new RSTile(3130, 9948, 0),
- new RSTile(3132, 9943, 0),
- new RSTile(3132, 9937, 0),
- new RSTile(3132, 9932, 0),
- new RSTile(3132, 9927, 0),
- new RSTile(3133, 9919, 0)},
- northPath = new RSTile[] {new RSTile (3120, 9961, 0),
- new RSTile (3121, 9956, 0)},
- eastPath = new RSTile[] {new RSTile (3110, 9956, 0),
- new RSTile (3114, 9958, 0),
- new RSTile (3119, 9955, 0)};
- private final int SPIDER_EGG_ID = 223;
- private final Polygon secondGateArea = new Polygon(
- new int[] { 3130, 3134, 3134, 3130 },
- new int[] { 9918, 9918, 9915, 9915 },
- 4),
- secondGateAreaR = new Polygon(
- new int[] { 3130, 3134, 3134, 3130 },
- new int[] { 9921, 9921, 9918, 9918 },
- 4),
- firstEggArea = new Polygon(
- new int[] { 3116, 3122, 3122, 3116 },
- new int[] { 9954, 9954, 9948, 9948 },
- 4),
- secondEggArea = new Polygon(
- new int[] { 3124, 3130, 3130, 3124 },
- new int[] { 9959, 9959, 9952, 9952 },
- 4),
- ladderToFirstGateArea = new Polygon(
- new int[] { 3093, 3103, 3103, 3093 },
- new int[] { 9915, 9915, 9867, 9867 },
- 4),
- firstGateToSecondGateArea = new Polygon(
- new int[] { 3102, 3135, 3135, 3102 },
- new int[] { 9918, 9918, 9905, 9905 },
- 4),
- secondGateToSpidersArea = new Polygon(
- new int[] { 3130, 3136, 3136, 3130 },
- new int[] { 9948, 9948, 9916, 9916 },
- 4);
- // MISC METHODS
- public boolean logout()
- {
- if (Login.getLoginState() == Login.STATE.INGAME)
- {
- Login.logout();
- for(int x = 0; x < 6; x++)
- {
- if(loggedOut())
- {
- return true;
- }
- sleep(490,510);
- }
- }
- return false;
- }
- public boolean waitFor(Condition c, long timeout) {
- Timer t = new Timer(timeout);
- while (t.isRunning()) {
- if (c.active()) {
- return true;
- }
- sleep(60, 80);
- }
- return false;
- }
- public boolean loggedOut() {
- return (Login.getLoginState() == Login.STATE.LOGINSCREEN)
- && (!Screen.getColorAt(100, 200).equals(new Color(0, 0, 0)));
- }
- // ANTI-BAN BY SOKCRA
- public void antiBan(int rotation) {
- int number = General.random(1, 500);
- sleep(200);
- switch (number) {
- case 1:
- case 2:
- case 3:
- case 4:
- case 5:
- Camera.setCameraRotation(Camera.getCameraRotation() + rotation);
- break;
- case 20:
- case 21:
- case 22:
- case 23:
- case 24:
- case 25:
- case 26:
- case 27:
- case 28:
- case 29:
- case 30:
- case 31:
- Mouse.move(General.random(100, 200), General.random(200, 400));
- sleep(200);
- break;
- case 50:
- GameTab.open(TABS.INVENTORY);
- sleep(200);
- break;
- case 75:
- GameTab.open(TABS.STATS);
- sleep(300);
- Mouse.moveBox(678, 386, 725, 366);
- sleep(1000, 1500);
- GameTab.open(TABS.INVENTORY);
- break;
- case 76:
- GameTab.open(TABS.FRIENDS);
- sleep(2000, 3000);
- GameTab.open(TABS.INVENTORY);
- break;
- case 89:
- case 90:
- case 91:
- case 92:
- case 93:
- case 94:
- Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
- sleep(200, 400);
- break;
- case 95:
- case 96:
- case 97:
- case 98:
- case 99:
- case 100:
- Camera.setCameraAngle(Camera.getCameraRotation() + rotation);
- sleep(200, 400);
- break;
- }
- }
- //AREA CHECKS
- private boolean closeToDestination(RSTile whichTile, int radius){
- return myPos.distanceTo(whichTile) < radius;
- }
- private boolean areaContainsPlayer(Polygon area){
- return area.contains(Player.getPosition().getX(), Player.getPosition().getY());
- }
- //WALKING METHODS
- private void walkDestination(final RSTile[] whichPath, final RSTile whichTile, final Polygon whichArea, final int radius) {
- if (myPos != whichTile && !Player.isMoving()) {
- sleep(50, 100);
- if (Walking.walkPath(whichPath)) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return areaContainsPlayer(whichArea) && closeToDestination(whichTile, radius) && !Player.isMoving();
- }
- }, 2000);
- }
- }
- }
- private void walkDestinationCustom(final RSTile[] whichPath, final RSTile whichTile, final int radius) {
- if (myPos != whichTile) {
- sleep(50, 100);
- if (Walking.walkPath(whichPath)) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return closeToDestination(whichTile, radius);
- }
- }, 4000);
- }
- }
- }
- // CHECK AREA METHODS
- private boolean atEdgeArea() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(EDGE_TILE) < 14;
- }
- private boolean atLadderToFirstGateArea() {
- return ladderToFirstGateArea.contains(Player.getPosition().getX(),
- Player.getPosition().getY());
- }
- private boolean atFirstGateToSecondGateArea() {
- return firstGateToSecondGateArea.contains(Player.getPosition().getX(),
- Player.getPosition().getY());
- }
- private boolean atSecondGateToSpidersArea() {
- return secondGateToSpidersArea.contains(Player.getPosition().getX(),
- Player.getPosition().getY());
- }
- private boolean atBank() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(EDGE_BANK) < 6;
- }
- private boolean atLadderUp() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(TRAPDOOR_TILE_UP) < 6;
- }
- private boolean atLadderDown() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(LADDER_TILE_DOWN) < 4;
- }
- private boolean atFirstGate() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(FIRST_GATE_TILE) < 5;
- }
- private boolean atFirstGateR() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(FIRST_GATE_TILE_R) < 3;
- }
- private boolean atSecondGate() {
- return secondGateArea.contains(Player.getPosition().getX(), Player
- .getPosition().getY());
- }
- private boolean atSecondGateR() {
- return secondGateAreaR.contains(Player.getPosition().getX(), Player
- .getPosition().getY());
- }
- private boolean atFirstEggArea() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(FIRST_EGG_TILE) < 4;
- }
- private boolean atSecondEggArea() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(SECOND_EGG_TILE) < 4;
- }
- private boolean atSpiderArea() {
- RSTile myPos = Player.getPosition();
- return myPos.distanceTo(SPIDER_AREA_TILE) < 10;
- }
- // BANKING METHODS
- private boolean openBank() {
- eggsCollected += Inventory.getCount(SPIDER_EGG_ID);
- if (!Banking.isBankScreenOpen()) {
- return Banking.openBankBooth();
- } else {
- if (Banking.isBankScreenOpen());
- return false;
- }
- }
- private void depositEggs() {
- RSItem[] spiderEgg = Inventory.find(spiderEggName);
- if (spiderEgg != null && spiderEgg.length > 0
- && Banking.isBankScreenOpen()) {
- Banking.depositAll();
- }
- }
- private boolean withdrawFood(boolean r) {
- return r;
- }
- private boolean withdrawFoodAmount(int a) {
- return Banking.withdraw(a, lobsterName);
- }
- // WALKING METHODS
- private void walkToEggs1() {
- RSTile myPos = Player.getPosition();
- RSTile eggTile1 = new RSTile(3118, 9948, 0);
- Walking.setControlClick(true);
- if (myPos != eggTile1 && !Player.isMoving()) {
- if (Walking.walkTo(eggTile1)) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return atFirstEggArea() && !Player.isMoving();
- }
- }, 2000);
- }
- }
- }
- private void walkToEggs2() {
- RSTile myPos = Player.getPosition();
- RSTile eggTile2 = new RSTile(3128, 9956, 0);
- if (myPos != eggTile2 && !Player.isMoving()) {
- if (Walking.walkTo(eggTile2)) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return atSecondEggArea() && !Player.isMoving();
- }
- }, 2000);
- }
- }
- }
- // GATES, LADDERS EN TRAPDOORS
- private void climbDownTrapdoor() {
- RSObject[] trapdoorOpen = Objects.findNearest(6, trapdoorName);
- boolean top = org.tribot.api2007.Game.isUptext("Open"),
- climbdown = org.tribot.api2007.Game.isUptext("Climb-down");
- if (trapdoorOpen != null && trapdoorOpen.length > 0) {
- if (trapdoorOpen[0].hover()) {
- if (top || climbdown){
- Mouse.click(1);
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return !Player.isMoving();
- }
- }, 2000);
- }
- }
- }
- }
- private void climbUpLadder() {
- RSObject[] ladderUp = Objects.findNearest(8, ladderName);
- if (ladderUp != null && ladderUp.length > 0) {
- if (DynamicClicking.clickRSObject(ladderUp[0], "Climb-up")) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return atLadderUp();
- }
- }, 2000);
- }
- }
- }
- private boolean isFirstGateOpen() {
- RSObject[] firstGateOpen = Objects.findNearest(8, gateName);
- boolean open = org.tribot.api2007.Game.isUptext("Close");
- return firstGateOpen != null && firstGateOpen.length > 0 && open;
- }
- private void goThroughFirstGate() {
- RSObject[] firstGate = Objects.findNearest(3, gateName);
- boolean closed = org.tribot.api2007.Game.isUptext("Open");
- if (firstGate != null && firstGate.length > 0) {
- if (firstGate[0].hover()) {
- if (closed) {
- Mouse.click(1);
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return isFirstGateOpen();
- }
- }, 2000);
- }
- }
- }
- }
- private void goThroughSecondGate() {
- RSObject[] secondGate = Objects.findNearest(8, gateName);
- if (secondGate != null && secondGate.length > 0) {
- if (DynamicClicking.clickRSObject(secondGate[0], "Open")) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return atSecondGateR() && !Player.isMoving();
- }
- }, 2000);
- }
- }
- }
- private void goThroughSecondGateR() {
- RSObject[] secondGate = Objects.findNearest(8, gateName);
- if (secondGate != null && secondGate.length > 0) {
- for (int i = 0; i < secondGate.length; i++) {
- if (DynamicClicking.clickRSObject(secondGate[0], "Open")) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return atSecondGate() && !Player.isMoving();
- }
- }, 2000);
- }
- }
- }
- }
- // ITEM METHODS
- private boolean foodInInvent() {
- RSItem[] food = Inventory.find(lobsterName);
- return food != null && food.length > 0;
- }
- public RSTile getEggPosition() {
- RSGroundItem[] eggs = GroundItems.find(spiderEggName);
- return eggs[0].getPosition();
- }
- private boolean areEggsThereArea1() {
- RSGroundItem[] eggs = GroundItems.find(spiderEggName);
- if (eggs != null && eggs.length > 0) {
- if (firstEggArea.contains(eggs[0].getPosition().getX(), eggs[0]
- .getPosition().getY())) {
- return true;
- }
- }
- return false;
- }
- private boolean areEggsThereArea2() {
- RSGroundItem[] eggs = GroundItems.find(spiderEggName);
- if (eggs != null && eggs.length > 0) {
- if (secondEggArea.contains(eggs[0].getPosition().getX(), eggs[0]
- .getPosition().getY())) {
- return true;
- }
- }
- return false;
- }
- public boolean gainedEgg() {
- int invCount = Inventory.getAll().length;
- return Inventory.getAll().length > invCount;
- }
- public boolean ateFood() {
- int invCount = Inventory.getAll().length;
- return Inventory.getAll().length < invCount;
- }
- private void pickUpEggs() {
- RSGroundItem[] egg = GroundItems.findNearest(spiderEggName);
- RSTile myPos = Player.getPosition();
- if (egg != null && egg.length > 0) {
- for (int i = 0; i < egg.length; i++) {
- if (myPos.distanceTo(getEggPosition()) < 6) {
- if (DynamicClicking.clickRSTile(egg[i],
- "Take Red spiders' egg")) {
- waitFor(new Condition() {
- @Override
- public boolean active() {
- return gainedEgg() || Inventory.isFull();
- }
- }, 2000);
- }
- }
- }
- }
- }
- // COMBAT RELATED AND HEALTH RELATED METHODS
- private boolean eatEverything(boolean q) {
- return q;
- }
- private void eatAllFood() {
- RSItem[] food = Inventory.find(lobsterName);
- if (food != null && food.length > 0) {
- for (int i = 0; i < food.length; i++) {
- if (food[0].click("Eat")){
- waitFor(new Condition(){
- @Override
- public boolean active(){
- return ateFood();
- }
- }, 1000);
- }
- }
- }
- }
- private boolean checkHealth(int p) {
- int percentage = Combat.getHPRatio();
- return percentage < p;
- }
- private boolean eatFood() {
- RSItem[] food = Inventory.find(lobsterName);
- for (int i = 0; i < food.length; i++) {
- if (checkHealth(eatPercent)) {
- return food[i].click("Eat");
- }
- }
- return false;
- }
- // GUI STUFF
- class spiderGUI extends javax.swing.JFrame {
- /**
- * Creates new form spiderGUI
- */
- public spiderGUI() {
- initComponents();
- }
- /**
- * This method is called from within the constructor to initialize the
- * form. WARNING: Do NOT modify this code. The content of this method is
- * always regenerated by the Form Editor.
- */
- @SuppressWarnings("unchecked")
- // <editor-fold defaultstate="collapsed" desc="Generated Code">
- private void initComponents() {
- jPanel1 = new javax.swing.JPanel();
- jLabel4 = new javax.swing.JLabel();
- jScrollPane1 = new javax.swing.JScrollPane();
- jTextArea1 = new javax.swing.JTextArea();
- jButton1 = new javax.swing.JButton();
- jLabel1 = new javax.swing.JLabel();
- jPanel2 = new javax.swing.JPanel();
- jLabel2 = new javax.swing.JLabel();
- jLabel3 = new javax.swing.JLabel();
- jLabel5 = new javax.swing.JLabel();
- withdrawAmount = new javax.swing.JTextField();
- eatPercentage = new javax.swing.JTextField();
- jLabel6 = new javax.swing.JLabel();
- jRadioButton1 = new javax.swing.JRadioButton();
- jRadioButton2 = new javax.swing.JRadioButton();
- isReady = new javax.swing.JButton();
- javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(
- jPanel1);
- jPanel1.setLayout(jPanel1Layout);
- jPanel1Layout.setHorizontalGroup(jPanel1Layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 100,
- Short.MAX_VALUE));
- jPanel1Layout.setVerticalGroup(jPanel1Layout.createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING).addGap(0, 100,
- Short.MAX_VALUE));
- jLabel4.setFont(new java.awt.Font("Forte", 0, 18)); // NOI18N
- jLabel4.setForeground(new java.awt.Color(149, 26, 12));
- jLabel4.setText("Amount to withdraw?");
- jTextArea1.setColumns(20);
- jTextArea1.setRows(5);
- jScrollPane1.setViewportView(jTextArea1);
- jButton1.setText("jButton1");
- setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);
- setCursor(new java.awt.Cursor(java.awt.Cursor.DEFAULT_CURSOR));
- setForeground(java.awt.Color.red);
- jLabel1.setFont(new java.awt.Font("Forte", 3, 24)); // NOI18N
- jLabel1.setForeground(new java.awt.Color(149, 26, 12));
- jLabel1.setText("ok_spiderEgg GUI");
- jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(""));
- jLabel2.setFont(new java.awt.Font("Forte", 0, 18)); // NOI18N
- jLabel2.setForeground(new java.awt.Color(149, 26, 12));
- jLabel2.setText("Amount to withdraw?");
- jLabel3.setFont(new java.awt.Font("Forte", 0, 18)); // NOI18N
- jLabel3.setForeground(new java.awt.Color(149, 26, 12));
- jLabel3.setText("Eat when inv full?");
- jLabel5.setFont(new java.awt.Font("Forte", 0, 18)); // NOI18N
- jLabel5.setForeground(new java.awt.Color(149, 26, 12));
- jLabel5.setText("HP percentage to eat at?");
- withdrawAmount.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
- withdrawAmount.setForeground(new java.awt.Color(149, 26, 12));
- withdrawAmount.setText("6");
- withdrawAmount
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(
- java.awt.event.ActionEvent evt) {
- withdrawAmountActionPerformed(evt);
- }
- });
- eatPercentage.setFont(new java.awt.Font("Tahoma", 3, 11)); // NOI18N
- eatPercentage.setForeground(new java.awt.Color(149, 26, 12));
- eatPercentage.setText("60");
- eatPercentage
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(
- java.awt.event.ActionEvent evt) {
- eatPercentageActionPerformed(evt);
- }
- });
- jLabel6.setFont(new java.awt.Font("Forte", 0, 18)); // NOI18N
- jLabel6.setForeground(new java.awt.Color(149, 26, 12));
- jLabel6.setText("Withdraw food?");
- jRadioButton2
- .addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(
- java.awt.event.ActionEvent evt) {
- jRadioButton2ActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(
- jPanel2);
- jPanel2.setLayout(jPanel2Layout);
- jPanel2Layout
- .setHorizontalGroup(jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- jPanel2Layout
- .createSequentialGroup()
- .addGap(23, 23, 23)
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(
- jLabel2)
- .addComponent(
- jLabel5)
- .addComponent(
- jLabel6,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 132,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(
- jLabel3))
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED,
- 72, Short.MAX_VALUE)
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- jPanel2Layout
- .createSequentialGroup()
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(
- withdrawAmount,
- javax.swing.GroupLayout.Alignment.TRAILING,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 57,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(
- eatPercentage,
- javax.swing.GroupLayout.Alignment.TRAILING,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 57,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addGap(54,
- 54,
- 54))
- .addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- jPanel2Layout
- .createSequentialGroup()
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(
- jRadioButton1)
- .addComponent(
- jRadioButton2))
- .addGap(72,
- 72,
- 72)))));
- jPanel2Layout
- .setVerticalGroup(jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- jPanel2Layout
- .createSequentialGroup()
- .addContainerGap(21,
- Short.MAX_VALUE)
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(
- jLabel6,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 32,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(
- jRadioButton1))
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.TRAILING)
- .addComponent(
- jLabel3,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 32,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(
- jRadioButton2))
- .addGap(8, 8, 8)
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(
- jLabel2,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 32,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(
- withdrawAmount,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE))
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addGroup(
- jPanel2Layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.BASELINE)
- .addComponent(
- jLabel5,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 32,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addComponent(
- eatPercentage,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE))));
- isReady.setFont(new java.awt.Font("Forte", 3, 18)); // NOI18N
- isReady.setForeground(new java.awt.Color(149, 26, 12));
- isReady.setText("Start");
- isReady.addActionListener(new java.awt.event.ActionListener() {
- public void actionPerformed(java.awt.event.ActionEvent evt) {
- isReadyActionPerformed(evt);
- }
- });
- javax.swing.GroupLayout layout = new javax.swing.GroupLayout(
- getContentPane());
- getContentPane().setLayout(layout);
- layout.setHorizontalGroup(layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addComponent(jPanel2,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .addGroup(
- layout.createSequentialGroup()
- .addGap(85, 85, 85)
- .addComponent(
- jLabel1,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 219,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addContainerGap(
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE))
- .addGroup(
- javax.swing.GroupLayout.Alignment.TRAILING,
- layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(
- isReady,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE).addContainerGap()));
- layout.setVerticalGroup(layout
- .createParallelGroup(
- javax.swing.GroupLayout.Alignment.LEADING)
- .addGroup(
- layout.createSequentialGroup()
- .addContainerGap()
- .addComponent(
- jLabel1,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- 51,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(
- jPanel2,
- javax.swing.GroupLayout.PREFERRED_SIZE,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- javax.swing.GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(
- javax.swing.LayoutStyle.ComponentPlacement.RELATED,
- javax.swing.GroupLayout.DEFAULT_SIZE,
- Short.MAX_VALUE)
- .addComponent(isReady).addContainerGap()));
- pack();
- }// </editor-fold>
- private void withdrawAmountActionPerformed(
- java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- private void eatPercentageActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- private void jRadioButton2ActionPerformed(java.awt.event.ActionEvent evt) {
- // TODO add your handling code here:
- }
- private void isReadyActionPerformed(java.awt.event.ActionEvent evt) { // TODO
- // etc
- // etc
- if (jRadioButton1.isSelected()) {
- withdrawFoodTrue = true;
- }
- if (jRadioButton2.isSelected()) {
- eatFully = true;
- }
- ok_spiderEgg.this.eatPercent = Integer.parseInt(this.eatPercentage
- .getText());
- ok_spiderEgg.this.withdrawFoodies = Integer
- .parseInt(this.withdrawAmount.getText());
- waitGUI = false;
- }
- // Variables declaration - do not modify
- private javax.swing.JTextField eatPercentage;
- private javax.swing.JButton isReady;
- private javax.swing.JButton jButton1;
- private javax.swing.JLabel jLabel1;
- private javax.swing.JLabel jLabel2;
- private javax.swing.JLabel jLabel3;
- private javax.swing.JLabel jLabel4;
- private javax.swing.JLabel jLabel5;
- private javax.swing.JLabel jLabel6;
- private javax.swing.JPanel jPanel1;
- private javax.swing.JPanel jPanel2;
- private javax.swing.JRadioButton jRadioButton1;
- private javax.swing.JRadioButton jRadioButton2;
- private javax.swing.JScrollPane jScrollPane1;
- private javax.swing.JTextArea jTextArea1;
- private javax.swing.JTextField withdrawAmount;
- // End of variables declaration
- }
- // PAINTSTUFF
- private Image getImage(String url) {
- try {
- return ImageIO.read(new URL(url));
- } catch (IOException e) {
- return null;
- }
- }
- private final Image img = getImage("http://i40.tinypic.com/2whjrqw.jpg");
- private static final long startTime = System.currentTimeMillis();
- private int eggsCollected;
- // Manual price, will put this in the GUI in a later version!
- Font font = new Font("Forte", Font.PLAIN, 18);
- @Override
- public void onPaint(Graphics g) {
- Graphics2D gg = (Graphics2D) g;
- gg.drawImage(img, 9, 345, null);
- long timeRan = System.currentTimeMillis() - startTime;
- double multiplier = timeRan / 3600000D;
- int eggs = eggsCollected;
- int price = 230;
- g.setFont(font);
- g.setColor(new Color(149, 26, 12));
- g.drawString("Action: " + SCRIPT_STATE, 14, 395);
- g.drawString("Time running: " + Timing.msToString(timeRan), 14, 410);
- g.drawString("Spider eggs p/h: " + (int) (eggs / multiplier) + " p/h",
- 14, 425);
- g.drawString(
- "Profit p/h: " + ((int) (eggs / multiplier) * price) + "K", 14,
- 440);
- g.drawString("Spider eggs collected: " + eggs, 14, 455);
- g.drawString("Profit made: " + ((double) (eggs * price) / 1000) + "K",
- 14, 470);
- }
- public enum State {
- OPENING_BANK, BANKING_EGGS,
- WALKING_TO_TRAPDOOR,
- OPENING_TRAPDOOR, CLIMBING_DOWN_TRAPDOOR,
- WALKING_TO_FIRST_GATE, OPENING_FIRST_GATE,
- WALKING_TO_SECOND_GATE, OPENING_SECOND_GATE,
- WALKING_TO_SPIDERS, WALKING_TO_EGGS_1,
- WALKING_TO_EGGS_2, PICKING_UP_EGGS,
- WALKING_TO_SECOND_GATE_R,
- OPENING_SECOND_GATE_R, OPENING_FIRST_GATE_R,
- WALKING_TO_LADDER, CLIMBING_UP_LADDER, WALKING_TO_BANK,
- WAITING_FOR_EGGS, WITHDRAWING_FOOD, EATING,
- CLEARING_SPACE_IN_INVENTORY, CLOSING_BANK,
- WALKING_TO_SPIDERS_R, LOGING_OUT,
- WALKING_BACK_FROM_NORTH, WALKING_BACK_FROM_EAST;
- }
- private State getState() {
- if (closeToDestination(OUT_OF_BOUND_TILE_NORTH, 5)){
- return State.WALKING_BACK_FROM_NORTH;
- }
- if (closeToDestination(OUT_OF_BOUND_TILE_EAST, 9)){
- return State.WALKING_BACK_FROM_EAST;
- }
- if (atBank()) {
- if (Inventory.isFull()) {
- if (!Banking.isBankScreenOpen()) {
- return State.OPENING_BANK;
- }
- if (Banking.isBankScreenOpen()) {
- return State.BANKING_EGGS;
- }
- }
- if (Banking.isBankScreenOpen() && !Inventory.isFull()
- && !withdrawFood(withdrawFoodTrue)) {
- return State.CLOSING_BANK;
- }
- if (!Banking.isBankScreenOpen() && !Inventory.isFull()
- && !withdrawFood(withdrawFoodTrue)) {
- return State.WALKING_TO_TRAPDOOR;
- }
- if (!Banking.isBankScreenOpen() && !Inventory.isFull()
- && withdrawFood(withdrawFoodTrue) && !foodInInvent()) {
- return State.OPENING_BANK;
- }
- if (Banking.isBankScreenOpen() && !Inventory.isFull()
- && withdrawFood(withdrawFoodTrue) && !foodInInvent()) {
- return State.WITHDRAWING_FOOD;
- }
- if (Banking.isBankScreenOpen() && !Inventory.isFull()
- && withdrawFood(withdrawFoodTrue) && foodInInvent()) {
- return State.CLOSING_BANK;
- }
- if (!Banking.isBankScreenOpen() && !Inventory.isFull()
- && withdrawFood(withdrawFoodTrue) && foodInInvent()) {
- return State.WALKING_TO_TRAPDOOR;
- }
- }
- if (atLadderUp()) {
- if (Inventory.isFull()) {
- return State.WALKING_TO_BANK;
- }
- if (!Inventory.isFull()) {
- return State.CLIMBING_DOWN_TRAPDOOR;
- }
- }
- if (atLadderDown()) {
- if (Inventory.isFull()) {
- return State.CLIMBING_UP_LADDER;
- }
- if (!Inventory.isFull()) {
- return State.WALKING_TO_FIRST_GATE;
- }
- }
- if (atFirstGate()) {
- if (!Inventory.isFull() && !isFirstGateOpen()) {
- return State.OPENING_FIRST_GATE;
- }
- if (!Inventory.isFull() && isFirstGateOpen()) {
- return State.WALKING_TO_SECOND_GATE;
- }
- }
- if (atFirstGateR()) {
- if (!Inventory.isFull()) {
- return State.WALKING_TO_SECOND_GATE;
- }
- if (Inventory.isFull() && !isFirstGateOpen()) {
- return State.OPENING_FIRST_GATE_R;
- }
- if (Inventory.isFull() && isFirstGateOpen()) {
- return State.WALKING_TO_LADDER;
- }
- }
- if (atSecondGate()) {
- if (!Inventory.isFull()) {
- return State.OPENING_SECOND_GATE;
- }
- if (Inventory.isFull()) {
- return State.WALKING_TO_SECOND_GATE_R;
- }
- }
- if (atSecondGateR()) {
- if (!Inventory.isFull()) {
- return State.WALKING_TO_SPIDERS;
- }
- if (Inventory.isFull()) {
- return State.OPENING_SECOND_GATE_R;
- }
- }
- if (atSpiderArea()) {
- if (!Inventory.isFull() && !areEggsThereArea1()
- && !areEggsThereArea2()) {
- return State.WAITING_FOR_EGGS;
- }
- if (!Inventory.isFull() && !atFirstEggArea() && !atSecondEggArea()
- && areEggsThereArea1()) {
- return State.WALKING_TO_EGGS_1;
- }
- if (!Inventory.isFull() && atFirstEggArea() && areEggsThereArea1()) {
- return State.PICKING_UP_EGGS;
- }
- if (!Inventory.isFull() && atFirstEggArea() && !areEggsThereArea1()) {
- return State.WALKING_TO_EGGS_2;
- }
- if (!Inventory.isFull() && atSecondEggArea() && areEggsThereArea2()) {
- return State.PICKING_UP_EGGS;
- }
- if (!Inventory.isFull() && atSecondEggArea()
- && !areEggsThereArea2()) {
- return State.WALKING_TO_EGGS_1;
- }
- if (Inventory.isFull() && !foodInInvent()) {
- return State.WALKING_TO_SPIDERS_R;
- }
- if (Inventory.isFull() && eatEverything(eatFully) && foodInInvent()) {
- return State.CLEARING_SPACE_IN_INVENTORY;
- }
- if (checkHealth(eatPercent) && foodInInvent()) {
- return State.EATING;
- }
- if (checkHealth(eatPercent) && !foodInInvent()) {
- return State.WALKING_TO_SPIDERS_R;
- }
- }
- if (atSecondGateToSpidersArea()) {
- if (Inventory.isFull()) {
- return State.WALKING_TO_SPIDERS_R;
- }
- if (!Inventory.isFull()) {
- return State.WALKING_TO_SPIDERS;
- }
- }
- if (atFirstGateToSecondGateArea()) {
- if (Inventory.isFull()) {
- return State.WALKING_TO_SECOND_GATE_R;
- }
- if (!Inventory.isFull()) {
- return State.WALKING_TO_SECOND_GATE;
- }
- }
- if (atLadderToFirstGateArea()) {
- if (Inventory.isFull()) {
- return State.WALKING_TO_LADDER;
- }
- if (!Inventory.isFull()) {
- return State.WALKING_TO_FIRST_GATE;
- }
- }
- if (atEdgeArea()) {
- if (Inventory.isFull()) {
- return State.WALKING_TO_BANK;
- }
- if (!Inventory.isFull()) {
- return State.WALKING_TO_TRAPDOOR;
- }
- }
- return State.LOGING_OUT;
- }
- private State SCRIPT_STATE = getState();
- @SuppressWarnings("deprecation")
- @Override
- public void run() {
- spiderGUI g = new spiderGUI();
- g.setVisible(true);
- while (waitGUI)
- sleep(300);
- g.setVisible(false);
- println("Started collecting Spider Eggs");
- super.setRandomSolverState(true);
- Walking.setControlClick(true);
- while (true) {
- if (loggedOut()) {
- super.setLoginBotState(active);
- } else {
- while (!loggedOut()) {
- SCRIPT_STATE = getState();
- int mSpeed = General.random(130, 160);
- Mouse.setSpeed(mSpeed);
- switch (SCRIPT_STATE) {
- case CLIMBING_DOWN_TRAPDOOR:
- climbDownTrapdoor();
- sleep(800, 900);
- break;
- case CLIMBING_UP_LADDER:
- climbUpLadder();
- sleep(800, 900);
- break;
- case OPENING_BANK:
- sleep(300, 350);
- openBank();
- sleep(1000, 2000);
- break;
- case OPENING_FIRST_GATE:
- goThroughFirstGate();
- sleep(300, 350);
- break;
- case OPENING_FIRST_GATE_R:
- goThroughFirstGate();
- sleep(300, 350);
- break;
- case OPENING_SECOND_GATE:
- goThroughSecondGate();
- sleep(300, 350);
- break;
- case OPENING_SECOND_GATE_R:
- goThroughSecondGateR();
- sleep(600, 700);
- break;
- case OPENING_TRAPDOOR:
- climbDownTrapdoor();
- sleep(300, 350);
- break;
- case PICKING_UP_EGGS:
- pickUpEggs();
- sleep(300, 350);
- break;
- case WALKING_TO_BANK:
- walkDestinationCustom(bankPath, EDGE_BANK, 3);
- sleep(300, 350);
- break;
- case WALKING_TO_EGGS_1:
- walkToEggs1();
- sleep(300, 350);
- break;
- case WALKING_TO_EGGS_2:
- Walking.setControlClick(true);
- walkToEggs2();
- sleep(3000, 3500);
- break;
- case WALKING_TO_FIRST_GATE:
- walkDestinationCustom(firstGatePath, FIRST_GATE_TILE, 8);
- sleep(300, 350);
- break;
- case WALKING_TO_LADDER:
- walkDestinationCustom(firstGateRPath, LADDER_TILE_DOWN, 8);
- sleep(300, 350);
- break;
- case WALKING_TO_SECOND_GATE:
- walkDestination(secondGatePath, SECOND_GATE_TILE, secondGateArea, 8);
- sleep(300, 350);
- break;
- case WALKING_TO_SECOND_GATE_R:
- walkDestinationCustom(secondGateRPath, FIRST_GATE_TILE_R, 8);
- sleep(300, 350);
- break;
- case WALKING_TO_SPIDERS:
- walkDestinationCustom(spiderPath, SPIDER_AREA_TILE, 8);
- sleep(300, 350);
- break;
- case WALKING_TO_TRAPDOOR:
- walkDestinationCustom(trapdoorPath, TRAPDOOR_TILE_UP, 8);
- sleep(300, 350);
- break;
- case BANKING_EGGS:
- depositEggs();
- sleep(300, 350);
- break;
- case WAITING_FOR_EGGS:
- int rotation = General.random(90, 200);
- antiBan(rotation);
- sleep(250, 400);
- break;
- case CLEARING_SPACE_IN_INVENTORY:
- eatAllFood();
- sleep(300, 350);
- break;
- case EATING:
- eatFood();
- sleep(300, 350);
- break;
- case WITHDRAWING_FOOD:
- withdrawFoodAmount(withdrawFoodies);
- sleep(550, 600);
- break;
- case CLOSING_BANK:
- Banking.close();
- sleep(300, 350);
- break;
- case WALKING_TO_SPIDERS_R:
- walkDestination(spiderRPath, SECOND_GATE_TILE_R, secondGateAreaR, 8);
- sleep(300, 350);
- break;
- case LOGING_OUT:
- logout();
- stopScript();
- break;
- case WALKING_BACK_FROM_EAST:
- walkDestinationCustom(eastPath, SPIDER_AREA_TILE, 9);
- sleep(300, 350);
- break;
- case WALKING_BACK_FROM_NORTH:
- walkDestinationCustom(northPath, SPIDER_AREA_TILE, 5);
- sleep(300, 350);
- break;
- }
- }
- }
- sleep(50, 150);
- }
- }
- @Override
- public void onRandom(RANDOM_SOLVERS arg0) {
- paused = true;
- }
- @Override
- public boolean randomFailed(RANDOM_SOLVERS arg0) {
- paused = false;
- return false;
- }
- @Override
- public void randomSolved(RANDOM_SOLVERS arg0) {
- paused = false;
- }
- @Override
- public void onPause() {
- paused = true;
- while(paused){
- sleep(100, 200);
- }
- }
- @Override
- public void onResume() {
- paused = false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement