Update netscript documentation.

Unfortunately, I haven't used most of the specialty APIs yet, so I'm not intimately familiar with where their documentation might be wrong. I figured some fixes were better than no fixes, and I can always make more fixes later.

Fixes #1023.
This commit is contained in:
MageKing17 2021-07-02 14:27:59 -07:00 committed by danielyxie
parent 55d1ebd0e4
commit ae15914efa
73 changed files with 322 additions and 267 deletions

@ -5,13 +5,16 @@ getBitNodeMultipliers() Netscript Function
:RAM cost: 4 GB :RAM cost: 4 GB
Returns an object containing the current BitNode multipliers. This function If you are not in BitNode-5, then you must have Source-File 5-1 in order to
requires Source-File 5 in order to run. The multipliers are returned in run this function.
decimal forms (e.g. 1.5 instead of 150%). The multipliers represent the
difference between the current BitNode and the original BitNode (BitNode-1). Returns an object containing the current BitNode multipliers. The
For example, if the *CrimeMoney* multiplier has a value of 0.1, then that multipliers are returned in decimal forms (e.g. 1.5 instead of 150%). The
means that committing crimes in the current BitNode will only give 10% of multipliers represent the difference between the current BitNode and the
the money you would have received in BitNode-1. original BitNode (BitNode-1). For example, if the *CrimeMoney* multiplier
has a value of 0.1, then that means that committing crimes in the current
BitNode will only give 10% of the money you would have received in
BitNode-1.
The structure of the returned object is subject to change as BitNode The structure of the returned object is subject to change as BitNode
multipliers get added to the game. Refer to the `source code here multipliers get added to the game. Refer to the `source code here

@ -3,7 +3,7 @@ getServer() Netscript Function
.. js:function:: getServer([hostname]) .. js:function:: getServer([hostname])
:RAM cost: 4 GB :RAM cost: 2 GB
:param string hostname: Hostname of the server, defaults to host server. :param string hostname: Hostname of the server, defaults to host server.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to run this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to run this function.

@ -7,8 +7,8 @@ brutessh() Netscript Function
:param string hostname: Hostname of the target server. :param string hostname: Hostname of the target server.
Runs the BruteSSH.exe program on the target server. BruteSSH.exe must exist Runs the ``BruteSSH.exe`` program on the target server. ``BruteSSH.exe``
on your home computer. must exist on your home computer.
Examples: Examples:

@ -9,9 +9,3 @@ disableLog() Netscript Function
Disables logging for the given function. Logging can be disabled for Disables logging for the given function. Logging can be disabled for
all functions by passing 'ALL' as the argument. all functions by passing 'ALL' as the argument.
Note that this does not completely remove all logging functionality.
This only stops a function from logging when the function is successful. If
the function fails, it will still log the reason for failure.
Notable functions that cannot have their logs disabled: run, exec, exit

@ -19,9 +19,8 @@ exec() Netscript Function
the :doc:`run<run>` function except that it can be used to run a script on any the :doc:`run<run>` function except that it can be used to run a script on any
server, instead of just the current server. server, instead of just the current server.
.. warning:: Running this function with a ``numThreads`` argument of 0 will return 0 without .. warning:: Running this function with a ``numThreads`` argument of 0 or
running the script. However, running this function with a negative *numThreads* less will cause a runtime error.
argument will cause a runtime error.
The simplest way to use the :doc:`exec<exec>` command is to call it with The simplest way to use the :doc:`exec<exec>` command is to call it with
just the script name and the target server. The following example will try just the script name and the target server. The following example will try

@ -6,3 +6,12 @@ exit() Netscript Function
:RAM cost: 0 GB :RAM cost: 0 GB
Terminates the current script immediately. Terminates the current script immediately.
.. warning:: In :ref:`netscriptjs`, execution may continue past a call to
this function; while some game-related functions (e.g. those with an
``ns.`` prefix) will not function after this function has been called,
there might still be unintended behavior if you assume ``exit`` will
immediately halt execution, like it does in :ref:`netscript1`. To be
safe, you should probably ``return`` from the main function instead
of/in addition to calling ``ns.exit()`` when halting a NetscriptJS
script.

