mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-22 14:12:27 +01:00
softReset now accepts a callback script like installAugmentations
This commit is contained in:
parent
486d025572
commit
cae28e2d25
@ -2054,7 +2054,7 @@ function applyAugmentation(aug, reapply=false) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function installAugmentations(cbScript=null) {
|
function installAugmentations() {
|
||||||
if (Player.queuedAugmentations.length == 0) {
|
if (Player.queuedAugmentations.length == 0) {
|
||||||
dialogBoxCreate("You have not purchased any Augmentations to install!");
|
dialogBoxCreate("You have not purchased any Augmentations to install!");
|
||||||
return false;
|
return false;
|
||||||
@ -2074,24 +2074,6 @@ function installAugmentations(cbScript=null) {
|
|||||||
"to install the following Augmentations:<br>" + augmentationList +
|
"to install the following Augmentations:<br>" + augmentationList +
|
||||||
"<br>You wake up in your home...you feel different...");
|
"<br>You wake up in your home...you feel different...");
|
||||||
prestigeAugmentation();
|
prestigeAugmentation();
|
||||||
|
|
||||||
//Run a script after prestiging
|
|
||||||
if (cbScript && isString(cbScript)) {
|
|
||||||
var home = Player.getHomeComputer();
|
|
||||||
for (const script of home.scripts) {
|
|
||||||
if (script.filename === cbScript) {
|
|
||||||
const ramUsage = script.ramUsage;
|
|
||||||
const ramAvailable = home.maxRam - home.ramUsed;
|
|
||||||
if (ramUsage > ramAvailable) {
|
|
||||||
return; // Not enough RAM
|
|
||||||
}
|
|
||||||
const runningScriptObj = new RunningScript(script, []); // No args
|
|
||||||
runningScriptObj.threads = 1; // Only 1 thread
|
|
||||||
|
|
||||||
startWorkerScript(runningScriptObj, home);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function augmentationExists(name) {
|
function augmentationExists(name) {
|
||||||
|
@ -228,19 +228,24 @@ export let CONSTANTS: IMap<any> = {
|
|||||||
|
|
||||||
LatestUpdate:
|
LatestUpdate:
|
||||||
`
|
`
|
||||||
v0.49.0 - 2021-XX-XX Source-File -1
|
v0.49.0 - 2021-03-11 Source-File -1
|
||||||
-------
|
-------
|
||||||
|
|
||||||
Source-File -1
|
Source-File -1
|
||||||
* For advanced players: The game now embraces exploits and will reward
|
* For advanced players: The game now embraces exploits and will reward
|
||||||
players for doing so.
|
players for doing so.
|
||||||
|
|
||||||
|
Gang
|
||||||
|
* ascension is less effective as the ascension multiplier goes up.
|
||||||
|
* territory gain scales with power difference.
|
||||||
|
|
||||||
Netscript
|
Netscript
|
||||||
* 'gang.getEquipmentStats' returns the stats of the equipment.
|
* 'gang.getEquipmentStats' returns the stats of the equipment.
|
||||||
* 'gang.getTaskStats' returns the stats of a task.
|
* 'gang.getTaskStats' returns the stats of a task.
|
||||||
* 'getCrimeStats' returns the stats of a crime.
|
* 'getCrimeStats' returns the stats of a crime.
|
||||||
* Crashes should now print the ns stack trace.
|
* Crashes should now print the ns stack trace.
|
||||||
* Log messages are now more consistent.
|
* Log messages are now more consistent.
|
||||||
|
* 'softReset' now accepts a callback script like 'installAugmentations'
|
||||||
|
|
||||||
Misc.
|
Misc.
|
||||||
* Minor formatting under Hacking>Active Scripts
|
* Minor formatting under Hacking>Active Scripts
|
||||||
|
@ -74,6 +74,8 @@ import {
|
|||||||
AddToAllServers,
|
AddToAllServers,
|
||||||
createUniqueRandomIp,
|
createUniqueRandomIp,
|
||||||
} from "./Server/AllServers";
|
} from "./Server/AllServers";
|
||||||
|
import { RunningScript } from "./Script/RunningScript";
|
||||||
|
import { startWorkerScript } from "./NetscriptWorker";
|
||||||
import { Server } from "./Server/Server";
|
import { Server } from "./Server/Server";
|
||||||
import {
|
import {
|
||||||
GetServerByHostname,
|
GetServerByHostname,
|
||||||
@ -529,6 +531,31 @@ function NetscriptFunctions(workerScript) {
|
|||||||
return Augmentations[name];
|
return Augmentations[name];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const runAfterReset = function(cbScript=null) {
|
||||||
|
//Run a script after reset
|
||||||
|
console.log(cbScript);
|
||||||
|
if (cbScript && isString(cbScript)) {
|
||||||
|
console.log('here');
|
||||||
|
const home = Player.getHomeComputer();
|
||||||
|
for (const script of home.scripts) {
|
||||||
|
console.log('here 2'+script);
|
||||||
|
if (script.filename === cbScript) {
|
||||||
|
console.log('here 3');
|
||||||
|
const ramUsage = script.ramUsage;
|
||||||
|
const ramAvailable = home.maxRam - home.ramUsed;
|
||||||
|
if (ramUsage > ramAvailable) {
|
||||||
|
console.log('here 4');
|
||||||
|
return; // Not enough RAM
|
||||||
|
}
|
||||||
|
const runningScriptObj = new RunningScript(script, []); // No args
|
||||||
|
runningScriptObj.threads = 1; // Only 1 thread
|
||||||
|
console.log('running!');
|
||||||
|
startWorkerScript(runningScriptObj, home);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
hacknet : {
|
hacknet : {
|
||||||
numNodes : function() {
|
numNodes : function() {
|
||||||
@ -3242,7 +3269,8 @@ function NetscriptFunctions(workerScript) {
|
|||||||
|
|
||||||
workerScript.log("softReset", "Soft resetting. This will cause this script to be killed");
|
workerScript.log("softReset", "Soft resetting. This will cause this script to be killed");
|
||||||
setTimeoutRef(() => {
|
setTimeoutRef(() => {
|
||||||
prestigeAugmentation(cbScript);
|
prestigeAugmentation();
|
||||||
|
runAfterReset(cbScript);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
// Prevent workerScript from "finishing execution naturally"
|
// Prevent workerScript from "finishing execution naturally"
|
||||||
@ -3260,7 +3288,8 @@ function NetscriptFunctions(workerScript) {
|
|||||||
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
Player.gainIntelligenceExp(CONSTANTS.IntelligenceSingFnBaseExpGain);
|
||||||
workerScript.log("installAugmentations", "Installing Augmentations. This will cause this script to be killed");
|
workerScript.log("installAugmentations", "Installing Augmentations. This will cause this script to be killed");
|
||||||
setTimeoutRef(() => {
|
setTimeoutRef(() => {
|
||||||
installAugmentations(cbScript);
|
installAugmentations();
|
||||||
|
runAfterReset(cbScript);
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
workerScript.running = false; // Prevent workerScript from "finishing execution naturally"
|
workerScript.running = false; // Prevent workerScript from "finishing execution naturally"
|
||||||
|
Loading…
Reference in New Issue
Block a user