Advertisement
Guest User

d2 bot channel afk rusher

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