diff --git a/doc/source/netscript/netscriptsingularityfunctions.rst b/doc/source/netscript/netscriptsingularityfunctions.rst index e9b3e5f28..d56d09130 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/NetscriptFunctions.js b/src/NetscriptFunctions.js index 6d297196b..f059ec4a4 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; + }, getAugmentationCost : function(name) { var ramCost = CONSTANTS.ScriptSingularityFn3RamCost; if (Player.bitNodeN !== 4) {ramCost *= CONSTANTS.ScriptSingularityFnRamMult;}