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

View File

@ -0,0 +1,8 @@
softReset() Netscript Function
===================================
.. js:function:: softReset()
If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
This function will perform a reset even if you don't have any augmentation installed.

View File

@ -231,6 +231,10 @@ export let CONSTANTS: IMap<any> = {
v0.48.0
-------
Netscript
* softReset is a new netscript function that performs a soft reset
regardless of if the player has bought augmentations or not.
Misc.
* Fixed an issue where SF3 was listed as infinitly repeatable and SF12 as
having a limit of 3.

View File

@ -203,6 +203,7 @@ export const RamCosts: IMap<any> = {
getAugmentationPrereq: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationCost: () => RamCostConstants.ScriptSingularityFn3RamCost,
purchaseAugmentation: () => RamCostConstants.ScriptSingularityFn3RamCost,
softReset: () => RamCostConstants.ScriptSingularityFn3RamCost,
installAugmentations: () => RamCostConstants.ScriptSingularityFn3RamCost,
// Gang API

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) {

View File

@ -91,7 +91,7 @@ let NetscriptFunctions =
"createProgram|commitCrime|getCrimeChance|getOwnedAugmentations|" +
"getOwnedSourceFiles|getAugmentationsFromFaction|" +
"getAugmentationPrereq|getAugmentationCost|purchaseAugmentation|" +
"installAugmentations|" +
"softReset|installAugmentations|" +
// TIX API
"getStockPrice|getStockPosition|getStockSymbols|getStockMaxShares|" +