@ -7,11 +7,16 @@ flags() Netscript Function
:param data array of pairs of strings: Flags definition. :param data array of pairs of strings: Flags definition.
:returns: Object containing all the flags that were parsed or default. :returns: Object containing all the flags that were parsed or default.
The flag definition is an array of pairs of values, the first value is the This function allows for a more flexible way of parsing script arguments
name of the flag, the 2nd value is the default value for that flag. than to just pass a fixed list in a fixed order. Options can be given
names, and passed in any order, while having defined default values.
The flag definition is an array of pairs of values: the first value is the
name of the flag, and the 2nd value is the default value for that flag.
The return object is a map containing flag names to the value. It also The return object is a map containing flag names to the value. It also
contains the special field '_' which contains all arguments that were not flags. contains the special field '_', which contains all arguments that were not
flags.
Example: Example:
@ -27,14 +32,14 @@ flags() Netscript Function
tprint(data); tprint(data);
*/ */
[home ~/]> run example.script [home ~/]> run example.script
{"_":[],"delay":0,"server":"foodnstuff"} {"_":[],"delay":0,"server":"foodnstuff","exclude":[],"help":false}
[home ~/]> run example.script --delay 3000 [home ~/]> run example.script --delay 3000
{"_":[],"server":"foodnstuff","delay":3000} {"_":[],"server":"foodnstuff","exclude":[],"help":false,"delay":3000}
[home ~/]> run example.script --delay 3000 --server harakiri-sushi [home ~/]> run example.script --delay 3000 --server harakiri-sushi
{"_":[],"delay":3000,"server":"harakiri-sushi"} {"_":[],"exclude":[],"help":false,"delay":3000,"server":"harakiri-sushi"}
[home ~/]> run example.script --delay 3000 --server harakiri-sushi hello world [home ~/]> run example.script --delay 3000 --server harakiri-sushi hello world
{"_":["hello","world"],"delay":3000,"server":"harakiri-sushi"} {"_":["hello","world"],"exclude":[],"help":false,"delay":3000,"server":"harakiri-sushi"}
[home ~/]> run example.script --delay 3000 --server harakiri-sushi hello world --exclude a --exclude b [home ~/]> run example.script --delay 3000 --server harakiri-sushi hello world --exclude a --exclude b
{"_":["hello","world"],"delay":3000,"server":"harakiri-sushi","exclude":["a","b"]} {"_":["hello","world"],"help":false,"delay":3000,"server":"harakiri-sushi","exclude":["a","b"]}
[home ~/]> run example.script --help [home ~/]> run example.script --help
{"_":[],"delay":0,"server":"foodnstuff","exclude":[],"help":true} {"_":[],"delay":0,"server":"foodnstuff","exclude":[],"help":true}

@ -10,7 +10,6 @@ ftpcrack() Netscript Function
Runs the ``FTPCrack.exe`` program on the target server. ``FTPCrack.exe`` Runs the ``FTPCrack.exe`` program on the target server. ``FTPCrack.exe``
must exist on your home computer. must exist on your home computer.
Examples: Examples:
.. code-block:: javascript .. code-block:: javascript

@ -13,7 +13,6 @@ getGrowTime() Netscript Function
The function takes in an optional ``hackLvl`` parameter that can be The function takes in an optional ``hackLvl`` parameter that can be
specified to see what the grow time would be at different hacking levels. specified to see what the grow time would be at different hacking levels.
Example: Example:
.. code-block:: javascript .. code-block:: javascript

@ -11,4 +11,3 @@ getHostname() Netscript Function
.. code-block:: javascript .. code-block:: javascript
getHostname(); // returns: "foodnstuff" getHostname(); // returns: "foodnstuff"

