Skip to content

Commit

Permalink
Improved support for --no-tail-windows mode
Browse files Browse the repository at this point in the history
  • Loading branch information
alainbryden committed Nov 24, 2024
1 parent 1da0f5e commit fd7377f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
3 changes: 3 additions & 0 deletions autopilot.js
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ export async function main(ns) {
if ((13 in unlockedSFs) && !stanekLaunched && !stanekRunning && installedAugmentations.includes(augStanek)) {
stanekLaunched = true; // Once we've know we've launched stanek once, we never have to again this reset.
const stanekArgs = ["--on-completion-script", getFilePath('daemon.js')]
if (options['no-tail-windows']) stanekArgs.push('--no-tail'); // Relay the option to suppress tail windows
if (daemonArgs.length >= 0) stanekArgs.push("--on-completion-script-args", JSON.stringify(daemonArgs)); // Pass in all the args we wanted to run daemon.js with
launchScriptHelper(ns, 'stanek.js', stanekArgs);
stanekRunning = true;
Expand Down Expand Up @@ -592,6 +593,8 @@ export async function main(ns) {
"--fast-crimes-only", // Essentially means we do mug until we can do homicide, then stick to homicide
"--get-invited-to-every-faction" // Join factions even we have all their augs. Good for having NeuroFlux providers
];
// Relay the options to suppress tail windows and ignore bladeburner
if (options['no-tail-windows']) workForFactionsArgs.push('--no-tail-windows');
if (options['disable-bladeburner']) workForFactionsArgs.push("--no-bladeburner-check")
// The following args are ideal when running 'work-for-factions.js' to rush unlocking gangs (earn karma)
const rushGangsArgs = workForFactionsArgs.concat(...[ // Everything above, plus...
Expand Down
15 changes: 8 additions & 7 deletions work-for-factions.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const argsSchema = [
['skip', []], // Don't work for these factions
['o', false], // Immediately grind company factions for rep after getting their invite, rather than first getting all company invites we can
['desired-stats', []], // Factions will be removed from our 'early-faction-order' once all augs with these stats have been bought out
['no-tail-windows', false], // Set to true to prevent the default behaviour of opening a tail window any time we initiate focused player work.
['no-focus', false], // Disable doing work that requires focusing (crime), and forces study/faction/company work to be non-focused (even if it means incurring a penalty)
['no-studying', false], // Disable studying.
['pay-for-studies-threshold', 200000], // Only be willing to pay for our studies if we have this much money
Expand Down Expand Up @@ -626,11 +627,11 @@ export async function crimeForKillsKarmaStats(ns, reqKills, reqKarma, reqStats,
if (await isValidInterruption(ns, currentWork)) return;
if (lastCrime) {
log(ns, `Committing Crime "${lastCrime}" Interrupted. (Now: ${crimeType ?? currentWork.type}) Restarting...`, false, 'warning');
tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep doing crime
if (!options['no-tail-windows']) tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep doing crime
}
let focusArg = shouldFocus === undefined ? true : shouldFocus; // Only undefined if running as imported function
crimeTime = await getNsDataThroughFile(ns, 'ns.singularity.commitCrime(ns.args[0], ns.args[1])', null, [crime, focusArg])
if (shouldFocus) tail(ns); // Force a tail window open when auto-criming with focus so that the user can more easily kill this script
if (shouldFocus && !options['no-tail-windows']) tail(ns); // Force a tail window open when auto-criming with focus so that the user can more easily kill this script
}
// Periodic status update with progress
if (lastCrime != crime || (Date.now() - lastStatusUpdateTime) > statusUpdateInterval) {
Expand Down Expand Up @@ -936,7 +937,7 @@ export async function workForSingleFaction(ns, factionName, forceUnlockDonations
if (await isValidInterruption(ns, currentWork)) return;
log(ns, `Work for faction ${factionName} was interrupted (Now: ${JSON.stringify(currentWork)}). Restarting...`, false, 'warning');
workAssigned = false;
tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep working
if (!options['no-tail-windows']) tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep working
}
// Periodically check again what the best faction work is (may change with stats over time)
if ((Date.now() - lastStatusUpdateTime) > statusUpdateInterval)
Expand All @@ -953,7 +954,7 @@ export async function workForSingleFaction(ns, factionName, forceUnlockDonations
if (!workAssigned) {
if (await startWorkForFaction(ns, factionName, bestFactionJob, shouldFocus)) {
workAssigned = true;
if (shouldFocus) tail(ns); // Keep a tail window open if we're stealing focus
if (shouldFocus && !options['no-tail-windows']) tail(ns); // Keep a tail window open if we're stealing focus
} else {
log(ns, `ERROR: Something went wrong, failed to start "${bestFactionJob}" work for faction "${factionName}" (Is gang faction, or not joined?)`, false, 'error');
break;
Expand Down Expand Up @@ -1205,7 +1206,7 @@ export async function workForMegacorpFactionInvite(ns, factionName, waitForInvit
if (await isValidInterruption(ns, currentWork)) return;
log(ns, `Leadership studies were interrupted. classType="${classType}" Restarting...`, false, 'warning');
isStudying = false; // If something external has interrupted our studies, take note
tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep studying
if (!options['no-tail-windows']) tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep studying
}
if (!isStudying) { // Study at ZB university if CHA is the limiter.
if (await studyForCharisma(ns, shouldFocus))
Expand Down Expand Up @@ -1245,11 +1246,11 @@ export async function workForMegacorpFactionInvite(ns, factionName, waitForInvit
if (isWorking) { // Log a warning if we discovered that work we previously began was disrupted
log(ns, `Work for company ${companyName} was interrupted (Now: ${JSON.stringify(currentWork)}). Restarting...`, false, 'warning');
isWorking = false;
tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep working
if (!options['no-tail-windows']) tail(ns); // Force a tail window open to help the user kill this script if they accidentally closed the tail window and don't want to keep working
}
if (await getNsDataThroughFile(ns, `ns.singularity.workForCompany(ns.args[0], ns.args[1])`, null, [companyName, shouldFocus])) {
isWorking = true;
if (shouldFocus) tail(ns); // Keep a tail window open if we're stealing focus
if (shouldFocus && !options['no-tail-windows']) tail(ns); // Keep a tail window open if we're stealing focus
} else {
log(ns, `Something went wrong, failed to start working for company "${companyName}".`, false, 'error');
break;
Expand Down

0 comments on commit fd7377f

Please sign in to comment.