kolton / d2bot-with-kolbot

d2bot game manager by D3STROY3R with kolbot libs by kolton for d2bs
345 stars 332 forks source link

Can sorc use telekinesis to grab wps etc? #1348

Open oband2 opened 5 years ago

oband2 commented 5 years ago

My sorc only wants to run to the wps, can i fix this so she will use telekinesis?

5noop commented 5 years ago

This is not implemented.

oband2 commented 5 years ago

This is not implemented.

thanks

Kosoleld commented 5 years ago

This works for me... :) but I changed ... :) everything

` useWaypoint: function (targetArea, check) { / Pather.useWaypoint(targetArea, check); targetArea - id of the area to enter check - force the waypoint menu /

    {//Early exit checks
        switch (targetArea) {
        case undefined:
            throw new Error("useWaypoint: Invalid targetArea parameter: " + targetArea);
        case null:
        case "random":
            check = true;

            break;
        default:
            if (typeof targetArea !== "number") {
                throw new Error("useWaypoint: Invalid targetArea parameter");
            }

            if (this.wpAreas.indexOf(targetArea) < 0) {
                return false;
            }

            break;
        }
    }
    var i, tick, wp, coord, retry;  
    var useTK = me.classid === 1 && me.getSkill(43, 1);

    for (i = 0; i < 12; i += 1) {
        if (me.area === targetArea || me.dead) {
            break;
        }

        if (me.inTown) {
            Town.move("waypoint");
        }

        wp = getUnit(2, "waypoint");

        if (wp && wp.area === me.area) {
            if (!me.inTown && getDistance(me, wp) > 12) {
                if(useTK) {
                    Attack.getIntoPosition({x: wp.x, y: wp.y}, 12, 0x4);
                    delay(200);
                    Skill.cast(43, 0, wp);
                    delay(200);
                    wp.interact(targetArea);
                    return (me.area === targetArea)
                }else{
                    this.moveToUnit(wp);
                    delay(50);
                    wp.interact(targetArea);
                }
                Misc.click(0, 0, wp);
                tick = getTickCount();

                while (getTickCount() - tick < Math.max(Math.round((i + 1) * 1000 / (i / 5 + 1)), me.ping * 2)) {
                    if (me.area === targetArea) {
                        delay(100);
                        if (Pather.waitForBO()) {
                            //print("ÿc1Pather: ÿc0Waited for a BO.");
                        }
                        return true;
                    }

                    delay(10);
                }

                me.cancel(); // In case lag causes the wp menu to stay open
            }

            if (check || Config.WaypointMenu) {
                if (getDistance(me, wp) > 12) {
                    if(useTK) {
                        Attack.getIntoPosition({x: wp.x, y: wp.y}, 12, 0x4);
                        delay(200);
                        Skill.cast(43, 0, wp);
                        delay(200);
                        wp.interact(targetArea);
                        return (me.area === targetArea)
                    }else{
                        this.moveToUnit(wp);
                        delay(50);
                        wp.interact(targetArea);
                    }
                }
                Misc.click(0, 0, wp);
                tick = getTickCount();
                while (getTickCount() - tick < Math.max(Math.round((i + 1) * 1000 / (i / 5 + 1)), me.ping * 2)) {
                    if (getUIFlag(0x14)) { // Waypoint screen is open
                        delay(500);

                        switch (targetArea) {
                        case "random":
                            while (true) {
                                targetArea = this.wpAreas[rand(0, this.wpAreas.length - 1)];

                                // get a valid wp, avoid towns
                                if ([1, 40, 75, 103, 109].indexOf(targetArea) === -1 && getWaypoint(this.wpAreas.indexOf(targetArea))) {
                                    break;
                                }

                                delay(5);
                            }

                            break;
                        case null:
                            me.cancel();

                            return true;
                        }

                        if (!getWaypoint(this.wpAreas.indexOf(targetArea))) {
                            me.cancel();
                            print("ÿc2Pather: Trying to get the waypoint ÿc0" + this.getAreaName(targetArea));
                            if (!me.inTown){
                                this.makePortal();
                            }

                            if(targetArea == 101) {
                                Pather.journeyTo(83);
                                Pather.moveToExit(100,true);
                                Pather.moveToExit(101,true);
                            }

                            if (this.getWP(targetArea)) {
                                //print("ÿc2Pather: Took waypoint ÿc0" + this.getAreaName(targetArea));
                                return true;
                            }else{
                                print("Pather.useWaypoint: Failed to go to waypoint");
                                return true;
                            }
                        }

                        break;
                    }

                    delay(10);
                }

                if (!getUIFlag(0x14)) {
                    print("waypoint retry " + (i + 1));
                    retry = Math.min(i + 1, 5)
                    coord = CollMap.getRandCoordinate(me.x, -5 * retry, 5 * retry, me.y, -5 * retry, 5 * retry);
                    this.moveTo(coord.x, coord.y);
                    delay(200 + me.ping);

                    Packet.flash(me.gid);

                    continue;
                }
            }

            if (!check || getUIFlag(0x14)) {
                delay(200);
                wp.interact(targetArea);

                tick = getTickCount();

                while (getTickCount() - tick < Math.max(Math.round((i + 1) * 1000 / (i / 5 + 1)), me.ping * 2)) {
                    if (me.area === targetArea) {
                        delay(100);
                        if (Pather.waitForBO()) {
                            //print("ÿc1Pather: ÿc0Waited for a BO.");
                        }
                        return true;
                    }

                    delay(10);
                }

                me.cancel(); // In case lag causes the wp menu to stay open
            }

            Packet.flash(me.gid);

            if (i > 1) { // Activate check if we fail direct interact twice
                check = true;
            }
        } else {
            Packet.flash(me.gid);
        }

        delay(200 + me.ping);
    }

    return false;

},

`

