Advertisement
Guest User

Untitled

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