gamemaste789

Untitled

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