@ -10,89 +10,89 @@ getPlayer() Netscript Function
Returns an object with the Player's stats. The object has the following properties:: Returns an object with the Player's stats. The object has the following properties::
{ {
hacking_skill hacking_skill: Current Hacking skill level
hp hp: Current health points
max_hp max_hp: Maximum health points
strength strength: Current Strength skill level
defense defense: Current Defense skill level
dexterity dexterity: Current Dexterity skill level
agility agility: Current Agility skill level
charisma charisma: Current Charisma skill level
intelligence intelligence: Current Intelligence skill level (from BitNode-5)
hacking_chance_mult hacking_chance_mult: Hacking Chance multiplier (from Source-Files and Augments)
hacking_speed_mult hacking_speed_mult: Hacking Speed multiplier (from Source-Files and Augments)
hacking_money_mult hacking_money_mult: Hacking Money multiplier (from Source-Files and Augments)
hacking_grow_mult hacking_grow_mult: Hacking Growth multiplier (from Source-Files and Augments)
hacking_exp hacking_exp: Current Hacking experience points
strength_exp strength_exp: Current Strength experience points
defense_exp defense_exp: Current Defense experience points
dexterity_exp dexterity_exp: Current Dexterity experience points
agility_exp agility_exp: Current Agility experience points
charisma_exp charisma_exp: Current Charisma experience points
hacking_mult hacking_mult: Hacking Level multiplier (from Source-Files and Augments)
strength_mult strength_mult: Strength Level multiplier (from Source-Files and Augments)
defense_mult defense_mult: Defense Level multiplier (from Source-Files and Augments)
dexterity_mult dexterity_mult: Dexterity Level multiplier (from Source-Files and Augments)
agility_mult agility_mult: Agility Level multiplier (from Source-Files and Augments)
charisma_mult charisma_mult: Charisma Level multiplier (from Source-Files and Augments)
hacking_exp_mult hacking_exp_mult: Hacking Experience multiplier (from Source-Files and Augments)
strength_exp_mult strength_exp_mult: Strength Experience multiplier (from Source-Files and Augments)
defense_exp_mult defense_exp_mult: Defense Experience multiplier (from Source-Files and Augments)
dexterity_exp_mult dexterity_exp_mult: Dexterity Experience multiplier (from Source-Files and Augments)
agility_exp_mult agility_exp_mult: Agility Experience multiplier (from Source-Files and Augments)
charisma_exp_mult charisma_exp_mult: Charisma Experience multiplier (from Source-Files and Augments)
company_rep_mult company_rep_mult: Company reputation gain multiplier (from Source-Files and Augments)
faction_rep_mult faction_rep_mult: Faction reputation gain multiplier (from Source-Files and Augments)
money money: Current money
city city: Name of city you are currently in
location location: Name of the last location visited
crime_money_mult crime_money_mult: Crime money multiplier (from Source-Files and Augments)
crime_success_mult crime_success_mult: Crime success multiplier (from Source-Files and Augments)
isWorking isWorking: Boolean indicating whether the player is currently performing work
workType workType: Name of the kind of work the player is performing
currentWorkFactionName currentWorkFactionName: Name of the faction the player is currently working for
currentWorkFactionDescription currentWorkFactionDescription: Description of the kind of work the player is currently doing
workHackExpGainRate workHackExpGainRate: Amount of Hacking experience the player will gain every cycle (fifth of a second)
workStrExpGainRate workStrExpGainRate: Amount of Strength experience the player will gain every cycle
workDefExpGainRate workDefExpGainRate: Amount of Defense experience the player will gain every cycle
workDexExpGainRate workDexExpGainRate: Amount of Dexterity experience the player will gain every cycle
workAgiExpGainRate workAgiExpGainRate: Amount of Agility experience the player will gain every cycle
workChaExpGainRate workChaExpGainRate: Amount of Charisma experience the player will gain every cycle
workRepGainRate workRepGainRate: Amount of Reputation the player will gain every cycle
workMoneyGainRate workMoneyGainRate: Amount of Money the player will gain every cycle
workMoneyLossRate workMoneyLossRate: Amount of Money the player will lose every cycle
workHackExpGained workHackExpGained: Total Hacking experience gained while working thus far
workStrExpGained workStrExpGained: Total Strength experience gained while working thus far
workDefExpGained workDefExpGained: Total Defense experience gained while working thus far
workDexExpGained workDexExpGained: Total Dexterity experience gained while working thus far
workAgiExpGained workAgiExpGained: Total Agility experience gained while working thus far
workChaExpGained workChaExpGained: Total Charisma experience gained while working thus far
workRepGained workRepGained: Total Reputation gained while working thus far
workMoneyGained workMoneyGained: Total Money gained while working thus far
createProgramName createProgramName: Name of the program the player is currently creating
createProgramReqLvl createProgramReqLvl: Hacking skill required to make that program
className className: Name of the class the player is currently studying
crimeType crimeType: Name of the crime the player last started
work_money_mult work_money_mult: Salary multiplier (from Source-Files and Augments)
hacknet_node_money_mult hacknet_node_money_mult: Hacknet Node production multiplier (from Source-Files and Augments)
hacknet_node_purchase_cost_mult hacknet_node_purchase_cost_mult: Hacknet Node purchase cost multiplier (from Source-Files and Augments)
hacknet_node_ram_cost_mult hacknet_node_ram_cost_mult: Hacknet Node RAM upgrade cost multiplier (from Source-Files and Augments)
hacknet_node_core_cost_mult hacknet_node_core_cost_mult: Hacknet Node Core purchase cost multiplier (from Source-Files and Augments)
hacknet_node_level_cost_mult hacknet_node_level_cost_mult: Hacknet Node level upgrade cost multiplier (from Source-Files and Augments)
hasWseAccount hasWseAccount: Boolean indicating whether the player has a WSE Account
hasTixApiAccess hasTixApiAccess: Boolean indicating whether the player has TIX API Access
has4SData has4SData: Boolean indicating whether the player has 4S Market Data Access
has4SDataTixApi has4SDataTixApi: Boolean indicating whether the player has 4S Market Data TIX API Access
bladeburner_max_stamina_mult bladeburner_max_stamina_mult: Bladeburner Max Stamina multiplier (from Source-Files and Augments)
bladeburner_stamina_gain_mult bladeburner_stamina_gain_mult: Bladeburner Stamina Gain multiplier (from Source-Files and Augments)
bladeburner_success_chance_mult bladeburner_success_chance_mult: Bladeburner Success Chance multiplier (from Source-Files and Augments)
bitNodeN bitNodeN: Current BitNode number
totalPlaytime totalPlaytime: Total amount of time the game has been running, in milliseconds
playtimeSinceLastAug playtimeSinceLastAug: Milliseconds since the last time Augmentations were installed
playtimeSinceLastBitnode playtimeSinceLastBitnode: Milliseconds since this BitNode was started
jobs jobs: A mapping of companies the player works for to the title of the player's job at that company
factions factions: An array of factions the player is currently a member of
tor tor: Boolean indicating whether or not you have a tor router
} }
Example:: Example::

@ -4,7 +4,7 @@ getRunningScript() Netscript Function
.. js:function:: getRunningScript() .. js:function:: getRunningScript()
:RAM cost: 0.3 GB :RAM cost: 0.3 GB
:returns: Script object or null if not found :returns: Script object or null if not found.
The object has the following properties: The object has the following properties:
@ -64,8 +64,8 @@ getRunningScript() Netscript Function
.. js:function:: getRunningScript(pid) .. js:function:: getRunningScript(pid)
:RAM cost: 0.3 GB :RAM cost: 0.3 GB
:param number pid: PID of the script :param number pid: PID of the script.
:returns: Script object or null if not found :returns: Script object or null if not found.
Examples: Examples:
@ -73,13 +73,13 @@ getRunningScript() Netscript Function
getRunningScript(42); // get the script with pid 42. getRunningScript(42); // get the script with pid 42.
.. js:function:: getRunningScript(fn, hostname[, args]) .. js:function:: getRunningScript(fn, hostname[, args...])
:RAM cost: 0.3 GB :RAM cost: 0.3 GB
:param number fn: filename of the target script :param number fn: Filename of the target script.
:param number hostname: hostname of the server running the script :param number hostname: Hostname of the server running the script.
:param number args: arguments to the script. :param number args...: Arguments that the script is running with.
:returns: Script object or null if not found :returns: Script object or null if not found.
Examples: Examples:

@ -15,4 +15,3 @@ getScriptExpGain() Netscript Function
.. note:: A script is uniquely identified by both its name and its .. note:: A script is uniquely identified by both its name and its
arguments. arguments.

@ -7,10 +7,10 @@ getServerGrowth() Netscript Function
:param string hostname: Hostname of target server. :param string hostname: Hostname of target server.
:returns: Server growth parameter. :returns: Server growth parameter.
The growth parameter is a number between 1 and 100 affects the percentage by The growth parameter is a number, typically between 1 and 100, that affects
which the server's money is increased when using the :doc:`grow<grow>` the percentage by which the server's money is increased when using the
function. A higher growth parameter will result in a higher percentage :doc:`grow<grow>` function. A higher growth parameter will result in a
increase. higher percentage increase.
Example: Example:

@ -11,4 +11,4 @@ getServerMaxMoney() Netscript Function
.. code-block:: javascript .. code-block:: javascript
getServerMaxMoney('foodnstuff'); // returns: 4000000 getServerMaxMoney('foodnstuff'); // returns: 50000000

@ -3,12 +3,14 @@ getServerRam() Netscript Function
.. js:function:: getServerRam(hostname) .. js:function:: getServerRam(hostname)
.. warning:: This function is deprecated. .. warning:: This function is deprecated. It still functions, but new
scripts should prefer :doc:`getServerMaxRam<getServerMaxRam>`
and :doc:`getServerUsedRam<getServerUsedRam>` instead.
:RAM cost: 0.1 GB :RAM cost: 0.1 GB
:param string hostname: Hostname of target server. :param string hostname: Hostname of target server.
:returns: An array of 2 number, first number is the total RAM, second the :returns: An array of 2 numbers; the first number is the total RAM, and the
used RAM. second is the used RAM.
Returns an array with two elements that gives information about a server's memory (RAM). The first Returns an array with two elements that gives information about a server's memory (RAM). The first
element in the array is the amount of RAM that the server has total (in GB). The second element in element in the array is the amount of RAM that the server has total (in GB). The second element in

@ -6,8 +6,8 @@ httpworm() Netscript Function
:RAM cost: 0.05 GB :RAM cost: 0.05 GB
:param string hostname: Hostname of the target server. :param string hostname: Hostname of the target server.
Runs the HTTPWorm.exe program on the target server. HTTPWorm.exe must exist Runs the ``HTTPWorm.exe`` program on the target server. ``HTTPWorm.exe``
on your home computer. must exist on your home computer.
Example: Example:

@ -6,7 +6,8 @@ nuke() Netscript Function
:RAM cost: 0.05 GB :RAM cost: 0.05 GB
:param string hostname: Hostname of the target server. :param string hostname: Hostname of the target server.
Runs the NUKE.exe program on the target server. NUKE.exe must exist on your home computer. Runs the ``NUKE.exe`` program on the target server. ``NUKE.exe`` must exist
on your home computer.
Example: Example:

