Guest User

Untitled

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