added getAugmentationStats to netscript, it returns the stat boost of an aug

This commit is contained in:
Olivier Gagnon 2021-03-07 04:57:49 -05:00
parent 64272c99fb
commit dc402bef68
5 changed files with 38 additions and 1 deletions

@ -0,0 +1,16 @@
getAugmentationStats() Netscript Function
=========================================
.. js:function:: getAugmentationStats(name)
:RAM cost: 5 GB
:param string name: 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.
ns.getAugmentationStats("Synfibril Muscle")
{
strength_mult: 1.3,
defense_mult: 1.3,
}

@ -234,6 +234,8 @@ export let CONSTANTS: IMap<any> = {
Netscript
* softReset is a new netscript function that performs a soft reset
regardless of if the player has bought augmentations or not.
* getAugmentationStats is a new netscript function that returns the stats of
an augmentation.
Misc.
* Fixed an issue where SF3 was listed as infinitly repeatable and SF12 as

@ -202,6 +202,7 @@ export const RamCosts: IMap<any> = {
getAugmentationsFromFaction: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationPrereq: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationCost: () => RamCostConstants.ScriptSingularityFn3RamCost,
getAugmentationStats: () => RamCostConstants.ScriptSingularityFn3RamCost,
purchaseAugmentation: () => RamCostConstants.ScriptSingularityFn3RamCost,
softReset: () => RamCostConstants.ScriptSingularityFn3RamCost,
installAugmentations: () => RamCostConstants.ScriptSingularityFn3RamCost,

@ -3416,6 +3416,24 @@ function NetscriptFunctions(workerScript) {
var aug = Augmentations[name];
return [aug.baseRepRequirement, aug.baseCost];
},
getAugmentationStats: function(name) {
updateDynamicRam("getAugmentationStats", getRamCost("getAugmentationStats"));
if (Player.bitNodeN !== 4) {
if (SourceFileFlags[4] <= 2) {
throw makeRuntimeRejectMsg(workerScript, "Cannot run getAugmentationStats(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
return false;
}
}
if (!augmentationExists(name)) {
workerScript.scriptRef.log("ERROR: getAugmentationStats() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name);
return {};
}
var aug = Augmentations[name];
return Object.assign({}, aug.mults);
},
purchaseAugmentation: function(faction, name) {
updateDynamicRam("purchaseAugmentation", getRamCost("purchaseAugmentation"));
if (Player.bitNodeN !== 4) {

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