Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2017
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 31.74 KB | None | 0 0
  1. // commented out the /f l line, but can be uncommented if you wich
  2. // added white screen of death fix and also some print txt for testing 2-17-11 stairbuilder
  3. // added stagger leech joining 9-25-11 by stair
  4. // added single /f l try to enter games for switching keys and missing the game join message 9-25-11 by stair
  5. // added a while loop and manager print if a bad cd key is used or bad account or password stair 9-25-11
  6. // added gameDoesNotExistDelay and txt file joining. Must use updated leader entry point for the txt joining
  7. // added 3 new config options tryLeaderGame1x, retryLeaderGame, tryLeaderGame1x 12-22-2011
  8. // changed where the game count increase is called to right when bot enters chat instead of waiting for game name. Saves a second or 2 credit for this goes to stib 1-21-12
  9. // fixed /f l delay to only apply after the first /f l 1-21-12
  10. // added fastJoin option. read comments next to setting below 1/22/12
  11. ///////////////////////////////////////////////////////////////////////////////////////////////////////////
  12. // Renamed from LeechStarter2.3 to LeechStarter on 4/27/2013 by Tru
  13. // Version of the LeechStarter remains at 2.3!
  14.  
  15. // =============================================================================
  16. // Leader Account settings
  17. // =============================================================================
  18.  
  19. var leaderAccountName = "exequiel";
  20. var leaderName = "wizawizz";
  21.  
  22. // =============================================================================
  23. // Leecher game entry delays use to stagger when leechers join game
  24. // [characterName, delay in milliseconds] - leave these as-is to not use them
  25. // =============================================================================
  26.  
  27. var leecher1 = ["characterName", 100];
  28. var leecher2 = ["characterName", 750];
  29. var leecher3 = ["characterName", 1250];
  30. var leecher4 = ["characterName", 2000];
  31.  
  32. //==============================================================================
  33. // join options
  34. //==============================================================================
  35.  
  36. var useFL = false; // set true if you wish your leecher to use /f l to join games. useFL MUST be set to 0 for this to work
  37. var useFLCount = 1; // this is seperate from the above setting allows you to use /f l to join, but will only spam /f l the set number of times. set to 0 to disable
  38. var delayFL = 3000; // milliseconds before the bot will use the /f l command in loby
  39. var reEnterSameGame = false; // set to false to keep the bot from using /f l to re enter same game also must be set to false if you don't want bot to re enter same game for txt joining
  40. var useTextFileJoin = true; // use txt file communication between leader and leecher to join games
  41. var gameDoesNotExistDelay = 10; // time to idle before trying if leader's game does not exist. In seconds.
  42. var tryLeaderGame1x = false; // will only try to enter the game one time. Good for when leader drops before leecher gets in.
  43. var retryLeaderGame = 0; // nuber of times you would like to try joining leaders game. Note tryLeaderGame1x = true bypasses this and the delay below
  44. var retryLeaderGameDelay = 10; // time in seconds to delay between retrying to enter leaders game
  45. var fastJoin = false; // this has preconfigured delays for easy switching. Gets you leecher in game in about 3 seconds. THIS MAY CAUSE JOIN PROBLEMS FOR SOME USERS!!!!!
  46. var ftjDelay = 180; // time to idle before trying if leecher failed to join. In seconds.
  47.  
  48. // =============================================================================
  49. // Game password (leave blank if none)
  50. // =============================================================================
  51.  
  52. var gamepassword = "959303";
  53.  
  54. // =============================================================================
  55. // UseCDKeyChangeTrick :
  56. // if true, the follow bot will say his gamename/gamepwd (set in the OOG) in chat before each game
  57. // in order to increment his number of runs (to switch CDKeys after xx runs)
  58. // if false, the follow bot will never change his CDKey
  59. // =============================================================================
  60.  
  61. var UseCDKeyChangeTrick = false;
  62.  
  63. // =============================================================================
  64. // Debug : set to true if you are experiencing problems with your JoinBot
  65. // it will log in your OOG the lobby chat actions
  66. // =============================================================================
  67.  
  68. var Debug = false;
  69.  
  70. ////////////////////////////////////////////////////////////////////////////////
  71. // Lobby chat settings :
  72. ////////////////////////////////////////////////////////////////////////////////
  73.  
  74. var joinChatAfterGame = true; // Set to true to join the chat after each game (needed for JoinBot)
  75. var firstJoinMessage = ""; // Message said when you first enter the chat
  76. var chatMessageAfterGame = ""; // Message said after each game
  77. var joinRandomChannel = false; // if this is true, will join a random channel, otherwise it will use the channel below..
  78. var joinChannelInChat = "pepapiggy"; // Name of the channel you want to join (leave blank if you want to stay in the default channel)
  79.  
  80. ////////////////////////////////////////////////////////////////////////////////
  81. // Delays:
  82. ////////////////////////////////////////////////////////////////////////////////
  83. // Minimum game length, waits in the lobby if last game was too short
  84. // I recommend to keep a value > 300000 (milliseconds) to avoid bnet temporary ban
  85. var gameMinLength = 420000; // Milliseconds
  86.  
  87. // Realm Delays
  88. var unableToConnectRetry = 20; // Minutes
  89. var realmDownRetry = 480; // Minutes
  90. var disconnectedRetry = 5; // Minutes
  91. var cdkeyInUseRetry = 5; // Minutes
  92.  
  93. if(fastJoin) {
  94. // interface delays (milliseconds)
  95. var connectingToBnetTimeout = 20000;
  96. var characterScreenTimeout = 10000;
  97. var pleaseWaitTimeout = 10000;
  98. var createGameThreshold = 10000;
  99. var createGameThresholdRandom = 1000;
  100. var createGameTimeout = 15000;
  101. var waitInLineTimeout = 15000;
  102. var characterSelectDelay = 1000;
  103. var loginDelay = 1000;
  104. var clickDelay = 0;
  105. var textDelay = 0;
  106. var clickDelayRandom = 0;
  107. var textDelayRandom = 0;
  108. var gameDoesNotExistDelayMin = 600000; // this not for leech configuration. Look for gameDoesNotExistDelay above
  109. var gameDoesNotExistDelayMax = 900000; // this not for leech configuration. Look for gameDoesNotExistDelay above
  110. var gameDoesNotExistTimeout = 30000;
  111. var waitBeforeEnterChatMin = 1000;
  112. var waitBeforeEnterChatMax = 2000;
  113. var waitInChatBeforeActionsMin = 2000;
  114. var waitInChatBeforeActionsMax = 3000;
  115. } else {
  116. var connectingToBnetTimeout = 20000;
  117. var characterScreenTimeout = 10000;
  118. var pleaseWaitTimeout = 10000;
  119. var createGameThreshold = 10000;
  120. var createGameThresholdRandom = 1000;
  121. var createGameTimeout = 15000;
  122. var waitInLineTimeout = 15000;
  123. var characterSelectDelay = 1000;
  124. var loginDelay = 1000;
  125. var clickDelay = 500;
  126. var textDelay = 500;
  127. var clickDelayRandom = 500;
  128. var textDelayRandom = 500;
  129. var gameDoesNotExistDelayMin = 600000; // this not for leech configuration. Look for gameDoesNotExistDelay above
  130. var gameDoesNotExistDelayMax = 900000; // this not for leech configuration. Look for gameDoesNotExistDelay above
  131. var gameDoesNotExistTimeout = 30000;
  132. var waitBeforeEnterChatMin = 1000;
  133. var waitBeforeEnterChatMax = 2000;
  134. var waitInChatBeforeActionsMin = 2000;
  135. var waitInChatBeforeActionsMax = 3000;
  136. }
  137.  
  138. // Only for JoinBot (friend list delay, milliseconds)
  139. var LeaderOfflineDelay = 30000;
  140. var LeaderInChatDelay = 10000;
  141. var GameIsFullDelay = 30000;
  142.  
  143. ////////////////////////////////////////////////////////////////////////////////
  144. ////////////////////////////////////////////////////////////////////////////////
  145. // DO NOT EDIT ANYTHING BELOW THIS
  146. ////////////////////////////////////////////////////////////////////////////////
  147. ////////////////////////////////////////////////////////////////////////////////
  148.  
  149. //D2NT Manager Command
  150.  
  151. const D2NT_MGR_LOADING = 1;
  152. const D2NT_MGR_READY = 2;
  153. const D2NT_MGR_LOGIN = 3;
  154. const D2NT_MGR_CREATE_GAME = 4;
  155. const D2NT_MGR_INGAME = 5;
  156. const D2NT_MGR_RESTART = 6;
  157. const D2NT_MGR_CHICKEN = 7;
  158. const D2NT_MGR_PRINT_STATUS = 8;
  159. const D2NT_MGR_PRINT_LOG = 9;
  160.  
  161. var lastGameMade = GetTickCount();
  162. var lastGameStatus = 0;
  163. var nextGameMake = 0;
  164. var inGameAt = 0;
  165. var chatActionsDone = false;
  166. var lastGameFailed = false;
  167. var sayChatMsgAfterGame = false;
  168. var ftjcount = 0;
  169.  
  170. Include("libs/controlInfo.ntl");
  171. Include("libs/common/NTColorConverter.ntl");
  172.  
  173. var controlData = new controlInfo();
  174.  
  175. var increaseGameCount = true;
  176. var firstTimeFl = true;
  177. var retryLeaderGameCount = 0;
  178. var lastGame = "";
  179. var retryFL = 0;
  180. var game = '';
  181. var _gamename = "";
  182. var _gamepassword = "";
  183. var _leaderOfflineTick = -LeaderOfflineDelay;
  184. var _leaderInChatTick = -LeaderInChatDelay;
  185. var _GameIsFullTick = -GameIsFullDelay;
  186.  
  187. function NTMain()
  188. {
  189. Delay(1000);
  190.  
  191. var _ingame = false;
  192.  
  193. controlData.clickDelay = clickDelay;
  194. controlData.textDelay = textDelay;
  195. controlData.clickDelayRandom = clickDelayRandom;
  196. controlData.textDelayRandom = textDelayRandom;
  197. while(1)
  198. {
  199. if(me.ingame)
  200. {
  201. _gamename = me.gamename;
  202. _gamepassword = me.gamepassword;
  203.  
  204. if(!inGameAt)
  205. inGameAt = GetTickCount();
  206.  
  207. if(!_ingame)
  208. {
  209. RunGC(); // run garbage collector between each game
  210.  
  211. if(Load("NTBot/NTBotGame.ntj"))
  212. {
  213. if(!reEnterSameGame) { NT_File("logs/messagecomands/"+me.charname+"-lastgame.txt", 1, me.gamename); } // writes current game for comparing to new game to join next time in lobby
  214.  
  215. retryFL = 0; // sets the counter back to 0 upon game entry.
  216. _ingame = true;
  217. retryLeaderGameCount = 0;
  218. firstTimeFl = true;
  219. increaseGameCount = true;
  220.  
  221. if(me.playtype > 0)
  222. sendEventToOOG(D2NT_MGR_INGAME, "In Game[IP:" + me.gameserverip.split(".")[3] + "]", 0);
  223. else
  224. sendEventToOOG(D2NT_MGR_INGAME, "In Game", 0);
  225.  
  226. lastGameStatus = 2; // in game successful
  227.  
  228. }
  229. }
  230.  
  231. Delay(1000);
  232. }
  233. else
  234. {
  235. if(_ingame)
  236. {
  237.  
  238.  
  239. My_ExitGame_Check(); // out of korean modded d2nt fixes white screen of death
  240. _ingame = false;
  241. sayChatMsgAfterGame = true;
  242.  
  243. sendEventToOOG(D2NT_MGR_READY, "", 0);
  244. }
  245.  
  246. locationAction(controlData.getLocation());
  247.  
  248. Delay(500);
  249. }
  250. }
  251. }
  252.  
  253. function locationAction(location)
  254. {
  255. switch(location.id)
  256. {
  257. case 3: // Lobby Chat
  258. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  259. //ftjcheck
  260. if (ftjcount >= 10 && lastGameStatus == 1) {
  261. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "FTJ detected...........Idling", 0);
  262. ftjcount = 0;
  263. inGameAt = 0;
  264. lastGameStatus = 0;
  265. setNextGameMake();
  266. locationTimeout(ftjDelay*1000, location);
  267. }
  268. //LogPrintSimple(me.account + "MyAccountTest.txt", me.account + " / " + me.charname) // this is to check for 2nd account login
  269. if (UseCDKeyChangeTrick && increaseGameCount) {
  270. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  271. increaseGameCount = false;
  272. Delay(1000);
  273. }
  274. if(!chatActionsDone)
  275. {
  276. Delay(Random(waitInChatBeforeActionsMin, waitInChatBeforeActionsMax));
  277.  
  278. if(joinRandomChannel || joinChannelInChat != "")
  279. {
  280. Say("/join " + (joinRandomChannel ? getRandomString(Random(3,10)) : joinChannelInChat));
  281. Delay(1000);
  282. }
  283.  
  284. if(firstJoinMessage)
  285. {
  286. Say(firstJoinMessage);
  287. Delay(200);
  288. }
  289.  
  290. chatActionsDone = true;
  291. }
  292.  
  293. if (chatMessageAfterGame && _gamename != "" && sayChatMsgAfterGame == true)
  294. {
  295. Say(chatMessageAfterGame);
  296. sayChatMsgAfterGame = false;
  297. Delay(200);
  298. }
  299.  
  300. game = '';
  301. if(useTextFileJoin) {
  302. NT_RetrievenextGame(); //read message from txt file and set game and gamepassword vars from that
  303. }
  304. else {
  305. if(useFL || useFLCount > 0) {
  306. var _tick = GetTickCount();
  307. if ((_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick) // maybe play with this so it skips it for 30 seconds
  308. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)
  309. && (_GameIsFullTick < 0 || (_GameIsFullTick + GameIsFullDelay) < _tick))
  310. {
  311. Delay(500);
  312. DebugInOOG('Locating the leader : '+leaderAccountName);
  313. if(useFLCount > 0 && retryFL < useFLCount) {
  314.  
  315. if(!firstTimeFl) {
  316. Delay(delayFL);
  317. } else {
  318. firstTimeFl = false;
  319. }
  320.  
  321. Say('/f l');
  322. retryFL++;
  323. }
  324. else if(useFL) {
  325. if(!firstTimeFl) {
  326. Delay(delayFL);
  327. } else {
  328. firstTimeFl = false;
  329. }
  330. Say('/f l');
  331. }
  332.  
  333. }
  334. }
  335.  
  336. if(chat = controlData.get(controlData.controls.lobby.chat.textBox.channelText))
  337. {
  338. var found_leader = false;
  339. lines = chat.GetText();
  340. if(!lines) { break; }
  341. for (var line_id = lines.length - 1; line_id > -1; line_id--)
  342. {
  343. if (found_leader) // useless... :/
  344. break;
  345.  
  346. if (lines[line_id].substring(0,1) == " ")
  347. continue;
  348.  
  349. // retrieving the whole message
  350. var msg = lines[line_id].replace(/^\s+|\s+$/, "");
  351. var msglines = 1;
  352. while (lines[line_id+msglines] != undefined && lines[line_id+msglines].substring(0,2) == " ")
  353. {
  354. msg += " " + lines[line_id+msglines].replace(/^\s+|\s+$/, "");
  355. msglines++;
  356. }
  357. if (msg.lastIndexOf(leaderName) >= 0)
  358. DebugInOOG("yc8found him :;"+msg);
  359.  
  360. // checking if the msg is a friendly whisper
  361. if (msg.lastIndexOf(leaderName + ' (*' +leaderAccountName+')') > -1 || msg.lastIndexOf(leaderName + '@' + GateWayToName() + ' (*' +leaderAccountName+')') > -1)
  362. // if (msg.lastIndexOf(leaderName + ' (*' +leaderAccountName+')') > -1) // need to modify this and then add another to handle the "@USWest
  363. { // should be just a matter of leaderName + '@' and then register the 2nd line as game name
  364. var regGameNameWhispered=/^.*in_new_game\s+(.*)$/gi; // replaced below with this to join on mesage upon entering game
  365. //var regGameNameWhispered=/^.*(game|partie|spiel|partita|partida).*(nomm[^\s]*|called|chiamata)\s*([\w\s-]*\w)\s*\.\s*$/gi;
  366. if (msg.match(regGameNameWhispered))
  367. game = msg.replace(regGameNameWhispered, "$1"); // replaced below with this to join on mesage upon entering game
  368. //game = msg.replace(regGameNameWhispered, "$3");
  369.  
  370. if (game != '')
  371. {
  372. found_leader = true;
  373. break;
  374. }
  375. }
  376.  
  377. // checking if the msg is from the friend list
  378. if (msg.lastIndexOf(': '+leaderAccountName+',') > -1)
  379. {
  380. found_leader = true;
  381. var regOffline=/^.*(offline|desconectado).*$/gi;
  382. var regInChat=/^.*(channel|canale?)\s*([\w\s-]*\w)\.?\s*$/gi;
  383. var regGameName=/^.*(game|partie|spiel|partita|partida)\s*([\w\s-]*\w)\s*\(priv[^\)]*\)\.\s*$/gi;
  384.  
  385. if (msg.match(regOffline)
  386. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  387. {
  388. DebugInOOG('Leader is offline, delay '+Math.round(LeaderOfflineDelay/1000)+' sec for next /f l.');
  389. _leaderOfflineTick = GetTickCount();
  390. }
  391. else if (msg.match(regInChat)
  392. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick))
  393. {
  394. DebugInOOG('Leader is in the chat "'+msg.replace(regInChat, "$2")+'", delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  395. _leaderInChatTick = GetTickCount();
  396. }
  397. else if (msg.match(regGameName)
  398. && ((_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick)
  399. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)))
  400. {
  401. game = msg.replace(regGameName, "$2");
  402. }
  403. else if ((_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)
  404. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  405. {
  406. // unhandled line, supposelly "In Realm"
  407. DebugInOOG('The leader was in the the lobby but not in chat, delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  408. _leaderInChatTick = GetTickCount();
  409. }
  410.  
  411. break;
  412. }
  413. }
  414.  
  415. if (found_leader == false)
  416. DebugInOOG('I couldn\'t find the leader in my friend list!');
  417. }
  418. else
  419. {
  420. DebugInOOG('I can\'t read the chat!');
  421. //DebugInOOG('You probably haven\'t added the lobby chat controlinfo coordinates!');
  422. Delay(30000);
  423. }
  424. }
  425. if(!reEnterSameGame) { // added to check game name. If same as last game then don't re enter.
  426. NT_RetrieveLastGame();
  427. //Delay(250);
  428. if(lastGame == game) {
  429. game = "";
  430. }
  431. }
  432. if (game!="")
  433. {
  434. DebugInOOG('Leader is in the game "' + game + '"');
  435. controlData.click(controlData.controls.lobby.button.join);
  436. Delay(100);
  437. }
  438.  
  439. break;
  440.  
  441. case 1: // Lobby
  442. if(location.id == 1 && joinChatAfterGame)
  443. {
  444. //LogPrintSimple(me.account + "MyAccountTest.txt", me.account + " / " + me.charname) // this is to check for 2nd account login
  445. Delay(Random(waitBeforeEnterChatMin, waitBeforeEnterChatMax));
  446. controlData.click(controlData.controls.lobby.button.enterChat);
  447.  
  448. break;
  449.  
  450. }
  451. break;
  452.  
  453. case 2: // Waiting In Line
  454. if(GetTickCount()-lastGameMade > waitInLineTimeout)
  455. controlData.click(controlData.controls.lobby.inLine.button.cancel);
  456. break;
  457.  
  458. case 4: // Create Game
  459. if(!controlData.get(controlData.controls.lobby.create.editBox.gameName))
  460. {
  461. controlData.click(controlData.controls.lobby.button.join);
  462. Delay (500);
  463. controlData.click(controlData.controls.lobby.button.create);
  464. Delay (500);
  465. break;
  466. }
  467.  
  468. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  469.  
  470. locationTimeout(5000, location);
  471.  
  472. lastGameMade = GetTickCount();
  473. lastGameStatus = 1; // pending creation
  474. break;
  475.  
  476. case 5: // Join Game
  477. if (game)
  478. {
  479. if(retryLeaderGameCount > 0 && retryLeaderGameDelay > 0) {
  480. Delay(retryLeaderGameDelay * 1000);
  481. }
  482. controlData.setText( controlData.controls.lobby.join.editBox.gameName, game);
  483. Delay (100);
  484. controlData.setText( controlData.controls.lobby.join.editBox.password, gamepassword);
  485. //SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + COLOR_1 +me.charname);
  486. if(leecher1[0] == me.charname){
  487. Delay(leecher1[1]);
  488. }
  489. else if(leecher2[0] == me.charname){
  490. Delay(leecher2[1]);
  491. }
  492. else if(leecher3[0] == me.charname){
  493. Delay(leecher3[1]);
  494. }
  495. else if(leecher4[0] == me.charname){
  496. Delay(leecher4[1]);
  497. }
  498. else{
  499. Delay(100);
  500. }
  501. if(tryLeaderGame1x && retryLeaderGame <= 0) {
  502. NT_File("logs/messagecomands/"+me.charname+"-lastgame.txt", 1, game); // writes current game for comparing to new game to join next time in lobby
  503. game = "";
  504. }
  505. if(retryLeaderGame > 0 && !tryLeaderGame1x && retryLeaderGameCount < retryLeaderGame) { // increases the leadergamecount
  506. retryLeaderGameCount++;
  507. }
  508. if(retryLeaderGame > 0 && !tryLeaderGame1x && retryLeaderGameCount >= retryLeaderGame) { // sets game name to "" because we have made as many attempts as configured to join
  509. game = "";
  510. }
  511. controlData.click(controlData.controls.lobby.join.button.joinGame);
  512. RunGC(); // run garbage collector between each game
  513.  
  514. locationTimeout(5000, location);
  515. lastGameStatus = 1; // pending join
  516. }
  517. else
  518. {
  519. DebugInOOG('No game to join : cancelling');
  520. me.Cancel(1);
  521. Delay(1000);
  522. }
  523.  
  524. break;
  525. case 6: // Ladder
  526. break;
  527.  
  528. case 7: // Channel List
  529. break;
  530.  
  531. case 8: // Main Menu
  532. if(controlData.getCurrentRealmIndex() == me.gatewayid)
  533. {
  534. outputGameLength();
  535. controlData.click(controlData.gameTypes[me.playtype]);
  536. }
  537. else
  538. controlData.click(controlData.controls.mainMenu.button.gateway);
  539. break;
  540.  
  541. case 9: // Login
  542. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  543. Delay(loginDelay);
  544.  
  545. controlData.setText(controlData.controls.login.editBox.accountName, me.account);
  546.  
  547. sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);
  548.  
  549. locationTimeout(5000, location);
  550. break;
  551.  
  552. case 10: // Login Error (this is a fatal error, so stop)
  553. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad Account or PW Entered.......Idling", 0);
  554. while(1) { Delay(500); }
  555. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
  556. Delay(3500);
  557. break;
  558.  
  559. case 11: // Unable To Connect
  560. timeoutDelay(unableToConnectRetry*60*1000, location)
  561. controlData.click(controlData.controls.login.unableToConnect.button.ok);
  562. break;
  563.  
  564. case 12: // Character Select
  565. var _time, _control;
  566.  
  567. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  568.  
  569. for(_time = 0 ; _time < characterScreenTimeout ; _time += 500)
  570. {
  571. _control = controlData.get(controlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
  572. if(_control && _control.GetText() != undefined)
  573. break;
  574.  
  575. Delay(500);
  576. }
  577.  
  578. if(_time < characterScreenTimeout)
  579. {
  580. Delay(characterSelectDelay);
  581.  
  582. controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
  583. controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);
  584.  
  585. // reset last game made, so it doesnt make a game immediately
  586. inGameAt = 0;
  587. setNextGameMake();
  588. }
  589. else
  590. {
  591. controlData.click(controlData.controls.characterSelect.button.exit);
  592. timeoutDelay(realmDownRetry*60*1000, location);
  593. }
  594. break;
  595.  
  596. case 13: // Realm Down - Character Select screen
  597. controlData.click(controlData.controls.characterSelect.button.exit);
  598. timeoutDelay(realmDownRetry*60*1000, location);
  599. break;
  600.  
  601. case 14: // Character Select - Disconnected
  602. timeoutDelay(disconnectedRetry*60*1000, location);
  603. controlData.click(controlData.controls.characterSelect.disconnected.button.ok);
  604. break;
  605.  
  606. case 15: // New Character
  607. break;
  608.  
  609. case 16: // Character Select - Please Wait popup
  610. if(!locationTimeout(pleaseWaitTimeout, location))
  611. controlData.click(controlData.controls.characterSelect.pleaseWait.button.cancel);
  612. break;
  613.  
  614. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  615. controlData.click(controlData.controls.lobby.lostConnection.button.ok);
  616. break;
  617.  
  618. case 18: // D2 Splash
  619. controlData.click(controlData.controls.d2Splash.textBox.copyright);
  620. break;
  621.  
  622. case 19: // Login - Cdkey In Use
  623. timeoutDelay(cdkeyInUseRetry*60*1000, location);
  624. controlData.click(controlData.controls.login.cdkeyInUse.button.ok);
  625. break;
  626.  
  627. case 20: // Single Player - Select Difficulty
  628. controlData.click(controlData.singlePlayerDifficulties[me.diff]);
  629. break;
  630.  
  631. case 21: // Main Menu - Connecting
  632. if(!locationTimeout(connectingToBnetTimeout, location))
  633. controlData.click(controlData.controls.mainMenu.connecting.button.cancel);
  634. break;
  635.  
  636. case 22: // Login - Invalid Cdkey (classic or xpac)
  637. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad CD Key...........Idling", 0);
  638. while(1) { Delay(500); }
  639. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
  640. Delay(3500);
  641. break;
  642.  
  643. case 23: // Character Select - Connecting
  644. if(!locationTimeout(characterScreenTimeout, location))
  645. controlData.click(controlData.controls.characterSelect.button.exit);
  646. break;
  647.  
  648. case 24: // Server Down - not much to do but wait..
  649. break;
  650.  
  651. case 25: // Lobby - Please Wait
  652. if(!locationTimeout(pleaseWaitTimeout, location))
  653. controlData.click(controlData.controls.lobby.pleaseWait.button.cancel);
  654. break;
  655.  
  656. case 26: // Lobby - Game Name Exists
  657. sendEventToOOG(D2NT_MGR_PRINT_LOG, "yE00000Game already exists", 0);
  658.  
  659. inGameAt = 0;
  660. lastGameStatus = 0;
  661. setNextGameMake();
  662.  
  663. locationTimeout(15000, location);
  664. break;
  665.  
  666. case 27: // Gateway Select
  667. controlData.clickRealmEntry(me.gatewayid);
  668. controlData.click(controlData.controls.gateway.button.ok);
  669. break;
  670.  
  671. case 28: // Lobby - Game Does Not Exist
  672. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Leader's game does not exist...........Idling", 0);
  673. Delay(gameDoesNotExistDelay*1000);
  674. inGameAt = Random(gameDoesNotExistDelayMin, gameDoesNotExistDelayMax);
  675. lastGameStatus = 0;
  676. setNextGameMake();
  677.  
  678. locationTimeout(gameDoesNotExistTimeout, location);
  679. break;
  680. default:
  681. if (lastGameStatus == 1) {
  682. sendEventToOOG(D2NT_MGR_PRINT_STATUS, "Please Wait...", 0);
  683. for (ftjcount=0; ftjcount<=10 && !me.ingame; ftjcount++) {
  684. Delay(1000)
  685. }
  686. }
  687. DebugInOOG("Unhandled location : "+location.id);
  688. break;
  689. }
  690. DebugInOOG("Location : "+location.id);
  691. }
  692.  
  693. function sendEventToOOG(locationId, statusString, pendingTime)
  694. {
  695. return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
  696. }
  697.  
  698. function setNextGameMake()
  699. {
  700. lastGameMade = GetTickCount();
  701. nextGameMake = lastGameMade + createGameThreshold + Random(0-createGameThresholdRandom, createGameThresholdRandom) + inGameAt;
  702. inGameAt = 0;
  703. chatActionsDone = false;
  704. }
  705.  
  706. function outputGameLength()
  707. {
  708. if(inGameAt)
  709. {
  710. duration = GetTickCount() - inGameAt;
  711.  
  712. inGameAt = (duration < gameMinLength ? gameMinLength - duration : 0);
  713. }
  714. }
  715.  
  716. function locationTimeout(time, location)
  717. {
  718. endtime = GetTickCount() + time;
  719.  
  720. while(controlData.getLocation().id == location.id && endtime > GetTickCount())
  721. {
  722. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  723. Delay(500);
  724. }
  725.  
  726. return (controlData.getLocation().id != location.id);
  727. }
  728.  
  729. function timeoutDelay(time, location)
  730. {
  731. endtime = GetTickCount() + time;
  732.  
  733. while(endtime > GetTickCount())
  734. {
  735. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  736. Delay(1000);
  737. if(me.ingame){ Delay(1000); return;}
  738. }
  739. }
  740.  
  741. function getRandomString(_length)
  742. {
  743. _retString = "";
  744. _charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
  745.  
  746. while(_length--)
  747. {
  748. _retString += _charSet.charAt(Random(0, _charSet.length-1));
  749. Delay(1);
  750. }
  751.  
  752. return _retString;
  753. }
  754. function DebugInOOG(logString)
  755. {
  756. if (Debug)
  757. return SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + logString);
  758. else
  759. return false;
  760. }
  761.  
  762. function My_ExitGame_Check()
  763. {
  764. for (var i = 0; i < 40; i++)
  765. {
  766. if (controlData.getLocation().id != undefined)
  767. break;
  768.  
  769. if (i > 38)
  770. {
  771. LogPrintSimple(me.account + " StarterTest.txt", "White Screen of Death: Restarting")
  772. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "White Screen of Death: Restarting", 0);
  773. sendEventToOOG(D2NT_MGR_RESTART, "", 5);
  774. My_Delay(); // make sure and add this also
  775. }
  776.  
  777. Delay(500);
  778. }
  779. }
  780.  
  781. function My_Delay(retry)
  782. {
  783. if (arguments.length < 1)
  784. retry = 20;
  785.  
  786. while (retry-- > 0)
  787. Delay(1000);
  788. }
  789.  
  790. function LogPrintSimple(filepath, mesg){
  791.  
  792. var _filepath = filepath;
  793. var _mesg = mesg;
  794.  
  795. var date = new Date().toLocaleFormat("<%a, %b %d, %H:%M>");
  796. var logfile = FileOpen(_filepath, 2); // opens file
  797. if(!logfile)
  798. var logfile = FileOpen(_filepath, 1); // if file not there then creates it
  799.  
  800. logfile.WriteLine(date + " " + _mesg );
  801. logfile.Close();
  802. }
  803.  
  804. function GateWayToName(){
  805. switch(me.gatewayid){
  806. case 0: return 'USWest';
  807. case 1: return 'USEast';
  808. case 2: return 'Asia';
  809. case 3: return 'Europe';
  810. default: return 'ugly'; // not sure how asia1, asia2, etc work so adding this for now
  811. }
  812. }
  813. // modes 0 = read only, 1 = overwrite the file, 2 = add to file
  814. function NT_File(path, mode, msg, delay) { //big thanks to all the koreans out there
  815. var _msg = "";
  816. var _line = "";
  817. var _fileHandle;
  818. var _isFileCheck = false;
  819.  
  820. if (arguments.length < 3) { msg = ""; }
  821. if (arguments.length < 4) { delay = (mode > 0) ? 5 : 2; }
  822.  
  823. while (delay--) {
  824. if (mode == 2 && !_isFileCheck) {
  825. _fileHandle = FileOpen(path, 0);
  826. if (!_fileHandle)
  827. _fileHandle = FileOpen(path, 1);
  828.  
  829. if (_fileHandle)
  830. _fileHandle.Close();
  831.  
  832. _isFileCheck = true;
  833. }
  834.  
  835. _fileHandle = FileOpen(path, mode);
  836. if (_fileHandle)
  837. break;
  838.  
  839. if (delay)
  840. Delay(200);
  841. }
  842.  
  843. if (_fileHandle) {
  844. if (mode == 0) {
  845. while (!_fileHandle.eof) {
  846. _line = _fileHandle.ReadLine();
  847. if (_line || !_fileHandle.eof)
  848. _msg += _line + msg;
  849. }
  850. }
  851. else if (msg)
  852. _fileHandle.WriteLine(msg);
  853.  
  854. _fileHandle.Close();
  855. }
  856.  
  857. return _msg;
  858. }
  859.  
  860. function NT_RetrieveLastGame() {
  861. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 0); // open file in read only
  862. if(!grabLastGame){
  863. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 1); // because the file doesn't exist create it
  864. }
  865. if(grabLastGame){
  866. lastGame = grabLastGame.ReadLine(); //retrieve the line and set the lastGame variable to it so we can check it against the game we may want to join
  867. grabLastGame.Close();
  868. }
  869. return;
  870. }
  871.  
  872. function NT_RetrievenextGame() { // to retrieve game and pw
  873. var grabLine;
  874. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 0); // open file in read only
  875. if(!grabNextGame){
  876. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 1); // because the file doesn't exist create it
  877. }
  878. if(grabNextGame){
  879. grabLine = grabNextGame.ReadLine(); //retrieve the line and set the nextGame variable to it so we can check it against the game we may want to join
  880. game = grabLine.substring(0, grabLine.indexOf('/')); //extracting game name from beginning of line to the "/"
  881. gamepassword = grabLine.substring(grabLine.indexOf('/') + 1, grabLine.length); //Parse after symbol till end of line.
  882. grabNextGame.Close();
  883. }
  884. return;
  885. }
  886. // so now we need to add code to get the next game and pw as well as check it against the last game
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement