gamemaste789

Untitled

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