Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // default.dbj gets executed upon gamejoin
- js_strict(true);
- include("json2.js");
- include("NTItemParser.dbl");
- include("OOG.js");
- include("Gambling.js");
- include("common/Attack.js");
- include("common/Cubing.js");
- include("common/Config.js");
- include("common/Loader.js");
- include("common/Misc.js");
- include("common/Pickit.js");
- include("common/Pather.js");
- include("common/Precast.js");
- include("common/Prototypes.js");
- include("common/Runewords.js");
- include("common/Storage.js");
- include("common/Town.js");
- var gidList = []; // fast pickit
- function main() {
- if (!getScript("tools/heartbeat.js")) {
- load("tools/heartbeat.js");
- }
- while (!me.gameReady) {
- delay(50);
- }
- var i, sojPause,
- sojCounter = 0,
- startTime = getTickCount();
- this.gameEvent = function (mode, param1, param2, name1, name2) {
- switch (mode) {
- case 0:
- case 1:
- case 3:
- if (Config.QuitList.indexOf(name1) > -1) {
- print(name1 + (mode === 0 ? " timed out" : " left"));
- quit();
- }
- break;
- case 17: // 0x11 - "%Param1 Stones of Jordan Sold to Merchants"
- if (!Config.SoJWaitTime) {
- break;
- }
- D2Bot.printToConsole(param1 + " Stones of Jordan Sold to Merchants;7");
- sojPause = true;
- sojCounter = 0;
- break;
- case 18: // 0x12 - "Diablo Walks the Earth"
- if (!Config.StopOnDClone) {
- break;
- }
- D2Bot.printToConsole("Diablo Walks the Earth;7");
- removeEventListener("gameevent", this.gameEvent);
- scriptBroadcast("dclone");
- break;
- }
- };
- this.itemEvent = function (gid, mode, code, global) {
- if (gid > 0 && mode === 0) {
- gidList.push(gid);
- }
- };
- // If game name is a part of Gambling System, don't load scripts
- if (Gambling.goldFinders.indexOf(me.profile) > -1) {
- for (i = 0; i < Gambling.gambleGames.length; i += 1) {
- if (me.gamename.match(Gambling.gambleGames[i])) {
- Gambling.dropGold();
- DataFile.updateStats("gold");
- delay(5000);
- quit();
- }
- }
- }
- // Initialize libs - load config variables, build pickit list, attacks, containers and cubing and runeword recipes
- Config.init(true);
- Pickit.init();
- Attack.init();
- Storage.Init();
- Cubing.init();
- Runewords.init();
- me.maxgametime = Config.MaxGameTime * 1000;
- if (me.getStat(13) < DataFile.getStats().experience) { // check for experience decrease -> log death
- D2Bot.printToConsole("You died in last game;1");
- D2Bot.printToConsole("Experience decreased by " + (DataFile.getStats().experience - me.getStat(13)) + ";1");
- DataFile.updateDeaths();
- }
- DataFile.updateStats("experience");
- // Load events and threads
- addEventListener("gameevent", this.gameEvent);
- load("tools/ToolsThread.js");
- if (Config.PublicMode) {
- load("tools/Party.js");
- }
- if (Config.AntiHostile) {
- load("tools/AntiHostile.js");
- }
- if (Config.FastPick) {
- print("ÿc2Fast pickit active.");
- addEventListener("itemaction", this.itemEvent);
- }
- // One time maintenance - get corpse, clear leftover items, pick items in case anything important was dropped
- if (!Scripts.UserAddon && !Scripts.Test) {
- Town.getCorpse();
- Town.clearBelt();
- Town.clearInventory();
- Pickit.pickItems();
- }
- // Go
- Loader.init();
- if (Config.MinGameTime && getTickCount() - startTime < Config.MinGameTime * 1000) {
- try {
- Town.goToTown();
- while (getTickCount() - startTime < Config.MinGameTime * 1000) {
- me.overhead("Stalling for " + Math.round(((startTime + (Config.MinGameTime * 1000)) - getTickCount()) / 1000) + " Seconds");
- delay(1000);
- }
- } catch (e1) {
- print(e1);
- }
- }
- print("ÿc8Run duration ÿc2" + ((getTickCount() - startTime) / 1000));
- DataFile.updateStats("gold");
- if (Config.LogExperience) {
- delay(500);
- Experience.log();
- }
- if (sojPause) {
- try {
- Town.goToTown();
- me.maxgametime = 0;
- while (sojCounter < Config.SoJWaitTime) {
- me.overhead("Waiting for SoJ sales... " + (Config.SoJWaitTime - sojCounter) + " min");
- delay(6e4);
- sojCounter += 1;
- }
- } catch (e2) {
- print(e2);
- }
- }
- if (Config.LastMessage) {
- say(Config.LastMessage);
- }
- quit();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement