Ezud.com - Trolling Assistance Forum

Ezud.com - Trolling Assistance Forum (http://ezud.com/forum/index.php)
-   Runescape Botting (http://ezud.com/forum/forumdisplay.php?f=194)
-   -   Thr33's PC Script [RSBOT] (http://ezud.com/forum/showthread.php?t=7138)

thr33 07-02-2009 11:08 AM

Thr33's PC Script [RSBOT]
 
Hey guys, this is my rsbot pc script.

If you don't want to spend points, just click start without checking box, otherwise check box + choose stat.

Code:

import java.awt.Component;

import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Point;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.UIManager;
import javax.swing.table.DefaultTableModel;

import com.speljohan.rsbot.accessors.NPC;
import com.speljohan.rsbot.bot.Bot;
import com.speljohan.rsbot.event.events.ServerMessageEvent;
import com.speljohan.rsbot.event.listeners.PaintListener;
import com.speljohan.rsbot.event.listeners.ServerMessageListener;
import com.speljohan.rsbot.script.Calculations;
import com.speljohan.rsbot.script.Script;
import com.speljohan.rsbot.script.Skills;
import com.speljohan.rsbot.script.wrappers.RSCharacter;
import com.speljohan.rsbot.script.wrappers.RSInterface;
import com.speljohan.rsbot.script.wrappers.RSInterfaceChild;
import com.speljohan.rsbot.script.wrappers.RSNPC;
import com.speljohan.rsbot.script.wrappers.RSObject;
import com.speljohan.rsbot.script.wrappers.RSPlayer;
import com.speljohan.rsbot.script.wrappers.RSTile;

public class Thr33PC extends Script implements PaintListener,
                ServerMessageListener {
        String[] mobs = { "Shifter", "Defiler", "Torcher", "Brawler", "Ravager",
                        "Spinner" };

        public long startTime = System.currentTimeMillis();


        int BOAT = 14315;
        int KNIGHTID = 3802;
        int VOIDID = 3781;

        RSTile curPortal = null;
        boolean inPest = false;
        Thread anti;

        long lol = 0;

        int currPortal;

        boolean walking = false;
        boolean openPortal = false;
        RSTile voidloc = null;
        int GATE_CLOSED[] = { 14235, 14233, 14239, 14237 };
        ArrayList<RSTile> u = new ArrayList<RSTile>();

        int points = 1;

        boolean spend = false;
        @Override
        public String getName() {
                return "Thr33PC";
        }

        @Override
        public double getVersion() {
                return 1.0;
        }

        @Override
        public String getAuthor() {
                return "Thr33";
        }

        @Override
        public String getScriptCategory() {
                return "Combat";
        }

        @Override
        public String getScriptDescription() {
                String html = "";
                html += "<html>\n";
                html += "<body>\n";
                html += "<h2>" + getName() + " v" + getVersion() + "</h2><br>\n";
                html += "Author: " + getAuthor() + "<br><br>\n";
                html += "Description: This Script plays Pest Control for you.";
                html += "</body>\n";
                html += "</html\n";
                return html;
        }
        boolean done = false;

        boolean blue = false;
        boolean yellow;
        boolean purple;
        ArrayList<RSTile> tiles = new ArrayList<RSTile>();

        private JCheckBox Spendpoints;
        private JList jList1;
        private JScrollPane jScrollPane2;
        private JButton jButton2;
        private JPanel contentPane;
        JFrame f;
        @Override
        public boolean onStart(Map<String, String> args) {
                f = new JFrame();
                contentPane = (JPanel)f.getContentPane();

                Spendpoints = new JCheckBox();
                jList1 = new JList();
                jScrollPane2 = new JScrollPane();
                jButton2 = new JButton();
                contentPane = (JPanel)f.getContentPane();

                //
                // Spendpoints
                //
                Spendpoints.setText("SpendPoints");
                //
                // jList1
                //
                jList1.setListData(new Object[] {"Strength", "Attack" , "Defence" , "Range" , "HitPoints" , "Prayer" , "Magic"});

                //
                // jScrollPane2
                //
                jScrollPane2.setViewportView(jList1);
                //
                // jButton2
                //
                jButton2.setText("Start");
                jButton2.setActionCommand("button");
                jButton2.addActionListener(new ActionListener() {
                        public void actionPerformed(ActionEvent e) {
                                if(Spendpoints.isSelected())
                                {
                                        if(jList1.getSelectedValue() != null)
                                        {
                                                spend = true;
                                                String s = (String) jList1.getSelectedValue();
                                                if(s.equals("Strength")) points = 1;
                                                else if(s.equals("Attack")) points = 2;
                                                else if(s.equals("Defence")) points = 3;
                                                else if(s.equals("Range")) points = 4;
                                                else if(s.equals("Prayer")) points = 5;
                                                else if(s.equals("Magic")) points = 6;
                                                else if(s.equals("HitPoints")) points = 7;
                                                log(s);

                                        }
                                }
                                f.dispose();
                        }

                });
                //
                // contentPane
                //
                contentPane.setLayout(null);
                addComponent(contentPane, Spendpoints, 5,5,96,20);
                addComponent(contentPane, jScrollPane2, 8,27,132,100);
                addComponent(contentPane, jButton2, 31,132,83,28);
                //
                // gui
                //
                f.setTitle("Thr33PC");
                f.setLocation(new Point(199, 104));
                f.setSize(new Dimension(164, 200));
                f.setVisible(true);
                while(f.isVisible()) wait(random(500,800));
                return true;

        }

        /** Add Component Without a Layout Manager (Absolute Positioning) */
        private void addComponent(Container container,Component c,int x,int y,int width,int height)
        {
                c.setBounds(x,y,width,height);
                container.add(c);
        }

        public int extract(final String s) { // Taken from SmartPC
                int j = s.length() - 1;
                while (j >= 0 && Character.isDigit(s.charAt(j))) {
                        j--;
                }
                return Integer.parseInt(s.substring(j + 1, s.length()));
        }

        public int getHP(RSPlayer p)
        {

                return -1;
        }
        int i = random(20,40);
        int[] portals = {};
        @Override
        public int loop() {
                if(getEnergy() > i && !isRunning())
                {
                        setRun(true);
                        i = random(20,40);
                        return random(100,700);
                }
                if (ONBOAT())
                {
                        final RSInterfaceChild POINTS = RSInterface.getChildInterface(407,
                                        16);
                        final String text = POINTS.getText();
                        CURRENTPOINTS = extract(text);
                        return random(400, 500);
                }
                if(spend && CURRENTPOINTS > 100 && !ONBOAT() && getNearestNPCByID(KNIGHTID) != null)
                {
                        SpendingPoints(points);
                        return random(200,300);
                }
                if (getNearestNPCByID(KNIGHTID) != null && !ONBOAT()) {
                        currPortal = random(0, 3);
                        inPest = false;
                        RSObject obj = findObject(BOAT);
                        if (obj != null)
                                if (atTile2(obj.getLocation(), "Cross"))
                                        wait(random(300, 400));
                        return random(1000, 1300);
                }
                if (getMyPlayer().getInteracting() == null)
                        lol = 0;
                if (!isPortalOpen(currPortal))
                        return walktoRandomOpenPortal();
                if (getMyPlayer().getInteracting() != null
                                || getMyPlayer().getAnimation() != -1) {
                        if (getMyPlayer().getInteracting() != null)
                        {
                                /*if (!getMyPlayer().isMoving()) {
                                        if (distanceTo(getMyPlayer().getInteracting().getLocation()) > 2) {
                                                RSNPC npc = getNearestNPCByNameinPest(mobs);
                                                if (npc != null) {
                                                        if (tileOnScreen(npc.getLocation()))
                                                                if (!isPortalOpen(currPortal))
                                                                        return walktoRandomOpenPortal();
                                                                else if (walking)
                                                                        return walktoRandomOpenPortal();
                                                                else
                                                                        ATTACKNPC(npc, "Attack");
                                                }
                                        }
                                }*/
                                RSNPC npc = getNearestNPCByName("Brawler");
                                if(npc != null)
                                        if(distanceTo(npc) < 3)
                                        {
                                                log("Attacking NPC");
                                                ATTACKNPC(npc,"Attack");
                                                wait(random(1500,1600));
                                                while(getMyPlayer().getInteracting() != null) wait(random(100,400));
                                        }
                        }
                        if (lol == 0)
                                lol = System.currentTimeMillis();
                        if (lol - System.currentTimeMillis() > 3000) {
                                RSNPC npc = getNearestNPCByNameinPest(mobs);
                                if (npc != null) {
                                        if (tileOnScreen(npc.getLocation()))
                                                if (!isPortalOpen(currPortal))
                                                        return walktoRandomOpenPortal();
                                                else if (walking)
                                                        return walktoRandomOpenPortal();
                                                else
                                                        ATTACKNPC(npc, "Attack");
                                        else return walktoRandomOpenPortal();

                                }
                                return random(400, 1400);
                        }
                        anti = new Thread(new antiban(random(0, 60)));
                        anti.start();
                        return random(100, 700);
                }
                if (getNearestNPCByID(VOIDID) != null) {
                        inPest = true;
                        if (distanceBetween(getMyPlayer().getLocation(), getNearestNPCByID(
                                        VOIDID).getLocation()) < 7) {
                                voidloc = getNearestNPCByID(VOIDID).getLocation();
                                return walktoRandomOpenPortal();
                        }
                }
                if (distanceBetween(getMyPlayer().getLocation(), curPortal) > 8) {
                        this
                                        .walkPathMM(
                                                        generatePath(curPortal), 6);
                }

                if (inPest) {
                        RSNPC npc = getNearestNPCByNameinPest(mobs);
                        if (npc != null) {
                                if (tileOnScreen(npc.getLocation()))
                                        if (walking)
                                                return walktoRandomOpenPortal();
                                        else
                                                ATTACKNPC(npc, "Attack");
                        }
                        return random(400, 1400);
                }
                if (!isPortalOpen(currPortal))
                        return walktoRandomOpenPortal();
                return random(100, 500);
        }

        public int openPortal()
        {
                if (findObject(GATE_CLOSED) != null) {
                        atObject(findObject(GATE_CLOSED), "Open");
                } else {
                        wait(random(1, 2));
                }
                return random(300,400);
        }

        class antiban implements Runnable {

                int i;

                public antiban(int i) {
                        this.i = i;
                }

                public void run() {
                        switch (i) {
                        case 0:
                                setCameraRotation(random(0, 360));
                                break;
                        case 1:
                                moveMouse(random(4, 500), random(4, 500));
                                break;
                        case 2:
                                moveMouse(random(4, 500), random(4, 500));
                                break;
                        case 3:
                                moveMouse(random(4, 500), random(4, 500));
                                break;
                        case 4:
                                setCameraRotation(random(0, 360));
                                break;
                        default:
                                break;
                        }
                }

        }

        public int walktoRandomOpenPortal() {
                walking = true;
                ArrayList<Integer> portal = new ArrayList<Integer>();
                if (!isPortalOpen(currPortal)) {
                        //log("setting current portal");
                        for (int i = 0; i < 4; i++)
                                if (isPortalOpen(i))
                                        portal.add(i);
                        if (portal.size() == 0) {
                                //log("ok");
                                return random(400, 800);
                        }
                        currPortal = portal.get(random(0, portal.size()));
                }
                RSTile[] path = getPath(currPortal);
                if (path != null && path.length > 0) {
                        curPortal = path[path.length - 1];
                        this.Path = path;
                        walkPathMM(path, 4);
                        wait(random(600, 1000));
                }
                if (distanceTo(curPortal) < 7)
                        walking = false;
                return random(400, 500);
        }

        RSTile[] Path;
        RSTile current;
        int CURRENTPOINTS;
        void SpendingPoints(int Location) {
                final int x = random(210, 304);
                final int y = random(288, 308);
                if (RSInterface.getInterface(267).isValid()) {
                        if (Location == 1) {
                                clickMouse(423, 70, true);
                                wait(random(1000, 2000));
                                clickMouse(x, y, true);
                                CURRENTPOINTS = 0;
                        } else if (Location == 2) {
                                clickMouse(204, 71, true);
                                wait(random(1000, 2000));
                                clickMouse(x, y, true);
                                CURRENTPOINTS = 0;
                        } else if (Location == 3) {
                                clickMouse(206, 108, true);
                                wait(random(1000, 2000));
                                clickMouse(x, y, true);
                                CURRENTPOINTS = 0;
                        } else if (Location == 4) {
                                clickMouse(423, 110, true);
                                wait(random(1000, 2000));
                                clickMouse(x, y, true);
                                CURRENTPOINTS = 0;
                        } else if (Location == 5) {
                                clickMouse(201, 186, true);
                                wait(random(1000, 2000));
                                clickMouse(x, y, true);
                                CURRENTPOINTS = 0;
                        } else if (Location == 6) {
                                clickMouse(206, 146, true);
                                wait(random(1000, 2000));
                                clickMouse(x, y, true);
                                CURRENTPOINTS = 0;
                        } else if (Location == 7) {
                                clickMouse(435, 147, true);
                                wait(random(1000, 2000));
                                clickMouse(x, y, true);
                                CURRENTPOINTS = 0;
                        }
                } else {
                        atNPC(getNearestNPCByID(3788), "change");
                        wait(random(1000, 2000));
                }
        }
        public String CurrentPortal(int i)
        {
                        try {
                                switch (i) {
                                case 0: // blue
                                        return "blue";
                                case 1: // yellow
                                        return "yellow";
                                case 2: // red
                                        return "red";
                                case 3: // purple
                                        return "Purple";
                                }
                        } catch (Exception e) {
                                return "";

                        }
                        return "";
        }

        public RSTile getGateLoc(int i)
        {
                if(i == 0) { // blue
                        return new RSTile(this.voidloc.getX() + 15 , voidloc.getY() - 15); // 15 - 15
                } else if(i == 1 || i == 2){
                        int t = random(0,5);
                        if(t > 2) {
                                return new RSTile(this.voidloc.getX() +  1, voidloc.getY() - 22); // 1 - 22
                        } else {
                                if(i == 1) {
                                        return new RSTile(this.voidloc.getX() - 15, voidloc.getY() - 15); //-12 - 15
                                } else {
                                        return new RSTile(this.voidloc.getX() + 15, voidloc.getY() - 15);
                                }
                        }
                } else {
                        return new RSTile(this.voidloc.getX() - 12, voidloc.getY() - 15);
                }
        }
        public boolean walkPathMM(RSTile[] path, int maxDist) {
                int i = 0;
                do
                        try {
                                if(!Calculations.canReach(path[path.length - 1], true)) {
                                        if(findObject(path[path.length - 1],this.GATE_CLOSED) != null)
                                        {
                                                  RSTile tile = getGateLoc(currPortal);
                                                  path = generatePath(tile);
                                        }
                                }
                                RSTile next = nextTile1(path, maxDist);
                                if (next != null && (!next.equals(current)) && !next.equals(getMyPlayer().getLocation())) {
                                        walkTileMM(next);
                                        current = next;
                                } else if (next != null && next.equals(current)) {
                                }
                                wait(random(1000, 1400));
                                while (getMyPlayer().isMoving()) {
                                        if (distanceTo(getDestination()) < 6)
                                                break;
                                        wait(random(500, 600));
                                }
                                if(getDestination() != null && !getMyPlayer().isMoving())
                                {
                                        i++;
                                        wait(random(500,700));
                                }

                                if(i > 4)
                                {
                                        log("walking");
                                        walkTileMM(getMyPlayer().getLocation().randomizeTile(6, 6));
                                        i = 0;
                                }
                                RSObject obj;
                                if((obj = findObject(GATE_CLOSED)) != null)
                                {
                                        if(Calculations.tileToScreen(obj.getLocation()) != null)
                                                atObject(obj, "Open");
                                        else
                                                walkTileMM(obj.getLocation());
                                }
                                RSNPC npc = getNearestNPCByName("Brawler");
                                if(npc != null)
                                        if(distanceTo(npc) < 3)
                                        {
                                                log("Attacking NPC");
                                                ATTACKNPC(npc,"Attack");
                                                wait(random(1500,1600));
                                                while(getMyPlayer().getInteracting() != null) wait(random(100,400));
                                        }

                                return true;
                        } catch (Exception e) {
                                return false;
                        }
                while (distanceTo(path[path.length - 1]) > 4);
        }

        public void openDoor(RSTile[] path)
        {
                RSObject obj;
                if((obj = findObject(8,GATE_CLOSED)) != null && distanceBetween(obj.getLocation(), path[path.length - 1]) > distanceTo(path[path.length]))
                {
                        if(Calculations.tileToScreen(obj.getLocation()) != null)
                                atObject(obj, "Open");
                        else
                                walkTileMM(obj.getLocation());

                        openDoor(path);
                }
        }
        public RSTile nextTile1(RSTile[] path, int maxDist) {
                RSTile cur = getMyPlayer().getLocation();
                RSTile t = path[0];
                for (int i = path.length - 1; i >= 0; i--) {
                        if (distanceBetween(t, path[0]) < distanceBetween(path[i], path[0])
                                        && this.tileOnMap(path[i]))
                                if (distanceTo(path[0]) < distanceBetween(path[i], path[0]) && this.distanceTo(path[i]) > 6)
                                        t = path[i];
                }
                return t;
        }

        public RSTile[] getPath(int portal) {
                if (voidloc != null)
                        switch (portal) {
                        case 0:
                                return randomizePath(generatePath(
                                                (voidloc.getX() + 26 + random(-1, -5)),
                                                (voidloc.getY() - 18 - random(+1, +4))), 2, 2);
                        case 1:
                                return randomizePath(generatePath(
                                                (voidloc.getX() + 15 + random(-1, -5)),
                                                (voidloc.getY() - 36 - random(-1, -4))), 2, 2);
                        case 2:
                                return randomizePath(generatePath((voidloc.getX() - 9 + random(
                                                +1, +5)), (voidloc.getY() - 37 - random(-1, -4))), 2, 2);
                        case 3:
                                return randomizePath(generatePath(
                                                (voidloc.getX() - 26 + random(+1, +5)),
                                                (voidloc.getY() - 15 - random(+1, +4))), 2, 2);
                        }
                return null;
        }

        /**
        * @param portal
        * @return
        */
        public boolean isPortalOpen(int portal) {
                try {
                        switch (portal) {
                        case 0: // blue
                                if (Integer.parseInt(getInterface(408, 14).getText()) < 10)
                                        return false;
                                else {
                                        break;
                                }
                        case 1: // yellow
                                if (Integer.parseInt(getInterface(408, 15).getText()) < 10)
                                        return false;
                                else {
                                        break;
                                }
                        case 2: // red
                                if (Integer.parseInt(getInterface(408, 16).getText()) < 10)
                                        return false;
                                else {
                                        break;
                                }
                        case 3: // purple
                                if (Integer.parseInt(getInterface(408, 13).getText()) < 10)
                                        return false;
                                else {
                                        break;
                                }
                        }
                } catch (Exception e) {
                        return false;
                }
                return true;
        }

        public void serverMessageRecieved(ServerMessageEvent e) {

        }

        public void onRepaint(Graphics g)
    {
        if(isLoggedIn())
        {
                       
                        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;

                        long minutes2 = minutes + (hours * 60);
           
                        g.setColor(Color.WHITE);
           
                        g.drawString("Thr33's PC Script", 9, 120);
           
                        g.drawString("Time running: " + hours + ":" + minutes + ":" + seconds + ".", 9, 140);
           
                        g.drawString("Total Points: " + CURRENTPOINTS, 9, 160);

                        if(skills.getRealSkillLevel(skills.getStatIndex("strength")) < 99)
            {
                        g.drawString("Percent until " + (skills.getRealSkillLevel(Skills.getStatIndex("strength")) + 1) + " Strength:", 9, 180);
                               
                        g.setColor(Color.red);
                               
                        g.fill3DRect(9, 190, 100 - skills.getPercentToNextLevel(Skills.getStatIndex("strength")), 9, true);
                               
                        g.setColor(Color.WHITE);
                               
                        g.drawString(100 - skills.getPercentToNextLevel(Skills.getStatIndex("strength")) + " %", 9, 198);
                       
                        }
             
                        if(skills.getRealSkillLevel(skills.getStatIndex("hitpoints")) < 99)
            {
                        g.drawString("Percent until " + (skills.getRealSkillLevel(Skills.getStatIndex("hitpoints")) + 1) + " HP:", 9, 220);
                               
                        g.setColor(Color.red);
                               
                        g.fill3DRect(9, 230, 100 - skills.getPercentToNextLevel(Skills.getStatIndex("hitpoints")), 9, true);
                               
                        g.setColor(Color.WHITE);
                               
                        g.drawString(100 - skills.getPercentToNextLevel(Skills.getStatIndex("hitpoints")) + " %", 9, 238);
                       
                        }
                }
   
        }

       
        public RSNPC getNearestNPCByNameinPest(String... names) {
                if (curPortal == null)
                        return null;
                int Dist = 20;
                RSNPC closest = null;
                int[] validNPCs = Bot.getClient().getNPCIndexArray();
                NPC[] npcs = Bot.getClient().getNPCArray();

                for (int element : validNPCs) {
                        if (npcs[element] == null) {
                                continue;
                        }
                        RSNPC Monster = new RSNPC(npcs[element]);
                        try {
                                for (String name : names) {
                                        if (!name.equals(Monster.getName())
                                                        || distanceBetween(curPortal, Monster.getLocation()) > 10) {
                                                continue;
                                        }
                                        int distance = distanceTo(Monster);
                                        if (distance < Dist) {
                                                Dist = distance;
                                                closest = Monster;
                                        }
                                }
                        } catch (Exception e) {
                                e.printStackTrace();
                        }
                }
                return closest;
        }

        public boolean atTile2(RSTile tile, String action) {
                if (!tileOnScreen(tile))
                        if (!tileOnMap(tile)) {
                                log("tile not on map");
                                return false;
                        } else
                                this.walkTileMM(tile);
                wait(random(100, 200));
                long start = System.currentTimeMillis();
                while (!tileOnScreen(tile)) {
                        wait(random(100, 200));
                        if (System.currentTimeMillis() - start > 3000) {
                                log("took to long");
                                return false;
                        }
                }
                moveMouse(Calculations
                                .tileToScreen(tile.getX(), tile.getY(), .5, .5, 0), 5, 5);
                wait(random(50, 100));

                while (Bot.getClient().getMousePressX() != this.getMouseLocation().x
                                && Bot.getClient().getMousePressY() != this.getMouseLocation().y) {
                        this.clickMouse(true);
                        wait(random(500, 700));
                }
                return true;


        }


        public boolean ONBOAT() {
                final RSTile myLocation = getMyPlayer().getLocation();
                final int myX = myLocation.getX();
                final int myY = myLocation.getY();
                int INTERGER1 = 2663;
                int INTERGER2 = 2660;
                int INTERGER3 = 2638;
                int INTERGER4 = 2643;
                if (myX <= INTERGER1 && myX >= INTERGER2 && myY >= INTERGER3
                                && myY <= INTERGER4) {
                        return true;
                }

                return false;
        }

        private boolean ATTACKNPC(final RSNPC npc, final String action) {
                final RSTile tile = npc.getLocation();
                final RSTile randomTile = tile.randomizeTile(1, 1);
                try {
                        final int hoverRand = random(8, 13);
                        for (int i = 0; i < hoverRand; i++) {
                                final Point screenLoc = npc.getScreenLocation();
                                if (!pointOnScreen(screenLoc)
                                                && getMyPlayer().getInteracting() == null) {
                                        walkTileMM(randomTile);
                                        return true;
                                }

                                moveMouse(screenLoc, 15, 15);

                                final List<String> menuItems = getMenuItems();
                                if (menuItems.isEmpty() || menuItems.size() <= 1) {
                                        continue;
                                }
                                if (menuItems.get(0).toLowerCase().contains(
                                                npc.getName().toLowerCase())
                                                && getMyPlayer().getInteracting() == null) {
                                        clickMouse(true);
                                        return true;
                                } else {
                                        for (int a = 1; a < menuItems.size(); a++) {
                                                if (menuItems.get(a).toLowerCase().contains(
                                                                npc.getName().toLowerCase())
                                                                && getMyPlayer().getInteracting() == null) {
                                                        clickMouse(false);
                                                        return atMenu(action);
                                                }
                                        }
                                }
                        }

                } catch (final Exception e) {
                        return false;
                }
                return false;
        }

       
        public RSTile[] generatePath(RSTile t) {
                RSTile path[] = generatePath(t.getX(),t.getY());
                RSTile last = path[0];
                ArrayList<RSTile> lol = new ArrayList<RSTile>();
                for(int i = 1; i < path.length;i++) {
                        RSTile[] p = this.generatePath(last.getX(), last.getY(), path[i].getX(), path[i].getY());
                        for(RSTile pp : p) {
                                lol.add(pp);
                        }
                        last = path[i];
                }
                return path;
        }
        public RSTile[] generatePath(int destinationX, int destinationY) {
                return generatePath(getMyPlayer().getLocation().getX(), getMyPlayer()
                                .getLocation().getY(), destinationX, destinationY);
        }

        public RSObject findObject(RSTile t,int... ids) {
                // Changed to find the nearest, reachable!
                // fixed, lol, getObjectAt want a real xy not this one
                RSObject cur = null;
                int dist = -1;
                for (int x = 0; x < 104; x++) {
                        for (int y = 0; y < 104; y++) {
                                RSObject o = getObjectAt(x + Bot.getClient().getBaseX(), y
                                                + Bot.getClient().getBaseY());
                                if (o != null) {
                                        boolean isObject = false;
                                        for (int id : ids) {
                                                if (o.getID() == id) {
                                                        isObject = true;
                                                        break;
                                                }
                                        }
                                        if (isObject) {

                                                int distTmp = Calculations.getRealDistanceTo(o.getLocation().getX(), o.getLocation().getY(), t.getX(), t.getY(), true);
                                                if (distTmp != -1) {
                                                        if (cur == null) {
                                                                dist = distTmp;
                                                                cur = o;
                                                        } else if (distTmp < dist) {
                                                                cur = o;
                                                                dist = distTmp;
                                                        }
                                                }
                                        }
                                }
                        }
                }
                return cur;
        }

        private RSTile[] generatePath(int startX, int startY, int destinationX,
                        int destinationY) { // most credits to aftermath
                double dx, dy;
                ArrayList<RSTile> list = new ArrayList<RSTile>();

                list.add(new RSTile(startX, startY));
                while (Math.hypot(destinationY - startY, destinationX - startX) > 8) {
                        dx = destinationX - startX;
                        dy = destinationY - startY;
                        int gamble = random(14, 17);
                        while (Math.hypot(dx, dy) > gamble) {
                                dx *= .95;
                                dy *= .95;
                        }
                        startX += (int) dx;
                        startY += (int) dy;
                        list.add(new RSTile(startX, startY));
                }
                list.add(new RSTile(destinationX, destinationY));
                return list.toArray(new RSTile[list.size()]);
        }

}

Enjoy!


All times are GMT -8. The time now is 10:31 AM.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.