Advertisement
kolton

Untitled

May 22nd, 2012
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.96 KB | None | 0 0
  1. var MuleData = {
  2. create: function () {
  3. var obj, string;
  4.  
  5. obj = {
  6. account: "",
  7. character: "",
  8. full: []
  9. };
  10.  
  11. string = JSON.stringify(obj);
  12.  
  13. FileTools.writeText("AutoMule." + AutoMule.realm + ".json", string);
  14. },
  15.  
  16. read: function () {
  17. var obj, string;
  18.  
  19. string = FileTools.readText("AutoMule." + AutoMule.realm + ".json");
  20. obj = JSON.parse(string);
  21.  
  22. return obj;
  23. },
  24.  
  25. write: function (obj) {
  26. var string = JSON.stringify(obj);
  27.  
  28. FileTools.writeText("AutoMule." + AutoMule.realm + ".json", string);
  29. }
  30. };
  31.  
  32. function pickItems() {
  33. print("pickItems function");
  34.  
  35. var item,
  36. list = [];
  37.  
  38. // temp
  39. while (true) {
  40. item = getUnit(4, -1, 3); // item, on ground
  41.  
  42. if (item) {
  43. do {
  44. list.push(copyUnit(item));
  45. } while (item.getNext());
  46. }
  47.  
  48. while (list.length > 0) {
  49. print("list " + list.length);
  50.  
  51. print (Pickit.pickItem(list.shift()));
  52. }
  53.  
  54. delay(1000);
  55. }
  56. }
  57.  
  58. include("json2.js");
  59. include("oog.js");
  60. include("automule.js");
  61. include("common/storage.js");
  62. include("common/pickit.js");
  63. include("common/town.js");
  64. include("common/pather.js");
  65. include("common/misc.js");
  66. include("common/config.js");
  67. include("common/prototypes.js");
  68. load("tools/heartbeat.js");
  69.  
  70. function main() {
  71.  
  72.  
  73. var status = "loading";
  74.  
  75. function MuleEvent(mode, msg) {
  76. if (typeof msg === "string") {
  77. print("Got a status request from: " + msg);
  78. sendCopyData(null, msg, 0, status);
  79. }
  80. }
  81.  
  82. if (!FileTools.exists("AutoMule." + AutoMule.realm + ".json")) {
  83. MuleData.create();
  84. }
  85.  
  86. addEventListener("copydata", MuleEvent);
  87.  
  88. while (true) {
  89. if (me.gameReady && status !== "ready") {
  90. Storage.Init();
  91.  
  92. status = "ready";
  93.  
  94. pickItems();
  95. }
  96.  
  97. locationAction(getLocation());
  98. delay(1000);
  99. }
  100. }
  101.  
  102. function locationAction(location) {
  103. var obj, info;
  104.  
  105. switch (location) {
  106. case 18: // splash
  107. ControlAction.click();
  108. break;
  109. case 8: // menu
  110. case 9: // login
  111. obj = MuleData.read();
  112.  
  113. if (!obj.account || obj.account.indexOf(AutoMule.accountPrefix) < 0 || obj.character.indexOf(AutoMule.charPrefix) < 0) {
  114. obj.account = AutoMule.accountPrefix + "1";
  115. obj.character = AutoMule.charPrefix + "I";
  116.  
  117. MuleData.write(obj);
  118. }
  119.  
  120. info = {
  121. realm: AutoMule.realm,
  122. account: obj.account,
  123. password: AutoMule.accountPassword
  124. };
  125.  
  126. if (!ControlAction.loginAccount(info)) {
  127. ControlAction.makeAccount(info);
  128. FileTools.writeText("Mules/" + info.account + ".txt", "");
  129. }
  130.  
  131. break;
  132. case 12: // char select
  133. case 42: // empty char screen
  134. obj = MuleData.read();
  135.  
  136. info = {
  137. charName: obj.character,
  138. ladder: AutoMule.ladder,
  139. hardcore: AutoMule.hardcore,
  140. expansion: AutoMule.expansion,
  141. charClass: "amazon"
  142. };
  143.  
  144. if (ControlAction.findCharacter(info)) {
  145. ControlAction.loginCharacter(info);
  146. } else {
  147. ControlAction.makeCharacter(info);
  148. }
  149.  
  150. break;
  151. case 30: // charname already exists
  152. // todo
  153.  
  154. break;
  155. }
  156. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement