Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.*;
- import org.rsbot.event.listeners.PaintListener;
- import org.rsbot.script.*;
- import org.rsbot.script.util.Timer;
- import org.rsbot.script.wrappers.*;
- @ScriptManifest(name = "Cooking Guild Re-Write", authors = {"Joe Titus"}, keywords = "Cooks Guild", version = 1.1, description = "Collects stuff in the guild")
- public class Methods extends Script implements PaintListener{
- public int doorID = 2712, hatID = 1949, bottomStairID = 24073, middleStairID = 24074,
- topStairID = 24075, chocolateID = 1973, pieDishID = 2313, jugID = 1935,
- grapeID = 1987, appleID = 1955, bankBoothID = 782, pathOptions = 0, grapesCollected = 0,
- applesCollected = 0, chocolatesCollected = 0, pieDishesCollected = 0, jugsCollected = 0;
- public int secondsWaited, missesSupressed = 0;
- public int grapeAmount, appleAmount, chocolateAmount, jugAmount, pieDishAmount;
- public int grapeAmount2, appleAmount2, chocolateAmount2, jugAmount2, pieDishAmount2;
- public int chocolatePrice = 0, pieDishPrice = 0, jugPrice = 0, grapePrice = 0, applePrice = 0, startLvl;
- public int profit, loop1 = 0, itemID, itemsDone = 0;
- public RSTile objTile = null;
- public int items [];
- int pickUpIDS [] = {1973, 2313, 1935, 1987, 1955}, stairIDS [] = {24073, 24074, 24075};
- boolean paused = false, returnStatement, climbStairs, startPaint = true, inAFK = false,
- pricesChecked = false, clickDone = false, pricesLoaded = false, loadingPrices = false, stairsClimbed = false;
- String lastFloor = "null", currentFloor = "Bottom", currentLoc;
- static String status = "Starting";
- String itemPicked = null, itemString = null;
- public RSTile doorTile = new RSTile (3143, 3443), bank1 = new RSTile(3186, 3445), bank2 = new RSTile(3186, 3435);
- public RSGroundItem groundItem1;
- public boolean grapesYes = true, applesYes = true, chocolatesYes = true, jugsYes = true, pieDishesYes = true, started = false;;
- public final RSArea westBank = new RSArea(new RSTile[] {
- new RSTile(3179, 3447), new RSTile(3179, 3432),
- new RSTile(3194, 3432), new RSTile(3194, 3447)
- });
- Timer AFKTimer = new Timer (0);
- public RSGroundItem pGrape, pApple, pChocolate, pPieDish, pJug, paintItem;
- public Polygon polly;
- public boolean antiBanTab = false, generalTab = true, paintTab = false;
- public final RSArea insideGuild = new RSArea(new RSTile[] {
- new RSTile(3141, 3444), new RSTile(3144, 3444),
- new RSTile(3148, 3448), new RSTile(3147, 3452),
- new RSTile(3142, 3454), new RSTile(3137, 3451),
- new RSTile(3137, 3448)
- });
- public int loop() {
- mouse.setSpeed(random(4, 9));
- return doAction(getState());
- }
- public state getState(){
- getLocation();
- if(AFKTimer.isRunning()) {
- return state.Paused;
- } else if (inventory.contains(1931)){
- return state.DropItem;
- } else if (inventory.isFull()){
- if (currentLoc.toLowerCase().contains("floor")){
- if (currentFloor == "Top"){
- return state.ClimbDownFromTop;
- } else if (currentFloor == "Middle"){
- return state.ClimbDownFromMiddle;
- } else if(currentFloor == "Bottom"){
- return state.ExitGuild;
- } else {
- return state.Sleep;
- }
- } else if (objects.getNearest(bankBoothID) == null || !objects.getNearest(bankBoothID).isOnScreen()){
- return state.WalkToBank;
- } else {
- return state.Bank;
- }
- } else if (!inventory.isFull()){
- if (currentLoc.toLowerCase().contains("floor")){
- if (grapesYes == true && groundItems.getNearest(grapeID) != null){
- secondsWaited = 0;
- return state.PickUpGrapes;
- } else if (applesYes == true && groundItems.getNearest(appleID) != null){
- secondsWaited = 0;
- return state.PickUpApple;
- } else if (chocolatesYes == true && groundItems.getNearest(chocolateID) != null){
- secondsWaited = 0;
- return state.PickUpChocolate;
- } else if (jugsYes == true && groundItems.getNearest(jugID) != null){
- secondsWaited = 0;
- return state.PickUpJug;
- } else if (pieDishesYes == true && groundItems.getNearest(pieDishID) != null){
- secondsWaited = 0;
- return state.PickUpPieDish;
- } else {
- return state.ClimbStairs;
- }
- } else if (currentLoc.toLowerCase().contains("inside")){
- return state.WalkToGuild;
- } else if (currentLoc.toLowerCase().contains("outside") &&
- calc.distanceTo(doorTile) > 5) {
- return state.WalkToGuild;
- } else if (currentLoc.toLowerCase().contains("outside") &&
- calc.distanceTo(doorTile) <= 5) {
- return state.EnterGuild;
- } else {
- return state.Sleep;
- }
- } else {
- return state.Sleep;
- }
- }
- private int sleep(){
- boolean exit = false;
- while (!getMyPlayer().isIdle() && !exit){
- sleep(300, 400);
- exit = (random(0, 4) == 0);
- }
- return random(0, 200);
- }
- RSWeb currentWeb = null;
- private boolean walkTo(RSTile tile){
- if (currentWeb == null || currentWeb.getEnd() != tile){
- currentWeb = web.getWeb(tile);
- return false;
- } else {
- return (currentWeb.step() && !currentWeb.finished());
- }
- }
- private int doAction(state theState) {
- switch (theState){
- case Paused:
- return sleep();
- case ClimbDownFromTop:
- status = "Leaving the guild";
- return interactObject(topStairID, "Climb-down") ? random(1500, 2000) : random(350, 750);
- case ClimbDownFromMiddle:
- status = "Leaving the guild";
- return interactObject(middleStairID, "Climb-down") ? random(1500, 2000) : random(350, 750);
- case ExitGuild:
- status = "Leaving the guild";
- return interactObject(doorID, "Open") ? random(1500, 2000) : random(350, 750);
- case WalkToBank:
- status = "Banking";
- return (walkTo(bank1) ? random(350, 750) : 50);
- case Bank:
- status = "Banking";
- return bank() ? random(500, 750) : 50;
- case WalkToGuild:
- status = "Walking to guild";
- return (walkTo(doorTile) ? random(350, 750) : 50);
- case EnterGuild:
- status = "Entering guild";
- return interactObject(doorID, "Open") ? random(1500, 2000) : random(350, 750);
- case ClimbStairs:
- status = "Climbing Stairs";
- return climbStairs() ? random(1500, 2000) : sleep();
- case DropItem:
- status = "Dropping Pot";
- RSItem i = inventory.getItem(1931);
- i.interact("Drop Empty pot");
- return random(500, 1000);
- case PickUpGrapes:
- status = "Picking up grapes";
- return pickUpItem(grapeID) ? random(750, 1250) : sleep();
- case PickUpApple:
- status = "Picking up apples";
- return pickUpItem(appleID) ? random(750, 1250) : sleep();
- case PickUpChocolate:
- status = "Picking up chocolates";
- return pickUpItem(chocolateID) ? random(750, 1250) : sleep();
- case PickUpJug:
- status = "Picking up jugs";
- return pickUpItem(jugID) ? random(750, 1250) : sleep();
- case PickUpPieDish:
- status = "Picking up pie dishes";
- return pickUpItem(pieDishID) ? random(750, 1250) : sleep();
- case Sleep:
- return sleep();
- default:
- return 0;
- }
- }
- private boolean bank(){
- if (bank.isOpen()){
- if (inventory.isFull()){
- return bank.depositAll();
- } else {
- return bank.close();
- }
- } else {
- return bank.open();
- }
- }
- public boolean interactObject(int ID, String s){
- RSObject obj = objects.getNearest(ID);
- if (obj == null || !obj.isReachable()){
- return false;
- }
- if (!obj.isOnScreen()){
- return walking.walkTileMM(obj.getLocation());
- }
- return obj.interact(s);
- }
- public boolean pickUpItem(int ID){
- RSGroundItem g = groundItems.getNearest(ID);
- if (g == null){
- return false;
- }
- if (!g.isOnScreen()){
- return walking.walkTileMM(g.getLocation());
- }
- return newTaker(g);
- }
- public enum state{
- ClimbDownFromTop, ClimbDownFromMiddle, ExitGuild, WalkToBank, Bank,
- WalkToGuild, EnterGuild, ClimbStairs, DropItem, Sleep, NOTHING, Paused,
- PickUpGrapes, PickUpApple, PickUpChocolate, PickUpJug, PickUpPieDish
- }
- public boolean newTaker(RSGroundItem g){
- RSTile t = g.getLocation();
- if (getMyPlayer().isIdle()) {
- if (objects.getTopAt(t) != null){
- if(atTile(t, -500, .5, .5, g.getItem().getName())){
- clickDone = true;
- return true;
- } else {
- return false;
- }
- } else {
- if(atTile(t, 0, .5, .5, g.getItem().getName())){
- clickDone = true;
- return true;
- } else {
- return false;
- }
- }
- } else {
- return false;
- }
- }
- public boolean atTile(final RSTile tile, final int h, final double xd, final double yd, String s) {
- try {
- final Point location = calc.tileToScreen(tile, xd, yd, h);
- if (location.x == -1 || location.y == -1) {
- return false;
- }
- mouse.move(location, 4, 4);
- if (menu.contains("Take " + s)){
- menu.doAction("Take " + s);
- } else {
- return false;
- }
- return true;
- } catch (final Exception e) {
- return false;
- }
- }
- public void getLocation() {
- if (insideGuild.contains(new RSTile(getMyPlayer().getLocation().getX(), getMyPlayer().getLocation().getY(), 0))){
- RSObject stairs = objects.getNearest(stairIDS);
- if (stairs.getID() == bottomStairID) {
- currentLoc = "Bottom Floor";
- currentFloor = "Bottom";
- if (lastFloor == "null") {
- lastFloor = "Bottom";
- }
- } else if (stairs.getID() == middleStairID) {
- currentLoc = "Middle Floor";
- currentFloor = "Middle";
- if (lastFloor == "null") {
- lastFloor = "Bottom";
- }
- } else if (stairs.getID() == topStairID) {
- currentLoc = "Top Floor";
- currentFloor = "Top";
- if (lastFloor == "null") {
- lastFloor = "Top";
- }
- }
- } else if (westBank.contains(getMyPlayer().getLocation())){
- currentLoc = "Inside Bank";
- if (lastFloor == "null") {
- lastFloor = "Bottom";
- }
- } else {
- currentLoc = "Outside";
- if (lastFloor == "null") {
- lastFloor = "Bottom";
- }
- }
- }
- public boolean climbStairs() {
- RSObject stairs = objects.getNearest(stairIDS);
- if (!getMyPlayer().isIdle() || stairs == null){
- return false;
- }
- if (!stairs.isOnScreen()){
- return walking.walkTileMM(stairs.getLocation());
- }
- try{
- if (stairs.getID() == bottomStairID) {
- stairsClimbed = true;
- stairs.interact("Climb-up");
- lastFloor = "Bottom";
- currentFloor = "Middle";
- } else if (stairs.getID() == middleStairID) {
- stairsClimbed = true;
- if (lastFloor == "Bottom") {
- currentFloor = "Top";
- stairs.interact("Climb-up");
- } else if (lastFloor == "Top") {
- stairs.interact("Climb-down");
- currentFloor = "Bottom";
- }
- } else if (stairs.getID() == topStairID) {
- stairsClimbed = true;
- stairs.interact("Climb-down");
- lastFloor = "Top";
- currentFloor = "Middle";
- }
- return true;
- } catch (Exception e){
- return false;
- }
- }
- @Override
- public void onRepaint(Graphics g1) {
- Graphics2D g = (Graphics2D) g1;
- g.setColor(Color.WHITE);
- g.drawString("Status: " + status, 5, 35);
- g.drawOval(mouse.getLocation().x-1, mouse.getLocation().y-1, 2, 2);
- }
- }
Add Comment
Please, Sign In to add comment