Guest User

Untitled

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