Advertisement
kolton

Untitled

May 22nd, 2012
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.69 KB | None | 0 0
  1. var AutoMule = {
  2. // The name of mule profile. It will be started and stopped when needed.
  3. muleProfile: "",
  4. accountPrefix: "",
  5. accountPassword: "",
  6. charPrefix: "",
  7. realm: "",
  8. expansion: true,
  9. ladder: false,
  10. hardcore: false,
  11.  
  12. // Game name and password of the mule game
  13. muleGameName: ["", ""],
  14.  
  15. // List of profiles that will mule items
  16. enabledProfiles: [],
  17.  
  18.  
  19.  
  20. // internal functions, don't edit
  21.  
  22. // check game name, override default.dbj actions
  23. inGameCheck: function () {
  24. if (me.gamename.toLowerCase() !== this.muleGameName[0].toLowerCase()) {
  25. return false;
  26. }
  27.  
  28. print("ÿc4AutoMuleÿc0: In mule game.");
  29. this.dropStuff();
  30.  
  31. // temp
  32. while (true) {
  33. delay(500);
  34. }
  35.  
  36. return true;
  37. },
  38.  
  39. // call mule profile, check if it's available for the mule session
  40. outOfGameCheck: function () {
  41. var status = "",
  42. failCount = 0;
  43.  
  44. function MuleCheckEvent(mode, msg) {
  45. status = msg;
  46. }
  47.  
  48. addEventListener("copydata", MuleCheckEvent);
  49. D2Bot.start(this.muleProfile);
  50.  
  51. MainLoop:
  52. while (true) {
  53. sendCopyData(null, this.muleProfile, 0, me.profile);
  54. delay(1000);
  55.  
  56. switch (status) {
  57. case "busy":
  58. D2Bot.printToConsole("Mule profile is busy");
  59.  
  60. break MainLoop;
  61. case "ready":
  62. joinGame(this.muleGameName[0], this.muleGameName[1]);
  63. delay(2000);
  64.  
  65. break MainLoop;
  66. default:
  67. failCount += 1;
  68.  
  69. if (failCount >= 30) {
  70. D2Bot.printToConsole("No response from mule profile.");
  71.  
  72. break MainLoop;
  73. }
  74.  
  75. break;
  76. }
  77. }
  78.  
  79. removeEventListener("copydata", MuleCheckEvent);
  80.  
  81. return true;
  82. },
  83.  
  84. dropStuff: function () {
  85. this.emptyStash();
  86. this.emptyInventory();
  87. delay(500);
  88. me.cancel();
  89. },
  90.  
  91. // empty the stash while ignoring cubing/runeword ingredients TODO skip horadric cube
  92. emptyStash: function () {
  93. if (!Town.openStash()) {
  94. return false;
  95. }
  96.  
  97. var i,
  98. items = me.getItems();
  99.  
  100. if (items) {
  101. for (i = 0; i < items.length; i += 1) {
  102. if (items[i].mode === 0 && items[i].location === 7 && Pickit.checkItem(items[i]) > 0 && items[i].classid !== 549 &&
  103. !this.cubingIngredient(items[i]) && !this.runewordIngredient(items[i])) {
  104. items[i].drop();
  105. }
  106. }
  107. }
  108.  
  109. return true;
  110. },
  111.  
  112. // empty the inventory while ignoring cubing/runeword ingredients TODO skip horadric cube
  113. emptyInventory: function () {
  114. if (!Town.openStash()) {
  115. return false;
  116. }
  117.  
  118. var i,
  119. items = Storage.Inventory.Compare(Config.Inventory);
  120.  
  121. if (items) {
  122. for (i = 0; i < items.length; i += 1) {
  123. if (items[i].mode === 0 && items[i].location === 3 && Pickit.checkItem(items[i]) > 0 && items[i].classid !== 549 &&
  124. !this.cubingIngredient(items[i]) && !this.runewordIngredient(items[i])) {
  125. items[i].drop();
  126. }
  127. }
  128. }
  129.  
  130. return true;
  131. },
  132.  
  133. // check if an item is a cubing ingredient
  134. cubingIngredient: function (item) {
  135. var i;
  136.  
  137. for (i = 0; i < Cubing.validIngredients.length; i += 1) {
  138. if (item.gid === Cubing.validIngredients[i].gid) {
  139. return true;
  140. }
  141. }
  142.  
  143. return false;
  144. },
  145.  
  146. // check if an item is a runeword ingrediend - rune, empty base or bad rolled base
  147. runewordIngredient: function (item) {
  148. if (Runewords.validGids.indexOf(item.gid) > -1) {
  149. return true;
  150. }
  151.  
  152. if (!this.baseGids) {
  153. var i, base;
  154.  
  155. this.baseGids = [];
  156.  
  157. for (i = 0; i < Config.Runewords.length; i += 1) {
  158. base = Runewords.getBase(Config.Runewords[i][0], Config.Runewords[i][1]) || Runewords.getBase(Config.Runewords[i][0], Config.Runewords[i][1], true);
  159.  
  160. if (base) {
  161. this.baseGids.push(base.gid);
  162. }
  163. }
  164. }
  165.  
  166. if (this.baseGids.indexOf(item.gid) > -1) {
  167. return true;
  168. }
  169.  
  170. return false;
  171. }
  172. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement