From 35777f3c367b5d200e38695ba5e38aaaaea1427e Mon Sep 17 00:00:00 2001 From: samohtGTO <71775252+samohtGTO@users.noreply.github.com> Date: Fri, 19 May 2023 12:42:11 +0200 Subject: [PATCH 1/3] suggestion: custom scripts helper #292 --- autopilot.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/autopilot.js b/autopilot.js index 89dd1d3e..84aae672 100644 --- a/autopilot.js +++ b/autopilot.js @@ -30,6 +30,7 @@ const argsSchema = [ // The set of all command line arguments ['disable-casino', false], // Set to true to disable running the casino.js script automatically ['on-completion-script', null], // Spawn this script when we defeat the bitnode ['on-completion-script-args', []], // Optional args to pass to the script when we defeat the bitnode + ['run-script', []], // Spawns a script if it isnt running already in the main loop, example [{"name": ,"arg": [arguments] "bitnode": [bitnode] , "ram": }] ]; export function autocomplete(data, args) { data.flags(argsSchema); @@ -423,6 +424,22 @@ async function checkOnRunningScripts(ns, player) { // NOTE: Default work-for-factions behaviour is to spend hashes on coding contracts, which suits us fine launchScriptHelper(ns, 'work-for-factions.js', rushGang ? rushGangsArgs : workForFactionsArgs); } + + // TODO: add that mutiple bitnodes in the requirements work + if (options['run-script']) { + options['run-script'].forEach(script => { + if(!script.ram){ + script.ram =0 + } + if (!findScript(script.name) && script.ram<=homeRam && (script.bitnode in unlockedSFs || script.bitnode==player.bitNodeN)) { + if(script.args) { + launchScriptHelper(ns, script.name, script.args) + } else { + launchScriptHelper(ns, script.name) + } + } + }); + } } /** Logic to steal 10b from the casino From c7bb4cd073c3d31ef708acc40ee75a44143eec6b Mon Sep 17 00:00:00 2001 From: samohtGTO <71775252+samohtGTO@users.noreply.github.com> Date: Sat, 1 Jul 2023 09:38:59 +0200 Subject: [PATCH 2/3] Suggestion: hacknet ram managment #308 --- daemon.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/daemon.js b/daemon.js index 95f2930c..433dc7c5 100644 --- a/daemon.js +++ b/daemon.js @@ -33,6 +33,7 @@ const argsSchema = [ ['n', false], // Can toggle on using hacknet nodes for extra hacking ram (at the expense of hash production) ['use-hacknet-nodes', false], // Same as above (kept for backwards compatibility, but these are now called hacknet-servers) ['use-hacknet-servers', false], // Same as above, but the game recently renamed these + ['hacknet-use-ram-percentage', 0.75] ['spend-hashes-for-money-when-under', 10E6], // (Default 10m) Convert 4 hashes to money whenever we're below this amount ['disable-spend-hashes', false], // An easy way to set the above to a very large negative number, thus never spending hashes for Money ['silent-misfires', false], // Instruct remote scripts not to alert when they misfire @@ -118,6 +119,7 @@ let xpOnly = false; // "-x" command line arg - focus on a strategy that produces let verbose = false; // "-v" command line arg - Detailed logs about batch scheduling / tuning let runOnce = false; // "-o" command line arg - Good for debugging, run the main targettomg loop once then stop let useHacknetNodes = false; // "-n" command line arg - Can toggle using hacknet nodes for extra hacking ram +let hacknetUsePercentage = 0.75 // How much ram percentage ram from the hacknet is getting used. let loopingMode = false; let recoveryThreadPadding = 1; // How many multiples to increase the weaken/grow threads to recovery from misfires automatically (useful when RAM is abundant and timings are tight) @@ -250,6 +252,7 @@ export async function main(ns) { stockMode = (options.s || options['stock-manipulation'] || options['stock-manipulation-focus']) && !options['disable-stock-manipulation']; stockFocus = options['stock-manipulation-focus'] && !options['disable-stock-manipulation']; useHacknetNodes = options.n || options['use-hacknet-nodes'] || options['use-hacknet-servers']; + hacknetUsePercentage = Math.max(options['hacknet-use-ram-percentage']) verbose = options.v || options['verbose']; runOnce = options.o || options['run-once']; loopingMode = options['looping-mode']; @@ -1008,8 +1011,11 @@ class Server { isHost() { return this.name == daemonHost; } totalRam() { let maxRam = this.ns.getServerMaxRam(this.name); - if (this.name == "home") + if (this.name == "home") { maxRam = Math.max(0, maxRam - homeReservedRam); // Complete HACK: but for most planning purposes, we want to pretend home has less ram to leave room for temp scripts to run + } else if (this.name.startsWith('hacknet-server-')) { + maxRam = maxRam * hacknetUsePercentage; + } return maxRam; } usedRam() { return this.ns.getServerUsedRam(this.name); } From cc3fd4c86ae5e3a10cea2a698ce6013bdc428045 Mon Sep 17 00:00:00 2001 From: samohtGTO <71775252+samohtGTO@users.noreply.github.com> Date: Sat, 1 Jul 2023 09:41:18 +0200 Subject: [PATCH 3/3] forgot a , --- daemon.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/daemon.js b/daemon.js index 433dc7c5..b27a6d7f 100644 --- a/daemon.js +++ b/daemon.js @@ -33,7 +33,7 @@ const argsSchema = [ ['n', false], // Can toggle on using hacknet nodes for extra hacking ram (at the expense of hash production) ['use-hacknet-nodes', false], // Same as above (kept for backwards compatibility, but these are now called hacknet-servers) ['use-hacknet-servers', false], // Same as above, but the game recently renamed these - ['hacknet-use-ram-percentage', 0.75] + ['hacknet-use-ram-percentage', 0.75], ['spend-hashes-for-money-when-under', 10E6], // (Default 10m) Convert 4 hashes to money whenever we're below this amount ['disable-spend-hashes', false], // An easy way to set the above to a very large negative number, thus never spending hashes for Money ['silent-misfires', false], // Instruct remote scripts not to alert when they misfire