daily pastebin goal
50%
SHARE
TWEET

Untitled

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