mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-07 19:14:37 +01:00
Added donateToFaction(), isLogEnabled(), and getScriptLogs() Netscript functions. Added optional hacking/int level parameters to getHackTime/getGrowTime/etc functions
This commit is contained in:
@ -43,3 +43,19 @@ getBitNodeMultipliers
|
||||
mults = getBitNodeMultipliers();
|
||||
print(mults.ServerMaxMoney);
|
||||
print(mults.HackExpGain);
|
||||
|
||||
getHackTime, getGrowTime, & getWeakenTime
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The :js:func:`getHackTime`, :js:func:`getGrowTime`, and :js:func:`getWeakenTime`
|
||||
all take an additional third optional parameter for specifying a specific intelligence
|
||||
level to see how that would affect the hack/grow/weaken times. This parameter
|
||||
defaults to your current intelligence level.
|
||||
|
||||
(Intelligence is unlocked after obtaining Source-File 5).
|
||||
|
||||
The function signatures are then::
|
||||
|
||||
getHackTime(hostname/ip[, hackLvl=current level, intLvl=current level])
|
||||
getGrowTime(hostname/ip[, hackLvl=current level, intLvl=current level])
|
||||
getWeakenTime(hostname/ip[, hackLvl=current level, intLvl=current level])
|
||||
|
@ -129,6 +129,28 @@ enableLog
|
||||
Re-enables logging for the given function. If 'ALL' is passed into this function
|
||||
as an argument, then it will revert the effects of disableLog('ALL')
|
||||
|
||||
isLogEnabled
|
||||
^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: isLogEnabled(fn)
|
||||
|
||||
:param string fn: Name of function to check
|
||||
|
||||
Returns a boolean indicating whether or not logging is enabled for that
|
||||
function (or 'ALL')
|
||||
|
||||
getScriptLogs
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getScriptLogs()
|
||||
|
||||
Returns the script's logs. The logs are returned as an array, where each
|
||||
line is an element in the array. The most recently logged line is at the
|
||||
end of the array.
|
||||
|
||||
Note that there is a maximum number of lines that a script stores in its logs.
|
||||
This is configurable in the game's options.
|
||||
|
||||
scan
|
||||
^^^^
|
||||
|
||||
@ -768,7 +790,7 @@ write
|
||||
when writing to a port.
|
||||
|
||||
If the first argument is a string, then it specifies the name of a text file (.txt) and this function will write *data* to that text file. If the
|
||||
specified text file does not exist, then it will be created. The third argument *mode, defines how the data will be written to the text file. If *mode*
|
||||
specified text file does not exist, then it will be created. The third argument *mode*, defines how the data will be written to the text file. If *mode*
|
||||
is set to "w", then the data is written in "write" mode which means that it will overwrite all existing data on the text file. If *mode* is set to
|
||||
any other value then the data will be written in "append" mode which means that the data will be added at the end of the text file.
|
||||
|
||||
@ -902,30 +924,42 @@ getScriptRam
|
||||
getHackTime
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getHackTime(hostname/ip)
|
||||
.. js:function:: getHackTime(hostname/ip[, hackLvl=current level])
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
:param number hackLvl: Optional hacking level for the calculation. Defaults to player's current hacking level
|
||||
|
||||
Returns the amount of time in seconds it takes to execute the *hack()* Netscript function on the target server.
|
||||
|
||||
The function takes in an optional *hackLvl* parameter that can be specified
|
||||
to see what the hack time would be at different hacking levels.
|
||||
|
||||
getGrowTime
|
||||
^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getGrowTime(hostname/ip)
|
||||
.. js:function:: getGrowTime(hostname/ip[, hackLvl=current level])
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
:param number hackLvl: Optional hacking level for the calculation. Defaults to player's current hacking level
|
||||
|
||||
Returns the amount of time in seconds it takes to execute the *grow()* Netscript function on the target server.
|
||||
|
||||
The function takes in an optional *hackLvl* parameter that can be specified
|
||||
to see what the grow time would be at different hacking levels.
|
||||
|
||||
getWeakenTime
|
||||
^^^^^^^^^^^^^
|
||||
|
||||
.. js:function:: getWeakenTime(hostname/ip)
|
||||
.. js:function:: getWeakenTime(hostname/ip[, hackLvl=current level])
|
||||
|
||||
:param string hostname/ip: Hostname or IP of target server
|
||||
:param number hackLvl: Optional hacking level for the calculation. Defaults to player's current hacking level
|
||||
|
||||
Returns the amount of time in seconds it takes to execute the *weaken()* Netscript function on the target server.
|
||||
|
||||
The function takes in an optional *hackLvl* parameter that can be specified
|
||||
to see what the weaken time would be at different hacking levels.
|
||||
|
||||
getScriptIncome
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
|
@ -12,7 +12,7 @@ A port is implemented as a sort of serialized queue, where you can only write
|
||||
and read one element at a time from the port. When you read data from a port,
|
||||
the element that is read is removed from the port.
|
||||
|
||||
The :js:func:`read`, :js:func:`write`, :js:func:`clear`, and :js:func:`peek`
|
||||
The :js:func:`read`, :js:func:`write`, :js:func:`tryWrite`, :js:func:`clear`, and :js:func:`peek`
|
||||
Netscript functions can be used to interact with ports.
|
||||
|
||||
Right now, there are only 20 ports for Netscript, denoted by the number 1
|
||||
@ -211,36 +211,12 @@ to specify a namespace for the import::
|
||||
|
||||
Note that exporting functions is not required.
|
||||
|
||||
|
||||
Javascript Math Module
|
||||
----------------------
|
||||
|
||||
The `Javascript Math Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math>`_ is
|
||||
supported in Netscript and is used in the same way::
|
||||
|
||||
numThreads = Math.floor(getServerRam("foodnstuff")[1] / 3.4);
|
||||
|
||||
Javascript Date Module
|
||||
----------------------
|
||||
|
||||
The `Javascript Date Module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date>`_ is supported in Netscript.
|
||||
However, since the 'new' operator does not work in Netscript, only the Date module's static functions can be used:
|
||||
|
||||
* now()
|
||||
* UTC()
|
||||
* Parse()
|
||||
* Maybe some others I don't know about
|
||||
|
||||
Example::
|
||||
|
||||
time = Date.now();
|
||||
|
||||
Javascript Number Module
|
||||
------------------------
|
||||
|
||||
The `Javascript Number module <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number>`_ is supported in Netscript.
|
||||
|
||||
Example::
|
||||
|
||||
tprint(Number.isInteger(1)); //True
|
||||
tprint(Number.isInteger(1.534059)); //False
|
||||
Standard, Built-In JavaScript Objects
|
||||
-------------------------------------
|
||||
Standard built-in JavaScript objects such as
|
||||
`Math <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math>`_,
|
||||
`Date <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date>`_,
|
||||
`Number <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number>`_,
|
||||
and others are supported as expected based on which version
|
||||
of Netscript you use (i.e. :ref:`netscript1` will support built-in objects that are
|
||||
defined in ES5, and :ref:`netscriptjs` will support whatever your browser supports).
|
||||
|
@ -311,17 +311,17 @@ getCompanyFavor
|
||||
|
||||
This function will return the amount of favor you have at the specified company.
|
||||
If the company passed in as an argument is invalid, -1 will be returned.
|
||||
|
||||
|
||||
getCompanyFavorGain
|
||||
-------------------
|
||||
|
||||
.. js:function:: getCompanyFavorGain(companyName)
|
||||
|
||||
:param string companyName: Name of the company. CASE-SENSITIVE
|
||||
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
|
||||
|
||||
This function will return the amount of favor you will gain for the specified company
|
||||
|
||||
This function will return the amount of favor you will gain for the specified company
|
||||
when you reset by installing Augmentations.
|
||||
|
||||
checkFactionInvitations
|
||||
@ -398,18 +398,31 @@ getFactionFavor
|
||||
If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
|
||||
|
||||
This function returns the amount of favor you have for the specified faction.
|
||||
|
||||
|
||||
getFactionFavorGain
|
||||
-------------------
|
||||
|
||||
.. js:function:: getFactionFavorGain(factionName)
|
||||
|
||||
:param string factionName: Name of faction. CASE-SENSITIVE
|
||||
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
|
||||
|
||||
|
||||
This function returns the amount of favor you will gain for the specified faction when you reset by installing Augmentations.
|
||||
|
||||
donateToFaction
|
||||
---------------
|
||||
|
||||
.. js:function:: donateToFaction(factionName, donateAmt)
|
||||
|
||||
:param string factionName: Name of faction to donate to. CASE-SENSITIVE
|
||||
:param number donateAmt: Amount of money to donate
|
||||
|
||||
If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
|
||||
|
||||
Attempts to donate money to the specified faction in exchange for reputation.
|
||||
Returns true if you successfully donate the money, and false otherwise.
|
||||
|
||||
createProgram
|
||||
-------------
|
||||
|
||||
|
54
index.html
54
index.html
@ -2,7 +2,7 @@
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Bitburner</title>
|
||||
<title>Bitburner - development</title>
|
||||
<link rel="apple-touch-icon" sizes="180x180" href="dist/apple-touch-icon.png">
|
||||
<link rel="icon" type="image/png" sizes="32x32" href="dist/favicon-32x32.png">
|
||||
<link rel="icon" type="image/png" sizes="16x16" href="dist/favicon-16x16.png">
|
||||
@ -109,7 +109,7 @@
|
||||
|
||||
<div id="script-editor-filename-wrapper">
|
||||
<p id="script-editor-filename-tag"> <strong style="background-color:#555;">Script name: </strong></p>
|
||||
<input id="script-editor-filename" type="text" maxlength="30" tabindex="1"/>
|
||||
<input id="script-editor-filename" type="text" maxlength="30" tabindex="1" />
|
||||
</div>
|
||||
|
||||
<div id="javascript-editor"></div>
|
||||
@ -159,7 +159,7 @@
|
||||
|
||||
<fieldset>
|
||||
<label for="script-editor-option-maxerr" class="tooltip">Max Error Count</label>
|
||||
<input type="range" max="1000" min="50" value="200" step="1" name="script-editor-option-maxerr" id="script-editor-option-maxerr"/>
|
||||
<input type="range" max="1000" min="50" value="200" step="1" name="script-editor-option-maxerr" id="script-editor-option-maxerr" />
|
||||
<em id="script-editor-option-maxerror-value-label" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
</div> <!-- End script editor options panel -->
|
||||
@ -170,7 +170,7 @@
|
||||
<table id="terminal">
|
||||
<tr id="terminal-input">
|
||||
<td id="terminal-input-td" tabindex="2">$
|
||||
<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" onfocus="this.value = this.value;"/>
|
||||
<input type="text" id="terminal-input-text-box" class="terminal-input" tabindex="1" onfocus="this.value = this.value;" />
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
@ -187,7 +187,7 @@
|
||||
provides information about each script's production. The scripts are categorized by the hostname of the servers on which
|
||||
they are running. </p>
|
||||
<p id="active-scripts-total-prod">Total online production of
|
||||
Active scripts: <span class="money-gold"><span id="active-scripts-total-production-active">$0.000</span> / sec</span><br/>
|
||||
Active scripts: <span class="money-gold"><span id="active-scripts-total-production-active">$0.000</span> / sec</span><br />
|
||||
Total online production since last Aug installation: <span id="active-scripts-total-prod-aug-total" class="money-gold">$0.000</span>
|
||||
(<span class="money-gold"><span id="active-scripts-total-prod-aug-avg" class="money-gold">$0.000</span> / sec</span>)</p>
|
||||
<ul class="active-scripts-list" id="active-scripts-list" style="list-style: none;">
|
||||
@ -201,19 +201,19 @@
|
||||
The Hacknet is a global, decentralized network of machines. It is used by hackers all around
|
||||
the world to anonymously share computing power and perform distributed cyberattacks without the
|
||||
fear of being traced.
|
||||
<br/><br/>
|
||||
<br /><br />
|
||||
Here, you can purchase a Hacknet Node, a specialized machine that can connect and contribute its
|
||||
resources to the Hacknet network. This allows you to take a small percentage of profits
|
||||
from hacks performed on the network. Essentially, you are renting out your Node's computing power.
|
||||
<br/><br/>
|
||||
<br /><br />
|
||||
Each Hacknet Node you purchase will passively earn you money. Each Hacknet Node can be upgraded
|
||||
in order to increase its computing power and thereby increase the profit you earn from it.
|
||||
</p>
|
||||
<a id="hacknet-nodes-purchase-button" class="a-link-button"> Purchase Hacknet Node </a>
|
||||
<br/>
|
||||
<br />
|
||||
<div id="hacknet-nodes-money-multipliers-div">
|
||||
<p id="hacknet-nodes-money">
|
||||
<span>Money:</span><span id="hacknet-nodes-player-money" class="money-gold"></span><br/>
|
||||
<span>Money:</span><span id="hacknet-nodes-player-money" class="money-gold"></span><br />
|
||||
<span>Total Hacknet Node Production:</span><span id="hacknet-nodes-total-production" class="money-gold"></span>
|
||||
</p>
|
||||
<span id="hacknet-nodes-multipliers">
|
||||
@ -471,7 +471,8 @@
|
||||
|
||||
<!-- Tutorial content -->
|
||||
<div id="tutorial-container" class="generic-menupage-container">
|
||||
<a id="tutorial-getting-started-link" class="a-link-button" href="http://bitburner.wikia.com/wiki/Chapt3rs_Guide_to_Getting_Started_with_Bitburner" target="_blank"> Getting Started </a>
|
||||
<a id="tutorial-getting-started-link" class="a-link-button"
|
||||
href="http://bitburner.wikia.com/wiki/Chapt3rs_Guide_to_Getting_Started_with_Bitburner" target="_blank"> Getting Started </a>
|
||||
<a id="tutorial-networking-link" class="a-link-button"> Servers & Networking </a>
|
||||
<a id="tutorial-hacking-link" class="a-link-button"> Hacking </a>
|
||||
<a id="tutorial-scripts-link" class="a-link-button"> Scripts </a>
|
||||
@ -480,7 +481,8 @@
|
||||
<a id="tutorial-jobs-link" class="a-link-button"> Companies and Infiltration </a>
|
||||
<a id="tutorial-factions-link" class="a-link-button"> Factions </a>
|
||||
<a id="tutorial-augmentations-link" class="a-link-button"> Augmentations </a>
|
||||
<a id="tutorial-shortcuts-link" class="a-link-button" href="https://bitburner.wikia.com/wiki/Shortcuts" target="_blank"> Keyboard Shortcuts </a>
|
||||
<a id="tutorial-shortcuts-link" class="a-link-button"
|
||||
href="https://bitburner.wikia.com/wiki/Shortcuts" target="_blank"> Keyboard Shortcuts </a>
|
||||
|
||||
<a id="tutorial-back-button" class="a-link-button"> Back </a>
|
||||
<p id="tutorial-text"> </p>
|
||||
@ -623,7 +625,7 @@
|
||||
<p id="location-slums-description">
|
||||
You have entered the Slums, a poverty-ridden district filled with gangs, criminals, and
|
||||
other shadowy entities. The city's government and police have neglected this area for years...
|
||||
<br/><br/><br/>
|
||||
<br /><br /><br />
|
||||
In the Slums, you can commit crimes to earn money and experience. Crime attempts are not always
|
||||
successful. Your chance at successfully committing a crime is determined by your stats.
|
||||
</p>
|
||||
@ -670,7 +672,7 @@
|
||||
|
||||
<div id="stock-market-container" class="generic-menupage-container">
|
||||
<p>
|
||||
Welcome to the World Stock Exchange (WSE)! <br/><br/>
|
||||
Welcome to the World Stock Exchange (WSE)! <br /><br />
|
||||
|
||||
To begin trading, you must first purchase an account. WSE accounts will persist
|
||||
after you 'reset' by installing Augmentations.
|
||||
@ -683,7 +685,7 @@
|
||||
TIX, short for Trade Information eXchange, is the communications protocol supported by the WSE.
|
||||
Purchasing access to the TIX API lets you write code to create your own algorithmic/automated
|
||||
trading strategies.
|
||||
<br/><br/>
|
||||
<br /><br />
|
||||
If you purchase access to the TIX API, you will retain that access even after
|
||||
you 'reset' by installing Augmentations.
|
||||
</p>
|
||||
@ -693,7 +695,7 @@
|
||||
<p>
|
||||
Four Sigma's (4S) Market Data Feed provides information about stocks
|
||||
that will help your trading strategies.
|
||||
<br/><br/>
|
||||
<br /><br />
|
||||
If you purchase access to 4S Market Data and/or the 4S TIX API, you will
|
||||
retain that access even after you 'reset' by installing Augmentations.
|
||||
</p>
|
||||
@ -711,7 +713,7 @@
|
||||
<a id="stock-market-mode" class="a-link-button tooltip"></a>
|
||||
<a id="stock-market-expand-tickers" class="a-link-button tooltip">Expand tickers</a>
|
||||
<a id="stock-market-collapse-tickers" class="a-link-button tooltip">Collapse tickers</a>
|
||||
<br/><br/>
|
||||
<br /><br />
|
||||
<input id="stock-market-watchlist-filter" type="text" placeholder="Filter Stocks by symbol (comma-separated list)"/>
|
||||
<a id="stock-market-watchlist-filter-update" class="a-link-button"> Update Watchlist </a>
|
||||
<ul id="stock-market-list" style="list-style:none;">
|
||||
@ -741,7 +743,7 @@
|
||||
<div id="yes-no-text-input-box-container" class="popup-box-container">
|
||||
<div id="yes-no-text-input-box-content" class="popup-box-content">
|
||||
<p id="yes-no-text-input-box-text"> </p>
|
||||
<input type="text" id="yes-no-text-input-box-input" pattern="[a-zA-Z0-9-_]" maxlength="30"/>
|
||||
<input type="text" id="yes-no-text-input-box-input" pattern="[a-zA-Z0-9-_]" maxlength="30" />
|
||||
<span id="yes-no-text-input-box-yes" class="popup-box-button"> Yes </span>
|
||||
<span id="yes-no-text-input-box-no" class="popup-box-button"> No </span>
|
||||
</div>
|
||||
@ -753,7 +755,7 @@
|
||||
<p id="faction-invitation-box-text"> </p>
|
||||
<p id="faction-invitation-box-message"> </p>
|
||||
<p id="faction-invitation-box-warning">
|
||||
Would you like to join? <br/> <br/>
|
||||
Would you like to join? <br /> <br />
|
||||
Warning: Joining this faction may prevent you from joining other factions during this run!
|
||||
</p>
|
||||
<span id="faction-invitation-box-yes" class="popup-box-button"> Yes </span>
|
||||
@ -766,8 +768,8 @@
|
||||
<div id="infiltration-box-content" class="popup-box-content">
|
||||
<p id="infiltration-box-text"> </p>
|
||||
|
||||
<span id="infiltration-box-sell" class="a-link-button"> Sell on Black Market </span> <br/><br/>
|
||||
<select id="infiltration-faction-select"> </select> <br/>
|
||||
<span id="infiltration-box-sell" class="a-link-button"> Sell on Black Market </span> <br /><br />
|
||||
<select id="infiltration-faction-select"> </select> <br />
|
||||
<span id="infiltration-box-faction" class="a-link-button"> Give to Faction for Reputation </span>
|
||||
|
||||
</div>
|
||||
@ -853,7 +855,7 @@
|
||||
<div id="game-options-content" class="game-options-box">
|
||||
<span id="game-options-close-button">×</span>
|
||||
<h1> Game Options </h1>
|
||||
<br/>
|
||||
<br />
|
||||
<div id="game-options-left-panel">
|
||||
<!-- Netscript execution time -->
|
||||
<fieldset>
|
||||
@ -865,7 +867,7 @@
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type="range" max="100" min="10" step="1" name="settingsNSExecTimeRangeVal" id="settingsNSExecTimeRangeVal" value="25"/>
|
||||
<input type ="range" max="100" min="10" step="1" name="settingsNSExecTimeRangeVal" id="settingsNSExecTimeRangeVal" value="25" />
|
||||
<em id="settingsNSExecTimeRangeValLabel" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
|
||||
@ -879,7 +881,7 @@
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type="range" max="100" min="20" step="1" name="settingsNSLogRangeVal" id="settingsNSLogRangeVal" value="50"/>
|
||||
<input type="range" max="100" min="20" step="1" name="settingsNSLogRangeVal" id="settingsNSLogRangeVal" value="50" />
|
||||
<em id="settingsNSLogRangeValLabel" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
|
||||
@ -893,7 +895,7 @@
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type="range" max="100" min="20" step="1" name="settingsNSPortRangeVal" id="settingsNSPortRangeVal" value="50"/>
|
||||
<input type="range" max="100" min="20" step="1" name="settingsNSPortRangeVal" id="settingsNSPortRangeVal" value="50" />
|
||||
<em id="settingsNSPortRangeValLabel" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
|
||||
@ -905,7 +907,7 @@
|
||||
</span>
|
||||
</label>
|
||||
|
||||
<input type="range" max="600" min="0" step="1" name="settingsAutosaveIntervalVal" id="settingsAutosaveIntervalVal" value="60"/>
|
||||
<input type="range" max="600" min="0" step="1" name="settingsAutosaveIntervalVal" id="settingsAutosaveIntervalVal" value="60" />
|
||||
<em id="settingsAutosaveIntervalValLabel" style="font-style: normal;"></em>
|
||||
</fieldset>
|
||||
|
||||
@ -991,7 +993,7 @@
|
||||
<a id="save-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Save Game </a>
|
||||
<a id="delete-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Delete Game </a>
|
||||
<a id="export-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Export Game </a>
|
||||
<input type="file" id="import-game-file-selector" name="file"/>
|
||||
<input type="file" id="import-game-file-selector" name="file" />
|
||||
<a id="import-game-link" class="a-link-button" style="display:inline-block;width:46%;"> Import Game </a>
|
||||
<a id="debug-delete-scripts-link" class="a-link-button tooltip" style="display:block;width:46%;">
|
||||
(DEBUG) Delete Active Scripts
|
||||
|
10
netscript.js
10
netscript.js
@ -60,7 +60,7 @@ var identifierRe = "[a-zA-Z\\$_\u00a1-\uffff][a-zA-Z\\d\\$_\u00a1-\uffff]*";
|
||||
|
||||
let NetscriptFunctions =
|
||||
"hack|sleep|grow|weaken|print|tprint|scan|nuke|brutessh|ftpcrack|" + //Netscript functions
|
||||
"clearLog|disableLog|enableLog|" +
|
||||
"clearLog|disableLog|enableLog|isLogEnabled|getScriptLogs|" +
|
||||
"relaysmtp|httpworm|sqlinject|run|exec|spawn|kill|killall|exit|" +
|
||||
"scp|ls|hasRootAccess|" +
|
||||
"getIp|getHackingMultipliers|getBitNodeMultipliers|getStats|isBusy|" +
|
||||
@ -73,22 +73,28 @@ let NetscriptFunctions =
|
||||
"deleteServer|getPurchasedServers|" +
|
||||
"getPurchasedServerLimit|getPurchasedServerMaxRam|" +
|
||||
"getPurchasedServerCost|" +
|
||||
"purchaseServer|round|write|read|peek|clear|rm|getPortHandle|" +
|
||||
"purchaseServer|round|write|tryWrite|read|peek|clear|rm|getPortHandle|" +
|
||||
"scriptRunning|scriptKill|getScriptName|getScriptRam|" +
|
||||
"getHackTime|getGrowTime|getWeakenTime|getScriptIncome|getScriptExpGain|" +
|
||||
"getTimeSinceLastAug|prompt|" +
|
||||
|
||||
//Singularity Functions
|
||||
"universityCourse|getCharacterInformation|" +
|
||||
"gymWorkout|travelToCity|purchaseTor|purchaseProgram|upgradeHomeRam|" +
|
||||
"getUpgradeHomeRamCost|workForCompany|applyToCompany|getCompanyRep|" +
|
||||
"getCompanyFavor|stopAction|getFactionFavor|" +
|
||||
"getFavorToDonate|getFactionFavorGain|getCompanyFavorGain|" +
|
||||
"checkFactionInvitations|joinFaction|workForFaction|getFactionRep|" +
|
||||
"donateToFaction|" +
|
||||
"createProgram|commitCrime|getCrimeChance|getOwnedAugmentations|" +
|
||||
"getOwnedSourceFiles|getAugmentationsFromFaction|" +
|
||||
"getAugmentationCost|purchaseAugmentation|" +
|
||||
"installAugmentations|" +
|
||||
|
||||
//TIX API
|
||||
"getStockPrice|getStockPosition|buyStock|sellStock|shortStock|sellShort|" +
|
||||
"placeOrder|cancelOrder|" +
|
||||
|
||||
//Hacknet Node API
|
||||
"hacknet|numNodes|purchaseNode|getPurchaseNodeCost|getNodeStats|" +
|
||||
"upgradeLevel|upgradeRam|upgradeCore|getLevelUpgradeCost|" +
|
||||
|
@ -35,6 +35,7 @@ let CONSTANTS = {
|
||||
|
||||
/* Faction and Company favor */
|
||||
BaseFavorToDonate: 150,
|
||||
DonateMoneyToRepDivisor: 1e6,
|
||||
FactionReputationToFavorBase: 500,
|
||||
FactionReputationToFavorMult: 1.02,
|
||||
CompanyReputationToFavorBase: 500,
|
||||
@ -508,6 +509,10 @@ let CONSTANTS = {
|
||||
* Increased the range of possible values for initial stock prices<br>
|
||||
* b1t_flum3.exe program can now be created immediately at Hacking level 1 (rather than hacking level 5)<br>
|
||||
* UI improvements for the character overview panel and the left-hand menu (by mat-jaworski)<br>
|
||||
* General UI improvements for displays and Terminal (by mat-jaworski)<br>
|
||||
* Added optional parameters to the getHackTime(), getGrowTime(), and getWeakenTime() Netscript functions<br>
|
||||
* Added isLogEnabled() and getScriptLogs() Netscript functions<br>
|
||||
* Added donateToFaction() Singularity function<br>
|
||||
* Updated documentation to reflect the fact that Netscript port handles (getPortHandle()) only works in NetscriptJS (2.0), NOT Netscript 1.0<br>
|
||||
* Added tryWrite() Netscript function<br>
|
||||
* When working (for a company/faction), experience is gained immediately/continuously rather than all at once when the work is finished<br>
|
||||
|
@ -319,7 +319,7 @@ function displayFactionContent(factionName) {
|
||||
if (isNaN(amt)) {
|
||||
donateRepGain.innerText = "Invalid donate amount entered!";
|
||||
} else {
|
||||
var repGain = amt / 1e6 * Player.faction_rep_mult;
|
||||
var repGain = amt / CONSTANTS.DonateMoneyToRepDivisor * Player.faction_rep_mult;
|
||||
donateRepGain.innerText = "This donation will result in " +
|
||||
formatNumber(repGain, 3) + " reputation gain";
|
||||
}
|
||||
@ -335,7 +335,7 @@ function displayFactionContent(factionName) {
|
||||
dialogBoxCreate("You cannot afford to donate this much money!");
|
||||
} else {
|
||||
Player.loseMoney(amt);
|
||||
var repGain = amt / 1e6 * Player.faction_rep_mult;
|
||||
var repGain = amt / CONSTANTS.DonateMoneyToRepDivisor * Player.faction_rep_mult;
|
||||
faction.playerReputation += repGain;
|
||||
dialogBoxCreate("You just donated " + numeral(amt).format("$0.000a") + " to " +
|
||||
faction.name + " to gain " + formatNumber(repGain, 3) + " reputation");
|
||||
|
@ -54,16 +54,18 @@ export function calculatePercentMoneyHacked(server) {
|
||||
/**
|
||||
* Returns time it takes to complete a hack on a server, in seconds
|
||||
*/
|
||||
export function calculateHackingTime(server) {
|
||||
export function calculateHackingTime(server, hack, int) {
|
||||
const difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
|
||||
|
||||
const baseDiff = 500;
|
||||
const baseSkill = 50;
|
||||
const diffFactor = 2.5;
|
||||
const intFactor = 0.1;
|
||||
if (hack == null) {hack = Player.hacking_skill;}
|
||||
if (int == null) {int = Player.intelligence;}
|
||||
var skillFactor = (diffFactor * difficultyMult + baseDiff);
|
||||
// tslint:disable-next-line
|
||||
skillFactor /= (Player.hacking_skill + baseSkill + (intFactor * Player.intelligence));
|
||||
skillFactor /= (hack + baseSkill + (intFactor * int));
|
||||
|
||||
const hackTimeMultiplier = 5;
|
||||
const hackingTime = hackTimeMultiplier * skillFactor / Player.hacking_speed_mult;
|
||||
@ -74,17 +76,17 @@ export function calculateHackingTime(server) {
|
||||
/**
|
||||
* Returns time it takes to complete a grow operation on a server, in seconds
|
||||
*/
|
||||
export function calculateGrowTime(server) {
|
||||
export function calculateGrowTime(server, hack, int) {
|
||||
const growTimeMultiplier = 3.2; // Relative to hacking time. 16/5 = 3.2
|
||||
|
||||
return growTimeMultiplier * calculateHackingTime(server);
|
||||
return growTimeMultiplier * calculateHackingTime(server, hack, int);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns time it takes to complete a weaken operation on a server, in seconds
|
||||
*/
|
||||
export function calculateWeakenTime(server) {
|
||||
export function calculateWeakenTime(server, hack, int) {
|
||||
const weakenTimeMultiplier = 4; // Relative to hacking time
|
||||
|
||||
return weakenTimeMultiplier * calculateHackingTime(server);
|
||||
return weakenTimeMultiplier * calculateHackingTime(server, hack, int);
|
||||
}
|
||||
|
@ -121,6 +121,7 @@ var possibleLogs = {
|
||||
applyToCompany: true,
|
||||
joinFaction: true,
|
||||
workForFaction: true,
|
||||
donateToFaction: true,
|
||||
createProgram: true,
|
||||
commitCrime: true,
|
||||
shortStock: true,
|
||||
@ -507,6 +508,17 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("Enabled logging for " + fn);
|
||||
}
|
||||
},
|
||||
isLogEnabled : function(fn) {
|
||||
if (workerScript.checkingRam) {return 0;}
|
||||
if (possibleLogs[fn] === undefined) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Invalid argument to isLogEnabled: " + fn);
|
||||
}
|
||||
return workerScript.disableLogs[fn] ? false : true;
|
||||
},
|
||||
getScriptLogs : function() {
|
||||
if (workerScript.checkingRam) {return 0;}
|
||||
return workerScript.scriptRef.logs.slice();
|
||||
},
|
||||
nuke : function(ip){
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("nuke", CONSTANTS.ScriptPortProgramRamCost);
|
||||
@ -2071,7 +2083,7 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
return 0;
|
||||
},
|
||||
getHackTime : function(ip) {
|
||||
getHackTime : function(ip, hack, int) {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getHackTime", CONSTANTS.ScriptGetHackTimeRamCost);
|
||||
}
|
||||
@ -2081,9 +2093,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
return calculateHackingTime(server); //Returns seconds
|
||||
return calculateHackingTime(server, hack, int); //Returns seconds
|
||||
},
|
||||
getGrowTime : function(ip) {
|
||||
getGrowTime : function(ip, hack, int) {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getGrowTime", CONSTANTS.ScriptGetHackTimeRamCost);
|
||||
}
|
||||
@ -2093,9 +2105,9 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
return calculateGrowTime(server); //Returns seconds
|
||||
return calculateGrowTime(server, hack, int); //Returns seconds
|
||||
},
|
||||
getWeakenTime : function(ip) {
|
||||
getWeakenTime : function(ip, hack, int) {
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("getWeakenTime", CONSTANTS.ScriptGetHackTimeRamCost);
|
||||
}
|
||||
@ -2105,7 +2117,7 @@ function NetscriptFunctions(workerScript) {
|
||||
workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||
throw makeRuntimeRejectMsg(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||
}
|
||||
return calculateWeakenTime(server); //Returns seconds
|
||||
return calculateWeakenTime(server, hack, int); //Returns seconds
|
||||
},
|
||||
getScriptIncome : function(scriptname, ip) {
|
||||
if (workerScript.checkingRam) {
|
||||
@ -3056,7 +3068,7 @@ function NetscriptFunctions(workerScript) {
|
||||
|
||||
return Factions[name].favor;
|
||||
},
|
||||
getFactionFavorGain: function(name){
|
||||
getFactionFavorGain: function(name) {
|
||||
var ramCost = CONSTANTS.ScriptSingularityFn2RamCost;
|
||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||
if (workerScript.checkingRam) {
|
||||
@ -3077,6 +3089,45 @@ function NetscriptFunctions(workerScript) {
|
||||
|
||||
return Factions[name].getFavorGain()[0];
|
||||
},
|
||||
donateToFaction : function(name, amt) {
|
||||
var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;
|
||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||
if (workerScript.checkingRam) {
|
||||
return updateStaticRam("donateToFaction", ramCost);
|
||||
}
|
||||
updateDynamicRam("donateToFaction", ramCost);
|
||||
if (Player.bitNodeN != 4) {
|
||||
if (!(hasSingularitySF && singularitySFLvl >= 3)) {
|
||||
throw makeRuntimeRejectMsg(workerScript, "Cannot run donateToFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!factionExists(name)) {
|
||||
workerScript.log(`ERROR: Faction specified in donateToFaction() does not exist: ${name}`);
|
||||
return false;
|
||||
}
|
||||
if (typeof amt !== 'number' || amt <= 0) {
|
||||
workerScript.log(`ERROR: Invalid donation amount specified in donateToFaction(): ${amt}. Must be numeric and positive`);
|
||||
return false;
|
||||
}
|
||||
if (Player.money.lt(amt)) {
|
||||
workerScript.log(`ERROR: You do not have enough money to donate $${amt} to ${name}`);
|
||||
return false;
|
||||
}
|
||||
var repNeededToDonate = Math.round(CONSTANTS.BaseFavorToDonate * BitNodeMultipliers.RepToDonateToFaction);
|
||||
if (Factions[name].favor < repNeededToDonate) {
|
||||
workerScript.log(`ERROR: You do not have enough favor to donate to this faction. Have ${Factions[name].favor}, need ${repNeededToDonate}`);
|
||||
return false;
|
||||
}
|
||||
var repGain = amt / CONSTANTS.DonateMoneyToRepDivisor * Player.faction_rep_mult;
|
||||
Factions[name].playerReputation += repGain;
|
||||
Player.loseMoney(amt);
|
||||
if (workerScript.shouldLog("donateToFaction")) {
|
||||
workerScript.log(`$${amt} donated to ${name} for ${repGain} reputation`);
|
||||
}
|
||||
return true;
|
||||
},
|
||||
createProgram : function(name) {
|
||||
var ramCost = CONSTANTS.ScriptSingularityFn3RamCost;
|
||||
if (Player.bitNodeN !== 4) {ramCost *= 8;}
|
||||
|
Reference in New Issue
Block a user