Don't like ads? PRO users don't see any ads ;-)
Guest

ntbotorig.ntj

By: a guest on Apr 29th, 2012  |  syntax: None  |  size: 21.79 KB  |  hits: 19  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. ///////////////////////////////////////////////////
  2. //           Break and Keyinuse Settings         //
  3. ///////////////////////////////////////////////////
  4.  
  5. ///////////////////////////////////////////////////
  6. //  take a break after a certain amount of runs  //
  7. ///////////////////////////////////////////////////
  8. var doBreak = true;                     // do you wanna take a break? true/false
  9. var breakMinutes = 5;           // how long will the break last?
  10. var breakAfterGames = 30;       // amount of games
  11.  
  12. var keyInUse = [true, 7];       // 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)]
  13.  
  14. ///////////////////////////////////////////////////
  15. //        characters in your game setting:               //            
  16. ///////////////////////////////////////////////////
  17. var characterdiff        =  "99";       //use this to keep those pesky spam bots out of the f'ing game
  18.                                                                         //note you must manually hit the check box the first time for this to work
  19. var maxNumberOfPlayersss = "8";         //use this to set the maximum number of players allowed in your game
  20.  
  21. ///////////////////////////////////////
  22. //        Channel Settings:              //             / /These controll what if any channel you join
  23. ///////////////////////////////////////
  24. var joinChatAfterGame                   = true;                  // join chat after leaving a game
  25. var joinRandomChannel                   = false;                 // if this is true, will join a random channel, otherwise it will use the channel below..
  26. var joinChannelInChat                   = "Op Ballins";          // Channel you want your bot to join, leave blank to not join a private channel
  27.  
  28. ///////////////////////////////////////
  29. //        Message Settings:              //             // These controll what your bot sais to the leechers will also send a log incommand to a channel bot
  30. ///////////////////////////////////////
  31. var chatMessageOnJoin                   = ".login";     // Chat Message to say Login command for channel bot will only be sent once
  32. var chatMessageAfterGame1               = "";   // Optional chat message Line #1 to say after each game on Channel
  33. var chatMessageAfterGame2               = "";           // Optional chat message Line #2 to say after each game on Channel
  34. var chatMessageAfterGame3               = "";           // Optional chat message Line #3 to say after each game on Channel
  35. var chatMessageAfterGame4               = "";           // Optional chat message Line #4 to say after each game on Channel
  36. var chatMessageAfterGame5               = "";   // Optional chat message Line #5 to say after each game on Channel
  37.  
  38. ///////////////////////////////////////         // These will let you send a message with a game name password and time to your leechers
  39. //      Game Message Settings:       //         // var saygamename must be true for any of these to work
  40. ///////////////////////////////////////         // You cant NOT have a - in you game name it will bug it out
  41. var saygamename                         = true;                                         // Must be true for any of the game message settings to work
  42. var nextgamemessage                     = "next game should be";        // This will come befor your next game name eg "New game is"
  43. var saypassword                         = false;                                                // This will togle if the bot says your game pw
  44. var saytime                             = true;                                         // This will togle if the bot says how much time till creation
  45. var timemessage                         = "in about";                           // This will come after your pw and befor the time eg. "in about" xx seconds say time MUST be true for this to be used
  46.  
  47. //////////////////////////////////////
  48. //       Minimum Game Length:       //
  49. //////////////////////////////////////
  50.  
  51. var gameMinLength               = 60000;        // time in milliseconds, minimum game length, 180 seconds default (1 game/3 minutes)
  52.  
  53. ////////////////////////////////////////
  54. //        Connection Settings:        //
  55. ////////////////////////////////////////
  56.  
  57. var unableToConnectRetry        = 10;           // time in minutes to retry connecting on connection fail (real value is +/- 1 min)
  58. var realmDownRetry              = 300;          // time in minutes to retry connecting on a realm down (default is 300 minutes)
  59. var disconnectedRetry           = 10;           // time in minutes to retry on a disconnection (usually ip ban related)
  60. var cdkeyInUseRetry             = 1;            // time in minutes to retry on a cdkey in use error message (set to 0 to stop)
  61. var connectingToBnetTimeout     = 20000;        // time in milliseconds to wait for a login to time out and click cancel and retry
  62. var characterScreenTimeout      = 5000; // time in milliseconds to wait for character screen to appear
  63. var pleaseWaitTimeout           = 5000; // time in milliseconds to wait for a please wait popup
  64. var createGameThreshold         = 10000;                // time in milliseconds to wait between making games
  65. var createGameThresholdRandom   = 500;          // time in milliseconds to randomly add +/- to the game create time
  66. var createGameTimeout           = 10000;        // time in milliseconds to register a failed to create game
  67. var waitInLineTimeout           = 60000;        // time in milliseconds to wait in lines for a create game (60 second default)
  68. var characterSelectDelay        = 1000;         // time in milliseconds to wait before selecting a character on the char screen
  69. var loginDelay                  = 1000;         // time in milliseconds to wait before submitting login information
  70. var clickDelay                  = 1000;         // wait X milliseconds before next action after a click event
  71. var textDelay                   = 1000;         // wait X milliseconds before next action after inserting text into a textbox
  72. var clickDelayRandom            = 1000;         // random amount of time to add to a click
  73. var textDelayRandom             = 1000;         // random amount of time to add to a text set
  74. var gameDoesNotExistDelayMin    = 600000;       // how long to wait when a Game Does Not Exist occurs - minimum - default 10 minutes
  75. var gameDoesNotExistDelayMax    = 900000;       // how long to wait when a Game Does Not Exist occurs - maximum - default 15 minutes
  76. var gameDoesNotExistTimeout     = 30000;        // how long to wait for the dialog to disappear (default 30 seconds, don't change this)
  77. var waitBeforeEnterChatMin      = 1000;         // min how long to wait before entering chat
  78. var waitBeforeEnterChatMax      = 2000;         // max how long to wait before entering chat
  79. var waitInChatBeforeActionsMin  = 2000;         // min how long to wait before joining channel
  80. var waitInChatBeforeActionsMax  = 3000;         // max how long to wait before joining channel
  81. var waitBeforeNextLineChatMin   = 1000;         // Minimum ammount of time to add after each text line 
  82. var waitBeforeNextLineChatMax   = 1500;         // Maximum ammount of time to add after each text line
  83.  
  84. // DONT EDIT ANYTHING BELOW THIS
  85.  
  86. // D2NT Manager Command
  87. const D2NT_MGR_LOADING = 1;
  88. const D2NT_MGR_READY = 2;
  89. const D2NT_MGR_LOGIN = 3;
  90. const D2NT_MGR_CREATE_GAME = 4;
  91. const D2NT_MGR_INGAME = 5;
  92. const D2NT_MGR_RESTART = 6;
  93. const D2NT_MGR_CHICKEN = 7;
  94. const D2NT_MGR_PRINT_STATUS = 8;
  95. const D2NT_MGR_PRINT_LOG = 9;
  96. var alreadyLoggedIn = false; // will only send the login command once leave as unless you want to login everytime you join a channel
  97. var lastGameMade = GetTickCount();
  98. var lastGameStatus = 0;
  99. var nextGameMake = 0;
  100. var inGameAt = 0;
  101. var chatActionsDone = false;
  102. var lastGameFailed = false;
  103. var tempDelay = Random(waitBeforeNextLineChatMin, waitBeforeNextLineChatMax);
  104. var gameInfo = "";
  105. var bugignor = true;
  106. Include("libs/controlInfo.ntl");
  107. Include("libs/common/NTColorConverter.ntl");
  108. var controlData = new controlInfo();
  109.  
  110. function NTMain()
  111. {
  112.         Delay(1000);
  113.  
  114.         var _ingame = false;
  115.  
  116.         controlData.clickDelay = clickDelay;
  117.         controlData.textDelay = textDelay;
  118.         controlData.clickDelayRandom = clickDelayRandom;
  119.         controlData.textDelayRandom = textDelayRandom;
  120.  
  121.         while(1)
  122.         {
  123.                 if(me.ingame)
  124.                 {
  125.                         if(!inGameAt)
  126.                                 inGameAt = GetTickCount();
  127.  
  128.                         if(!_ingame)
  129.                         {
  130.                                 RunGC(); // run garbage collector between each game
  131.  
  132.                                 if(Load("NTBot/NTBotGame.ntj"))
  133.                                 {
  134.                                         _ingame = true;
  135.  
  136.                                         if(me.playtype > 0)
  137.                                                 sendEventToOOG(D2NT_MGR_INGAME, "In Game[IP:" + me.gameserverip.split(".")[3] + "]", 0);
  138.                                         else
  139.                                                 sendEventToOOG(D2NT_MGR_INGAME, "In Game", 0);
  140.  
  141.                                         lastGameStatus = 2; // in game successful
  142.                                 }
  143.                         }
  144.  
  145.                         Delay(1000);
  146.                 }
  147.                 else
  148.                 {
  149.                         if(_ingame)
  150.                         {
  151.                                 _ingame = false;                               
  152.  
  153.                                 sendEventToOOG(D2NT_MGR_READY, "", 0);
  154.                                
  155.                                 /*>>>> BREAK EVERY XXX RUNS <<<<*/     
  156.                                 var _number, breakDone, reallyDoBreak;
  157.                                 // increase the gamecounter by 1
  158.                                 if (doBreak)
  159.                                 {      
  160.                                         _number = MyIL_File("NTBot/run[" + me.charname + "].txt", 0);
  161.                                         _number = 1 * _number + 1;
  162.                                         MyIL_File("NTBot/break[" + me.charname + "].txt", 1, "false", 50);
  163.                                         if(_number >= breakAfterGames)
  164.                                                 MyIL_File("NTBot/break[" + me.charname + "].txt", 1, "true", 50);
  165.                                         else
  166.                                                 MyIL_File("NTBot/break[" + me.charname + "].txt", 1, "false", 50);
  167.                                         MyIL_File("NTBot/run[" + me.charname + "].txt", 1, _number, 50);
  168.                                 }
  169.                         }
  170.                        
  171.                                 // reset everything if we did a break
  172.                                 breakDone = MyIL_File("NTBot/breakDone[" + me.charname + "].txt", 0);
  173.                                 if (doBreak && breakDone == "true")
  174.                                 {
  175.                                                 MyIL_File("NTBot/break[" + me.charname + "].txt", 1, "false", 50);
  176.                                                 MyIL_File("NTBot/run[" + me.charname + "].txt", 1, "0", 50);   
  177.                                                 MyIL_File("NTBot/breakDone[" + me.charname + "].txt", 1, "false", 50);                         
  178.                                 }
  179.                                
  180.                                 // check if we have to do a break
  181.                                 reallyDoBreak = MyIL_File("NTBot/break[" + me.charname + "].txt", 0);
  182.                                 if (doBreak && reallyDoBreak == "true")
  183.                                 {
  184.                                         sendEventToOOG(D2NT_MGR_PRINT_LOG, "ÿc6--------------------------", 0);
  185.                                         sendEventToOOG(D2NT_MGR_PRINT_LOG, "ÿc2Gonna take a " + breakMinutes + " min break.", 0);
  186.                                         sendEventToOOG(D2NT_MGR_PRINT_LOG, "ÿc6--------------------------", 0);       
  187.                                         MyIL_File("NTBot/breakDone[" + me.charname + "].txt", 1, "true", 50);  
  188.                                         sendEventToOOG(D2NT_MGR_RESTART, "", breakMinutes * 60);       
  189.                                         My_Delay();                                    
  190.                                 }                              
  191.                                 /*>>>> BREAK EVERY XXX RUNS <<<<*/                             
  192.  
  193.                         locationAction(controlData.getLocation());
  194.  
  195.                         Delay(500);
  196.                 }
  197.         }
  198. }
  199. function locationAction(location)
  200. {
  201.         switch(location.id)
  202.         {
  203.         case 3: // Lobby Chat
  204.                 if(!chatActionsDone)
  205.                 {
  206.                         chatActionsDone = true;
  207.                         Delay(Random(waitInChatBeforeActionsMin, waitInChatBeforeActionsMax));
  208.  
  209.                         if(joinRandomChannel || joinChannelInChat != "")
  210.                         {
  211.                                 Say("/join " + (joinRandomChannel ? getRandomString(Random(3,10)) : joinChannelInChat));
  212.                                 Delay(1000);
  213.                                         if(!alreadyLoggedIn){
  214.                                         alreadyLoggedIn = true;
  215.                                         if (chatMessageOnJoin.length > 0){
  216.                                                 Say(chatMessageOnJoin);
  217.                                         }
  218.                                         }
  219.                                 Delay(1000);
  220.                                 chatActionsDone = true;
  221.                         }
  222.                 }
  223.         case 1: // Lobby
  224.                 if(location.id == 1 && joinChatAfterGame)
  225.                 {
  226.                         Delay(Random(waitBeforeEnterChatMin, waitBeforeEnterChatMax));
  227.                         controlData.click(controlData.controls.lobby.button.enterChat);
  228.                         break;
  229.                 }
  230.  
  231.                 if(GetTickCount() > nextGameMake)
  232.                 {
  233.                         lastGameFailed = false;
  234.  
  235.                         switch(lastGameStatus)
  236.                         {
  237.                         case 0:
  238.                                 password = (me.gamepassword);
  239.                                 game = (getGameName(me.gamename));
  240.                                 counter = (getGameCounter(me.gamename, false));
  241.                                 time = (parseInt((nextGameMake - GetTickCount() - tempDelay)/1000+3.0));
  242.                                 if (saygamename){{
  243.                                         gameInfo += nextgamemessage + " " + game + counter;
  244.                                 }
  245.                                         if (saypassword){
  246.                                         gameInfo += "//" + password
  247.                                         }
  248.                                                 if (saytime){
  249.                                                 gameInfo += " " + timemessage + " " + time + " seconds"
  250.                                                 }
  251.                                 }
  252.                                 if(joinChatAfterGame){
  253.                                         if(chatMessageAfterGame1.length > 0){
  254.                                                 Say(chatMessageAfterGame1);
  255.                                                 if(chatMessageAfterGame1.length > 0){
  256.                                                         Delay(tempDelay);
  257.                                                 }
  258.                                         }
  259.                                         if(chatMessageAfterGame2.length > 0){
  260.                                                 Say(chatMessageAfterGame2);
  261.                                                         if(chatMessageAfterGame2.length > 0){
  262.                                                                 Delay(tempDelay);
  263.                                                         }
  264.                                         }
  265.                                         if(chatMessageAfterGame3.length > 0){
  266.                                                 Say(chatMessageAfterGame3);
  267.                                                 if(chatMessageAfterGame3.length > 0){
  268.                                                         Delay(tempDelay);
  269.                                                 }
  270.                                         }
  271.                                         if(chatMessageAfterGame4.length > 0){
  272.                                                 Say(chatMessageAfterGame4);
  273.                                                 if(chatMessageAfterGame4.length > 0){
  274.                                                         Delay(tempDelay);
  275.                                                 }
  276.                                         }
  277.                                         if(chatMessageAfterGame5.length > 0){
  278.                                                 Say(chatMessageAfterGame5);
  279.                                                 if(chatMessageAfterGame5.length > 0){
  280.                                                         Delay(tempDelay);
  281.                                                 }
  282.                                         }
  283.                                         if(saygamename) {
  284.                                                 if(bugignor){
  285.                                                         bugignor = false;
  286.                                                         gameInfo = "";
  287.                                                 }
  288.                                         else{
  289.                                                 Say(gameInfo)
  290.                                                 Delay(tempDelay)
  291.                                                 gameInfo = "";
  292.                                         }
  293.                                         }
  294.                                 }
  295.                                 _control = controlData.get(controlData.controls.lobby.button.create); // fixes creation stuck button bug out of unmodded d2nt
  296.                                 if(_control && _control.pressed)
  297.                                 {
  298.                                         controlData.click(controlData.controls.lobby.button.join);
  299.                                         Delay(1000);
  300.                                 }
  301.                                
  302.                                 controlData.click(controlData.controls.lobby.button.create);
  303.                                 _control = controlData.get(controlData.controls.lobby.create.button.useCharacterDifference);
  304.                                 if(_control && !_control.pressed)
  305.                                 {
  306.                                         controlData.click(controlData.controls.lobby.create.button.useCharacterDifference);//checks the use character diff box...does this every time so no go
  307.                                 }
  308.                                 controlData.setText(controlData.controls.lobby.create.editBox.characterDifference,(characterdiff)); //level restriction
  309.                                 controlData.setText(controlData.controls.lobby.create.editBox.maxNumberOfPlayers, (maxNumberOfPlayersss)); //max players
  310.                                 nextGameMake = GetTickCount() + createGameTimeout; // set our timeout
  311.                                 sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  312.                                 break;
  313.                         case 1: // game failed, rollover to reset timer
  314.                                 inGameAt = GetTickCount(); // reset inGameAt, to wait how long we should have waited..
  315.                                 lastGameFailed = true;
  316.                         case 2:
  317.                                 outputGameLength();
  318.                                 lastGameStatus = 0;
  319.                                 setNextGameMake();
  320.                                 sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  321.                                 break;
  322.                         }
  323.                 }
  324.                 else
  325.                         timeoutDelay(nextGameMake-GetTickCount(), location, true);
  326.                 break;
  327.  
  328.         case 2: // Waiting In Line
  329.                 if(GetTickCount()-lastGameMade > waitInLineTimeout)
  330.                         controlData.click(controlData.controls.lobby.inLine.button.cancel);
  331.                 break;
  332.  
  333.         case 4: // Create Game
  334.                 sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  335.  
  336.                 locationTimeout(5000, location);
  337.  
  338.                 lastGameMade = GetTickCount();
  339.                 lastGameStatus = 1; // pending creation
  340.                 break;
  341.  
  342.         case 5: // Join Game
  343.                 break;
  344.  
  345.         case 6: // Ladder
  346.                 break;
  347.  
  348.         case 7: // Channel List
  349.                 break;
  350.  
  351.         case 8: // Main Menu
  352.                 if(controlData.getCurrentRealmIndex() == me.gatewayid)
  353.                 {
  354.                         outputGameLength();
  355.                         controlData.click(controlData.gameTypes[me.playtype]);
  356.                 }
  357.                 else
  358.                         controlData.click(controlData.controls.mainMenu.button.gateway);
  359.                 break;
  360.  
  361.         case 9: // Login
  362.                 sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  363.                 Delay(loginDelay);
  364.  
  365.                 controlData.setText(controlData.controls.login.editBox.accountName, me.account);
  366.  
  367.                 sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);
  368.  
  369.                 locationTimeout(5000, location);
  370.                 break;
  371.  
  372.         case 10: // Login Error (this is a fatal error, so stop)
  373.                 sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
  374.                 Delay(3500);
  375.                 break;
  376.  
  377.         case 11: // Unable To Connect
  378.                 timeoutDelay(unableToConnectRetry*60*1000, location)
  379.                 controlData.click(controlData.controls.login.unableToConnect.button.ok);
  380.                 break;
  381.  
  382.         case 12: // Character Select
  383.                 var _time, _control;
  384.  
  385.                 sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  386.  
  387.                 for(_time = 0 ; _time < characterScreenTimeout ; _time += 500)
  388.                 {
  389.                         _control = controlData.get(controlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
  390.                         if(_control && _control.GetText() != undefined)
  391.                                 break;
  392.  
  393.                         Delay(1000);
  394.                 }
  395.  
  396.                 if(_time < characterScreenTimeout)
  397.                 {
  398.                         Delay(characterSelectDelay);
  399.  
  400.                         controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
  401.                         controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);
  402.  
  403.                         // reset last game made, so it doesnt make a game immediately
  404.                         inGameAt = 0;
  405.                         setNextGameMake();
  406.                 }
  407.                 else
  408.                 {
  409.                         controlData.click(controlData.controls.characterSelect.button.exit);
  410.                         timeoutDelay(realmDownRetry*60*1000, location);
  411.                 }
  412.                 break;
  413.  
  414.         case 13: // Realm Down - Character Select screen
  415.                 controlData.click(controlData.controls.characterSelect.button.exit);
  416.                 timeoutDelay(realmDownRetry*60*1000, location);
  417.                 break;
  418.  
  419.         case 14: // Character Select - Disconnected
  420.                 timeoutDelay(disconnectedRetry*60*1000, location);
  421.                 controlData.click(controlData.controls.characterSelect.disconnected.button.ok);
  422.                 break;
  423.  
  424.         case 15: // New Character
  425.                 break; 
  426.  
  427.         case 16: // Character Select - Please Wait popup
  428.                 if(!locationTimeout(pleaseWaitTimeout, location))
  429.                         controlData.click(controlData.controls.characterSelect.pleaseWait.button.cancel);
  430.                 break;
  431.  
  432.         case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  433.                 controlData.click(controlData.controls.lobby.lostConnection.button.ok);
  434.                 break;
  435.  
  436.         case 18: // D2 Splash
  437.                 controlData.click(controlData.controls.d2Splash.textBox.copyright);
  438.                 break;
  439.  
  440.         case 19: // Login - Cdkey In Use
  441.         if (keyInUse[0])
  442.         {
  443.             for (var i = 0; i < keyInUse[1]; i++)
  444.             {
  445.                 sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  446.                 My_Delay(2);
  447.             }
  448.  
  449.             sendEventToOOG(D2NT_MGR_PRINT_LOG, "ÿc1Key in use", 0);
  450.             sendEventToOOG(D2NT_MGR_RESTART, "ÿc1Key in use", keyInUse[1]);
  451.         }
  452.         else
  453.         {
  454.             timeoutDelay(cdkeyInUseRetry * 60 * 1000, location);
  455.             controlData.click(controlData.controls.login.cdkeyInUse.button.ok);
  456.         }
  457.                 break;
  458.  
  459.  
  460.         case 20: // Single Player - Select Difficulty
  461.                 controlData.click(controlData.singlePlayerDifficulties[me.diff]);
  462.                 break;
  463.  
  464.         case 21: // Main Menu - Connecting
  465.                 if(!locationTimeout(connectingToBnetTimeout, location))
  466.                         controlData.click(controlData.controls.mainMenu.connecting.button.cancel);
  467.                 break;
  468.  
  469.         case 22: // Login - Invalid Cdkey (classic or xpac)
  470.                 sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
  471.                 Delay(3500);
  472.                 break; 
  473.  
  474.         case 23: // Character Select - Connecting
  475.                 if(!locationTimeout(characterScreenTimeout, location))
  476.                         controlData.click(controlData.controls.characterSelect.button.exit);
  477.                 break;
  478.  
  479.         case 24: // Server Down - not much to do but wait..
  480.                 break;
  481.  
  482.         case 25: // Lobby - Please Wait
  483.                 if(!locationTimeout(pleaseWaitTimeout, location))
  484.                         controlData.click(controlData.controls.lobby.pleaseWait.button.cancel);
  485.                 break;
  486.  
  487.         case 26: // Lobby - Game Name Exists
  488.                 sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Game already exists", 0);
  489.  
  490.                 inGameAt = 0;
  491.                 lastGameStatus = 0;
  492.                 setNextGameMake();
  493.  
  494.                 locationTimeout(15000, location);
  495.                 break;
  496.  
  497.         case 27: // Gateway Select
  498.                 controlData.clickRealmEntry(me.gatewayid);
  499.                 controlData.click(controlData.controls.gateway.button.ok);
  500.                 break;
  501.  
  502.         case 28: // Lobby - Game Does Not Exist
  503.                 inGameAt = Random(gameDoesNotExistDelayMin, gameDoesNotExistDelayMax);
  504.                 lastGameStatus = 0;
  505.                 setNextGameMake();
  506.  
  507.                 locationTimeout(gameDoesNotExistTimeout, location);
  508.                 break;
  509.         }
  510. }
  511.  
  512. function sendEventToOOG(locationId, statusString, pendingTime)
  513. {
  514.         return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
  515. }
  516.  
  517. function setNextGameMake()
  518. {
  519.         lastGameMade = GetTickCount();
  520.         nextGameMake = lastGameMade + createGameThreshold + Random(0-createGameThresholdRandom, createGameThresholdRandom) + inGameAt;
  521.         inGameAt = 0;
  522.         chatActionsDone = false;
  523. }
  524.  
  525. function outputGameLength()
  526. {
  527.         if(inGameAt)
  528.         {
  529.                 duration = GetTickCount() - inGameAt;
  530.  
  531.                 inGameAt = (duration < gameMinLength ? gameMinLength - duration : 0);
  532.         }
  533. }
  534.  
  535. function locationTimeout(time, location)
  536. {
  537.         endtime = GetTickCount() + time;
  538.  
  539.         while(controlData.getLocation().id == location.id && endtime > GetTickCount())
  540.         {
  541.                 sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  542.                 Delay(1000);
  543.         }
  544.  
  545.         return (controlData.getLocation().id != location.id);
  546. }
  547.  
  548. function timeoutDelay(time, location)
  549. {
  550.         endtime = GetTickCount() + time;
  551.  
  552.         while(endtime > GetTickCount())
  553.         {
  554.                 sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  555.                 Delay(1000);
  556.         }
  557. }
  558.  
  559. function getRandomString(_length)
  560. {
  561.         _retString = "";
  562.         _charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
  563.  
  564.         while(_length--)
  565.         {
  566.                 _retString += _charSet.charAt(Random(0, _charSet.length-1));
  567.                 Delay(1);
  568.         }
  569.  
  570.         return _retString;
  571. }
  572. function getGameName(lastGameString)
  573. {
  574.    if(!lastGameString)
  575.       return "";
  576.    else
  577.       return (lastGameString.split("-")[0] + "-");
  578. }
  579.  
  580. function getGameCounter(lastGameString, simple)
  581. {
  582.    var myCount;
  583.    if(!lastGameString)
  584.       return "-1";
  585.    else
  586.    {
  587.       switch(lastGameString.split("-")[1])
  588.       {
  589.          case "08":
  590.             myCount = 9;
  591.             break;
  592.          case "09":
  593.             myCount = 10;
  594.             break;
  595.                 case "99":
  596.                         myCount = 00;
  597.                         break;
  598.          default:
  599.             myCount = parseInt(lastGameString.split("-")[1]) + 1;
  600.             break;
  601.       }
  602.       if(!simple)
  603.       {
  604.          if(myCount <= 9)
  605.             return ('0' + myCount);
  606.       }
  607.       return myCount;
  608.    }
  609. }
  610.  
  611. function MyIL_File(path, mode, msg, retry)
  612. {
  613.     var _msg  = "";
  614.     var _line = "";
  615.     var _fileHandle;
  616.     var _isFileCheck = false;
  617.  
  618.     if (arguments.length < 3) msg   = "";
  619.     if (arguments.length < 4) retry = (mode != 0) ? 25 : 5;
  620.  
  621.     while (retry-- > 0)
  622.     {
  623.         if (mode == 2 && !_isFileCheck)
  624.         {
  625.             _fileHandle = FileOpen(path, 0);
  626.             if (!_fileHandle)
  627.                 _fileHandle = FileOpen(path, 1);
  628.  
  629.             if (_fileHandle)
  630.                 _fileHandle.Close();
  631.  
  632.             _isFileCheck = true;
  633.         }
  634.  
  635.         _fileHandle = FileOpen(path, mode);
  636.         if (_fileHandle)
  637.             break;
  638.  
  639.         if (retry > 0)
  640.             Delay(200);
  641.     }
  642.  
  643.     if (_fileHandle)
  644.     {
  645.         if (mode == 0)
  646.         {
  647.             while (!_fileHandle.eof)
  648.             {
  649.                 _line = _fileHandle.ReadLine();
  650.                 if (_line || !_fileHandle.eof)
  651.                     _msg += _line + msg;
  652.             }
  653.         }
  654.         else if (msg)
  655.             _fileHandle.WriteLine(msg);
  656.  
  657.         _fileHandle.Close();
  658.     }
  659.  
  660.     return _msg;
  661. }