- import java.awt.*;
- import org.rsbot.script.Script;
- import org.rsbot.script.methods.*;
- import org.rsbot.script.wrappers.*;
- import org.rsbot.script.ScriptManifest;
- import org.rsbot.event.listeners.PaintListener;
- import java.awt.image.BufferedImage;
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.net.URL;
- import javax.imageio.ImageIO;
- @ScriptManifest (authors = "WarLord Burn (Kieren Boal)",
- name = "Chicken Theft",
- description = "Start at Port Sarim, next to the crate that loots chickens.",
- version = 1.00)
- public class ChickenTheft extends Script implements PaintListener{
- long startTime;
- RSObject Crate, Door, Door2, DepositBox;
- int LootFailSafe, DepositFailSafe, DoorFailSafe, Looted, Deposits, Price, Delay, SleepDelay, CrateID=15032, DoorID=2069, Door2ID=40108, DepositBoxID=36788, ChickenID=2138;
- RSTile CheckPoint1, CheckPoint2, CheckPoint3, CheckPoint4, CheckPoint5;
- BufferedImage MainPicture, Users;
- boolean CP1, CP2, CP3, CP4, CP5;
- public boolean onStart() {
- try {
- Users = ImageIO.read(new URL ("http://www.webcounter.com/4d8362b90a47f/counter.png"));
- MainPicture = ImageIO.read(new URL ("http://img838.imageshack.us/img838/7672/44569764.png"));
- }catch (final IOException e) {
- log("Images have failed to load!");
- e.printStackTrace();
- }
- Price = grandExchange.lookup(ChickenID).getGuidePrice();
- log("Raw chicken Guide Price: "+Price+"gp.");
- camera.setPitch(0);
- if (!game.isFixed()) {log.severe("Failed to start up. Please change graphics to 'fixed' mode!"); return false;}
- if (equipment.getItem(Equipment.BODY).getID()!=1005) {log.severe("Failed to start up. Please start the script while wearing a 'White apron'!"); return false;}
- startTime = System.currentTimeMillis();
- return true;
- }
- public void onFinish() {
- log.severe("--WarLord Burn's Chicken Theft 1.00--");
- //env.saveScreenshot(true);
- }
- public boolean epicFailSafe() {
- if (players.getMyPlayer().getLocation().getX()<2950) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
- if (players.getMyPlayer().getLocation().getX()>3100) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
- if (players.getMyPlayer().getLocation().getY()>3300) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
- if (players.getMyPlayer().getLocation().getY()<3100) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
- if (!game.isLoggedIn()) {log.severe("epicFailSafe()==false; Saved the day!"); return false;}
- return true;
- }
- public boolean canLoot() {
- if (players.getMyPlayer().getLocation().getX()>3008 && players.getMyPlayer().getLocation().getX()<3012 && players.getMyPlayer().getLocation().getY()<3211 && players.getMyPlayer().getLocation().getY()>3202) {return true;}
- return false;
- }
- public boolean inHouse() {
- if (players.getMyPlayer().getLocation().getX()>3008 && players.getMyPlayer().getLocation().getX()<3017 && players.getMyPlayer().getLocation().getY()<3211 && players.getMyPlayer().getLocation().getY()>3202) {return true;}
- return false;
- }
- public void LootChicken() {
- if (canLoot()==false) {
- if (inHouse()==false){openDoor2();}
- if (inHouse()==true) {openDoor();}
- sleep(SleepDelay);
- }
- if (canLoot()==true) {
- Crate=objects.getNearest(CrateID);
- if (Crate!=null && !Crate.isOnScreen()) {camera.turnToObject(Crate);}
- if (Crate!=null && Crate.isOnScreen()) {
- mouse.move(Crate.getModel().getPoint());
- Crate.doAction("Search Crates");
- sleep(1,2000);
- mouse.move(random(240,280),random(395,410));
- while (!interfaces.get(228).isValid() && LootFailSafe<30 && epicFailSafe()==true){sleep(50,250);
- LootFailSafe++;
- int i=random(1,150);
- if (i==5) {camera.setAngle(camera.getAngle()+random(-20,21));}
- }
- LootFailSafe=0;
- mouse.click(true);
- Looted++;
- }
- }
- }
- public void proWalk(boolean B, RSTile T){
- walking.walkTileMM(T);
- while (B==false && epicFailSafe()==true) {
- int i=random(1,10000);
- if (i==5) {camera.setAngle(camera.getAngle()+random(-20,21));;}
- if (calc.distanceTo(T) > 5 && players.getMyPlayer().isMoving()==false) {walking.walkTileMM(T);}
- if (calc.distanceTo(T) < 6) {B=true;}
- sleep(1);
- }
- }
- public void openDoor() {
- if(!walking.isRunEnabled()) {Delay=random(950,1050);}
- if(walking.isRunEnabled()) {Delay=random(450,550);}
- Door=objects.getNearest(DoorID);
- if (Door!=null && !Door.isOnScreen()) {camera.turnToObject(Door);}
- if (Door!=null && Door.isOnScreen()) {Door.doAction("Open Door"); SleepDelay=calc.distanceTo(Door.getLocation())*Delay*2;}
- }
- public void openDoor2() {
- if(!walking.isRunEnabled()) {Delay=random(950,1050);}
- if(walking.isRunEnabled()) {Delay=random(450,550);}
- Door2=objects.getNearest(Door2ID);
- if (Door2!=null && !Door2.isOnScreen() && Door2.getLocation().getY()==3206 && Door2.getLocation().getX()==3017) {
- if (inHouse()==false) {camera.turnToObject(Door2);}
- if (inHouse()==true) {camera.setAngle(random(270,335));}
- }
- if (Door2!=null && Door2.isOnScreen() && Door2.getLocation().getY()==3206 && Door2.getLocation().getX()==3017) {Door2.doAction("Open Door"); SleepDelay=calc.distanceTo(Door2.getLocation())*Delay;}
- if (Door2!=null && Door2.getLocation().getY()!=3206 && Door2.getLocation().getX()!=3017) {
- if (inHouse()==true) {walking.walkTileMM(new RSTile(3023,3206)); SleepDelay=calc.distanceTo(new RSTile(3023,3206))*Delay;}
- if (inHouse()==false) {walking.walkTileMM(new RSTile(3013,3206)); SleepDelay=calc.distanceTo(new RSTile(3013,3206))*Delay;}
- }
- }
- public void depositChickens() {
- DepositFailSafe=0;
- while (!interfaces.get(11).isValid() && epicFailSafe()==true){
- sleep(1);
- DepositFailSafe--;{
- if (DepositFailSafe<0) {
- DepositBox=objects.getNearest(DepositBoxID);
- if (DepositBox!=null && !DepositBox.isOnScreen()) {camera.turnToObject(DepositBox);}
- if (DepositBox!=null && DepositBox.isOnScreen()) {
- mouse.move(DepositBox.getModel().getPoint());
- DepositBox.doAction("Deposit bank deposit box");
- mouse.move(random(320,375),random(260,295));
- DepositFailSafe=5000;
- }
- }
- }
- }
- if (interfaces.get(11).isValid()){
- Deposits++;
- sleep(200,500);
- mouse.click(random(338,358),random(271,285),true);
- CP1=false;
- CP2=false;
- CP3=false;
- CP4=false;
- CP5=false;
- }
- }
- public void goBank() {
- CheckPoint1 = new RSTile(3025+random(-1,2), 3207+random(-1,2));
- CheckPoint2 = new RSTile(3027+random(0,2), 3221+random(-1,2));
- CheckPoint3 = new RSTile(3028+random(-1,2), 3231+random(-1,2));
- CheckPoint4 = new RSTile(3036+random(-3,4), 3236+random(-1,2));
- CheckPoint5 = new RSTile(3047+random(-3,4), 3235+random(-1,2));
- if(!walking.isRunEnabled() && walking.getEnergy()>random(25,50)){walking.setRun(true);}
- while (inHouse()==true && epicFailSafe()==true){
- if (canLoot()==true) {openDoor();}
- if (canLoot()==false) {openDoor2();}
- sleep(SleepDelay);
- }
- proWalk(CP1, CheckPoint1);
- proWalk(CP2, CheckPoint2);
- proWalk(CP3, CheckPoint3);
- proWalk(CP4, CheckPoint4);
- proWalk(CP4, CheckPoint5);
- depositChickens();
- if(!walking.isRunEnabled() && walking.getEnergy()>random(25,50)){walking.setRun(true);}
- proWalk(CP4, CheckPoint4);
- proWalk(CP3, CheckPoint3);
- proWalk(CP2, CheckPoint2);
- proWalk(CP1, CheckPoint1);
- while (canLoot()==false && epicFailSafe()==true) {
- if (inHouse()==false) {openDoor2();}
- if (inHouse()==true) {openDoor();}
- sleep(SleepDelay);
- }
- }
- public int loop() {
- camera.setPitch(0);
- mouse.setSpeed(random(4,8));
- if (inventory.getCount()<27) {LootChicken();}
- if (inventory.getCount()>26) {goBank();}
- return 100;
- }
- public void onRepaint(Graphics g) {
- g.setFont(new Font("Arial", 0, 16));
- g.setColor(new Color(0,0,0));
- g.drawImage(MainPicture,0,338,null);
- g.drawImage(Users,436,320,null);
- long millis = System.currentTimeMillis() - startTime;
- long hours = millis / (1000 * 60 * 60);
- millis -= hours * (1000 * 60 * 60);
- long minutes = millis / (1000 * 60);
- millis -= minutes * (1000 * 60);
- long seconds = millis / 1000;
- double lootHr = Looted*3600000/(System.currentTimeMillis()-startTime);
- g.drawString(hours+":"+minutes+":"+seconds, 107,370);
- g.drawString(""+Looted,63,395);
- g.drawString(""+lootHr,63,417);
- g.drawString(((Looted*Price)/1000)+"k ("+Price+"gp each)",63,445);
- g.drawString(((lootHr*Price)/1000)+"k",63,465);
- g.setColor(new Color(255,0,0));
- g.fillOval(mouse.getLocation().x-10, mouse.getLocation().y-1, 22, 3);
- g.fillOval(mouse.getLocation().x-1, mouse.getLocation().y-10, 3, 22);
- }
- }