ULTIMATE GUIDE

LoG iN

Join the forum, it's quick and easy

ULTIMATE GUIDE

LoG iN

ULTIMATE GUIDE

Would you like to react to this message? Create an account in a few clicks or log in to continue.

ULTIMATE GUIDE


    HCutter Cuts anything

    avatar
    Turk4life321
    Admin


    Posts : 41
    Join date : 2009-08-09
    Location : In Saims Room *cough*

    HCutter Cuts anything Empty HCutter Cuts anything

    Post  Turk4life321 Fri Jan 01, 2010 4:43 am

    import org.rsbot.bot.Bot;
    import org.rsbot.bot.input.Mouse;
    import org.rsbot.event.events.ServerMessageEvent;
    import org.rsbot.event.listeners.PaintListener;
    import org.rsbot.event.listeners.ServerMessageListener;
    import org.rsbot.script.*;
    import org.rsbot.script.wrappers.*;

    import java.awt.*;
    import java.util.ArrayList;
    import java.util.Map;
    import java.util.List;
    import org.rsbot.util.ScreenshotUtil;

    import java.awt.BorderLayout;
    import java.awt.event.ActionEvent;
    import java.awt.event.ActionListener;

    import javax.swing.JButton;
    import javax.swing.JCheckBox;
    import javax.swing.JComboBox;
    import javax.swing.JFrame;
    import javax.swing.JPanel;
    import javax.swing.JLabel;
    import javax.swing.JRadioButton;
    import javax.swing.JTabbedPane;
    import javax.swing.DefaultComboBoxModel;


    @ScriptManifest(authors = { "Henry11200" }, category = "Woodcutting", name = "HCutter", version = 0.1, description = "Start script and set settings in GUI")
    public class HCutter extends Script implements PaintListener{

    public int WillowLog = 1519;
    public int WillowTree[] = {5551,5552,5553};
    public int WillowTreeDown = 5554;

    private final ScriptManifest properties = getClass().getAnnotation(ScriptManifest.class);

    public int Tinderbox = 590;
    final int burningFire = 2732;
    public long startTime = System.currentTimeMillis();
    public int[] axes = {1351,1349,1353,1355,1361,1357,1359,6739,590};
    private RSTile Location = new RSTile(-1,-1);
    private RSTile BurnTile = new RSTile(-1,-1);
    private RSTile pos = new RSTile(-1,-1);
    final RSTile RimmPath[] = {new RSTile(2939, 3201), new RSTile(2943, 3198), new RSTile(2947, 3197), new RSTile(2951, 3196), new RSTile(2956, 3194), new RSTile(2960, 3193), new RSTile(2963, 3193), new RSTile(2969, 3196)};
    final RSTile CraftingPath[] = {new RSTile(2927, 3294), new RSTile(2922, 3293), new RSTile(2917, 3294), new RSTile(2918, 3297)};
    final RSTile PortSarimPath[] = {new RSTile(3004, 3190),new RSTile(3000, 3190), new RSTile(2994, 3190),new RSTile(2989, 3187)};
    final RSTile[] RimmFMPath = {new RSTile(2968, 3195), new RSTile(2969, 3199), new RSTile(2962, 3202)};
    private RSTile FmBackPath[];
    private RSTile ReversedPath[];
    boolean burn;
    public double x1 = 1.5;
    public double x2 = 1.5;
    final TheWalker theWalker = new TheWalker();
    public int speed = 10;
    boolean droping;
    public int startEXP;
    public int startLvl;
    public int FailSafe = 0;
    boolean CheckSell;
    boolean CheckBurn;
    boolean CheckDrop;
    String status = "Starting Up";
    String antib = "OFF";

    public static boolean guidone = false;
    public static boolean antiban;
    public static String Where = "";
    public static String BDS = "";

    @Override
    public boolean onStart(final Map<String, String> args) {
    startEXP = skills.getCurrentSkillExp(STAT_WOODCUTTING);
    startLvl = skills.getCurrentSkillLevel(STAT_WOODCUTTING);

    new GUI();
    while (!guidone) {
    status = "GUI settings";
    wait(1000);
    }
    if (Where.equals("Rimmington")) {
    Location = new RSTile(2969,3195);
    BurnTile = new RSTile(2959,3200);
    FmBackPath = RimmPath;
    if (BDS.equals("Burn")){
    CheckBurn = true;
    }
    if (BDS.equals("Drop")){
    CheckDrop = true;
    }
    if (BDS.equals("Sell")){
    CheckSell = true;
    }
    }
    if (Where.equals("Crafting Guild")) {
    Location = new RSTile(2917,3301);
    BurnTile = new RSTile(2927,3294);
    FmBackPath = CraftingPath;
    if (BDS.equals("Burn")){
    CheckBurn = true;
    }
    if (BDS.equals("Drop")){
    CheckDrop = true;
    }
    }
    if (Where.equals("Port Sarim")) {
    Location = new RSTile(2990,3187);
    BurnTile = new RSTile(3006,3191);
    FmBackPath = PortSarimPath;
    if (BDS.equals("Burn")){
    CheckBurn = true;
    }
    if (BDS.equals("Drop")){
    CheckDrop = true;
    }
    }
    setCameraAltitude(true);
    return true;
    }
    @Override
    public void onFinish() {
    }


    @SuppressWarnings("serial")
    class GUI extends JFrame implements ActionListener {
    private JLabel descLabel = new JLabel("This can powerchop, burn the logs and sell them.");
    private JLabel descLabel1 = new JLabel("Start at the places");
    private JButton startScript = new JButton("Start script");
    private JPanel mainPanel = new JPanel();
    private JTabbedPane tabs = new JTabbedPane();
    private JComboBox Where = new JComboBox(new String[] {"Rimmington", "Crafting Guild", "Port Sarim" });
    private DefaultComboBoxModel model = new DefaultComboBoxModel();
    private JComboBox whatToDo = new JComboBox(model);
    private JCheckBox antibanBox = new JCheckBox("Use antiban");
    private String[] How = new String[] {"Drop","Burn"};;

    public GUI() {
    super(properties.name() + " v" + properties.version() + " - By Henry11200");

    mainPanel.setLayout(new FlowLayout());

    startScript.setActionCommand("start");
    startScript.addActionListener(this);

    mainPanel.add(descLabel);
    mainPanel.add(descLabel1);
    mainPanel.add(startScript);

    Where.addActionListener(this);
    mainPanel.add(Where);

    model.removeAllElements();
    for (String s : How) {
    model.addElement(s);
    }
    mainPanel.add(whatToDo);

    mainPanel.add(antibanBox);
    tabs.addTab("Settings", mainPanel);

    add(tabs);
    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    setPreferredSize(new Dimension(300, 155));
    pack();
    setVisible(true);
    }

    public void actionPerformed(ActionEvent e) {
    if (e.getActionCommand().equals("start")) {
    HCutter.antiban = antibanBox.isSelected();
    HCutter.guidone = true;
    HCutter.BDS = whatToDo.getSelectedItem().toString();
    HCutter.Where = Where.getSelectedItem().toString();
    dispose();
    return;
    }
    if (Where.getSelectedItem().equals("Rimmington")) {
    How = new String[] { "Drop","Burn"};
    }
    if (Where.getSelectedItem().equals("Crafting Guild")) {
    How = new String[] { "Drop","Burn"};
    }
    if (Where.getSelectedItem().equals("Port Sarim")) {
    How = new String[] { "Drop","Burn"};
    }
    model.removeAllElements();
    for (String s : How) {
    model.addElement(s);
    }
    }
    }

    public void onRepaint(Graphics g) {
    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;
    Mouse m = Bot.getClient().getMouse();
    //Settings
    g.setColor( new Color(70, 234, 40, 150));
    g.fillRect(459, 322, 60, 16);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(459, 322, 60, 16);
    g.setColor( new Color(70, 234, 40, 200));
    g.drawRect(460, 323, 58, 14);
    g.setColor(new Color(255, 255, 255));
    g.drawString("Settings", 464,334);
    g.setColor( new Color(70, 234, 40, 100));
    g.fillRect(459, 322, 60, Cool;
    //About
    g.setColor( new Color(70, 234, 40, 150));
    g.fillRect(398, 322, 60, 16);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(398, 322, 60, 16);
    g.setColor( new Color(70, 234, 40, 200));
    g.drawRect(399, 323, 58, 14);
    g.setColor(new Color(255, 255, 255));
    g.drawString("About", 402,334);
    g.setColor( new Color(70, 234, 40, 100));
    g.fillRect(398, 322, 60, Cool;
    //Status
    g.setColor( new Color(70, 234, 40, 150));
    g.fillRect(337, 322, 60, 16);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(337, 322, 60, 16);
    g.setColor( new Color(70, 234, 40, 200));
    g.drawRect(338, 323, 58, 14);
    g.setColor(new Color(255, 255, 255));
    g.drawString("Status", 341,334);
    g.setColor( new Color(70, 234, 40, 100));
    g.fillRect(337, 322, 60, Cool;
    //Time Ran
    g.setColor( new Color(70, 234, 40, 150));
    g.fillRect(226, 322, 110, 16);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(226, 322, 110, 16);
    g.setColor( new Color(70, 234, 40, 200));
    g.drawRect(227, 323, 108, 14);
    g.setColor(new Color(255, 255, 255));
    g.drawString(
    hours
    +"h "
    +minutes
    +"min"
    +seconds
    +"sec", 234,334);
    g.setColor( new Color(70, 234, 40, 100));
    g.fillRect(226, 322, 110, Cool;
    if(m.x >= 337 && m.x < 397 && m.y >= 321 && m.y < 337) {
    g.setColor( new Color(70, 234, 40, 150));
    g.fillRect(337, 175, 182, 147);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(337, 175, 182, 147);
    g.setColor(new Color(255, 255, 255));
    g.drawString("Lvl's gained "+ (startLvl - skills.getCurrentSkillLevel(STAT_WOODCUTTING)), 397,197);
    g.setColor(new Color(255, 255, 255, 255));
    g.drawString("EXP gained "+ (skills.getCurrentSkillExp(STAT_WOODCUTTING) - startEXP), 360,230);
    g.setColor(new Color(255, 255, 255));
    g.drawString("Status: "+status, 360,263);
    }
    if(m.x >= 397 && m.x < 459 && m.y >= 321 && m.y < 337) {
    g.setColor( new Color(70, 234, 40, 150));
    g.fillRect(337, 175, 182, 147);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(337, 175, 182, 147);
    g.setColor(new Color(255, 255, 255));
    g.drawString("HCtter v"+ properties.version(), 397,197);
    g.setColor(new Color(255, 255, 255));
    g.drawString("Made by Henry11200 ", 375,263);
    }
    if(m.x >= 459 && m.x < 519 && m.y >= 321 && m.y < 337) {
    g.setColor( new Color(70, 234, 40, 150));
    g.fillRect(337, 175, 182, 147);
    g.setColor(new Color(0, 0, 0));
    g.drawRect(337, 175, 182, 147);
    g.setColor(new Color(255, 255, 255));
    g.drawString("Cutting at " +Where, 360,197);
    g.drawString(BDS +"ing mode", 360,230);
    if(antiban == true) {antib = "ON";}
    if(antiban == false) {antib = "OFF";}
    g.drawString("Antiban is " +antib, 360,263);
    }
    }

    public int loop() {
    if(getInventoryCountID(axes) == 0)
    {
    stopScript();
    }
    if(TreeDown() && atLocation() && !isInventoryFull() && !burn) {
    GetNewTree();
    status = "Cutting trees";
    }
    if(isInventoryFull())
    {
    if(CheckDrop){
    droping = true;
    status = "Droping";
    dropAllExcept_(axes);
    droping = false;
    }
    if(CheckBurn){
    burn = true;
    status = "Burning";
    if(Where.equals("Rimmington")){
    walkPath(RimmFMPath);
    wait(random(3000,4500));
    }
    if(Where.equals("Port Sarim")){
    walkPath(reversePath(FmBackPath));
    wait(random(2000,3500));
    }
    if(Where.equals("Crafting Guild")){
    walkPath(reversePath(FmBackPath));
    wait(random(2000,3500));
    }
    ProperPlace();
    wait(random(1000,2000));
    BurnIt();
    }
    pos = new RSTile(-1,-1);
    wait(random(600,800));
    }
    if(CheckBurn && burn && getInventoryCountID(WillowLog) > 0 && getMyPlayer().getAnimation() == -1)
    {
    BurnIt();
    wait(random(600,800));
    }
    if(CheckBurn && burn && getInventoryCountID(WillowLog) == 0)
    {
    burn = false;
    wait(random(300,500));
    while(!atLocation()){
    walkPath(FmBackPath);
    wait(random(3500,4500));
    pos = new RSTile(-1,-1);
    }
    }
    if(antiban && getMyPlayer().getAnimation() != -1 && !TreeDown() && !droping && !burn)
    {
    antiBan();
    }
    if(!TreeDown() && atLocation() && !isInventoryFull() && !burn && !droping && getMyPlayer().getAnimation() == -1 && !getMyPlayer().isMoving()) {
    if(FailSafe == 0) { FailSafe++; return 100; }
    if(FailSafe == 1) { FailSafe++; return 100; }
    if(FailSafe == 2) {
    GetNewTree();
    FailSafe = 0;
    }
    }
    if(FailSafe > 0) { FailSafe = 0; return 100; }
    return 100;
    }
    //
    //FIREMAKING
    //
    public void ProperPlace() {
    if (Where.equals("Port Sarim")) {
    atTile3(new RSTile(random(3005,3007),random(3190,3191)),"Walk here");
    }
    if (Where.equals("Crafting Guild")) {
    atTile3(new RSTile(random(2926,2927),random(3293,3294)),"Walk here");
    }
    if (Where.equals("Rimmington")) {
    atTile3(new RSTile(random(2962,2965),random(3200,3201)),"Walk here");
    }
    }
    public void step() {
    if (Where.equals("Port Sarim")) {
    RSTile thisTile = getMyPlayer().getLocation();
    walkPath(reversePath(FmBackPath));
    wait(random(3000,4000));
    if(Check()){
    if(thisTile.getY() == 3191){
    atTile3(new RSTile(random(3005,3007),3190),"Walk here");
    wait(random(500,900));
    }
    if(thisTile.getY() == 3190){
    atTile3(new RSTile(random(3005,3007),3190),"Walk here");
    wait(random(500,900));
    }
    }
    }
    if (Where.equals("Crafting Guild")) {
    RSTile thisTile = getMyPlayer().getLocation();
    walkPath(reversePath(FmBackPath));
    wait(random(5000,6000));
    if(Check()){
    if(thisTile.getY() == 3294){
    atTile3(new RSTile(random(2926,2927),3293),"Walk here");
    wait(random(500,900));
    }
    if(thisTile.getY() == 3293){
    atTile3(new RSTile(random(2926,2927),3294),"Walk here");
    wait(random(500,900));
    }
    }
    }
    if (Where.equals("Rimmington")) {
    if(Check()){
    if(getMyPlayer().getLocation().getY() == 3201 && getMyPlayer().getLocation().getX() == 2944){
    atTile3(new RSTile(random(2944,2945),3203),"Walk here");
    wait(random(500,900));
    }
    if(getMyPlayer().getLocation().getY() == 3200 && getMyPlayer().getLocation().getX() == 2940){
    atTile3(new RSTile(random(2944,2945),3203),"Walk here");
    wait(random(500,900));
    }
    }
    }
    }
    public boolean Check() {
    RSTile thisTile = getMyPlayer().getLocation();
    try {
    int tileObj = getObjectAt(thisTile.getX(), thisTile.getY()).getID();
    if (tileObj == burningFire)
    return true;
    } catch (final Exception e) { }
    return false;
    }
    public void BurnIt() {
    boolean burning = true;
    burn = true;
    try{
    if(Check()) {
    step();
    wait(random(1000,2000));
    }
    clickInventoryItem(Tinderbox);
    wait(random(300,400));
    clickInventoryItem(WillowLog);
    while(burning){
    if(getMyPlayer().getAnimation() == -1 && !getMyPlayer().isMoving()){
    burning = false;
    }
    if(getMyPlayer().getAnimation() != -1){
    wait(random(300,500));
    burning = true;
    }
    }
    }catch (final Exception e) { }
    }
    //
    //Woodcutting
    //
    public void GetNewTree() {
    RSObject Willow = getClosestTreeByID(WillowTree);
    if (Willow == null){
    return;
    }
    final RSTile WillowCo = Willow.getLocation();
    if(distanceTo(WillowCo) > random(7,9)) {
    if(distanceTo(WillowCo) < 20){
    wait(random(900,1100));
    GetNewTree();
    return;
    }
    walkTo(WillowCo);
    wait(random(600,900));
    }
    CutTree(Willow.getLocation());
    wait(random(500,900));
    pos = Willow.getLocation();
    wait(random(200,300));
    }
    public void CutTree(final RSTile tile) {
    final Point location = Calculations.tileToScreen(tile.getX(), tile.getY(), x1, x2, 0);
    moveMouse(location, 6, 6);
    wait(random(100, 200));
    clickMouse(true);
    }
    public boolean TreeDown() { //Credits to Henry11200
    if(pos.getX() == -1)
    {
    return true;
    }
    try {
    RSObject willowtree = getObjectAt(pos);
    final int will = willowtree.getID();
    if(will == WillowTreeDown) {
    return true;
    }
    else{
    return false;
    }
    }
    catch (final Exception e) { }
    return false;
    }
    public boolean atLocation() {
    if (Where.equals("Port Sarim")) {
    if(distanceTo(Location) <= random(10,14)){
    return true;
    }
    else{
    return false;
    }
    }
    if (Where.equals("Rimmington")) {
    if(distanceTo(Location) <= random(12,14)){
    return true;
    }
    else{
    return false;
    }
    }
    if (Where.equals("Crafting Guild")) {
    if(distanceTo(Location) <= random(10,14)){
    return true;
    }
    else{
    return false;
    }
    }
    else{
    return false;
    }
    }
    //
    //Other Functions
    //
    public int antiBan() {
    final int ranNo = random(0, 22);
    int angle;
    if (ranNo == 2 && random(0,10) == 5) {
    if (getCurrentTab() != Constants.TAB_STATS) {
    openTab(Constants.TAB_STATS);
    moveMouse(random(670, 690), random(400, 410));
    wait(random(500, 750));
    return random(100, 200);
    }
    } else if (ranNo == 3 && random(0,5) == 2) {
    openTab(Constants.TAB_INVENTORY);
    return random(200, 400);
    } else if (ranNo == 4 && random(0,1) == 1) {
    moveMouse(random(0, 700), random(0, 500));
    return random(200, 400);
    } else if (ranNo == 5 && random(0,1) == 1) {
    moveMouse(random(0, 450), random(0, 400));
    return random(200, 400);
    }
    else if (ranNo == 6 && random(0, 1) == 1) {
    angle = getCameraAngle() + random(-90, 90);
    if (angle < 0) {
    angle = 0;
    }
    if (angle > 359) {
    angle = 0;
    }

    setCameraRotation(angle);
    return random(200, 400);
    }
    return 1;
    }
    public int getInventoryCountID(final int... itemIDs) {
    int total = 0;

    for (final RSItem item : getInventoryItems()) {
    if (item == null) {
    continue;
    }

    for (final int ID : itemIDs) {
    if (item.getID() == ID) {
    total += item.getStackSize();
    }
    }
    }

    return total;
    }
    public RSObject getClosestTreeByID(final int... ids) {
    RSObject cur = null;
    double dist = -1;

    for (int x = 0; x < 104; x++) {
    outer: for (int y = 0; y < 104; y++) {
    final RSObject o = getObjectAt(x + Bot.getClient().getBaseX(),
    y + Bot.getClient().getBaseY());

    if (o != null) {
    boolean isObject = false;
    for (final int id : ids) {
    if (o.getID() == id) {
    isObject = true;
    break;
    }
    }
    if (isObject) {
    final RSObject tl = getObjectAt(x
    + Bot.getClient().getBaseX() - 1, y
    + Bot.getClient().getBaseY());
    final RSObject tb = getObjectAt(x
    + Bot.getClient().getBaseX(), y
    + Bot.getClient().getBaseY() - 1);
    final int id = o.getID();
    if (tl != null && tl.getID() == id || tb != null
    && tb.getID() == id) {
    continue outer;
    }
    final double distTmp = calculateDistance(getMyPlayer()
    .getLocation(), o.getLocation());

    if (cur == null || distTmp < dist) {
    dist = distTmp;
    cur = o;
    }
    }
    }
    }
    }
    return cur;
    }
    private boolean moveToInventoryItem(final int itemID) {
    if (getCurrentTab() != Constants.TAB_INVENTORY) {
    openTab(Constants.TAB_INVENTORY);
    }
    final int[] items = getInventoryArray();
    for (int i = 0; i < items.length; i++) {
    if (items[i] == itemID) {
    final Point loc = getInventoryItemPoint(i);
    moveMouse(loc.x + 12, loc.y + 12, 5, 5);
    return true;
    }
    }
    return false;
    }
    private boolean clickInventoryItem(final int itemID) {
    if (moveToInventoryItem(itemID)) {
    clickMouse(true, 5);
    return true;
    }
    return false;
    }
    public void dropAllExcept_(final int... items) {
    try {
    boolean canDrop = true;
    int i = 0;
    int j = 0;
    int[] inventoryArray = null;
    Point inventoryItemPoint = null;

    if (getCurrentTab() != Constants.TAB_INVENTORY) {
    openTab(Constants.TAB_INVENTORY);
    }

    for (i = 0; i < 4; i++) {

    for (j = 0; j < 7; j++) {
    inventoryArray = null;
    inventoryItemPoint = null;

    inventoryArray = getInventoryArray();

    canDrop = true;

    if (inventoryArray[i + j * 4] != 0) {

    if (items != null) {
    for (final int k : items) {
    if (inventoryArray[i + j * 4] == k) {
    canDrop = false;
    }
    }
    }
    if (canDrop) {
    inventoryItemPoint = getInventoryItemPoint(i + j * 4);
    inventoryItemPoint.x += random(10,22);
    inventoryItemPoint.y += random(10,22);
    if (inventoryItemPoint != null) {
    clickMouse(inventoryItemPoint, false);
    atMenu("Drop");
    }
    }
    }
    }
    }
    } catch (final Exception e) {
    log("Small problem encountered, meltdown averted =P (not sure what it's going to do now =S)");
    }
    return;
    }
    private boolean atTile3(final RSTile tile, final String action) {
    return atTile3(tile, action, 0, 0, 10);
    }

    private boolean atTile3(final RSTile tile, final String action,
    final int xOffset, final int yOffset) {
    return atTile3(tile, action, xOffset, yOffset, 10);
    }

    // atTile3 -Jacmob
    private boolean atTile3(final RSTile tile, final String action,
    final int xOffset, final int yOffset, final int variation) {
    try {
    final Point location = Calculations.tileToScreen(tile);
    if (location.x == -1 || location.y == -1) {
    return false;
    }
    moveMouse(location.x + xOffset, location.y + yOffset, variation,
    variation);
    wait(random(20, 40));
    getMenuItems();
    final ArrayList<String> mis = getMenuItems();
    if (mis.get(0).contains(action)) {
    clickMouse(true);
    } else {
    for (int i = 1; i < mis.size(); i++) {
    if (mis.get(i).contains(action)) {
    clickMouse(false);
    if (atMenu(action)) {
    return true;
    }
    }
    }
    return false;
    }
    return true;
    } catch (final Exception e) {
    return false;
    }
    }
    public boolean walkPath(RSTile[] path) {
    if(!getMyPlayer().isMoving() || distanceTo(getDestination()) <= 5)
    return theWalker.walkTo(path, true);
    return false;
    }
    public void getMouseSpeed(final int speed) {
    this.speed = speed;
    getMouseSpeed();
    }

    protected int getMouseSpeed() {
    return speed;
    }

    //Please give credit if you decide to use - Garrett
    public class TheWalker {

    Methods methods = new Methods();
    Thread walker = null;
    RSTile[] path = null;

    public void drawMap(final Graphics g) {
    if (walker != null && walker.isAlive()) {
    Point myTile = tileToMinimap(getMyPlayer().getLocation());
    Point center = new Point(myTile.x + 2, myTile.y + 2);
    g.drawOval(center.x - 70, center.y - 70, 140, 140);
    if (path == null) return;
    for (int i = 0; i < path.length; i++) {
    final RSTile tile = path[i];
    final Point p = tileToMinimap(tile);
    if (p.x != -1 && p.y != -1) {
    g.setColor(Color.BLACK);
    g.fillRect(p.x + 1, p.y + 1, 3, 3);
    if (i > 0) {
    final Point p1 = tileToMinimap(path[i - 1]);
    g.setColor(Color.ORANGE);
    if (p1.x != -1 && p1.y != -1)
    g.drawLine(p.x + 2, p.y + 2, p1.x + 2, p1.y + 2);
    }
    }
    }
    Point tile = tileToMinimap(nextTile(path));
    g.setColor(Color.RED);
    if (tile.x != -1 && tile.y != -1) {
    g.fillRect(tile.x + 1, tile.y + 1, 3, 3);
    }
    g.setColor(Color.BLACK);
    }
    }

    public boolean walkTo(final RSTile[] path, final boolean waitUntilDest) {
    Walker walkto = new Walker(path, 3, 10000);
    walker = new Thread(walkto);
    walker.start();
    waitToMove(random(800, 1200));
    if (waitUntilDest) {
    while (walker.isAlive()) {
    methods.wait(random(300, 600));
    }
    return walkto.done;
    } else return true;
    }

    public Point tileToMM(RSTile tile) {
    return new Point(tileToMinimap(tile).x + 2, tileToMinimap(tile).y + 2);
    }

    public boolean tileOnMM(RSTile tile) {
    return pointOnMM(tileToMM(tile));
    }

    public boolean pointOnMM(Point point) {
    Point myTile = tileToMM(getMyPlayer().getLocation());
    Point center = new Point(myTile.x, myTile.y);
    return (center.distance(point) < 70) ? true : false;
    }

    public RSTile getClosestTileOnMap(final RSTile tile) {
    if (isLoggedIn() && !tileOnMM(tile)) {
    try {
    final RSTile loc = getMyPlayer().getLocation();
    final RSTile walk = new RSTile((loc.getX() + tile.getX()) / 2, (loc.getY() + tile.getY()) / 2);
    return tileOnMM(walk) ? walk : getClosestTileOnMap(walk);
    } catch (final Exception e) { }
    }
    return tile;
    }

    public RSTile nextTile(RSTile[] path) {
    for (int i = path.length - 1; i >= 0; i--) {
    if (tileOnMM(path[i])) {
    return path[i];
    }
    }
    return getClosestTileOnMap(path[0]);
    }

    public class Walker implements Runnable {

    RSTile tile = null;
    boolean done = false;
    boolean stop = false;
    int movementTimer = 10000;
    int distanceTo = 3;

    Walker(final RSTile[] userpath) {
    this.tile = userpath[userpath.length - 1];
    path = userpath;
    }

    Walker(final RSTile[] userpath, final int distanceTo, final int movementTimer) {
    this.tile = userpath[userpath.length - 1];
    this.movementTimer = movementTimer;
    this.distanceTo = distanceTo;
    path = userpath;
    }

    public void run() {
    long timer = System.currentTimeMillis();
    RSTile lastTile = getMyPlayer().getLocation();
    int randomReturn = random(5, Cool;
    while (distanceTo(tile) > distanceTo && !stop) {
    if (!getMyPlayer().isMoving() || getDestination() == null || distanceTo(getDestination()) < randomReturn) {
    RSTile nextTile = nextTile(path);
    if (getDestination() != null && distanceBetween(getDestination(), nextTile) <= distanceTo) {
    continue;
    }
    getMouseSpeed(random(6, Cool);
    walkTileMM(nextTile);
    getMouseSpeed(random(8, 10));
    waitToMove(random(800, 1200));
    randomReturn = random(5, Cool;
    }
    final RSTile myLoc = getMyPlayer().getLocation();
    if (myLoc != lastTile) {
    if (distanceBetween(myLoc, lastTile) > 30) {
    log("Teleportation Detected. Stopping The Walking Loop.");
    stop = true;
    }
    timer = System.currentTimeMillis();
    lastTile = myLoc;
    }
    if (System.currentTimeMillis() - timer > movementTimer) {
    stop = true;
    }
    methods.wait(random(20, 40));
    }
    if (distanceTo(tile) <= distanceTo) {
    done = true;
    }
    }

    }

    }
    }

      Similar topics

      -

      Current date/time is Fri Apr 26, 2024 4:44 am