Guest User

Untitled

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