Advertisement
gtoilet

chanter make/join

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