@ -6,9 +6,8 @@ relaysmtp() Netscript Function
:RAM cost: 0.05 GB :RAM cost: 0.05 GB
:param string hostname: Hostname of the target server. :param string hostname: Hostname of the target server.
Runs the ``relaySMTP.exe`` program on the target server. ``relaySMTP.exe``
Runs the relaySMTP.exe program on the target server. relaySMTP.exe must must exist on your home computer.
exist on your home computer.
Example: Example:

@ -17,9 +17,8 @@ run() Netscript Function
scripts located on the current server (the server running the script that scripts located on the current server (the server running the script that
calls this function). calls this function).
.. warning:: Running this function with a ``numThreads`` argument of 0 will .. warning:: Running this function with a ``numThreads`` argument of 0 or
return 0 without running the script. However, running this function with less will cause a runtime error.
a negative ``numThreads`` argument will cause a runtime error.
The simplest way to use the :doc:`run<run>` command is to call it with just The simplest way to use the :doc:`run<run>` command is to call it with just
the script name. The following example will run ``foo.script`` the script name. The following example will run ``foo.script``

@ -9,7 +9,7 @@ scp() Netscript Function
Hostname of the source server, which is the server from which the file will be copied. Hostname of the source server, which is the server from which the file will be copied.
This argument is optional and if it's omitted the source will be the current server. This argument is optional and if it's omitted the source will be the current server.
:param string destination: Hostname of the destination server, which is the server to which the file will be copied. :param string destination: Hostname of the destination server, which is the server to which the file will be copied.
:returns: ``true`` is the copy was a success. :returns: ``true`` if the copy was a success.
Copies a script or literature (.lit) file(s) to another server. The Copies a script or literature (.lit) file(s) to another server. The
``files`` argument can be either a string specifying a single file to copy, ``files`` argument can be either a string specifying a single file to copy,

@ -8,7 +8,6 @@ sleep() Netscript Function
Suspends the script for n milliseconds. Suspends the script for n milliseconds.
Example: Example:
.. code-block:: javascript .. code-block:: javascript

@ -16,6 +16,8 @@ spawn() Netscript Function
current one. This function can only be used to run scripts on the local current one. This function can only be used to run scripts on the local
server. server.
.. warning:: Running this function with a ``numThreads`` argument of 0 or
less will cause a runtime error.
Example: Example:

@ -6,8 +6,8 @@ sqlinject() Netscript Function
:RAM cost: 0.05 GB :RAM cost: 0.05 GB
:param string hostname: Hostname of the target server. :param string hostname: Hostname of the target server.
Runs the SQLInject.exe program on the target server. SQLInject.exe must Runs the ``SQLInject.exe`` program on the target server. ``SQLInject.exe``
exist on your home computer. must exist on your home computer.
Example: Example:

@ -44,9 +44,6 @@ tail() Netscript Function
// Open logs from process with id 42 // Open logs from process with id 42
tail(42); tail(42);
// Open logs from process with id 42 on the foodnstuff server
tail(42, "foodnstuff");
.. js:function:: tail() .. js:function:: tail()
:RAM cost: 0 GB :RAM cost: 0 GB

@ -8,7 +8,6 @@ write() Netscript Function
:param string data: Data to write :param string data: Data to write
:param string mode: Defines the write mode. Only valid when writing to text files or scripts. :param string mode: Defines the write mode. Only valid when writing to text files or scripts.
This function can be used to either write data to a port, a text file This function can be used to either write data to a port, a text file
(.txt), or a script (.script, .js, .ns) (.txt), or a script (.script, .js, .ns)

@ -11,8 +11,8 @@ getData() Netscript Function
contract type. contract type.
Get the data associated with the specific Coding Contract. Note that this is Get the data associated with the specific Coding Contract. Note that this is
not the same as the contract's description. This is just the data that not the same as the contract's description; this is just the data that
the contract wants you to act on in order to solve the contract wants you to act on in order to solve.
Example: Example:

@ -8,15 +8,18 @@ calculateExp() Netscript Function
:param number mult: Assume a specific skill multipler (not exp multiplier). :param number mult: Assume a specific skill multipler (not exp multiplier).
:returns: number of exp required to reach given ``skillLevel`` with that multiplier. :returns: number of exp required to reach given ``skillLevel`` with that multiplier.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the amount of experience needed to reach level the given ``skillLevel``. This function calculates the amount of experience needed to reach the given
``skillLevel``.
Examples: Examples:
.. code-block:: javascript .. code-block:: javascript
nextHacking = getStats().hacking+1; player = getPlayer();
nextHacking = player.hacking_skill+1;
nextExp = formulas.basic.calculateExp(nextHacking); nextExp = formulas.basic.calculateExp(nextHacking);
missingExp = nextExp - getCharacterInformation().hackingExp; missingExp = nextExp - player.hacking_exp;
tprint("Missing " + missingExp + " to reach next hacking level"); tprint("Missing " + missingExp + " to reach next hacking level");

