Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var Pather = {
- teleport: true,
- walkDistance: 15,
- teleDistance: 40,
- wpAreas: [1, 3, 4, 5, 6, 27, 29, 32, 35, 40, 48, 42, 57, 43, 44, 52, 74, 46, 75, 76, 77, 78, 79, 80, 81, 83, 101, 103, 106, 107, 109, 111, 112, 113, 115, 123, 117, 118, 129],
- moveTo: function (x, y, retry, clearPath, pop) {
- if (getDistance(me, x, y) < 2) {
- return true;
- }
- if (arguments.length < 2) {
- throw new Error("moveTo: Function must be called with at least 2 arguments.");
- }
- if (typeof (x) !== "number" || typeof (y) !== "number") {
- throw new Error("moveTo: Coords must be numbers");
- }
- if (getUIFlag(0x01) || getUIFlag(0x02) || getUIFlag(0x04) || getUIFlag(0x16) || getUIFlag(0x0C) || getUIFlag(0x0F)) {
- me.cancel();
- }
- switch (arguments.length) {
- case 2:
- retry = 3;
- clearPath = false;
- pop = false;
- break;
- case 3:
- clearPath = false;
- pop = false;
- break;
- case 4:
- pop = false;
- break;
- }
- var path, mob,
- node = {x: x, y: y},
- fail = 0;
- this.useTeleport = this.teleport && !me.inTown && me.getSkill(54, 1);
- // Teleport without calling getPath if the spot is close enough
- if (this.useTeleport && getDistance(me, x, y) <= this.teleDistance) {
- return this.teleportTo(x, y);
- }
- // Walk without calling getPath if the spot is close enough
- if (!this.useTeleport && getDistance(me, x, y) <= 5) {
- return this.walkTo(x, y);
- }
- //path = getPath(me.area, x, y, me.x, me.y, this.useTeleport ? 1 : 0, this.useTeleport ? this.teleDistance : this.walkDistance);
- path = getPath(me.area, me.x, me.y, x, y, this.useTeleport ? 1 : 0, this.useTeleport ? this.teleDistance : this.walkDistance);
- if (!path) {
- throw new Error("moveTo: Failed to generate path.");
- }
- //path.reverse();
- if (pop) {
- path.pop();
- }
- if (this.useTeleport && Config.TeleSwitch) {
- Misc.teleSwitch();
- }
- while (path.length > 0) {
- if (getUIFlag(0x01) || getUIFlag(0x02) || getUIFlag(0x04) || getUIFlag(0x16) || getUIFlag(0x0C) || getUIFlag(0x0F)) {
- me.cancel();
- }
- node = path.shift();
- /* Right now getPath's first node is our own position so it's not necessary to take it into account
- This will be removed if getPath changes
- */
- if (this.useTeleport && getDistance(me, node) < 2) {
- continue;
- }
- if (!(this.useTeleport ? this.teleportTo(node.x, node.y) : this.walkTo(node.x, node.y))) {
- // Reduce node distance in new path
- //path = getPath(me.area, x, y, me.x, me.y, this.useTeleport ? 1 : 0, this.useTeleport ? 30 : 10);
- path = getPath(me.area, me.x, me.y, x, y, this.useTeleport ? 1 : 0, this.useTeleport ? 30 : 10);
- if (!path) {
- throw new Error("moveTo: Failed to generate path.");
- }
- //path.reverse();
- if (fail === 2 && !this.useTeleport) {
- Attack.clear(5);
- }
- fail += 1;
- print("move retry " + fail);
- }
- if (fail >= retry) {
- break;
- }
- if (clearPath) {
- Attack.clear(15, typeof clearPath === "number" ? clearPath : false);
- if (getDistance(me, node.x, node.y) > 4) {
- this.moveTo(node.x, node.y);
- }
- }
- if (Config.Countess.KillGhosts) { // TODO: expand&improve
- mob = Attack.getMob("ghost", 0, 30);
- if (mob) {
- Attack.clearList(mob);
- }
- if (getDistance(me, node.x, node.y) > 4) {
- this.moveTo(node.x, node.y);
- }
- }
- if (Misc.townCheck(false)) {
- this.useTeleport = this.teleport && !me.inTown && me.getSkill(54, 1);
- }
- }
- if (this.useTeleport && Config.TeleSwitch) {
- Precast.weaponSwitch(Misc.oldSwitch);
- }
- return getDistance(me, node.x, node.y) < 4;
- },
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement