-
Notifications
You must be signed in to change notification settings - Fork 21
/
D2BotSoloPlay.dbj
147 lines (119 loc) · 4.73 KB
/
D2BotSoloPlay.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
/**
* @filename D2BotSoloPlay.dbj
* @author theBGuy
* @desc Entry script for SoloPlay leveling system
*
*
* @typedef {import("./sdk/globals")}
* @typedef {import("./libs/SoloPlay/globals")}
*/
// No touchy!
include("critical.js"); // required
// D2BotSoloPlay specific settings - for global settings see libs/starter/StarterConfig.js
Starter.Config.InvalidPasswordDelay = 10; // Minutes to wait after getting Invalid Password message
Starter.Config.GameDoesNotExistTimeout = 600; // Seconds to wait before cancelling the 'Game does not exist.' screen
Starter.Config.DelayBeforeLogin = rand(5, 25); // Seconds to wait before logging in
Starter.Config.VersionErrorDelay = rand(5, 30); // Seconds to wait after 'unable to identify version' message
// Global Account Settings.
Starter.Config.GlobalAccount = ""; // Set value for a global account. (MAX Characters 12 plus AccountSuffixLength)
Starter.Config.AccountSuffixLength = 3; // Set Global Account value for random numbers at the end of the name. (Minimum suffix 3)
Starter.Config.GlobalAccountPassword = ""; // Set value for a global password for account generation.
// Override default values for StarterConfig under here by following format
// Starter.Config.ValueToChange = value; // Example: Starter.Config.MinGameTime = 500; // changes MinGameTime to 500 seconds
// Profile().type === sdk.game.profiletype.SinglePlayer && (Starter.Config.CrashDelay = 2);
/**
* @todo
* - re-structure to use datafile for login info instead of writing to d2bot#
* - need to hanlde single player and online logging in
* - need to handle someone using a premade account
*/
// the only things we really need from these are their oog checks
includeSystemLibs();
// solo specific
include("SoloPlay/Tools/Developer.js");
include("SoloPlay/Tools/CharData.js");
include("SoloPlay/Tools/Tracker.js");
include("SoloPlay/Tools/OOGOverrides.js");
// is this needed? soloplay doesn't run in default.dbj anymore
include("SoloPlay/Functions/ConfigOverrides.js");
if (typeof Starter.AdvancedConfig[me.profile] === "object") {
Object.assign(Starter.Config, Starter.AdvancedConfig[me.profile]);
}
delete Starter.AdvancedConfig;
// initialize data files
if (!FileTools.exists("data/" + me.profile + ".json") && DataFile.create()) {
Starter.firstRun = true;
}
!FileTools.exists(CharData.filePath) && CharData.create();
!FileTools.exists(CharData.login.filePath) && CharData.login.create();
Developer.logPerformance && Tracker.initialize();
function main () {
debugLog(me.profile);
addEventListener("copydata", Starter.receiveCopyData);
addEventListener("scriptmsg", Starter.scriptMsgEvent);
let oogTick = getTickCount();
while (!Starter.handle) {
delay(3);
}
DataFile.updateStats("handle", Starter.handle);
D2Bot.handle = Starter.handle;
delay(500);
load("threads/heartbeat.js");
if (Profile().type === sdk.game.profiletype.TcpIpJoin) {
D2Bot.printToConsole("TcpJoin is unsupported.");
D2Bot.stop();
}
Starter.gameCount = (DataFile.getStats().runs + 1 || 1);
while (!Object.keys(Starter.gameInfo).length) {
delay(rand(200, 1500));
D2Bot.requestGameInfo();
delay(500);
}
if (Starter.gameInfo.error) {
ControlAction.timeoutDelay("Crash Delay", Starter.Config.CrashDelay * 1e3);
Starter.BNET && D2Bot.updateRuns();
}
DataFile.updateStats("debugInfo", JSON.stringify({ currScript: "none", area: "out of game" }));
while (!Object.keys(Starter.profileInfo).length) {
delay(rand(200, 1500));
D2Bot.getProfile();
delay(500);
}
while (true) {
// returns true before actually in game so we can't only use this check
while (me.ingame) {
// returns false when switching acts so we can't use while
if (me.gameReady) {
Starter.isUp = "yes";
if (!Starter.inGame) {
Starter.gameStart = getTickCount();
Starter.lastGameStatus = "ingame";
Starter.inGame = true;
DataFile.updateStats("runs", Starter.gameCount);
DataFile.updateStats("ingameTick");
Developer.logPerformance && Tracker.update((getTickCount() - oogTick));
oogTick = 0;
D2Bot.updateStatus("In-Game :: Initializing threads...");
} else {
// Tracker
if (Developer.logPerformance) {
if (getTickCount() - Tracker.tick > Time.minutes(3)) {
Tracker.tick = getTickCount();
try {
Tracker.update();
} catch (e) {
console.error(e);
}
}
}
}
}
delay(1000);
}
// was in game so start recording oog time
Starter.inGame && oogTick === 0 && (oogTick = getTickCount());
Starter.isUp = "no";
LocationAction.run();
delay(1000);
}
}