@ -8,7 +8,8 @@ calculateSkill() Netscript Function
:param number mult: Assume a specific skill multipler (not exp multiplier). :param number mult: Assume a specific skill multipler (not exp multiplier).
:returns: skillLevel that ``exp`` would reach with that multiplier. :returns: skillLevel that ``exp`` would reach with that multiplier.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the skillLevel that the given amount of ``exp`` would reach. This function calculates the skillLevel that the given amount of ``exp`` would reach.

@ -7,14 +7,18 @@ growPercent() Netscript Function
:param server server: The server that receives the growth. :param server server: The server that receives the growth.
:param number threads: The number of thread that would be used. :param number threads: The number of thread that would be used.
:param player player: The player. :param player player: The player.
:returns: The percentage growth this server would receive with these parameters. :returns: The amount the server's money would be multiplied by with these
parameters.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function. Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function. Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates percentage of growth a server would receive with these parameters. This function calculates the amount of growth, as a multiplier, a server
would receive with these parameters. Despite its name, it does not return
a percentage.
Examples: Examples:

@ -8,10 +8,11 @@ growTime() Netscript Function
:param player player: The player. :param player player: The player.
:returns: The time it takes to grow this server. In seconds. :returns: The time it takes to grow this server. In seconds.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function. Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function. Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of time it takes to grow a server. This function calculates the amount of time it takes to grow a server.

@ -6,14 +6,15 @@ hackChance() Netscript Function
:RAM cost: 0 GB :RAM cost: 0 GB
:param server server: The server to hack. :param server server: The server to hack.
:param player player: The player. :param player player: The player.
:returns: The change to hack that server. between 0 and 1. :returns: The chance to hack that server, between 0 and 1.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function. Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function. Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates percentage chance to hack a server. This function calculates the probability to successfully hack a server.
Examples: Examples:

@ -8,10 +8,11 @@ hackExp() Netscript Function
:param player player: The player. :param player player: The player.
:returns: The amount of exp that would be acquired if this server were to be hacked. :returns: The amount of exp that would be acquired if this server were to be hacked.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function. Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function. Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of exp obtained by hacking a server. This function calculates the amount of exp obtained by hacking a server.
@ -19,6 +20,4 @@ hackExp() Netscript Function
.. code-block:: javascript .. code-block:: javascript
server = getServer(); tprint(formulas.basic.hackExp(getServer(), getPlayer()));
server.hackDifficulty = 99.9;
tprint(formulas.basic.hackExp(server, getPlayer()));

@ -6,14 +6,15 @@ hackPercent() Netscript Function
:RAM cost: 0 GB :RAM cost: 0 GB
:param server server: The server to hack. :param server server: The server to hack.
:param player player: The player. :param player player: The player.
:returns: The percentage of money hacked from a servers maximum money. :returns: The percentage of money hacked from the server's money.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function. Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function. Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the percentage of maximum money hacked from a server. This function calculates the percentage of money hacked from a server.
Multiply this by thread count to know calculate the percentage for more than 1 thread. Multiply this by thread count to know calculate the percentage for more than 1 thread.
Examples: Examples:

@ -8,10 +8,11 @@ hackTime() Netscript Function
:param player player: The player. :param player player: The player.
:returns: The time it takes to hack this server. In seconds. :returns: The time it takes to hack this server. In seconds.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function. Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function. Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of time it takes to hack a server. This function calculates the amount of time it takes to hack a server.

@ -8,10 +8,11 @@ weakenTime() Netscript Function
:param player player: The player. :param player player: The player.
:returns: The time it takes to weaken this server. In seconds. :returns: The time it takes to weaken this server. In seconds.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function. Server can be acquired with the :doc:`getServer<../../advancedfunctions/getServer>` function.
Player can be acquired with the :doc:`getPlayer<../../singularityfunctions/getPlayer>` function. Player can be acquired with the :doc:`getPlayer<../../basicfunctions/getPlayer>` function.
This function calculates the amount of time it takes to weaken a server. This function calculates the amount of time it takes to weaken a server.

