blob: 7b19355b74d1fc27932b6e381919edd914856185 (
plain)
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
|
/** @param {NS} ns */
export async function main(ns) {
// What server will be targeted?
let target = ns.args[0];
if (target === undefined) {
target = "iron-gym";
} else if (target == "help") {
ns.tprint("\n1st arg is target server to hack.\n2nd arg is boolean to enable debug Logs.\n");
ns.exit();
}
let debug = ns.args[1];
if (debug == false) {
ns.disablelog("ALL");
}
//How much money does target have?
const moneyThresh = ns.getServerMaxMoney(target);
// When do we start hacking?
const securityThresh = ns.getServerMinSecurityLevel(target);
// Infinite loop that continously hacks/grows/weakens the target server
while (true) {
if (ns.getServerSecurityLevel(target) > (securityThresh + 2)) {
// If the server's security level is above our threshold, weaken it
await ns.weaken(target);
} else if (ns.getServerMoneyAvailable(target) < moneyThresh) {
// If the server's money is less than our threshold, grow it
await ns.grow(target);
} else {
// Otherwise, hack it
await ns.hack(target);
}
}
}
// hacks a server endlessly
|