-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgrow.js
76 lines (64 loc) · 1.69 KB
/
grow.js
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
/**Grow() script.
* This will report via ports to the coordinator which has 0 RAM cost!
* Requires the hack-daemon!
* Written By: Zharay
* URL: https://github.com/Zharay/BitburnerBotnet
**/
/** @param {NS} ns */
export async function main(ns) {
var target = "";
var threshModifier = 0.75;
var host = "";
var threads = 0;
var ram = 0;
var security = 0;
if (ns.args.length) {
target = ns.args[0];
ns.print("Target: " + target);
} else {
ns.print("ERROR: No target set!");
return;
}
if (ns.args.length > 1) {
threshModifier = parseFloat(ns.args[1]);
if (threshModifier <= 0) {
ns.print("ERROR: Threshold is set to [" + threshModifier + "]");
return;
}
}
if (ns.args.length > 2) {
host = ns.args[2];
ns.print("Host: " + host);
}
if (ns.args.length > 3) {
threads = ns.args[3];
ns.print("Threads: " + threads);
}
if (ns.args.length > 4) {
ram = ns.args[4];
ns.print("RAM: " + ram);
}
if (ns.args.length > 5) {
security = ns.args[5];
ns.print("Security Risk: " + security);
}
var task = {"target" : target, "host" : host, "task" : "grow", "done" : false, "threads" : threads, "ram" : ram, "security" : security};
if (host != "EXP") {
ns.print("Reporting of incoming growth...")
await ns.tryWritePort(13, JSON.stringify(task));
} else {
ns.print("Reporting EXP growth...");
await ns.tryWritePort(14, JSON.stringify(task));
}
ns.print("Growing money...");
await ns.grow(target);
task.done = true;
task.security *= -1;
if (host != "EXP") {
ns.print("Reporting of growth completion...")
await ns.tryWritePort(13, JSON.stringify(task));
} else {
ns.print("Reporting EXP growth...");
await ns.tryWritePort(14, JSON.stringify(task));
}
}