@ -6,21 +6,28 @@ constants() Netscript Function
:RAM cost: 0 GB :RAM cost: 0 GB
:returns: A structure with various constants related to hacknet nodes. :returns: A structure with various constants related to hacknet nodes.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
Returns an object with the following properties::
{
MoneyGainPerLevel: Multiplied by the node's level to get the node's base income
BaseCost: A multiplier used when buying new nodes or upgrading levels
LevelBaseCost: A multiplier used when upgrading levels
RamBaseCost: A multiplier used when upgrading RAM
CoreBaseCost: A multiplier used when buying additional cores
PurchaseNextMult: The root of an exponent used when buying new nodes
UpgradeLevelMult: The root of an exponent used when upgrading levels
UpgradeRamMult: The root of an exponent used when upgrading RAM
UpgradeCoreMult: The root of an exponent used when buying additional cores
MaxLevel: Maximum level a node can have
MaxRam: Maximum RAM a node can have
MaxCores: Maximum number of cores a node can have
}
Examples: Examples:
.. code-block:: javascript .. code-block:: javascript
{ tprint("Maximum RAM a hacknet node can have: "+formulas.hacknetNodes.constants().MaxRam+" GB.");
MoneyGainPerLevel
BaseCost
LevelBaseCost
RamBaseCost
CoreBaseCost
PurchaseNextMult
UpgradeLevelMult
UpgradeRamMult
UpgradeCoreMult
MaxLevel
MaxRam
MaxCores
}

@ -9,7 +9,8 @@ coreUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``. :param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingCores`` to ``startingCores+extraCores``. :returns: Money required to go from ``startingCores`` to ``startingCores+extraCores``.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost of upgrading cores from any level to any level. This function calculates the cost of upgrading cores from any level to any level.

@ -8,7 +8,8 @@ hacknetNodeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``. :param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to buy your ``nodeN`` th node. :returns: Money required to buy your ``nodeN`` th node.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost purchasing a hacknet node. This function calculates the cost purchasing a hacknet node.

@ -9,7 +9,8 @@ levelUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``. :param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``. :returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost of upgrading levels from any level to any level. This function calculates the cost of upgrading levels from any level to any level.

@ -9,7 +9,8 @@ moneyGainRate() Netscript Function
:param number core: cores of the node. :param number core: cores of the node.
:returns: Money per second that a node with those stats would gain per second. :returns: Money per second that a node with those stats would gain per second.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the money rate of a node with the given stats. This function calculates the money rate of a node with the given stats.

@ -11,7 +11,8 @@ ramUpgradeCost() Netscript Function
..note:: ``startingRam`` is the actual amount of ram, not the amount of levels of ram. ..note:: ``startingRam`` is the actual amount of ram, not the amount of levels of ram.
You must have Source-File 5-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function.
This function calculates the cost of upgrading levels from any level to any level. This function calculates the cost of upgrading levels from any level to any level.

@ -9,7 +9,9 @@ cacheUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``. :param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``. :returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading cache from any level to any level. This function calculates the cost of upgrading cache from any level to any level.

@ -6,24 +6,32 @@ constants() Netscript Function
:RAM cost: 0 GB :RAM cost: 0 GB
:returns: A structure with various constants related to hacknet servers. :returns: A structure with various constants related to hacknet servers.
If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
Returns an object with the following properties::
{
HashesPerLevel: Multiplied by the server's level to get the server's base income
BaseCost: A multiplier used when buying new nodes or upgrading levels
RamBaseCost: A multiplier used when upgrading RAM
CoreBaseCost: A multiplier used when buying additional cores
CacheBaseCost: A multiplier used when upgrading cache
PurchaseMult: The root of an exponent used when buying new servers
UpgradeLevelMult: The root of an exponent used when upgrading levels
UpgradeRamMult: The root of an exponent used when upgrading RAM
UpgradeCoreMult: The root of an exponent used when buying additional cores
UpgradeCacheMult: The root of an exponent used when upgrading cache
MaxServers: Maximum number of hacknet servers you can own
MaxLevel: Maximum level a server can have
MaxRam: Maximum RAM a server can have
MaxCores: Maximum number of cores a server can have
MaxCache: Maximum cache a server can have
}
Examples: Examples:
.. code-block:: javascript .. code-block:: javascript
{ tprint("Maximum RAM a hacknet server can have: "+formulas.hacknetServers.constants().MaxRam+" GB");
HashesPerLevel
BaseCost
RamBaseCost
CoreBaseCost
CacheBaseCost
PurchaseMult
UpgradeLevelMult
UpgradeRamMult
UpgradeCoreMult
UpgradeCacheMult
MaxServers
MaxLevel
MaxRam
MaxCores
MaxCache
}

@ -9,7 +9,9 @@ coreUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``. :param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingCores`` to ``startingCores+extraCores``. :returns: Money required to go from ``startingCores`` to ``startingCores+extraCores``.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading cores from any level to any level. This function calculates the cost of upgrading cores from any level to any level.

@ -8,7 +8,9 @@ hacknetServerCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``. :param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to buy your ``serverN`` th node. :returns: Money required to buy your ``serverN`` th node.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost purchasing a hacknet node. This function calculates the cost purchasing a hacknet node.

