Advertisement
Guest User

Untitled

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