Advertisement
gtoilet

d2classic follow.dbj

Feb 19th, 2017
187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 19.99 KB | None | 0 0
  1. var StarterConfig = {
  2. JoinChannel: "op darjkeel", // Name of the channel to join
  3. FirstJoinMessage: "", // Message to say when first joining a channel, usually ".login"
  4. ChatActionsDelay: 12, // Seconds to wait in lobby before entering a channel
  5.  
  6. JoinRetryDelay: 15, // 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: 5, // 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: 45, // Seconds to wait before cancelling the 'Connecting...' screen
  14. PleaseWaitTimeout: 45, // Seconds to wait before cancelling the 'Please Wait...' screen
  15. WaitInLineTimeout: 180, // Seconds to wait before cancelling the 'Waiting in Line...' screen
  16. GameDoesNotExistTimeout: 45 // Seconds to wait before cancelling the 'Game does not exist.' screen
  17. };
  18.  
  19. /* Join game settings
  20. Format: "leader's profile": ["leecher 1 profile", "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. "lead1": ["follow1", "follow2"],
  27. "lead2": ["follow3", "follow4"]
  28. };
  29. */
  30.  
  31. var JoinSettings = {
  32. "barb": ["sorc"]
  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. "Profile Name": {JoinDelay: number_of_seconds}
  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. // No touchy!
  54. include("json2.js");
  55. include("OOG.js");
  56. include("automule.js");
  57. include("gambling.js");
  58. include("craftingsystem.js");
  59. include("torchsystem.js");
  60. include("common/misc.js");
  61.  
  62. var i, j, gameInfo, joinInfo, gameStart, ingame, handle,
  63. firstLogin, chatActionsDone, lastGameTick, connectFail,
  64. gameCount = DataFile.getStats().runs + 1,
  65. loginRetry = 0,
  66. lastGameStatus = "ready",
  67. leader = "",
  68. lastGame = [];
  69.  
  70. if (!FileTools.exists("data/" + me.profile + ".json")) {
  71. DataFile.create();
  72. }
  73.  
  74. function locationTimeout (time, location) {
  75. var endtime = getTickCount() + time;
  76.  
  77. while (!me.ingame && getLocation() === location && endtime > getTickCount()) {
  78. delay(500);
  79. }
  80.  
  81. return (getLocation() !== location);
  82. }
  83.  
  84. function updateCount () {
  85. D2Bot.updateCount();
  86. delay(1000);
  87. ControlAction.click(6, 264, 366, 272, 35);
  88.  
  89. try {
  90. login(me.profile);
  91. } catch (e) {
  92.  
  93. }
  94.  
  95. delay(1000);
  96. ControlAction.click(6, 33, 572, 128, 35);
  97. }
  98.  
  99. function ScriptMsgEvent (msg) {
  100. switch (msg) {
  101. case "mule":
  102. AutoMule.check = true;
  103.  
  104. break;
  105. case "muleTorch":
  106. AutoMule.torchCheck = true;
  107.  
  108. break;
  109. case "torch":
  110. TorchSystem.check = true;
  111.  
  112. break;
  113. case "crafting":
  114. CraftingSystem.check = true;
  115.  
  116. break;
  117. case "getMuleMode":
  118. if (AutoMule.torchAnniCheck === 2) {
  119. scriptBroadcast("2");
  120. } else if (AutoMule.torchAnniCheck === 1) {
  121. scriptBroadcast("1");
  122. } else if (AutoMule.check) {
  123. scriptBroadcast("0");
  124. }
  125.  
  126. break;
  127. }
  128. }
  129.  
  130. function ReceiveCopyData (mode, msg) {
  131. var obj;
  132.  
  133. switch (msg) {
  134. case "Handle":
  135. handle = mode;
  136.  
  137. break;
  138. }
  139.  
  140. switch (mode) {
  141. case 1: // JoinInfo
  142. //print("Got Join Info");
  143.  
  144. joinInfo = JSON.parse(msg);
  145.  
  146. break;
  147. case 2: // Game info
  148. print("Recieved Game Info");
  149.  
  150. gameInfo = JSON.parse(msg);
  151.  
  152. break;
  153. case 3: // Game request
  154. // Don't let others join mule/torch/key/gold drop game
  155. if (AutoMule.inGame || Gambling.inGame || TorchSystem.inGame || CraftingSystem.inGame) {
  156. break;
  157. }
  158.  
  159. if (gameInfo) {
  160. obj = JSON.parse(msg);
  161.  
  162. D2Bot.joinMe(obj.profile, me.gamename || "", "", me.gamepassword || "", me.gameReady ? "yes" : "no");
  163. }
  164.  
  165. break;
  166. case 4:
  167. // Heartbeat ping
  168. if (msg === "pingreq") {
  169. sendCopyData(null, me.windowtitle, 4, "pingrep");
  170. }
  171.  
  172. break;
  173. }
  174. }
  175.  
  176. function timer (tick) {
  177. if (!tick) {
  178. return "";
  179. }
  180.  
  181. var min, sec;
  182.  
  183. min = Math.floor((getTickCount() - tick) / 60000).toString();
  184.  
  185. if (min <= 9) {
  186. min = "0" + min;
  187. }
  188.  
  189. sec = (Math.floor((getTickCount() - tick) / 1000) % 60).toString();
  190.  
  191. if (sec <= 9) {
  192. sec = "0" + sec;
  193. }
  194.  
  195. return " (" + min + ":" + sec + ")";
  196. }
  197.  
  198. function main () {
  199. debugLog(me.profile);
  200. addEventListener('copydata', ReceiveCopyData);
  201. addEventListener('scriptmsg', ScriptMsgEvent);
  202.  
  203. while (!handle) {
  204. delay(100);
  205. }
  206.  
  207. DataFile.updateStats("handle", handle);
  208. D2Bot.init();
  209. load("tools/heartbeat.js");
  210.  
  211. while (!gameInfo) {
  212. D2Bot.requestGameInfo();
  213. delay(500);
  214. }
  215.  
  216. if (gameInfo.error) {
  217. //D2Bot.retrieve();
  218. delay(200);
  219.  
  220. if (!!DataFile.getStats().debugInfo) {
  221. gameInfo.crashInfo = DataFile.getStats().debugInfo;
  222.  
  223. D2Bot.printToConsole("Crash Info: Script: " + JSON.parse(gameInfo.crashInfo).currScript + " Area: " + JSON.parse(gameInfo.crashInfo).area, 10);
  224. }
  225.  
  226. /*if (gameInfo.crashInfo) {
  227. D2Bot.printToConsole("Crash Info: Script: " + gameInfo.crashInfo.currScript + " Area: " + gameInfo.crashInfo.area + (gameInfo.crashInfo.hasOwnProperty("lastAction") ? " " + gameInfo.crashInfo.lastAction : ""), 10);
  228. }*/
  229.  
  230. ControlAction.timeoutDelay("Crash Delay", StarterConfig.CrashDelay * 1e3);
  231. D2Bot.updateRuns();
  232. }
  233.  
  234. //D2Bot.store(JSON.stringify({currScript: "none", area: "out of game"}));
  235. DataFile.updateStats("debugInfo", JSON.stringify({currScript: "none", area: "out of game"}));
  236.  
  237. while (true) {
  238. while (me.ingame) { // returns true before actually in game so we can't only use this check
  239. if (me.gameReady) { // returns false when switching acts so we can't use while
  240. if (!ingame) {
  241. print("ÿc4Updating Status");
  242. //D2Bot.updateStatus("Game: " + me.gamename);
  243.  
  244. lastGameStatus = "ingame";
  245. ingame = true;
  246. gameStart = getTickCount();
  247.  
  248. DataFile.updateStats("runs", gameCount);
  249. }
  250.  
  251. D2Bot.updateStatus("Game: " + me.gamename + timer(gameStart));
  252. }
  253.  
  254. delay(1000);
  255. }
  256.  
  257. locationAction();
  258. delay(1000);
  259. }
  260. }
  261.  
  262. function joinCheck (leader) {
  263. D2Bot.requestGame(leader);
  264. delay(500);
  265.  
  266. //print(leader + " " + joinInfo.inGame + " " + lastGame.toSource() + " " + joinInfo.gameName);
  267.  
  268. if (!joinInfo.inGame || (lastGame.length && lastGame.indexOf(joinInfo.gameName) === -1)) {
  269. D2Bot.printToConsole("Game is finished. Stopping join delay.");
  270.  
  271. return true;
  272. }
  273.  
  274. return false;
  275. }
  276.  
  277. function locationAction () {
  278. if (me.ingame) {
  279. return;
  280. }
  281.  
  282. var i, string, control, text, location;
  283.  
  284. location = getLocation();
  285.  
  286. MainSwitch:
  287. switch (location) {
  288. case 0:
  289. ControlAction.click(6, 264, 266, 272, 35);
  290.  
  291. break;
  292. case 1: // Lobby
  293. D2Bot.updateStatus("Lobby");
  294.  
  295. me.blockKeys = false;
  296. loginRetry = 0;
  297.  
  298. if (!firstLogin) {
  299. firstLogin = true;
  300. }
  301.  
  302. if (StarterConfig.JoinChannel !== "") {
  303. ControlAction.click(6, 27, 480, 120, 20);
  304.  
  305. break;
  306. }
  307.  
  308. if (ingame) {
  309. if (AutoMule.outOfGameCheck() || TorchSystem.outOfGameCheck() || Gambling.outOfGameCheck() || CraftingSystem.outOfGameCheck()) {
  310. break;
  311. }
  312.  
  313. print("updating runs");
  314. D2Bot.updateRuns();
  315.  
  316. lastGameTick = getTickCount();
  317. gameCount += 1;
  318. lastGameStatus = "ready";
  319. ingame = false;
  320. }
  321.  
  322. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  323. break;
  324. }
  325.  
  326. if (!locationTimeout(5000, location)) { // in case join button gets bugged
  327. if (!ControlAction.click(6, 533, 469, 120, 20)) { // Create
  328. break;
  329. }
  330.  
  331. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  332. break;
  333. }
  334. }
  335.  
  336. break;
  337. case 2: // Waiting In Line
  338. D2Bot.updateStatus("Waiting...");
  339. locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location);
  340. ControlAction.click(6, 433, 433, 96, 32);
  341.  
  342. break;
  343. case 3: // Lobby Chat
  344. D2Bot.updateStatus("Lobby Chat");
  345.  
  346. if (ingame) {
  347. if (AutoMule.outOfGameCheck() || TorchSystem.outOfGameCheck() || Gambling.outOfGameCheck() || CraftingSystem.outOfGameCheck()) {
  348. break;
  349. }
  350.  
  351. print("updating runs");
  352. D2Bot.updateRuns();
  353.  
  354. lastGameTick = getTickCount();
  355. gameCount += 1;
  356. lastGameStatus = "ready";
  357. ingame = false;
  358. }
  359.  
  360. if (!chatActionsDone) {
  361. chatActionsDone = true;
  362.  
  363. ControlAction.timeoutDelay("Chat delay", StarterConfig.ChatActionsDelay * 1e3);
  364. say("/j " + StarterConfig.JoinChannel);
  365. delay(1000);
  366.  
  367. if (StarterConfig.FirstJoinMessage !== "") {
  368. say(StarterConfig.FirstJoinMessage);
  369. delay(500);
  370. }
  371. }
  372.  
  373. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  374. break;
  375. }
  376.  
  377. if (!locationTimeout(5000, location)) { // in case join button gets bugged
  378. if (!ControlAction.click(6, 533, 469, 120, 20)) { // Create
  379. break;
  380. }
  381.  
  382. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  383. break;
  384. }
  385. }
  386.  
  387. break;
  388. case 4: // Create Game
  389. break;
  390. case 5: // Join Game
  391. D2Bot.updateStatus("Join Game");
  392.  
  393. if (!leader) {
  394. leader = [];
  395.  
  396. for (i in JoinSettings) {
  397. if (JoinSettings.hasOwnProperty(i) && typeof i === "string") {
  398. for (j = 0; j < JoinSettings[i].length; j += 1) {
  399. if (JoinSettings[i][j] === me.profile || JoinSettings[i][j] === "all") {
  400. leader.push(i);
  401. }
  402. }
  403. }
  404. }
  405. }
  406.  
  407. if (!leader || !leader.length) {
  408. break;
  409. }
  410.  
  411. JoinLoop2:
  412. for (i = 0; i < 5; i += 1) {
  413. for (j = 0; j < leader.length; j += 1) {
  414. joinInfo = false;
  415.  
  416. D2Bot.requestGame(leader[j]);
  417. delay(100);
  418.  
  419. if (joinInfo && joinInfo.gameName !== "" && (lastGame.indexOf(joinInfo.gameName) === -1 || lastGameStatus === "pending")) {
  420. ControlAction.setText(1, 606, 148, 155, 20, joinInfo.gamePass);
  421. ControlAction.setText(1, 432, 148, 155, 20, joinInfo.gameName);
  422.  
  423. if (lastGameStatus === "pending" || (gameInfo.error && DataFile.getStats().gameName === joinInfo.gameName)) {
  424. D2Bot.printToConsole("Failed to join game");
  425. ControlAction.timeoutDelay("Join Delay", StarterConfig.JoinRetryDelay * 1000, joinCheck, leader[j]);
  426. D2Bot.updateRuns();
  427. D2Bot.requestGame(leader[j]);
  428. delay(200);
  429.  
  430. if (!joinInfo.inGame) {
  431. lastGameStatus = "ready";
  432.  
  433. break;
  434. }
  435. }
  436.  
  437. if (!joinInfo.inGame) {
  438. continue;
  439. }
  440.  
  441. // Don't join immediately after previous game to avoid FTJ
  442. if (getTickCount() - lastGameTick < 5000) {
  443. ControlAction.timeoutDelay("Game Delay", (lastGameTick - getTickCount() + 5000));
  444. }
  445.  
  446. print("joining game " + joinInfo.gameName);
  447.  
  448. if (typeof AdvancedConfig[me.profile] === "object" && typeof AdvancedConfig[me.profile].JoinDelay === "number") {
  449. ControlAction.timeoutDelay("Custom Join Delay", AdvancedConfig[me.profile].JoinDelay * 1e3);
  450. }
  451.  
  452. me.blockMouse = true;
  453.  
  454. DataFile.updateStats("gameName", joinInfo.gameName);
  455. ControlAction.click(6, 594, 433, 172, 32);
  456.  
  457. me.blockMouse = false;
  458.  
  459. lastGame.push(joinInfo.gameName);
  460.  
  461. if (lastGame.length > leader.length) { // Might need a fixed number. Right now it stores 1 game per leader.
  462. lastGame.shift();
  463. }
  464.  
  465. lastGameStatus = "pending";
  466.  
  467. locationTimeout(15000, location);
  468.  
  469. break JoinLoop2;
  470. }
  471. }
  472. }
  473.  
  474. break;
  475. case 6: // Ladder
  476. break;
  477. case 7: // Channel List
  478. break;
  479. case 8: // Main Menu
  480. case 9: // Login
  481. case 15: // Character Select
  482. case 18: // D2 Splash
  483. // Single Player screen fix
  484. if (getLocation() === 15 && !getControl(4, 634, 555, 29, 20)) {
  485. delay(3100);
  486. ControlAction.click(4, 514, 339, 200, 92);
  487. delay(100);
  488. ControlAction.click(6, 353, 572, 128, 35);
  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() === 15 && 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