Guest User

Untitled

a guest
Jun 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 21.31 KB | None | 0 0
  1. //credit for this goes to D2od who knows way more than I do
  2.  
  3. // =============================================================================
  4. // Leader Account settings
  5. // =============================================================================
  6. var leaderAccountName = "lost_ganja";
  7. var leaderName = "Lost_Njgga";
  8.  
  9. // =============================================================================
  10. // Game password (leave blank if none)
  11. // =============================================================================
  12. var gamepassword = "";
  13.  
  14. // =============================================================================
  15. // UseCDKeyChangeTrick :
  16. // if true, the follow bot will say his gamename/gamepwd (set in the OOG) in chat before each game
  17. // in order to increment his number of runs (to switch CDKeys after xx runs)
  18. // if false, the follow bot will never change his CDKey
  19. // =============================================================================
  20. var UseCDKeyChangeTrick = false;
  21.  
  22. // =============================================================================
  23. // Debug : set to true if you are experiencing problems with your JoinBot
  24. // it will log in your OOG the lobby chat actions
  25. // =============================================================================
  26. var Debug = false;
  27.  
  28. ////////////////////////////////////////////////////////////////////////////////
  29. // Lobby chat settings :
  30. ////////////////////////////////////////////////////////////////////////////////
  31.  
  32. // Set to true to join the chat after each game (needed for JoinBot)
  33. var joinChatAfterGame = false;
  34.  
  35. // Message said when you first enter the chat
  36. var firstJoinMessage = "join lost baalz for good xp!";
  37.  
  38. // Message said after each game
  39. var chatMessageAfterGame = "Stay in channel to follow runs";
  40.  
  41. // if this is true, will join a random channel, otherwise it will use the channel below..
  42. var joinRandomChannel = false;
  43. // Name of the channel you want to join (leave blank if you want to stay in the default channel)
  44. var joinChannelInChat = "op twistedmind";
  45.  
  46.  
  47. ////////////////////////////////////////////////////////////////////////////////
  48. // Delays:
  49. ////////////////////////////////////////////////////////////////////////////////
  50.  
  51. // Minimum game length, waits in the lobby if last game was too short
  52. // I recommend to keep a value > 300000 (milliseconds) to avoid bnet temporary ban
  53. var gameMinLength = 420000;
  54.  
  55. // realm delays (minutes)
  56. var unableToConnectRetry = 5;
  57. var realmDownRetry = 120;
  58. var disconnectedRetry = 5;
  59. var cdkeyInUseRetry = 5;
  60.  
  61. // interface delays (milliseconds)
  62. var connectingToBnetTimeout = 20000;
  63. var characterScreenTimeout = 10000;
  64. var pleaseWaitTimeout = 10000;
  65. var createGameThreshold = 10000;
  66. var createGameThresholdRandom = 1000;
  67. var createGameTimeout = 15000;
  68. var waitInLineTimeout = 15000;
  69. var characterSelectDelay = 1000;
  70. var loginDelay = 1000;
  71. var clickDelay = 500;
  72. var textDelay = 500;
  73. var clickDelayRandom = 500;
  74. var textDelayRandom = 500;
  75. var gameDoesNotExistDelayMin = 600000;
  76. var gameDoesNotExistDelayMax = 900000;
  77. var gameDoesNotExistTimeout = 30000;
  78. var waitBeforeEnterChatMin = 1000;
  79. var waitBeforeEnterChatMax = 2000;
  80. var waitInChatBeforeActionsMin = 2000;
  81. var waitInChatBeforeActionsMax = 3000;
  82.  
  83. // Only for JoinBot (friend list delay, milliseconds)
  84. var LeaderOfflineDelay = 30000;
  85. var LeaderInChatDelay = 10000;
  86. var GameIsFullDelay = 30000;
  87.  
  88. ////////////////////////////////////////////////////////////////////////////////
  89. ////////////////////////////////////////////////////////////////////////////////
  90. // DO NOT EDIT ANYTHING BELOW THIS
  91. ////////////////////////////////////////////////////////////////////////////////
  92. ////////////////////////////////////////////////////////////////////////////////
  93.  
  94. //D2NT Manager Command
  95.  
  96. const D2NT_MGR_LOADING = 1;
  97. const D2NT_MGR_READY = 2;
  98. const D2NT_MGR_LOGIN = 3;
  99. const D2NT_MGR_CREATE_GAME = 4;
  100. const D2NT_MGR_INGAME = 5;
  101. const D2NT_MGR_RESTART = 6;
  102. const D2NT_MGR_CHICKEN = 7;
  103. const D2NT_MGR_PRINT_STATUS = 8;
  104. const D2NT_MGR_PRINT_LOG = 9;
  105.  
  106. var lastGameMade = GetTickCount();
  107. var lastGameStatus = 0;
  108. var nextGameMake = 0;
  109. var inGameAt = 0;
  110. var chatActionsDone = false;
  111. var lastGameFailed = false;
  112. var sayChatMsgAfterGame = false;
  113.  
  114. Include("libs/controlInfo.ntl");
  115. Include("libs/common/NTColorConverter.ntl");
  116.  
  117. var controlData = new controlInfo();
  118.  
  119. var game = '';
  120. var _gamename = "";
  121. var _gamepassword = "";
  122. var _leaderOfflineTick = -LeaderOfflineDelay;
  123. var _leaderInChatTick = -LeaderInChatDelay;
  124. var _GameIsFullTick = -GameIsFullDelay;
  125.  
  126. function NTMain()
  127. {
  128. Delay(1000);
  129.  
  130. var _ingame = false;
  131.  
  132. controlData.clickDelay = clickDelay;
  133. controlData.textDelay = textDelay;
  134. controlData.clickDelayRandom = clickDelayRandom;
  135. controlData.textDelayRandom = textDelayRandom;
  136.  
  137. while(1)
  138. {
  139. if(me.ingame)
  140. {
  141. _gamename = me.gamename;
  142. _gamepassword = me.gamepassword;
  143.  
  144. if(!inGameAt)
  145. inGameAt = GetTickCount();
  146.  
  147. if(!_ingame)
  148. {
  149. RunGC(); // run garbage collector between each game
  150.  
  151. if(Load("NTBot/NTBotGame.ntj"))
  152. {
  153. _ingame = true;
  154.  
  155. if(me.playtype > 0)
  156. sendEventToOOG(D2NT_MGR_INGAME, "In Game[IP:" + me.gameserverip.split(".")[3] + "]", 0);
  157. else
  158. sendEventToOOG(D2NT_MGR_INGAME, "In Game", 0);
  159.  
  160. lastGameStatus = 2; // in game successful
  161.  
  162. // To exit game as soon as the leader quits
  163. //Load("NTBot/NTCheckLeader.ntj");
  164. // to party only the leader
  165. //Load("NTBot/tools/NTTools_AutoPartyJoinFriendGames.ntj");
  166. }
  167. }
  168.  
  169. Delay(1000);
  170. }
  171. else
  172. {
  173. if(_ingame)
  174. {
  175. _ingame = false;
  176. sayChatMsgAfterGame = true;
  177.  
  178. sendEventToOOG(D2NT_MGR_READY, "", 0);
  179. }
  180.  
  181. locationAction(controlData.getLocation());
  182.  
  183. Delay(500);
  184. }
  185. }
  186. }
  187.  
  188. function locationAction(location)
  189. {
  190. switch(location.id)
  191. {
  192. case 3: // Lobby Chat
  193. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  194.  
  195. if(!chatActionsDone)
  196. {
  197. Delay(Random(waitInChatBeforeActionsMin, waitInChatBeforeActionsMax));
  198.  
  199. if(joinRandomChannel || joinChannelInChat != "")
  200. {
  201. Say("/join " + (joinRandomChannel ? getRandomString(Random(3,10)) : joinChannelInChat));
  202. Delay(1000);
  203. }
  204.  
  205. if(firstJoinMessage)
  206. {
  207. Say(firstJoinMessage);
  208. Delay(200);
  209. }
  210.  
  211. chatActionsDone = true;
  212. }
  213.  
  214. if (chatMessageAfterGame && _gamename != "" && sayChatMsgAfterGame == true)
  215. {
  216. Say(chatMessageAfterGame);
  217. sayChatMsgAfterGame = false;
  218. Delay(200);
  219. }
  220.  
  221. game = '';
  222.  
  223. var _tick = GetTickCount();
  224. if ((_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick)
  225. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)
  226. && (_GameIsFullTick < 0 || (_GameIsFullTick + GameIsFullDelay) < _tick))
  227. {
  228. DebugInOOG('Locating the leader : '+leaderAccountName);
  229. Say('/f l');
  230. Delay(1500);
  231. }
  232.  
  233. if(chat = controlData.get(controlData.controls.lobby.chat.textBox.channelText))
  234. {
  235. var found_leader = false;
  236. lines = chat.GetText();
  237. if(!lines) { break; }
  238. for (var line_id = lines.length - 1; line_id > -1; line_id--)
  239. {
  240. if (found_leader) // useless... :/
  241. break;
  242.  
  243. if (lines[line_id].substring(0,1) == " ")
  244. continue;
  245.  
  246. // retrieving the whole message
  247. var msg = lines[line_id].replace(/^\s+|\s+$/, "");
  248. var msglines = 1;
  249. while (lines[line_id+msglines] != undefined && lines[line_id+msglines].substring(0,2) == " ")
  250. {
  251. msg += " " + lines[line_id+msglines].replace(/^\s+|\s+$/, "");
  252. msglines++;
  253. }
  254. if (msg.lastIndexOf(leaderName) >= 0)
  255. DebugInOOG("yc8found him :;"+msg);
  256.  
  257. // checking if the msg is a friendly whisper
  258. if (msg.lastIndexOf(leaderName + ' (*' +leaderAccountName+')') > -1)
  259. {
  260. var regGameNameWhispered=/^.*(game|partie|spiel|partita|partida).*(nomm[^\s]*|called|chiamata)\s*([\w\s-]*\w)\s*\.\s*$/gi;
  261. if (msg.match(regGameNameWhispered))
  262. game = msg.replace(regGameNameWhispered, "$3");
  263.  
  264. if (game != '')
  265. {
  266. found_leader = true;
  267. break;
  268. }
  269. }
  270.  
  271. // checking if the msg is from the friend list
  272. if (msg.lastIndexOf(': '+leaderAccountName+',') > -1)
  273. {
  274. found_leader = true;
  275. var regOffline=/^.*(offline|desconectado).*$/gi;
  276. var regInChat=/^.*(channel|canale?)\s*([\w\s-]*\w)\.?\s*$/gi;
  277. var regGameName=/^.*(game|partie|spiel|partita|partida)\s*([\w\s-]*\w)\s*\(priv[^\)]*\)\.\s*$/gi;
  278.  
  279. if (msg.match(regOffline)
  280. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  281. {
  282. DebugInOOG('Leader is offline, delay '+Math.round(LeaderOfflineDelay/1000)+' sec for next /f l.');
  283. _leaderOfflineTick = GetTickCount();
  284. }
  285. else if (msg.match(regInChat)
  286. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick))
  287. {
  288. DebugInOOG('Leader is in the chat "'+msg.replace(regInChat, "$2")+'", delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  289. _leaderInChatTick = GetTickCount();
  290. }
  291. else if (msg.match(regGameName)
  292. && ((_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick)
  293. && (_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)))
  294. {
  295. game = msg.replace(regGameName, "$2");
  296. }
  297. else if ((_leaderInChatTick < 0 || (_leaderInChatTick + LeaderInChatDelay) < _tick)
  298. && (_leaderOfflineTick < 0 || (_leaderOfflineTick + LeaderOfflineDelay) < _tick))
  299. {
  300. // unhandled line, supposelly "In Realm"
  301. DebugInOOG('The leader was in the the lobby but not in chat, delay '+Math.round(LeaderInChatDelay/1000)+' sec for next /f l.');
  302. _leaderInChatTick = GetTickCount();
  303. }
  304.  
  305. break;
  306. }
  307. }
  308.  
  309. if (found_leader == false)
  310. DebugInOOG('I couldn\'t find the leader in my friend list!');
  311.  
  312. if (game!="")
  313. {
  314. if (UseCDKeyChangeTrick)
  315. {
  316. // increasing the number of runs in the OOG (for CDKey switch)
  317. // Problem : the gamename/gamepassword set in your OOG will be typed in the lobbyChat
  318. // this may output a red message in the lobby chat if you have a password set (not a real problem)
  319. // 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
  320. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  321. Delay(1000);
  322. }
  323.  
  324. DebugInOOG('Leader is in the game "' + game + '"');
  325. controlData.click(controlData.controls.lobby.button.join);
  326. Delay(100);
  327. }
  328.  
  329. }
  330. else
  331. {
  332. DebugInOOG('I can\'t read the chat!');
  333. //DebugInOOG('You probably haven\'t added the lobby chat controlinfo coordinates!');
  334. Delay(30000);
  335. }
  336. break;
  337.  
  338. case 1: // Lobby
  339. if(location.id == 1 && joinChatAfterGame)
  340. {
  341. Delay(Random(waitBeforeEnterChatMin, waitBeforeEnterChatMax));
  342. controlData.click(controlData.controls.lobby.button.enterChat);
  343. break;
  344. }
  345. break;
  346.  
  347. case 2: // Waiting In Line
  348. if(GetTickCount()-lastGameMade > waitInLineTimeout)
  349. controlData.click(controlData.controls.lobby.inLine.button.cancel);
  350. break;
  351.  
  352. case 4: // Create Game
  353. if(!controlData.get(controlData.controls.lobby.create.editBox.gameName))
  354. {
  355. controlData.click(controlData.controls.lobby.button.join);
  356. Delay (500);
  357. controlData.click(controlData.controls.lobby.button.create);
  358. Delay (500);
  359. break;
  360. }
  361.  
  362. sendEventToOOG(D2NT_MGR_CREATE_GAME, location.name, 0);
  363.  
  364. locationTimeout(5000, location);
  365.  
  366. lastGameMade = GetTickCount();
  367. lastGameStatus = 1; // pending creation
  368. break;
  369.  
  370. case 5: // Join Game
  371. if (game)
  372. {
  373. controlData.setText( controlData.controls.lobby.join.editBox.gameName, game);
  374. Delay (100);
  375. controlData.setText( controlData.controls.lobby.join.editBox.password, gamepassword);
  376. Delay (100);
  377. controlData.click(controlData.controls.lobby.join.button.joinGame);
  378. RunGC(); // run garbage collector between each game
  379. locationTimeout(5000, location);
  380. lastGameStatus = 1; // pending join
  381. }
  382. else
  383. {
  384. DebugInOOG('No game to join : cancelling');
  385. me.Cancel(1);
  386. Delay(1000);
  387. }
  388. break;
  389.  
  390. case 6: // Ladder
  391. break;
  392.  
  393. case 7: // Channel List
  394. break;
  395.  
  396. case 8: // Main Menu
  397. if(controlData.getCurrentRealmIndex() == me.gatewayid)
  398. {
  399. outputGameLength();
  400. controlData.click(controlData.gameTypes[me.playtype]);
  401. }
  402. else
  403. controlData.click(controlData.controls.mainMenu.button.gateway);
  404. break;
  405.  
  406. case 9: // Login
  407. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  408. Delay(loginDelay);
  409.  
  410. controlData.setText(controlData.controls.login.editBox.accountName, me.account);
  411.  
  412. sendEventToOOG(D2NT_MGR_LOGIN, location.name, 0);
  413.  
  414. locationTimeout(5000, location);
  415. break;
  416.  
  417. case 10: // Login Error (this is a fatal error, so stop)
  418. sendEventToOOG(D2NT_MGR_RESTART, location.name, 10);
  419. Delay(3500);
  420. break;
  421.  
  422. case 11: // Unable To Connect
  423. timeoutDelay(unableToConnectRetry*60*1000, location)
  424. controlData.click(controlData.controls.login.unableToConnect.button.ok);
  425. break;
  426.  
  427. case 12: // Character Select
  428. var _time, _control;
  429.  
  430. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name, 0);
  431.  
  432. for(_time = 0 ; _time < characterScreenTimeout ; _time += 500)
  433. {
  434. _control = controlData.get(controlData.controls.characterSelect.textBox.characterInfo[me.charloc]);
  435. if(_control && _control.GetText() != undefined)
  436. break;
  437.  
  438. Delay(500);
  439. }
  440.  
  441. if(_time < characterScreenTimeout)
  442. {
  443. Delay(characterSelectDelay);
  444.  
  445. controlData.click(controlData.controls.characterSelect.textBox.characters[me.charloc], 0, 0, 1);
  446. controlData.click(controlData.controls.characterSelect.textBox.characterInfo[me.charloc], 0, 0, 1);
  447.  
  448. // reset last game made, so it doesnt make a game immediately
  449. inGameAt = 0;
  450. setNextGameMake();
  451. }
  452. else
  453. {
  454. controlData.click(controlData.controls.characterSelect.button.exit);
  455. timeoutDelay(realmDownRetry*60*1000, location);
  456. }
  457. break;
  458.  
  459. case 13: // Realm Down - Character Select screen
  460. controlData.click(controlData.controls.characterSelect.button.exit);
  461. timeoutDelay(realmDownRetry*60*1000, location);
  462. break;
  463.  
  464. case 14: // Character Select - Disconnected
  465. timeoutDelay(disconnectedRetry*60*1000, location);
  466. controlData.click(controlData.controls.characterSelect.disconnected.button.ok);
  467. break;
  468.  
  469. case 15: // New Character
  470. break;
  471.  
  472. case 16: // Character Select - Please Wait popup
  473. if(!locationTimeout(pleaseWaitTimeout, location))
  474. controlData.click(controlData.controls.characterSelect.pleaseWait.button.cancel);
  475. break;
  476.  
  477. case 17: // Lobby - Lost Connection - just click okay, since we're toast anyway
  478. controlData.click(controlData.controls.lobby.lostConnection.button.ok);
  479. break;
  480.  
  481. case 18: // D2 Splash
  482. controlData.click(controlData.controls.d2Splash.textBox.copyright);
  483. break;
  484.  
  485. case 19: // Login - Cdkey In Use
  486. timeoutDelay(cdkeyInUseRetry*60*1000, location);
  487. controlData.click(controlData.controls.login.cdkeyInUse.button.ok);
  488. break;
  489.  
  490. case 20: // Single Player - Select Difficulty
  491. controlData.click(controlData.singlePlayerDifficulties[me.diff]);
  492. break;
  493.  
  494. case 21: // Main Menu - Connecting
  495. if(!locationTimeout(connectingToBnetTimeout, location))
  496. controlData.click(controlData.controls.mainMenu.connecting.button.cancel);
  497. break;
  498.  
  499. case 22: // Login - Invalid Cdkey (classic or xpac)
  500. sendEventToOOG(D2NT_MGR_RESTART, location.name, 3600);
  501. Delay(3500);
  502. break;
  503.  
  504. case 23: // Character Select - Connecting
  505. if(!locationTimeout(characterScreenTimeout, location))
  506. controlData.click(controlData.controls.characterSelect.button.exit);
  507. break;
  508.  
  509. case 24: // Server Down - not much to do but wait..
  510. break;
  511.  
  512. case 25: // Lobby - Please Wait
  513. if(!locationTimeout(pleaseWaitTimeout, location))
  514. controlData.click(controlData.controls.lobby.pleaseWait.button.cancel);
  515. break;
  516.  
  517. case 26: // Lobby - Game Name Exists
  518. sendEventToOOG(D2NT_MGR_PRINT_LOG, "yE00000Game already exists", 0);
  519.  
  520. inGameAt = 0;
  521. lastGameStatus = 0;
  522. setNextGameMake();
  523.  
  524. locationTimeout(15000, location);
  525. break;
  526.  
  527. case 27: // Gateway Select
  528. controlData.clickRealmEntry(me.gatewayid);
  529. controlData.click(controlData.controls.gateway.button.ok);
  530. break;
  531.  
  532. case 28: // Lobby - Game Does Not Exist
  533. inGameAt = Random(gameDoesNotExistDelayMin, gameDoesNotExistDelayMax);
  534. lastGameStatus = 0;
  535. setNextGameMake();
  536.  
  537. locationTimeout(gameDoesNotExistTimeout, location);
  538. break;
  539. default:
  540. DebugInOOG("Unhandled location : "+location.id);
  541. break;
  542. }
  543. DebugInOOG("Location : "+location.id);
  544. }
  545.  
  546. function sendEventToOOG(locationId, statusString, pendingTime)
  547. {
  548. return SendCopyData("D2NT Manager", null, (locationId<<16)|pendingTime, statusString);
  549. }
  550.  
  551. function setNextGameMake()
  552. {
  553. lastGameMade = GetTickCount();
  554. nextGameMake = lastGameMade + createGameThreshold + Random(0-createGameThresholdRandom, createGameThresholdRandom) + inGameAt;
  555. inGameAt = 0;
  556. chatActionsDone = false;
  557. }
  558.  
  559. function outputGameLength()
  560. {
  561. if(inGameAt)
  562. {
  563. duration = GetTickCount() - inGameAt;
  564.  
  565. inGameAt = (duration < gameMinLength ? gameMinLength - duration : 0);
  566. }
  567. }
  568.  
  569. function locationTimeout(time, location)
  570. {
  571. endtime = GetTickCount() + time;
  572.  
  573. while(controlData.getLocation().id == location.id && endtime > GetTickCount())
  574. {
  575. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  576. Delay(500);
  577. }
  578.  
  579. return (controlData.getLocation().id != location.id);
  580. }
  581.  
  582. function timeoutDelay(time, location)
  583. {
  584. endtime = GetTickCount() + time;
  585.  
  586. while(endtime > GetTickCount())
  587. {
  588. sendEventToOOG(D2NT_MGR_PRINT_STATUS, location.name + " (" + parseInt((endtime-GetTickCount())/1000) + "s)", 0);
  589. Delay(1000);
  590. }
  591. }
  592.  
  593. function getRandomString(_length)
  594. {
  595. _retString = "";
  596. _charSet = "0123456789abcdefghijklmnopqrstuvwxyz";
  597.  
  598. while(_length--)
  599. {
  600. _retString += _charSet.charAt(Random(0, _charSet.length-1));
  601. Delay(1);
  602. }
  603.  
  604. return _retString;
  605. }
  606. function DebugInOOG(logString)
  607. {
  608. if (Debug)
  609. return SendCopyData("D2NT Manager", null, 9<<16, "-- Debug : " + logString);
  610. else
  611. return false;
  612. }
Add Comment
Please, Sign In to add comment