Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.BasicStroke;
- import java.awt.Color;
- import java.awt.Font;
- import java.awt.Graphics;
- import java.awt.Graphics2D;
- import java.awt.Image;
- import java.awt.Point;
- import java.awt.Rectangle;
- import java.awt.event.KeyEvent;
- import java.awt.event.MouseEvent;
- import java.awt.event.MouseListener;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.net.URL;
- import java.net.URLConnection;
- import java.util.ArrayList;
- import java.util.List;
- import javax.imageio.ImageIO;
- import javax.swing.JOptionPane;
- import org.rsbot.event.events.MessageEvent;
- import org.rsbot.event.listeners.MessageListener;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.methods.Magic;
- import org.rsbot.script.Script;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.script.methods.Skills;
- import org.rsbot.script.methods.GrandExchange.GEItem;
- import org.rsbot.script.util.Filter;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.RSArea;
- import org.rsbot.script.wrappers.RSGroundItem;
- import org.rsbot.script.wrappers.RSItem;
- import org.rsbot.script.wrappers.RSNPC;
- import org.rsbot.script.wrappers.RSObject;
- import org.rsbot.script.wrappers.RSPath;
- import org.rsbot.script.wrappers.RSTile;
- import org.rsbot.script.wrappers.RSTilePath;
- @ScriptManifest(authors = "M1ckst3r", name = "Cow Looter", keywords = "Moneymaking", description = "Loots cowhides and bones in Lumbridge", version = 1.00)
- public class CowLooter extends Script implements PaintListener {
- final int HidesID = 1739;
- final int BonesID = 526;
- final int MeatID = 2132;
- final int[] stairsID = {36774, 36773,36775};
- final int BankerID = 494;
- public int IBStart = 0;
- public int IMStart = 0;
- public int IHStart = 0;
- public float Bones;
- public float Hides;
- public float BonesPrice;
- public float HidesPrice;
- public int curtime;
- public int hour;
- public int min;
- public int sec;
- public int atstart = 1;
- RSArea CowArea = new RSArea(new RSTile(3253,3255),new RSTile(3266,3299));
- RSArea CowArea2 = new RSArea(new RSTile(3245,3279),new RSTile(3266,3299));
- RSArea BankArea = new RSArea(new RSTile(3207,3221),new RSTile(3210,3215));
- RSArea GateArea = new RSArea(new RSTile(3255,3269),new RSTile(3250,3264));
- RSArea StairsArea = new RSArea(new RSTile(3203,3206),new RSTile(3209,3213));
- RSArea BridgeArea = new RSArea(new RSTile(3249,3265),new RSTile(3228,3258));
- RSArea CEArea = new RSArea(new RSTile(3225,3221), new RSTile(3232,3216));
- RSArea AnnoyingHouse = new RSArea(new RSTile(3229,3241), new RSTile(3232,3236));
- RSTile StairsTile = new RSTile(3206,3210);
- RSTile CETile = new RSTile(3229,3218);
- RSTile BridgeTile = new RSTile(3235,3262);
- RSTile BankTile = new RSTile(3208,3220);
- RSTile GateTile = new RSTile(3254,3266);
- RSTile dest;
- RSTile Nearest;
- final int gateClosedID = 45212;
- final int gateOpenID = 45213;
- public String state;
- public String stateMsg;
- GEItem bonesGE;
- GEItem hidesGE;
- private boolean takepic = false;
- private long STime;
- private long starttime;
- private void Screenshot(int hour) {
- if (!takepic) {
- STime = System.currentTimeMillis();
- takepic = true;
- }
- if (takepic && (System.currentTimeMillis() - STime) >= (3600000 * hour)) {
- env.saveScreenshot(true);
- takepic = false;
- }
- }
- public int loop(){
- Screenshot(1);
- if(atstart==1){
- setStartInvCount();
- getPrices();
- starttime = System.currentTimeMillis();
- atstart = 0;
- state = "teleport";
- }
- state = getState();
- if (state == "loot"){
- stateMsg = "Looting";
- loot(HidesID, BonesID, 15);
- sleep(random(500,1000));
- if(IBStart!=(int)inventory.getCount(BonesID)){
- Bones+=1;
- setStartInvCount();
- }
- if(IHStart!=(int)inventory.getCount(HidesID)){
- Hides+=1;
- setStartInvCount();
- }
- }
- if (state == "walkGate"){
- stateMsg = "Walking to gate";
- walkTo(GateTile, 3, 3, 4);
- }
- if (state == "openGate"){
- stateMsg = "Opening gate";
- openGate();
- }
- if (state == "walkStairs"){
- stateMsg = "Walking to stairs";
- walkTo(StairsTile, 1, 1, 3);
- }
- if (state == "walkCE"){
- stateMsg = "Walking to castle entrance";
- walkTo(CETile, 4, 4, 4);
- }
- if (state == "walkCows"){
- stateMsg = "Walking into the cow area";
- walkTo(new RSTile(random(3253,3264),random(3255,3296)), 0, 0, 0);
- }
- if (state == "climbUpStairs"){
- stateMsg = "Climbing up the stairs";
- climbStairs("up");
- }
- if (state == "climbDownStairs"){
- stateMsg = "Climbing down the stairs";
- climbStairs("down");
- }
- if (state == "walkBridge"){
- stateMsg = "Walking to the bridge";
- walkTo(BridgeTile, 4, 4, 5);
- }
- if (state == "doBank"){
- stateMsg = "Banking";
- doBank();
- setStartInvCount();
- }
- if (state == "walkBank"){
- stateMsg = "Walking to the bank";
- walkTo(BankTile, 2, 2, 3);
- }
- if (state == "teleport"){
- stateMsg = "Teleporting";
- teleport();
- if(inventory.isFull()) state = "walkStairs";
- else state = "walkCE";
- }
- return 0;
- }
- public void setStartInvCount(){
- IBStart = inventory.getCount(BonesID);
- IHStart = inventory.getCount(HidesID);
- }
- public void getPrices(){
- log("Getting the prices of the items from the GE. This can take a while.");
- bonesGE = grandExchange.lookup(BonesID);
- hidesGE = grandExchange.lookup(HidesID);
- BonesPrice = bonesGE.getMarketPrice();
- HidesPrice = hidesGE.getMarketPrice();
- }
- public void teleport(){
- if(magic.castSpell(Magic.SPELL_HOME_TELEPORT)) sleep(random(13000,18000));
- }
- public void openGate(){
- if(!players.getMyPlayer().isMoving()){
- RSObject gate = objects.getNearest(gateClosedID);
- if(gate!=null){
- camera.turnToTile(gate.getLocation());
- gate.doAction("Open");
- sleep(random(500,1000));
- }
- }
- }
- public void climbStairs(String direction){
- if(!players.getMyPlayer().isMoving()){
- RSObject stairs = objects.getNearest(stairsID);
- if(stairs != null){
- if(!stairs.isOnScreen()) camera.turnToTile(stairs.getLocation().randomize(1,1));
- stairs.doAction("Climb-"+direction);
- sleep(random(750,1250));
- }
- }
- }
- public void walkTo(RSTile destination, int xvar, int yvar, int distance){
- setRun();
- if ((!players.getMyPlayer().isMoving())||(calc.distanceTo(dest)<distance)) {
- dest = walking.getClosestTileOnMap(destination.randomize(xvar, yvar));
- while (AnnoyingHouse.contains(dest)) dest = dest.randomize(2,2);
- walking.walkTileMM(dest);
- sleep(random(750,1500));
- }
- }
- public void doBank(){
- RSNPC banker = npcs.getNearest(BankerID);
- if((!players.getMyPlayer().isMoving())&&(banker!=null)){
- if(!banker.isOnScreen()) camera.turnToTile(banker.getLocation().randomize(1,1));
- if(!bank.isOpen()){
- banker.doAction("Bank Banker");
- sleep(random(1000,1500));
- }
- else{
- bank.depositAll();
- sleep(random(1000,1500));
- bank.close();
- }
- }
- }
- private String getState(){
- if(inventory.isFull()){
- RSNPC banker = npcs.getNearest(BankerID);
- if(StairsArea.contains(getMyPlayer().getLocation())){
- if (banker == null) return "climbUpStairs";
- else return "walkBank";
- }
- else if((BankArea.contains(getMyPlayer().getLocation()))&&(banker != null)) return "doBank";
- else if(calc.distanceTo(StairsTile)>25)state = "teleport";
- }
- else{
- if(BankArea.contains(getMyPlayer().getLocation())) return "walkStairs";
- RSObject stairs = objects.getNearest(36773);
- if(StairsArea.contains(getMyPlayer().getLocation())){
- if(stairs == null) return "climbDownStairs";
- else return "walkCE";
- }
- if(CEArea.contains(getMyPlayer().getLocation())) return "walkBridge";
- if(BridgeArea.contains(getMyPlayer().getLocation())) return "walkGate";
- if((CowArea.contains(getMyPlayer().getLocation()))||(CowArea2.contains(getMyPlayer().
- getLocation()))) return "loot";
- else if(GateArea.contains(getMyPlayer().getLocation())){
- if(objects.getNearest(gateOpenID)!= null) return "walkCows";
- else return "openGate";
- }
- }
- return state;
- }
- public int loot(int lootID, int lootID2, int distance) {
- setRun();
- if (players.getMyPlayer().isMoving()) return 1;
- RSGroundItem loot = groundItems.getNearest(lootID);
- if((loot == null)||calc.distanceTo(loot.getLocation())>distance) loot = groundItems.getNearest(lootID2);
- if (loot != null) {
- if(CowArea.contains(loot.getLocation())||(CowArea2.contains(loot.getLocation()))) {
- if(!loot.isOnScreen()) camera.turnToTile(loot.getLocation());
- if (!inventory.isFull()) {
- if (!loot.isOnScreen()) {
- walking.walkTileMM(walking.getClosestTileOnMap(loot.getLocation()));
- return 1;
- }
- loot.doAction("Take " + loot.getItem().getName());
- sleep(random(500, 1000));
- return 1;
- }
- }
- }
- walkTo(new RSTile(random(3253,3264),random(3255,3296)), 0, 0, 0);
- return 1;
- }
- public void setRun() {
- if (walking.getEnergy() > random(25, 100)) walking.setRun(true);
- sleep(250);
- }
- public void onRepaint(Graphics g){
- g.setColor(new Color(0,0,0,255));
- g.fillRect(0,335,518,142);
- g.setColor(new Color(255,255,255,255));
- curtime = (int)(System.currentTimeMillis()-starttime)/1000;
- hour = curtime/60/60;
- min = (curtime - hour*3600)/60;
- sec = (curtime - hour*3600)-min*60;
- g.drawString("Time ran: "+hour+":"+min+":"+sec,5,350);
- g.drawString("Bones: "+((int)Bones),5,365);
- g.drawString("Bones/h: "+(Bones/curtime*3600),200,365);
- g.drawString("Hides: "+((int)Hides),5,380);
- g.drawString("Hides/h: "+(Hides/curtime*3600),200,380);
- g.drawString("Profit: approx. "+((int)(Bones*BonesPrice+Hides*HidesPrice))+"gp",5,395);
- g.drawString("Profit/h: approx. "+((Bones*BonesPrice+Hides*HidesPrice)/curtime*3600)+" gp",200,395);
- g.drawString("Action: "+stateMsg,5,410);
- g.setFont(new Font("Verdana", 0, 20));
- g.drawString("CowLooter by M1ckst3r",5,470);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement