Advertisement
Guest User

NTBot.ntj

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