Advertisement
gtoilet

d2classic channel.dbj

Feb 19th, 2017
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.67 KB | None | 0 0
  1. var StarterConfig = {
  2. JoinChannel: "op darjkeel", // 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: [""], // List of games to look for. Example: Games: ["some baal-", "chaos run-"],
  8. Passwords: [""], // 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(6, 264, 266, 272, 35);
  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 15: // Character Select
  506. case 18: // D2 Splash
  507. // Single Player screen fix
  508. if (getLocation() === 15 && !getControl(4, 634, 555, 29, 20)) {
  509. delay(3100);
  510. ControlAction.click(4, 514, 339, 200, 92);
  511. delay(100);
  512. ControlAction.click(6, 353, 572, 128, 35);
  513. break;
  514. }
  515.  
  516. if (firstLogin && getLocation() === 9) { // multiple realm botting fix in case of R/D or disconnect
  517. ControlAction.click(6, 33, 572, 128, 35);
  518. }
  519.  
  520. D2Bot.updateStatus("Logging In");
  521.  
  522. try {
  523. login(me.profile);
  524. } catch (e) {
  525. if (getLocation() === 12 && loginRetry < 2) {
  526. if (loginRetry === 0) {
  527. // start from beginning of the char list
  528. sendKey(0x24);
  529. }
  530.  
  531. control = getControl(4, 237, 457, 72, 93); // char on 1st column, 4th row
  532.  
  533. if (control) {
  534. me.blockMouse = true;
  535. me.blockKeys = true;
  536.  
  537. control.click();
  538. sendKey(0x28);
  539. sendKey(0x28);
  540. sendKey(0x28);
  541. sendKey(0x28);
  542.  
  543. me.blockMouse = false;
  544. }
  545.  
  546. loginRetry++;
  547. } else {
  548. me.blockKeys = false;
  549. print(e + " " + getLocation());
  550. }
  551. }
  552.  
  553. break;
  554. case 10: // Login Error
  555. string = "";
  556. text = ControlAction.getText(4, 199, 377, 402, 140);
  557.  
  558. if (text) {
  559. for (i = 0; i < text.length; i += 1) {
  560. string += text[i];
  561.  
  562. if (i !== text.length - 1) {
  563. string += " ";
  564. }
  565. }
  566.  
  567. switch (string) {
  568. case getLocaleString(5207):
  569. D2Bot.updateStatus("Invalid Password");
  570. D2Bot.printToConsole("Invalid Password");
  571.  
  572. break;
  573. case getLocaleString(5208):
  574. D2Bot.updateStatus("Invalid Account");
  575. D2Bot.printToConsole("Invalid Account");
  576.  
  577. break;
  578. case getLocaleString(5202): // cd key intended for another product
  579. case getLocaleString(10915): // lod key intended for another product
  580. D2Bot.updateStatus("Invalid CDKey");
  581. D2Bot.printToConsole("Invalid CDKey: " + gameInfo.mpq, 6);
  582. D2Bot.CDKeyDisabled();
  583.  
  584. if (gameInfo.switchKeys) {
  585. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  586. D2Bot.restart(true);
  587. } else {
  588. D2Bot.stop();
  589. }
  590.  
  591. break;
  592. case getLocaleString(5199):
  593. D2Bot.updateStatus("Disabled CDKey");
  594. D2Bot.printToConsole("Disabled CDKey: " + gameInfo.mpq, 6);
  595. D2Bot.CDKeyDisabled();
  596.  
  597. if (gameInfo.switchKeys) {
  598. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  599. D2Bot.restart(true);
  600. } else {
  601. D2Bot.stop();
  602. }
  603.  
  604. break;
  605. case getLocaleString(10913):
  606. D2Bot.updateStatus("Disabled LoD CDKey");
  607. D2Bot.printToConsole("Disabled LoD CDKey: " + gameInfo.mpq, 6);
  608. D2Bot.CDKeyDisabled();
  609.  
  610. if (gameInfo.switchKeys) {
  611. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  612. D2Bot.restart(true);
  613. } else {
  614. D2Bot.stop();
  615. }
  616.  
  617. break;
  618. case getLocaleString(5347):
  619. D2Bot.updateStatus("Disconnected");
  620. D2Bot.printToConsole("Disconnected");
  621. ControlAction.click(6, 335, 412, 128, 35);
  622.  
  623. break MainSwitch;
  624. default:
  625. D2Bot.updateStatus("Login Error");
  626. D2Bot.printToConsole("Login Error - " + string);
  627.  
  628. if (gameInfo.switchKeys) {
  629. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  630. D2Bot.restart(true);
  631. } else {
  632. D2Bot.stop();
  633. }
  634.  
  635. break;
  636. }
  637. }
  638.  
  639. ControlAction.click(6, 335, 412, 128, 35);
  640.  
  641. while (true) {
  642. delay(1000);
  643. }
  644.  
  645. break;
  646. case 11: // Unable To Connect
  647. D2Bot.updateStatus("Unable To Connect");
  648.  
  649. if (connectFail) {
  650. timeoutDelay("Unable to Connect", StarterConfig.UnableToConnectDelay * 6e4);
  651.  
  652. connectFail = false;
  653. }
  654.  
  655. if (!ControlAction.click(6, 335, 450, 128, 35)) {
  656. break;
  657. }
  658.  
  659. connectFail = true;
  660.  
  661. break;
  662. case 13: // Realm Down - Character Select screen
  663. D2Bot.updateStatus("Realm Down");
  664. delay(1000);
  665.  
  666. if (!ControlAction.click(6, 33, 572, 128, 35)) {
  667. break;
  668. }
  669.  
  670. updateCount();
  671. timeoutDelay("Realm Down", StarterConfig.RealmDownDelay * 6e4);
  672. D2Bot.CDKeyRD();
  673.  
  674. if (gameInfo.switchKeys) {
  675. D2Bot.printToConsole("Realm Down - Changing CD-Key");
  676. timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  677. D2Bot.restart(true);
  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. break;
  686. case 16: // Character Select - Please Wait popup
  687. if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) {
  688. ControlAction.click(6, 351, 337, 96, 32);
  689. }
  690.  
  691. break;
  692. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  693. delay(1000);
  694. ControlAction.click(6, 351, 337, 96, 32);
  695. break;
  696. case 19: // Login - Cdkey In Use
  697. D2Bot.printToConsole(gameInfo.mpq + " is in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
  698. D2Bot.CDKeyInUse();
  699.  
  700. if (gameInfo.switchKeys) {
  701. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  702. D2Bot.restart(true);
  703. } else {
  704. ControlAction.click(6, 335, 450, 128, 35);
  705. ControlAction.timeoutDelay("CD-Key in use", StarterConfig.CDKeyInUseDelay * 6e4);
  706. }
  707.  
  708. break;
  709. case 20: // Single Player - Select Difficulty
  710. break;
  711. case 21: // Main Menu - Connecting
  712. if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
  713. ControlAction.click(6, 330, 416, 128, 35);
  714. }
  715.  
  716. break;
  717. case 22: // Login - Invalid Cdkey (classic or xpac)
  718. text = ControlAction.getText(4, 162, 270, 477, 50);
  719. string = "";
  720.  
  721. if (text) {
  722. for (i = 0; i < text.length; i += 1) {
  723. string += text[i];
  724.  
  725. if (i !== text.length - 1) {
  726. string += " ";
  727. }
  728. }
  729. }
  730.  
  731. switch (string) {
  732. case getLocaleString(10914):
  733. D2Bot.printToConsole(gameInfo.mpq + " LoD key in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
  734. D2Bot.CDKeyInUse();
  735.  
  736. if (gameInfo.switchKeys) {
  737. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  738. D2Bot.restart(true);
  739. } else {
  740. ControlAction.click(6, 335, 450, 128, 35);
  741. ControlAction.timeoutDelay("LoD key in use", StarterConfig.CDKeyInUseDelay * 6e4);
  742. }
  743.  
  744. break;
  745. default:
  746. if (gameInfo.switchKeys) {
  747. D2Bot.printToConsole("Invalid CD-Key");
  748. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  749. D2Bot.restart(true);
  750. } else {
  751. ControlAction.click(6, 335, 450, 128, 35);
  752. ControlAction.timeoutDelay("Invalid CD-Key", StarterConfig.CDKeyInUseDelay * 6e4);
  753. }
  754.  
  755. break;
  756. }
  757.  
  758. break;
  759. case 23: // Character Select - Connecting
  760. case 42: // Empty character screen
  761. string = "";
  762. text = ControlAction.getText(4, 45, 318, 531, 140);
  763.  
  764. if (text) {
  765. for (i = 0; i < text.length; i += 1) {
  766. string += text[i];
  767.  
  768. if (i !== text.length - 1) {
  769. string += " ";
  770. }
  771. }
  772.  
  773. if (string === getLocaleString(11161)) { // CDKey disabled from realm play
  774. D2Bot.updateStatus("Realm Disabled CDKey");
  775. D2Bot.printToConsole("Realm Disabled CDKey: " + gameInfo.mpq, 6);
  776. D2Bot.CDKeyDisabled();
  777.  
  778. if (gameInfo.switchKeys) {
  779. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  780. D2Bot.restart(true);
  781. } else {
  782. D2Bot.stop();
  783. }
  784. }
  785. }
  786.  
  787. if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
  788. ControlAction.click(6, 33, 572, 128, 35);
  789.  
  790. if (gameInfo.rdBlocker) {
  791. D2Bot.restart();
  792. }
  793. }
  794.  
  795. break;
  796. case 24: // Server Down - not much to do but wait..
  797. break;
  798. case 25: // Lobby - Please Wait
  799. if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) {
  800. ControlAction.click(6, 351, 337, 96, 32);
  801. }
  802.  
  803. break;
  804. case 26: // Lobby - Game Name Exists
  805. break;
  806. case 27: // Gateway Select
  807. ControlAction.click(6, 436, 538, 96, 32);
  808.  
  809. break;
  810. case 28: // Lobby - Game Does Not Exist
  811. //D2Bot.printToConsole("Game doesn't exist");
  812. ControlAction.click(6, 652, 469, 120, 20);
  813. ControlAction.click(6, 433, 433, 96, 32);
  814. timeoutDelay("Game doesn't exist", StarterConfig.GameDoesNotExistTimeout * 1e3);
  815.  
  816. lastGameStatus = "DNE";
  817.  
  818. break;
  819. case 38: // Game is full
  820. badGames.push(joinInfo.gameName);
  821. ControlAction.click(6, 652, 469, 120, 20);
  822. ControlAction.click(6, 433, 433, 96, 32);
  823.  
  824. lastGameStatus = "FULL";
  825.  
  826. break;
  827. default:
  828. if (location !== undefined) {
  829. D2Bot.printToConsole("Unhandled location " + location);
  830. delay(500);
  831. D2Bot.restart();
  832. }
  833.  
  834. break;
  835. }
  836. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement