diff --git a/doc/source/netscript/netscriptsingularityfunctions.rst b/doc/source/netscript/netscriptsingularityfunctions.rst index e9b3e5f28..6e44ab72e 100644 --- a/doc/source/netscript/netscriptsingularityfunctions.rst +++ b/doc/source/netscript/netscriptsingularityfunctions.rst @@ -556,6 +556,20 @@ getAugmentationsFromFaction Returns an array containing the names (as strings) of all Augmentations that are available from the specified faction. +getAugmentationPrereq +--------------------- + +.. js:function:: getAugmentationPrereq(augName) + + :param string augName: Name of Augmentation. CASE-SENSITIVE + + 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 returns an array with the names of the prerequisite Augmentation(s) for the specified Augmentation. + If there are no prerequisites, a blank array is returned. + + If an invalid Augmentation name is passed in for the *augName* argument, this function will return a blank array. + getAugmentationCost ------------------- diff --git a/netscript.js b/netscript.js index e57a7a0be..5aa197399 100644 --- a/netscript.js +++ b/netscript.js @@ -89,7 +89,7 @@ let NetscriptFunctions = "donateToFaction|" + "createProgram|commitCrime|getCrimeChance|getOwnedAugmentations|" + "getOwnedSourceFiles|getAugmentationsFromFaction|" + - "getAugmentationCost|purchaseAugmentation|" + + "getAugmentationPrereq|getAugmentationCost|purchaseAugmentation|" + "installAugmentations|" + // TIX API diff --git a/src/Constants.ts b/src/Constants.ts index 2f0e89dcc..80c50702a 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -519,7 +519,7 @@ export let CONSTANTS: IMap = { ** Slightly reduced the effect "Real Estate" has on the Production Multiplier for the Agriculture industry * Added getOrders() Netscript function to the TIX API - * + * Added getAugmentationPrereq() Singularity function (by havocmayhem) * Stock Market, Travel, and Corporation main menu links are now properly styled * Many pop-up/dialog boxes now support the 'Enter' and 'Esc' hotkeys. If you find a pop-up/dialog box that doesnt support this, let me know specifically which one ('Enter' for the default option, 'Esc' for cancelling and closing the pop-up box) * Added "brace_style = preserve_inline" configuration to Script Editor Beautifier diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 6d297196b..e65c1bac5 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -3606,6 +3606,28 @@ function NetscriptFunctions(workerScript) { } return res; }, + getAugmentationPrereq : function(name) { + var ramCost = CONSTANTS.ScriptSingularityFn3RamCost; + if (Player.bitNodeN !== 4) {ramCost *= CONSTANTS.ScriptSingularityFnRamMult;} + if (workerScript.checkingRam) { + return updateStaticRam("getAugmentationPrereq", ramCost); + } + updateDynamicRam("getAugmentationPrereq", ramCost); + if (Player.bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw makeRuntimeRejectMsg(workerScript, "Cannot run getAugmentationPrereq(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return false; + } + } + + if (!augmentationExists(name)) { + workerScript.scriptRef.log("ERROR: getAugmentationPrereq() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name); + return []; + } + + var aug = Augmentations[name]; + return aug.prereqs.slice(); + }, getAugmentationCost : function(name) { var ramCost = CONSTANTS.ScriptSingularityFn3RamCost; if (Player.bitNodeN !== 4) {ramCost *= CONSTANTS.ScriptSingularityFnRamMult;}