-
Notifications
You must be signed in to change notification settings - Fork 0
/
exec-script-server.js
118 lines (110 loc) · 2.42 KB
/
exec-script-server.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
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
/** @param {NS} ns **/
export async function main(ns) {
const state = ns.args[0];
let servers;
if (state != "small" && state != "mid" && state != "big") {
return ns.tprint("Wrong state");
}
if (state == "small") {
servers = [
"joesguns",
"nectar-net",
"hong-fang-tea",
"harakiri-sushi",
"neo-net",
"zer0",
"max-hardware",
"iron-gym",
"phantasy",
"silver-helix",
"omega-net",
"crush-fitness",
"johnson-ortho",
"the-hub",
"comptek",
"netlink",
"rothman-uni",
"catalyst",
"aevum-police",
"summit-uni",
"rho-construction",
"millenium-fitness",
"alpha-ent",
"syscore",
"lexo-corp",
];
}
if (state == "mid") {
servers = [
"zb-institute",
"snap-fitness",
"zb-def",
"unitalife",
"nova-med",
"solaris",
"applied-energetics",
"zeus-med",
"global-pharm",
"galactic-cyber",
"microdyne",
"titan-labs",
"vitalife",
"deltaone",
"univ-energy",
"helios",
"aerocorp",
"icarus",
"taiyang-digital",
"infocomm",
"omnia",
"defcomm",
"stormtech",
"omnitek",
"powerhouse-fitness",
];
}
if (state == "big") {
servers = [
"fulcrumtech",
"kuai-gong",
"4sigma",
"omnitek",
"megacorp",
"ecorp",
"icarus",
"nwo",
"stormtech",
"global-pharm",
"galactic-cyber",
"microdyne",
"univ-energy",
"zb-institute",
"nova-med",
"blade",
"unitalife",
"zeus-med",
"solaris",
"taiyang-digital",
"titan-labs",
"vitalife",
"helios",
"b-and-a",
"netlink",
];
}
const hckScript = "hack.js";
const wknScript = "weaken.js";
const hckScriptRam = ns.getScriptRam("hack.js");
const wknScriptRam = ns.getScriptRam("weaken.js");
for (let i = 1; i <= servers.length; i++) {
const serverName = "p" + i;
if (ns.serverExists(serverName)) {
const target = servers[i - 1];
const serverRam = ns.getServerMaxRam(serverName);
const totalHckThread = Math.round(serverRam / 2 / hckScriptRam);
const totalWknThread = Math.round(serverRam / 2 / wknScriptRam) - 1;
ns.exec(hckScript, serverName, totalHckThread, target);
ns.exec(wknScript, serverName, totalWknThread, target);
}
}
}