Advertisement
gob75

automule 4 dummy

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