From 7dd44446df9c67119fe355dc79f80156106b00d7 Mon Sep 17 00:00:00 2001 From: havocmayhem <44165205+havocmayhem@users.noreply.github.com> Date: Sun, 30 Dec 2018 20:58:42 +0530 Subject: [PATCH 1/4] Update NetscriptFunctions.js --- src/NetscriptFunctions.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 9a32ce26d..eb058574a 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -3568,6 +3568,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 [-1, -1]; + } + + var aug = Augmentations[name]; + return aug.prereqs; + }, getAugmentationCost : function(name) { var ramCost = CONSTANTS.ScriptSingularityFn3RamCost; if (Player.bitNodeN !== 4) {ramCost *= CONSTANTS.ScriptSingularityFnRamMult;} From 99987778afe627e393bd966e31dfc97ae7c8c6ce Mon Sep 17 00:00:00 2001 From: havocmayhem <44165205+havocmayhem@users.noreply.github.com> Date: Sun, 30 Dec 2018 21:02:08 +0530 Subject: [PATCH 2/4] Added getAugmentationPrereq() --- netscript.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/netscript.js b/netscript.js index b84426ef4..283d6e4c3 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 From f8cccd56ac25ea355ba48654df383a1c2ba505bf Mon Sep 17 00:00:00 2001 From: havocmayhem <44165205+havocmayhem@users.noreply.github.com> Date: Sun, 30 Dec 2018 21:07:23 +0530 Subject: [PATCH 3/4] Added getAugmentationPrereq() --- doc/source/netscriptsingularityfunctions.rst | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/doc/source/netscriptsingularityfunctions.rst b/doc/source/netscriptsingularityfunctions.rst index e9b3e5f28..d56d09130 100644 --- a/doc/source/netscriptsingularityfunctions.rst +++ b/doc/source/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 ------------------- From 984a2aa5d46154fc16f6604daf71ccc12f3be4d2 Mon Sep 17 00:00:00 2001 From: havocmayhem <44165205+havocmayhem@users.noreply.github.com> Date: Sun, 30 Dec 2018 21:07:24 +0530 Subject: [PATCH 4/4] Update NetscriptFunctions.js --- src/NetscriptFunctions.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index eb058574a..015eebb12 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -3584,7 +3584,7 @@ function NetscriptFunctions(workerScript) { if (!augmentationExists(name)) { workerScript.scriptRef.log("ERROR: getAugmentationPrereq() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name); - return [-1, -1]; + return []; } var aug = Augmentations[name];