Guest User

Untitled

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