import { NS } from '@ns'; export const main = async (ns: NS) => { if (ns.args.length !== 1) { ns.tprint('Usage: run super.js [target]'); return; } const target = ns.args[0].toString(); ns.tprint('Target selected: ' + target); const maxMoneyThresh = ns.getServerMaxMoney(target); const minSecurityThresh = ns.getServerMinSecurityLevel(target); // get root access ns.nuke(target); // main loop that continously hacks/grows/weakens the target server while (true) { if (ns.getServerSecurityLevel(target) > minSecurityThresh) { // If the server's security level is above our threshold, weaken it await ns.weaken(target); } else if (ns.getServerMoneyAvailable(target) < maxMoneyThresh) { // If the server's money is less than our threshold, grow it await ns.grow(target); } else { // Otherwise, hack it await ns.hack(target); } } };