Advertisement
Guest User

Untitled

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