Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
dec 09
D2BotChannel.dbj - better join fail handling, restart if stuck on connecting if rdblocker is on, fix for exiting char select screen on slow connections
D2BotFollow.dbj - added join game delay per profile, join retry delay will now stop if leader's game has ended, fix for exiting char select screen on slow connections
D2BotLead.dbj - added ping quit delay before making next game, fix for exiting char select screen on slow connections
AutoMule.js - fixed an error that would trigger in single player
DiabloHelper.js - wait until player areas can be read before trying to take a portal
OrgTorch.js - torch mule trigger fix
Travincal.js - optimization for walking barbs with leap attack
Barbarian.js - changed whirlwind code
Pather.js - changed me.move to a new function Pather.clickMove, paladin charge fix
Pickit.js - rewrote item pickup code
Storage.js - fixed room check for invalidated item units
Town.js - moved cain id to Town.initNPC function
ToolsThread.js - added ping quit

added Config.PingQuit to character config files
usage: Config.PingQuit = [{Ping: ping_limit, Duration: number_of_seconds}];
it supports multiple rules, for example: Config.PingQuit = [{Ping: 500, Duration: 10}, {Ping: 1000, Duration: 0}]
  • Loading branch information
kolton committed Dec 9, 2012
1 parent dce15b7 commit 1687439
Show file tree
Hide file tree
Showing 24 changed files with 328 additions and 128 deletions.
41 changes: 30 additions & 11 deletions d2bs/kolbot/D2BotChannel.dbj
Expand Up @@ -294,10 +294,27 @@ MainSwitch:
fListTick = getTickCount();
}

