Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import java.awt.event.ActionEvent;
- import java.awt.event.ActionListener;
- import java.awt.event.ItemEvent;
- import java.awt.event.ItemListener;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import javax.swing.GroupLayout;
- import javax.swing.JButton;
- import javax.swing.JComboBox;
- import javax.swing.JFrame;
- import javax.swing.JLabel;
- import javax.swing.JTextField;
- import javax.swing.LayoutStyle;
- import javax.swing.SwingConstants;
- //import org.rsbot.client.RSItem;
- import org.rsbot.script.wrappers.RSItem;
- //import org.rsbot.client.RSPlayer;
- import org.rsbot.script.wrappers.RSPlayer;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Game;
- import org.rsbot.script.methods.Inventory;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSComponent;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSTilePath;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSWeb;
- import javax.imageio.ImageIO;
- import java.io.IOException;
- import java.net.URL;
- //End Imports
- @ScriptManifest
- (
- authors = {"MD"},
- version = 1.0,
- description = "Loots any items you want in the wilderness.",
- name = "a new Wilderness Looter (beta)"
- )
- public class wildLooterBeta extends Script implements PaintListener, MessageListener
- {
- //Global Variables
- long startingTime = System.currentTimeMillis();
- long millis = 0;
- long hour = 0;
- long minute = 0;
- long second = 0;
- long startTime = 0;
- long lastHopTime = 0;
- long lastWalkTime = 0;
- long lastBankTime = 0;
- long lastClickTime = 0;
- long lastRotateTime = 0;
- int userItemChoice = 0;
- int userItemStackLimit = 50;
- int userItemLimit = 14;
- int lastItemClicked = 0;
- int inventoryGoldCount = 0;
- int lastInventoryCount = 0;
- int totalGoldCount = 0;
- int oldGroundItemID = 0;
- boolean wasonscreen = false;
- boolean ic = false;
- boolean pickupall = false;
- String status = "";
- RSGroundItem oldGroundItem = null;
- RSGroundItem newGroundItem = null;
- RSTile bankingTile = new RSTile (3092,3495,0);
- private final Color color1 = new Color(0, 0, 0, 100);
- private final Color color2 = new Color(255,255,255);
- private final Color color3 = new Color(255,255,255);
- private final Color color5 = new Color(0, 0, 0);
- private final BasicStroke stroke1 = new BasicStroke(2);
- private final Font font1 = new Font("Sylfaen", 1, 20);
- private final Font font2 = new Font("Sylfaen", 0, 15);
- private final Font font3 = new Font("Sylfaen", 1, 13);
- private Image getImage(String url)
- {
- try
- {
- return ImageIO.read(new URL(url));
- } catch(IOException e) {
- return null;
- }
- }
- //get pic of what u are looking up
- private final Image im = getImage("http://1.gravatar.com/avatar/927fa8b1a0fc8667d1bad14e1637d2c8?s=128&d=identicon&r=G");
- private long lastCheckFunctionTime;
- private boolean isTasking;
- //End Global Variables
- private long lastHeadToItemTime;
- private RSItem ObjectClicked;
- private boolean checkInvent;
- WGUI Wgui = new WGUI();
- public boolean onStart()
- {
- log("Starting script..");
- //iCountT.start();
- mouse.setSpeed(7);
- log("Starting script..");
- Wgui.setVisible(true);
- while(Wgui.isVisible())
- {
- sleep(3);
- }
- if(userItemChoice == 0)
- pickupall = true;
- return true;
- }
- public int loop()
- {
- if(System.currentTimeMillis() - lastCheckFunctionTime > 5000 || isTasking() == true)
- {
- //log("-- part 1 --");
- lastCheckFunctionTime = System.currentTimeMillis();
- RSPlayer p = getMyPlayer();
- isTasking = false;
- if(p.isInCombat())
- {
- isTasking = true;
- runToBorder();
- if(atWall())
- {
- hopBorder();
- sleep(40);
- if(!isInWild())
- {
- walkTo(new RSTile (random(3068,3119),p.getLocation().getY(),p.getLocation().getZ()));
- sleep(5);
- }
- }
- }
- else
- if(walking.getEnergy() <= 15)
- {
- isTasking = true;
- status = "Resting until 100% (" + walking.getEnergy()+")";
- playerRest();
- }
- else
- if(inventory.getCount() > userItemLimit || stackSizeOverLimit())
- {
- isTasking = true;
- bankInventory();
- }
- else
- if(!isOnWildSide())
- {
- isTasking = true;
- runToWild();
- }
- if(isTasking == true)
- sleep(20);
- }
- else
- {
- //log("-- part 2 --");
- isTasking = false;
- RSGroundItem gi = null;
- if(pickupall == true)
- {
- gi = getClosestGroundItem();
- }
- else
- {
- gi = getClosestItem();
- }
- if(checkInvent == true && getTotalInventoryCount() > lastInventoryCount && oldGroundItemID > 0 && oldGroundItemID != 0)
- {
- checkInvent = false;
- try
- {
- inventoryGoldCount = (inventoryGoldCount) + (grandExchange.lookup(oldGroundItemID).getGuidePrice()*oldGroundItem.getItem().getStackSize());
- lastInventoryCount = getTotalInventoryCount();
- }
- catch(Exception e)
- {
- }
- }
- if(gi != null)
- {
- if(gi.isOnScreen())
- {
- wasonscreen = true;
- checkInvent = true;
- pickupGroundItem(gi);
- }
- else if(System.currentTimeMillis() - lastHeadToItemTime > 2000)
- {
- checkInvent = false;
- lastHeadToItemTime = System.currentTimeMillis();
- if(gi.getItem().getName() == null)
- status = "Heading to *FETCHING ITEM NAME*(" + gi.getItem().getStackSize() + ")";
- else
- status = "Heading to " + gi.getItem().getName() + "(" + gi.getItem().getStackSize() + ")";
- walkTo(gi.getLocation());
- }
- }
- if(wasonscreen == true)
- {
- if(gi != null)
- {
- oldGroundItem = gi;
- oldGroundItemID = gi.getItem().getID();
- wasonscreen = false;
- }
- }
- }
- if(System.currentTimeMillis() - lastRotateTime > random(10000,20000))
- {
- lastRotateTime = System.currentTimeMillis();
- camera.setAngle(random(0,200));
- }
- if(menu.isOpen())
- moveMouseFromMenu();
- return 1;
- }
- public void onFinish()
- {
- }
- public boolean isTasking()
- {
- return isTasking;
- }
- public void moveMouseFromMenu()
- {
- Point b = menu.getLocation();
- if(menu.isOpen())
- {
- int x = b.x;
- int y = b.y;
- if(random(0,2)==0)
- {
- x = x+random(-20,-50);
- }
- else
- {
- x = (x+218)+random(+20,+50);
- }
- if(random(0,2)==0)
- {
- y = y+random(-20,-50);
- }
- else
- {
- y = (y+menu.getSize()*17)+random(+20,+50);
- }
- mouse.move(x,y);
- sleep(random(10,40));
- }
- }
- public void pickupGroundItem(RSGroundItem item)
- {
- RSTile itemLocation = item.getLocation();
- String itemName = item.getItem().getName();
- String pickUpMSG = itemName;
- status = "Picking up " + itemName + " (" + item.getItem().getStackSize() +")";
- mouse.move(calc.tileToScreen(itemLocation));
- if(menu.getSize() > 2 && menu.getSize() <= 4)
- {
- if(menuHasAction("Take") && System.currentTimeMillis() - lastClickTime > 600)
- {
- item.interact("Take");
- lastClickTime = System.currentTimeMillis();
- ObjectClicked = item.getItem();
- }
- }
- else
- {
- if(menuHasAction("Take") && System.currentTimeMillis() - lastClickTime > 600)
- {
- mouse.click(false);
- sleep(1,2);
- if(menu.contains("Take"))
- {
- menu.doAction("Take " + pickUpMSG);
- lastClickTime = System.currentTimeMillis();
- ObjectClicked = item.getItem();
- }
- }
- }
- }
- public RSGroundItem getClosestGroundItem()
- {
- RSGroundItem[] it = groundItems.getAll();
- RSGroundItem temp = null;
- RSPlayer me = getMyPlayer();
- int i =0; for(i=0; i<it.length; i++)
- {
- if(temp == null)
- {
- temp = it[i];
- }
- else
- if(calc.distanceBetween(it[i].getLocation(), me.getLocation()) < calc.distanceBetween(temp.getLocation(), me.getLocation()))
- {
- if(it[i].getLocation().getY() >= 3523)
- {
- temp = it[i];
- }
- }
- }
- return temp;
- }
- public boolean menuHasAction(String a)
- {
- String[] men = menu.getActions();
- int i = 0; for(i=0; i<men.length; i++)
- if(men[i].contains(a))
- return true;
- return false;
- }
- public boolean stackSizeOverLimit()
- {
- RSItem[] it = inventory.getItems();
- int i = 0; for(i=0; i<28; i++)
- {
- if(it[i] != null && it[i].getID() != -1)
- {
- if(it[i].getStackSize() > 1)
- {
- if(it[i].getStackSize() > userItemStackLimit)
- return true;
- }
- }
- }
- return false;
- }
- public RSGroundItem getClosestItem()
- {
- RSGroundItem tempItem = null;
- tempItem = groundItems.getNearest(userItemChoice);
- if(tempItem!= null && tempItem.getLocation().getY() >= 3523)
- return tempItem;
- return null;
- }
- public boolean isInWild()
- {
- String iface = interfaces.getComponent(381,2).getText();
- if(iface.contains("Level:"))
- return true;
- return false;
- }
- public boolean isOnWildSide()
- {
- if(getMyPlayer().getLocation().getY() >= 3523)
- return true;
- return false;
- }
- public int getTotalInventoryCount()
- {
- RSItem[] invent = inventory.getItems();
- int icount = 0;
- int i = 0; for(i=0;i<invent.length; i++)
- {
- if(invent[i].getID() != -1)
- {
- if(invent[i].getStackSize() >= 2)
- {
- icount += invent[i].getStackSize();
- }
- else
- {
- icount++;
- }
- }
- }
- return icount;
- }
- public void playerRest()
- {
- if(!atWall())
- {
- status = "Heading to safety to rest.";
- runToBorder();
- }
- else
- {
- walking.rest();
- if(!walking.isRunEnabled())
- {
- walking.setRun(true);
- sleep(2000);
- }
- }
- if(walking.getEnergy() == 100)
- {
- isTasking = false;
- }
- else
- isTasking = true;
- }
- public void runToBorder()
- {
- RSObject wall = objects.getNearest(1444);
- if(wall != null)
- {
- if(!atWall())
- {
- walkTo(wall.getLocation());
- }
- }
- else
- {
- RSTile pl = getMyPlayer().getLocation();
- RSTile tile = new RSTile (pl.getX(),3520,pl.getZ());
- walkTo(tile);
- }
- }
- public void hopBorder()
- {
- status = "Hopping wall.";
- RSObject wall = objects.getNearest(1444);
- if(wall != null)
- {
- if(wall.isOnScreen())
- {
- if(System.currentTimeMillis() - lastHopTime > 4000)
- {
- wall.interact("Cross Wilderness wall");
- lastHopTime = System.currentTimeMillis();
- isTasking = false;
- sleep(2000);
- }
- }
- }
- }
- public boolean atWall()
- {
- RSObject wall = objects.getNearest(1444);
- if(wall != null)
- if(wall.isOnScreen())
- return true;
- return false;
- }
- public void bankInventory()
- {
- if(atWall() && isOnWildSide())
- {
- if(System.currentTimeMillis() - lastHopTime > 4000)
- {
- hopBorder();
- lastHopTime = System.currentTimeMillis();
- }
- }
- else
- {
- if(!isOnWildSide())
- {
- RSNPC banker = npcs.getNearest(2759);
- if(banker != null && banker.isOnScreen() && System.currentTimeMillis() - lastBankTime > 4000)
- {
- status = "Banking everything in our inventory.";
- banker.interact("Bank Banker");
- int dist = (int) calc.distanceBetween(getMyPlayer().getLocation(), banker.getLocation());
- sleep(1000 * dist);
- bank.depositAll();
- bank.close();
- totalGoldCount += inventoryGoldCount;
- inventoryGoldCount = 0;
- lastInventoryCount = 0;
- lastBankTime = System.currentTimeMillis();
- }
- else
- {
- status = "Heading to a banker.";
- walkTo(bankingTile);
- }
- }
- else
- {
- status = "Walking to the wall, bank time!";
- RSObject wall = objects.getNearest(1444);
- if(wall != null)
- walkTo(wall.getLocation());
- }
- }
- }
- public void runToWild()
- {
- if(!isOnWildSide())
- {
- if(!atWall())
- {
- runToBorder();
- }
- else
- if(System.currentTimeMillis() - lastHopTime > 4000)
- {
- hopBorder();
- lastHopTime = System.currentTimeMillis();
- }
- }
- }
- public void walkTo(RSTile tile)
- {
- if(tile != null && System.currentTimeMillis() - lastWalkTime > 1000) //&& !getMyPlayer().isMoving())
- {
- walking.walkTileMM(tile);
- lastWalkTime = System.currentTimeMillis();
- }
- }
- public void onRepaint(Graphics g1)
- {
- if (startTime == 0 && game.isLoggedIn())
- {
- startTime = System.currentTimeMillis();
- }
- float totalSec = 0;
- long millis = System.currentTimeMillis() - startTime;
- final long hours = millis / (1000 * 60 * 60);
- millis -= hours * 1000 * 60 * 60;
- final long minutes = millis / (1000 * 60);
- millis -= minutes * 1000 * 60;
- final long seconds = millis / 1000;
- totalSec = hours * 3600 + minutes * 60 + seconds;
- Graphics2D g = (Graphics2D) g1;
- g.setColor(color1);
- g.fillRoundRect(11, 12, 498, 112, 16, 16);
- g.setColor(color2);
- g.setStroke(stroke1);
- g.drawRoundRect(11, 12, 498, 112, 16, 16);
- g.setFont(font1);
- g.setColor(color3);
- g.drawString(" MD's Wilderness Looter", 22, 33);
- g.setFont(font2);
- g.drawString(String.format("RunTime: %02d:%02d:%02d", hours, minutes, seconds), 22, 55);
- g.drawImage(im, 380, 1, null);
- g.drawString("Inventory worth: " + inventoryGoldCount , 22, 75);
- g.drawString("Money Made: " + totalGoldCount, 22, 95);
- g.drawString("Status: " + status,455 - status.length()*6,330);
- }
- public void messageReceived(MessageEvent message)
- {
- }
- public class WGUI extends JFrame {
- public WGUI() {
- initComponents();
- }
- private void button1ActionPerformed(ActionEvent e)
- {
- // TODO add your code here
- userItemChoice = Integer.parseInt(textField1.getText());
- this.dispose();
- }
- private void initComponents() {
- // JFormDesigner - Component initialization - DO NOT MODIFY //GEN-BEGIN:initComponents
- // Generated using JFormDesigner Evaluation license - marc davis
- button1 = new JButton();
- textField1 = new JTextField();
- label1 = new JLabel();
- label2 = new JLabel();
- label3 = new JLabel();
- label4 = new JLabel();
- label5 = new JLabel();
- label6 = new JLabel();
- //======== this ========
- setTitle("MD's Wilderness Looter Beta");
- Container contentPane = getContentPane();
- //---- button1 ----
- button1.setText("Start");
- button1.addActionListener(new ActionListener() {
- @Override
- public void actionPerformed(ActionEvent e) {
- button1ActionPerformed(e);
- }
- });
- //---- label1 ----
- label1.setText("MD's Wilderness Looter Beta - Premium version comming soon!");
- //---- label2 ----
- label2.setText("Fill in the box with your object's ID or if you want it to");
- //---- label3 ----
- label3.setText("pick up anything, just leave it blank.");
- //---- label4 ----
- label4.setText("__________________________________________________");
- //---- label5 ----
- label5.setText("HOW TO:");
- //---- label6 ----
- label6.setText("_________________________________________________");
- //---- textfield1 ----
- textField1.setText("0");
- GroupLayout contentPaneLayout = new GroupLayout(contentPane);
- contentPane.setLayout(contentPaneLayout);
- contentPaneLayout.setHorizontalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(33, 33, 33)
- .addComponent(label2)
- .addContainerGap(37, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(134, 134, 134)
- .addComponent(label5)
- .addContainerGap(147, Short.MAX_VALUE))
- .addGroup(GroupLayout.Alignment.TRAILING, contentPaneLayout.createSequentialGroup()
- .addContainerGap(GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
- .addComponent(label6)
- .addGap(161, 161, 161))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(label1)
- .addContainerGap(157, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addContainerGap()
- .addComponent(label4)
- .addContainerGap(155, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(76, 76, 76)
- .addComponent(label3)
- .addContainerGap(216, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(141, 141, 141)
- .addComponent(textField1, GroupLayout.PREFERRED_SIZE, 26, GroupLayout.PREFERRED_SIZE)
- .addContainerGap(298, Short.MAX_VALUE))
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(126, 126, 126)
- .addComponent(button1)
- .addContainerGap(282, Short.MAX_VALUE))
- );
- contentPaneLayout.setVerticalGroup(
- contentPaneLayout.createParallelGroup()
- .addGroup(contentPaneLayout.createSequentialGroup()
- .addGap(6, 6, 6)
- .addComponent(label1)
- .addGap(5, 5, 5)
- .addComponent(label4)
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(label5)
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(label2)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(label3, GroupLayout.PREFERRED_SIZE, 14, GroupLayout.PREFERRED_SIZE)
- .addGap(11, 11, 11)
- .addComponent(label6)
- .addPreferredGap(LayoutStyle.ComponentPlacement.RELATED)
- .addComponent(textField1, GroupLayout.PREFERRED_SIZE, GroupLayout.DEFAULT_SIZE, GroupLayout.PREFERRED_SIZE)
- .addPreferredGap(LayoutStyle.ComponentPlacement.UNRELATED)
- .addComponent(button1)
- .addGap(72, 72, 72))
- );
- pack();
- setLocationRelativeTo(getOwner());
- // JFormDesigner - End of component initialization //GEN-END:initComponents
- }
- // JFormDesigner - Variables declaration - DO NOT MODIFY //GEN-BEGIN:variables
- // Generated using JFormDesigner Evaluation license - marc davis
- private JButton button1;
- private JTextField textField1;
- private JLabel label1;
- private JLabel label2;
- private JLabel label3;
- private JLabel label4;
- private JLabel label5;
- private JLabel label6;
- // JFormDesigner - End of variables declaration //GEN-END:variables
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement