Advertisement
Guest User

Untitled

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