diff --git a/d2bs/kolbot/D2BotMule.dbj b/d2bs/kolbot/D2BotMule.dbj index f62e8574d..284d89ac7 100644 --- a/d2bs/kolbot/D2BotMule.dbj +++ b/d2bs/kolbot/D2BotMule.dbj @@ -1,4 +1,6 @@ var StarterConfig = { + MinGameTime: 30, // Minimum game length in seconds. + 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 @@ -60,12 +62,13 @@ var MuleData = { // stash picked items function stashItems() { var i, - items = me.getItems(); + items = me.findItems(-1, 0, 3); + + // stash large items first by sorting items by size in descending order + items.sort(function(a, b) {return (b.sizex * b.sizey - a.sizex * a.sizey);}); for (i = 0; i < items.length; i += 1) { - if (items[i].mode === 0 && items[i].location === 3) { - Storage.Stash.MoveTo(items[i]); - } + Storage.Stash.MoveTo(items[i]); } return true; @@ -129,6 +132,19 @@ function pickItems() { break; } + // pick large items first by sorting items by size in descending order and move gheed's charm to the end of the list + list.sort(function(a, b) { + if (a.classid === 605 && a.quality === 7 && !Pickit.canPick(a)) { + return 1; + } + + if (b.classid === 605 && b.quality === 7 && !Pickit.canPick(b)) { + return -1; + } + + return (b.sizex * b.sizey - a.sizex * a.sizey); + }); + while (list.length > 0) { item = list.shift(); canFit = Storage.Inventory.CanFit(item); @@ -147,6 +163,12 @@ function pickItems() { rval = "next"; } + // Gheed's Fortune handling + if (item.classid === 605 && item.quality === 7 && !Pickit.canPick(item)) { + D2Bot.printToConsole("Mule already has Gheed's.", 7); + rval = "next"; + } + if (!canFit) { stashItems(); @@ -454,7 +476,11 @@ function main() { D2Bot.updateStatus("In " + (muleMode === 2 ? "anni" : muleMode === 1 ? "torch" : "") + " mule game."); D2Bot.printToConsole("In " + (muleMode === 2 ? "anni" : muleMode === 1 ? "torch" : "") + " mule game.", 7); - delay(500); + tick = getTickCount(); + + while (!me.area && getTickCount() - tick < 2000) { + delay(200); + } Town.goToTown(1); Town.move("stash"); @@ -516,6 +542,14 @@ function main() { MuleData.write(obj); nextChar(); D2Bot.printToConsole("Mule full, getting next character.", 7); + + if (StarterConfig.MinGameTime && getTickCount() - tick < StarterConfig.MinGameTime * 1000) { + while (getTickCount() - tick < StarterConfig.MinGameTime * 1000) { + me.overhead("Stalling for " + Math.round(((tick + (StarterConfig.MinGameTime * 1000)) - getTickCount()) / 1000) + " Seconds"); + delay(1000); + } + } + quit(); // TODO: see whether a for loop is better diff --git a/d2bs/kolbot/libs/OOG.js b/d2bs/kolbot/libs/OOG.js index d0789570a..69e264d7e 100644 --- a/d2bs/kolbot/libs/OOG.js +++ b/d2bs/kolbot/libs/OOG.js @@ -935,6 +935,8 @@ MainLoop: me.blockMouse = false; } + } else { // no further check necessary + break; } } @@ -981,6 +983,8 @@ MainLoop: me.blockMouse = false; } + } else { // no further check necessary + break; } } @@ -1012,12 +1016,16 @@ MainLoop: return position; }, - loginCharacter: function (info) { + loginCharacter: function (info, startFromTop = true) { me.blockMouse = true; var control, text, count = 0; + if (startFromTop) { // start from beginning of the char list + sendKey(0x24); + } + MainLoop: while (getLocation() !== 1) { // cycle until in lobby switch (getLocation()) { @@ -1034,8 +1042,9 @@ MainLoop: if (text[1].toLowerCase() === info.charName.toLowerCase()) { control.click(); this.click(6, 627, 572, 128, 35); + me.blockMouse = false; - break MainLoop; + return true; } } } while (control.getNext()); @@ -1051,6 +1060,8 @@ MainLoop: sendKey(0x28); sendKey(0x28); } + } else { // no further check necessary + break MainLoop; } break; @@ -1060,9 +1071,7 @@ MainLoop: break; case 14: // disconnected? case 30: // player not found? - me.blockMouse = false; - - return false; + break MainLoop; default: break; } @@ -1072,7 +1081,7 @@ MainLoop: me.blockMouse = false; - return true; + return false; }, makeCharacter: function (info) { diff --git a/d2bs/kolbot/libs/common/Attack.js b/d2bs/kolbot/libs/common/Attack.js index 26f25e0db..7ab04a268 100644 --- a/d2bs/kolbot/libs/common/Attack.js +++ b/d2bs/kolbot/libs/common/Attack.js @@ -140,6 +140,7 @@ var Attack = { } var i, target, gid, + retry = 0, errorInfo = "", attackCount = 0; @@ -188,9 +189,15 @@ var Attack = { } if (!ClassAttack.doAttack(target, attackCount % 15 === 0)) { - errorInfo = " (doAttack failed)"; + if (retry++ > 3) { + errorInfo = " (doAttack failed)"; - break; + break; + } + + Packet.flash(me.gid); + } else { + retry = 0; } attackCount += 1; @@ -219,6 +226,7 @@ var Attack = { hurt: function (classId, percent) { var i, target, + retry = 0, attackCount = 0; for (i = 0; i < 5; i += 1) { @@ -233,7 +241,13 @@ var Attack = { while (attackCount < 300 && Attack.checkMonster(target) && Attack.skipCheck(target)) { if (!ClassAttack.doAttack(target, attackCount % 15 === 0)) { - break; + if (retry++ > 3) { + break; + } + + Packet.flash(me.gid); + } else { + retry = 0; } if (!copyUnit(target).x) { @@ -317,6 +331,7 @@ var Attack = { } var i, boss, orgx, orgy, target, result, monsterList, start, coord, + retry = 0, gidAttack = [], attackCount = 0; @@ -389,6 +404,8 @@ var Attack = { result = ClassAttack.doAttack(target, attackCount % 15 === 0); if (result) { + retry = 0; + for (i = 0; i < gidAttack.length; i += 1) { if (gidAttack[i].gid === target.gid) { break; @@ -434,7 +451,12 @@ var Attack = { Pickit.fastPick(); } } else { - monsterList.shift(); + if (retry++ > 3) { + monsterList.shift(); + retry = 0; + } + + Packet.flash(me.gid); } } else { monsterList.shift(); @@ -502,6 +524,7 @@ var Attack = { // Clear an already formed array of monstas clearList: function (mainArg, sortFunc, refresh) { var i, target, result, monsterList, coord, + retry = 0, gidAttack = [], attackCount = 0; @@ -548,6 +571,8 @@ var Attack = { result = ClassAttack.doAttack(target, attackCount % 15 === 0); if (result) { + retry = 0; + for (i = 0; i < gidAttack.length; i += 1) { if (gidAttack[i].gid === target.gid) { break; @@ -591,7 +616,12 @@ var Attack = { Pickit.fastPick(); } } else { - monsterList.shift(); + if (retry++ > 3) { + monsterList.shift(); + retry = 0; + } + + Packet.flash(me.gid); } } else { monsterList.shift(); @@ -777,7 +807,7 @@ var Attack = { } rooms.sort(RoomSort); - room = rooms.shift(); + room = rooms.shift(); result = Pather.getNearestWalkable(room[0], room[1], 18, 3); @@ -1497,4 +1527,4 @@ AuraLoop: // Skip monsters with auras return false; } -}; +}; \ No newline at end of file