Added softReset to netscript

This commit is contained in:
Olivier Gagnon
2021-03-07 04:49:57 -05:00
parent c8377c0bb3
commit 64272c99fb
5 changed files with 33 additions and 1 deletions
+19
View File
@@ -10,6 +10,7 @@ import {
augmentationExists,
installAugmentations
} from "./Augmentation/AugmentationHelpers";
import { prestigeAugmentation } from "./Prestige";
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
import { BitNodeMultipliers } from "./BitNode/BitNodeMultipliers";
import { findCrime } from "./Crime/CrimeHelpers";
@@ -3483,6 +3484,24 @@ function NetscriptFunctions(workerScript) {
return false;
}
},
softReset: function() {
updateDynamicRam("softReset", getRamCost("softReset"));
if (Player.bitNodeN !== 4) {
if (SourceFileFlags[4] <= 2) {
throw makeRuntimeRejectMsg(workerScript, "Cannot run softReset(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
return false;
}
}
workerScript.log("Soft resetting. This will cause this script to be killed");
setTimeoutRef(() => {
prestigeAugmentation();
}, 0);
// Prevent workerScript from "finishing execution naturally"
workerScript.running = false;
killWorkerScript(workerScript);
},
installAugmentations: function(cbScript) {
updateDynamicRam("installAugmentations", getRamCost("installAugmentations"));
if (Player.bitNodeN !== 4) {