Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.36 KB | None | 0 0
  1. var StarterConfig = {
  2. MinGameTime: 0, // Minimum game length in seconds. If a game is ended too soon, the rest of the time is waited in the lobby
  3. PingQuitDelay: 30, // Time in seconds to wait in lobby after quitting due to high ping
  4. CreateGameDelay: 5, // Seconds to wait before creating a new game
  5. ResetCount: 0, // Reset game count back to 1 every X games.
  6. CharacterDifference: false, // Character level difference. Set to false to disable character difference.
  7. ChatActionsDelay: 3, // Seconds to wait in lobby before entering a channel
  8.  
  9. JoinChannel: "Op D2Station", // Default channel. Can be an array of channels - ["channel 1", "channel 2"]
  10. FirstJoinMessage: "", // Default join message. Can be an array of messages
  11. AnnounceGames: false, // Default value
  12. AfterGameMessage: "", // Default message after a finished game. Can be an array of messages
  13.  
  14. SwitchKeyDelay: 5, // Seconds to wait before switching a used/banned key or after realm down
  15. CrashDelay: 5, // Seconds to wait after a d2 window crash
  16. FTJDelay: 10, // Seconds to wait after failing to create a game
  17. RealmDownDelay: 2, // Minutes to wait after getting Realm Down message
  18. UnableToConnectDelay: 5, // Minutes to wait after Unable To Connect message
  19. CDKeyInUseDelay: 5, // Minutes to wait before connecting again if CD-Key is in use.
  20. ConnectingTimeout: 20, // Seconds to wait before cancelling the 'Connecting...' screen
  21. PleaseWaitTimeout: 10, // Seconds to wait before cancelling the 'Please Wait...' screen
  22. WaitInLineTimeout: 60, // Seconds to wait before cancelling the 'Waiting in Line...' screen
  23. GameDoesNotExistTimeout: 30 // Seconds to wait before cancelling the 'Game does not exist.' screen
  24. };
  25.  
  26. /**
  27. IncludeFilter config:
  28.  
  29. Multiple entries in the same array mean AND:
  30. ["Normalbaal2", "-"] = game has to contain "baal" and "-"
  31.  
  32. Different entries mean OR:
  33. ["baal"],
  34. ["diablo"]
  35. ["Normalbaal2"]
  36. will join games with either "baal" or "diablo" in their name
  37.  
  38. Similar rules apply to ExcludeFilter:
  39.  
  40. ["somebaal", "-"] ignores games with "somebaal" and "-" in the game name
  41.  
  42. ["somebaal"],
  43. ["somediablo"]
  44. this will ignore all games with "somebaal" or "somediablo" in their names
  45. */
  46.  
  47. var IncludeFilter = [
  48. [""]
  49. ];
  50.  
  51. var ExcludeFilter = [
  52. [""]
  53. ];
  54.  
  55. // ###############################################################################
  56.  
  57. function includeCheck(game) {
  58. // No filters
  59. if (!IncludeFilter.length) {
  60. return true;
  61. }
  62.  
  63. var i, j;
  64.  
  65. for (i = 0; i < IncludeFilter.length; i += 1) {
  66. for (j = 0; j < IncludeFilter[i].length; j += 1) {
  67. // Break the inner loop if an element didn't match or if an element is invalid
  68. if (!IncludeFilter[i][j] || !game.match(IncludeFilter[i][j], "gi")) {
  69. break;
  70. }
  71. }
  72.  
  73. // All elements matched
  74. if (j === IncludeFilter[i].length) {
  75. return true;
  76. }
  77. }
  78.  
  79. return false;
  80. }
  81.  
  82. function excludeCheck(game) {
  83. // No filters
  84. if (!ExcludeFilter.length) {
  85. return true;
  86. }
  87.  
  88. var i, j;
  89.  
  90. for (i = 0; i < ExcludeFilter.length; i += 1) {
  91. for (j = 0; j < ExcludeFilter[i].length; j += 1) {
  92. // Break the inner loop if an element didn't match or if an element is invalid
  93. if (!ExcludeFilter[i][j] || !game.match(ExcludeFilter[i][j], "gi")) {
  94. break;
  95. }
  96. }
  97.  
  98. // All elements matched
  99. if (j === ExcludeFilter[i].length) {
  100. return false;
  101. }
  102. }
  103.  
  104. return true;
  105. }
  106.  
  107. // No touchy!
  108. include("json2.js");
  109. include("OOG.js");
  110. include("automule.js");
  111. include("gambling.js");
  112. include("craftingsystem.js");
  113. include("torchsystem.js");
  114. include("common/misc.js");
  115.  
  116. if (!FileTools.exists("data/" + me.profile + ".json")) {
  117. DataFile.create();
  118. }
  119.  
  120. var gameInfo, gameStart, ingame, chatActionsDone, pingQuit,
  121. handle, useChat, firstLogin, connectFail, lastGameTick,
  122. gameCount = DataFile.getStats().runs + 1,
  123. lastGameStatus = "ready",
  124. loginRetry = 0,
  125. loginFail = 0,
  126. isUp = "no",
  127. chanInfo = {
  128. joinChannel: "",
  129. firstMsg: "",
  130. afterMsg: "",
  131. announce: false
  132. };
  133.  
  134. function sayMsg(string) {
  135. if (!useChat) {
  136. return;
  137. }
  138.  
  139. say(string);
  140. }
  141.  
  142. function ReceiveCopyData(mode, msg) {
  143. var obj;
  144.  
  145. switch (msg) {
  146. case "Handle":
  147. handle = mode;
  148.  
  149. break;
  150. }
  151.  
  152. switch (mode) {
  153. case 2: // Game info
  154. print("Recieved Game Info");
  155.  
  156. gameInfo = JSON.parse(msg);
  157.  
  158. break;
  159. case 3: // Game request
  160. // Don't let others join mule/torch/key/gold drop game
  161. if (AutoMule.inGame || Gambling.inGame || TorchSystem.inGame || CraftingSystem.inGame) {
  162. break;
  163. }
  164.  
  165. if (gameInfo) {
  166. obj = JSON.parse(msg);
  167.  
  168. if (me.gameReady) {
  169. D2Bot.joinMe(obj.profile, me.gamename.toLowerCase(), "", me.gamepassword.toLowerCase(), isUp);
  170. } else {
  171. D2Bot.joinMe(obj.profile, gameInfo.gameName.toLowerCase(), gameCount, gameInfo.gamePass.toLowerCase(), isUp);
  172. }
  173. }
  174.  
  175. break;
  176. case 4: // Heartbeat ping
  177. if (msg === "pingreq") {
  178. sendCopyData(null, me.windowtitle, 4, "pingrep");
  179. }
  180.  
  181. break;
  182. case 0xf124: // Cached info retreival
  183. if (msg !== "null") {
  184. gameInfo.crashInfo = JSON.parse(msg);
  185. }
  186.  
  187. break;
  188. }
  189. }
  190.  
  191. function setNextGame() {
  192. var nextGame = gameInfo.gameName;
  193.  
  194. if (StarterConfig.ResetCount && gameCount + 1 >= StarterConfig.ResetCount) {
  195. nextGame += 1;
  196. } else {
  197. nextGame += (gameCount + 1);
  198. }
  199.  
  200. DataFile.updateStats("nextGame", nextGame);
  201. }
  202.  
  203. function locationTimeout(time, location) {
  204. var endtime = getTickCount() + time;
  205.  
  206. while (getLocation() === location && endtime > getTickCount()) {
  207. delay(500);
  208. }
  209.  
  210. return (getLocation() !== location);
  211. }
  212.  
  213. function updateCount() {
  214. D2Bot.updateCount();
  215. delay(1000);
  216. ControlAction.click(6, 264, 366, 272, 35);
  217.  
  218. try {
  219. login(me.profile);
  220. } catch (e) {
  221.  
  222. }
  223.  
  224. delay(1000);
  225. ControlAction.click(6, 33, 572, 128, 35);
  226. }
  227.  
  228. function ScriptMsgEvent(msg) {
  229. switch (msg) {
  230. case "mule":
  231. AutoMule.check = true;
  232.  
  233. break;
  234. case "muleTorch":
  235. AutoMule.torchCheck = true;
  236.  
  237. break;
  238. case "torch":
  239. TorchSystem.check = true;
  240.  
  241. break;
  242. case "crafting":
  243. CraftingSystem.check = true;
  244.  
  245. break;
  246. case "getMuleMode":
  247. if (AutoMule.torchAnniCheck === 2) {
  248. scriptBroadcast("2");
  249. } else if (AutoMule.torchAnniCheck === 1) {
  250. scriptBroadcast("1");
  251. } else if (AutoMule.check) {
  252. scriptBroadcast("0");
  253. }
  254.  
  255. break;
  256. case "pingquit":
  257. pingQuit = true;
  258.  
  259. break;
  260. }
  261. }
  262.  
  263. function timer(tick) {
  264. if (!tick) {
  265. return "";
  266. }
  267.  
  268. var min, sec;
  269.  
  270. min = Math.floor((getTickCount() - tick) / 60000).toString();
  271.  
  272. if (min <= 9) {
  273. min = "0" + min;
  274. }
  275.  
  276. sec = (Math.floor((getTickCount() - tick) / 1000) % 60).toString();
  277.  
  278. if (sec <= 9) {
  279. sec = "0" + sec;
  280. }
  281.  
  282. return " (" + min + ":" + sec + ")";
  283. }
  284.  
  285. function randomString(len) {
  286. var i,
  287. rval = "",
  288. letters = "abcdefghijklmnopqrstuvwxyz";
  289.  
  290. for (i = 0; i < len; i += 1) {
  291. rval += letters[Math.floor(Math.random() * 26)];
  292. }
  293.  
  294. return rval;
  295. }
  296.  
  297. function main() {
  298. debugLog(me.profile);
  299. addEventListener('copydata', ReceiveCopyData);
  300. addEventListener('scriptmsg', ScriptMsgEvent);
  301.  
  302. while (!handle) {
  303. delay(100);
  304. }
  305.  
  306. DataFile.updateStats("handle", handle);
  307. delay(500);
  308. D2Bot.init();
  309. load("tools/heartbeat.js");
  310.  
  311. while (!gameInfo) {
  312. D2Bot.requestGameInfo();
  313. delay(500);
  314. }
  315.  
  316. if (gameInfo.error) {
  317. D2Bot.retrieve();
  318. delay(200);
  319.  
  320. if (gameInfo.crashInfo) {
  321. D2Bot.printToConsole("Crash Info: Script: " + gameInfo.crashInfo.currScript + " Area: " + gameInfo.crashInfo.area, 10);
  322. }
  323.  
  324. ControlAction.timeoutDelay("Crash Delay", StarterConfig.CrashDelay * 1e3);
  325. D2Bot.updateRuns();
  326. }
  327.  
  328. D2Bot.store(JSON.stringify({currScript: "none", area: "out of game"}));
  329.  
  330. while (true) {
  331. while (me.ingame) { // returns true before actually in game so we can't only use this check
  332. if (me.gameReady) { // returns false when switching acts so we can't use while
  333. isUp = "yes";
  334.  
  335. if (!ingame) {
  336. gameStart = getTickCount();
  337.  
  338. print("Updating Status");
  339. //D2Bot.updateStatus("Game: " + me.gamename);
  340.  
  341. lastGameStatus = "ingame";
  342. ingame = true;
  343.  
  344. DataFile.updateStats("runs", gameCount);
  345. DataFile.updateStats("ingameTick");
  346. }
  347.  
  348. D2Bot.updateStatus("Game: " + me.gamename + timer(gameStart));
  349. }
  350.  
  351. delay(1000);
  352. }
  353.  
  354. isUp = "no";
  355.  
  356. locationAction(getLocation());
  357. delay(1000);
  358. }
  359. }
  360.  
  361. function locationAction(location) {
  362. var i, string, control, text, gameToJoin, doneGames, gameList;
  363.  
  364. MainSwitch:
  365. switch (location) {
  366. case 0:
  367. ControlAction.click();
  368.  
  369. break;
  370. case 1: // Lobby
  371. D2Bot.updateStatus("Lobby");
  372.  
  373. me.blockKeys = false;
  374. loginRetry = 0;
  375.  
  376. if (!firstLogin) {
  377. firstLogin = true;
  378. }
  379.  
  380. if (lastGameStatus === "pending") {
  381. gameCount += 1;
  382. }
  383.  
  384. loginFail = 0;
  385.  
  386. if (StarterConfig.PingQuitDelay && pingQuit) {
  387. ControlAction.timeoutDelay("Ping Delay", StarterConfig.PingQuitDelay * 1e3);
  388.  
  389. pingQuit = false;
  390. }
  391.  
  392. if (ingame || gameInfo.error) {
  393. if (!gameStart) {
  394. gameStart = DataFile.getStats().ingameTick;
  395. }
  396.  
  397. if (getTickCount() - gameStart < StarterConfig.MinGameTime * 1e3) {
  398. ControlAction.timeoutDelay("Min game time wait", StarterConfig.MinGameTime * 1e3 + gameStart - getTickCount());
  399. }
  400. }
  401.  
  402. if (ingame) {
  403. D2Bot.store(JSON.stringify({currScript: "none", area: "out of game"}));
  404.  
  405. if (AutoMule.outOfGameCheck() || TorchSystem.outOfGameCheck() || Gambling.outOfGameCheck() || CraftingSystem.outOfGameCheck()) {
  406. break;
  407. }
  408.  
  409. print("updating runs");
  410. D2Bot.updateRuns();
  411.  
  412. lastGameTick = getTickCount();
  413. gameCount += 1;
  414. lastGameStatus = "ready";
  415. ingame = false;
  416.  
  417. if (StarterConfig.ResetCount && gameCount >= StarterConfig.ResetCount) {
  418. gameCount = 1;
  419.  
  420. DataFile.updateStats("runs", gameCount);
  421. }
  422. }
  423.  
  424. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  425. break;
  426. }
  427.  
  428. if (!locationTimeout(5000, location)) { // in case create button gets bugged
  429. if (!ControlAction.click(6, 533, 469, 120, 20)) { // Create
  430. break;
  431. }
  432.  
  433. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  434. break;
  435. }
  436. }
  437.  
  438. break;
  439. case 2: // Waiting In Line
  440. D2Bot.updateStatus("Waiting...");
  441. locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location);
  442. ControlAction.click(6, 433, 433, 96, 32);
  443.  
  444. break;
  445. case 3: // Lobby Chat
  446. break;
  447. case 4: // Create Game
  448. break;
  449. case 5: // Join Game
  450. // Don't join immediately after previous game to avoid FTJ
  451. if (getTickCount() - lastGameTick < 5000) {
  452. ControlAction.timeoutDelay("Game Delay", (lastGameTick - getTickCount() + 5000));
  453. }
  454.  
  455. for (i = 0; i < 5; i += 1) {
  456. gameList = ControlAction.getGameList();
  457.  
  458. if (gameList && gameList.length > 0) {
  459. break;
  460. }
  461.  
  462. delay(1000);
  463. }
  464.  
  465. if (gameList) {
  466. doneGames = [];
  467. gameToJoin = false;
  468.  
  469. if (FileTools.exists("logs/doneGames.json")) {
  470. doneGames = JSON.parse(Misc.fileAction("logs/doneGames.json", 0));
  471. }
  472.  
  473. gameList.sort(function (a, b) {
  474. return b.players - a.players;
  475. });
  476.  
  477. for (i = 0; i < gameList.length; i += 1) {
  478. if (doneGames.indexOf(gameList[i].gameName) === -1 && includeCheck(gameList[i].gameName) && excludeCheck(gameList[i].gameName)) {
  479. print("ÿc7Game: " + gameList[i].gameName + ", Players: " + gameList[i].players);
  480.  
  481. gameToJoin = gameList[i].gameName;
  482.  
  483. break;
  484. }
  485. }
  486.  
  487. if (gameToJoin) {
  488. if (doneGames.length >= 20) {
  489. doneGames.shift();
  490. }
  491.  
  492. doneGames.push(gameToJoin);
  493. Misc.fileAction("logs/doneGames.json", 1, JSON.stringify(doneGames));
  494.  
  495. me.blockMouse = true;
  496.  
  497. try {
  498. joinGame(gameToJoin, "");
  499. } catch (joinErr) {
  500.  
  501. }
  502.  
  503. me.blockMouse = false;
  504.  
  505. locationTimeout(5000, location);
  506. }
  507. }
  508.  
  509. break;
  510. case 6: // Ladder
  511. break;
  512. case 7: // Channel List
  513. break;
  514. case 8: // Main Menu
  515. case 9: // Login
  516. case 12: // Character Select
  517. case 18: // D2 Splash
  518. // Single Player screen fix
  519. if (getLocation() === 12 && !getControl(4, 626, 100, 151, 44)) {
  520. ControlAction.click(6, 33, 572, 128, 35);
  521.  
  522. break;
  523. }
  524.  
  525. if (firstLogin && getLocation() === 9) { // multiple realm botting fix in case of R/D or disconnect
  526. ControlAction.click(6, 33, 572, 128, 35);
  527. }
  528.  
  529. D2Bot.updateStatus("Logging In");
  530.  
  531. try {
  532. login(me.profile);
  533. } catch (e) {
  534. if (getLocation() === 12 && loginRetry < 2) {
  535. if (loginRetry === 0) {
  536. // start from beginning of the char list
  537. sendKey(0x24);
  538. }
  539.  
  540. control = getControl(4, 237, 457, 72, 93); // char on 1st column, 4th row
  541.  
  542. if (control) {
  543. me.blockMouse = true;
  544. me.blockKeys = true;
  545.  
  546. control.click();
  547. sendKey(0x28);
  548. sendKey(0x28);
  549. sendKey(0x28);
  550. sendKey(0x28);
  551.  
  552. me.blockMouse = false;
  553. }
  554.  
  555. loginRetry++;
  556. } else {
  557. me.blockKeys = false;
  558. print(e + " " + getLocation());
  559. }
  560. }
  561.  
  562. break;
  563. case 10: // Login Error
  564. string = "";
  565. text = ControlAction.getText(4, 199, 377, 402, 140);
  566.  
  567. if (text) {
  568. for (i = 0; i < text.length; i += 1) {
  569. string += text[i];
  570.  
  571. if (i !== text.length - 1) {
  572. string += " ";
  573. }
  574. }
  575.  
  576. switch (string) {
  577. case getLocaleString(5207):
  578. D2Bot.updateStatus("Invalid Password");
  579. D2Bot.printToConsole("Invalid Password");
  580.  
  581. break;
  582. case getLocaleString(5208):
  583. loginFail += 1;
  584.  
  585. if (loginFail < 2) {
  586. ControlAction.timeoutDelay("Login retry", 3000);
  587. ControlAction.click(6, 335, 412, 128, 35);
  588.  
  589. break MainSwitch;
  590. }
  591.  
  592. D2Bot.updateStatus("Invalid Account");
  593. D2Bot.printToConsole("Invalid Account");
  594.  
  595. break;
  596. case getLocaleString(5199):
  597. D2Bot.updateStatus("Disabled CDKey");
  598. D2Bot.printToConsole("Disabled CDKey: " + gameInfo.mpq, 6);
  599. D2Bot.CDKeyDisabled();
  600.  
  601. if (gameInfo.switchKeys) {
  602. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  603. D2Bot.restart(true);
  604. } else {
  605. D2Bot.stop();
  606. }
  607.  
  608. break;
  609. case getLocaleString(10913):
  610. D2Bot.updateStatus("Disabled LoD CDKey");
  611. D2Bot.printToConsole("Disabled LoD CDKey: " + gameInfo.mpq, 6);
  612. D2Bot.CDKeyDisabled();
  613.  
  614. if (gameInfo.switchKeys) {
  615. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  616. D2Bot.restart(true);
  617. } else {
  618. D2Bot.stop();
  619. }
  620.  
  621. break;
  622. case getLocaleString(5347):
  623. D2Bot.updateStatus("Disconnected");
  624. D2Bot.printToConsole("Disconnected");
  625. ControlAction.click(6, 335, 412, 128, 35);
  626.  
  627. break MainSwitch;
  628. default:
  629. D2Bot.updateStatus("Login Error");
  630. D2Bot.printToConsole("Login Error - " + string);
  631.  
  632. break;
  633. }
  634. }
  635.  
  636. ControlAction.click(6, 335, 412, 128, 35);
  637.  
  638. while (true) {
  639. delay(1000);
  640. }
  641.  
  642. break;
  643. case 11: // Unable To Connect
  644. D2Bot.updateStatus("Unable To Connect");
  645.  
  646. if (connectFail) {
  647. ControlAction.timeoutDelay("Unable to Connect", StarterConfig.UnableToConnectDelay * 6e4);
  648.  
  649. connectFail = false;
  650. }
  651.  
  652. if (!ControlAction.click(6, 335, 450, 128, 35)) {
  653. break;
  654. }
  655.  
  656. connectFail = true;
  657.  
  658. break;
  659. case 13: // Realm Down - Character Select screen
  660. D2Bot.updateStatus("Realm Down");
  661. delay(1000);
  662.  
  663. if (!ControlAction.click(6, 33, 572, 128, 35)) {
  664. break;
  665. }
  666.  
  667. updateCount();
  668. ControlAction.timeoutDelay("Realm Down", StarterConfig.RealmDownDelay * 6e4);
  669. D2Bot.CDKeyRD();
  670.  
  671. if (gameInfo.switchKeys && !gameInfo.rdBlocker) {
  672. D2Bot.printToConsole("Realm Down - Changing CD-Key");
  673. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  674. D2Bot.restart(true);
  675. } else {
  676. D2Bot.printToConsole("Realm Down - Restart");
  677. D2Bot.restart();
  678. }
  679.  
  680. break;
  681. case 14: // Character Select / Main Menu - Disconnected
  682. D2Bot.updateStatus("Disconnected");
  683. delay(500);
  684. ControlAction.click(6, 351, 337, 96, 32);
  685.  
  686. break;
  687. case 16: // Character Select - Please Wait popup
  688. if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) {
  689. ControlAction.click(6, 351, 337, 96, 32);
  690. }
  691.  
  692. break;
  693. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  694. delay(1000);
  695. ControlAction.click(6, 351, 337, 96, 32);
  696.  
  697. break;
  698. case 19: // Login - Cdkey In Use
  699. D2Bot.printToConsole(gameInfo.mpq + " is in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
  700. D2Bot.CDKeyInUse();
  701.  
  702. if (gameInfo.switchKeys) {
  703. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  704. D2Bot.restart(true);
  705. } else {
  706. ControlAction.click(6, 335, 450, 128, 35);
  707. ControlAction.timeoutDelay("CD-Key in use", StarterConfig.CDKeyInUseDelay * 6e4);
  708. }
  709.  
  710. break;
  711. case 20: // Single Player - Select Difficulty
  712. break;
  713. case 21: // Main Menu - Connecting
  714. if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
  715. ControlAction.click(6, 330, 416, 128, 35);
  716. }
  717.  
  718. break;
  719. case 22: // Login - Invalid Cdkey (classic or xpac)
  720. text = ControlAction.getText(4, 162, 270, 477, 50);
  721. string = "";
  722.  
  723. if (text) {
  724. for (i = 0; i < text.length; i += 1) {
  725. string += text[i];
  726.  
  727. if (i !== text.length - 1) {
  728. string += " ";
  729. }
  730. }
  731. }
  732.  
  733. switch (string) {
  734. case getLocaleString(10914):
  735. D2Bot.printToConsole(gameInfo.mpq + " LoD key in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
  736. D2Bot.CDKeyInUse();
  737.  
  738. if (gameInfo.switchKeys) {
  739. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  740. D2Bot.restart(true);
  741. } else {
  742. ControlAction.click(6, 335, 450, 128, 35);
  743. ControlAction.timeoutDelay("LoD key in use", StarterConfig.CDKeyInUseDelay * 6e4);
  744. }
  745.  
  746. break;
  747. default:
  748. if (gameInfo.switchKeys) {
  749. D2Bot.printToConsole("Invalid CD-Key");
  750. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  751. D2Bot.restart(true);
  752. } else {
  753. ControlAction.click(6, 335, 450, 128, 35);
  754. ControlAction.timeoutDelay("Invalid CD-Key", StarterConfig.CDKeyInUseDelay * 6e4);
  755. }
  756.  
  757. break;
  758. }
  759.  
  760. break;
  761. case 23: // Character Select - Connecting
  762. case 42: // Empty character screen
  763. if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
  764. ControlAction.click(6, 33, 572, 128, 35);
  765. }
  766.  
  767. if (gameInfo.rdBlocker) {
  768. D2Bot.restart();
  769. }
  770.  
  771. break;
  772. case 24: // Server Down - not much to do but wait..
  773. break;
  774. case 25: // Lobby - Please Wait
  775. if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) {
  776. ControlAction.click(6, 351, 337, 96, 32);
  777. }
  778.  
  779. break;
  780. case 26: // Lobby - Game Name Exists
  781. ControlAction.click(6, 533, 469, 120, 20);
  782.  
  783. gameCount += 1;
  784. lastGameStatus = "ready";
  785.  
  786. break;
  787. case 27: // Gateway Select
  788. ControlAction.click(6, 436, 538, 96, 32);
  789.  
  790. break;
  791. case 28: // Lobby - Game Does Not Exist
  792. D2Bot.printToConsole("Game doesn't exist");
  793.  
  794. if (gameInfo.rdBlocker) {
  795. D2Bot.printToConsole(gameInfo.mpq + " is probably flagged.", 6);
  796.  
  797. if (gameInfo.switchKeys) {
  798. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  799. D2Bot.restart(true);
  800. }
  801. } else {
  802. locationTimeout(StarterConfig.GameDoesNotExistTimeout * 1e3, location);
  803. }
  804.  
  805. lastGameStatus = "ready";
  806.  
  807. break;
  808. case 38: // Game is full
  809. // doesn't happen when making
  810. break;
  811. default:
  812. if (location !== undefined) {
  813. D2Bot.printToConsole("Unhandled location " + location);
  814. //takeScreenshot();
  815. delay(500);
  816. D2Bot.restart();
  817. }
  818.  
  819. break;
  820. }
  821. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement