Guest User

Untitled

a guest
Apr 22nd, 2018
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 28.62 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 = "Rsin-1";
  16. var leaderName = "WBarbra";
  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", 1200];
  24. var leecher2 = ["characterName", 2000];
  25. var leecher3 = ["characterName", 2250];
  26. var leecher4 = ["characterName", 3000];
  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 = 0; // 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
  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 = "";
  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 = false;
  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 = "Op Reternal";
  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. for (var line_id = lines.length - 1; line_id > -1; line_id--)
  284. {
  285. if (found_leader) // useless... :/
  286. break;
  287.  
  288. if (lines[line_id].substring(0,1) == " ")
  289. continue;
  290.  
  291. // retrieving the whole message
  292. var msg = lines[line_id].replace(/^\s+|\s+$/, "");
  293. var msglines = 1;
  294. while (lines[line_id+msglines] != undefined && lines[line_id+msglines].substring(0,2) == " ")
  295. {
  296. msg += " " + lines[line_id+msglines].replace(/^\s+|\s+$/, "");
  297. msglines++;
  298. }
  299. if (msg.lastIndexOf(leaderName) >= 0)
  300. DebugInOOG("yc8found him :;"+msg);
  301.  
  302. // checking if the msg is a friendly whisper
  303. if (msg.lastIndexOf(leaderName + ' (*' +leaderAccountName+')') > -1 || msg.lastIndexOf(leaderName + '@' + GateWayToName() + ' (*' +leaderAccountName+')') > -1)
  304. // if (msg.lastIndexOf(leaderName + ' (*' +leaderAccountName+')') > -1) // need to modify this and then add another to handle the "@USWest
  305. { // should be just a matter of leaderName + '@' and then register the 2nd line as game name
  306. var regGameNameWhispered=/^.*in_new_game\s+(.*)$/gi; // replaced below with this to join on mesage upon entering game
  307. //var regGameNameWhispered=/^.*(game|partie|spiel|partita|partida).*(nomm[^\s]*|called|chiamata)\s*([\w\s-]*\w)\s*\.\s*$/gi;
  308. if (msg.match(regGameNameWhispered))
  309. game = msg.replace(regGameNameWhispered, "$1"); // replaced below with this to join on mesage upon entering game
  310. //game = msg.replace(regGameNameWhispered, "$3");
  311.  
  312. if (game != '')
  313. {
  314. found_leader = true;
  315. break;
  316. }
  317. }
  318.  
  319. // checking if the msg is from the friend list
  320. if (msg.lastIndexOf(': '+leaderAccountName+',') > -1)
  321. {
  322. found_leader = true;
  323. var regOffline=/^.*(offline|desconectado).*$/gi;
  324. var regInChat=/^.*(channel|canale?)\s*([\w\s-]*\w)\.?\s*$/gi;
  325. var regGameName=/^.*(game|partie|spiel|partita|partida)\s*([\w\s-]*\w)\s*\(priv[^\)]*\)\.\s*$/gi;
  326.  
  327. if (msg.match(regOffline)
  328. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  329. {
  330. DebugInOOG('Leader is offline, delay '+Math.round(LeaderOfflineDelay/1000)+' sec for next /f l.');
  331. _leaderOfflineTick = GetTickCount();
  332. }
  333. else if (msg.match(regInChat)
  334. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick))
  335. {
  336. DebugInOOG('Leader is in the chat "'+msg.replace(regInChat, "$2")+'", delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  337. _leaderInChatTick = GetTickCount();
  338. }
  339. else if (msg.match(regGameName)
  340. && ((_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick)
  341. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)))
  342. {
  343. game = msg.replace(regGameName, "$2");
  344. }
  345. else if ((_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)
  346. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  347. {
  348. // unhandled line, supposelly "In Realm"
  349. DebugInOOG('The leader was in the the lobby but not in chat, delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  350. _leaderInChatTick = GetTickCount();
  351. }
  352.  
  353. break;
  354. }
  355. }
  356.  
  357. if (found_leader == false)
  358. DebugInOOG('I couldn\'t find the leader in my friend list!');
  359. }
  360. else
  361. {
  362. DebugInOOG('I can\'t read the chat!');
  363. //DebugInOOG('You probably haven\'t added the lobby chat controlinfo coordinates!');
  364. Delay(30000);
  365. }
  366. }
  367. if(!reEnterSameGame) { // added to check game name. If same as last game then don't re enter.
  368. NT_RetrieveLastGame();
  369. //Delay(250);
  370. if(lastGame == game) {
  371. game = "";
  372. }
  373. }
  374. if (game!="")
  375. {
  376. if (UseCDKeyChangeTrick)
  377. {
  378. // increasing the number of runs in the OOG (for CDKey switch)
  379. // Problem : the gamename/gamepassword set in your OOG will be typed in the lobbyChat
  380. // this may output a red message in the lobby chat if you have a password set (not a real problem)
  381. // 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
  382. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  383. Delay(1000);
  384. }
  385.  
  386. DebugInOOG('Leader is in the game "' + game + '"');
  387. controlData.click(controlData.controls.lobby.button.join);
  388. Delay(100);
  389. }
  390.  
  391. break;
  392.  
  393. case 1: // Lobby
  394. if(location.id == 1 && joinChatAfterGame)
  395. {
  396. //LogPrintSimple(me.account + "MyAccountTest.txt", me.account + " / " + me.charname) // this is to check for 2nd account login
  397. Delay(Random(waitBeforeEnterChatMin, waitBeforeEnterChatMax));
  398. controlData.click(controlData.controls.lobby.button.enterChat);
  399. break;
  400. }
  401. break;
  402.  
  403. case 2: // Waiting In Line
  404. if(GetTickCount()-lastGameMade > waitInLineTimeout)
  405. controlData.click(controlData.controls.lobby.inLine.button.cancel);
  406. break;
  407.  
  408. case 4: // Create Game
  409. if(!controlData.get(controlData.controls.lobby.create.editBox.gameName))
  410. {
  411. controlData.click(controlData.controls.lobby.button.join);
  412. Delay (500);
  413. controlData.click(controlData.controls.lobby.button.create);
  414. Delay (500);
  415. break;
  416. }
  417.  
  418. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  419.  
  420. locationTimeout(5000, location);
  421.  
  422. lastGameMade = GetTickCount();
  423. lastGameStatus = 1; // pending creation
  424. break;
  425.  
  426. case 5: // Join Game
  427. if (game)
  428. {
  429. controlData.setText( controlData.controls.lobby.join.editBox.gameName, game);
  430. Delay (100);
  431. controlData.setText( controlData.controls.lobby.join.editBox.password, gamepassword);
  432. //SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + COLOR_1 +me.charname);
  433. if(leecher1[0] == me.charname){
  434. Delay(leecher1[1]);
  435. }
  436. else if(leecher2[0] == me.charname){
  437. Delay(leecher2[1]);
  438. }
  439. else if(leecher3[0] == me.charname){
  440. Delay(leecher3[1]);
  441. }
  442. else{
  443. Delay(100);
  444. }
  445. controlData.click(controlData.controls.lobby.join.button.joinGame);
  446. RunGC(); // run garbage collector between each game
  447. locationTimeout(5000, location);
  448. lastGameStatus = 1; // pending join
  449. }
  450. else
  451. {
  452. DebugInOOG('No game to join : cancelling');
  453. me.Cancel(1);
  454. Delay(1000);
  455. }
  456. break;
  457.  
  458. case 6: // Ladder
  459. break;
  460.  
  461. case 7: // Channel List
  462. break;
  463.  
  464. case 8: // Main Menu
  465. if(controlData.getCurrentRealmIndex() == me.gatewayid)
  466. {
  467. outputGameLength();
  468. controlData.click(controlData.gameTypes[me.playtype]);
  469. }
  470. else
  471. controlData.click(controlData.controls.mainMenu.button.gateway);
  472. break;
  473.  
  474. case 9: // Login
  475. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  476. Delay(loginDelay);
  477.  
  478. controlData.setText(controlData.controls.login.editBox.accountName, me.account);
  479.  
  480. sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);
  481.  
  482. locationTimeout(5000, location);
  483. break;
  484.  
  485. case 10: // Login Error (this is a fatal error, so stop)
  486. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad Account or PW Entered.......Idling", 0);
  487. while(1) { Delay(500); }
  488. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
  489. Delay(3500);
  490. break;
  491.  
  492. case 11: // Unable To Connect
  493. timeoutDelay(unableToConnectRetry*60*1000, location)
  494. controlData.click(controlData.controls.login.unableToConnect.button.ok);
  495. break;
  496.  
  497. case 12: // Character Select
  498. var _time, _control;
  499.  
  500. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  501.  
  502. for(_time = 0 ; _time < characterScreenTimeout ; _time += 500)
  503. {
  504. _control = controlData.get(controlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
  505. if(_control && _control.GetText() != undefined)
  506. break;
  507.  
  508. Delay(500);
  509. }
  510.  
  511. if(_time < characterScreenTimeout)
  512. {
  513. Delay(characterSelectDelay);
  514.  
  515. controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
  516. controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);
  517.  
  518. // reset last game made, so it doesnt make a game immediately
  519. inGameAt = 0;
  520. setNextGameMake();
  521. }
  522. else
  523. {
  524. controlData.click(controlData.controls.characterSelect.button.exit);
  525. timeoutDelay(realmDownRetry*60*1000, location);
  526. }
  527. break;
  528.  
  529. case 13: // Realm Down - Character Select screen
  530. controlData.click(controlData.controls.characterSelect.button.exit);
  531. timeoutDelay(realmDownRetry*60*1000, location);
  532. break;
  533.  
  534. case 14: // Character Select - Disconnected
  535. timeoutDelay(disconnectedRetry*60*1000, location);
  536. controlData.click(controlData.controls.characterSelect.disconnected.button.ok);
  537. break;
  538.  
  539. case 15: // New Character
  540. break;
  541.  
  542. case 16: // Character Select - Please Wait popup
  543. if(!locationTimeout(pleaseWaitTimeout, location))
  544. controlData.click(controlData.controls.characterSelect.pleaseWait.button.cancel);
  545. break;
  546.  
  547. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  548. controlData.click(controlData.controls.lobby.lostConnection.button.ok);
  549. break;
  550.  
  551. case 18: // D2 Splash
  552. controlData.click(controlData.controls.d2Splash.textBox.copyright);
  553. break;
  554.  
  555. case 19: // Login - Cdkey In Use
  556. timeoutDelay(cdkeyInUseRetry*60*1000, location);
  557. controlData.click(controlData.controls.login.cdkeyInUse.button.ok);
  558. break;
  559.  
  560. case 20: // Single Player - Select Difficulty
  561. controlData.click(controlData.singlePlayerDifficulties[me.diff]);
  562. break;
  563.  
  564. case 21: // Main Menu - Connecting
  565. if(!locationTimeout(connectingToBnetTimeout, location))
  566. controlData.click(controlData.controls.mainMenu.connecting.button.cancel);
  567. break;
  568.  
  569. case 22: // Login - Invalid Cdkey (classic or xpac)
  570. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad CD Key...........Idling", 0);
  571. while(1) { Delay(500); }
  572. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
  573. Delay(3500);
  574. break;
  575.  
  576. case 23: // Character Select - Connecting
  577. if(!locationTimeout(characterScreenTimeout, location))
  578. controlData.click(controlData.controls.characterSelect.button.exit);
  579. break;
  580.  
  581. case 24: // Server Down - not much to do but wait..
  582. break;
  583.  
  584. case 25: // Lobby - Please Wait
  585. if(!locationTimeout(pleaseWaitTimeout, location))
  586. controlData.click(controlData.controls.lobby.pleaseWait.button.cancel);
  587. break;
  588.  
  589. case 26: // Lobby - Game Name Exists
  590. sendEventToOOG(D2NT_MGR_PRINT_LOG, "yE00000Game already exists", 0);
  591.  
  592. inGameAt = 0;
  593. lastGameStatus = 0;
  594. setNextGameMake();
  595.  
  596. locationTimeout(15000, location);
  597. break;
  598.  
  599. case 27: // Gateway Select
  600. controlData.clickRealmEntry(me.gatewayid);
  601. controlData.click(controlData.controls.gateway.button.ok);
  602. break;
  603.  
  604. case 28: // Lobby - Game Does Not Exist
  605. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Leader's game does not exist...........Idling", 0);
  606. Delay(gameDoesNotExistDelay*1000);
  607. inGameAt = Random(gameDoesNotExistDelayMin, gameDoesNotExistDelayMax);
  608. lastGameStatus = 0;
  609. setNextGameMake();
  610.  
  611. locationTimeout(gameDoesNotExistTimeout, location);
  612. break;
  613. default:
  614. DebugInOOG("Unhandled location : "+location.id);
  615. break;
  616. }
  617. DebugInOOG("Location : "+location.id);
  618. }
  619.  
  620. function sendEventToOOG(locationId, statusString, pendingTime)
  621. {
  622. return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
  623. }
  624.  
  625. function setNextGameMake()
  626. {
  627. lastGameMade = GetTickCount();
  628. nextGameMake = lastGameMade + createGameThreshold + Random(0-createGameThresholdRandom, createGameThresholdRandom) + inGameAt;
  629. inGameAt = 0;
  630. chatActionsDone = false;
  631. }
  632.  
  633. function outputGameLength()
  634. {
  635. if(inGameAt)
  636. {
  637. duration = GetTickCount() - inGameAt;
  638.  
  639. inGameAt = (duration < gameMinLength ? gameMinLength - duration : 0);
  640. }
  641. }
  642.  
  643. function locationTimeout(time, location)
  644. {
  645. endtime = GetTickCount() + time;
  646.  
  647. while(controlData.getLocation().id == location.id && endtime > GetTickCount())
  648. {
  649. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  650. Delay(500);
  651. }
  652.  
  653. return (controlData.getLocation().id != location.id);
  654. }
  655.  
  656. function timeoutDelay(time, location)
  657. {
  658. endtime = GetTickCount() + time;
  659.  
  660. while(endtime > GetTickCount())
  661. {
  662. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  663. Delay(1000);
  664. }
  665. }
  666.  
  667. function getRandomString(_length)
  668. {
  669. _retString = "";
  670. _charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
  671.  
  672. while(_length--)
  673. {
  674. _retString += _charSet.charAt(Random(0, _charSet.length-1));
  675. Delay(1);
  676. }
  677.  
  678. return _retString;
  679. }
  680. function DebugInOOG(logString)
  681. {
  682. if (Debug)
  683. return SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + logString);
  684. else
  685. return false;
  686. }
  687.  
  688. function My_ExitGame_Check()
  689. {
  690. for (var i = 0; i < 40; i++)
  691. {
  692. if (controlData.getLocation().id != undefined)
  693. break;
  694.  
  695. if (i > 38)
  696. {
  697. LogPrintSimple(me.account + " StarterTest.txt", "White Screen of Death: Restarting")
  698. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "White Screen of Death: Restarting", 0);
  699. sendEventToOOG(D2NT_MGR_RESTART, "", 5);
  700. My_Delay(); // make sure and add this also
  701. }
  702.  
  703. Delay(500);
  704. }
  705. }
  706.  
  707. function My_Delay(retry)
  708. {
  709. if (arguments.length < 1)
  710. retry = 20;
  711.  
  712. while (retry-- > 0)
  713. Delay(1000);
  714. }
  715.  
  716. function LogPrintSimple(filepath, mesg){
  717.  
  718. var _filepath = filepath;
  719. var _mesg = mesg;
  720.  
  721. var date = new Date().toLocaleFormat("<%a, %b %d, %H:%M>");
  722. var logfile = FileOpen(_filepath, 2); // opens file
  723. if(!logfile)
  724. var logfile = FileOpen(_filepath, 1); // if file not there then creates it
  725.  
  726. logfile.WriteLine(date + " " + _mesg );
  727. logfile.Close();
  728. }
  729.  
  730. function GateWayToName(){
  731. switch(me.gatewayid){
  732. case 0: return 'USWest';
  733. case 1: return 'USEast';
  734. case 2: return 'Asia';
  735. case 3: return 'Europe';
  736. default: return 'ugly'; // not sure how asia1, asia2, etc work so adding this for now
  737. }
  738. }
  739. // modes 0 = read only, 1 = overwrite the file, 2 = add to file
  740. function NT_File(path, mode, msg, delay) { //big thanks to all the koreans out there
  741. var _msg = "";
  742. var _line = "";
  743. var _fileHandle;
  744. var _isFileCheck = false;
  745.  
  746. if (arguments.length < 3) { msg = ""; }
  747. if (arguments.length < 4) { delay = (mode > 0) ? 5 : 2; }
  748.  
  749. while (delay--) {
  750. if (mode == 2 && !_isFileCheck) {
  751. _fileHandle = FileOpen(path, 0);
  752. if (!_fileHandle)
  753. _fileHandle = FileOpen(path, 1);
  754.  
  755. if (_fileHandle)
  756. _fileHandle.Close();
  757.  
  758. _isFileCheck = true;
  759. }
  760.  
  761. _fileHandle = FileOpen(path, mode);
  762. if (_fileHandle)
  763. break;
  764.  
  765. if (delay)
  766. Delay(200);
  767. }
  768.  
  769. if (_fileHandle) {
  770. if (mode == 0) {
  771. while (!_fileHandle.eof) {
  772. _line = _fileHandle.ReadLine();
  773. if (_line || !_fileHandle.eof)
  774. _msg += _line + msg;
  775. }
  776. }
  777. else if (msg)
  778. _fileHandle.WriteLine(msg);
  779.  
  780. _fileHandle.Close();
  781. }
  782.  
  783. return _msg;
  784. }
  785.  
  786. function NT_RetrieveLastGame() {
  787. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 0); // open file in read only
  788. if(!grabLastGame){
  789. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 1); // because the file doesn't exist create it
  790. }
  791. if(grabLastGame){
  792. 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
  793. }
  794. grabLastGame.Close();
  795. return;
  796. }
  797.  
  798. function NT_RetrievenextGame() { // to retrieve game and pw
  799. var grabLine;
  800. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 0); // open file in read only
  801. if(!grabNextGame){
  802. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 1); // because the file doesn't exist create it
  803. }
  804. if(grabNextGame){
  805. 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
  806. game = grabLine.substring(0, grabLine.indexOf('/')); //extracting game name from beginning of line to the "/"
  807. gamepassword = grabLine.substring(grabLine.indexOf('/') + 1, grabLine.length); //Parse after symbol till end of line.
  808. }
  809. grabNextGame.Close();
  810. return;
  811. }
  812. // 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