Ask Me Help Desk

Ask Me Help Desk (https://www.askmehelpdesk.com/forum.php)
-   Javascript (https://www.askmehelpdesk.com/forumdisplay.php?f=452)
-   -   What is wrong with this script? (https://www.askmehelpdesk.com/showthread.php?t=293671)

  • Dec 18, 2008, 04:50 PM
    nobodyman1
    What is wrong with this script?
    Code:

    import java.awt.*;
    import com.speljohan.rsbot.script.*;
    import com.speljohan.rsbot.script.wrappers.*;
    import com.speljohan.rsbot.bot.Bot;
    import com.speljohan.rsbot.script.wrappers.RSObject ;

    public class SwampScavenger extends Script {


        long                            lastCheck = 0;
        public long                    time = System.currentTimeMillis();
        public long                    startTime = System.currentTimeMillis();
        int                            checkTime;
        int                            GambleInt;
        int                            randomRunValue = 30;
        public int                        tar = 1939;



        @Override
        public String getScriptCategory() {
            return "HtsTigers03/Money Making";
        }

        public double getVersion() {
            return 1.0;
        }


        public String getName() {
            return "SwampScavenger";
        }

        public String getAuthor() {
            return "HtsTigers03";
       


        public boolean onStart(String[] args) {
        return true;

        }


        public int loop() {
            runEnable();
            if (getMyPlayer( ).isInCombat( )) {
                runAway();
                }
            RSItemTile TAR = getNearestGroundItemByID(25,tar);
            if (TAR != null){
                if (goTo(TAR)){
                    if(getMyPlayer().isMoving())return random(200,500);
                    if(atTile(TAR,"Take")){
                        log("Got Tar!");
                    }
                }
            }


            return random(500,1000);
        }



          public boolean goTo(RSTile t){
                return goTo(t,5);
            }
            // walks in strait line to tile, returns True when within set range of tile.
          public boolean goTo(RSTile t,int range) {  //Walking method by Bug5532
              if (distanceTo(t) < range) return true;

                  if (distanceTo(t) < 13){
                      walkTileMM(t);
                      wait(random(500,1000));
                      return false;
                  }

                  while(true){
                        t = new RSTile( ((t.getX()+getMyPlayer().getLocation().getX())/2)+random(-1,1) , ((t.getY()+getMyPlayer().getLocation().getY())/2)+random(-1,1) ) ;
                        if (distanceTo(t) < 15){
                            walkTileMM(t);
                            wait(random(500,1000));
                            break;
                        }
                }

              return false;
          }


        public RSItemTile getNearestGroundItemByID( int[] ids) {
            return getNearestGroundItemByID(50,ids);
        }
        public RSItemTile getNearestGroundItemByID( int range, int id) {
            int[] j = {id};
            return getNearestGroundItemByID(range,j);
        }

        public RSItemTile getNearestGroundItemByID(int range, int[] ids) {
            int pX = getMyPlayer().getLocation().getX();
            int pY = getMyPlayer().getLocation().getY();
            int minX = pX - range;
            int minY = pY - range;
            int maxX = pX + range;
            int maxY = pY + range;
            int dist = 100;
            RSItemTile nItem = null;
            for (int x = minX; x <= maxX; x++) {
                for (int y = minY; y <= maxY; y++) {
                    if (Calculations.canReach(new RSTile(x,y), false)){
                        RSItemTile[] items = getGroundItemsAt(x, y);
                        for (RSItemTile item : items) {
                            int iId = item.getItem().getID();
                            for (int id : ids) {
                                if (iId == id) {
                                //    log(""+id+" at "+x+","+y);
                                    if (distanceTo(new RSTile(x,y)) < dist){
                                        dist = distanceTo(new RSTile(x,y));
                                        nItem = item;
                                    }



                                }
                            }
                       
                    }
                }
            }
            return nItem;
        }



            public void runEnable() {
                    if(getEnergy() > random(60, 100)) {
                setRun(true);
                }
            }
    //AELIN'S ANTIBAN
            public int AntiBan() {
            GambleInt = random(1, 5);
            if (GambleInt == 1) {
                wait(random(2000, 2000));
            }
            if (GambleInt == 2) {
                int xA = random(0, 750);
                int yA = random(0, 500);
                moveMouse(0, 0, xA, yA);
            }
            if (GambleInt == 3) {
                if (getCurrentTab() != TAB_INVENTORY) {
                    openTab(TAB_INVENTORY);
                }
            }
            if (GambleInt == 4) {
                if (getMyPlayer().isMoving()) {
                    return (random(500, 1750));
                }

                if ((System.currentTimeMillis() - lastCheck) >= checkTime) {
                    lastCheck = System.currentTimeMillis();
                    checkTime = random(300000, 600000);

                    if (getCurrentTab() != TAB_STATS) {
                        openTab(TAB_STATS);
                    }
                    moveMouse(627, 240, 52, 29);
                    return (random(3000, 6000));
                }
            }

            return (random(500, 1000));
        }

            public void runAway() {

            RSTile Foo;
            RSTile Bar;

            Foo = getMyPlayer().getLocation();
            setRun(true);

            Bar = new RSTile(Foo.getX() + random(8, 10), Foo.getY() + random(8, 10));

            walkTileMM(Bar);
            wait(random(4000, 5000));
            walkTileMM(Foo);
       

    }


    What is wrong with it?

    Thanks.

  • All times are GMT -7. The time now is 03:04 AM.