Advertisement
Guest User

Untitled

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