Advertisement
gtoilet

d2bclassic lead.dbj

Feb 19th, 2017
181
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.09 KB | None | 0 0
  1. var StarterConfig = {
  2. MinGameTime: 120, // Minimum game length in seconds. If a game is ended too soon, the rest of the time is waited in the lobby
  3. PingQuitDelay: 30, // Time in seconds to wait in lobby after quitting due to high ping
  4. CreateGameDelay: 20, // Seconds to wait before creating a new game
  5. ResetCount: 999, // Reset game count back to 1 every X games.
  6. CharacterDifference: 99, // Character level difference. Set to false to disable character difference.
  7. ChatActionsDelay: 14, // Seconds to wait in lobby before entering a channel
  8.  
  9. // ChannelConfig can override these options for individual profiles.
  10. JoinChannel: "op darjkeel", // Default channel. Can be an array of channels - ["channel 1", "channel 2"]
  11. FirstJoinMessage: "", // Default join message. Can be an array of messages
  12. AnnounceGames: false, // Default value
  13. AfterGameMessage: "", // Default message after a finished game. Can be an array of messages
  14.  
  15. SwitchKeyDelay: 15, // Seconds to wait before switching a used/banned key or after realm down
  16. CrashDelay: 25, // Seconds to wait after a d2 window crash
  17. FTJDelay: 45, // Seconds to wait after failing to create a game
  18. RealmDownDelay: 5, // Minutes to wait after getting Realm Down message
  19. UnableToConnectDelay: 5, // Minutes to wait after Unable To Connect message
  20. CDKeyInUseDelay: 5, // Minutes to wait before connecting again if CD-Key is in use.
  21. ConnectingTimeout: 50, // Seconds to wait before cancelling the 'Connecting...' screen
  22. PleaseWaitTimeout: 40, // Seconds to wait before cancelling the 'Please Wait...' screen
  23. WaitInLineTimeout: 180, // Seconds to wait before cancelling the 'Waiting in Line...' screen
  24. GameDoesNotExistTimeout: 45 // Seconds to wait before cancelling the 'Game does not exist.' screen
  25. };
  26.  
  27. var ChannelConfig = {
  28. /* Override default values for JoinChannel, FirstJoinMessage, AnnounceGames and AfterGameMessage per profile
  29. It's possible to override any number of these options (you don't have to put all of them)
  30.  
  31. **** DO NOT EDIT ANYTHING INSIDE THIS COMMENT BLOCK ***
  32.  
  33. Format:
  34.  
  35. "Profile Name": {
  36. JoinChannel: "channel name", -OR- ["channel 1", "channel 2"],
  37. FirstJoinMessage: "first message", -OR- ["join msg 1", "join msg 2"],
  38. AnnounceGames: true,
  39. AfterGameMessage: "message after a finished run" -OR- ["msg 1", msg 2"]
  40. }
  41.  
  42. Multiple entries are separated by a comma
  43.  
  44. Examples:
  45.  
  46. "Profile 1": {
  47. JoinChannel: "my channel",
  48. FirstJoinMessage: ".login",
  49. AnnounceGames: true,
  50. AfterGameMessage: "follow my runs or die"
  51. },
  52. "Profile 2": {
  53. JoinChannel: ["channel 1", "channel 2"],
  54. FirstJoinMessage: [".login", "^login"],
  55. AfterGameMessage: ["follow my runs or die", "seriously, you'll die"]
  56. }
  57. */
  58.  
  59. // Add your lines here
  60.  
  61. };
  62.  
  63.  
  64.  
  65. // No touchy!
  66. include("json2.js");
  67. include("OOG.js");
  68. include("automule.js");
  69. include("gambling.js");
  70. include("craftingsystem.js");
  71. include("torchsystem.js");
  72. include("common/misc.js");
  73.  
  74. if (!FileTools.exists("data/" + me.profile + ".json")) {
  75. DataFile.create();
  76. }
  77.  
  78. var gameInfo, gameStart, ingame, chatActionsDone, pingQuit,
  79. handle, useChat, firstLogin, connectFail,
  80. gameCount = DataFile.getStats().runs + 1,
  81. loginRetry = 0,
  82. lastGameStatus = "ready",
  83. isUp = "no",
  84. chanInfo = {
  85. joinChannel: "",
  86. firstMsg: "",
  87. afterMsg: "",
  88. announce: false
  89. };
  90.  
  91. function sayMsg(string) {
  92. if (!useChat) {
  93. return;
  94. }
  95.  
  96. say(string);
  97. }
  98.  
  99. function ReceiveCopyData(mode, msg) {
  100. var obj;
  101.  
  102. switch (msg) {
  103. case "Handle":
  104. handle = mode;
  105.  
  106. break;
  107. }
  108.  
  109. switch (mode) {
  110. case 2: // Game info
  111. print("Recieved Game Info");
  112.  
  113. gameInfo = JSON.parse(msg);
  114.  
  115. break;
  116. case 3: // Game request
  117. // Don't let others join mule/torch/key/gold drop game
  118. if (AutoMule.inGame || Gambling.inGame || TorchSystem.inGame || CraftingSystem.inGame) {
  119. break;
  120. }
  121.  
  122. if (gameInfo) {
  123. obj = JSON.parse(msg);
  124.  
  125. if (me.gameReady) {
  126. D2Bot.joinMe(obj.profile, me.gamename.toLowerCase(), "", me.gamepassword.toLowerCase(), isUp);
  127. } else {
  128. D2Bot.joinMe(obj.profile, gameInfo.gameName.toLowerCase(), gameCount, gameInfo.gamePass.toLowerCase(), isUp);
  129. }
  130. }
  131.  
  132. break;
  133. case 4: // Heartbeat ping
  134. if (msg === "pingreq") {
  135. sendCopyData(null, me.windowtitle, 4, "pingrep");
  136. }
  137.  
  138. break;
  139. case 0xf124: // Cached info retreival
  140. if (msg !== "null") {
  141. gameInfo.crashInfo = JSON.parse(msg);
  142. }
  143.  
  144. break;
  145. }
  146. }
  147.  
  148. function setNextGame() {
  149. var nextGame = gameInfo.gameName;
  150.  
  151. if (StarterConfig.ResetCount && gameCount + 1 >= StarterConfig.ResetCount) {
  152. nextGame += 1;
  153. } else {
  154. nextGame += (gameCount + 1);
  155. }
  156.  
  157. DataFile.updateStats("nextGame", nextGame);
  158. }
  159.  
  160. function locationTimeout(time, location) {
  161. var endtime = getTickCount() + time;
  162.  
  163. while (getLocation() === location && endtime > getTickCount()) {
  164. delay(500);
  165. }
  166.  
  167. return (getLocation() !== location);
  168. }
  169.  
  170. function updateCount() {
  171. D2Bot.updateCount();
  172. delay(1000);
  173. ControlAction.click(6, 264, 366, 272, 35);
  174.  
  175. try {
  176. login(me.profile);
  177. } catch (e) {
  178.  
  179. }
  180.  
  181. delay(1000);
  182. ControlAction.click(6, 33, 572, 128, 35);
  183. }
  184.  
  185. function ScriptMsgEvent(msg) {
  186. switch (msg) {
  187. case "mule":
  188. AutoMule.check = true;
  189.  
  190. break;
  191. case "muleTorch":
  192. AutoMule.torchAnniCheck = 1;
  193.  
  194. break;
  195. case "muleAnni":
  196. AutoMule.torchAnniCheck = 2;
  197.  
  198. break;
  199. case "torch":
  200. TorchSystem.check = true;
  201.  
  202. break;
  203. case "crafting":
  204. CraftingSystem.check = true;
  205.  
  206. break;
  207. case "getMuleMode":
  208. if (AutoMule.torchAnniCheck === 2) {
  209. scriptBroadcast("2");
  210. } else if (AutoMule.torchAnniCheck === 1) {
  211. scriptBroadcast("1");
  212. } else if (AutoMule.check) {
  213. scriptBroadcast("0");
  214. }
  215.  
  216. break;
  217. case "pingquit":
  218. pingQuit = true;
  219.  
  220. break;
  221. }
  222. }
  223.  
  224. function timer(tick) {
  225. if (!tick) {
  226. return "";
  227. }
  228.  
  229. var min, sec;
  230.  
  231. min = Math.floor((getTickCount() - tick) / 60000).toString();
  232.  
  233. if (min <= 9) {
  234. min = "0" + min;
  235. }
  236.  
  237. sec = (Math.floor((getTickCount() - tick) / 1000) % 60).toString();
  238.  
  239. if (sec <= 9) {
  240. sec = "0" + sec;
  241. }
  242.  
  243. return " (" + min + ":" + sec + ")";
  244. }
  245.  
  246. function randomString(len, useNumbers = false) {
  247. var i, rval = "",
  248. letters = useNumbers ? "abcdefghijklmnopqrstuvwxyz0123456789" : "abcdefghijklmnopqrstuvwxyz";
  249.  
  250. len = len ? len : rand(5, 14);
  251.  
  252. for (i = 0; i < len; i += 1) {
  253. rval += letters[rand(0, letters.length - 1)];
  254. }
  255.  
  256. return rval;
  257. }
  258.  
  259. function main() {
  260. debugLog(me.profile);
  261. addEventListener('copydata', ReceiveCopyData);
  262. addEventListener('scriptmsg', ScriptMsgEvent);
  263.  
  264. while (!handle) {
  265. delay(100);
  266. }
  267.  
  268. DataFile.updateStats("handle", handle);
  269. delay(500);
  270. D2Bot.init();
  271. load("tools/heartbeat.js");
  272.  
  273. while (!gameInfo) {
  274. D2Bot.requestGameInfo();
  275. delay(500);
  276. }
  277.  
  278. if (gameInfo.error) {
  279. //D2Bot.retrieve();
  280. delay(200);
  281.  
  282. if (!!DataFile.getStats().debugInfo) {
  283. gameInfo.crashInfo = DataFile.getStats().debugInfo;
  284.  
  285. D2Bot.printToConsole("Crash Info: Script: " + JSON.parse(gameInfo.crashInfo).currScript + " Area: " + JSON.parse(gameInfo.crashInfo).area, 10);
  286. }
  287.  
  288. /*if (gameInfo.crashInfo) {
  289. D2Bot.printToConsole("Crash Info: Script: " + gameInfo.crashInfo.currScript + " Area: " + gameInfo.crashInfo.area + (gameInfo.crashInfo.hasOwnProperty("lastAction") ? " " + gameInfo.crashInfo.lastAction : ""), 10);
  290. }*/
  291.  
  292. ControlAction.timeoutDelay("Crash Delay", StarterConfig.CrashDelay * 1e3);
  293. D2Bot.updateRuns();
  294. }
  295.  
  296. //D2Bot.store(JSON.stringify({currScript: "none", area: "out of game"}));
  297. DataFile.updateStats("debugInfo", JSON.stringify({currScript: "none", area: "out of game"}));
  298.  
  299. while (true) {
  300. while (me.ingame) { // returns true before actually in game so we can't only use this check
  301. if (me.gameReady) { // returns false when switching acts so we can't use while
  302. isUp = "yes";
  303.  
  304. if (!ingame) {
  305. gameStart = getTickCount();
  306.  
  307. print("Updating Status");
  308. //D2Bot.updateStatus("Game: " + me.gamename);
  309.  
  310. lastGameStatus = "ingame";
  311. ingame = true;
  312.  
  313. DataFile.updateStats("runs", gameCount);
  314. DataFile.updateStats("ingameTick");
  315. }
  316.  
  317. D2Bot.updateStatus("Game: " + me.gamename + timer(gameStart));
  318. }
  319.  
  320. delay(1000);
  321. }
  322.  
  323. isUp = "no";
  324.  
  325. locationAction(getLocation());
  326. delay(1000);
  327. }
  328. }
  329.  
  330. function locationAction(location) {
  331. var i, control, string, text;
  332.  
  333. MainSwitch:
  334. switch (location) {
  335. case 0:
  336. ControlAction.click(6, 264, 266, 272, 35);
  337.  
  338. break;
  339. case 1: // Lobby
  340. D2Bot.updateStatus("Lobby");
  341.  
  342. me.blockKeys = false;
  343. loginRetry = 0;
  344.  
  345. if (!firstLogin) {
  346. firstLogin = true;
  347. }
  348.  
  349. if (lastGameStatus === "pending") {
  350. gameCount += 1;
  351. }
  352.  
  353. if (StarterConfig.PingQuitDelay && pingQuit) {
  354. ControlAction.timeoutDelay("Ping Delay", StarterConfig.PingQuitDelay * 1e3);
  355.  
  356. pingQuit = false;
  357. }
  358.  
  359. if (StarterConfig.JoinChannel !== "" || (ChannelConfig[me.profile] && ChannelConfig[me.profile].JoinChannel !== "")) {
  360. ControlAction.click(6, 27, 480, 120, 20);
  361.  
  362. break;
  363. }
  364.  
  365. if (ingame || gameInfo.error) {
  366. if (!gameStart) {
  367. gameStart = DataFile.getStats().ingameTick;
  368. }
  369.  
  370. if (getTickCount() - gameStart < StarterConfig.MinGameTime * 1e3) {
  371. ControlAction.timeoutDelay("Min game time wait", StarterConfig.MinGameTime * 1e3 + gameStart - getTickCount());
  372. }
  373. }
  374.  
  375. if (ingame) {
  376. //D2Bot.store(JSON.stringify({currScript: "none", area: "out of game"}));
  377.  
  378. if (AutoMule.outOfGameCheck() || TorchSystem.outOfGameCheck() || Gambling.outOfGameCheck() || CraftingSystem.outOfGameCheck()) {
  379. break;
  380. }
  381.  
  382. print("updating runs");
  383. D2Bot.updateRuns();
  384.  
  385. gameCount += 1;
  386. lastGameStatus = "ready";
  387. ingame = false;
  388.  
  389. if (StarterConfig.ResetCount && gameCount >= StarterConfig.ResetCount) {
  390. gameCount = 1;
  391.  
  392. DataFile.updateStats("runs", gameCount);
  393. }
  394. }
  395.  
  396. if (!ControlAction.click(6, 533, 469, 120, 20)) { // Create
  397. break;
  398. }
  399.  
  400. if (!locationTimeout(5000, location)) { // in case create button gets bugged
  401. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  402. break;
  403. }
  404.  
  405. if (!ControlAction.click(6, 533, 469, 120, 20)) { // Create
  406. break;
  407. }
  408. }
  409.  
  410. break;
  411. case 2: // Waiting In Line
  412. D2Bot.updateStatus("Waiting...");
  413. locationTimeout(StarterConfig.WaitInLineTimeout * 1e3, location);
  414. ControlAction.click(6, 433, 433, 96, 32);
  415.  
  416. break;
  417. case 3: // Lobby Chat
  418. D2Bot.updateStatus("Lobby Chat");
  419.  
  420. if (lastGameStatus === "pending") {
  421. gameCount += 1;
  422. }
  423.  
  424. if (ingame || gameInfo.error) {
  425. if (!gameStart) {
  426. gameStart = DataFile.getStats().ingameTick;
  427. }
  428.  
  429. if (getTickCount() - gameStart < StarterConfig.MinGameTime * 1e3) {
  430. ControlAction.timeoutDelay("Min game time wait", StarterConfig.MinGameTime * 1e3 + gameStart - getTickCount());
  431. }
  432. }
  433.  
  434. if (ingame) {
  435. //D2Bot.store(JSON.stringify({currScript: "none", area: "out of game"}));
  436.  
  437. if (AutoMule.outOfGameCheck() || TorchSystem.outOfGameCheck() || Gambling.outOfGameCheck() || CraftingSystem.outOfGameCheck()) {
  438. break;
  439. }
  440.  
  441. print("updating runs");
  442. D2Bot.updateRuns();
  443.  
  444. gameCount += 1;
  445. lastGameStatus = "ready";
  446. ingame = false;
  447.  
  448. if (StarterConfig.ResetCount && gameCount >= StarterConfig.ResetCount) {
  449. gameCount = 1;
  450.  
  451. DataFile.updateStats("runs", gameCount);
  452. }
  453.  
  454. if (ChannelConfig[me.profile] && ChannelConfig[me.profile].hasOwnProperty("AfterGameMessage")) {
  455. chanInfo.afterMsg = ChannelConfig[me.profile].AfterGameMessage;
  456. } else {
  457. chanInfo.afterMsg = StarterConfig.AfterGameMessage;
  458. }
  459.  
  460. if (chanInfo.afterMsg) {
  461. if (typeof chanInfo.afterMsg === "string") {
  462. chanInfo.afterMsg = [chanInfo.afterMsg];
  463. }
  464.  
  465. for (i = 0; i < chanInfo.afterMsg.length; i += 1) {
  466. sayMsg(chanInfo.afterMsg[i]);
  467. delay(500);
  468. }
  469. }
  470. }
  471.  
  472. if (!chatActionsDone) {
  473. chatActionsDone = true;
  474.  
  475. if (ChannelConfig[me.profile] && ChannelConfig[me.profile].hasOwnProperty("JoinChannel")) {
  476. chanInfo.joinChannel = ChannelConfig[me.profile].JoinChannel;
  477. } else {
  478. chanInfo.joinChannel = StarterConfig.JoinChannel;
  479. }
  480.  
  481. if (ChannelConfig[me.profile] && ChannelConfig[me.profile].hasOwnProperty("FirstJoinMessage")) {
  482. chanInfo.firstMsg = ChannelConfig[me.profile].FirstJoinMessage;
  483. } else {
  484. chanInfo.firstMsg = StarterConfig.FirstJoinMessage;
  485. }
  486.  
  487. if (chanInfo.joinChannel) {
  488. if (typeof chanInfo.joinChannel === "string") {
  489. chanInfo.joinChannel = [chanInfo.joinChannel];
  490. }
  491.  
  492. if (typeof chanInfo.firstMsg === "string") {
  493. chanInfo.firstMsg = [chanInfo.firstMsg];
  494. }
  495.  
  496. for (i = 0; i < chanInfo.joinChannel.length; i += 1) {
  497. ControlAction.timeoutDelay("Chat delay", StarterConfig.ChatActionsDelay * 1e3);
  498.  
  499. if (ControlAction.joinChannel(chanInfo.joinChannel[i])) {
  500. useChat = true;
  501. } else {
  502. print("ÿc1Unable to join channel, disabling chat messages.");
  503.  
  504. useChat = false;
  505. }
  506.  
  507. if (chanInfo.firstMsg[i] !== "") {
  508. sayMsg(chanInfo.firstMsg[i]);
  509. delay(500);
  510. }
  511. }
  512. }
  513. }
  514.  
  515. // Announce game
  516. if (ChannelConfig[me.profile] && ChannelConfig[me.profile].hasOwnProperty("AnnounceGames")) {
  517. chanInfo.announce = ChannelConfig[me.profile].AnnounceGames;
  518. } else {
  519. chanInfo.announce = StarterConfig.AnnounceGames;
  520. }
  521.  
  522. if (chanInfo.announce) {
  523. sayMsg("Next game is " + gameInfo.gameName + gameCount + (gameInfo.gamePass === "" ? "" : "//" + gameInfo.gamePass));
  524. }
  525.  
  526. if (!ControlAction.click(6, 533, 469, 120, 20)) { // Create
  527. break;
  528. }
  529.  
  530. if (!locationTimeout(5000, location)) { // in case create button gets bugged
  531. if (!ControlAction.click(6, 652, 469, 120, 20)) { // Join
  532. break;
  533. }
  534.  
  535. if (!ControlAction.click(6, 533, 469, 120, 20)) { // Create
  536. break;
  537. }
  538. }
  539.  
  540. break;
  541. case 4: // Create Game
  542. D2Bot.updateStatus("Creating Game");
  543.  
  544. control = getControl(1, 657, 342, 27, 20);
  545.  
  546. // Set character difference
  547. if (typeof StarterConfig.CharacterDifference === "number") {
  548. if (control.disabled === 4) {
  549. ControlAction.click(6, 431, 341, 15, 16);
  550. }
  551.  
  552. ControlAction.setText(1, 657, 342, 27, 20, StarterConfig.CharacterDifference.toString());
  553. } else if (StarterConfig.CharacterDifference === false && control.disabled === 5) {
  554. ControlAction.click(6, 431, 341, 15, 16);
  555. }
  556.  
  557. // Get game name if there is none
  558. while (!gameInfo.gameName) {
  559. D2Bot.requestGameInfo();
  560. delay(500);
  561. }
  562.  
  563. // FTJ handler
  564. if (lastGameStatus === "pending") {
  565. isUp = "no";
  566.  
  567. D2Bot.printToConsole("Failed to create game");
  568. ControlAction.timeoutDelay("FTJ delay", StarterConfig.FTJDelay * 1e3);
  569. D2Bot.updateRuns();
  570. }
  571.  
  572. ControlAction.createGame((gameInfo.gameName === "?" ? randomString(null,true) : gameInfo.gameName + gameCount), (gameInfo.gamePass === "?" ? randomString(null,true) : gameInfo.gamePass), gameInfo.difficulty, StarterConfig.CreateGameDelay * 1000);
  573.  
  574. lastGameStatus = "pending";
  575.  
  576. setNextGame();
  577. locationTimeout(10000, location);
  578.  
  579. break;
  580. case 5: // Join Game
  581. break;
  582. case 6: // Ladder
  583. break;
  584. case 7: // Channel List
  585. break;
  586. case 8: // Main Menu
  587. case 9: // Login
  588. case 12: // Character Select
  589. case 15: // D2 Splash
  590. // Single Player screen fix
  591. if (getLocation() === 15 && !getControl(4, 634, 555, 29, 20)) {
  592. delay(3100);
  593. ControlAction.click(4, 514, 339, 200, 92);
  594. delay(100);
  595. ControlAction.click(6, 353, 572, 128, 35);
  596. break;
  597. }
  598.  
  599. if (firstLogin && getLocation() === 9) { // multiple realm botting fix in case of R/D or disconnect
  600. ControlAction.click(6, 33, 572, 128, 35);
  601. }
  602.  
  603. D2Bot.updateStatus("Logging In");
  604.  
  605. try {
  606. login(me.profile);
  607. } catch (e) {
  608. if (getLocation() === 15 && loginRetry < 2) {
  609. if (loginRetry === 0) {
  610. // start from beginning of the char list
  611. sendKey(0x24);
  612. }
  613.  
  614. control = getControl(4, 237, 457, 72, 93); // char on 1st column, 4th row
  615.  
  616. if (control) {
  617. me.blockMouse = true;
  618. me.blockKeys = true;
  619.  
  620. control.click();
  621. sendKey(0x28);
  622. sendKey(0x28);
  623. sendKey(0x28);
  624. sendKey(0x28);
  625.  
  626. me.blockMouse = false;
  627. }
  628.  
  629. loginRetry++;
  630. } else {
  631. me.blockKeys = false;
  632. print(e + " " + getLocation());
  633. }
  634. }
  635.  
  636. break;
  637. case 10: // Login Error
  638. string = "";
  639. text = ControlAction.getText(4, 199, 377, 402, 140);
  640.  
  641. if (text) {
  642. for (i = 0; i < text.length; i += 1) {
  643. string += text[i];
  644.  
  645. if (i !== text.length - 1) {
  646. string += " ";
  647. }
  648. }
  649.  
  650. switch (string) {
  651. case getLocaleString(5207):
  652. D2Bot.updateStatus("Invalid Password");
  653. D2Bot.printToConsole("Invalid Password");
  654.  
  655. break;
  656. case getLocaleString(5208):
  657. D2Bot.updateStatus("Invalid Account");
  658. D2Bot.printToConsole("Invalid Account");
  659.  
  660. break;
  661. case getLocaleString(5202): // cd key intended for another product
  662. case getLocaleString(10915): // lod key intended for another product
  663. D2Bot.updateStatus("Invalid CDKey");
  664. D2Bot.printToConsole("Invalid CDKey: " + gameInfo.mpq, 6);
  665. D2Bot.CDKeyDisabled();
  666.  
  667. if (gameInfo.switchKeys) {
  668. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  669. D2Bot.restart(true);
  670. } else {
  671. D2Bot.stop();
  672. }
  673.  
  674. break;
  675. case getLocaleString(5199):
  676. D2Bot.updateStatus("Disabled CDKey");
  677. D2Bot.printToConsole("Disabled CDKey: " + gameInfo.mpq, 6);
  678. D2Bot.CDKeyDisabled();
  679.  
  680. if (gameInfo.switchKeys) {
  681. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  682. D2Bot.restart(true);
  683. } else {
  684. D2Bot.stop();
  685. }
  686.  
  687. break;
  688. case getLocaleString(10913):
  689. D2Bot.updateStatus("Disabled LoD CDKey");
  690. D2Bot.printToConsole("Disabled LoD CDKey: " + gameInfo.mpq, 6);
  691. D2Bot.CDKeyDisabled();
  692.  
  693. if (gameInfo.switchKeys) {
  694. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  695. D2Bot.restart(true);
  696. } else {
  697. D2Bot.stop();
  698. }
  699.  
  700. break;
  701. case getLocaleString(5347):
  702. D2Bot.updateStatus("Disconnected");
  703. D2Bot.printToConsole("Disconnected");
  704. ControlAction.click(6, 335, 412, 128, 35);
  705.  
  706. break MainSwitch;
  707. default:
  708. D2Bot.updateStatus("Login Error");
  709. D2Bot.printToConsole("Login Error - " + string);
  710.  
  711. if (gameInfo.switchKeys) {
  712. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  713. D2Bot.restart(true);
  714. } else {
  715. D2Bot.stop();
  716. }
  717.  
  718. break;
  719. }
  720. }
  721.  
  722. ControlAction.click(6, 335, 412, 128, 35);
  723.  
  724. while (true) {
  725. delay(1000);
  726. }
  727.  
  728. break;
  729. case 11: // Unable To Connect
  730. D2Bot.updateStatus("Unable To Connect");
  731.  
  732. if (connectFail) {
  733. ControlAction.timeoutDelay("Unable to Connect", StarterConfig.UnableToConnectDelay * 6e4);
  734.  
  735. connectFail = false;
  736. }
  737.  
  738. if (!ControlAction.click(6, 335, 450, 128, 35)) {
  739. break;
  740. }
  741.  
  742. connectFail = true;
  743.  
  744. break;
  745. case 13: // Realm Down - Character Select screen
  746. D2Bot.updateStatus("Realm Down");
  747. delay(1000);
  748.  
  749. if (!ControlAction.click(6, 33, 572, 128, 35)) {
  750. break;
  751. }
  752.  
  753. updateCount();
  754. ControlAction.timeoutDelay("Realm Down", StarterConfig.RealmDownDelay * 6e4);
  755. D2Bot.CDKeyRD();
  756.  
  757. if (gameInfo.switchKeys && !gameInfo.rdBlocker) {
  758. D2Bot.printToConsole("Realm Down - Changing CD-Key");
  759. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  760. D2Bot.restart(true);
  761. } else {
  762. D2Bot.printToConsole("Realm Down - Restart");
  763. D2Bot.restart();
  764. }
  765.  
  766. break;
  767. case 14: // Character Select / Main Menu - Disconnected
  768. D2Bot.updateStatus("Disconnected");
  769. delay(500);
  770. ControlAction.click(6, 351, 337, 96, 32);
  771.  
  772. break;
  773. case 16: // Character Select - Please Wait popup
  774. if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) {
  775. ControlAction.click(6, 351, 337, 96, 32);
  776. }
  777.  
  778. break;
  779. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  780. delay(1000);
  781. ControlAction.click(6, 351, 337, 96, 32);
  782.  
  783. break;
  784. case 19: // Login - Cdkey In Use
  785. D2Bot.printToConsole(gameInfo.mpq + " is in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
  786. D2Bot.CDKeyInUse();
  787.  
  788. if (gameInfo.switchKeys) {
  789. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  790. D2Bot.restart(true);
  791. } else {
  792. ControlAction.click(6, 335, 450, 128, 35);
  793. ControlAction.timeoutDelay("CD-Key in use", StarterConfig.CDKeyInUseDelay * 6e4);
  794. }
  795.  
  796. break;
  797. case 20: // Single Player - Select Difficulty
  798. break;
  799. case 21: // Main Menu - Connecting
  800. if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
  801. ControlAction.click(6, 330, 416, 128, 35);
  802. }
  803.  
  804. break;
  805. case 22: // Login - Invalid Cdkey (classic or xpac)
  806. text = ControlAction.getText(4, 162, 270, 477, 50);
  807. string = "";
  808.  
  809. if (text) {
  810. for (i = 0; i < text.length; i += 1) {
  811. string += text[i];
  812.  
  813. if (i !== text.length - 1) {
  814. string += " ";
  815. }
  816. }
  817. }
  818.  
  819. switch (string) {
  820. case getLocaleString(10914):
  821. D2Bot.printToConsole(gameInfo.mpq + " LoD key in use by " + ControlAction.getText(4, 158, 310, 485, 40), 6);
  822. D2Bot.CDKeyInUse();
  823.  
  824. if (gameInfo.switchKeys) {
  825. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  826. D2Bot.restart(true);
  827. } else {
  828. ControlAction.click(6, 335, 450, 128, 35);
  829. ControlAction.timeoutDelay("LoD key in use", StarterConfig.CDKeyInUseDelay * 6e4);
  830. }
  831.  
  832. break;
  833. default:
  834. if (gameInfo.switchKeys) {
  835. D2Bot.printToConsole("Invalid CD-Key");
  836. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  837. D2Bot.restart(true);
  838. } else {
  839. ControlAction.click(6, 335, 450, 128, 35);
  840. ControlAction.timeoutDelay("Invalid CD-Key", StarterConfig.CDKeyInUseDelay * 6e4);
  841. }
  842.  
  843. break;
  844. }
  845.  
  846. break;
  847. case 23: // Character Select - Connecting
  848. case 42: // Empty character screen
  849. string = "";
  850. text = ControlAction.getText(4, 45, 318, 531, 140);
  851.  
  852. if (text) {
  853. for (i = 0; i < text.length; i += 1) {
  854. string += text[i];
  855.  
  856. if (i !== text.length - 1) {
  857. string += " ";
  858. }
  859. }
  860.  
  861. if (string === getLocaleString(11161)) { // CDKey disabled from realm play
  862. D2Bot.updateStatus("Realm Disabled CDKey");
  863. D2Bot.printToConsole("Realm Disabled CDKey: " + gameInfo.mpq, 6);
  864. D2Bot.CDKeyDisabled();
  865.  
  866. if (gameInfo.switchKeys) {
  867. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  868. D2Bot.restart(true);
  869. } else {
  870. D2Bot.stop();
  871. }
  872. }
  873. }
  874.  
  875. if (!locationTimeout(StarterConfig.ConnectingTimeout * 1e3, location)) {
  876. ControlAction.click(6, 33, 572, 128, 35);
  877.  
  878. if (gameInfo.rdBlocker) {
  879. D2Bot.restart();
  880. }
  881. }
  882.  
  883. break;
  884. case 24: // Server Down - not much to do but wait..
  885. break;
  886. case 25: // Lobby - Please Wait
  887. if (!locationTimeout(StarterConfig.PleaseWaitTimeout * 1e3, location)) {
  888. ControlAction.click(6, 351, 337, 96, 32);
  889. }
  890.  
  891. break;
  892. case 26: // Lobby - Game Name Exists
  893. ControlAction.click(6, 533, 469, 120, 20);
  894.  
  895. gameCount += 1;
  896. lastGameStatus = "ready";
  897.  
  898. break;
  899. case 27: // Gateway Select
  900. ControlAction.click(6, 436, 538, 96, 32);
  901.  
  902. break;
  903. case 28: // Lobby - Game Does Not Exist
  904. D2Bot.printToConsole("Game doesn't exist");
  905.  
  906. if (gameInfo.rdBlocker) {
  907. D2Bot.printToConsole(gameInfo.mpq + " is probably flagged.", 6);
  908.  
  909. if (gameInfo.switchKeys) {
  910. ControlAction.timeoutDelay("Key switch delay", StarterConfig.SwitchKeyDelay * 1000);
  911. D2Bot.restart(true);
  912. }
  913. } else {
  914. locationTimeout(StarterConfig.GameDoesNotExistTimeout * 1e3, location);
  915. }
  916.  
  917. lastGameStatus = "ready";
  918.  
  919. break;
  920. case 38: // Game is full
  921. // doesn't happen when making
  922. break;
  923. default:
  924. if (location !== undefined) {
  925. D2Bot.printToConsole("Unhandled location " + location);
  926. //takeScreenshot();
  927. delay(500);
  928. D2Bot.restart();
  929. }
  930.  
  931. break;
  932. }
  933. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement