Advertisement
Guest User

Untitled

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