summaryrefslogtreecommitdiff
path: root/hack.js
diff options
context:
space:
mode:
authorAlmightyMiau <almightymeow612@gmail.com>2024-11-13 10:56:53 -0800
committerAlmightyMiau <almightymeow612@gmail.com>2024-11-13 10:56:53 -0800
commit40843e35434d56e883655e4377994ac76746b184 (patch)
tree786c3acc109b4add11c88ca58a534fd19d4e77cb /hack.js
parent1ca00b3b73a9699e41f81e154cea32934c16de03 (diff)
Organized scripts into folders
Diffstat (limited to 'hack.js')
-rw-r--r--hack.js40
1 files changed, 40 insertions, 0 deletions
diff --git a/hack.js b/hack.js
new file mode 100644
index 0000000..7b19355
--- /dev/null
+++ b/hack.js
@@ -0,0 +1,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
+