This repository has been archived by the owner on Apr 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
default.dbj
340 lines (274 loc) · 7.49 KB
/
default.dbj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
// default.dbj gets executed upon gamejoin
js_strict(true);
include("json2.js");
include("NTItemParser.dbl");
include("OOG.js");
include("AutoMule.js");
include("Gambling.js");
include("CraftingSystem.js");
include("TorchSystem.js");
include("MuleLogger.js");
include("GameAction.js");
include("common/Attack.js");
include("common/Cubing.js");
include("common/CollMap.js");
include("common/Config.js");
include("common/Loader.js");
include("common/misc.js");
include("common/util.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");
function main () {
D2Bot.init(); // Get D2Bot# handle
D2Bot.ingame();
// wait until game is ready
while (!me.gameReady) {
delay(50);
}
clearAllEvents(); // remove any event listeners from game crash
if (!getScript("tools/heartbeat.js")) {
load("tools/heartbeat.js");
}
if (getScript("d2botmap.dbj")) {
load("tools/mapthread.js");
if (FileTools.exists("tools/maptoolsthread.js")) {
load("tools/maptoolsthread.js");
} else {
load("tools/ToolsThread.js");
}
Config.init(true);
LocalChat.init();
if (Config.PublicMode) {
load("tools/party.js");
}
if (Config.ManualPlayPick) {
load("tools/pickthread.js");
}
if (Config.AutoMap) {
me.automap = true;
}
while (true) {
delay(1000);
}
}
if (getScript("D2BotShopDrop.dbj")) {
return true;
}
// don't load default for dropper/mules
if (getScript("D2BotDropper.dbj") || getScript("D2BotMule.dbj") || getScript("D2BotDrop.dbj")) {
while(true) {
try {
if (me.gameReady && me.ingame && !me.inTown) {
D2Bot.printToConsole("Saved from suicide walk!");
D2Bot.restart();
}
} catch (e) {
D2Bot.restart();
}
delay(1000);
}
return true;
}
// MuleLogger handler
if (MuleLogger.inGameCheck()) {
return true;
}
var i, sojPause, stats, anni,
sojCounter = 0,
startTime = getTickCount();
this.itemEvent = function (gid, mode, code, global) {
if (gid > 0 && mode === 0) {
Pickit.gidList.push(gid);
}
};
this.scriptEvent = function (msg) {
switch (msg) {
case "soj":
sojPause = true;
sojCounter = 0;
break;
}
};
this.copyDataEvent = function (mode, msg) {
if (mode === 0 && msg === "mule") { // "Mule Profile" option from D2Bot#
if (AutoMule.getInfo() && AutoMule.getInfo().hasOwnProperty("muleInfo")) {
if (AutoMule.getMuleItems().length > 0) {
D2Bot.printToConsole("Mule triggered");
scriptBroadcast("mule");
scriptBroadcast("quit");
} else {
D2Bot.printToConsole("No items to mule.");
}
} else {
D2Bot.printToConsole("Profile not enabled for muling.");
}
}
if (mode === 1638) { // getProfile
msg = JSON.parse(msg);
if (msg.Tag) {
GameAction.init(msg.Tag);
}
}
};
// Initialize libs - load config variables, build pickit list, attacks, containers and cubing and runeword recipes
Config.init(true);
Pickit.init(true);
Attack.init();
Storage.Init();
CraftingSystem.buildLists();
Runewords.init();
Cubing.init();
LocalChat.init();
// Load events
addEventListener("scriptmsg", this.scriptEvent);
addEventListener("copydata", this.copyDataEvent);
// GameAction handler
if (GameAction.inGameCheck()) {
return true;
}
// AutoMule handler
if (AutoMule.inGameCheck()) {
return true;
}
// TorchSystem handler
if (TorchSystem.inGameCheck()) {
return true;
}
// Gambling System handler
if (Gambling.inGameCheck()) {
return true;
}
// Crafting System handler
if (CraftingSystem.inGameCheck()) {
return true;
}
me.maxgametime = Config.MaxGameTime * 1000;
stats = DataFile.getStats();
// Check for experience decrease -> log death. Skip report if life chicken is disabled.
if (stats.name === me.name && me.getStat(13) < stats.experience && Config.LifeChicken > 0) {
D2Bot.printToConsole("You died in last game", 9);
D2Bot.printToConsole("Experience decreased by " + (stats.experience - me.getStat(13)), 9);
DataFile.updateStats("deaths");
D2Bot.updateDeaths();
}
DataFile.updateStats(["experience", "name"]);
// Load threads
if (getScript("D2BotSoloPlay.dbj")) {
if (!isIncluded("SoloPlay/Tools/Developer.js")) {
include("SoloPlay/Tools/Developer.js");
}
if (!isIncluded("SoloPlay/Tools/Tracker.js")) {
include("SoloPlay/Tools/Tracker.js");
}
if (!isIncluded("libs/SoloPlay/Functions/Globals.js")) {
include("libs/SoloPlay/Functions/Globals.js");
SetUp.include();
}
load("libs/SoloPlay/Tools/ToolsThread.js");
load("libs/SoloPlay/Tools/EventThread.js");
if (Config.TownCheck || Config.TownHP || Config.TownMP) {
load("libs/SoloPlay/Tools/TownChicken.js");
}
} else {
load("tools/ToolsThread.js");
if (Config.TownCheck || Config.TownHP || Config.TownMP) {
load("tools/TownChicken.js");
}
}
if (Config.PublicMode) {
if (Config.PublicMode === true) {
require('libs/modules/SimpleParty');
} else {
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();
if (Config.ClearInvOnStart) {
Town.clearInventory();
}
//Pickit.pickItems();
}
me.automap = Config.AutoMap;
// Next game = drop keys
if (TorchSystem.keyCheck()) {
scriptBroadcast("torch");
}
// Auto skill and stat
if (Config.AutoSkill.Enabled && include("common/AutoSkill.js")) {
AutoSkill.init(Config.AutoSkill.Build, Config.AutoSkill.Save);
}
if (Config.AutoStat.Enabled && include("common/AutoStat.js")) {
AutoStat.init(Config.AutoStat.Build, Config.AutoStat.Save, Config.AutoStat.BlockChance, Config.AutoStat.UseBulk);
}
// 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);
}
}
DataFile.updateStats("gold");
if (sojPause) {
try {
Town.goToTown();
Town.doChores();
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) {
switch (typeof Config.LastMessage) {
case "string":
say(Config.LastMessage.replace("$nextgame", DataFile.getStats().nextGame, "i"));
break;
case "object":
for (i = 0; i < Config.LastMessage.length; i += 1) {
say(Config.LastMessage[i].replace("$nextgame", DataFile.getStats().nextGame, "i"));
}
break;
}
}
if (AutoMule.muleCheck()) {
scriptBroadcast("mule");
}
// Anni handler. Mule Anni if it's in unlocked space and profile is set to mule torch/anni.
anni = me.findItem(603, 0, -1, 7);
if (anni && !Storage.Inventory.IsLocked(anni, Config.Inventory) && AutoMule.getInfo() && AutoMule.getInfo().hasOwnProperty("torchMuleInfo")) {
scriptBroadcast("muleAnni");
}
if (CraftingSystem.checkFullSets()) {
scriptBroadcast("crafting");
}
if (TorchSystem.keyCheck()) {
scriptBroadcast("torch");
}
scriptBroadcast("quit");
return true;
}