-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustLoopWeaken.ts
More file actions
34 lines (33 loc) · 1.07 KB
/
justLoopWeaken.ts
File metadata and controls
34 lines (33 loc) · 1.07 KB
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
import {BitBurner as NS} from "Bitburner";
export async function main(ns: NS) {
let host = ns.args[0];
let target = ns.args[1];
if (host == "all")
for (let h = 0; h < ns.getPurchasedServers().length; h++) {
host = "pserv-" + h;
await runWeakenLoop(ns, host, target);
}
else if(host == "free"){
for (let h = 0; h < ns.getPurchasedServers().length; h++) {
host = "pserv-" + h;
await runWeakenLoop(ns, host, target, true);
}
}
else
await runWeakenLoop(ns,host,target);
}
async function runWeakenLoop(ns: NS, host, target, requireFree = false)
{
ns.tprint(`Weaken running on Host: ${host} target: ${target}`);
let ram = ns.getServerRam(host);
if(requireFree && (ram[1]!=0))
return;
let availableRam = ram[0] - ram[1];
let thr = Math.floor((availableRam) / 1.75);
ns.tprint(`${thr} threads`);
if(thr == 0)
return;
ns.scp("loopweaken.js", host);
//@ts-ignore
await ns.exec("loopweaken.js", host, thr, { target: target, threads: thr });
}