oband2 commented 5 years ago

This works for me... :) but I changed ... :) everything

` useWaypoint: function (targetArea, check) { / Pather.useWaypoint(targetArea, check); targetArea - id of the area to enter check - force the waypoint menu /

  {//Early exit checks
      switch (targetArea) {
      case undefined:
          throw new Error("useWaypoint: Invalid targetArea parameter: " + targetArea);
      case null:
      case "random":
          check = true;

          break;
      default:
          if (typeof targetArea !== "number") {
              throw new Error("useWaypoint: Invalid targetArea parameter");
          }

          if (this.wpAreas.indexOf(targetArea) < 0) {
              return false;
          }

          break;
      }
  }
  var i, tick, wp, coord, retry;  
  var useTK = me.classid === 1 && me.getSkill(43, 1);

  for (i = 0; i < 12; i += 1) {
      if (me.area === targetArea || me.dead) {
          break;
      }

      if (me.inTown) {
          Town.move("waypoint");
      }

      wp = getUnit(2, "waypoint");

      if (wp && wp.area === me.area) {
          if (!me.inTown && getDistance(me, wp) > 12) {
              if(useTK) {
                  Attack.getIntoPosition({x: wp.x, y: wp.y}, 12, 0x4);
                  delay(200);
                  Skill.cast(43, 0, wp);
                  delay(200);
                  wp.interact(targetArea);
                  return (me.area === targetArea)
              }else{
                  this.moveToUnit(wp);
                  delay(50);
                  wp.interact(targetArea);
              }
              Misc.click(0, 0, wp);
              tick = getTickCount();

              while (getTickCount() - tick < Math.max(Math.round((i + 1) * 1000 / (i / 5 + 1)), me.ping * 2)) {
                  if (me.area === targetArea) {
                      delay(100);
                      if (Pather.waitForBO()) {
                          //print("ÿc1Pather: ÿc0Waited for a BO.");
                      }
                      return true;
                  }

                  delay(10);
              }

              me.cancel(); // In case lag causes the wp menu to stay open
          }

          if (check || Config.WaypointMenu) {
              if (getDistance(me, wp) > 12) {
                  if(useTK) {
                      Attack.getIntoPosition({x: wp.x, y: wp.y}, 12, 0x4);
                      delay(200);
                      Skill.cast(43, 0, wp);
                      delay(200);
                      wp.interact(targetArea);
                      return (me.area === targetArea)
                  }else{
                      this.moveToUnit(wp);
                      delay(50);
                      wp.interact(targetArea);
                  }
              }
              Misc.click(0, 0, wp);
              tick = getTickCount();
              while (getTickCount() - tick < Math.max(Math.round((i + 1) * 1000 / (i / 5 + 1)), me.ping * 2)) {
                  if (getUIFlag(0x14)) { // Waypoint screen is open
                      delay(500);

                      switch (targetArea) {
                      case "random":
                          while (true) {
                              targetArea = this.wpAreas[rand(0, this.wpAreas.length - 1)];

                              // get a valid wp, avoid towns
                              if ([1, 40, 75, 103, 109].indexOf(targetArea) === -1 && getWaypoint(this.wpAreas.indexOf(targetArea))) {
                                  break;
                              }

                              delay(5);
                          }

                          break;
                      case null:
                          me.cancel();

                          return true;
                      }

                      if (!getWaypoint(this.wpAreas.indexOf(targetArea))) {
                          me.cancel();
                          print("ÿc2Pather: Trying to get the waypoint ÿc0" + this.getAreaName(targetArea));
                          if (!me.inTown){
                              this.makePortal();
                          }

                          if(targetArea == 101) {
                              Pather.journeyTo(83);
                              Pather.moveToExit(100,true);
                              Pather.moveToExit(101,true);
                          }

                          if (this.getWP(targetArea)) {
                              //print("ÿc2Pather: Took waypoint ÿc0" + this.getAreaName(targetArea));
                              return true;
                          }else{
                              print("Pather.useWaypoint: Failed to go to waypoint");
                              return true;
                          }
                      }

                      break;
                  }

                  delay(10);
              }

              if (!getUIFlag(0x14)) {
                  print("waypoint retry " + (i + 1));
                  retry = Math.min(i + 1, 5)
                  coord = CollMap.getRandCoordinate(me.x, -5 * retry, 5 * retry, me.y, -5 * retry, 5 * retry);
                  this.moveTo(coord.x, coord.y);
                  delay(200 + me.ping);

                  Packet.flash(me.gid);

                  continue;
              }
          }

          if (!check || getUIFlag(0x14)) {
              delay(200);
              wp.interact(targetArea);

              tick = getTickCount();

              while (getTickCount() - tick < Math.max(Math.round((i + 1) * 1000 / (i / 5 + 1)), me.ping * 2)) {
                  if (me.area === targetArea) {
                      delay(100);
                      if (Pather.waitForBO()) {
                          //print("ÿc1Pather: ÿc0Waited for a BO.");
                      }
                      return true;
                  }

                  delay(10);
              }

              me.cancel(); // In case lag causes the wp menu to stay open
          }

          Packet.flash(me.gid);

          if (i > 1) { // Activate check if we fail direct interact twice
              check = true;
          }
      } else {
          Packet.flash(me.gid);
      }

      delay(200 + me.ping);
  }

  return false;

},

`