@ -10,7 +10,9 @@ hashGainRate() Netscript Function
:param number core: cores of the server. :param number core: cores of the server.
:returns: Money per second that a server with those stats would gain per second. :returns: Money per second that a server with those stats would gain per second.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the hash rate of a server with the given stats. This function calculates the hash rate of a server with the given stats.
@ -19,7 +21,7 @@ hashGainRate() Netscript Function
.. code-block:: javascript .. code-block:: javascript
server = hacknet.getNodeStats(1); server = hacknet.getNodeStats(1);
currentRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram, server.cores); currentRate = formulas.hacknetServers.hashGainRate(server.level, 0, server.ram, server.cores);
levelRate = formulas.hacknetNodes.hashGainRate(server.level+1, 0, server.ram, server.cores); levelRate = formulas.hacknetServers.hashGainRate(server.level+1, 0, server.ram, server.cores);
ramRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram*2, server.cores); ramRate = formulas.hacknetServers.hashGainRate(server.level, 0, server.ram*2, server.cores);
coresRate = formulas.hacknetNodes.hashGainRate(server.level, 0, server.ram, server.cores+1); coresRate = formulas.hacknetServers.hashGainRate(server.level, 0, server.ram, server.cores+1);

@ -8,7 +8,9 @@ hashUpgradeCost() Netscript Function
:param number level: Level of the upgrade. :param number level: Level of the upgrade.
:returns: Amount of Hash. :returns: Amount of Hash.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates amount of Hash require to buy level ``level`` of upgrade ``upgName``. This function calculates amount of Hash require to buy level ``level`` of upgrade ``upgName``.

@ -9,7 +9,9 @@ levelUpgradeCost() Netscript Function
:param number costMult: Aug multiplier that reduces cost. Defaults to ``1``. :param number costMult: Aug multiplier that reduces cost. Defaults to ``1``.
:returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``. :returns: Money required to go from ``startingLevel`` to ``startingLevel+extraLevels``.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading levels from any level to any level. This function calculates the cost of upgrading levels from any level to any level.

@ -11,7 +11,9 @@ ramUpgradeCost() Netscript Function
..note:: ``startingRam`` is the actual amount of ram, not the amount of levels of ram. ..note:: ``startingRam`` is the actual amount of ram, not the amount of levels of ram.
You must have Source-File 5-1 and Source-File 9-1 in order to use this function. If you are not in BitNode-5, then you must have Source-File 5-1 in order to
use this function. In addition, if you are not in BitNode-9, then you must
have Source-File 9-1 in order to use this function.
This function calculates the cost of upgrading levels from any level to any level. This function calculates the cost of upgrading levels from any level to any level.

@ -8,15 +8,19 @@ Netscript Formulas Functions
The formulas API allow you to gain insight into the inner workings of the game. The formulas API allow you to gain insight into the inner workings of the game.
These functions will allow you to make more informed decision. These functions will allow you to make more informed decision.
All of these function cost 0 GB of ram to use. All these function require The formulas API is unlocked in BitNode-5. If you are in BitNode-5, you will
Source-File 5-1 but some additionally need another source file level 1 to use. automatically gain access to this API. Otherwise, you must have Source-File 5-1
in order to use this API in other BitNodes. Additionally, some functions need
another source file level 1 to use.
All of these function cost 0 GB of ram to use.
basic formulas basic formulas
-------------- --------------
These functions are under the ``formulas.basic.`` name space and available as These functions are under the ``formulas.basic.`` name space and available as
soon as you acquire Source-File 5-1 soon as you enter BitNode-5 or acquire Source-File 5-1.
.. toctree:: .. toctree::
calculateSkill() <formulasapi/basic/calculateSkill> calculateSkill() <formulasapi/basic/calculateSkill>
@ -34,7 +38,7 @@ hacknetNodes formulas
--------------------- ---------------------
These functions are under the ``formulas.hacknetNodes.`` namespace and available as These functions are under the ``formulas.hacknetNodes.`` namespace and available as
soon as you acquire Source-File 5-1. soon as you enter BitNode-5 or acquire Source-File 5-1.
.. toctree:: .. toctree::
hacknetNodeCost() <formulasapi/hacknetNodes/hacknetNodeCost> hacknetNodeCost() <formulasapi/hacknetNodes/hacknetNodeCost>
@ -48,7 +52,8 @@ hacknetServers formulas
----------------------- -----------------------
These functions are under the ``formulas.hacknetServers.`` namespace. These functions are under the ``formulas.hacknetServers.`` namespace.
These functions require Source-File 5-1 and Source-File 9-1 to be invoked. These functions require either being in BitNode-5 or having Source-File 5-1, and
also require either being in BitNode-9 or having Source-File 9-1 to be invoked.
.. toctree:: .. toctree::
hacknetServerCost() <formulasapi/hacknetServers/hacknetServerCost> hacknetServerCost() <formulasapi/hacknetServers/hacknetServerCost>