Guest User

Untitled

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