is it possible u can put it into a pastebin? and tell me what file i should edit it into :)

Kosoleld commented 5 years ago

What is pastebin? Open Pather.js in libs/common and CTRL + F for "useWaypoint: function" paste over that function, feel free to rename the original to useWaypoint2 or something instead of deleting it so that it starts using the new code but you still have the original incase it doesn't work somewhere actually just reading i can see you will need to remove some functions I'm using which aren't native like Pather.waitForBO(); i will post a newer file

oband2 commented 5 years ago

pastebin is just a site for copy scripts into so it looks good, cos this side sometimes bug with quoting the codes instead, so was just to make sure i got everything i needed copied, lmk when u posted new file

Kosoleld commented 5 years ago

Here you go buddy.

https://pastebin.com/embed_js/nr7kmfzX

mcvk56 commented 5 years ago

this should be implemented again imo 🤔

Kosoleld commented 5 years ago

@5noop implement it ;)

Kosoleld commented 5 years ago

Can't figure out why but it's not working properly and often causes character to get connection interrupted. Don't use this code guys.

5noop commented 5 years ago

Yeah it was removed ~1 year ago probably because of that, c.f. https://github.com/kolton/d2bot-with-kolbot/commit/8c3b8fcfeab398ab1aa58cb4849ac860f8c179fd And no I don't have much interested trying to implement it, even if there was a way to do it right.

Kosoleld commented 5 years ago

Allright, is that because you have generally lost interest in the whole project?

On Sun, Mar 24, 2019 at 2:00 PM 5noop notifications@github.com wrote:

Yeah it was removed ~1 year ago probably because of that, c.f. 8c3b8fc

diff-64087b2317499d6b4aebb3a94077ca5f

https://github.com/kolton/d2bot-with-kolbot/commit/8c3b8fcfeab398ab1aa58cb4849ac860f8c179fd#diff-64087b2317499d6b4aebb3a94077ca5f And no I don't have much interested trying to implement it, even if there was a way to do it right.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/kolton/d2bot-with-kolbot/issues/1348#issuecomment-475956642, or mute the thread https://github.com/notifications/unsubscribe-auth/As7tpxJnosHJj4feMhtiTbqIzSf4LF4Iks5vZ3cAgaJpZM4b3Zn5 .