Advertisement
Guest User

Untitled

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