if (lastGameStatus === "pending") {
switch (lastGameStatus) {
case "pending": // Most likely FTJ (can't detect it directly)
retry += 1;

//print("game joining failed " + retry);
D2Bot.updateRuns();

if (retry < 3) {
ControlAction.click(6, 652, 469, 120, 20);

break MainSwitch;
}

break;
case "DNE": // Game didn't exist
retry += 1;

break;
case "FULL": // Game is full
retry = 3;

break;
}

if (retry >= 3) {
Expand Down Expand Up @@ -346,7 +363,7 @@ MainLoop:
D2Bot.updateStatus("Join Game");

if (gameName !== "") {
if (retry === 0) { // Only delay on first join - the rest is handled by GameDoesNotExistTimeout. Any other case is instant fail (ie. full game).
if (retry === 0 || lastGameStatus === "pending") { // Only delay on first join - the rest is handled by GameDoesNotExistTimeout. Any other case is instant fail (ie. full game).
if (typeof AdvancedConfig[me.profile] === "object" && typeof AdvancedConfig[me.profile].JoinDelay === "number") {
timeoutDelay("Custom Join Delay", AdvancedConfig[me.profile].JoinDelay * 1e3);
} else if (StarterConfig.JoinDelay) {
Expand All @@ -370,7 +387,7 @@ MainLoop:
case 9: // Login
case 12: // Character Select
case 18: // D2 Splash
if (firstLogin) { // multiple realm botting fix in case of R/D or disconnect
if (firstLogin && getLocation() === 9) { // multiple realm botting fix in case of R/D or disconnect
ControlAction.click(6, 33, 572, 128, 35);
}

Expand Down Expand Up @@ -570,10 +587,16 @@ MainLoop:

break;
case 23: // Character Select - Connecting
case 42: // Empty character screen
if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
//print("QQQ");
ControlAction.click(6, 33, 572, 128, 35);
}

if (rdblocker) {
D2Bot.restart();
}

break;
case 24: // Server Down - not much to do but wait..
break;
Expand All @@ -595,19 +618,15 @@ MainLoop:
ControlAction.click(6, 433, 433, 96, 32);
timeoutDelay("Game doesn't exist", StarterConfig.GameDoesNotExistTimeout * 1e3);

lastGameStatus = "DNE";

break;
case 38: // Game is full
//D2Bot.printToConsole("Game is full");

retry = 2; // force fail - becaomes 3 at next cycle and aborts join

ControlAction.click(6, 652, 469, 120, 20);
ControlAction.click(6, 433, 433, 96, 32);

break;
case 42: // Empty character screen
delay(1000);
ControlAction.click(6, 33, 572, 128, 35);
lastGameStatus = "FULL";

break;
default:
Expand Down
66 changes: 52 additions & 14 deletions d2bs/kolbot/D2BotFollow.dbj
Expand Up @@ -3,7 +3,7 @@ var StarterConfig = {
FirstJoinMessage: "", // Message to say when first joining a channel, usually ".login"
ChatActionsDelay: 2, // Seconds to wait in lobby before entering a channel

RejoinDelay: 10, // Time in seconds to wait before next join attempt
JoinRetryDelay: 15, // Time in seconds to wait before next join attempt
SwitchKeyDelay: 0, // Seconds to wait before switching a used/banned key or after realm down

CrashDelay: 0, // Seconds to wait after a d2 window crash
Expand Down Expand Up @@ -32,6 +32,22 @@ var JoinSettings = {
"Leader": ["Leecher"]
};

// Advanced config - you don't have to edit this unless you need some of the features provided
var AdvancedConfig = {
/* Features: Override join delay for each profile

* Format *:
"Profile Name": {JoinDelay: number_of_seconds}

* Example * (don't edit this - it's just an example):
"MyProfile1": {JoinDelay: 3},
"MyProfile2": {JoinDelay: 6}
*/

// Put your lines under this one. Multiple entries are separated by commas. No comma after the last one.

};



// No touchy!
Expand All @@ -56,10 +72,16 @@ if (!FileTools.exists("data/" + me.profile + ".json")) {
DataFile.create();
}

function timeoutDelay(text, time) {
function timeoutDelay(text, time, stopfunc) {
var endTime = getTickCount() + time;

while (getTickCount() < endTime) {
if (typeof stopfunc === "function" && stopfunc.call()) {
D2Bot.printToConsole("Game is finished. Stopping join delay.");

break;
}

D2Bot.updateStatus(text + " (" + Math.floor((endTime - getTickCount()) / 1000) + "s)");
delay(500);
}
Expand Down Expand Up @@ -373,16 +395,35 @@ JoinLoop:
ControlAction.setText(1, 606, 148, 155, 20, gamePass);
ControlAction.setText(1, 432, 148, 155, 20, nextGame);

if (isUp !== "yes") {
break;
if (lastGameStatus === "pending") {
timeoutDelay("Join Delay", StarterConfig.JoinRetryDelay * 1000,
function () {
D2Bot.requestGame(leader);
delay(500);

return isUp === "no" || nextGame !== gameName;
}
);
D2Bot.updateRuns();
D2Bot.requestGame(leader);
delay(200);

if (isUp !== "yes") {
lastGameStatus = "ready";

break;
}
}

if (lastGameStatus === "pending") {
timeoutDelay("Join Delay", StarterConfig.RejoinDelay * 1000);
if (isUp !== "yes") {
break;
}

print("joining game " + nextGame);
delay(rand(1, 1000));

if (typeof AdvancedConfig[me.profile] === "object" && typeof AdvancedConfig[me.profile].JoinDelay === "number") {
timeoutDelay("Custom Join Delay", AdvancedConfig[me.profile].JoinDelay * 1e3);
}

me.blockMouse = true;

Expand All @@ -405,7 +446,7 @@ JoinLoop:
case 9: // Login
case 12: // Character Select
case 18: // D2 Splash
if (firstLogin) { // multiple realm botting fix in case of R/D or disconnect
if (firstLogin && getLocation() === 9) { // multiple realm botting fix in case of R/D or disconnect
ControlAction.click(6, 33, 572, 128, 35);
}

Expand All @@ -418,7 +459,7 @@ JoinLoop:
try {
login(me.profile);
} catch (e) {
print(e);
print(e + " " + getLocation());
}

break;
Expand Down Expand Up @@ -608,6 +649,7 @@ JoinLoop:

break;
case 23: // Character Select - Connecting
case 42: // Empty character screen
if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
ControlAction.click(6, 33, 572, 128, 35);
}
Expand Down Expand Up @@ -654,15 +696,11 @@ JoinLoop:

lastGameStatus = "ready";

break;
case 42: // Empty character screen
delay(1000);
ControlAction.click(6, 33, 572, 128, 35);

break;
default:
if (location !== undefined) {
D2Bot.printToConsole("Unhandled location " + location);
//takeScreenshot();
delay(500);
D2Bot.restart();
}
Expand Down
25 changes: 17 additions & 8 deletions d2bs/kolbot/D2BotLead.dbj
@@ -1,12 +1,13 @@
var StarterConfig = {
MinGameTime: 120, // Minimum game length in seconds. If a game is ended too soon, the rest of the time is waited in the lobby
PingQuitDelay: 30, // Time in seconds to wait in lobby after quitting due to high ping
CreateGameDelay: 10, // Seconds to wait before creating a new game
ResetCount: 999, // Reset game count back to 1 every X games.
CharacterDifference: 99, // Character level difference. Set to false to disable character difference.
ChatActionsDelay: 2, // Seconds to wait in lobby before entering a channel

SwitchKeyDelay: 0, // Seconds to wait before switching a used/banned key or after realm down
CrashDelay: 0, // Seconds to wait after a d2 window crash
CrashDelay: 10, // Seconds to wait after a d2 window crash
FTJDelay: 60, // Seconds to wait after failing to create a game
RealmDownDelay: 3, // Minutes to wait after getting Realm Down message
UnableToConnectDelay: 5, // Minutes to wait after Unable To Connect message
Expand Down Expand Up @@ -41,7 +42,7 @@ if (!FileTools.exists("data/" + me.profile + ".json")) {
DataFile.create();
}

var difficulty, error, keyswap, rdblocker, gameStart, ingame, muleTrigger, firstLogin, connectFail, chatActionsDone, torchTrigger, torchMuleTrigger,
var difficulty, error, keyswap, rdblocker, gameStart, ingame, muleTrigger, firstLogin, connectFail, chatActionsDone, torchTrigger, torchMuleTrigger, pingQuit,
loginFail = 0,
gamePass = "",
gameName = "",
Expand Down Expand Up @@ -124,6 +125,10 @@ function ScriptMsgEvent(msg) {

torchMuleTrigger = false;

break;
case "pingquit":
pingQuit = true;

break;
}
}
Expand Down Expand Up @@ -220,6 +225,12 @@ MainSwitch:

loginFail = 0;

if (StarterConfig.PingQuitDelay && pingQuit) {
timeoutDelay("Ping Delay", StarterConfig.PingQuitDelay * 1e3);

pingQuit = false;
}

if (ChannelConfig.hasOwnProperty(me.profile) && ChannelConfig[me.profile].JoinChannel !== "") {
ControlAction.click(6, 27, 480, 120, 20);

Expand Down Expand Up @@ -499,7 +510,7 @@ MainSwitch:
case 8: // Main Menu
case 9: // Login
case 18: // D2 Splash
if (firstLogin) { // multiple realm botting fix in case of R/D or disconnect
if (firstLogin && getLocation() === 9) { // multiple realm botting fix in case of R/D or disconnect
ControlAction.click(6, 33, 572, 128, 35);
}

Expand All @@ -512,7 +523,7 @@ MainSwitch:
try {
login(me.profile);
} catch (e) {
print(e);
print(e + " " + getLocation());
}

break;
Expand Down Expand Up @@ -712,6 +723,7 @@ MainSwitch:

break;
case 23: // Character Select - Connecting
case 42: // Empty character screen
if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
ControlAction.click(6, 33, 572, 128, 35);
}
Expand Down Expand Up @@ -759,14 +771,11 @@ MainSwitch:
break;
case 38: // Game is full
// doesn't happen when making
break;
case 42: // Empty character screen
ControlAction.click(6, 33, 572, 128, 35);

break;
default:
if (location !== undefined) {
D2Bot.printToConsole("Unhandled location " + location);
//takeScreenshot();
delay(500);
D2Bot.restart();
}
Expand Down
5 changes: 5 additions & 0 deletions d2bs/kolbot/libs/AutoMule.js
Expand Up @@ -210,6 +210,11 @@ MainLoop:
},

inGameCheck: function () {
// Single player
if (!me.gamename) {
return false;
}

// Check if we're in mule or torch mule game
if ((!this.getMule(0) || me.gamename.toLowerCase() !== this.getMule(0).muleGameName[0].toLowerCase()) &&
(!this.getMule(1) || me.gamename.toLowerCase() !== this.getMule(1).muleGameName[0].toLowerCase())) {
Expand Down
10 changes: 4 additions & 6 deletions d2bs/kolbot/libs/bots/DiabloHelper.js
Expand Up @@ -257,7 +257,6 @@ function DiabloHelper() {

var i, partybaal;


// start
Town.doChores();
Pather.useWaypoint(107);
Expand All @@ -268,23 +267,22 @@ function DiabloHelper() {
for (i = 0; i < Config.DiabloHelper.Wait; i += 1) {
partybaal = getParty();

if (partybaal) {
if (partybaal && partybaal.area) {
do {
if (partybaal.area === 131) {
return false;
}
} while (partybaal.getNext());
}

if (Pather.usePortal(108, null)) {
break;
if (Pather.usePortal(108, null)) {
break;
}
}

delay(1000);
}

if (i === Config.DiabloHelper.Wait) {

throw new Error("No portals to Chaos");
}

Expand Down
11 changes: 5 additions & 6 deletions d2bs/kolbot/libs/bots/OrgTorch.js
Expand Up @@ -20,12 +20,11 @@ function OrgTorch() {
return false;
}

var i,
items = Storage.Inventory.Compare(Config.Inventory);
var item = me.getItem("cm2");

if (items) {
for (i = 0; i < items.length; i += 1) {
if (items[i].quality === 7 && Pickit.checkItem(items[i]).result === 1) {
if (item) {
do {
if (item.quality === 7 && Pickit.checkItem(item).result === 1) {
if (TorchSystem.FarmerProfiles.indexOf(me.profile) > -1) {
//D2Bot.printToConsole("torch found");
scriptBroadcast("muleTorch");
Expand All @@ -36,7 +35,7 @@ function OrgTorch() {
return true;
}
}
}
} while (item.getNext());
}

return false;
Expand Down

0 comments on commit 1687439

Please sign in to comment.