Guest User

Untitled

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