Skip to content

Commit

Permalink
Fix #399 & Fix #382
Browse files Browse the repository at this point in the history
- Go doesn't need SF14 to be played (this was actually quietly fixed back in 6e6b241, possibly by accident
- Go is now owned by daemon.js and launched asap - autopilot doesn't touch it (and has no reason to)
  • Loading branch information
alainbryden committed Oct 22, 2024
1 parent 61266ac commit abd428b
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
8 changes: 1 addition & 7 deletions autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ const argsSchema = [ // The set of all command line arguments
['disable-wait-for-4s', false], // If true, will doesn't wait for the 4S Tix API to be acquired under any circumstantes
['disable-rush-gangs', false], // Set to true to disable focusing work-for-faction on Karma until gangs are unlocked
['disable-casino', false], // Set to true to disable running the casino.js script automatically
['disable-go', false], // Set to true to disable the Go script
['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
['xp-mode-interval-minutes', 55], // Every time this many minutes has elapsed, toggle daemon.js to runing in --xp-only mode, which prioritizes earning hack-exp rather than money
Expand Down Expand Up @@ -105,7 +104,7 @@ export async function main(ns) {

log(ns, "INFO: Auto-pilot engaged...", true, 'info');
// The game does not allow boolean flags to be turned "off" via command line, only on. Since this gets saved, notify the user about how they can turn it off.
const flagsSet = ['disable-auto-destroy-bn', 'disable-bladeburner', 'disable-wait-for-4s', 'disable-rush-gangs', 'disable-go'].filter(f => options[f]);
const flagsSet = ['disable-auto-destroy-bn', 'disable-bladeburner', 'disable-wait-for-4s', 'disable-rush-gangs'].filter(f => options[f]);
for (const flag of flagsSet)
log(ns, `WARNING: You have previously enabled the flag "--${flag}". Because of the way this script saves its run settings, the ` +
`only way to now turn this back off will be to manually edit or delete the file ${ns.getScriptName()}.config.txt`, true);
Expand Down Expand Up @@ -563,11 +562,6 @@ 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);
}

// Launch go.js. If we have SF14.2 or higher, we can use the cheats API
if (!options['disable-go'] && !findScript('go.js') && homeRam >= 64) {
launchScriptHelper(ns, 'go.js', ['--silent']);
}
}

/** Logic to steal 10b from the casino
Expand Down
16 changes: 9 additions & 7 deletions daemon.js
Original file line number Diff line number Diff line change
Expand Up @@ -323,9 +323,10 @@ async function startup(ns) {
// Set up "asynchronous helpers" - standalone scripts to manage certain aspacts of the game. daemon.js launches each of these once when ready (but not again if they are shut down)
const reqRam = (ram) => homeServer.totalRam(/*ignoreReservedRam:*/true) >= ram; // To avoid wasting precious RAM, many scripts don't launch unless we have more than a certain amount
asynchronousHelpers = [
{ name: "stats.js", shouldRun: () => reqRam(64) }, // Adds stats not usually in the HUD
{ name: "stats.js", shouldRun: () => reqRam(64) }, // Adds stats not usually in the HUD (nice to have)
{ name: "go.js", shouldRun: () => reqRam(32), minRamReq: 20.2, args: openTailWindows ? [] : ['--silent'] }, // Play go.js (various multipliers, but large dynamic ram requirements)
{ name: "stockmaster.js", shouldRun: () => reqRam(64), args: openTailWindows ? ["--show-market-summary"] : [], tail: openTailWindows }, // Start our stockmaster
{ name: "hacknet-upgrade-manager.js", shouldRun: () => reqRam(64), args: ["-c", "--max-payoff-time", "1h"] }, // One-time kickstart of hash income by buying everything with up to 1h payoff time immediately
{ name: "hacknet-upgrade-manager.js", shouldRun: () => reqRam(32), args: ["-c", "--max-payoff-time", "1h"] }, // One-time kickstart of hash income by buying everything with up to 1h payoff time immediately
{ name: "spend-hacknet-hashes.js", args: [], shouldRun: () => reqRam(64) && 9 in dictSourceFiles }, // Always have this running to make sure hashes aren't wasted
{ name: "sleeve.js", tail: openTailWindows, shouldRun: () => reqRam(64) && 10 in dictSourceFiles }, // Script to create manage our sleeves for us
{ name: "gangs.js", tail: openTailWindows, shouldRun: () => reqRam(64) && 2 in dictSourceFiles }, // Script to create manage our gang for us
Expand All @@ -338,6 +339,7 @@ async function startup(ns) {
shouldRun: () => !options['disable-script'].includes('bladeburner.js') && reqRam(64) && 7 in dictSourceFiles && !isInBn8
},
];

// Fix the file path for each tool if this script was cloned to a sub-directory
asynchronousHelpers.forEach(helper => helper.name = getFilePath(helper.name));
// Add any additional scripts to be run provided by --run-script arguments
Expand Down Expand Up @@ -419,11 +421,6 @@ async function startup(ns) {
await kickstartHackXp(ns);
}

// For early players, provide a hint to buy more home RAM asap:
if (!(4 in dictSourceFiles) && !reqRam(64))
log(ns, `HINT: Daemon.js can do more if you have more Home Ram. ` +
`Head to [alpha ent.] and purchase at 64 GB as soon as possible!`, true, 'info');

// Start the main targetting loop
await doTargetingLoop(ns);
}
Expand Down Expand Up @@ -541,6 +538,11 @@ async function runPeriodicScripts(ns) {
await runCommand(ns, `0; if(ns.hacknet.spendHashes("Sell for Money")) ns.toast('Sold 4 hashes for \$1M', 'success')`, '/Temp/sell-hashes-for-money.js');
}
}
// For early players, provide a hint to buy more home RAM asap:
if (!(4 in dictSourceFiles) && !homeServer.totalRam(true) < 64)
log(ns, `INFO: Reminder: Daemon.js can do a lot more if you have more Home RAM. Right now, you must buy this yourself.` +
`\nHead to the "City", visit [alpha ent.] (or other Tech store), and purchase at least 64 GB as soon as possible!` +
`\nAlso be sure to purchase TOR and run "buy -a" from the terminal until you own all hack tools.`, true, 'info');
}

// Helper that gets the either invokes a function that returns a value, or returns the value as-is if it is not a function.
Expand Down

0 comments on commit abd428b

Please sign in to comment.