OFFR500

leechstarter2.2 for OFF Runs

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