diff --git a/d2bs/kolbot/libs/bots/Andariel.js b/d2bs/kolbot/libs/bots/Andariel.js index 998797527..594b0fc49 100644 --- a/d2bs/kolbot/libs/bots/Andariel.js +++ b/d2bs/kolbot/libs/bots/Andariel.js @@ -4,7 +4,7 @@ * @desc kill Andariel */ -function Andariel() { +function Andariel () { this.killAndariel = function () { var i, target = getUnit(1, 156); @@ -19,7 +19,7 @@ function Andariel() { } for (i = 0; i < 300; i += 1) { - ClassAttack.doCast(target, Config.AttackSkill[1], Config.AttackSkill[2]); + ClassAttack.doAttack(target); if (target.dead) { return true; @@ -53,4 +53,4 @@ function Andariel() { Pickit.pickItems(); return true; -} \ No newline at end of file +} diff --git a/d2bs/kolbot/libs/bots/Duriel.js b/d2bs/kolbot/libs/bots/Duriel.js index f7ce972af..21bae5177 100644 --- a/d2bs/kolbot/libs/bots/Duriel.js +++ b/d2bs/kolbot/libs/bots/Duriel.js @@ -4,7 +4,7 @@ * @desc kill Duriel */ -function Duriel() { +function Duriel () { this.killDuriel = function () { var i, target; @@ -28,7 +28,7 @@ function Duriel() { } for (i = 0; i < 300; i += 1) { - ClassAttack.doCast(target, Config.AttackSkill[1], Config.AttackSkill[2]); + ClassAttack.doAttack(target); if (target.dead) { return true; @@ -44,8 +44,11 @@ function Duriel() { var i, unit; - Town.doChores(); - Pather.useWaypoint(46); + if (me.area !== 46) { + Town.doChores(); + Pather.useWaypoint(46); + } + Precast.doPrecast(true); if (!Pather.moveToExit(getRoom().correcttomb, true)) { @@ -100,4 +103,4 @@ function Duriel() { Pickit.pickItems(); return true; -} \ No newline at end of file +} diff --git a/d2bs/kolbot/libs/bots/Summoner.js b/d2bs/kolbot/libs/bots/Summoner.js index 6fa6fb755..acbc9d0ff 100644 --- a/d2bs/kolbot/libs/bots/Summoner.js +++ b/d2bs/kolbot/libs/bots/Summoner.js @@ -4,7 +4,7 @@ * @desc kill the Summoner */ -function Summoner() { +function Summoner () { Town.doChores(); Pather.useWaypoint(74); Precast.doPrecast(true); @@ -27,5 +27,24 @@ function Summoner() { Attack.clear(15, 0, 250); // The Summoner + if (Loader.scriptName(1) === "Duriel") { + let journal = getUnit(2, 357); + + if (!journal) { + throw new Error("Journal not found"); + } + + Pather.moveToUnit(journal); + journal.interact(); + delay(500); + me.cancel(); + + if (!Pather.usePortal(46)) { + throw new Error("Failed to take arcane portal"); + } + + Loader.skipTown.push("Duriel"); + } + return true; -} \ No newline at end of file +} diff --git a/d2bs/kolbot/libs/common/Loader.js b/d2bs/kolbot/libs/common/Loader.js index cd16c0800..f0540a79c 100644 --- a/d2bs/kolbot/libs/common/Loader.js +++ b/d2bs/kolbot/libs/common/Loader.js @@ -7,7 +7,10 @@ var global = this; var Loader = { + fileList: [], scriptList: [], + scriptIndex: -1, + skipTown: ["Test", "Follower"], init: function () { this.getScripts(); @@ -20,7 +23,7 @@ var Loader = { for (i = 0; i < fileList.length; i += 1) { if (fileList[i].indexOf(".js") > -1) { - this.scriptList.push(fileList[i].substring(0, fileList[i].indexOf(".js"))); + this.fileList.push(fileList[i].substring(0, fileList[i].indexOf(".js"))); } } }, @@ -81,65 +84,75 @@ var Loader = { }, loadScripts: function () { - var i, townCheck, reconfiguration, + var reconfiguration, s, script, unmodifiedConfig = {}; this.copy(Config, unmodifiedConfig); - if (!this.scriptList.length) { + if (!this.fileList.length) { showConsole(); throw new Error("You don't have any valid scripts in bots folder."); } - for (i in Scripts) { - if (Scripts.hasOwnProperty(i)) { - if (this.scriptList.indexOf(i) > -1) { - if (!!Scripts[i]) { - if (!include("bots/" + i + ".js")) { - Misc.errorReport("Failed to include script: " + i); + for (s in Scripts) { + if (Scripts.hasOwnProperty(s) && Scripts[s]) { + this.scriptList.push(s); + } + } + + for (this.scriptIndex = 0; this.scriptIndex < this.scriptList.length; this.scriptIndex++) { + script = this.scriptList[this.scriptIndex]; + + if (this.fileList.indexOf(script) < 0) { + Misc.errorReport("ÿc1Script " + script + " doesn't exist."); + continue; + } + + if (!include("bots/" + script + ".js")) { + Misc.errorReport("Failed to include script: " + script); + continue; + } + + if (isIncluded("bots/" + script + ".js")) { + try { + if (typeof (global[script]) !== "function") { + throw new Error("Invalid script function name"); + } + + if (this.skipTown.indexOf(script) > -1 || Town.goToTown()) { + print("ÿc2Starting script: ÿc9" + script); + //scriptBroadcast(JSON.stringify({currScript: script})); + Messaging.sendToScript("tools/toolsthread.js", JSON.stringify({currScript: script})); + + reconfiguration = typeof Scripts[script] === 'object'; + + if (reconfiguration) { + print("ÿc2Copying Config properties from " + script + " object."); + this.copy(Scripts[script], Config); } - if (isIncluded("bots/" + i + ".js")) { - try { - reconfiguration = typeof Scripts[i] === 'object'; - - if (typeof (global[i]) === "function") { - if (i !== "Test" && i !== "Follower") { - townCheck = Town.goToTown(); - } else { - townCheck = true; - } - - if (townCheck) { - print("ÿc2Starting script: ÿc9" + i); - //scriptBroadcast(JSON.stringify({currScript: i})); - Messaging.sendToScript("tools/toolsthread.js", JSON.stringify({currScript: i})); - - if (reconfiguration) { - print("ÿc2Copying Config properties from " + i + " object."); - this.copy(Scripts[i], Config); - } - - global[i](); - - if (reconfiguration) { - print("ÿc2Reverting back unmodified config properties."); - this.copy(unmodifiedConfig, Config); - } - } - } else { - throw new Error("Invalid script function name"); - } - } catch (error) { - Misc.errorReport(error, i); - } + global[script](); + + if (reconfiguration) { + print("ÿc2Reverting back unmodified config properties."); + this.copy(unmodifiedConfig, Config); } } - } else { - Misc.errorReport("ÿc1Script " + i + " doesn't exist."); + } catch (error) { + Misc.errorReport(error, script); } } } + }, + + scriptName: function (offset = 0) { + let index = this.scriptIndex + offset; + + if (index >= 0 && index < this.scriptList.length) { + return this.scriptList[index]; + } + + return null; } -}; \ No newline at end of file +}; diff --git a/d2bs/kolbot/libs/common/Pather.js b/d2bs/kolbot/libs/common/Pather.js index a7da217f6..fce8b3af1 100644 --- a/d2bs/kolbot/libs/common/Pather.js +++ b/d2bs/kolbot/libs/common/Pather.js @@ -923,7 +923,7 @@ ModeLoop: break; } - var i, tick, wp, coord, retry; + var i, tick, wp, coord, retry, npc; for (i = 0; i < 12; i += 1) { if (me.area === targetArea || me.dead) { @@ -931,6 +931,14 @@ ModeLoop: } if (me.inTown) { + npc = getUnit(1, NPC.Warriv); + + if (me.area === 40 && npc && getDistance(me, npc) < 50) { + if (npc && npc.openMenu()) { + Misc.useMenu(0x0D37); + } + } + Town.move("waypoint"); }