This repository has been archived by the owner on Jun 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathD2BotSoloCleaner.dbj
813 lines (655 loc) · 21.1 KB
/
D2BotSoloCleaner.dbj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
/**
* @filename D2BotSoloCleaner.dbj
* @author theBGuy
* @credits Whoever did the original D2BotAccountCleaner.dbj
* @desc Modified D2BotAccountCleaner, The purpose of this entryscript is to delete old characters and optional related files
*/
const StarterConfig = {
// New Stuff - DataCleaner to delete old files associated with running SoloPlay, SaveFiles to save important files to SoloPlay/Data/ for performance review
//***********************************************************************************************************************//
// DataCleaner and SaveFiles can both be used for cleaning/saving files without having to delete associated characters //
//***********************************************************************************************************************//
DataCleaner: true, // Always run this when re-using a profile with Kolbot-SoloPlay
SaveFiles: true, // Highly recommened to run this if using the peformance tracking system
// Old Stuff
DelayBetweenAccounts: rand(10,25), //Seconds to wait before cleaning next account, if doing 10+ accounts recommended to increase this delay to rand(30, 60) prevent R/D
SwitchKeyDelay: rand(10,25), // Seconds to wait before switching a used/banned key or after realm down
CrashDelay: rand(60, 120), // Seconds to wait after a d2 window crash
RealmDownDelay: rand(3, 6), // Minutes to wait after getting Realm Down message
UnableToConnectDelay: rand(5, 8), // Minutes to wait after Unable To Connect message
CDKeyInUseDelay: rand(5, 8), // Minutes to wait before connecting again if CD-Key is in use. SwitchKeys overrides this!
ConnectingTimeout: rand(30, 60), // Seconds to wait before cancelling the 'Connecting...' screen
PleaseWaitTimeout: rand(30, 60), // Seconds to wait before cancelling the 'Please Wait...' screen
WaitInLineTimeout: rand(30, 60) // Seconds to wait before cancelling the 'Waiting in Line...' screen
};
const AccountsToClean = {
/* Format:
"account1/password1/realm": ["charname1", "charname2"],
"account2/password2/realm": ["charnameX", "charnameY"],
"account3/password3/realm": ["all"]
To clean a full account, put "account/password/realm": ["all"]
realm = useast, uswest, europe, asia, or singleplayer
for singleplayer enter null into both account and password
Individual entries are separated with a comma.
*/
/* Example:
"MyAcc1/tempPass/useast": ["soloSorc"],
"null/null/singleplayer": ["solobarb"],
*/
//Enter your lines under here
};
//NEW STUFF - Please enter your profile name exactly as is
const profiles = [
/* Format. Enter in profile exactly the way it appears in D2Bot#
"SCL-ZON123",
"hcnl-pal123",
*/
//Enter your lines under here
];
function dataCleaner() {
if (!profiles.length) {
D2Bot.printToConsole("SoloCleaner: No profiles entered to clean. If this was a mistake, fill out profile information under NEW STUFF. Exiting dataCleaner and moving on to clean characters...", 6);
return;
}
let charClass;
let folder, j;
for (let i = 0; i < profiles.length; i++) {
let buildCheck = profiles[i].toUpperCase().split("-");
buildCheck[1] = buildCheck[1].toString().substring(0, 3).toUpperCase();
let charType = buildCheck[0].includes("CC") ? "Classic" : "Expansion";
let profileExists = false;
// Filepaths
let dataFP = "data/" + profiles[i] + ".json";
let gameTimeFP = "libs/SoloPlay/Data/" + profiles[i] + "/" + profiles[i] + "-GameTime" + ".json";
let charDataFP = "libs/SoloPlay/Data/" + profiles[i] + "/" + profiles[i] + "-CharData" + ".json";
let lvlPerfFP = "libs/SoloPlay/Data/" + profiles[i] + "/" + profiles[i] + "-LevelingPerformance" + ".csv";
let scrPerfFP = "libs/SoloPlay/Data/" + profiles[i] + "/" + profiles[i] + "-ScriptPerformance" + ".csv";
switch (buildCheck[1]) {
case "ZON":
charClass = "amazon";
break;
case "SOR":
charClass = "sorceress";
break;
case "NEC":
charClass = "necromancer";
break;
case "PAL":
charClass = "paladin";
break;
case "BAR":
charClass = "barbarian";
break;
case "DRU":
charClass = "druid";
break;
case "SIN":
charClass = "assassin";
break;
default:
D2Bot.printToConsole("SoloCleaner: Failed to get charClass. Please check that your profile was entered correctly under NEW STUFF.", 6);
return;
}
if (StarterConfig.SaveFiles) {
if (FileTools.exists(dataFP) || FileTools.exists(gameTimeFP) || FileTools.exists(charDataFP) || FileTools.exists(lvlPerfFP) || FileTools.exists(scrPerfFP)) {
// Create folder to copy files to
if (!FileTools.exists("libs/SoloPlay/Data/" + charType)) {
folder = dopen("libs/SoloPlay/Data");
folder.create(charType);
}
if (!FileTools.exists("libs/SoloPlay/Data/" + charType + "/" + charClass)) {
folder = dopen("libs/SoloPlay/Data/" + charType);
folder.create(charClass);
}
let files = dopen("libs/SoloPlay/Data/" + charType + "/" + charClass + "/").getFolders();
j = 1;
files.forEach((file) => {
if (FileTools.exists("libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j.toString())){
j++;
}
});
if (!FileTools.exists("libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j.toString())) {
folder = dopen("libs/SoloPlay/Data/" + charType + "/" + charClass);
folder.create(j.toString());
}
profileExists = true;
}
}
if (FileTools.exists(dataFP)) {
if (StarterConfig.SaveFiles){
FileTools.copy(dataFP, "libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j.toString() + "/" + profiles[i] + "Old.json");
}
profileExists = true;
FileTools.remove(dataFP);
}
if (FileTools.exists(gameTimeFP)) {
if (StarterConfig.SaveFiles) {
FileTools.copy(gameTimeFP, "libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j.toString() + "/" + profiles[i] + "-GameTimeOld.json");
}
FileTools.remove(gameTimeFP);
}
if (FileTools.exists(charDataFP)) {
if (StarterConfig.SaveFiles) {
FileTools.copy(charDataFP, "libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j.toString() + "/" + profiles[i] + "-CharDataOld.json");
}
FileTools.remove(charDataFP);
}
if (FileTools.exists(lvlPerfFP)) {
if (StarterConfig.SaveFiles) {
FileTools.copy(lvlPerfFP, "libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j.toString() + "/" + profiles[i] + "-LevelingPerformanceOld.csv");
}
FileTools.remove(lvlPerfFP);
}
if (FileTools.exists(scrPerfFP)) {
if (StarterConfig.SaveFiles) {
FileTools.copy(scrPerfFP, "libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j.toString() + "/" + profiles[i] + "-ScriptPerformanceOld.csv");
}
FileTools.remove(scrPerfFP);
}
if (StarterConfig.SaveFiles && profileExists) {
D2Bot.printToConsole("SoloCleaner: Files saved to -> libs/SoloPlay/Data/" + charType + "/" + charClass + "/" + j, 6);
}
if (profileExists) {
D2Bot.printToConsole("SoloCleaner: Cleaned files for -> " + profiles[i], 6);
}
delay(500);
}
D2Bot.printToConsole("SoloCleaner: Done cleaning files", 6);
};
/* Generate accounts to entirely clean ("all")
to use this, set generateAccounts to true and setup the rest of the parameters
it will generates accounts from start to stop range(included) :
account1/password/realm
account2/password/realm
etc...
*/
var generateAccounts = false,
accountPrefix = "account",
accountPassword = "password",
accountRealm = "realm",
rangeStart = 1,
rangeStop = 10;
// No touchy!
include("json2.js");
include('polyfill.js');
include("OOG.js");
include("common/misc.js");
if (!FileTools.exists("data/" + me.profile + ".json")) {
DataFile.create();
}
let handle, gameInfo, gameStart, ingame, connectFail, currAcc, charList, firstAccount = true,
lastGameStatus = "ready",
gameCount = DataFile.getStats().runs + 1,
accounts = [],
chars = [];
function parseInfo() {
for (let i in AccountsToClean) {
if (AccountsToClean.hasOwnProperty(i) && typeof i === "string") {
accounts.push(i);
chars.push(AccountsToClean[i]);
}
}
if (generateAccounts) {
for (let index = rangeStart ; index <= rangeStop ; index += 1) {
accounts.push(accountPrefix + index + "/" + accountPassword + "/" + accountRealm);
chars.push(["all"]);
}
}
if (!accounts.length) {
FileTools.remove("logs/AccountCleaner.json");
D2Bot.printToConsole("SoloCleaner: No accounts entered. Exiting SoloCleaner", 6);
ControlAction.timeoutDelay("Exiting in: ", 3 * 1e3);
D2Bot.stop(me.profile, true);
}
}
function ReceiveCopyData(mode, msg) {
switch (msg) {
case "Handle":
handle = mode;
break;
}
switch (mode) {
case 2: // game info
print("Recieved Game Info");
gameInfo = JSON.parse(msg);
break;
case 4:
// Heartbeat ping
if (msg === "pingreq") {
sendCopyData(null, me.windowtitle, 4, "pingrep");
}
break;
}
}
function timeoutDelay(text, time) {
let endTime = getTickCount() + time;
while (getTickCount() < endTime) {
D2Bot.updateStatus(text + " (" + Math.floor((endTime - getTickCount()) / 1000) + "s)");
delay(500);
}
}
function locationTimeout(time, location) {
let endtime = getTickCount() + time;
while (getLocation() === location && endtime > getTickCount()) {
delay(500);
}
return (getLocation() !== location);
}
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);
}
function timer (tick) {
return " (" + new Date(getTickCount() - tick).toISOString().slice(11, -5) + ")";
}
function deleteCharacter(info) {
me.blockMouse = true;
let control, text, count = 0;
// start from beginning of the char list
sendKey(0x24);
MainLoop:
while (getLocation() === 12) { // cycle until in lobby
control = getControl(4, 37, 178, 200, 92);
if (control) {
do {
text = control.getText();
if (text instanceof Array && typeof text[1] === "string") {
count++;
if (text[1].toLowerCase() === info.charName.toLowerCase()) {
print("delete character " + info.charName);
control.click();
ControlAction.click(6, 433, 528, 168, 60);
delay(500);
ControlAction.click(6, 421, 337, 96, 32);
delay(500);
me.blockMouse = false;
return true;
}
}
} while (control.getNext());
}
if (count === 8 || count === 16) { // check for additional characters up to 24
control = getControl(4, 237, 457, 72, 93);
if (control) {
control.click();
sendKey(0x28);
sendKey(0x28);
sendKey(0x28);
sendKey(0x28);
}
} else { // no further check necessary
break MainLoop;
}
delay(100);
}
me.blockMouse = false;
return false;
}
function deleteAllCharacters() {
let characters = ControlAction.getCharacters();
for (let character of characters) {
let info = {charName: character};
if (!deleteCharacter(info)) {
print("failed to delete character " + character);
return false;
}
delay(500);
}
return true;
}
function main() {
addEventListener('copydata', ReceiveCopyData);
while (!handle) {
delay(100);
}
DataFile.updateStats("handle", handle);
D2Bot.init();
load("tools/heartbeat.js");
while (!gameInfo) {
D2Bot.requestGameInfo();
delay(500);
}
if (gameInfo.error) {
if (!!DataFile.getStats().debugInfo) {
gameInfo.crashInfo = DataFile.getStats().debugInfo;
D2Bot.printToConsole("Crash Info: Script: " + JSON.parse(gameInfo.crashInfo).currScript + " Area: " + JSON.parse(gameInfo.crashInfo).area, 10);
}
ControlAction.timeoutDelay("Crash Delay", StarterConfig.CrashDelay * 1e3);
D2Bot.updateRuns();
}
DataFile.updateStats("debugInfo", JSON.stringify({currScript: "none", area: "out of game"}));
if (StarterConfig.DataCleaner) {
dataCleaner();
}
parseInfo();
while (true) {
locationAction(getLocation());
delay(1000);
}
}
function locationAction(location) {
var i, control, string, text, currChar,
obj = {};
MainSwitch:
switch (location) {
case 0:
break;
case 1: // Lobby
case 3: // Lobby Chat
break;
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
break;
case 5: // Join Game
break;
case 6: // Ladder
break;
case 7: // Channel List
break;
case 8: // Main Menu
case 9: // Login
case 18: // D2 Splash
if (!accounts.length) {
FileTools.remove("logs/AccountCleaner.json");
D2Bot.printToConsole("SoloCleaner: Done cleaning accounts !", 6);
D2Bot.stop(me.profile, true);
break;
}
if (!firstAccount)
{
for (i = 0 ; i < StarterConfig.DelayBetweenAccounts ; i += 1)
{
D2Bot.updateStatus("Waiting " + (StarterConfig.DelayBetweenAccounts - i) + "s for next account");
delay(1e3);
}
}
firstAccount = false;
if (FileTools.exists("logs/AccountCleaner.json")) {
obj = JSON.parse(FileTools.readText("logs/AccountCleaner.json"));
if (obj.currAcc) {
for (i = 0; i < accounts.length; i += 1) {
if (accounts[i].split("/")[0] === obj.currAcc) {
accounts.splice(0, i);
chars.splice(0, i);
i -= 1;
break;
}
}
}
}
currAcc = accounts[0];
currAcc = currAcc.split("/");
charList = chars[0];
obj.currAcc = currAcc[0];
currAcc[2] = currAcc[2].toLowerCase();
D2Bot.printToConsole("SoloCleaner: Cleaning account " + currAcc[0] + " ; char list : " + charList, 6);
FileTools.writeText("logs/AccountCleaner.json", JSON.stringify(obj));
if (currAcc[2] === "singleplayer"){
ControlAction.click(2,0,599,800,600);
break;
}
ControlAction.loginAccount({account: currAcc[0], password: currAcc[1], realm: currAcc[2]});
break;
case 10: // Login Error
string = "";
text = ControlAction.getText(4, 199, 377, 402, 140);
if (text) {
for (i = 0; i < text.length; i += 1) {
string += text[i];
if (i !== text.length - 1) {
string += " ";
}
}
switch (string) {
case getLocaleString(5207):
D2Bot.updateStatus("Invalid Password");
D2Bot.printToConsole("Invalid Password");
break;
case getLocaleString(5208):
D2Bot.updateStatus("Invalid Account");
D2Bot.printToConsole("Invalid Account");
break;
case getLocaleString(5202): // cd key intended for another product
case getLocaleString(10915): // lod key intended for another product
D2Bot.updateStatus("Invalid CDKey");
D2Bot.printToConsole("Invalid CDKey: " + gameInfo.mpq, 6);
D2Bot.CDKeyDisabled();
if (gameInfo.switchKeys) {
ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
D2Bot.restart(true);
} else {
D2Bot.stop(me.profile, true);
}
break;
case getLocaleString(5199):
D2Bot.updateStatus("Disabled CDKey");
D2Bot.printToConsole("Disabled CDKey: " + gameInfo.mpq, 6);
D2Bot.CDKeyDisabled();
if (gameInfo.switchKeys) {
ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
D2Bot.restart(true);
} else {
D2Bot.stop(me.profile, true);
}
break;
case getLocaleString(10913):
D2Bot.updateStatus("Disabled LoD CDKey");
D2Bot.printToConsole("Disabled LoD CDKey: " + gameInfo.mpq, 6);
D2Bot.CDKeyDisabled();
if (gameInfo.switchKeys) {
ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
D2Bot.restart(true);
} else {
D2Bot.stop(me.profile, true);
}
break;
case getLocaleString(5347):
D2Bot.updateStatus("Disconnected");
D2Bot.printToConsole("Disconnected");
ControlAction.click(6, 335, 412, 128, 35);
break MainSwitch;
default:
D2Bot.updateStatus("Login Error");
D2Bot.printToConsole("Login Error - " + string);
if (gameInfo.switchKeys) {
ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
D2Bot.restart(true);
} else {
D2Bot.stop(me.profile, true);
}
break;
}
}
ControlAction.click(6, 335, 412, 128, 35);
while (true) {
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 12: // Character Select
case 42:
// Single Player screen fix
if (currAcc[2] !== "singleplayer"){
if (getLocation() === 12 && !getControl(4, 626, 100, 151, 44)) {
ControlAction.click(6, 33, 572, 128, 35);
break;
}
}
if (!charList.length) {
ControlAction.click(6, 33, 572, 128, 35);
break;
}
if (charList[0] === "all") {
deleteAllCharacters();
}
else
{
if (FileTools.exists("logs/AccountCleaner.json")) {
obj = JSON.parse(FileTools.readText("logs/AccountCleaner.json"));
if (obj.currChar) {
for (i = 0; i < charList.length; i += 1) {
if (charList[i] === obj.currChar) {
charList.splice(0, i + 1); // Remove the previous currChar as well
break;
}
}
}
}
var charInfo = {charName: charList[0]};
deleteCharacter(charInfo);
delay(500);
}
currChar = charList.shift();
obj.currChar = currChar;
// last char in acc = trigger next acc
if (!charList.length) {
accounts.shift();
chars.shift();
FileTools.writeText("logs/AccountCleaner.json", JSON.stringify(obj));
ControlAction.click(6, 33, 572, 128, 35);
break;
}
FileTools.writeText("logs/AccountCleaner.json", JSON.stringify(obj));
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);
if (gameInfo.switchKeys) {
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 15: // New Character
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(gameInfo.mpq + " is in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
D2Bot.CDKeyInUse();
if (gameInfo.switchKeys) {
ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
D2Bot.restart(true);
} else {
ControlAction.click(6, 335, 450, 128, 35);
ControlAction.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)
text = ControlAction.getText(4, 162, 270, 477, 50);
string = "";
if (text) {
for (i = 0; i < text.length; i += 1) {
string += text[i];
if (i !== text.length - 1) {
string += " ";
}
}
}
switch (string) {
case getLocaleString(10914):
D2Bot.printToConsole(gameInfo.mpq + " LoD key in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
D2Bot.CDKeyInUse();
if (gameInfo.switchKeys) {
ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
D2Bot.restart(true);
} else {
ControlAction.click(6, 335, 450, 128, 35);
ControlAction.timeoutDelay("LoD key in use", StarterConfig.CDKeyInUseDelay * 6e4);
}
break;
default:
if (gameInfo.switchKeys) {
D2Bot.printToConsole("Invalid CD-Key");
ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
D2Bot.restart(true);
} else {
ControlAction.click(6, 335, 450, 128, 35);
ControlAction.timeoutDelay("Invalid CD-Key", StarterConfig.CDKeyInUseDelay * 6e4);
}
break;
}
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: // Lobby - Game Name Exists
ControlAction.click(6, 533, 469, 120, 20);
break;
case 27: // Gateway Select
ControlAction.click(6, 436, 538, 96, 32);
break;
case 28: // Lobby - Game Does Not Exist
ControlAction.click(6, 533, 469, 120, 20);
break;
case 38: // Game is full
D2Bot.printToConsole("Game is full");
lastGameStatus = "ready";
delay(500);
ControlAction.click(6, 652, 469, 120, 20);
break;
default:
if (location !== undefined) {
D2Bot.printToConsole("Unhandled location " + location);
delay(500);
D2Bot.restart();
}
break;
}
}