diff --git a/d2bs/kolbot/D2BotChannel.dbj b/d2bs/kolbot/D2BotChannel.dbj index 95315f188..1aa5fb2be 100644 --- a/d2bs/kolbot/D2BotChannel.dbj +++ b/d2bs/kolbot/D2BotChannel.dbj @@ -183,6 +183,7 @@ MainSwitch: case 2: // Waiting In Line D2Bot.updateStatus("Waiting..."); locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location); + ControlAction.click(6, 433, 433, 96, 32); break; case 3: // Lobby Chat diff --git a/d2bs/kolbot/D2BotFollow.dbj b/d2bs/kolbot/D2BotFollow.dbj index cc073f73a..75b5a481b 100644 --- a/d2bs/kolbot/D2BotFollow.dbj +++ b/d2bs/kolbot/D2BotFollow.dbj @@ -232,6 +232,7 @@ MainSwitch: case 2: // Waiting In Line D2Bot.updateStatus("Waiting..."); locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location); + ControlAction.click(6, 433, 433, 96, 32); break; case 3: // Lobby Chat diff --git a/d2bs/kolbot/D2BotLead.dbj b/d2bs/kolbot/D2BotLead.dbj index 672baf483..5d164c35c 100644 --- a/d2bs/kolbot/D2BotLead.dbj +++ b/d2bs/kolbot/D2BotLead.dbj @@ -250,6 +250,7 @@ MainSwitch: case 2: // Waiting In Line D2Bot.updateStatus("Waiting..."); locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location); + ControlAction.click(6, 433, 433, 96, 32); break; case 3: // Lobby Chat @@ -493,6 +494,7 @@ MainSwitch: D2Bot.updateStatus("Disconnected"); delay(500); ControlAction.click(6, 351, 337, 96, 32); + break; case 15: // New Character break; @@ -505,6 +507,7 @@ MainSwitch: case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway delay(1000); ControlAction.click(6, 351, 337, 96, 32); + break; case 19: // Login - Cdkey In Use D2Bot.printToConsole("CD-Key in use by " + ControlAction.getText(4, 158, 310, 485, 40)); diff --git a/d2bs/kolbot/D2BotMule.dbj b/d2bs/kolbot/D2BotMule.dbj index 3dbc36850..581f11b2c 100644 --- a/d2bs/kolbot/D2BotMule.dbj +++ b/d2bs/kolbot/D2BotMule.dbj @@ -1,4 +1,15 @@ -var muler, mulerStatus, keyswap, +var StarterConfig = { + SwitchKeyDelay: 0, // Seconds to wait before switching a used/banned key or after realm down + RealmDownDelay: 3, // Minutes to wait after getting Realm Down message + UnableToConnectDelay: 5, // Minutes to wait after Unable To Connect message + CDKeyInUseDelay: 5, // Minutes to wait before connecting again if CD-Key is in use. + ConnectingTimeout: 20, // Seconds to wait before cancelling the 'Connecting...' screen + PleaseWaitTimeout: 10, // Seconds to wait before cancelling the 'Please Wait...' screen + WaitInLineTimeout: 60 // Seconds to wait before cancelling the 'Waiting in Line...' screen +}; + + +var muler, mulerStatus, keyswap, connectFail, makeNext = false, status = "loading"; @@ -59,8 +70,9 @@ function pickItems() { rval = "fail", list = []; - while (me.ingame && !me.gameReady) + while (me.ingame && !me.gameReady) { delay(500); + } while (me.gameReady) { if (mulerStatus === "done") { @@ -73,12 +85,10 @@ function pickItems() { } // If and only if there is nothing left are we "done" - if (list.length == 0) - { + if (list.length === 0) { rval = "done"; break; } - while (list.length > 0) { item = list.shift(); canFit = Storage.Inventory.CanFit(item); @@ -96,8 +106,9 @@ function pickItems() { } } - if (rval == "next") + if (rval === "next") { break; + } } else { sendCopyData(null, muler, 0, "report"); //D2Bot.shoutGlobal("report", 0); @@ -180,6 +191,15 @@ function nextChar() { charNumbers = "abcdefghijklmnopqrstuvwxyz", obj = MuleData.read(); + if (getLocation() === 12) { + obj.charNum = ControlAction.getCharacters().length; + } + + // dirty + if (obj.charNum > 25) { + obj.charNum = 0; + } + num = obj.accNum.toString(); for (i = 0; i < num.length; i += 1) { @@ -214,6 +234,21 @@ function timeoutDelay(text, time) { } } +function updateCount() { + D2Bot.updateCount(); + delay(1000); + ControlAction.click(6, 264, 366, 272, 35); + + try { + login(me.profile); + } catch (e) { + + } + + delay(1000); + ControlAction.click(6, 33, 572, 128, 35); +} + include("json2.js"); include("oog.js"); include("automule.js"); @@ -243,11 +278,10 @@ function main() { if (!FileTools.exists("AutoMule." + AutoMule.realm + ".json")) { MuleData.create(); } - } - catch (e) { + } catch (e) { print("Caught exception creating data files."); print(e); - D2Bot.printToConsole("Exception: "+e); + D2Bot.printToConsole("Exception: " + e); } while (true) { @@ -256,6 +290,7 @@ function main() { if (status === "loading") { status = "ready"; + D2Bot.updateStatus("In mule game."); D2Bot.printToConsole("In mule game."); Storage.Init(); } @@ -264,8 +299,7 @@ function main() { delay(500); } - if (!muler) - { + if (!muler) { D2Bot.printToConsole("Failed to contact mulee."); D2Bot.stop(); } @@ -305,11 +339,10 @@ function main() { locationAction(getLocation()); delay(1000); - } - catch (e) { + } catch (e2) { print("Caught an exception in the main loop."); print(e); - D2Bot.printToConsole("Exception: "+e); + D2Bot.printToConsole("Exception: " + e); } } } @@ -319,6 +352,8 @@ function locationAction(location) { MainSwitch: switch (location) { + case 0: + break; case 1: case 3: if (makeNext) { @@ -343,6 +378,12 @@ MainSwitch: createGame(AutoMule.muleGameName[0], AutoMule.muleGameName[1]); locationTimeout(5000, location); + break; + case 2: // Waiting In Line + D2Bot.updateStatus("Waiting..."); + locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location); + ControlAction.click(6, 433, 433, 96, 32); + break; case 5: // Join Game D2Bot.updateStatus("Join Game"); @@ -350,6 +391,10 @@ MainSwitch: joinGame(AutoMule.muleGameName[0], AutoMule.muleGameName[1]); locationTimeout(5000, location); + break; + case 6: // Ladder + break; + case 7: // Channel List break; case 8: // menu case 9: // login @@ -430,6 +475,49 @@ MainSwitch: delay(1000); } + break; + case 11: // Unable To Connect + D2Bot.updateStatus("Unable To Connect"); + + if (connectFail) { + timeoutDelay("Unable to Connect", StarterConfig.UnableToConnectDelay * 6e4); + + connectFail = false; + } + + if (!ControlAction.click(6, 335, 450, 128, 35)) { + break; + } + + connectFail = true; + + break; + case 13: // Realm Down - Character Select screen + D2Bot.updateStatus("Realm Down"); + delay(1000); + + if (!ControlAction.click(6, 33, 572, 128, 35)) { + break; + } + + updateCount(); + timeoutDelay("Realm Down", StarterConfig.RealmDownDelay * 6e4); + D2Bot.CDKeyRD(); + + if (keyswap) { + D2Bot.printToConsole("Realm Down - Changing CD-Key"); + timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000); + D2Bot.restart(true); + } else { + D2Bot.restart(); + } + + break; + case 14: // Character Select / Main Menu - Disconnected + D2Bot.updateStatus("Disconnected"); + delay(500); + ControlAction.click(6, 351, 337, 96, 32); + break; case 18: // splash ControlAction.click(); @@ -487,10 +575,69 @@ MainSwitch: D2Bot.printToConsole("Made character: " + info.charName); } + break; + case 16: // Character Select - Please Wait popup + if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) { + ControlAction.click(6, 351, 337, 96, 32); + } + + break; + case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway + delay(1000); + ControlAction.click(6, 351, 337, 96, 32); + + break; + case 19: // Login - Cdkey In Use + D2Bot.printToConsole("CD-Key in use by " + ControlAction.getText(4, 158, 310, 485, 40)); + D2Bot.CDKeyInUse(); + + if (keyswap) { + timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000); + D2Bot.restart(true); + } else { + ControlAction.click(6, 335, 450, 128, 35); + timeoutDelay("CD-Key in use", StarterConfig.CDKeyInUseDelay * 6e4); + } + + break; + case 20: // Single Player - Select Difficulty + break; + case 21: // Main Menu - Connecting + if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) { + ControlAction.click(6, 330, 416, 128, 35); + } + + break; + case 22: // Login - Invalid Cdkey (classic or xpac) + if (keyswap) { + D2Bot.printToConsole("Invalid CD-Key"); + timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000); + D2Bot.restart(true); + } else { + ControlAction.click(6, 335, 450, 128, 35); + timeoutDelay("Invalid CD-Key", StarterConfig.CDKeyInUseDelay * 6e4); + } + + break; + case 23: // Character Select - Connecting + if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) { + ControlAction.click(6, 33, 572, 128, 35); + } + + break; + case 24: // Server Down - not much to do but wait.. + break; + case 25: // Lobby - Please Wait + if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) { + ControlAction.click(6, 351, 337, 96, 32); + } + break; case 26: // game already exists ControlAction.click(6, 652, 469, 120, 20); // Join + break; + case 27: // Gateway Select break; case 28: // Lobby - Game Does Not Exist ControlAction.click(6, 533, 469, 120, 20); @@ -500,5 +647,7 @@ MainSwitch: ControlAction.click(6, 351, 337, 96, 32); break; + case 38: // Game is full + break; // not sure how/if to handle } -} +} \ No newline at end of file diff --git a/d2bs/kolbot/D2BotMuleLog.dbj b/d2bs/kolbot/D2BotMuleLog.dbj index 12bf03371..c9b874782 100644 --- a/d2bs/kolbot/D2BotMuleLog.dbj +++ b/d2bs/kolbot/D2BotMuleLog.dbj @@ -173,6 +173,7 @@ MainSwitch: case 2: // Waiting In Line D2Bot.updateStatus("Waiting..."); locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location); + ControlAction.click(6, 433, 433, 96, 32); break; case 4: // Create Game diff --git a/d2bs/kolbot/libs/AutoMule.js b/d2bs/kolbot/libs/AutoMule.js index 99a538704..c808e4150 100644 --- a/d2bs/kolbot/libs/AutoMule.js +++ b/d2bs/kolbot/libs/AutoMule.js @@ -32,7 +32,7 @@ var AutoMule = { switch (msg) { case "report": // reply to status request sendCopyData(null, AutoMule.muleProfile, 12, status); - + break; case "quit": // quit command status = "quit"; diff --git a/d2bs/kolbot/libs/MuleLogger.js b/d2bs/kolbot/libs/MuleLogger.js index 2ff33634d..351674d64 100644 --- a/d2bs/kolbot/libs/MuleLogger.js +++ b/d2bs/kolbot/libs/MuleLogger.js @@ -22,7 +22,7 @@ var MuleLogger = { LogGame: ["muleloggame", "password"], // ["gamename", "password"] LogNames: true, // Put account/character name on the picture LogItemLevel: true, // Add item level to the picture - SaveScreenShot: true, // Save pictures in jpg format (saved in 'Images' folder) + SaveScreenShot: false, // Save pictures in jpg format (saved in 'Images' folder) IngameTime: 20, // Time to wait after leaving game // don't edit @@ -73,6 +73,10 @@ var MuleLogger = { }, logChar: function () { + while (!me.gameReady) { + delay(500); + } + var i, folder, items = me.getItems(), color = -1, @@ -92,6 +96,10 @@ var MuleLogger = { folder.create(me.account); } + if (!items.length) { + return; + } + for (i = 0; i < items.length; i += 1) { if (items[i].mode === 0) { color = items[i].getColor(); diff --git a/d2bs/kolbot/libs/NTItemParser.dbl b/d2bs/kolbot/libs/NTItemParser.dbl index 92965e770..cea59a234 100644 --- a/d2bs/kolbot/libs/NTItemParser.dbl +++ b/d2bs/kolbot/libs/NTItemParser.dbl @@ -202,7 +202,7 @@ function NTIP_CheckQuantityOwned(item_type, item_stats) { } } - print("I have "+num+" of these."); + //print("I have "+num+" of these."); return num; } @@ -509,43 +509,61 @@ Unit.prototype.getColor = function () { "Godly": 16, "Visionary": 20, "Mnemonic": 6, - "Psychic": 14, - "Veteran's": 14, + // changed skill tabs to 15 from 14 because it looks more appropriate + "Bowyer's": 15, + "Gymnastic": 15, + "Spearmaiden's": 15, + "Archer's": 15, + "Athlete's": 15, + "Lancer's": 15, + "Charged": 15, + "Blazing": 15, + "Freezing": 15, + "Glacial": 15, + "Powered": 15, + "Volcanic": 15, + "Blighting": 15, + "Noxious": 15, + "Mojo": 15, + "Cursing": 15, + "Venomous": 15, + "Golemlord's": 15, + "Warden's": 15, + "Hawk Branded": 15, + "Commander's": 15, + "Marshal's": 15, + "Rose Branded": 15, + "Guardian's": 15, + "Veteran's": 15, + "Resonant": 15, + "Raging": 15, + "Echoing": 15, + "Furious": 15, + "Master's": 15, // there's 2x masters... + "Caretaker's": 15, + "Terrene": 15, + "Feral": 15, + "Gaean": 15, + "Communal": 15, + "Keeper's": 15, + "Sensei's": 15, + "Trickster's": 15, + "Psychic": 15, + "Kenshi's": 15, + "Cunning": 15, + "Shadow": 15, + "Faithful": 20, + "Priest's": 12, "Dragon's": 6, "Vulpine": 6, "Shimmering": 17, "Rainbow": 17, "Scintillating": 17, "Prismatic": 17, - "Warden's": 14, - "Hawk Branded": 14, - "Commander's": 14, - "Priest's": 12, - "Caretaker's": 14, - "Terrene": 14, - "Feral": 14, "Hierophant's": 12, - "Resonant": 14, - "Raging": 14, - "Veteran's": 14, "Berserker's": 12, - "Blighting": 14, - "Noxious": 14, - "Mojo": 14, "Necromancer's": 12, - "Sensei's": 14, - "Bowyer's": 14, - "Gymnastic": 14, - "Spearmaiden's": 14, - "Athlete's": 14, - "Archer's": 14, - "Kenshi's": 14, - "Lancer's": 14, - "Charged": 14, - "Blazing": 14, - "Freezing": 14, - "Trickster's": 14, "Witch-hunter's": 12, "Arch-Angel's": 12, "Valkyrie's": 12, diff --git a/d2bs/kolbot/libs/OOG.js b/d2bs/kolbot/libs/OOG.js index 5c4193e69..747a87663 100644 --- a/d2bs/kolbot/libs/OOG.js +++ b/d2bs/kolbot/libs/OOG.js @@ -117,7 +117,7 @@ var DataFile = { }, updateStats: function (arg, value) { - var obj, string; + var obj, string, area; obj = this.getObj(); @@ -132,6 +132,12 @@ var DataFile = { break; case "lastArea": + area = getArea(); + + if (typeof area !== "object") { + return; + } + if (obj.lastArea === getArea().name) { return; } @@ -624,4 +630,4 @@ var ShitList = { FileTools.writeText("shitlist.json", string); } -}; +}; \ No newline at end of file diff --git a/d2bs/kolbot/libs/bots/BaalHelper.js b/d2bs/kolbot/libs/bots/BaalHelper.js index 0b2f0861e..66ee54a0a 100644 --- a/d2bs/kolbot/libs/bots/BaalHelper.js +++ b/d2bs/kolbot/libs/bots/BaalHelper.js @@ -310,6 +310,7 @@ MainLoop: } delay(1000); + Pather.moveTo(15092, 5011); portal = getUnit(2, 563); diff --git a/d2bs/kolbot/libs/bots/Questing.js b/d2bs/kolbot/libs/bots/Questing.js index c5f680b5c..4381b98bd 100644 --- a/d2bs/kolbot/libs/bots/Questing.js +++ b/d2bs/kolbot/libs/bots/Questing.js @@ -1 +1 @@ -/** * @filename Questing.js * @author kolton * @desc Do quests, only most popular ones for now */ function Questing() { var i, quests = [ [1, "clearDen"], [9, "killRadament"], [17, "lamEssen"], [25, "killIzual"], [35, "killShenk"], [37, "freeAnya"] ]; this.clearDen = function () { var akara; if (!Town.goToTown(1) || !Pather.moveToExit([2, 8], true)) { throw new Error(); } Precast.doPrecast(true); Attack.clearLevel(); Town.goToTown(); Town.move("akara"); akara = getUnit(1, "akara"); akara.openMenu(); me.cancel(); return true; }; this.killRadament= function () { var book, atma; if (!Town.goToTown() || !Pather.useWaypoint(48)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToExit(49, true) || !Pather.moveToPreset(me.area, 2, 355)) { throw new Error(); } Attack.kill(229); // Radament book = getUnit(4, 552); if (book) { Pickit.pickItem(book); delay(300); clickItem(1, book); } Town.goToTown(); Town.move("atma"); atma = getUnit(1, "atma"); atma.openMenu(); me.cancel(); return true; }; this.killIzual = function () { var tyrael; if (!Town.goToTown() || !Pather.useWaypoint(106)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToPreset(105, 1, 256)) { return false; } Attack.kill(256); // Izual Town.goToTown(); Town.move("tyrael"); tyrael = getUnit(1, "tyrael"); tyrael.openMenu(); me.cancel(); return true; }; this.lamEssen = function () { var stand, book, alkor; if (!Town.goToTown() || !Pather.useWaypoint(80)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToExit(94, true) || !Pather.moveToPreset(me.area, 2, 193)) { throw new Error(); } stand = getUnit(2, 193); Misc.openChest(stand); delay(300); book = getUnit(4, 548); Pickit.pickItem(book); Town.goToTown(); Town.move("alkor"); alkor = getUnit(1, "alkor"); alkor.openMenu(); me.cancel(); return true; }; this.killShenk = function () { if (!Town.goToTown() || !Pather.useWaypoint(111)) { throw new Error(); } Precast.doPrecast(true); Pather.moveTo(3883, 5113); Attack.kill(getLocaleString(22435)); // Shenk the Overseer Town.goToTown(); return true; }; this.freeAnya = function () { var anya, malah, scroll; if (!Town.goToTown() || !Pather.useWaypoint(113)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToExit(114, true) || !Pather.moveToPreset(me.area, 2, 460)) { throw new Error(); } delay(1000); Attack.clear(10); anya = getUnit(2, 558); Pather.moveToUnit(anya); anya.interact(); delay(300); me.cancel(); Town.goToTown(); Town.move("malah"); malah = getUnit(1, "malah"); malah.openMenu(); me.cancel(); Town.move("portalspot"); Pather.usePortal(114, me.name); anya.interact(); delay(300); me.cancel(); Town.goToTown(); Town.move("malah"); malah.openMenu(); me.cancel(); scroll = me.getItem(646); clickItem(1, scroll); return true; }; for (i = 0; i < quests.length; i += 1) { if (!me.getQuest(quests[i][0], 0)) { try { this[quests[i][1]](); } catch (e) { print("Quest failed, moving to next one"); continue; } } } return true; } \ No newline at end of file +/** * @filename Questing.js * @author kolton * @desc Do quests, only most popular ones for now */ function Questing() { var i, quests = [ [1, "clearDen"], [9, "killRadament"], [17, "lamEssen"], [25, "killIzual"], [35, "killShenk"], [37, "freeAnya"] ]; this.clearDen = function () { print("starting den"); var akara; if (!Town.goToTown(1) || !Pather.moveToExit([2, 8], true)) { throw new Error(); } Precast.doPrecast(true); Attack.clearLevel(); Town.goToTown(); Town.move("akara"); akara = getUnit(1, "akara"); akara.openMenu(); me.cancel(); return true; }; this.killRadament = function () { print("starting radament"); var book, atma; if (!Town.goToTown() || !Pather.useWaypoint(48, true)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToExit(49, true) || !Pather.moveToPreset(me.area, 2, 355)) { throw new Error(); } Attack.kill(229); // Radament book = getUnit(4, 552); if (book) { Pickit.pickItem(book); delay(300); clickItem(1, book); } Town.goToTown(); Town.move("atma"); atma = getUnit(1, "atma"); atma.openMenu(); me.cancel(); return true; }; this.killIzual = function () { print("starting izual"); var tyrael; if (!Town.goToTown() || !Pather.useWaypoint(106, true)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToPreset(105, 1, 256)) { return false; } Attack.kill(256); // Izual Town.goToTown(); Town.move("tyrael"); tyrael = getUnit(1, "tyrael"); tyrael.openMenu(); me.cancel(); return true; }; this.lamEssen = function () { print("starting lam essen"); var stand, book, alkor; if (!Town.goToTown() || !Pather.useWaypoint(80, true)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToExit(94, true) || !Pather.moveToPreset(me.area, 2, 193)) { throw new Error(); } stand = getUnit(2, 193); Misc.openChest(stand); delay(300); book = getUnit(4, 548); Pickit.pickItem(book); Town.goToTown(); Town.move("alkor"); alkor = getUnit(1, "alkor"); alkor.openMenu(); me.cancel(); return true; }; this.killShenk = function () { print("starting shenk"); if (!Town.goToTown() || !Pather.useWaypoint(111, true)) { throw new Error(); } Precast.doPrecast(true); Pather.moveTo(3883, 5113); Attack.kill(getLocaleString(22435)); // Shenk the Overseer Town.goToTown(); return true; }; this.freeAnya = function () { print("starting anya"); var anya, malah, scroll; if (!Town.goToTown() || !Pather.useWaypoint(113, true)) { throw new Error(); } Precast.doPrecast(true); if (!Pather.moveToExit(114, true) || !Pather.moveToPreset(me.area, 2, 460)) { throw new Error(); } delay(1000); Attack.clear(10); anya = getUnit(2, 558); Pather.moveToUnit(anya); anya.interact(); delay(300); me.cancel(); Town.goToTown(); Town.move("malah"); malah = getUnit(1, "malah"); malah.openMenu(); me.cancel(); Town.move("portalspot"); Pather.usePortal(114, me.name); anya.interact(); delay(300); me.cancel(); Town.goToTown(); Town.move("malah"); malah.openMenu(); me.cancel(); delay(500); scroll = me.getItem(646); if (scroll) { clickItem(1, scroll); } return true; }; for (i = 0; i < quests.length; i += 1) { if (me.inTown) { Town.doChores(); } if (!me.getQuest(quests[i][0], 0)) { try { this[quests[i][1]](); } catch (e) { print("Quest failed, moving to next one"); continue; } } } 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 48beaed07..6fa6fb755 100644 --- a/d2bs/kolbot/libs/bots/Summoner.js +++ b/d2bs/kolbot/libs/bots/Summoner.js @@ -21,7 +21,7 @@ function Summoner() { } } - if (!Pather.moveToPreset(me.area, 2, 357)) { + if (!Pather.moveToPreset(me.area, 2, 357, -3, -3)) { throw new Error("Failed to move to Summoner"); } diff --git a/d2bs/kolbot/libs/bots/Test.js b/d2bs/kolbot/libs/bots/Test.js index c85322bfb..315d8f254 100644 --- a/d2bs/kolbot/libs/bots/Test.js +++ b/d2bs/kolbot/libs/bots/Test.js @@ -3,7 +3,7 @@ function Test() { var c; - include("automule.js"); + //include("automule.js"); function KeyDown(key) { if (key === 45) { @@ -25,6 +25,5 @@ function Test() { } function test() { - //print(MuleLogger.getItemDesc(getUnit(101))); - Pather.moveToExit(me.area + 1, true); + Pather.moveToExit(108, true); } \ No newline at end of file diff --git a/d2bs/kolbot/libs/bots/WPGetter.js b/d2bs/kolbot/libs/bots/WPGetter.js new file mode 100644 index 000000000..6b28bc6dc --- /dev/null +++ b/d2bs/kolbot/libs/bots/WPGetter.js @@ -0,0 +1,14 @@ +function WPGetter() { + Town.doChores(); + Town.goToTown(1); + + var i; + + for (i = 0; i < Pather.wpAreas.length; i += 1) { + if (!getWaypoint(i) && Pather.wpAreas[i] !== 123) { + Pather.getWP(Pather.wpAreas[i]); + } + } + + return true; +} \ No newline at end of file diff --git a/d2bs/kolbot/libs/common/Attack.js b/d2bs/kolbot/libs/common/Attack.js index 8d4e598a0..acd21dad3 100644 --- a/d2bs/kolbot/libs/common/Attack.js +++ b/d2bs/kolbot/libs/common/Attack.js @@ -102,18 +102,18 @@ var Attack = { if (dodgeList.length) { dodgeList.sort(Sort.units); - + if (typeof test === "undefined") { test = {x: target.x, y: target.y}; } if (getDistance(me, dodgeList[0]) < 13) { - this.dodge(test, 15, dodgeList); + this.dodge(test, ClassAttack.skillRange[1] || 15, dodgeList); } } } - Misc.townCheck(true); + Misc.townCheck(); if (ClassAttack.doAttack(target, attackCount % 15 === 0) < 2) { break; @@ -126,7 +126,11 @@ var Attack = { attackCount += 1; } - return (target.mode === 0 || target.mode === 12); + if (target.mode !== 0 && target.mode !== 12) { + throw new Error("Failed to kill " + target.name); + } + + return true; }, getScarinessLevel: function (unit) { @@ -429,12 +433,12 @@ var Attack = { }, // Draw lines around a room on minimap - markRoom: function (room, color) { + /*markRoom: function (room, color) { new Line(room.x * 5, room.y * 5, room.x * 5, room.y * 5 + room.ysize, color, true); new Line(room.x * 5, room.y * 5, room.x * 5 + room.xsize, room.y * 5, color, true); new Line(room.x * 5 + room.xsize, room.y * 5, room.x * 5 + room.xsize, room.y * 5 + room.ysize, color, true); new Line(room.x * 5, room.y * 5 + room.ysize, room.x * 5 + room.xsize, room.y * 5 + room.ysize, color, true); - }, + },*/ // Clear an entire area based on monster spectype clearLevel: function (spectype) { @@ -549,7 +553,7 @@ var Attack = { validSpot: function (x, y) { var result; - if (!me.area) { // Just in case + if (!me.area || !x || !y) { // Just in case return false; } @@ -687,22 +691,24 @@ var Attack = { return false; } - if (unit.classid === 543 && me.area === 131) { // Baal in Throne - return false; - } - if (getBaseStat("monstats", unit.classid, "neverCount")) { // neverCount base stat - hydras, traps etc. return false; } switch (unit.classid) { + case 179: // An evil force - cow (lol) + return false; + case 543: // Baal in Throne + if (me.area === 131) { + return false; + } + + break; case 110: // Vultures case 111: case 112: case 113: case 114: - case 179: // An evil force - cow (lol) - return false; case 608: if (unit.mode === 8) { // Flying return false; @@ -1017,4 +1023,4 @@ AuraLoop: // Skip monsters with auras return false; } -}; +}; \ No newline at end of file diff --git a/d2bs/kolbot/libs/common/Attacks/Assassin.js b/d2bs/kolbot/libs/common/Attacks/Assassin.js index cb4599056..670ae380f 100644 --- a/d2bs/kolbot/libs/common/Attacks/Assassin.js +++ b/d2bs/kolbot/libs/common/Attacks/Assassin.js @@ -82,7 +82,7 @@ var ClassAttack = { if (checkTraps) { if (Math.round(getDistance(me, unit)) > 20 || checkCollision(me, unit, 0x4)) { - if (!Attack.getIntoPosition(unit, 20, 0x4) || checkCollision(me, unit, 0x1) && (getCollision(unit.area, unit.x, unit.y) & 0x1)) { + if (!Attack.getIntoPosition(unit, 20, 0x4) || (checkCollision(me, unit, 0x1) && (getCollision(unit.area, unit.x, unit.y) & 0x1))) { return 1; } } @@ -199,7 +199,7 @@ var ClassAttack = { return true; } - if (unit.hasOwnProperty("classid") && [211, 242, 243, 544].indexOf(unit.classid) > -1) { // Duriel, Mephisto, Diablo, Baal + if ((unit.hasOwnProperty("classid") && [211, 242, 243, 544].indexOf(unit.classid) > -1) || (unit.hasOwnProperty("type") && unit.type === 0)) { // Duriel, Mephisto, Diablo, Baal, other players if (traps >= Config.BossTraps.length) { return true; } diff --git a/d2bs/kolbot/libs/common/Attacks/Barbarian.js b/d2bs/kolbot/libs/common/Attacks/Barbarian.js index 909f05ada..7a3479a45 100644 --- a/d2bs/kolbot/libs/common/Attacks/Barbarian.js +++ b/d2bs/kolbot/libs/common/Attacks/Barbarian.js @@ -242,7 +242,7 @@ MainLoop: } if (Config.FindItemSwitch) { - Precast.weaponSwitch(Config.FindItemSwitch - 1); + Precast.weaponSwitch(Config.FindItemSwitch); } CorpseLoop: diff --git a/d2bs/kolbot/libs/common/Attacks/Paladin.js b/d2bs/kolbot/libs/common/Attacks/Paladin.js index 27797de26..59a8e7fb8 100644 --- a/d2bs/kolbot/libs/common/Attacks/Paladin.js +++ b/d2bs/kolbot/libs/common/Attacks/Paladin.js @@ -109,11 +109,17 @@ var ClassAttack = { }, doCast: function (unit, index) { - var i; + var i, + dodgeList = []; if (Config.AttackSkill[index] === 112) { if (unit.classid === 691) { - Attack.getIntoPosition(unit, 15, 0x4); + dodgeList = Attack.buildDodgeList(); + + if (dodgeList.length) { + dodgeList.sort(Sort.units); + Attack.dodge(unit, 15, dodgeList); + } if (Config.AttackSkill[index + 1] > -1) { Skill.setSkill(Config.AttackSkill[index + 1], 0); @@ -126,7 +132,7 @@ var ClassAttack = { if (!this.getHammerPosition(unit)) { print("can't get to " + unit.name); - return 0; + return (unit.spectype & 0x7) ? 2 : 0; // continue attacking a boss monster } /*if (getDistance(me, unit) > 6) { // increase pvp aggressiveness diff --git a/d2bs/kolbot/libs/common/Attacks/Sorceress.js b/d2bs/kolbot/libs/common/Attacks/Sorceress.js index ae4b7e241..74f96c989 100644 --- a/d2bs/kolbot/libs/common/Attacks/Sorceress.js +++ b/d2bs/kolbot/libs/common/Attacks/Sorceress.js @@ -78,20 +78,20 @@ var ClassAttack = { var index, staticRange, timedIndex, untimedIndex; // Static - if (Config.CastStatic < 100 && me.getSkill(42, 1) && Math.round(unit.hp * 100 / unit.hpmax) > Config.CastStatic && Attack.checkResist(unit, "lightning") && Config.StaticList.indexOf(unit.name) > -1) { + if (Config.CastStatic < 100 && me.getSkill(42, 1) && Attack.checkResist(unit, "lightning") && Config.StaticList.indexOf(unit.name) > -1 && Math.round(unit.hp * 100 / unit.hpmax) > Config.CastStatic) { staticRange = Math.floor((me.getSkill(42, 1) + 4) * 2 / 3); - if (getDistance(me, unit) > staticRange || checkCollision(me, unit, 0x4)) { - if (!Attack.getIntoPosition(unit, staticRange, 0x4)) { - return 1; + while (Math.round(unit.hp * 100 / unit.hpmax) > Config.CastStatic) { + if (getDistance(me, unit) > staticRange || checkCollision(me, unit, 0x4)) { + if (!Attack.getIntoPosition(unit, staticRange, 0x4)) { + return 1; + } } - } - if (!Skill.cast(42, 0)) { - return 2; + if (!Skill.cast(42, 0)) { + return 2; + } } - - return 3; } index = ((unit.spectype & 0x7) || unit.type === 0) ? 1 : 3; diff --git a/d2bs/kolbot/libs/common/CollMap.js b/d2bs/kolbot/libs/common/CollMap.js index 8c6fadb93..916822a74 100644 --- a/d2bs/kolbot/libs/common/CollMap.js +++ b/d2bs/kolbot/libs/common/CollMap.js @@ -9,10 +9,11 @@ var CollMap = new function () { this.maps = []; this.addRoom = function (x, y) { + // In case a room is passed directly if (x instanceof Room) { this.rooms.push(x); this.maps.push(x.getCollision()); - + return true; } diff --git a/d2bs/kolbot/libs/common/Config.js b/d2bs/kolbot/libs/common/Config.js index a3c1dc2e1..f0dbabe77 100644 --- a/d2bs/kolbot/libs/common/Config.js +++ b/d2bs/kolbot/libs/common/Config.js @@ -278,4 +278,4 @@ var Config = { Summoner: { FireEye: false } -}; +}; \ No newline at end of file diff --git a/d2bs/kolbot/libs/common/Misc.js b/d2bs/kolbot/libs/common/Misc.js index 4915f03ed..26927cdb5 100644 --- a/d2bs/kolbot/libs/common/Misc.js +++ b/d2bs/kolbot/libs/common/Misc.js @@ -475,33 +475,16 @@ var Misc = { } } - if (Config.OpenChests && Town.needKeys()) - { + if (Config.OpenChests && Town.needKeys()) { check = true; } } if (check) { - Town.goToTown(); - Town.heal(); - Town.buyPotions(); - Town.buyKeys(); - Town.reviveMerc(); - me.cancel(); - Town.move("portalspot"); - - if (!Pather.usePortal(null, me.name)) { - throw new Error("Misc.townCheck: Failed to use portal."); - } - - if (Config.PublicMode) { - Pather.makePortal(); - } - - return true; + scriptBroadcast("townCheck"); } - return false; + return true; } }; diff --git a/d2bs/kolbot/libs/common/Pather.js b/d2bs/kolbot/libs/common/Pather.js index 68b1ae00f..579552635 100644 --- a/d2bs/kolbot/libs/common/Pather.js +++ b/d2bs/kolbot/libs/common/Pather.js @@ -8,9 +8,20 @@ var Pather = { teleport: true, walkDistance: 15, teleDistance: 40, + cancelFlags: [0x01, 0x02, 0x04, 0x08, 0x14, 0x16, 0x0c, 0x0f], 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) { + var i, path, mob, + node = {x: x, y: y}, + fail = 0; + + for (i = 0; i < this.cancelFlags.length; i += 1) { + if (getUIFlag(this.cancelFlags[i])) { + me.cancel(); + } + } + if (getDistance(me, x, y) < 2) { return true; } @@ -23,10 +34,6 @@ var Pather = { throw new Error("moveTo: Coords must be numbers"); } - if (getUIFlag(0x01) || getUIFlag(0x02) || getUIFlag(0x04) || getUIFlag(0x16) || getUIFlag(0x0C) || getUIFlag(0x0F)) { - me.cancel(); - } - if (typeof retry === "undefined") { retry = 3; } @@ -39,10 +46,6 @@ var Pather = { pop = false; } - var path, mob, - node = {x: x, y: y}, - fail = 0; - this.useTeleport = this.teleport && !me.inTown && ((me.getSkill(54, 1) && me.classid === 1) || me.getStat(97, 54)); // Teleport without calling getPath if the spot is close enough @@ -55,6 +58,10 @@ var Pather = { return this.walkTo(x, y); } + if (!me.area) { + throw new Error("moveTo: area error"); + } + path = getPath(me.area, x, y, me.x, me.y, this.useTeleport ? 1 : 0, this.useTeleport ? this.teleDistance : this.walkDistance); if (!path) { @@ -72,8 +79,10 @@ var Pather = { } while (path.length > 0) { - if (getUIFlag(0x01) || getUIFlag(0x02) || getUIFlag(0x04) || getUIFlag(0x16) || getUIFlag(0x0C) || getUIFlag(0x0F)) { - me.cancel(); + for (i = 0; i < this.cancelFlags.length; i += 1) { + if (getUIFlag(this.cancelFlags[i])) { + me.cancel(); + } } node = path.shift(); @@ -125,9 +134,7 @@ var Pather = { } } - if (Misc.townCheck(false)) { - this.useTeleport = this.teleport && !me.inTown && me.getSkill(54, 1); - } + Misc.townCheck(); } } @@ -339,7 +346,7 @@ ModeLoop: // moveToExit can take a single area or an array of areas as the first argument moveToExit: function (targetArea, use, clearPath) { - var i, j, exits, myRoom, targetRoom, + var i, j, area, exits, myRoom, targetRoom, dest, areas = []; if (targetArea instanceof Array) { @@ -349,7 +356,13 @@ ModeLoop: } for (i = 0; i < areas.length; i += 1) { - exits = getArea().exits; + area = getArea(); + + if (typeof area !== "object") { + throw new Error("moveToExit: error in getArea()"); + } + + exits = area.exits; if (!exits || !exits.length) { return false; @@ -357,7 +370,16 @@ ModeLoop: for (j = 0; j < exits.length; j += 1) { if (exits[j].target === areas[i]) { - this.moveToUnit(exits[j], 0, 0, clearPath); + //this.moveToUnit(exits[j], 0, 0, clearPath); + + // tile exit fix, helps with a certain crash too + dest = this.getNearestWalkable(exits[j].x, exits[j].y, 5, 1); + + if (!dest) { + return false; + } + + Pather.moveTo(dest[0], dest[1], 3, clearPath); /* i < areas.length - 1 is for crossing multiple areas. In that case we must use the exit before the last area. @@ -372,24 +394,6 @@ ModeLoop: this.moveTo(targetRoom[0], targetRoom[1]); break; - - /*if (targetRoom[0] > myRoom[0]) { - return this.moveTo(me.x + 10, me.y); - } - - if (targetRoom[0] < myRoom[0]) { - return this.moveTo(me.x - 10, me.y); - } - - if (targetRoom[1] > myRoom[1]) { - return this.moveTo(me.x, me.y + 10); - } - - if (targetRoom[1] < myRoom[1]) { - return this.moveTo(me.x, me.y - 10); - } - - return false;*/ case 2: if (!this.useUnit(5, exits[j].tileid, areas[i])) { return false; @@ -404,6 +408,10 @@ ModeLoop: } } + if (use) { + return typeof targetArea === "object" ? me.area === targetArea[targetArea.length - 1] : me.area === targetArea; + } + return true; }, @@ -456,7 +464,10 @@ ModeLoop: } for (i = 0; i < 3; i += 1) { - this.moveToUnit(unit); + if (getDistance(me, unit) > 5) { + this.moveToUnit(unit); + } + unit.interact(); tick = getTickCount(); @@ -533,7 +544,14 @@ ModeLoop: } if (!getWaypoint(this.wpAreas.indexOf(targetArea))) { - throw new Error("useWaypoint: You don't have the waypoint"); + me.cancel(); + me.overhead("Trying to get the waypoint"); + + if (this.getWP(targetArea)) { + return true; + } + + throw new Error("Pather.useWaypoint: Failed to go to waypoint"); } break; @@ -543,10 +561,6 @@ ModeLoop: } } - if (me.inTown) { - Town.move("waypoint"); - } - if (getUIFlag(0x14) || !check) { wp.interact(targetArea); @@ -576,6 +590,10 @@ ModeLoop: if (i > 2) { // Try to get unstuck Town.move("stash"); } + + if (me.inTown) { + Town.move("waypoint"); + } } throw new Error("Pather.useWaypoint: Failed to use waypoint"); @@ -810,5 +828,203 @@ MainLoop: default: return false; } + }, + + getWP: function (area) { + var i, j, wp, preset, + wpIDs = [119, 145, 156, 157, 237, 238, 288, 323, 324, 398, 402, 429, 494, 496, 511, 539]; + + this.journeyTo(area); + + for (i = 0; i < wpIDs.length; i += 1) { + preset = getPresetUnit(area, 2, wpIDs[i]); + + if (preset) { + this.moveToUnit(preset); + + wp = getUnit(2, "waypoint"); + + if (wp) { + for (j = 0; j < 10; j += 1) { + wp.interact(); + + if (getUIFlag(0x14)) { + me.cancel(); + + return true; + } + + delay(500); + } + } + } + } + + return false; + }, + + // TODO: Hell levels + journeyTo: function (area) { + var i, special, unit, tick, target; + + target = this.plotCourse(area); + + print(target.course); + + /*while (true) { + delay(500); + }*/ + + if (target.useWP) { + Town.goToTown(); + } + + // handle variable flayer jungle entrances + if (target.course.indexOf(78) > -1) { + Town.goToTown(3); // without initiated act, getArea().exits will crash + + special = getArea(78); + + if (special) { + special = special.exits; + + for (i = 0; i < special.length; i += 1) { + if (special[i].target === 77) { + target.course.splice(target.course.indexOf(78), 0, 77); // add great marsh if needed + + break; + } + } + } + } + + while (target.course.length) { + if (!me.inTown) { + Precast.doPrecast(false); + } + + if (me.inTown && this.wpAreas.indexOf(target.course[0]) > -1 && getWaypoint(this.wpAreas.indexOf(target.course[0]))) { + this.useWaypoint(target.course[0], true); + } else if (me.area === 109 && target.course[0] === 110) { // Harrogath -> Bloody Foothills + this.moveTo(5026, 5095); + + unit = getUnit(2, 449); // Gate + + if (unit) { + for (i = 0; i < 3; i += 1) { + unit.interact(); + + tick = getTickCount(); + + while (getTickCount() - tick < 3000) { + if (unit.mode === 2) { + delay(1000); + + break; + } + } + } + } + + this.moveToExit(target.course[0], true); + } else if (me.area === 4 && target.course[0] === 38) { // Stony Field -> Tristram + this.moveToPreset(me.area, 1, 737, 0, 0, false, true); + + for (i = 0; i < 5; i += 1) { + if (this.usePortal(38)) { + break; + } + + delay(1000); + } + } else if (me.area === 74 && target.course[0] === 46) { // Arcane Sanctuary -> Canyon of the Magi + this.moveToPreset(me.area, 2, 357); + + for (i = 0; i < 5; i += 1) { + unit = getUnit(2, 357); + + unit.interact(); + delay(1000); + me.cancel(); + + if (this.usePortal(46)) { + break; + } + } + } else if (me.area === 54 && target.course[0] === 74) { // Palace -> Arcane + this.moveTo(10073, 8670); + this.usePortal(null); + } else if (me.area === 109 && target.course[0] === 121) { // Harrogath -> Nihlathak's Temple + Town.move("anya"); + this.usePortal(121); + } else { + this.moveToExit(target.course[0], true); + } + + target.course.shift(); + } + }, + + plotCourse: function (dest, src) { + var node, prevArea, + useWP = false, + arr = [], + previousAreas = [0, 0, 1, 2, 3, 10, 5, 6, 2, 3, 4, 6, 7, 9, 10, 11, 12, 3, 17, 17, 6, 20, 21, 22, 23, 24, 7, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 4, 1, 1, 40, 41, 42, 43, 44, 74, 40, 47, 48, 40, 50, 51, 52, 53, 41, 42, 56, 45, 55, 57, 58, 43, 62, 63, 44, 46, 46, 46, 46, 46, 46, 46, 1, 54, 1, 75, 76, 76, 78, 79, 80, 81, 82, 76, 76, 78, 86, 78, 88, 87, 89, 80, 92, 80, 80, 81, 81, 82, 82, 83, 100, 101, 102, 103, 104, 105, 106, 107, 103, 109, 110, 111, 112, 113, 113, 115, 115, 117, 118, 118, 109, 121, 122, 123, 111, 112, 117, 120, 128, 129, 130, 131, 109, 109, 109, 109], + visitedNodes = [], + toVisitNodes = [{from: dest, to: null}]; + + if (!src) { + src = me.area; + } + + while (toVisitNodes.length > 0) { + node = toVisitNodes[0]; + + // If we've already visited it, just move on + if (visitedNodes[node.from] === undefined) { + visitedNodes[node.from] = node.to; + + // If we have this wp we can start from there + if (Pather.wpAreas.indexOf(node.from) > 0 && getWaypoint(Pather.wpAreas.indexOf(node.from))) { + if (node.from !== src) { + useWP = true; + } + src = node.from; + } + + // We found it, time to go + if (node.from === src) { + break; + } + + if ((prevArea = previousAreas[node.from]) !== 0 && visitedNodes.indexOf(prevArea) === -1) { + toVisitNodes.push({from: prevArea, to: node.from}); + } + + for (prevArea = 1; prevArea < previousAreas.length; prevArea += 1) { + // Only interested in those connected to node + if (previousAreas[prevArea] === node.from && visitedNodes.indexOf(prevArea) === -1) { + toVisitNodes.push({from: prevArea, to: node.from}); + } + } + } + + toVisitNodes.shift(); + } + + arr.push(src); + + node = src; + + while (node !== dest && node !== undefined) { + arr.push(node = visitedNodes[node]); + } + + // Something failed + if (node === undefined) { + return false; + } + + return {course: arr, useWP: useWP}; } -}; +}; \ No newline at end of file diff --git a/d2bs/kolbot/libs/common/Pickit.js b/d2bs/kolbot/libs/common/Pickit.js index 3123f18b7..93c4a1a52 100644 --- a/d2bs/kolbot/libs/common/Pickit.js +++ b/d2bs/kolbot/libs/common/Pickit.js @@ -22,12 +22,12 @@ var Pickit = { }, // Returns: - // -1 - Needs iding - // 0 - Unwanted - // 1 - NTIP wants - // 2 - Cubing wants - // 3 - Runeword wants - // 4 - Pickup to sell (triggered when low on gold) + // -1 - Needs iding + // 0 - Unwanted + // 1 - NTIP wants + // 2 - Cubing wants + // 3 - Runeword wants + // 4 - Pickup to sell (triggered when low on gold) checkItem: function (unit) { var result = NTIPCheckItem(unit, false, true); @@ -41,14 +41,15 @@ var Pickit = { // If total gold is less than 10k pick up anything worth 10 gold per // square to sell in town. - if (me.getStat(14) + me.getStat(15) < Config.LowGold && result == 0) - { + if (me.getStat(14) + me.getStat(15) < Config.LowGold && result === 0) { // Gold doesn't take up room, just pick it up - if (unit.name == "Gold") + if (unit.name === "Gold") { return {result: 4, line: null}; + } - if (unit.getItemCost(1) / (unit.sizex * unit.sizey) >= 10) + if (unit.getItemCost(1) / (unit.sizex * unit.sizey) >= 10) { return {result: 4, line: null}; + } } return result; @@ -395,4 +396,4 @@ MainLoop: return true; } -}; +}; \ No newline at end of file diff --git a/d2bs/kolbot/libs/common/Town.js b/d2bs/kolbot/libs/common/Town.js index ce833a0ae..49120f1f2 100644 --- a/d2bs/kolbot/libs/common/Town.js +++ b/d2bs/kolbot/libs/common/Town.js @@ -344,11 +344,13 @@ MainLoop: item = list.shift(); result = Pickit.checkItem(item); - if (item.location != 3) + if (item.location != 3) { continue; + } - if (this.ignoredItemTypes.indexOf(item.itemType) !== -1) + if (this.ignoredItemTypes.indexOf(item.itemType) !== -1) { continue; + } switch (result.result) { case 1: @@ -1212,15 +1214,12 @@ MainLoop: }, clearInventory: function () { - var i, items, + var i, items, loseItemAction + dropAction = 0, + sellAction = 1, clearList = [], item = me.getItem(-1, 0); - var dropAction = 0; - var sellAction = 1; - - var loseItemAction; - // Potions (after death usually) if (item) { do { @@ -1368,6 +1367,7 @@ MainLoop: this.act[4].spot.waypoint = [5113, 5068]; this.act[4].spot.nihlathak = [5071, 5111]; this.act[4].initialized = true; + break; } diff --git a/d2bs/kolbot/pickit/LLD.nip b/d2bs/kolbot/pickit/LLD.nip index be2829a4f..8553ae171 100644 --- a/d2bs/kolbot/pickit/LLD.nip +++ b/d2bs/kolbot/pickit/LLD.nip @@ -224,7 +224,7 @@ [name] == meshboots && [quality] == set # [plusdefense] == 125 && [coldresist] == 25 && [lightresist] == 25 // Natalya's Soul, perfect [name] == boots && [quality] == unique && [flag] != ethereal # [enhanceddefense] == 20 // Hotspur -[name] == lightplatedboots && [quality] == unique && [flag] != ethereal # [enhanceddefense] == 60 // Goblin Toe +//[name] == lightplatedboots && [quality] == unique && [flag] != ethereal # [enhanceddefense] == 60 // Goblin Toe //[name] == greaves && [quality] == unique && [flag] != ethereal # [enhanceddefense] == 80 // Tearhaunch //================================================================================================================================================================================= diff --git a/d2bs/kolbot/pickit/test.nip b/d2bs/kolbot/pickit/test.nip index f9a35a953..8e8fde36c 100644 --- a/d2bs/kolbot/pickit/test.nip +++ b/d2bs/kolbot/pickit/test.nip @@ -3,4 +3,5 @@ [quality] == rare && [color] == white //[color] == Crystal Blue //[name] == greatertalons # [assassinskills] == 2 -[type] == 74 # # [maxquantity] == 10 \ No newline at end of file +[type] == 74 # # [maxquantity] == 10 +[name] == helrune \ No newline at end of file diff --git a/d2bs/kolbot/tools/AntiHostile.js b/d2bs/kolbot/tools/AntiHostile.js index 7810c3c87..5d1a68314 100644 --- a/d2bs/kolbot/tools/AntiHostile.js +++ b/d2bs/kolbot/tools/AntiHostile.js @@ -4,8 +4,6 @@ * @desc handle hostile threats */ -// TODO: more classes for entrance guard, timeout/leave event for hostiles array - js_strict(true); include("json2.js"); @@ -28,7 +26,7 @@ include("common/Town.js"); function main() { // Variables and functions - var player, findTrigger, attackCount, mugShot, prevPos, + var player, findTrigger, attackCount, prevPos, check, charClass = ["Amazon", "Sorceress", "Necromancer", "Paladin", "Barbarian", "Druid", "Assassin"], hostiles = []; @@ -46,8 +44,9 @@ function main() { case 0x06: // "%Name1 was Slain by %Name2" if (param2 === 0x00 && name2 === me.name) { D2Bot.printToConsole(name1 + " has been neutralized.;4"); - - mugShot = true; + hideConsole(); + delay(500); + takeScreenshot(); } break; @@ -176,27 +175,59 @@ function main() { findTrigger = false; } - if (Config.HostileAction === 3 && hostiles.length > 0 && me.area === 131 && me.classid === 1) { // Spam entrance test - prevPos = {x: me.x, y: me.y}; - - this.pause(); - Pather.moveTo(15103, 5247); + if (Config.HostileAction === 3 && hostiles.length > 0 && me.area === 131) { // Spam entrance test + switch (me.classid) { + case 1: // Sorceress + prevPos = {x: me.x, y: me.y}; + this.pause(); + Pather.moveTo(15103, 5247); - while (!this.findPlayer() && hostiles.length > 0) { - if (!me.getState(121)) { - Skill.cast(Config.AttackSkill[1], ClassAttack.skillHand[1], 15099, 5237); - } else { - if (Config.AttackSkill[2] > -1) { - Skill.cast(Config.AttackSkill[2], ClassAttack.skillHand[2], 15099, 5237); + while (!this.findPlayer() && hostiles.length > 0) { + if (!me.getState(121)) { + Skill.cast(Config.AttackSkill[1], ClassAttack.skillHand[1], 15099, 5237); } else { - while (me.getState(121)) { - delay(40); + if (Config.AttackSkill[2] > -1) { + Skill.cast(Config.AttackSkill[2], ClassAttack.skillHand[2], 15099, 5237); + } else { + while (me.getState(121)) { + delay(40); + } } } } + + break; + case 6: // Assassin + prevPos = {x: me.x, y: me.y}; + this.pause(); + Pather.moveTo(15103, 5247); + + while (!this.findPlayer() && hostiles.length > 0) { + if (Config.UseTraps) { + check = ClassAttack.checkTraps({x: 15099, y: 5242, classid: 544}); + + if (check) { + ClassAttack.placeTraps({x: 15099, y: 5242, classid: 544}, 5); + } + } + + Skill.cast(Config.AttackSkill[1], ClassAttack.skillHand[1], 15099, 5237); + + while (me.getState(121)) { + delay(40); + } + } + + break; } } + if (!hostiles.length && prevPos) { + Pather.moveTo(prevPos.x, prevPos.y); + this.resume(); + prevPos = false; + } + player = this.findPlayer(); if (player) { @@ -247,14 +278,6 @@ function main() { this.stopFlash(); } - if (mugShot) { - hideConsole(); - delay(500); - takeScreenshot(); - - mugShot = false; - } - delay(200); } } \ No newline at end of file diff --git a/d2bs/kolbot/tools/ToolsThread.js b/d2bs/kolbot/tools/ToolsThread.js index fcb3469c4..cde1a9a24 100644 --- a/d2bs/kolbot/tools/ToolsThread.js +++ b/d2bs/kolbot/tools/ToolsThread.js @@ -5,7 +5,7 @@ */ function main() { - var i, mercHP, ironGolem, + var i, mercHP, ironGolem, area, quitFlag = false, timerLastDrink = []; @@ -65,6 +65,27 @@ function main() { } }; + // for global quit + this.quitPrep = function () { + var i, + pauseScripts = ["tools/townchicken.js", "tools/antihostile.js"], + script = getScript("default.dbj"); + + if (script && !script.running) { + script.resume(); + } + + for (i = 0; i < pauseScripts.length; i += 1) { + script = getScript(pauseScripts[i]); + + if (script && script.running) { + script.pause(); + } + } + + return true; + }; + this.drinkPotion = function (type) { var pottype, potion, tNow = getTickCount(); @@ -100,12 +121,15 @@ function main() { case 0: case 3: pottype = 76; + break; case 1: pottype = 77; + break; default: pottype = 78; + break; } @@ -208,7 +232,13 @@ function main() { break; case 123: // F12 key - me.overhead("Revealing " + getArea().name); + area = getArea(); + + if (typeof area !== "object") { + break; + } + + me.overhead("Revealing " + area.name); this.revealArea(me.area); break; @@ -224,7 +254,8 @@ function main() { case 3: if (Config.QuitList.indexOf(name1) > -1) { print(name1 + (mode === 0 ? " timed out" : " left")); - scriptBroadcast("quit"); + + quitFlag = true; } break; @@ -244,8 +275,14 @@ function main() { } if (Config.LifeChicken > 0 && me.hp <= Math.floor(me.hpmax * Config.LifeChicken / 100)) { + area = getArea(); + + if (typeof area !== "object") { + area = {name: "unknown"}; + } + D2Bot.updateChickens(); - D2Bot.printToConsole("Life Chicken: " + me.hp + "/" + me.hpmax + " in " + getArea().name + this.getNearestMonster() + ";9"); + D2Bot.printToConsole("Life Chicken: " + me.hp + "/" + me.hpmax + " in " + area.name + this.getNearestMonster() + ";9"); me.chickenhp = me.hpmax; // Just to trigger the core chicken @@ -261,8 +298,14 @@ function main() { } if (Config.ManaChicken > 0 && me.mp <= Math.floor(me.mpmax * Config.ManaChicken / 100)) { + area = getArea(); + + if (typeof area !== "object") { + area = {name: "unknown"}; + } + D2Bot.updateChickens(); - D2Bot.printToConsole("Mana Chicken: " + me.mp + "/" + me.mpmax + " in " + getArea().name + ";9"); + D2Bot.printToConsole("Mana Chicken: " + me.mp + "/" + me.mpmax + " in " + area.name + ";9"); me.chickenmp = me.mpmax; // Just to trigger the core chicken @@ -276,8 +319,14 @@ function main() { if (ironGolem) { if (ironGolem.hp <= Math.floor(128 * Config.IronGolemChicken / 100)) { // ironGolem.hpmax is bugged with BO + area = getArea(); + + if (typeof area !== "object") { + area = {name: "unknown"}; + } + D2Bot.updateChickens(); - D2Bot.printToConsole("Irom Golem Chicken in " + getArea().name + ";9"); + D2Bot.printToConsole("Irom Golem Chicken in " + area.name + ";9"); quit(); break; @@ -290,7 +339,13 @@ function main() { if (mercHP > 0) { if (mercHP < Config.MercChicken) { - D2Bot.printToConsole("Merc Golem Chicken in " + getArea().name + ";9"); + area = getArea(); + + if (typeof area !== "object") { + area = {name: "unknown"}; + } + + D2Bot.printToConsole("Merc Chicken in " + area.name + ";9"); quit(); break; @@ -309,7 +364,9 @@ function main() { } if (quitFlag) { - quit(); + this.quitPrep(); + // do we need a delay? + scriptBroadcast("quit"); break; } diff --git a/d2bs/kolbot/tools/TownChicken.js b/d2bs/kolbot/tools/TownChicken.js index e6d89796e..613f33613 100644 --- a/d2bs/kolbot/tools/TownChicken.js +++ b/d2bs/kolbot/tools/TownChicken.js @@ -25,6 +25,8 @@ include("common/Storage.js"); include("common/Town.js"); function main() { + var townCheck = false; + this.togglePause = function () { var script = getScript("default.dbj"); @@ -39,26 +41,33 @@ function main() { } }; + addEventListener("scriptmsg", + function (msg) { + if (msg === "townCheck") { + townCheck = true; + } + } + ); + // Init config and attacks Config.init(); Attack.init(); Storage.Init(); while (true) { - if (!me.inTown && ((Config.TownHP > 0 && me.hp < Math.floor(me.hpmax * Config.TownHP / 100)) || (Config.TownMP > 0 && me.hp < Math.floor(me.hpmax * Config.TownMP / 100)))) { + if (!me.inTown && (townCheck || + (Config.TownHP > 0 && me.hp < Math.floor(me.hpmax * Config.TownHP / 100)) || + (Config.TownMP > 0 && me.hp < Math.floor(me.hpmax * Config.TownMP / 100)))) { this.togglePause(); - + try { - me.overhead("Town chicken"); + me.overhead("Going to town"); Town.goToTown(); - Town.heal(); - Town.buyPotions(); - Town.reviveMerc(); - me.cancel(); + Town.doChores(); Town.move("portalspot"); if (!Pather.usePortal(null, me.name)) { - throw new Error("Misc.townCheck: Failed to use portal."); + throw new Error("TownChicken: Failed to use portal."); } if (Config.PublicMode) { @@ -66,6 +75,8 @@ function main() { } } finally { this.togglePause(); + + townCheck = false; } }