Advertisement
Guest User

Untitled

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