Advertisement
kolton

Untitled

Jun 2nd, 2012
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.11 KB | None | 0 0
  1. // default.dbj gets executed upon gamejoin
  2. js_strict(true);
  3.  
  4. include("json2.js");
  5. include("NTItemParser.dbl");
  6. include("OOG.js");
  7. include("Gambling.js");
  8. include("common/Attack.js");
  9. include("common/Cubing.js");
  10. include("common/Config.js");
  11. include("common/Loader.js");
  12. include("common/Misc.js");
  13. include("common/Pickit.js");
  14. include("common/Pather.js");
  15. include("common/Precast.js");
  16. include("common/Prototypes.js");
  17. include("common/Runewords.js");
  18. include("common/Storage.js");
  19. include("common/Town.js");
  20.  
  21. var gidList = []; // fast pickit
  22.  
  23. function main() {
  24. if (!getScript("tools/heartbeat.js")) {
  25. load("tools/heartbeat.js");
  26. }
  27.  
  28. while (!me.gameReady) {
  29. delay(50);
  30. }
  31.  
  32. var i, sojPause,
  33. sojCounter = 0,
  34. startTime = getTickCount();
  35.  
  36. this.gameEvent = function (mode, param1, param2, name1, name2) {
  37. switch (mode) {
  38. case 0:
  39. case 1:
  40. case 3:
  41. if (Config.QuitList.indexOf(name1) > -1) {
  42. print(name1 + (mode === 0 ? " timed out" : " left"));
  43. quit();
  44. }
  45.  
  46. break;
  47. case 17: // 0x11 - "%Param1 Stones of Jordan Sold to Merchants"
  48. if (!Config.SoJWaitTime) {
  49. break;
  50. }
  51.  
  52. D2Bot.printToConsole(param1 + " Stones of Jordan Sold to Merchants;7");
  53. sojPause = true;
  54. sojCounter = 0;
  55.  
  56. break;
  57. case 18: // 0x12 - "Diablo Walks the Earth"
  58. if (!Config.StopOnDClone) {
  59. break;
  60. }
  61.  
  62. D2Bot.printToConsole("Diablo Walks the Earth;7");
  63. removeEventListener("gameevent", this.gameEvent);
  64. scriptBroadcast("dclone");
  65.  
  66. break;
  67. }
  68. };
  69.  
  70. this.itemEvent = function (gid, mode, code, global) {
  71. if (gid > 0 && mode === 0) {
  72. gidList.push(gid);
  73. }
  74. };
  75.  
  76. // If game name is a part of Gambling System, don't load scripts
  77. if (Gambling.goldFinders.indexOf(me.profile) > -1) {
  78. for (i = 0; i < Gambling.gambleGames.length; i += 1) {
  79. if (me.gamename.match(Gambling.gambleGames[i])) {
  80. Gambling.dropGold();
  81. DataFile.updateStats("gold");
  82. delay(5000);
  83. quit();
  84. }
  85. }
  86. }
  87.  
  88. // Initialize libs - load config variables, build pickit list, attacks, containers and cubing and runeword recipes
  89. Config.init(true);
  90. Pickit.init();
  91. Attack.init();
  92. Storage.Init();
  93. Cubing.init();
  94. Runewords.init();
  95.  
  96. me.maxgametime = Config.MaxGameTime * 1000;
  97.  
  98. if (me.getStat(13) < DataFile.getStats().experience) { // check for experience decrease -> log death
  99. D2Bot.printToConsole("You died in last game;1");
  100. D2Bot.printToConsole("Experience decreased by " + (DataFile.getStats().experience - me.getStat(13)) + ";1");
  101. DataFile.updateDeaths();
  102. }
  103.  
  104. DataFile.updateStats("experience");
  105.  
  106. // Load events and threads
  107. addEventListener("gameevent", this.gameEvent);
  108. load("tools/ToolsThread.js");
  109.  
  110. if (Config.PublicMode) {
  111. load("tools/Party.js");
  112. }
  113.  
  114. if (Config.AntiHostile) {
  115. load("tools/AntiHostile.js");
  116. }
  117.  
  118. if (Config.FastPick) {
  119. print("ÿc2Fast pickit active.");
  120. addEventListener("itemaction", this.itemEvent);
  121. }
  122.  
  123. // One time maintenance - get corpse, clear leftover items, pick items in case anything important was dropped
  124. if (!Scripts.UserAddon && !Scripts.Test) {
  125. Town.getCorpse();
  126. Town.clearBelt();
  127. Town.clearInventory();
  128. Pickit.pickItems();
  129. }
  130.  
  131. // Go
  132. Loader.init();
  133.  
  134. if (Config.MinGameTime && getTickCount() - startTime < Config.MinGameTime * 1000) {
  135. try {
  136. Town.goToTown();
  137.  
  138. while (getTickCount() - startTime < Config.MinGameTime * 1000) {
  139. me.overhead("Stalling for " + Math.round(((startTime + (Config.MinGameTime * 1000)) - getTickCount()) / 1000) + " Seconds");
  140. delay(1000);
  141. }
  142. } catch (e1) {
  143. print(e1);
  144. }
  145. }
  146.  
  147. print("ÿc8Run duration ÿc2" + ((getTickCount() - startTime) / 1000));
  148. DataFile.updateStats("gold");
  149.  
  150. if (Config.LogExperience) {
  151. delay(500);
  152. Experience.log();
  153. }
  154.  
  155. if (sojPause) {
  156. try {
  157. Town.goToTown();
  158.  
  159. me.maxgametime = 0;
  160.  
  161. while (sojCounter < Config.SoJWaitTime) {
  162. me.overhead("Waiting for SoJ sales... " + (Config.SoJWaitTime - sojCounter) + " min");
  163. delay(6e4);
  164.  
  165. sojCounter += 1;
  166. }
  167. } catch (e2) {
  168. print(e2);
  169. }
  170. }
  171.  
  172. if (Config.LastMessage) {
  173. say(Config.LastMessage);
  174. }
  175.  
  176. quit();
  177. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement