Guest User

Untitled

a guest
Jul 28th, 2019
369
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 16.96 KB | None | 0 0
  1. var AutoMule = {
  2. Mules: {
  3. "Mule1": {
  4. muleProfile: "automule", // The name of mule profile in d2bot#. It will be started and stopped when needed.
  5. accountPrefix: "NisMule", // Account prefix. Numbers added automatically when making accounts.
  6. accountPassword: "******", // Account password.
  7. charPrefix: "NisMul", // Character prefix. Suffix added automatically when making characters.
  8. realm: "useast", // Available options: "useast", "uswest", "europe", "asia"
  9. expansion: true,
  10. ladder: true,
  11. hardcore: false,
  12. charsPerAcc: 8, // Maximum number of mules to create per account (between 1 to 18)
  13.  
  14. // Game name and password of the mule game. Never use the same game name as for mule logger.
  15. muleGameName: ["***", "321"], // ["gamename", "password"]
  16.  
  17. // List of profiles that will mule items. Example: enabledProfiles: ["profile 1", "profile 2"],
  18. enabledProfiles: ["nisleech", "bozolead", "Nastren", "rusher", "rush1 nis", "rush2 nes"],
  19.  
  20. // Stop a profile prior to muling. Useful when running 8 bots without proxies.
  21. stopProfile: "Nastren", "rush2 nes",
  22. stopProfileKeyRelease: true, // true = stopProfile key will get released on stop. useful when using 100% of your keys for botting.
  23.  
  24. // Trigger muling at the end of a game if used space in stash and inventory is equal to or more than given percent.
  25. usedStashTrigger: 80,
  26. usedInventoryTrigger: 80,
  27.  
  28. // Mule items that have been stashed at some point but are no longer in pickit.
  29. muleOrphans: true
  30. }
  31. },
  32.  
  33. /** Torch/Anni mules
  34. - Torch is muled in OrgTorch script after finishing uber Tristram successfully or when starting OrgTorch script with a Torch already on the character.
  35. - Anni is muled after successfully killing Diablo in Palace Cellar level 3 using Config.KillDclone option or KillDClone script.
  36. If a profile is listed in Torch/Anni mule's enabledProfiles list, it will also do a check to mule Anni at the end of each game.
  37. Anni that is in locked inventory slot will not be muled.
  38.  
  39. * Each mule will hold either a Torch or an Anni, but not both. As soon as the current mule has either one, a new one will be created.
  40. */
  41. TorchAnniMules: {
  42. "Mule1": {
  43. muleProfile: "", // The name of mule profile in d2bot#. It will be started and stopped when needed.
  44. accountPrefix: "", // Account prefix. Numbers added automatically when making accounts.
  45. accountPassword: "", // Account password.
  46. charPrefix: "", // Character prefix. Suffix added automatically when making characters.
  47. realm: "", // Available options: "useast", "uswest", "europe", "asia"
  48. expansion: true,
  49. ladder: true,
  50. hardcore: false,
  51. charsPerAcc: 8, // Maximum number of mules to create per account (between 1 to 18)
  52.  
  53. // Game name and password of the mule game. Never use the same game name as for mule logger.
  54. muleGameName: ["", ""], // ["gamename", "password"]
  55.  
  56. // List of profiles that will mule items. Example: enabledProfiles: ["profile 1", "profile 2"],
  57. enabledProfiles: [""],
  58.  
  59. // Stop a profile prior to muling. Useful when running 8 bots without proxies.
  60. stopProfile: ""
  61. }
  62. //##########################################################################################
  63. },
  64.  
  65. inGame: false,
  66. check: false,
  67. torchAnniCheck: false,
  68.  
  69. // *** Master functions ***
  70. getInfo: function () {
  71. var i, j, info;
  72.  
  73. for (i in this.Mules) {
  74. if (this.Mules.hasOwnProperty(i)) {
  75. for (j = 0; j < this.Mules[i].enabledProfiles.length; j += 1) {
  76. if (this.Mules[i].enabledProfiles[j].toLowerCase() === me.profile.toLowerCase()) {
  77. if (!info) {
  78. info = {};
  79. }
  80.  
  81. info.muleInfo = this.Mules[i];
  82. }
  83. }
  84. }
  85. }
  86.  
  87. for (i in this.TorchAnniMules) {
  88. if (this.TorchAnniMules.hasOwnProperty(i)) {
  89. for (j = 0; j < this.TorchAnniMules[i].enabledProfiles.length; j += 1) {
  90. if (this.TorchAnniMules[i].enabledProfiles[j].toLowerCase() === me.profile.toLowerCase()) {
  91. if (!info) {
  92. info = {};
  93. }
  94.  
  95. info.torchMuleInfo = this.TorchAnniMules[i];
  96. }
  97. }
  98. }
  99. }
  100.  
  101. return info;
  102. },
  103.  
  104. muleCheck: function () {
  105. var i, items,
  106. info = this.getInfo();
  107.  
  108. if (info && info.hasOwnProperty("muleInfo")) {
  109. items = this.getMuleItems();
  110.  
  111. if (info.muleInfo.hasOwnProperty("usedStashTrigger") && info.muleInfo.hasOwnProperty("usedInventoryTrigger") &&
  112. Storage.Inventory.UsedSpacePercent() >= info.muleInfo.usedInventoryTrigger && Storage.Stash.UsedSpacePercent() >= info.muleInfo.usedStashTrigger &&
  113. items.length > 0) {
  114. D2Bot.printToConsole("MuleCheck triggered!", 7);
  115.  
  116. return true;
  117. }
  118.  
  119. for (i = 0; i < items.length; i += 1) {
  120. if (this.matchItem(items[i], Config.AutoMule.Trigger)) {
  121. D2Bot.printToConsole("MuleCheck triggered!", 7);
  122. return true;
  123. }
  124. }
  125. }
  126.  
  127. return false;
  128. },
  129.  
  130. getMule: function () {
  131. var info;
  132.  
  133. info = this.getInfo();
  134.  
  135. if (info) {
  136. if (this.check && info.hasOwnProperty("muleInfo")) {
  137. return info.muleInfo;
  138. }
  139.  
  140. if (this.torchAnniCheck && info.hasOwnProperty("torchMuleInfo")) {
  141. return info.torchMuleInfo;
  142. }
  143. }
  144.  
  145. return false;
  146. },
  147.  
  148. outOfGameCheck: function () {
  149. if (!this.check && !this.torchAnniCheck) {
  150. return false;
  151. }
  152.  
  153. var i, control, muleObj,
  154. stopCheck = false,
  155. muleInfo = {status: ""},
  156. failCount = 0;
  157.  
  158. muleObj = this.getMule();
  159.  
  160. if (!muleObj) {
  161. return false;
  162. }
  163.  
  164. function MuleCheckEvent(mode, msg) {
  165. if (mode === 10) {
  166. muleInfo = JSON.parse(msg);
  167. }
  168. }
  169.  
  170. addEventListener("copydata", MuleCheckEvent);
  171. D2Bot.printToConsole("Starting " + (this.torchAnniCheck === 2 ? "anni" : this.torchAnniCheck === 1 ? "torch" : "") + " mule profile: " + muleObj.muleProfile, 7);
  172.  
  173. MainLoop:
  174. while (true) {
  175. // If nothing received our copy data start the mule profile
  176. if (!sendCopyData(null, muleObj.muleProfile, 10, JSON.stringify({profile: me.profile, mode: this.torchAnniCheck || 0}))) {
  177. // if the mule profile isn't already running and there is a profile to be stopped, stop it before starting the mule profile
  178. if (!stopCheck && muleObj.stopProfile && me.profile.toLowerCase() !== muleObj.stopProfile.toLowerCase()) {
  179. D2Bot.stop(muleObj.stopProfile, muleObj.stopProfileKeyRelease);
  180.  
  181. stopCheck = true;
  182.  
  183. delay(2000); // prevents cd-key in use error if using -skiptobnet on mule profile
  184. }
  185.  
  186. D2Bot.start(muleObj.muleProfile);
  187. }
  188.  
  189. delay(1000);
  190.  
  191. switch (muleInfo.status) {
  192. case "loading":
  193. if (!stopCheck && muleObj.stopProfile && me.profile.toLowerCase() !== muleObj.stopProfile.toLowerCase()) {
  194. D2Bot.stop(muleObj.stopProfile, muleObj.stopProfileKeyRelease);
  195.  
  196. stopCheck = true;
  197. }
  198.  
  199. failCount += 1;
  200.  
  201. break;
  202. case "busy":
  203. case "begin":
  204. D2Bot.printToConsole("Mule profile is busy.", 9);
  205.  
  206. break MainLoop;
  207. case "ready":
  208. control = getControl(6, 652, 469, 120, 20);
  209.  
  210. if (control) {
  211. delay(200);
  212. control.click();
  213. }
  214.  
  215. delay(2000);
  216.  
  217. this.inGame = true;
  218. me.blockMouse = true;
  219.  
  220. try {
  221. joinGame(muleObj.muleGameName[0], muleObj.muleGameName[1]);
  222. } catch (joinError) {
  223.  
  224. }
  225.  
  226. me.blockMouse = false;
  227.  
  228. // Untested change 11.Feb.14.
  229. for (i = 0; i < 8; i += 1) {
  230. delay(1000);
  231.  
  232. if (me.ingame && me.gameReady) {
  233. break MainLoop;
  234. }
  235. }
  236.  
  237. break;
  238. default:
  239. failCount += 1;
  240.  
  241. break;
  242. }
  243.  
  244. if (failCount >= 60) {
  245. D2Bot.printToConsole("No response from mule profile.", 9);
  246.  
  247. break;
  248. }
  249. }
  250.  
  251. removeEventListener("copydata", MuleCheckEvent);
  252.  
  253. while (me.ingame) {
  254. delay(1000);
  255. }
  256.  
  257. this.inGame = false;
  258. this.check = false;
  259. this.torchAnniCheck = false;
  260.  
  261. // No response - stop mule profile
  262. if (failCount >= 60) {
  263. D2Bot.stop(muleObj.muleProfile, true);
  264. delay(1000);
  265. }
  266.  
  267. if (stopCheck && muleObj.stopProfile) {
  268. D2Bot.start(muleObj.stopProfile);
  269. }
  270.  
  271. return true;
  272. },
  273.  
  274. inGameCheck: function () {
  275. var muleObj, tick, info,
  276. timeout = 150 * 1000, // Ingame mule timeout
  277. status = "muling";
  278.  
  279. // Single player
  280. if (!me.gamename) {
  281. return false;
  282. }
  283.  
  284. info = this.getInfo();
  285.  
  286. // Profile is not a part of AutoMule
  287. if (!info) {
  288. return false;
  289. }
  290.  
  291. // Profile is not in mule or torch mule game
  292. if (!((info.hasOwnProperty("muleInfo") && me.gamename.toLowerCase() === info.muleInfo.muleGameName[0].toLowerCase()) ||
  293. (info.hasOwnProperty("torchMuleInfo") && me.gamename.toLowerCase() === info.torchMuleInfo.muleGameName[0].toLowerCase()))) {
  294. return false;
  295. }
  296.  
  297. function DropStatusEvent(mode, msg) {
  298. if (mode === 10) {
  299. switch (JSON.parse(msg).status) {
  300. case "report": // reply to status request
  301. sendCopyData(null, muleObj.muleProfile, 12, JSON.stringify({status: status}));
  302.  
  303. break;
  304. case "quit": // quit command
  305. status = "quit";
  306.  
  307. break;
  308. }
  309. }
  310. }
  311.  
  312. function MuleModeEvent(msg) {
  313. switch (msg) {
  314. case "2":
  315. AutoMule.torchAnniCheck = 2;
  316.  
  317. break;
  318. case "1":
  319. AutoMule.torchAnniCheck = 1;
  320.  
  321. break;
  322. case "0":
  323. AutoMule.check = true;
  324.  
  325. break;
  326. }
  327. }
  328.  
  329. addEventListener("copydata", DropStatusEvent);
  330. addEventListener("scriptmsg", MuleModeEvent);
  331. scriptBroadcast("getMuleMode");
  332. delay(500);
  333.  
  334. if (!this.check && !this.torchAnniCheck) {
  335. print("Error - Unable to determine mule mode");
  336. quit();
  337.  
  338. return false;
  339. }
  340.  
  341. muleObj = this.getMule();
  342. me.maxgametime = 0;
  343.  
  344. if (!Town.goToTown(1)) {
  345. print("Error - Failed to go to Act 1");
  346. quit();
  347.  
  348. return false;
  349. }
  350.  
  351. sendCopyData(null, muleObj.muleProfile, 11, "begin");
  352.  
  353. if (this.torchAnniCheck === 2) {
  354. print("ÿc4AutoMuleÿc0: In anni mule game.");
  355. D2Bot.updateStatus("AutoMule: In game.");
  356. this.dropCharm(true);
  357. } else if (this.torchAnniCheck === 1) {
  358. print("ÿc4AutoMuleÿc0: In torch mule game.");
  359. D2Bot.updateStatus("AutoMule: In game.");
  360. this.dropCharm(false);
  361. } else {
  362. print("ÿc4AutoMuleÿc0: In mule game.");
  363. D2Bot.updateStatus("AutoMule: In game.");
  364. this.dropStuff();
  365. }
  366.  
  367. status = "done";
  368. tick = getTickCount();
  369.  
  370. while (true) {
  371. if (status === "quit") {
  372. break;
  373. }
  374.  
  375. if (getTickCount() - tick > timeout) {
  376. D2Bot.printToConsole("Mule didn't rejoin. Picking up items.", 9);
  377.  
  378. Misc.useItemLog = false; // Don't log items picked back up in town.
  379.  
  380. Pickit.pickItems();
  381.  
  382. break;
  383. }
  384.  
  385. delay(500);
  386. }
  387.  
  388. removeEventListener("copydata", DropStatusEvent);
  389. D2Bot.stop(muleObj.muleProfile, true);
  390. delay(1000);
  391.  
  392. if (muleObj.stopProfile) {
  393. D2Bot.start(muleObj.stopProfile);
  394. }
  395.  
  396. if (getScript("AnniStarter.dbj")) {
  397. scriptBroadcast("exit");
  398. }
  399.  
  400. delay(2000);
  401. quit();
  402. //delay(10000);
  403.  
  404. return true;
  405. },
  406.  
  407. dropStuff: function () {
  408. if (!Town.openStash()) {
  409. return false;
  410. }
  411.  
  412. var i,
  413. items = this.getMuleItems();
  414.  
  415. if (!items || items.length === 0) {
  416. return false;
  417. }
  418.  
  419. D2Bot.printToConsole("AutoMule: Transfering items.", 7);
  420.  
  421. for (i = 0; i < items.length; i += 1) {
  422. items[i].drop();
  423. }
  424.  
  425. delay(1000);
  426. me.cancel();
  427.  
  428. return true;
  429. },
  430.  
  431. matchItem: function (item, list) {
  432. var i, info, parsedLine,
  433. parsedPickit = [], classIDs = [];
  434.  
  435. for (i = 0; i < list.length; i += 1) {
  436. info = {
  437. file: "Character Config",
  438. line: list[i]
  439. };
  440.  
  441. if (typeof list[i] === "number") { // classids
  442. classIDs.push(list[i]);
  443. } else if (typeof list[i] === "string") { // pickit entries
  444. parsedLine = NTIP.ParseLineInt(list[i], info);
  445.  
  446. if (parsedLine) {
  447. parsedPickit.push(parsedLine);
  448. }
  449. }
  450. }
  451.  
  452. return (classIDs.indexOf(item.classid) > -1 || NTIP.CheckItem(item, parsedPickit));
  453. },
  454.  
  455. // get a list of items to mule
  456. getMuleItems: function () {
  457. var item, items,
  458. info = this.getInfo();
  459.  
  460. if (!info || !info.hasOwnProperty("muleInfo")) {
  461. return false;
  462. }
  463.  
  464. item = me.getItem(-1, 0);
  465. items = [];
  466.  
  467. if (item) {
  468. do {
  469. if (Town.ignoredItemTypes.indexOf(item.itemType) === -1 &&
  470. (Pickit.checkItem(item).result > 0 || (item.location === 7 && info.muleInfo.hasOwnProperty("muleOrphans") && info.muleInfo.muleOrphans)) &&
  471. item.classid !== 549 && // Don't drop Horadric Cube
  472. (item.classid !== 603 || item.quality !== 7) && // Don't drop Annihilus
  473. (item.classid !== 604 || item.quality !== 7) && // Don't drop Hellfire Torch
  474. (item.location === 7 || (item.location === 3 && !Storage.Inventory.IsLocked(item, Config.Inventory))) && // Don't drop items in locked slots
  475. ((!TorchSystem.getFarmers() && !TorchSystem.isFarmer()) || [647, 648, 649].indexOf(item.classid) === -1)) { // Don't drop Keys if part of TorchSystem
  476. if (this.matchItem(item, Config.AutoMule.Force.concat(Config.AutoMule.Trigger)) || // Always drop items on Force or Trigger list
  477. (!this.matchItem(item, Config.AutoMule.Exclude) && (!this.cubingIngredient(item) && !this.runewordIngredient(item) && !this.utilityIngredient(item)))) { // Don't drop Excluded items or Runeword/Cubing/CraftingSystem ingredients
  478. items.push(copyUnit(item));
  479. }
  480. }
  481. } while (item.getNext());
  482. }
  483.  
  484. return items;
  485. },
  486.  
  487. utilityIngredient: function (item) {
  488. return CraftingSystem.validGids.indexOf(item.gid) > -1;
  489. },
  490.  
  491. // check if an item is a cubing ingredient
  492. cubingIngredient: function (item) {
  493. var i;
  494.  
  495. for (i = 0; i < Cubing.validIngredients.length; i += 1) {
  496. if (item.gid === Cubing.validIngredients[i].gid) {
  497. return true;
  498. }
  499. }
  500.  
  501. return false;
  502. },
  503.  
  504. // check if an item is a runeword ingrediend - rune, empty base or bad rolled base
  505. runewordIngredient: function (item) {
  506. if (Runewords.validGids.indexOf(item.gid) > -1) {
  507. return true;
  508. }
  509.  
  510. if (!this.baseGids) {
  511. var i, base;
  512.  
  513. this.baseGids = [];
  514.  
  515. for (i = 0; i < Config.Runewords.length; i += 1) {
  516. base = Runewords.getBase(Config.Runewords[i][0], Config.Runewords[i][1], (Config.Runewords[i][2]||0)) || Runewords.getBase(Config.Runewords[i][0], Config.Runewords[i][1], (Config.Runewords[i][2]||0), true);
  517.  
  518. if (base) {
  519. this.baseGids.push(base.gid);
  520. }
  521. }
  522. }
  523.  
  524. if (this.baseGids.indexOf(item.gid) > -1) {
  525. return true;
  526. }
  527.  
  528. return false;
  529. },
  530.  
  531. dropCharm: function (dropAnni) {
  532. if (!Town.openStash()) {
  533. return false;
  534. }
  535.  
  536. var item;
  537.  
  538. if (dropAnni) {
  539. item = me.findItem(603, 0, -1, 7);
  540.  
  541. if (item && !Storage.Inventory.IsLocked(item, Config.Inventory)) {
  542. D2Bot.printToConsole("AutoMule: Transfering Anni.", 7);
  543. item.drop();
  544. delay(1000);
  545. me.cancel();
  546.  
  547. return true;
  548. }
  549.  
  550. return false;
  551. }
  552.  
  553. item = me.findItem(604, 0, -1, 7);
  554.  
  555. if (item) {
  556. D2Bot.printToConsole("AutoMule: Transfering Torch.", 7);
  557. item.drop();
  558. delay(1000);
  559. me.cancel();
  560.  
  561. return true;
  562. }
  563.  
  564. me.cancel();
  565.  
  566. return true;
  567. },
  568.  
  569. // *** Mule functions ***
  570. getMaster: function (info) {
  571. var i, j, k, muleObj;
  572.  
  573. muleObj = info.mode === 1 ? this.TorchAnniMules : this.Mules;
  574.  
  575. for (i in muleObj) {
  576. if (muleObj.hasOwnProperty(i)) {
  577. for (j in muleObj[i]) {
  578. if (muleObj[i].hasOwnProperty(j) && j === "enabledProfiles") {
  579. for (k = 0; k < muleObj[i][j].length; k += 1) {
  580. if (muleObj[i][j][k].toLowerCase() === info.profile.toLowerCase()) {
  581. return {
  582. profile: muleObj[i][j][k],
  583. mode: info.mode
  584. };
  585. }
  586. }
  587. }
  588. }
  589. }
  590. }
  591.  
  592. return false;
  593. },
  594.  
  595. getMuleObject: function (mode, master) {
  596. var i, mule;
  597.  
  598. mode = mode || 0;
  599. mule = mode > 0 ? this.TorchAnniMules : this.Mules;
  600.  
  601. for (i in mule) {
  602. if (mule.hasOwnProperty(i)) {
  603. if (mule[i].muleProfile && mule[i].enabledProfiles &&
  604. mule[i].muleProfile.toLowerCase() === me.profile.toLowerCase() && mule[i].enabledProfiles.indexOf(master) > -1) {
  605. return mule[i];
  606. }
  607. }
  608. }
  609.  
  610. return false;
  611. },
  612.  
  613. getMuleFilename: function (mode, master) {
  614. var i, mule, jsonObj, jsonStr, file;
  615.  
  616. mode = mode || 0;
  617. mule = mode > 0 ? this.TorchAnniMules : this.Mules;
  618.  
  619. // Iterate through mule object
  620. for (i in mule) {
  621. if (mule.hasOwnProperty(i)) {
  622. // Mule profile matches config
  623. if (mule[i].muleProfile && mule[i].muleProfile.toLowerCase() === me.profile.toLowerCase() && mule[i].enabledProfiles.indexOf(master) > -1) {
  624. file = mode === 0 ? "logs/AutoMule." + i + ".json" : "logs/TorchMule." + i + ".json";
  625.  
  626. // If file exists check for valid info
  627. if (FileTools.exists(file)) {
  628. try {
  629. jsonStr = FileTools.readText(file);
  630. jsonObj = JSON.parse(jsonStr);
  631.  
  632. // Return filename containing correct mule info
  633. if (mule[i].accountPrefix && jsonObj.account && jsonObj.account.match(mule[i].accountPrefix)) {
  634. return file;
  635. }
  636. } catch (e) {
  637. print(e);
  638. }
  639. } else {
  640. return file;
  641. }
  642. }
  643. }
  644. }
  645.  
  646. // File exists but doesn't contain valid info - remake
  647. FileTools.remove(file);
  648.  
  649. return file;
  650. }
  651. };
Advertisement
Add Comment
Please, Sign In to add comment