Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * @filename NotNormalDiablo.js
- * @author dzik (base on kolton's fast diablo)
- * @desc clear way from waypoint to diablo skipping normal mobs.
- */
- var temp2 = Pather.moveTo;
- Pather.moveTo = function (x, y, retry, clearPath, pop) {
- if (me.dead) { // Abort if dead
- return false;
- }
- var i, path, adjustedNode, cleared,
- node = {x: x, y: y},
- fail = 0;
- for (i = 0; i < Pather.cancelFlags.length; i += 1) {
- if (getUIFlag(Pather.cancelFlags[i])) {
- me.cancel();
- }
- }
- if (getDistance(me, x, y) < 2) {
- return true;
- }
- if (x === undefined || y === undefined) {
- 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 (retry === undefined) {
- retry = 3;
- }
- if (clearPath === undefined) {
- clearPath = false;
- }
- if (pop === undefined) {
- pop = false;
- }
- Pather.useTeleport = Pather.teleport && !me.getState(139) && !me.getState(140) && !me.inTown &&
- ((me.classid === 1 && me.getSkill(54, 1)) || me.getStat(97, 54));
- // Teleport without calling getPath if the spot is close enough
- if (Pather.useTeleport && getDistance(me, x, y) <= Pather.teleDistance) {
- //Misc.townCheck();
- return Pather.teleportTo(x, y);
- }
- // Walk without calling getPath if the spot is close enough
- if (!Pather.useTeleport && (getDistance(me, x, y) <= 5 || (getDistance(me, x, y) <= 25 && !CollMap.checkColl(me, {x: x, y: y}, 0x1)))) {
- return Pather.walkTo(x, y);
- }
- path = getPath(me.area, x, y, me.x, me.y, 0, 20);
- if (!path) {
- throw new Error("moveTo: Failed to generate path.");
- }
- path.reverse();
- if (pop) {
- path.pop();
- }
- PathDebug.drawPath(path);
- if (Pather.useTeleport && Config.TeleSwitch) {
- Misc.teleSwitch();
- }
- while (path.length > 0) {
- if (me.dead) { // Abort if dead
- return false;
- }
- for (i = 0; i < Pather.cancelFlags.length; i += 1) {
- if (getUIFlag(Pather.cancelFlags[i])) {
- 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 (getDistance(me, node) > 2) {
- // Make life in Maggot Lair easier
- if ([62, 63, 64].indexOf(me.area) > -1) {
- adjustedNode = Pather.getNearestWalkable(node.x, node.y, 15, 3, 0x1 | 0x4 | 0x800 | 0x1000);
- if (adjustedNode) {
- node.x = adjustedNode[0];
- node.y = adjustedNode[1];
- }
- }
- if (Pather.useTeleport ? Pather.teleportTo(node.x, node.y) : Pather.walkTo(node.x, node.y, (fail > 0 || me.inTown) ? 2 : 4)) {
- if (!me.inTown) {
- if (Pather.recursion) {
- Pather.recursion = false;
- NodeAction.go({clearPath: clearPath});
- if (getDistance(me, node.x, node.y) > 5) {
- Pather.moveTo(node.x, node.y);
- }
- Pather.recursion = true;
- }
- Misc.townCheck();
- }
- } else {
- if (fail > 0 && !Pather.useTeleport && !me.inTown) {
- // Don't go berserk on longer paths
- if (!cleared) {
- Attack.clear(5);
- cleared = true;
- }
- if (fail > 1 && me.getSkill(143, 1)) {
- Skill.cast(143, 0, node.x, node.y);
- }
- }
- // Reduce node distance in new path
- path = getPath(me.area, x, y, me.x, me.y, 0, 20);
- fail += 1;
- if (!path) {
- throw new Error("moveTo: Failed to generate path.");
- }
- path.reverse();
- PathDebug.drawPath(path);
- if (pop) {
- path.pop();
- }
- print("move retry " + fail);
- Attack.clear(5);
- if (fail > 0 && fail >= retry) {
- break;
- }
- }
- }
- delay(5);
- }
- if (Pather.useTeleport && Config.TeleSwitch) {
- Precast.weaponSwitch(Misc.oldSwitch);
- }
- PathDebug.removeHooks();
- return getDistance(me, node.x, node.y) < 5;
- };
- NodeAction.killMonsters = function (arg) {
- var monList;
- if (Config.Countess.KillGhosts && [21, 22, 23, 24, 25].indexOf(me.area) > -1) {
- monList = Attack.getMob(38, 0, 30);
- if (monList) {
- Attack.clearList(monList);
- }
- }
- if ((typeof Config.ClearPath === "number" || typeof Config.ClearPath === "object") && arg.clearPath === false) {
- switch (typeof Config.ClearPath) {
- case "number":
- Attack.clear(40, 0xF);
- break;
- case "object":
- if (!Config.ClearPath.hasOwnProperty("Areas") || Config.ClearPath.Areas.length === 0 || Config.ClearPath.Areas.indexOf(me.area) > -1) {
- Attack.clear(Config.ClearPath.Range, Config.ClearPath.Spectype);
- }
- break;
- }
- }
- if (arg.clearPath !== false) {
- Attack.clear(15, typeof arg.clearPath === "number" ? arg.clearPath : 0);
- }
- };
- var temp = Attack.clear;
- Attack.clear = function (range, spectype, bossId, sortfunc, pickit) {
- while (!me.gameReady) {
- delay(40);
- }
- if (Config.MFLeader && !!bossId) {
- Pather.makePortal();
- say("clear " + bossId);
- }
- if (range === undefined) {
- range = 25;
- }
- if (spectype === undefined) {
- spectype = 0xF;
- }
- if (bossId === undefined) {
- bossId = false;
- }
- if (sortfunc === undefined) {
- sortfunc = false;
- }
- if (pickit === undefined) {
- pickit = true;
- }
- if (typeof (range) !== "number") {
- throw new Error("Attack.clear: range must be a number.");
- }
- var i, boss, orgx, orgy, target, result, monsterList, start,
- gidAttack = [],
- attackCount = 0;
- if (Config.AttackSkill[1] < 0 || Config.AttackSkill[3] < 0) {
- return false;
- }
- if (!sortfunc) {
- sortfunc = Attack.sortMonsters;
- }
- if (bossId) {
- for (i = 0; !boss && i < 5; i += 1) {
- boss = bossId > 999 ? getUnit(1, -1, -1, bossId) : getUnit(1, bossId);
- delay(200);
- }
- if (!boss) {
- throw new Error("Attack.clear: " + bossId + " not found");
- }
- orgx = boss.x;
- orgy = boss.y;
- } else {
- orgx = me.x;
- orgy = me.y;
- }
- monsterList = [];
- target = getUnit(1);
- if (target) {
- do {
- if ((target.spectype & 0xF) && Attack.checkMonster(target) && Attack.skipCheck(target)) {
- // Speed optimization - don't go through monster list until there's at least one within clear range
- if (!start && getDistance(target, orgx, orgy) <= range &&
- (me.getSkill(54, 1) || !Scripts.Follower || !checkCollision(me, target, 0x1))) {
- start = true;
- }
- monsterList.push(copyUnit(target));
- }
- } while (target.getNext());
- }
- while (start && monsterList.length > 0 && attackCount < 300) {
- if (boss) {
- orgx = boss.x;
- orgy = boss.y;
- }
- if (me.dead) {
- return false;
- }
- //monsterList.sort(Sort.units);
- monsterList.sort(sortfunc);
- target = copyUnit(monsterList[0]);
- if ((target.spectype & 0xF) && target.x !== undefined && (getDistance(target, orgx, orgy) <= range || (Attack.getScarinessLevel(target) > 7 && getDistance(me, target) <= range)) && Attack.checkMonster(target)) {
- if (Config.Dodge && me.hp * 100 / me.hpmax <= Config.DodgeHP) {
- Attack.deploy(target, Config.DodgeRange, 5, 9);
- }
- Misc.townCheck(true);
- me.overhead("attacking " + target.name + " spectype " + target.spectype + " id " + target.classid);
- result = ClassAttack.doAttack(target, attackCount % 15 === 0);
- if (result) {
- for (i = 0; i < gidAttack.length; i += 1) {
- if (gidAttack[i].gid === target.gid) {
- break;
- }
- }
- if (i === gidAttack.length) {
- gidAttack.push({gid: target.gid, attacks: 0, name: target.name});
- }
- gidAttack[i].attacks += 1;
- attackCount += 1;
- // Desync/bad position handler
- switch (Config.AttackSkill[(target.spectype & 0x7) ? 1 : 3]) {
- case 112:
- //print(gidAttack[i].name + " " + gidAttack[i].attacks);
- // Tele in random direction with Blessed Hammer
- if (gidAttack[i].attacks > 0 && gidAttack[i].attacks % ((target.spectype & 0x7) ? 4 : 2) === 0) {
- //print("random move m8");
- Pather.moveTo(me.x + rand(-1, 1) * 5, me.y + rand(-1, 1) * 5);
- }
- break;
- default:
- // Flash with melee skills
- if (gidAttack[i].attacks > 0 && gidAttack[i].attacks % ((target.spectype & 0x7) ? 15 : 5) === 0 && Skill.getRange(Config.AttackSkill[(target.spectype & 0x7) ? 1 : 3]) < 4) {
- Packet.flash(me.gid);
- }
- break;
- }
- // Skip non-unique monsters after 15 attacks, except in Throne of Destruction
- if (me.area !== 131 && !(target.spectype & 0x7) && gidAttack[i].attacks > 15) {
- print("˙c1Skipping " + target.name + " " + target.gid + " " + gidAttack[i].attacks);
- monsterList.shift();
- }
- if (target.mode === 0 || target.mode === 12 || Config.FastPick === 2) {
- Pickit.fastPick();
- }
- } else {
- monsterList.shift();
- }
- } else {
- monsterList.shift();
- }
- }
- ClassAttack.afterAttack(pickit);
- Attack.openChests(range, orgx, orgy);
- if (attackCount > 0 && pickit) {
- Pickit.pickItems();
- }
- return true;
- };
- function NotNormalDiablo() {
- this.getLayout = function (seal, value) {
- var sealPreset = getPresetUnit(108, 2, seal);
- if (!seal) {
- Pather.moveTo = temp2;
- Attack.clear = temp;
- throw new Error("Seal preset not found");
- }
- if (sealPreset.roomy * 5 + sealPreset.y === value || sealPreset.roomx * 5 + sealPreset.x === value) {
- return 1;
- }
- return 2;
- };
- this.initLayout = function () {
- this.vizLayout = this.getLayout(396, 5275);
- this.seisLayout = this.getLayout(394, 7773);
- this.infLayout = this.getLayout(392, 7893);
- };
- this.getBoss = function (name) {
- var i, boss,
- glow = getUnit(2, 131);
- for (i = 0; i < 24; i += 1) {
- boss = getUnit(1, name);
- if (boss) {
- this.chaosPreattack(name, 8);
- try {
- Attack.kill(name);
- } catch (e) {
- Attack.clear(10, 0, name);
- }
- Pickit.pickItems();
- return true;
- }
- delay(250);
- }
- return !!glow;
- };
- this.chaosPreattack = function (name, amount) {
- var i, n, target, positions;
- switch (me.classid) {
- case 0:
- break;
- case 1:
- break;
- case 2:
- break;
- case 3:
- target = getUnit(1, name);
- if (!target) {
- return;
- }
- positions = [[6, 11], [0, 8], [8, -1], [-9, 2], [0, -11], [8, -8]];
- for (i = 0; i < positions.length; i += 1) {
- if (Attack.validSpot(target.x + positions[i][0], target.y + positions[i][1])) { // check if we can move there
- Pather.moveTo(target.x + positions[i][0], target.y + positions[i][1], 3, true);
- Skill.setSkill(Config.AttackSkill[2], 0);
- for (n = 0; n < amount; n += 1) {
- Skill.cast(Config.AttackSkill[1], 1);
- }
- break;
- }
- }
- break;
- case 4:
- break;
- case 5:
- break;
- case 6:
- break;
- }
- };
- this.diabloPrep = function () {
- var trapCheck,
- tick = getTickCount();
- while (getTickCount() - tick < 17500) {
- if (getTickCount() - tick >= 8000) {
- switch (me.classid) {
- case 1: // Sorceress
- if ([56, 59, 64].indexOf(Config.AttackSkill[1]) > -1) {
- if (me.getState(121)) {
- delay(500);
- } else {
- Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
- }
- break;
- }
- delay(500);
- break;
- case 3: // Paladin
- Skill.setSkill(Config.AttackSkill[2]);
- Skill.cast(Config.AttackSkill[1], 1);
- break;
- case 5: // Druid
- if (Config.AttackSkill[1] === 245) {
- Skill.cast(Config.AttackSkill[1], 0, 7793, 5293);
- break;
- }
- delay(500);
- break;
- case 6: // Assassin
- if (Config.UseTraps) {
- trapCheck = ClassAttack.checkTraps({x: 7793, y: 5293});
- if (trapCheck) {
- ClassAttack.placeTraps({x: 7793, y: 5293, classid: 243}, trapCheck);
- break;
- }
- }
- delay(500);
- break;
- default:
- delay(500);
- }
- } else {
- delay(500);
- }
- if (getUnit(1, 243)) {
- return true;
- }
- }
- Pather.moveTo = temp2;
- Attack.clear = temp;
- throw new Error("Diablo not found");
- };
- this.openSeal = function (classid) {
- var i, j, seal;
- for (i = 0; i < 5; i += 1) {
- Pather.moveToPreset(108, 2, classid, classid === 394 ? 5 : 2, classid === 394 ? 5 : 0, true);
- if (i > 1) {
- Attack.clear(10);
- }
- for (j = 0; j < 3; j += 1) {
- seal = getUnit(2, classid);
- if (seal) {
- break;
- }
- delay(100);
- }
- if (!seal) {
- Pather.moveTo = temp2;
- Attack.clear = temp;
- throw new Error("Seal not found (id " + classid + ")");
- }
- if (seal.mode) {
- return true;
- }
- sendPacket(1, 0x13, 4, 0x2, 4, seal.gid);
- delay(classid === 394 ? 1000 : 500);
- if (!seal.mode) {
- if (classid === 394 && Attack.validSpot(seal.x + 15, seal.y)) { // de seis optimization
- Pather.moveTo(seal.x + 15, seal.y, 3, true);
- } else {
- Pather.moveTo(seal.x - 5, seal.y - 5, 3, true);
- }
- delay(500);
- } else {
- return true;
- }
- }
- Pather.moveTo = temp2;
- Attack.clear = temp;
- throw new Error("Failed to open seal (id " + classid + ")");
- };
- Town.doChores();
- Pather.useWaypoint(106);
- Pather.moveToExit(107, true, false);
- Precast.doPrecast(true);
- if (!Pather.moveToPreset(me.area, 2, 376, true)) {
- throw new Error("Failed to move to Hephasto");
- }
- Attack.kill(getLocaleString(1067)); // Hephasto The Armorer
- Pickit.pickItems();
- Precast.doPrecast(true);
- this.initLayout();
- this.openSeal(395);
- this.openSeal(396);
- if (this.vizLayout === 1) {
- Pather.moveTo(7691, 5292, 3, true);
- } else {
- Pather.moveTo(7695, 5316, 3, true);
- }
- if (!this.getBoss(getLocaleString(2851))) {
- Pather.moveTo = temp2;
- Attack.clear = temp;
- throw new Error("Failed to kill Vizier");
- }
- this.openSeal(394);
- if (this.seisLayout === 1) {
- Pather.moveTo(7771, 5196, 3, true);
- } else {
- Pather.moveTo(7798, 5186, 3, true);
- }
- if (!this.getBoss(getLocaleString(2852))) {
- Pather.moveTo = temp2;
- Attack.clear = temp;
- throw new Error("Failed to kill de Seis");
- }
- this.openSeal(392);
- this.openSeal(393);
- if (this.infLayout === 1) {
- delay(1);
- } else {
- Pather.moveTo(7928, 5295, 3, true); // temp
- }
- if (!this.getBoss(getLocaleString(2853))) {
- Pather.moveTo = temp2;
- Attack.clear = temp;
- throw new Error("Failed to kill Infector");
- }
- Pather.moveTo(7788, 5292, 3, true);
- Pather.moveTo = temp2;
- Attack.clear = temp;
- this.diabloPrep();
- Attack.kill(243); // Diablo
- Pickit.pickItems();
- return true;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement