Advertisement
kolton

Untitled

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