Created
December 30, 2021 21:34
-
-
Save benzittlau/8c3c1a857514a4e872c5d67143e4b363 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {NS} ns | |
*/ | |
export async function main(ns) { | |
ns.print("Running hacking script..."); | |
var target; securityTreshold; moneyTreshold | |
// Identify the server to attempt to hack | |
var target = ns.args[0]; | |
// Set the thresholds based on the server configuration | |
var securityTreshold = ns.args[1] || ns.getServerMinSecurityLevel(target) + 5; | |
var moneyTreshold = ns.args[2] || ns.getServerMaxMoney(target) * 0.75; | |
ns.print('Hacking "' + target + '" with thresholds: security:' + securityTreshold + ', money:' + moneyTreshold + '.'); | |
while (true) { | |
if (securityTreshold < ns.getServerSecurityLevel(target)) { | |
await ns.weaken(target); | |
} | |
else if (moneyTreshold > ns.getServerMoneyAvailable(target)) { | |
await ns.grow(target); | |
} | |
else { | |
await ns.hack(target); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment