Advertisement
Guest User

AutoMulingSystemLeech1.2

a guest
Dec 18th, 2014
211
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 32.34 KB | None | 0 0
  1.  
  2. // ============================================================================
  3. // Mule Notify
  4. // ============================================================================
  5. var MuleNotification = true; // Set to true to send status to manager
  6.  
  7. // ============================================================================
  8. // Mule Specific vars
  9. // ============================================================================
  10. var MuleGamePassword = “eom”; // Consistant through all games
  11. var muleAccountPassword = “g9418728”; // for all mule accounts
  12. var CharPrefix = "";
  13. var AccountPrefix = “i)”ark-Mule;
  14. var CreateCharacterClass = 4; // 0:Amazon, 1:Sorceress, 2:Necromancer, 3:Paladin, 4:Barbarian, 5:Druid, 6:Assassin
  15. var Hardcore = false;
  16. var Ladder = false;
  17. var Classic = false;
  18.  
  19. // =============================================================================
  20. // Leader Account settings
  21. // =============================================================================
  22. var leaderAccountName = “i)”ark-Flame;
  23. var leaderName = “spinns”;
  24. // =============================================================================
  25.  
  26. // Leecher game entry delays use to stagger when leechers join game...
  27. // [characterName, delay in milliseconds]...just leave these as they are if you don't want to
  28. // use them
  29. // =============================================================================
  30. var leecher1 = ["characterName", 100];
  31. var leecher2 = ["characterName", 750];
  32. var leecher3 = ["characterName", 1250];
  33. var leecher4 = ["characterName", 2000];
  34.  
  35. //==============================================================================
  36. // join options
  37. //==============================================================================
  38. var useFL = false; // set true if you wish your leecher to use /f l to join games. useFL MUST be set to 0 for this to work
  39. var useFLCount = 1; // this is seperate from the above setting allows you to use /f l to join, but will only spam /f l the set number of times. set to 0 to disable
  40. var delayFL = 3000; // milliseconds before the bot will use the /f l command in loby
  41. var reEnterSameGame = false; // set to false to keep the bot from using /f l to re enter same game also must be set to false if you don't want bot to re enter same game for txt joining
  42. var useTextFileJoin = false; // use txt file communication between leader and leecher to join games. False uses message sent from leader when in game
  43. var gameDoesNotExistDelay = 10; // time to idle before trying if leader's game does not exist. In seconds.
  44. var tryLeaderGame1x = false; // will only try to enter the game one time. Good for when leader drops before leecher gets in.
  45.  
  46. // =============================================================================
  47. // Game password (leave blank if none)
  48. // =============================================================================
  49. var gamepassword = “eom”;
  50.  
  51. // =============================================================================
  52. // UseCDKeyChangeTrick :
  53. // if true, the follow bot will say his gamename/gamepwd (set in the OOG) in chat before each game
  54. // in order to increment his number of runs (to switch CDKeys after xx runs)
  55. // if false, the follow bot will never change his CDKey
  56. // =============================================================================
  57. var UseCDKeyChangeTrick = false;
  58.  
  59. // =============================================================================
  60. // Debug : set to true if you are experiencing problems with your JoinBot
  61. // it will log in your OOG the lobby chat actions
  62. // =============================================================================
  63. var Debug = false;
  64.  
  65. ////////////////////////////////////////////////////////////////////////////////
  66. // Lobby chat settings :
  67. ////////////////////////////////////////////////////////////////////////////////
  68.  
  69. // Set to true to join the chat after each game (needed for JoinBot)
  70. var joinChatAfterGame = true;
  71.  
  72. // Message said when you first enter the chat
  73. var firstJoinMessage = "";
  74.  
  75. // Message said after each game
  76. var chatMessageAfterGame = "";
  77.  
  78. // if this is true, will join a random channel, otherwise it will use the channel below..
  79. var joinRandomChannel = false;
  80. // Name of the channel you want to join (leave blank if you want to stay in the default channel)
  81. var joinChannelInChat = "";
  82.  
  83.  
  84. ////////////////////////////////////////////////////////////////////////////////
  85. // Delays:
  86. ////////////////////////////////////////////////////////////////////////////////
  87.  
  88. // Minimum game length, waits in the lobby if last game was too short
  89. // I recommend to keep a value > 300000 (milliseconds) to avoid bnet temporary ban
  90. var gameMinLength = 180000;
  91.  
  92. // realm delays (minutes)
  93. var unableToConnectRetry = 20;
  94. var realmDownRetry = 480;
  95. var disconnectedRetry = 5;
  96. var cdkeyInUseRetry = 5;
  97.  
  98. // interface delays (milliseconds)
  99. var connectingToBnetTimeout = 20000;
  100. var characterScreenTimeout = 10000;
  101. var pleaseWaitTimeout = 10000;
  102. var createGameThreshold = 10000;
  103. var createGameThresholdRandom = 1000;
  104. var createGameTimeout = 15000;
  105. var waitInLineTimeout = 15000;
  106. var characterSelectDelay = 1000;
  107. var loginDelay = 1000;
  108. var clickDelay = 500;
  109. var textDelay = 500;
  110. var clickDelayRandom = 500;
  111. var textDelayRandom = 500;
  112. var gameDoesNotExistDelayMin = 600000; // this not for leech configuration. Look for gameDoesNotExistDelay above
  113. var gameDoesNotExistDelayMax = 900000; // this not for leech configuration. Look for gameDoesNotExistDelay above
  114. var gameDoesNotExistTimeout = 30000;
  115. var waitBeforeEnterChatMin = 1000;
  116. var waitBeforeEnterChatMax = 2000;
  117. var waitInChatBeforeActionsMin = 2000;
  118. var waitInChatBeforeActionsMax = 3000;
  119. var ftjDelay = 180; // time to idle before trying if leecher failed to join. In seconds.
  120. // Only for JoinBot (friend list delay, milliseconds)
  121. var LeaderOfflineDelay = 30000;
  122. var LeaderInChatDelay = 10000;
  123. var GameIsFullDelay = 30000;
  124.  
  125. ////////////////////////////////////////////////////////////////////////////////
  126. ////////////////////////////////////////////////////////////////////////////////
  127. // DO NOT EDIT ANYTHING BELOW THIS
  128. ////////////////////////////////////////////////////////////////////////////////
  129. ////////////////////////////////////////////////////////////////////////////////
  130.  
  131. //D2NT Manager Command
  132.  
  133. const D2NT_MGR_LOADING = 1;
  134. const D2NT_MGR_READY = 2;
  135. const D2NT_MGR_LOGIN = 3;
  136. const D2NT_MGR_CREATE_GAME = 4;
  137. const D2NT_MGR_INGAME = 5;
  138. const D2NT_MGR_RESTART = 6;
  139. const D2NT_MGR_CHICKEN = 7;
  140. const D2NT_MGR_PRINT_STATUS = 8;
  141. const D2NT_MGR_PRINT_LOG = 9;
  142.  
  143. var lastGameMade = GetTickCount();
  144. var lastGameStatus = 0;
  145. var nextGameMake = 0;
  146. var inGameAt = 0;
  147. var chatActionsDone = false;
  148. var lastGameFailed = false;
  149. var sayChatMsgAfterGame = false;
  150. var muleGame = "";
  151. var Muling;
  152. var ingameScript;
  153. var MuleAccount;
  154. var onMule = false;
  155. var GrabMule;
  156. var mulepos;
  157. var myGame = getRandomString(12);
  158.  
  159. Include("libs/controlInfo.ntl");
  160. Include("libs/common/NTColorConverter.ntl");
  161. Include("libs/mulingInfo.ntl");
  162.  
  163. var controlData = new controlInfo();
  164.  
  165. var lastGame = "";
  166. var retryFL = 0;
  167. var game = '';
  168. var _gamename = "";
  169. var _gamepassword = "";
  170. var _leaderOfflineTick = -LeaderOfflineDelay;
  171. var _leaderInChatTick = -LeaderInChatDelay;
  172. var _GameIsFullTick = -GameIsFullDelay;
  173. var ftjcount = 0;
  174.  
  175. function NTMain()
  176. {
  177. Delay(1000);
  178.  
  179. writeInitialSettings();
  180.  
  181. var _ingame = false;
  182.  
  183. controlData.clickDelay = clickDelay;
  184. controlData.textDelay = textDelay;
  185. controlData.clickDelayRandom = clickDelayRandom;
  186. controlData.textDelayRandom = textDelayRandom;
  187. while(1)
  188. {
  189. if(me.ingame)
  190. {
  191. _gamename = me.gamename;
  192. _gamepassword = me.gamepassword;
  193.  
  194. if(!inGameAt)
  195. inGameAt = GetTickCount();
  196.  
  197. if(!_ingame)
  198. {
  199. RunGC(); // run garbage collector between each game
  200.  
  201. if(Load(ingameScript))
  202. {
  203. if(!reEnterSameGame) { NT_File("logs/messagecomands/"+me.charname+"-lastgame.txt", 1, me.gamename); } // writes current game for comparing to new game to join next time in lobby
  204.  
  205. retryFL = 0; // sets the counter back to 0 upon game entry.
  206. _ingame = true;
  207.  
  208. if(me.playtype > 0)
  209. sendEventToOOG(D2NT_MGR_INGAME, "In Game[IP:" + me.gameserverip.split(".")[3] + "]", 0);
  210. else
  211. sendEventToOOG(D2NT_MGR_INGAME, "In Game", 0);
  212.  
  213. lastGameStatus = 2; // in game successful
  214.  
  215. }
  216. }
  217.  
  218. Delay(1000);
  219. }
  220. else
  221. {
  222. if(_ingame)
  223. {
  224. My_ExitGame_Check(); // out of korean modded d2nt fixes white screen of death
  225. _ingame = false;
  226. sayChatMsgAfterGame = true;
  227.  
  228. sendEventToOOG(D2NT_MGR_READY, "", 0);
  229. }
  230.  
  231. muleGame = NT_File("AMS/MuleStatus/" + me.account + "_mulegame.txt", 0);
  232. GrabMule = NT_File("AMS/MuleStatus/" + me.account + "_charstatus.txt", 0);
  233. Muling = NT_File("AMS/MuleStatus/" + me.account + "_mulingstatus.txt", 0);
  234.  
  235. switch(Muling)
  236. {
  237. case "true":
  238. {
  239. locationActionMule(controlData.getLocation());
  240. break;
  241. }
  242. case "false":
  243. {
  244. locationAction(controlData.getLocation());
  245. break;
  246. }
  247. }
  248.  
  249. Delay(500);
  250. }
  251. }
  252. }
  253.  
  254. function locationAction(location)
  255. {
  256. switch(location.id)
  257. {
  258. case 3: // Lobby Chat
  259. //ftjcheck
  260. if (ftjcount >= 10 && lastGameStatus == 1) {
  261. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "FTJ detected...........Idling", 0);
  262. ftjcount = 0;
  263. inGameAt = 0;
  264. lastGameStatus = 0;
  265. setNextGameMake();
  266. locationTimeout(ftjDelay*1000, location);
  267. }
  268. if(onMule) {
  269. if(MuleNotification) {
  270. SendCopyData("D2NT Manager", null, 9<<16, "Swapping to Main character!");
  271. }
  272. controlData.click(controlData.controls.lobby.button.quit);
  273. break;
  274. }
  275.  
  276. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  277. //LogPrintSimple(me.account + "MyAccountTest.txt", me.account + " / " + me.charname) // this is to check for 2nd account login
  278.  
  279. if(!chatActionsDone)
  280. {
  281. Delay(Random(waitInChatBeforeActionsMin, waitInChatBeforeActionsMax));
  282.  
  283. if(joinRandomChannel || joinChannelInChat != "")
  284. {
  285. Say("/join " + (joinRandomChannel ? getRandomString(Random(3,10)) : joinChannelInChat));
  286. Delay(1000);
  287. }
  288.  
  289. if(firstJoinMessage)
  290. {
  291. Say(firstJoinMessage);
  292. Delay(200);
  293. }
  294.  
  295. chatActionsDone = true;
  296. }
  297.  
  298. if (chatMessageAfterGame && _gamename != "" && sayChatMsgAfterGame == true)
  299. {
  300. Say(chatMessageAfterGame);
  301. sayChatMsgAfterGame = false;
  302. Delay(200);
  303. }
  304.  
  305. game = '';
  306. if(useTextFileJoin) {
  307. NT_RetrievenextGame(); //read message from txt file and set game and gamepassword vars from that
  308. }
  309. else {
  310. if(useFL || useFLCount > 0) {
  311. var _tick = GetTickCount();
  312. if ((_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick) // maybe play with this so it skips it for 30 seconds
  313. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)
  314. && (_GameIsFullTick < 0 || (_GameIsFullTick + GameIsFullDelay) < _tick))
  315. {
  316. Delay(500);
  317. DebugInOOG('Locating the leader : '+leaderAccountName);
  318. if(useFLCount > 0 && retryFL < useFLCount) {
  319. Delay(delayFL);
  320. Say('/f l');
  321. retryFL++;
  322. }
  323. else if(useFL) {
  324. Delay(delayFL);
  325. Say('/f l');
  326. }
  327.  
  328. }
  329. }
  330.  
  331. if(chat = controlData.get(controlData.controls.lobby.chat.textBox.channelText))
  332. {
  333. var found_leader = false;
  334. lines = chat.GetText();
  335. if(!lines) { break; }
  336. for (var line_id = lines.length - 1; line_id > -1; line_id--)
  337. {
  338. if (found_leader) // useless... :/
  339. break;
  340.  
  341. if (lines[line_id].substring(0,1) == " ")
  342. continue;
  343.  
  344. // retrieving the whole message
  345. var msg = lines[line_id].replace(/^\s+|\s+$/, "");
  346. var msglines = 1;
  347. while (lines[line_id+msglines] != undefined && lines[line_id+msglines].substring(0,2) == " ")
  348. {
  349. msg += " " + lines[line_id+msglines].replace(/^\s+|\s+$/, "");
  350. msglines++;
  351. }
  352. if (msg.lastIndexOf(leaderName) >= 0)
  353. DebugInOOG("yc8found him :;"+msg);
  354.  
  355. // checking if the msg is a friendly whisper
  356. if (msg.lastIndexOf(leaderName + ' (*' +leaderAccountName+')') > -1 || msg.lastIndexOf(leaderName + '@' + GateWayToName() + ' (*' +leaderAccountName+')') > -1)
  357. // if (msg.lastIndexOf(leaderName + ' (*' +leaderAccountName+')') > -1) // need to modify this and then add another to handle the "@USWest
  358. { // should be just a matter of leaderName + '@' and then register the 2nd line as game name
  359. var regGameNameWhispered=/^.*in_new_game\s+(.*)$/gi; // replaced below with this to join on mesage upon entering game
  360. //var regGameNameWhispered=/^.*(game|partie|spiel|partita|partida).*(nomm[^\s]*|called|chiamata)\s*([\w\s-]*\w)\s*\.\s*$/gi;
  361. if (msg.match(regGameNameWhispered))
  362. game = msg.replace(regGameNameWhispered, "$1"); // replaced below with this to join on mesage upon entering game
  363. //game = msg.replace(regGameNameWhispered, "$3");
  364.  
  365. if (game != '')
  366. {
  367. found_leader = true;
  368. break;
  369. }
  370. }
  371.  
  372. // checking if the msg is from the friend list
  373. if (msg.lastIndexOf(': '+leaderAccountName+',') > -1)
  374. {
  375. found_leader = true;
  376. var regOffline=/^.*(offline|desconectado).*$/gi;
  377. var regInChat=/^.*(channel|canale?)\s*([\w\s-]*\w)\.?\s*$/gi;
  378. var regGameName=/^.*(game|partie|spiel|partita|partida)\s*([\w\s-]*\w)\s*\(priv[^\)]*\)\.\s*$/gi;
  379.  
  380. if (msg.match(regOffline)
  381. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  382. {
  383. DebugInOOG('Leader is offline, delay '+Math.round(LeaderOfflineDelay/1000)+' sec for next /f l.');
  384. _leaderOfflineTick = GetTickCount();
  385. }
  386. else if (msg.match(regInChat)
  387. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick))
  388. {
  389. DebugInOOG('Leader is in the chat "'+msg.replace(regInChat, "$2")+'", delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  390. _leaderInChatTick = GetTickCount();
  391. }
  392. else if (msg.match(regGameName)
  393. && ((_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick)
  394. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)))
  395. {
  396. game = msg.replace(regGameName, "$2");
  397. }
  398. else if ((_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)
  399. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  400. {
  401. // unhandled line, supposelly "In Realm"
  402. DebugInOOG('The leader was in the the lobby but not in chat, delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  403. _leaderInChatTick = GetTickCount();
  404. }
  405.  
  406. break;
  407. }
  408. }
  409.  
  410. if (found_leader == false)
  411. DebugInOOG('I couldn\'t find the leader in my friend list!');
  412. }
  413. else
  414. {
  415. DebugInOOG('I can\'t read the chat!');
  416. //DebugInOOG('You probably haven\'t added the lobby chat controlinfo coordinates!');
  417. Delay(30000);
  418. }
  419. }
  420. if(!reEnterSameGame) { // added to check game name. If same as last game then don't re enter.
  421. NT_RetrieveLastGame();
  422. //Delay(250);
  423. if(lastGame == game) {
  424. game = "";
  425. }
  426. }
  427. if (game!="")
  428. {
  429. if (UseCDKeyChangeTrick)
  430. {
  431. // increasing the number of runs in the OOG (for CDKey switch)
  432. // Problem : the gamename/gamepassword set in your OOG will be typed in the lobbyChat
  433. // this may output a red message in the lobby chat if you have a password set (not a real problem)
  434. // I recommend to set a gamename like "Run" and no gamepassword in your OOG. -> this will output "Run-01", "Run-02", etc in lobby chat before joining games
  435. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  436. Delay(1000);
  437. }
  438.  
  439. DebugInOOG('Leader is in the game "' + game + '"');
  440. controlData.click(controlData.controls.lobby.button.join);
  441. Delay(100);
  442. }
  443.  
  444. break;
  445.  
  446. case 1: // Lobby
  447. //ftjcheck
  448. if (ftjcount >= 10 && lastGameStatus == 1) {
  449. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "FTJ detected...........Idling", 0);
  450. ftjcount = 0;
  451. inGameAt = 0;
  452. lastGameStatus = 0;
  453. setNextGameMake();
  454. locationTimeout(ftjDelay*1000, location);
  455. }
  456. if(onMule) {
  457. if(MuleNotification) {
  458. SendCopyData("D2NT Manager", null, 9<<16, "Swapping to Main character!");
  459. }
  460. controlData.click(controlData.controls.lobby.button.quit);
  461. onMule = true;
  462. break;
  463. }
  464.  
  465. if(location.id == 1 && joinChatAfterGame)
  466. {
  467. //LogPrintSimple(me.account + "MyAccountTest.txt", me.account + " / " + me.charname) // this is to check for 2nd account login
  468. Delay(Random(waitBeforeEnterChatMin, waitBeforeEnterChatMax));
  469. controlData.click(controlData.controls.lobby.button.enterChat);
  470. break;
  471. }
  472. break;
  473.  
  474. case 2: // Waiting In Line
  475. if(GetTickCount()-lastGameMade > waitInLineTimeout)
  476. controlData.click(controlData.controls.lobby.inLine.button.cancel);
  477. break;
  478.  
  479. case 4: // Create Game
  480. break;
  481.  
  482. case 5: // Join Game
  483. ingameScript = "NTBot/NTBotGame.ntj";
  484. if (game)
  485. {
  486. controlData.setText( controlData.controls.lobby.join.editBox.gameName, game);
  487. Delay (100);
  488. controlData.setText( controlData.controls.lobby.join.editBox.password, gamepassword);
  489. //SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + COLOR_1 +me.charname);
  490. if(leecher1[0] == me.charname){
  491. Delay(leecher1[1]);
  492. }
  493. else if(leecher2[0] == me.charname){
  494. Delay(leecher2[1]);
  495. }
  496. else if(leecher3[0] == me.charname){
  497. Delay(leecher3[1]);
  498. }
  499. else if(leecher4[0] == me.charname){
  500. Delay(leecher4[1]);
  501. }
  502. else{
  503. Delay(100);
  504. }
  505. if(tryLeaderGame1x) {
  506. NT_File("logs/messagecomands/"+me.charname+"-lastgame.txt", 1, game); // writes current game for comparing to new game to join next time in lobby
  507. game = "";
  508. }
  509. controlData.click(controlData.controls.lobby.join.button.joinGame);
  510. RunGC(); // run garbage collector between each game
  511. locationTimeout(5000, location);
  512. lastGameStatus = 1; // pending join
  513. }
  514. else
  515. {
  516. DebugInOOG('No game to join : cancelling');
  517. me.Cancel(1);
  518. Delay(1000);
  519. }
  520. break;
  521.  
  522. case 6: // Ladder
  523. break;
  524.  
  525. case 7: // Channel List
  526. break;
  527.  
  528. case 8: // Main Menu
  529. if(controlData.getCurrentRealmIndex() == me.gatewayid)
  530. {
  531. outputGameLength();
  532. controlData.click(controlData.gameTypes[me.playtype]);
  533. }
  534. else
  535. controlData.click(controlData.controls.mainMenu.button.gateway);
  536. break;
  537.  
  538. case 9: // Login
  539. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  540. Delay(loginDelay);
  541.  
  542. controlData.setText(controlData.controls.login.editBox.accountName, me.account);
  543.  
  544. sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);
  545.  
  546. locationTimeout(5000, location);
  547. onMule = false;
  548. break;
  549.  
  550. case 10: // Login Error (this is a fatal error, so stop)
  551. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad Account or PW Entered.......Idling", 0);
  552. while(1) { Delay(500); }
  553. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
  554. Delay(3500);
  555. break;
  556.  
  557. case 11: // Unable To Connect
  558. timeoutDelay(unableToConnectRetry*60*1000, location)
  559. controlData.click(controlData.controls.login.unableToConnect.button.ok);
  560. break;
  561.  
  562. case 12: // Character Select
  563. var _time, _control;
  564. if(onMule) {
  565. Delay(1000);
  566. controlData.click(controlData.controls.characterSelect.button.exit);
  567. break;
  568. }
  569.  
  570. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  571.  
  572. for(_time = 0 ; _time < characterScreenTimeout ; _time += 500)
  573. {
  574. _control = controlData.get(controlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
  575. if(_control && _control.GetText() != undefined)
  576. break;
  577.  
  578. Delay(500);
  579. }
  580.  
  581. if(_time < characterScreenTimeout)
  582. {
  583. Delay(characterSelectDelay);
  584.  
  585. controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
  586. controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);
  587.  
  588. // reset last game made, so it doesnt make a game immediately
  589. inGameAt = 0;
  590. setNextGameMake();
  591. }
  592. else
  593. {
  594. controlData.click(controlData.controls.characterSelect.button.exit);
  595. timeoutDelay(realmDownRetry*60*1000, location);
  596. }
  597. break;
  598.  
  599. case 13: // Realm Down - Character Select screen
  600. controlData.click(controlData.controls.characterSelect.button.exit);
  601. timeoutDelay(realmDownRetry*60*1000, location);
  602. break;
  603.  
  604. case 14: // Character Select - Disconnected
  605. timeoutDelay(disconnectedRetry*60*1000, location);
  606. controlData.click(controlData.controls.characterSelect.disconnected.button.ok);
  607. break;
  608.  
  609. case 15: // New Character
  610. break;
  611.  
  612. case 16: // Character Select - Please Wait popup
  613. if(!locationTimeout(pleaseWaitTimeout, location))
  614. controlData.click(controlData.controls.characterSelect.pleaseWait.button.cancel);
  615. break;
  616.  
  617. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  618. controlData.click(controlData.controls.lobby.lostConnection.button.ok);
  619. break;
  620.  
  621. case 18: // D2 Splash
  622. controlData.click(controlData.controls.d2Splash.textBox.copyright);
  623. break;
  624.  
  625. case 19: // Login - Cdkey In Use
  626. timeoutDelay(cdkeyInUseRetry*60*1000, location);
  627. controlData.click(controlData.controls.login.cdkeyInUse.button.ok);
  628. break;
  629.  
  630. case 20: // Single Player - Select Difficulty
  631. controlData.click(controlData.singlePlayerDifficulties[me.diff]);
  632. break;
  633.  
  634. case 21: // Main Menu - Connecting
  635. if(!locationTimeout(connectingToBnetTimeout, location))
  636. controlData.click(controlData.controls.mainMenu.connecting.button.cancel);
  637. break;
  638.  
  639. case 22: // Login - Invalid Cdkey (classic or xpac)
  640. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Bad CD Key...........Idling", 0);
  641. while(1) { Delay(500); }
  642. //sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
  643. Delay(3500);
  644. break;
  645.  
  646. case 23: // Character Select - Connecting
  647. if(!locationTimeout(characterScreenTimeout, location))
  648. controlData.click(controlData.controls.characterSelect.button.exit);
  649. break;
  650.  
  651. case 24: // Server Down - not much to do but wait..
  652. break;
  653.  
  654. case 25: // Lobby - Please Wait
  655. if(!locationTimeout(pleaseWaitTimeout, location))
  656. controlData.click(controlData.controls.lobby.pleaseWait.button.cancel);
  657. break;
  658.  
  659. case 26: // Lobby - Game Name Exists
  660. sendEventToOOG(D2NT_MGR_PRINT_LOG, "yE00000Game already exists", 0);
  661.  
  662. inGameAt = 0;
  663. lastGameStatus = 0;
  664. setNextGameMake();
  665.  
  666. locationTimeout(15000, location);
  667. break;
  668.  
  669. case 27: // Gateway Select
  670. controlData.clickRealmEntry(me.gatewayid);
  671. controlData.click(controlData.controls.gateway.button.ok);
  672. break;
  673.  
  674. case 28: // Lobby - Game Does Not Exist
  675. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "Leader's game does not exist...........Idling", 0);
  676. Delay(gameDoesNotExistDelay*1000);
  677. inGameAt = Random(gameDoesNotExistDelayMin, gameDoesNotExistDelayMax);
  678. lastGameStatus = 0;
  679. setNextGameMake();
  680.  
  681. locationTimeout(gameDoesNotExistTimeout, location);
  682. break;
  683. default:
  684. if (lastGameStatus == 1) {
  685. sendEventToOOG(D2NT_MGR_PRINT_STATUS, "Please Wait...", 0);
  686. for (ftjcount=0; ftjcount<=10 && !me.ingame; ftjcount++) {
  687. Delay(1000)
  688. }
  689. }
  690. DebugInOOG("Unhandled location : "+location.id);
  691. break;
  692. }
  693. DebugInOOG("Location : "+location.id);
  694. }
  695.  
  696. function sendEventToOOG(locationId, statusString, pendingTime)
  697. {
  698. return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
  699. }
  700.  
  701. function setNextGameMake()
  702. {
  703. lastGameMade = GetTickCount();
  704. nextGameMake = lastGameMade + createGameThreshold + Random(0-createGameThresholdRandom, createGameThresholdRandom) + inGameAt;
  705. inGameAt = 0;
  706. chatActionsDone = false;
  707. }
  708.  
  709. function outputGameLength()
  710. {
  711. if(inGameAt)
  712. {
  713. duration = GetTickCount() - inGameAt;
  714.  
  715. inGameAt = (duration < gameMinLength ? gameMinLength - duration : 0);
  716. }
  717. }
  718.  
  719. function locationTimeout(time, location)
  720. {
  721. endtime = GetTickCount() + time;
  722.  
  723. while(controlData.getLocation().id == location.id && endtime > GetTickCount())
  724. {
  725. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  726. Delay(500);
  727. }
  728.  
  729. return (controlData.getLocation().id != location.id);
  730. }
  731.  
  732. function timeoutDelay(time, location)
  733. {
  734. endtime = GetTickCount() + time;
  735.  
  736. while(endtime > GetTickCount())
  737. {
  738. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  739. Delay(1000);
  740. }
  741. }
  742.  
  743. function getRandomString(_length)
  744. {
  745. _retString = "";
  746. _charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
  747. _cRo = -1;
  748. _cR = -1;
  749. while(_length--)
  750. {
  751. while(_cRo == _cR)
  752. _cR = Random(0, _charSet.length-1)
  753. _retString += _charSet.charAt(_cR);
  754. Delay(1);
  755. _cRo = _cR
  756. }
  757.  
  758. return _retString;
  759. }
  760.  
  761. function DebugInOOG(logString)
  762. {
  763. if (Debug)
  764. return SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + logString);
  765. else
  766. return false;
  767. }
  768.  
  769. function My_ExitGame_Check()
  770. {
  771. for (var i = 0; i < 40; i++)
  772. {
  773. if (controlData.getLocation().id != undefined)
  774. break;
  775.  
  776. if (i > 38)
  777. {
  778. LogPrintSimple(me.account + " StarterTest.txt", "White Screen of Death: Restarting")
  779. sendEventToOOG(D2NT_MGR_PRINT_LOG, COLOR_1 + "White Screen of Death: Restarting", 0);
  780. sendEventToOOG(D2NT_MGR_RESTART, "", 5);
  781. My_Delay(); // make sure and add this also
  782. }
  783.  
  784. Delay(500);
  785. }
  786. }
  787.  
  788. function My_Delay(retry)
  789. {
  790. if (arguments.length < 1)
  791. retry = 20;
  792.  
  793. while (retry-- > 0)
  794. Delay(1000);
  795. }
  796.  
  797. function LogPrintSimple(filepath, mesg){
  798.  
  799. var _filepath = filepath;
  800. var _mesg = mesg;
  801.  
  802. var date = new Date().toLocaleFormat("<%a, %b %d, %H:%M>");
  803. var logfile = FileOpen(_filepath, 2); // opens file
  804. if(!logfile)
  805. var logfile = FileOpen(_filepath, 1); // if file not there then creates it
  806.  
  807. logfile.WriteLine(date + " " + _mesg );
  808. logfile.Close();
  809. }
  810.  
  811. function GateWayToName(){
  812. switch(me.gatewayid){
  813. case 0: return 'USWest';
  814. case 1: return 'USEast';
  815. case 2: return 'Asia';
  816. case 3: return 'Europe';
  817. default: return 'ugly'; // not sure how asia1, asia2, etc work so adding this for now
  818. }
  819. }
  820.  
  821. function NT_RetrieveLastGame() {
  822. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 0); // open file in read only
  823. if(!grabLastGame){
  824. var grabLastGame = FileOpen("logs/messagecomands/"+me.charname+"-lastgame.txt", 1); // because the file doesn't exist create it
  825. }
  826. if(grabLastGame){
  827. lastGame = grabLastGame.ReadLine(); //retrieve the line and set the lastGame variable to it so we can check it against the game we may want to join
  828. grabLastGame.Close();
  829. }
  830. return;
  831. }
  832.  
  833. function NT_RetrievenextGame() { // to retrieve game and pw
  834. var grabLine;
  835. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 0); // open file in read only
  836. if(!grabNextGame){
  837. var grabNextGame = FileOpen("logs/messagecomands/"+leaderName+"-nextgame.txt", 1); // because the file doesn't exist create it
  838. }
  839. if(grabNextGame){
  840. grabLine = grabNextGame.ReadLine(); //retrieve the line and set the nextGame variable to it so we can check it against the game we may want to join
  841. game = grabLine.substring(0, grabLine.indexOf('/')); //extracting game name from beginning of line to the "/"
  842. gamepassword = grabLine.substring(grabLine.indexOf('/') + 1, grabLine.length); //Parse after symbol till end of line.
  843. grabNextGame.Close();
  844. }
  845. return;
  846. }
  847.  
  848. function writeInitialSettings()
  849. {
  850. _char = FileOpen("AMS/MuleStatus/" + me.account + "_charstatus.txt", 0);
  851.  
  852. if(!_char)
  853. NT_File("AMS/MuleStatus/" + me.account + "_charstatus.txt", 1, "Main");
  854. else
  855. _char.Close();
  856. Delay(500);
  857.  
  858. _stat = FileOpen("AMS/MuleStatus/" + me.account + "_mulingstatus.txt", 0);
  859.  
  860. if(!_stat)
  861. NT_File("AMS/MuleStatus/" + me.account + "_mulingstatus.txt", 1, "false");
  862. else
  863. _stat.Close();
  864. Delay(500);
  865.  
  866. _pos = FileOpen("AMS/MuleStatus/" + me.account + "_locstatus.txt", 0);
  867.  
  868. if(!_pos)
  869. NT_File("AMS/MuleStatus/" + me.account + "_locstatus.txt", 1, "0");
  870. else
  871. _pos.Close();
  872. }
  873.  
  874. function NT_File(path, mode, msg, delay) {
  875. var _msg = "";
  876. var _line = "";
  877. var _fileHandle;
  878. var _isFileCheck = false;
  879.  
  880. if (arguments.length < 3) { msg = ""; }
  881. if (arguments.length < 4) { delay = (mode > 0) ? 5 : 2; }
  882.  
  883. while (delay--) {
  884. if (mode == 2 && !_isFileCheck) {
  885. _fileHandle = FileOpen(path, 0);
  886. if (!_fileHandle)
  887. _fileHandle = FileOpen(path, 1);
  888.  
  889. if (_fileHandle)
  890. _fileHandle.Close();
  891.  
  892. _isFileCheck = true;
  893. }
  894.  
  895. _fileHandle = FileOpen(path, mode);
  896. if (_fileHandle)
  897. break;
  898.  
  899. if (delay)
  900. Delay(200);
  901. }
  902.  
  903. if (_fileHandle) {
  904. if (mode == 0) {
  905. while (!_fileHandle.eof) {
  906. _line = _fileHandle.ReadLine();
  907. if (_line || !_fileHandle.eof)
  908. _msg += _line + msg;
  909. }
  910. }
  911. else if (msg)
  912. _fileHandle.WriteLine(msg);
  913.  
  914. _fileHandle.Close();
  915. }
  916.  
  917. return _msg;
  918. }
  919.  
  920. function SetForNextGame()
  921. {
  922. var gametime = GetTickCount() + 1000 * 60 * 3 + 1000 * 15;
  923. var timeTilStart = gametime - GetTickCount();
  924. locationTimeout(timeTilStart, location);
  925. chatActionsDone = false;
  926. inGameAt = 0;
  927. }
  928.  
  929. function NT_CheckNameLength(prefix, totallength)
  930. {
  931. var _howManyChars = totallength - prefix.length
  932. return _howManyChars;
  933. }
  934.  
  935. function NT_LogMuleAccount(newaccount)
  936. {
  937. var _newAccount = newaccount;
  938. var muleaccountlist = FileOpen("AMS/MuleLogs/" + me.account + "_muleaccount.txt", 2);
  939. if(!muleaccountlist)
  940. var muleaccountlist = FileOpen("AMS/MuleLogs/" + me.account + "_muleaccount.txt", 1);
  941.  
  942. muleaccountlist.WriteLine(_newAccount + "/" + muleAccountPassword);
  943. muleaccountlist.Close();
  944. return;
  945. }
  946.  
  947. function LogMuleAccountStatus(newaccount)
  948. {
  949. var _newAccount = newaccount;
  950. var muleaccountlist = FileOpen("AMS/MuleStatus/" + me.account + "_muleaccount.txt", 2);
  951. if(!muleaccountlist)
  952. var muleaccountlist = FileOpen("AMS/MuleStatus/" + me.account + "_muleaccount.txt", 1);
  953.  
  954. muleaccountlist.WriteLine(_newAccount);
  955. muleaccountlist.Close();
  956. return;
  957. }
  958.  
  959. function getRandomStringNames(_length)
  960. {
  961. _retString = "";
  962. _charSet = "abcdefghijklmnopqrstuvwxyz";
  963.  
  964. while(_length--)
  965. {
  966. _retString += _charSet.charAt(Random(0, _charSet.length-1));
  967. Delay(50);
  968. }
  969. return _retString;
  970. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement