Inspired by this basic auto farm, automate all servers with improved performances.
Perceber
Observação: Require at least 8.1G on your ‘home’ servidor.
Create a ‘runner.js’ file on your home server, paste the content below on it then run it.
nano runner.js
Por padrão, this script will not kill all other services running on each server. You can enforce it by running
run runner.js --kill
This script will use all your personally owned servers. The more you have, the more it’ll be efficient.
Roteiro
/** @param {NS} ns **/ export async function main(ns) { ns.disableLog('ALL'); ns.enableLog('print'); var options = ns.flags([ ['kill', falso], ['hack', falso], ['grow', falso], ['weaken', falso], ['waitTime', 10], ['help', falso] ]); se (opções['help']) { ns.tail(); ns.print(`Auto-script, opções: * --matar: Force kill every other process on every servers * --hack some-script.js: Replace hack script with some-script.js one * --grow some-script.js: Replace grow script with some-script.js one * --weaken some-script.js: Replace weaken script with some-script.js one * --waitTime 10: Wait time between two servers in ms, must be higher than 1 * --ajuda: show this message `); retornar; } // Creating scripts var hack = options['hack'] || '/temp/hack.js', grow = options['grow'] || '/temp/grow.js', weaken = options['weaken'] || '/temp/weaken.js'; se (!opções['hack']) { await ns.write(hack, ` /** @param {NS} ns **/ export async function main(ns) { await ns.hack(ns.args[0]); } `, 'w'); } se (!opções['grow']) { await ns.write(grow, ` /** @param {NS} ns **/ export async function main(ns) { await ns.grow(ns.args[0]); } `, 'w'); } se (!opções['weaken']) { await ns.write(weaken, ` /** @param {NS} ns **/ export async function main(ns) { await ns.weaken(ns.args[0]); } `, 'w'); } // Divs variables declarations var serverList = ns.scan('home'), serverCount = [serverList.length, 0], softwares = [0, 0, 0, 0, 0, 0], softwaresCount = 0, scanLevel = 2, index = 0, notProxyList = [], proxyList = ['home'], hackables = [], growables = [], weakenables = [], linked, alvo, proxyTarget, depth = 0, checked = 0, hackType; // Checking softwares if (ns.fileExists('BruteSSH.exe')) { softwares[0] = 1; softwaresCount++; }; se (ns.fileExists('FTPCrack.exe')) { softwares[1] = 1; softwaresCount++; }; se (ns.fileExists('relaySMTP.exe')) { softwares[2] = 1; softwaresCount++; }; se (ns.fileExists('HTTPWorm.exe')) { softwares[3] = 1; softwaresCount++; }; se (ns.fileExists('SQLInject.exe')) { softwares[4] = 1; softwaresCount++; }; se (ns.fileExists('DeepscanV1.exe')) { scanLevel += 2; }; se (ns.fileExists('DeepscanV2.exe')) { scanLevel += 5; }; ns.print('/---/ SEARCHING \\---\\\n-- Default --\n > ' + serverList.join('\n > ') + '\n>- Scan Limit: L' + [scanLevel + 1] + ' -<'); enquanto (index <= serverCount[profundidade] - 1 && profundidade < scanLevel) { linked = ns.scan(serverList[checked]); checked++; para (let index = 0; index <= linked.length - 1; index++) { target = linked[index]; se (alvo != 'home' && !serverList.includes(alvo)) { serverList.push(alvo); ns.print('L' + [profundidade + 2] + ' > ' + alvo); serverCount[profundidade + 1]++; } } se (index == serverCount[profundidade] - 1) { index = 0; depth++; serverCount.push(0); } outro { index++; }; } ns.print('/-------/ CHECKING \\-------\\'); para (let index = 0; index <= serverList.length - 1; index++) { target = serverList[index]; se (ns.getPurchasedServers().includes(alvo)) { await ns.scp([hack, grow, weaken], 'home', alvo); se (opções['kill']) { ns.killall(alvo); } proxyList.push(alvo); ns.print(' >>> PROXY ' + alvo); } senão se (ns.getServerNumPortsRequired(alvo) > softwaresCount) { ns.print(' >X< SOFTWARE ' + alvo); } senão se (ns.getServerMaxRam(alvo) < 2) { ns.print(' >X< NO RAM ' + alvo); } senão se (ns.getHackingLevel() < ns.getServerRequiredHackingLevel(alvo)) { ns.print(' >X< SKILL ' + alvo); } outro { se (softwares[0]) { ns.brutessh(alvo); }; se (softwares[1]) { ns.ftpcrack(alvo); }; se (softwares[2]) { ns.relaysmtp(alvo); }; se (softwares[3]) { ns.httpworm(alvo); }; se (softwares[4]) { ns.sqlinject(alvo); }; ns.nuke(alvo); await ns.scp([hack, grow, weaken], 'home', alvo); se (opções['kill']) { ns.killall(alvo); } se (ns.getServerMoneyAvailable(alvo) == 0) { ns.print(' >X< NO MONEY ' + alvo); proxyList.push(alvo); ns.print(' >>> PROXY ' + alvo); } outro { notProxyList.push(alvo); ns.print(' >>> VALID ' + alvo); } } } se (notProxyList.length > 0) { ns.print('/------------/ HACKING \\------------\\'); enquanto (verdadeiro) { hackables = []; growables = []; weakenables = []; para (target of notProxyList) { // Priority for targets: weaken, then grow, then hack if (ns.getServerSecurityLevel(alvo) > ns.getServerMinSecurityLevel(alvo) + 5) { hackType = weaken; weakenables.push(alvo); } senão se (ns.getServerMoneyAvailable(alvo) < ns.getServerMaxMoney(alvo) * 0.80) { hackType = grow; growables.push(alvo); } outro { hackType = hack; hackables.push(alvo); } se ((ns.getServerMaxRam(alvo) - ns.getServerUsedRam(alvo)) > ns.getScriptRam(hackType)) { ns.exec(hackType, alvo, Math.floor((ns.getServerMaxRam(alvo) - ns.getServerUsedRam(alvo)) / ns.getScriptRam(hackType)), alvo); ns.print('|||||||||| ' + hackType + ' --> ' + alvo + ' ||||||||||'); } } para (target of proxyList) { // Priority for proxies: hack, then grow, then weaken if (hackables.length > 0) { proxyTarget = hackables[Math.floor(Math.random() * hackables.length)]; hackType = hack; } senão se (growables.length > 0) { proxyTarget = growables[Math.floor(Math.random() * growables.length)]; hackType = grow; } senão se (weakenables.length > 0) { proxyTarget = weakenables[Math.floor(Math.random() * weakenables.length)]; hackType = weaken; } se ((ns.getServerMaxRam(alvo) - ns.getServerUsedRam(alvo)) > ns.getScriptRam(hackType)) { ns.exec(hackType, alvo, Math.floor((ns.getServerMaxRam(alvo) - ns.getServerUsedRam(alvo)) / ns.getScriptRam(hackType)), proxyTarget); ns.print('|||||||||| proxy --> ' + alvo + ' --> ' + hackType + ' --> ' + proxyTarget + ' ||||||||||'); } } // Await n ms between each servers to avoid issue with the infinite loop await ns.sleep(opções['waitTime']); } } outro { ns.print('Error, no server available.'); } }
Advanced Usage
You can see all options in-game with
run runner.js --help
You are allowed to use your own hack, grow, weaken script. You can also customize the waiting time between each server. Aviso. Always use more that 1ms or you’ll freeze your game.
Isso é tudo o que estamos compartilhando hoje para isso Bitburner guia. Este guia foi originalmente criado e escrito por Nekotorep. Caso não atualizemos este guia, você pode encontrar a atualização mais recente seguindo este link.
As of release 2.0.1, the last two arguments of the scp function need to be flipped. It won’t throw errors, but you’ll find that it will only be using the home computer to run the grow/weaken/hack cycle.