Skip to content

Commit

Permalink
D2BotChannel.dbj/D2BotFollow.dbj/D2BotLead.dbj/D2BotMuleLog.dbj - add…
Browse files Browse the repository at this point in the history
…ed click cancel on waiting in line timeout

D2BotMule.dbj - added handling for the rest of out of game locations
MuleLogger.js - error handling + wait for me.gameReady
NTItemParser.dbl - added/fixed some item colors
OOG.js - don't call getArea().name directly
BaalHelper.js - move to the center of throne before scanning for baal's portal (antihostile can break the run without this)
Questing.js - added some ptints and town chores
Summoner.js - added offset to preset unit move
Attack.js - fixed attack for vultures, attack.kill throws error if it fails to kill the boss
Barbarian.js - fixed find item switch
Paladin.js - use the faster dodge function on dolls (instead of getIntoPosition)
Sorceress.js - static fix
Misc.js - town check now sends messages with TownChicken.js
Pather.js - fixed exit taking for some areas (harem/cellar etc), added journeyTo stuff, grab wp if the character doesn't have it
AntiHostile.js - some more tweaks, added assassin entrance camping
ToolsThread.js - global quit fixes, don't call getArea().name directly
TownChicken.js - added potion check

added WPGetter.js for testing purposes (add Scripts.WPGetter)
  • Loading branch information
kolton committed Aug 10, 2012
1 parent 599b407 commit e1cf66f
Show file tree
Hide file tree
Showing 30 changed files with 713 additions and 207 deletions.
1 change: 1 addition & 0 deletions d2bs/kolbot/D2BotChannel.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions d2bs/kolbot/D2BotFollow.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 3 additions & 0 deletions d2bs/kolbot/D2BotLead.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -493,6 +494,7 @@ MainSwitch:
D2Bot.updateStatus("Disconnected");
delay(500);
ControlAction.click(6, 351, 337, 96, 32);

break;
case 15: // New Character
break;
Expand All @@ -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));
Expand Down
179 changes: 164 additions & 15 deletions d2bs/kolbot/D2BotMule.dbj
Original file line number Diff line number Diff line change
@@ -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";

Expand Down Expand Up @@ -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") {
Expand All @@ -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);
Expand All @@ -96,8 +106,9 @@ function pickItems() {
}
}

if (rval == "next")
if (rval === "next") {
break;
}
} else {
sendCopyData(null, muler, 0, "report");
//D2Bot.shoutGlobal("report", 0);
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -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) {
Expand All @@ -256,6 +290,7 @@ function main() {
if (status === "loading") {
status = "ready";

D2Bot.updateStatus("In mule game.");
D2Bot.printToConsole("In mule game.");
Storage.Init();
}
Expand All @@ -264,8 +299,7 @@ function main() {
delay(500);
}

if (!muler)
{
if (!muler) {
D2Bot.printToConsole("Failed to contact mulee.");
D2Bot.stop();
}
Expand Down Expand Up @@ -305,11 +339,10 @@ function main() {

locationAction(getLocation());
delay(1000);
}
catch (e) {
} catch (e2) {
print("Caught an exception in the main loop.");
print(e);

This comment has been minimized.

Copy link
@DetectiveSquirrel

DetectiveSquirrel Aug 12, 2012

Contributor

print(e);

needs to be

print(e2);

it gives off error when starting d2botmule

D2Bot.printToConsole("Exception: "+e);
D2Bot.printToConsole("Exception: " + e);
}
}
}
Expand All @@ -319,6 +352,8 @@ function locationAction(location) {

MainSwitch:
switch (location) {
case 0:
break;
case 1:
case 3:
if (makeNext) {
Expand All @@ -343,13 +378,23 @@ 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");
delay(2000);
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
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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);
Expand All @@ -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
}
}
}
1 change: 1 addition & 0 deletions d2bs/kolbot/D2BotMuleLog.dbj
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion d2bs/kolbot/libs/AutoMule.js
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
10 changes: 9 additions & 1 deletion d2bs/kolbot/libs/MuleLogger.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -73,6 +73,10 @@ var MuleLogger = {
},

logChar: function () {
while (!me.gameReady) {
delay(500);
}

var i, folder,
items = me.getItems(),
color = -1,
Expand All @@ -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();
Expand Down
Loading

0 comments on commit e1cf66f

Please sign in to comment.