From 39ed2c40dd34baf9d45af6a2a89cd6da14c6f38e Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sun, 6 May 2018 14:22:29 -0400 Subject: [PATCH 1/2] added hacknet multiplier netscript function --- doc/source/netscriptfunctions.rst | 24 ++++++++++++++++++++++++ doc/source/netscripthacknetnodeapi.rst | 23 +++++++++++++++++++++++ src/NetscriptFunctions.js | 17 +++++++++++++++++ 3 files changed, 64 insertions(+) diff --git a/doc/source/netscriptfunctions.rst b/doc/source/netscriptfunctions.rst index 3b0dd2a13..4f76382a8 100644 --- a/doc/source/netscriptfunctions.rst +++ b/doc/source/netscriptfunctions.rst @@ -437,6 +437,30 @@ getHackingMultipliers print(mults.chance); print(mults.growth); +getHacknetMultipliers +^^^^^^^^^^^^^^^^^^^^^ + +.. js:function:: getHacknetMultipliers() + + Returns an object containing the Player's hacknet related multipliers. These multipliers are + returned in integer forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: + + { + production: Player's hacknet production multiplier, + purchaseCost: Player's hacknet purchase cost multiplier, + ramCost: Player's hacknet ram cost multiplier, + coreCost: Player's hacknet core cost multiplier, + levelCost: Player's hacknet level cost multiplier + } + + Example of how this can be used:: + + mults = getHacknetMultipliers(); + print(mults.production); + print(mults.purchaseCost); + + + getServerMoneyAvailable ^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/doc/source/netscripthacknetnodeapi.rst b/doc/source/netscripthacknetnodeapi.rst index 73c0860c1..5fe51b4cc 100644 --- a/doc/source/netscripthacknetnodeapi.rst +++ b/doc/source/netscripthacknetnodeapi.rst @@ -90,6 +90,29 @@ array itself. Returns the cost of upgrading the number of cores of the specified Hacknet Node. Upgrading a Node's number of cores adds one additional core. +Utils +^^^^^ + +.. js:function:: getHacknetMultipliers() + + Returns an object containing the Player's hacknet related multipliers. These multipliers are + returned in integer forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: + + { + production: Player's hacknet production multiplier, + purchaseCost: Player's hacknet purchase cost multiplier, + ramCost: Player's hacknet ram cost multiplier, + coreCost: Player's hacknet core cost multiplier, + levelCost: Player's hacknet level cost multiplier + } + + Example of how this can be used:: + + mults = getHacknetMultipliers(); + print(mults.production); + print(mults.purchaseCost); + + Example(s) ^^^^^^^^^^ diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 799ca02df..eeeab05ee 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -1036,6 +1036,23 @@ function NetscriptFunctions(workerScript) { growth: Player.hacking_grow_mult, }; }, + getHacknetMultipliers : function() { + if (workerScript.checkingRam) { + if (workerScript.loadedFns.getHacknetMultipliers) { + return 0; + } else { + workerScript.loadedFns.getHacknetMultipliers = true; + return CONSTANTS.ScriptGetMultipliersRamCost; + } + } + return { + production: Player.hacknet_node_money_mult, + purchaseCost: Player.hacknet_node_purchase_cost_mult, + ramCost: Player.hacknet_node_ram_cost_mult, + coreCost: Player.hacknet_node_core_cost_mult, + levelCost: Player.hacknet_node_level_cost_mult, + }; + }, getBitNodeMultipliers: function() { if (workerScript.checkingRam) { if (workerScript.loadedFns.getBitNodeMultipliers) { From 92b1050a6855c77ea18d1b4f969d1d38e4fb73f9 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Sun, 6 May 2018 16:27:10 -0400 Subject: [PATCH 2/2] fixed integer form typo --- doc/source/netscriptfunctions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/source/netscriptfunctions.rst b/doc/source/netscriptfunctions.rst index 4f76382a8..846af59f5 100644 --- a/doc/source/netscriptfunctions.rst +++ b/doc/source/netscriptfunctions.rst @@ -422,7 +422,7 @@ getHackingMultipliers .. js:function:: getHackingMultipliers() Returns an object containing the Player's hacking related multipliers. These multipliers are - returned in integer forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: + returned in fractional forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: { chance: Player's hacking chance multiplier, @@ -443,7 +443,7 @@ getHacknetMultipliers .. js:function:: getHacknetMultipliers() Returns an object containing the Player's hacknet related multipliers. These multipliers are - returned in integer forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: + returned in fractional forms, not percentages (e.g. 1.5 instead of 150%). The object has the following structure:: { production: Player's hacknet production multiplier,