Advertisement
Guest User

Untitled

a guest
Sep 24th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.25 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 = "xxxxx";
  20. var leaderName = "xxxxx";
  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 = true; // 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 = false; // 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 = 10; // 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 = "";
  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 = true;
  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 = "OP Etal"; // 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.  
  171. Include("libs/controlInfo.ntl");
  172. Include("libs/common/NTColorConverter.ntl");
  173.  
  174. var controlData = new controlInfo();
  175.  
  176. var increaseGameCount = true;
  177. var firstTimeFl = true;
  178. var retryLeaderGameCount = 0;
  179. var lastGame = "";
  180. var retryFL = 0;
  181. var game = '';
  182. var _gamepassword = "";
  183. var _leaderOfflineTick = -LeaderOfflineDelay;
  184. var _leaderInChatTick = -LeaderInChatDelay;
  185. var _GameIsFullTick = -GameIsFullDelay;
  186.  
  187. function NTMain()
  188. {
  189. Delay(1200);
  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 (game!="")
  285. {
  286. DebugInOOG('Leader is in the game "' + game + '"');
  287. controlData.click(controlData.controls.lobby.button.join);
  288. Delay(100);
  289. }
  290.  
  291. break;
  292.  
  293. case 1: // Lobby
  294. if(location.id == 1 && joinChatAfterGame)
  295. {
  296. //LogPrintSimple(me.account + "MyAccountTest.txt", me.account + " / " + me.charname) // this is to check for 2nd account login
  297. Delay(Random(waitBeforeEnterChatMin, waitBeforeEnterChatMax));
  298. controlData.click(controlData.controls.lobby.button.enterChat);
  299.  
  300. break;
  301.  
  302. }
  303. break;
  304.  
  305. case 2: // Waiting In Line
  306. if(GetTickCount()-lastGameMade > waitInLineTimeout)
  307. controlData.click(controlData.controls.lobby.inLine.button.cancel);
  308. break;
  309.  
  310. case 4: // Create Game
  311. break;
  312.  
  313. case 5: // Join Game
  314. var bla = controlData.get(controlData.controls.lobby.join.textBox.gameList);
  315. var lines;
  316. var game;
  317.  
  318. while(1)
  319. {
  320. lines = bla.GetText();
  321.  
  322. if(!lines)
  323. {
  324. sendEventToOOG(D2NT_MGR_PRINT_LOG, "ÿFF7E00" + "Debug - 'lines' was null");
  325. controlData.click(controlData.controls.lobby.button.join);
  326. Delay(1000);
  327. }
  328. else
  329. {
  330. for (i = 0; i < lines.length; i++)
  331. {
  332. if (lines.indexOf("2") == -1 && lines.indexOf("Fdia") != -1 && lines.indexOf("Baal") != -1)
  333. {
  334. game = lines[i];
  335. break;
  336. }
  337. }
  338. }
  339. if(game && lines)
  340. break;
  341. }
  342.  
  343. Delay(250);
  344. controlData.setText(controlData.controls.lobby.join.editBox.gameName, game);
  345. Delay(250);
  346. sendEventToOOG(D2NT_MGR_PRINT_LOG, "ÿ4D86B0Joining: " + game);
  347. Delay(250);
  348. controlData.click(controlData.controls.lobby.join.button.joinGame);
  349.  
  350. break;
  351.  
  352.  
  353.  
  354. if (game)
  355. {
  356. if(retryLeaderGameCount > 0 && retryLeaderGameDelay > 0) {
  357. Delay(retryLeaderGameDelay * 1000);
  358. }
  359. controlData.setText( controlData.controls.lobby.join.editBox.gameName, game);
  360. Delay (100);
  361. controlData.setText( controlData.controls.lobby.join.editBox.password, gamepassword);
  362. //SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + COLOR_1 +me.charname);
  363. if(leecher1[0] == me.charname){
  364. Delay(leecher1[1]);
  365. }
  366. else if(leecher2[0] == me.charname){
  367. Delay(leecher2[1]);
  368. }
  369. else if(leecher3[0] == me.charname){
  370. Delay(leecher3[1]);
  371. }
  372. else if(leecher4[0] == me.charname){
  373. Delay(leecher4[1]);
  374. }
  375. else{
  376. Delay(100);
  377. }
  378. if(tryLeaderGame1x && retryLeaderGame <= 0) {
  379. NT_File("logs/messagecomands/"+me.charname+"-lastgame.txt", 1, game); // writes current game for comparing to new game to join next time in lobby
  380. game = "";
  381. }
  382. if(retryLeaderGame > 0 && !tryLeaderGame1x && retryLeaderGameCount < retryLeaderGame) { // increases the leadergamecount
  383. retryLeaderGameCount++;
  384. }
  385. if(retryLeaderGame > 0 && !tryLeaderGame1x && retryLeaderGameCount >= retryLeaderGame) { // sets game name to "" because we have made as many attempts as configured to join
  386. game = "";
  387. }
  388. controlData.click(controlData.controls.lobby.join.button.joinGame);
  389. RunGC(); // run garbage collector between each game
  390.  
  391. locationTimeout(5000, location);
  392. lastGameStatus = 1; // pending join
  393. }
  394. else
  395. {
  396. DebugInOOG('No game to join : cancelling');
  397. me.Cancel(1);
  398. Delay(1000);
  399. }
  400. break;
  401.  
  402. case 6: // Ladder
  403. break;
  404.  
  405. case 7: // Channel List
  406. break;
  407.  
  408. case 8: // Main Menu
  409. if(controlData.getCurrentRealmIndex() == me.gatewayid)
  410. {
  411. outputGameLength();
  412. controlData.click(controlData.gameTypes[me.playtype]);
  413. }
  414. else
  415. controlData.click(controlData.controls.mainMenu.button.gateway);
  416. break;
  417.  
  418. case 9: // Login
  419. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  420. Delay(loginDelay);
  421.  
  422. controlData.setText(controlData.controls.login.editBox.accountName, me.account);
  423.  
  424. sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);
  425.  
  426. locationTimeout(5000, location);
  427. break;
  428.  
  429. case 10: // Login Error (this is a fatal error, so stop)
  430. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad Account or PW Entered.......Idling", 0);
  431. while(1) { Delay(500); }
  432. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
  433. Delay(3500);
  434. break;
  435.  
  436. case 11: // Unable To Connect
  437. timeoutDelay(unableToConnectRetry*60*1000, location)
  438. controlData.click(controlData.controls.login.unableToConnect.button.ok);
  439. break;
  440.  
  441. case 12: // Character Select
  442. var _time, _control;
  443.  
  444. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  445.  
  446. for(_time = 0 ; _time < characterScreenTimeout ; _time += 500)
  447. {
  448. _control = controlData.get(controlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
  449. if(_control && _control.GetText() != undefined)
  450. break;
  451.  
  452. Delay(500);
  453. }
  454.  
  455. if(_time < characterScreenTimeout)
  456. {
  457. Delay(characterSelectDelay);
  458.  
  459. controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
  460. controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);
  461.  
  462. // reset last game made, so it doesnt make a game immediately
  463. inGameAt = 0;
  464. setNextGameMake();
  465. }
  466. else
  467. {
  468. controlData.click(controlData.controls.characterSelect.button.exit);
  469. timeoutDelay(realmDownRetry*60*1000, location);
  470. }
  471. break;
  472.  
  473. case 13: // Realm Down - Character Select screen
  474. controlData.click(controlData.controls.characterSelect.button.exit);
  475. timeoutDelay(realmDownRetry*60*1000, location);
  476. break;
  477.  
  478. case 14: // Character Select - Disconnected
  479. timeoutDelay(disconnectedRetry*60*1000, location);
  480. controlData.click(controlData.controls.characterSelect.disconnected.button.ok);
  481. break;
  482.  
  483. case 15: // New Character
  484. break;
  485.  
  486. case 16: // Character Select - Please Wait popup
  487. if(!locationTimeout(pleaseWaitTimeout, location))
  488. controlData.click(controlData.controls.characterSelect.pleaseWait.button.cancel);
  489. break;
  490.  
  491. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  492. controlData.click(controlData.controls.lobby.lostConnection.button.ok);
  493. break;
  494.  
  495. case 18: // D2 Splash
  496. controlData.click(controlData.controls.d2Splash.textBox.copyright);
  497. break;
  498.  
  499. case 19: // Login - Cdkey In Use
  500. timeoutDelay(cdkeyInUseRetry*60*1000, location);
  501. controlData.click(controlData.controls.login.cdkeyInUse.button.ok);
  502. break;
  503.  
  504. case 20: // Single Player - Select Difficulty
  505. controlData.click(controlData.singlePlayerDifficulties[me.diff]);
  506. break;
  507.  
  508. case 21: // Main Menu - Connecting
  509. if(!locationTimeout(connectingToBnetTimeout, location))
  510. controlData.click(controlData.controls.mainMenu.connecting.button.cancel);
  511. break;
  512.  
  513. case 22: // Login - Invalid Cdkey (classic or xpac)
  514. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad CD Key...........Idling", 0);
  515. while(1) { Delay(500); }
  516. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
  517. Delay(3500);
  518. break;
  519.  
  520. case 23: // Character Select - Connecting
  521. if(!locationTimeout(characterScreenTimeout, location))
  522. controlData.click(controlData.controls.characterSelect.button.exit);
  523. break;
  524.  
  525. case 24: // Server Down - not much to do but wait..
  526. break;
  527.  
  528. case 25: // Lobby - Please Wait
  529. if(!locationTimeout(pleaseWaitTimeout, location))
  530. controlData.click(controlData.controls.lobby.pleaseWait.button.cancel);
  531. break;
  532.  
  533. case 26: // Lobby - Game Name Exists
  534. sendEventToOOG(D2NT_MGR_PRINT_LOG, "yE00000Game already exists", 0);
  535.  
  536. inGameAt = 0;
  537. lastGameStatus = 0;
  538. setNextGameMake();
  539.  
  540. locationTimeout(15000, location);
  541. break;
  542.  
  543. case 27: // Gateway Select
  544. controlData.clickRealmEntry(me.gatewayid);
  545. controlData.click(controlData.controls.gateway.button.ok);
  546. break;
  547.  
  548. case 28: // Lobby - Game Does Not Exist
  549. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Leader's game does not exist...........Idling", 0);
  550. Delay(gameDoesNotExistDelay*1000);
  551. inGameAt = Random(gameDoesNotExistDelayMin, gameDoesNotExistDelayMax);
  552. lastGameStatus = 0;
  553. setNextGameMake();
  554.  
  555. locationTimeout(gameDoesNotExistTimeout, location);
  556. break;
  557. default:
  558. if (lastGameStatus == 1) {
  559. sendEventToOOG(D2NT_MGR_PRINT_STATUS, "Please Wait...", 0);
  560. for (ftjcount=0; ftjcount<=10 && !me.ingame; ftjcount++) {
  561. Delay(1000)
  562. }
  563. }
  564. DebugInOOG("Unhandled location : "+location.id);
  565. break;
  566. }
  567. DebugInOOG("Location : "+location.id);
  568. }
  569.  
  570. function sendEventToOOG(locationId, statusString, pendingTime)
  571. {
  572. return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
  573. }
  574.  
  575. function setNextGameMake()
  576. {
  577. lastGameMade = GetTickCount();
  578. nextGameMake = lastGameMade + createGameThreshold + Random(0-createGameThresholdRandom, createGameThresholdRandom) + inGameAt;
  579. inGameAt = 0;
  580. chatActionsDone = false;
  581. }
  582.  
  583. function outputGameLength()
  584. {
  585. if(inGameAt)
  586. {
  587. duration = GetTickCount() - inGameAt;
  588.  
  589. inGameAt = (duration < gameMinLength ? gameMinLength - duration : 0);
  590. }
  591. }
  592.  
  593. function locationTimeout(time, location)
  594. {
  595. endtime = GetTickCount() + time;
  596.  
  597. while(controlData.getLocation().id == location.id && endtime > GetTickCount())
  598. {
  599. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  600. Delay(500);
  601. }
  602.  
  603. return (controlData.getLocation().id != location.id);
  604. }
  605.  
  606. function timeoutDelay(time, location)
  607. {
  608. endtime = GetTickCount() + time;
  609.  
  610. while(endtime > GetTickCount())
  611. {
  612. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  613. Delay(1000);
  614. if(me.ingame){ Delay(1000); return;}
  615. }
  616. }
  617.  
  618. function getRandomString(_length)
  619. {
  620. _retString = "";
  621. _charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
  622.  
  623. while(_length--)
  624. {
  625. _retString += _charSet.charAt(Random(0, _charSet.length-1));
  626. Delay(1);
  627. }
  628.  
  629. return _retString;
  630. }
  631. function DebugInOOG(logString)
  632. {
  633. if (Debug)
  634. return SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + logString);
  635. else
  636. return false;
  637. }
  638.  
  639. function My_ExitGame_Check()
  640. {
  641. for (var i = 0; i < 40; i++)
  642. {
  643. if (controlData.getLocation().id != undefined)
  644. break;
  645.  
  646. if (i > 38)
  647. {
  648. LogPrintSimple(me.account + " StarterTest.txt", "White Screen of Death: Restarting")
  649. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "White Screen of Death: Restarting", 0);
  650. sendEventToOOG(D2NT_MGR_RESTART, "", 5);
  651. My_Delay(); // make sure and add this also
  652. }
  653.  
  654. Delay(500);
  655. }
  656. }
  657.  
  658. function My_Delay(retry)
  659. {
  660. if (arguments.length < 1)
  661. retry = 20;
  662.  
  663. while (retry-- > 0)
  664. Delay(1000);
  665. }
  666.  
  667. function LogPrintSimple(filepath, mesg){
  668.  
  669. var _filepath = filepath;
  670. var _mesg = mesg;
  671.  
  672. var date = new Date().toLocaleFormat("<%a, %b %d, %H:%M>");
  673. var logfile = FileOpen(_filepath, 2); // opens file
  674. if(!logfile)
  675. var logfile = FileOpen(_filepath, 1); // if file not there then creates it
  676.  
  677. logfile.WriteLine(date + " " + _mesg );
  678. logfile.Close();
  679. }
  680.  
  681. function GateWayToName(){
  682. switch(me.gatewayid){
  683. case 0: return 'USWest';
  684. case 1: return 'USEast';
  685. case 2: return 'Asia';
  686. case 3: return 'Europe';
  687. default: return 'ugly'; // not sure how asia1, asia2, etc work so adding this for now
  688. }
  689. }
  690. // modes 0 = read only, 1 = overwrite the file, 2 = add to file
  691. function NT_File(path, mode, msg, delay) { //big thanks to all the koreans out there
  692. var _msg = "";
  693. var _line = "";
  694. var _fileHandle;
  695. var _isFileCheck = false;
  696.  
  697. if (arguments.length < 3) { msg = ""; }
  698. if (arguments.length < 4) { delay = (mode > 0) ? 5 : 2; }
  699.  
  700. while (delay--) {
  701. if (mode == 2 && !_isFileCheck) {
  702. _fileHandle = FileOpen(path, 0);
  703. if (!_fileHandle)
  704. _fileHandle = FileOpen(path, 1);
  705.  
  706. if (_fileHandle)
  707. _fileHandle.Close();
  708.  
  709. _isFileCheck = true;
  710. }
  711.  
  712. _fileHandle = FileOpen(path, mode);
  713. if (_fileHandle)
  714. break;
  715.  
  716. if (delay)
  717. Delay(200);
  718. }
  719.  
  720. if (_fileHandle) {
  721. if (mode == 0) {
  722. while (!_fileHandle.eof) {
  723. _line = _fileHandle.ReadLine();
  724. if (_line || !_fileHandle.eof)
  725. _msg += _line + msg;
  726. }
  727. }
  728. else if (msg)
  729. _fileHandle.WriteLine(msg);
  730.  
  731. _fileHandle.Close();
  732. }
  733.  
  734. return _msg;
  735. }
  736.  
  737. function NT_RetrieveLastGame() {
  738. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 0); // open file in read only
  739. if(!grabLastGame){
  740. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 1); // because the file doesn't exist create it
  741. }
  742. if(grabLastGame){
  743. 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
  744. grabLastGame.Close();
  745. }
  746. return;
  747. }
  748.  
  749. function NT_RetrievenextGame() { // to retrieve game and pw
  750. var grabLine;
  751. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 0); // open file in read only
  752. if(!grabNextGame){
  753. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 1); // because the file doesn't exist create it
  754. }
  755. if(grabNextGame){
  756. 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
  757. game = grabLine.substring(0, grabLine.indexOf('/')); //extracting game name from beginning of line to the "/"
  758. gamepassword = grabLine.substring(grabLine.indexOf('/') + 1, grabLine.length); //Parse after symbol till end of line.
  759. grabNextGame.Close();
  760. }
  761. return;
  762. }
  763. // 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