mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
748 lines
40 KiB
HTML
748 lines
40 KiB
HTML
|
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
|
|
<html xmlns="http://www.w3.org/1999/xhtml" lang="English">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
|
<title>Netscript Bladeburner API — Bitburner 1.0 documentation</title>
|
|
<link rel="stylesheet" href="_static/agogo.css" type="text/css" />
|
|
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
|
|
<script type="text/javascript">
|
|
var DOCUMENTATION_OPTIONS = {
|
|
URL_ROOT: './',
|
|
VERSION: '1.0',
|
|
COLLAPSE_INDEX: false,
|
|
FILE_SUFFIX: '.html',
|
|
HAS_SOURCE: true,
|
|
SOURCELINK_SUFFIX: '.txt'
|
|
};
|
|
</script>
|
|
<script type="text/javascript" src="_static/jquery.js"></script>
|
|
<script type="text/javascript" src="_static/underscore.js"></script>
|
|
<script type="text/javascript" src="_static/doctools.js"></script>
|
|
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.1/MathJax.js?config=TeX-AMS-MML_HTMLorMML"></script>
|
|
<link rel="index" title="Index" href="genindex.html" />
|
|
<link rel="search" title="Search" href="search.html" />
|
|
<link rel="next" title="Netscript Miscellaneous" href="netscriptmisc.html" />
|
|
<link rel="prev" title="Netscript Singularity Functions" href="netscriptsingularityfunctions.html" />
|
|
</head>
|
|
<body>
|
|
<div class="header-wrapper" role="banner">
|
|
<div class="header">
|
|
<div class="headertitle"><a
|
|
href="index.html">Bitburner 1.0 documentation</a></div>
|
|
<div class="rel" role="navigation" aria-label="related navigation">
|
|
<a href="netscriptsingularityfunctions.html" title="Netscript Singularity Functions"
|
|
accesskey="P">previous</a> |
|
|
<a href="netscriptmisc.html" title="Netscript Miscellaneous"
|
|
accesskey="N">next</a> |
|
|
<a href="genindex.html" title="General Index"
|
|
accesskey="I">index</a>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="content-wrapper">
|
|
<div class="content">
|
|
<div class="document">
|
|
|
|
<div class="documentwrapper">
|
|
<div class="bodywrapper">
|
|
<div class="body" role="main">
|
|
|
|
<div class="section" id="netscript-bladeburner-api">
|
|
<h1>Netscript Bladeburner API<a class="headerlink" href="#netscript-bladeburner-api" title="Permalink to this headline">¶</a></h1>
|
|
<p>Netscript provides the following API for interacting with the game's Bladeburner mechanic.</p>
|
|
<p>The Bladeburner API is <strong>not</strong> immediately available to the palyer and must be unlocked
|
|
later in the game</p>
|
|
<p><strong>WARNING: This page contains spoilers for the game</strong></p>
|
|
<p>The Bladeburner API is unlocked in BitNode-7. If you are in BitNode-7, you will
|
|
automatically gain access to this API. Otherwise, you must have Source-File 7 in
|
|
order to use this API in other BitNodes</p>
|
|
<p><strong>Bladeburner API functions must be accessed through the bladeburner namespace</strong></p>
|
|
<p>In Netscript 1.0:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getContractNames</span><span class="p">();</span>
|
|
<span class="n">bladeburner</span><span class="o">.</span><span class="n">startAction</span><span class="p">(</span><span class="s2">"general"</span><span class="p">,</span> <span class="s2">"Training"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>In <a class="reference internal" href="netscriptjs.html#netscriptjs"><span class="std std-ref">NetscriptJS (Netscript 2.0)</span></a>:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">ns</span><span class="o">.</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getContractNames</span><span class="p">();</span>
|
|
<span class="n">ns</span><span class="o">.</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">startAction</span><span class="p">(</span><span class="s2">"general"</span><span class="p">,</span> <span class="s2">"Training"</span><span class="p">);</span>
|
|
</pre></div>
|
|
</div>
|
|
<div class="section" id="bladeburner-action-types">
|
|
<span id="id1"></span><h2>Bladeburner Action Types<a class="headerlink" href="#bladeburner-action-types" title="Permalink to this headline">¶</a></h2>
|
|
<p>Several functions in the Bladeburner API require you to specify an action using
|
|
its type and name. The following are valid values when specifying the action's type:</p>
|
|
<dl class="docutils">
|
|
<dt><strong>Contracts</strong></dt>
|
|
<dd><ul class="first last simple">
|
|
<li>contract</li>
|
|
<li>contracts</li>
|
|
<li>contr</li>
|
|
</ul>
|
|
</dd>
|
|
<dt><strong>Operations</strong></dt>
|
|
<dd><ul class="first last simple">
|
|
<li>operation</li>
|
|
<li>operations</li>
|
|
<li>op</li>
|
|
<li>ops</li>
|
|
</ul>
|
|
</dd>
|
|
<dt><strong>Black Ops</strong></dt>
|
|
<dd><ul class="first last simple">
|
|
<li>blackoperation</li>
|
|
<li>black operation</li>
|
|
<li>black operations</li>
|
|
<li>black op</li>
|
|
<li>black ops</li>
|
|
<li>blackop</li>
|
|
<li>blackops</li>
|
|
</ul>
|
|
</dd>
|
|
<dt><strong>General Actions (Training, Field Analysis, Recruitment)</strong></dt>
|
|
<dd><ul class="first last simple">
|
|
<li>general</li>
|
|
<li>general action</li>
|
|
<li>gen</li>
|
|
</ul>
|
|
</dd>
|
|
</dl>
|
|
</div>
|
|
<div class="section" id="getcontractnames">
|
|
<h2>getContractNames<a class="headerlink" href="#getcontractnames" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getContractNames">
|
|
<code class="descname">getContractNames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getContractNames" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an array of strings containing the names of all Bladeburner contracts</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getoperationnames">
|
|
<h2>getOperationNames<a class="headerlink" href="#getoperationnames" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getOperationNames">
|
|
<code class="descname">getOperationNames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getOperationNames" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an array of strings containing the names of all Bladeburner operations</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getblackopnames">
|
|
<h2>getBlackOpNames<a class="headerlink" href="#getblackopnames" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getBlackOpNames">
|
|
<code class="descname">getBlackOpNames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getBlackOpNames" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an array of strings containing the names of all Bladeburner Black Ops</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getgeneralactionnames">
|
|
<h2>getGeneralActionNames<a class="headerlink" href="#getgeneralactionnames" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getGeneralActionNames">
|
|
<code class="descname">getGeneralActionNames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getGeneralActionNames" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an array of strings containing the names of all general Bladeburner actions</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getskillnames">
|
|
<h2>getSkillNames<a class="headerlink" href="#getskillnames" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getSkillNames">
|
|
<code class="descname">getSkillNames</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getSkillNames" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an array of strings containing the names of all Bladeburner skills</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="startaction">
|
|
<h2>startAction<a class="headerlink" href="#startaction" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="startAction">
|
|
<code class="descname">startAction</code><span class="sig-paren">(</span><em>type</em>, <em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#startAction" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>type</strong> (<em>string</em>) -- Type of action. See <a class="reference internal" href="#bladeburner-action-types"><span class="std std-ref">Bladeburner Action Types</span></a></li>
|
|
<li><strong>name</strong> (<em>string</em>) -- Name of action. Must be an exact match</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Attempts to start the specified Bladeburner action. Returns true if the action
|
|
was started successfully, and false otherwise.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="stopbladeburneraction">
|
|
<h2>stopBladeburnerAction<a class="headerlink" href="#stopbladeburneraction" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="stopBladeburnerAction">
|
|
<code class="descname">stopBladeburnerAction</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#stopBladeburnerAction" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Stops the current Bladeburner action</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getactiontime">
|
|
<h2>getActionTime<a class="headerlink" href="#getactiontime" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getActionTime">
|
|
<code class="descname">getActionTime</code><span class="sig-paren">(</span><em>type</em>, <em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#getActionTime" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>type</strong> (<em>string</em>) -- Type of action. See <a class="reference internal" href="#bladeburner-action-types"><span class="std std-ref">Bladeburner Action Types</span></a></li>
|
|
<li><strong>name</strong> (<em>string</em>) -- Name of action. Must be an exact match</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the number of seconds it takes to complete the specified action</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getactionestimatedsuccesschance">
|
|
<h2>getActionEstimatedSuccessChance<a class="headerlink" href="#getactionestimatedsuccesschance" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getActionEstimatedSuccessChance">
|
|
<code class="descname">getActionEstimatedSuccessChance</code><span class="sig-paren">(</span><em>type</em>, <em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#getActionEstimatedSuccessChance" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>type</strong> (<em>string</em>) -- Type of action. See <a class="reference internal" href="#bladeburner-action-types"><span class="std std-ref">Bladeburner Action Types</span></a></li>
|
|
<li><strong>name</strong> (<em>string</em>) -- Name of action. Must be an exact match</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the estimated success chance for the specified action</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getactioncountremaining">
|
|
<h2>getActionCountRemaining<a class="headerlink" href="#getactioncountremaining" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getActionCountRemaining">
|
|
<code class="descname">getActionCountRemaining</code><span class="sig-paren">(</span><em>type</em>, <em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#getActionCountRemaining" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>type</strong> (<em>string</em>) -- Type of action. See <a class="reference internal" href="#bladeburner-action-types"><span class="std std-ref">Bladeburner Action Types</span></a></li>
|
|
<li><strong>name</strong> (<em>string</em>) -- Name of action. Must be an exact match</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the remaining count of the specified action.</p>
|
|
<p>Note that this is meant to be used for Contracts and Operations.
|
|
This function will return 'Infinity' for actions such as Training and Field Analysis.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getrank">
|
|
<h2>getRank<a class="headerlink" href="#getrank" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getRank">
|
|
<code class="descname">getRank</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getRank" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the player's Bladeburner Rank</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getskillpoints">
|
|
<h2>getSkillPoints<a class="headerlink" href="#getskillpoints" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getSkillPoints">
|
|
<code class="descname">getSkillPoints</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getSkillPoints" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns the number of Bladeburner skill points you have</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getskilllevel">
|
|
<h2>getSkillLevel<a class="headerlink" href="#getskilllevel" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getSkillLevel">
|
|
<code class="descname">getSkillLevel</code><span class="sig-paren">(</span><em>skillName=""</em><span class="sig-paren">)</span><a class="headerlink" href="#getSkillLevel" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>skillName</strong> (<em>string</em>) -- Optional name of Skill. Empty string by default</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>If no argument or an empty string is passed in, this function returns
|
|
an object with your level for all Bladeburner Skills (only for skills that
|
|
have at least one level). In the object, the name of the Bladeburner Skills
|
|
are the keys and your skill levels are the values. For example:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="p">{</span>
|
|
<span class="s2">"Blade's Intuition"</span><span class="p">:</span> <span class="mi">10</span><span class="p">,</span>
|
|
<span class="s2">"Cloak"</span><span class="p">:</span> <span class="mi">5</span><span class="p">,</span>
|
|
<span class="s2">"Evasive System"</span><span class="p">:</span> <span class="mi">6</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
<p>If the name of a skill is passed in as an argument, then this function
|
|
returns your level in the specified skill.</p>
|
|
<p>The function returns -1 if an invalid skill name is passed in</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="upgradeskill">
|
|
<h2>upgradeSkill<a class="headerlink" href="#upgradeskill" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="upgradeSkill">
|
|
<code class="descname">upgradeSkill</code><span class="sig-paren">(</span><em>skillName</em><span class="sig-paren">)</span><a class="headerlink" href="#upgradeSkill" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>skillName</strong> (<em>string</em>) -- Name of Skill to be upgraded. Must be an exact match</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Attempts to upgrade the specified Bladeburner skill. Returns true if the
|
|
skill is successfully upgraded, and false otherwise</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getteamsize">
|
|
<h2>getTeamSize<a class="headerlink" href="#getteamsize" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getTeamSize">
|
|
<code class="descname">getTeamSize</code><span class="sig-paren">(</span><em>type</em>, <em>name</em><span class="sig-paren">)</span><a class="headerlink" href="#getTeamSize" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>type</strong> (<em>string</em>) -- Type of action. See <a class="reference internal" href="#bladeburner-action-types"><span class="std std-ref">Bladeburner Action Types</span></a></li>
|
|
<li><strong>name</strong> (<em>string</em>) -- Name of action. Must be an exact match</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the number of Bladeburner team members you have assigned to the
|
|
specified action.</p>
|
|
<p>Setting a team is only applicable for Operations and BlackOps. This function
|
|
will return 0 for other action types.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="setteamsize">
|
|
<h2>setTeamSize<a class="headerlink" href="#setteamsize" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="setTeamSize">
|
|
<code class="descname">setTeamSize</code><span class="sig-paren">(</span><em>type</em>, <em>name</em>, <em>size</em><span class="sig-paren">)</span><a class="headerlink" href="#setTeamSize" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>type</strong> (<em>string</em>) -- Type of action. See <a class="reference internal" href="#bladeburner-action-types"><span class="std std-ref">Bladeburner Action Types</span></a></li>
|
|
<li><strong>name</strong> (<em>string</em>) -- Name of action. Must be an exact match</li>
|
|
<li><strong>size</strong> (<em>int</em>) -- Number of team members to set. Will be converted using Math.round()</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Set the team size for the specified Bladeburner action.</p>
|
|
<p>Returns the team size that was set, or -1 if the function failed.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getcityestimatedpopulation">
|
|
<h2>getCityEstimatedPopulation<a class="headerlink" href="#getcityestimatedpopulation" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getCityEstimatedPopulation">
|
|
<code class="descname">getCityEstimatedPopulation</code><span class="sig-paren">(</span><em>cityName</em><span class="sig-paren">)</span><a class="headerlink" href="#getCityEstimatedPopulation" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>cityName</strong> (<em>string</em>) -- Name of city. Case-sensitive</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the estimated number of Synthoids in the specified city, or -1
|
|
if an invalid city was specified.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getcityestimatedcommunities">
|
|
<h2>getCityEstimatedCommunities<a class="headerlink" href="#getcityestimatedcommunities" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getCityEstimatedCommunities">
|
|
<code class="descname">getCityEstimatedCommunities</code><span class="sig-paren">(</span><em>cityName</em><span class="sig-paren">)</span><a class="headerlink" href="#getCityEstimatedCommunities" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>cityName</strong> (<em>string</em>) -- Name of city. Case-sensitive</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the estimated number of Synthoid communities in the specified city,
|
|
or -1 if an invalid city was specified.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getcitychaos">
|
|
<h2>getCityChaos<a class="headerlink" href="#getcitychaos" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getCityChaos">
|
|
<code class="descname">getCityChaos</code><span class="sig-paren">(</span><em>cityName</em><span class="sig-paren">)</span><a class="headerlink" href="#getCityChaos" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>cityName</strong> (<em>string</em>) -- Name of city. Case-sensitive</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Returns the chaos in the specified city, or -1 if an invalid city was specified</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="switchcity">
|
|
<h2>switchCity<a class="headerlink" href="#switchcity" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="switchCity">
|
|
<code class="descname">switchCity</code><span class="sig-paren">(</span><em>cityName</em><span class="sig-paren">)</span><a class="headerlink" href="#switchCity" title="Permalink to this definition">¶</a></dt>
|
|
<dd><table class="docutils field-list" frame="void" rules="none">
|
|
<col class="field-name" />
|
|
<col class="field-body" />
|
|
<tbody valign="top">
|
|
<tr class="field-odd field"><th class="field-name">Arguments:</th><td class="field-body"><ul class="first last simple">
|
|
<li><strong>cityName</strong> (<em>string</em>) -- Name of city</li>
|
|
</ul>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
<p>Attempts to switch to the specified city (for Bladeburner only).</p>
|
|
<p>Returns true if successful, and false otherwise</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="getstamina">
|
|
<h2>getStamina<a class="headerlink" href="#getstamina" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="getStamina">
|
|
<code class="descname">getStamina</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#getStamina" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Returns an array with two elements:</p>
|
|
<blockquote>
|
|
<div>[Current stamina, Max stamina]</div></blockquote>
|
|
<p>Example usage:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">function</span> <span class="n">getStaminaPercentage</span><span class="p">()</span> <span class="p">{</span>
|
|
<span class="n">let</span> <span class="n">res</span> <span class="o">=</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getStamina</span><span class="p">();</span>
|
|
<span class="k">return</span> <span class="n">res</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">/</span> <span class="n">res</span><span class="p">[</span><span class="mi">1</span><span class="p">];</span>
|
|
<span class="p">}</span>
|
|
</pre></div>
|
|
</div>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="joinbladeburnerfaction">
|
|
<h2>joinBladeburnerFaction<a class="headerlink" href="#joinbladeburnerfaction" title="Permalink to this headline">¶</a></h2>
|
|
<dl class="function">
|
|
<dt id="joinBladeburnerFaction">
|
|
<code class="descname">joinBladeburnerFaction</code><span class="sig-paren">(</span><span class="sig-paren">)</span><a class="headerlink" href="#joinBladeburnerFaction" title="Permalink to this definition">¶</a></dt>
|
|
<dd><p>Attempts to join the Bladeburner faction.</p>
|
|
<p>Returns true if you successfully join the Bladeburner faction, or if
|
|
you are already a member.</p>
|
|
<p>Returns false otherwise.</p>
|
|
</dd></dl>
|
|
|
|
</div>
|
|
<div class="section" id="examples">
|
|
<h2>Examples<a class="headerlink" href="#examples" title="Permalink to this headline">¶</a></h2>
|
|
<p><strong>Basic example usage</strong>:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">tprint</span><span class="p">(</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getContractNames</span><span class="p">());</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getOperationNames</span><span class="p">());</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getBlackOpNames</span><span class="p">());</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getGeneralActionNames</span><span class="p">());</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getSkillNames</span><span class="p">());</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="n">bladeburner</span><span class="o">.</span><span class="n">getActionTime</span><span class="p">(</span><span class="s2">"contract"</span><span class="p">,</span> <span class="s2">"Tracking"</span><span class="p">));</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Rank: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getRank</span><span class="p">());</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Skill Points: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getSkillPoints</span><span class="p">());</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Cloak Skill Level: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getSkillLevel</span><span class="p">(</span><span class="s2">"Cloak"</span><span class="p">));</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Trying to upgradeSkill: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">upgradeSkill</span><span class="p">(</span><span class="s2">"Cloak"</span><span class="p">));</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Skill Points remaining: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getSkillPoints</span><span class="p">());</span>
|
|
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Trying to switch to a nonexistent city: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">switchCity</span><span class="p">(</span><span class="s2">"lskgns"</span><span class="p">));</span>
|
|
|
|
<span class="n">var</span> <span class="n">chongqing</span> <span class="o">=</span> <span class="s2">"Chongqing"</span><span class="p">;</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Trying to switch to Chongqing: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">switchCity</span><span class="p">(</span><span class="n">chongqing</span><span class="p">));</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Chongqing chaos: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getCityChaos</span><span class="p">(</span><span class="n">chongqing</span><span class="p">));</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Chongqing estimated pop: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getCityEstimatedPopulation</span><span class="p">(</span><span class="n">chongqing</span><span class="p">));</span>
|
|
<span class="n">tprint</span><span class="p">(</span><span class="s2">"Chonqging estimated communities: "</span> <span class="o">+</span> <span class="n">bladeburner</span><span class="o">.</span><span class="n">getCityEstimatedCommunities</span><span class="p">(</span><span class="n">chongqing</span><span class="p">));</span>
|
|
</pre></div>
|
|
</div>
|
|
<p><strong>Bladeburner handler example</strong>. Note that this avoids the need of using the <em>bladeburner</em> namespace
|
|
identifier by attaching the Bladeburner API functions to an object:</p>
|
|
<div class="highlight-default"><div class="highlight"><pre><span></span>const FIELD_ANALYSIS_INTERVAL = 10; //Number of minutes between field analysis states
|
|
const FIELD_ANALYSIS_DURATION = 5; //Duration in minutes
|
|
|
|
function BladeburnerHandler(ns, params) {
|
|
//Netscript environment becomes part of the instance
|
|
this.ns = ns;
|
|
|
|
//Netscript bladeburner API becomes part of this instance
|
|
for (var bladeburnerFn in ns.bladeburner) {
|
|
this[bladeburnerFn] = ns.bladeburner[bladeburnerFn];
|
|
}
|
|
|
|
this.fieldAnalysis = {
|
|
inProgress: params.startFieldAnalysis ? true : false,
|
|
cyclesRemaining: FIELD_ANALYSIS_DURATION,
|
|
cyclesSince: FIELD_ANALYSIS_INTERVAL
|
|
}
|
|
}
|
|
|
|
BladeburnerHandler.prototype.getStaminaPercentage = function() {
|
|
var res = this.getStamina();
|
|
return 100 * (res[0] / res[1]);
|
|
}
|
|
|
|
BladeburnerHandler.prototype.hasSimulacrum = function() {
|
|
var augs = this.ns.getOwnedAugmentations();
|
|
return augs.includes("The Blade's Simulacrum");
|
|
}
|
|
|
|
BladeburnerHandler.prototype.handle = function() {
|
|
//If we're doing something else manually (without Simlacrum),
|
|
//it overrides Bladeburner stuff
|
|
if (!this.hasSimulacrum() && this.ns.isBusy()) {
|
|
this.ns.print("Idling bc player is busy with some other action");
|
|
return;
|
|
}
|
|
|
|
if (this.fieldAnalysis.inProgress) {
|
|
--(this.fieldAnalysis.cyclesRemaining);
|
|
if (this.fieldAnalysis.cyclesRemaining < 0) {
|
|
this.fieldAnalysis.inProgress = false;
|
|
this.fieldAnalysis.cyclesSince = 0;
|
|
return this.handle();
|
|
} else {
|
|
this.startAction("general", "Field Analysis");
|
|
this.ns.print("handler is doing field analyis for " +
|
|
(this.fieldAnalysis.cyclesRemaining+1) + " more mins");
|
|
return;
|
|
}
|
|
} else {
|
|
++(this.fieldAnalysis.cyclesSince);
|
|
if (this.fieldAnalysis.cyclesSince > FIELD_ANALYSIS_INTERVAL) {
|
|
this.fieldAnalysis.inProgress = true;
|
|
this.fieldAnalysis.cyclesRemaining = FIELD_ANALYSIS_DURATION;
|
|
return this.handle();
|
|
}
|
|
}
|
|
|
|
this.stopBladeburnerAction();
|
|
|
|
var staminaPerc = this.getStaminaPercentage();
|
|
if (staminaPerc < 55) {
|
|
this.ns.print("handler is starting training due to low stamina percentage");
|
|
this.startAction("general", "Training");
|
|
} else {
|
|
var action = this.chooseAction();
|
|
this.ns.print("handler chose " + action.name + " " + action.type + " through chooseAction()");
|
|
this.startAction(action.type, action.name);
|
|
}
|
|
}
|
|
|
|
BladeburnerHandler.prototype.chooseAction = function() {
|
|
//Array of all Operations
|
|
var ops = this.getOperationNames();
|
|
|
|
//Sort Operations in order of increasing success chance
|
|
ops.sort((a, b)=>{
|
|
return this.getActionEstimatedSuccessChance("operation", a) -
|
|
this.getActionEstimatedSuccessChance("operation", b);
|
|
});
|
|
|
|
//Loop through until you find one with 99+% success chance
|
|
for (let i = 0; i < ops.length; ++i) {
|
|
let successChance = this.getActionEstimatedSuccessChance("operation", ops[i]);
|
|
let count = this.getActionCountRemaining("operation", ops[i]);
|
|
if (successChance >= 0.99 && count > 10) {
|
|
return {type: "operation", name: ops[i]};
|
|
}
|
|
}
|
|
|
|
//Repeat for Contracts
|
|
var contracts = this.getContractNames();
|
|
contracts.sort((a, b)=>{
|
|
return this.getActionEstimatedSuccessChance("contract", a) -
|
|
this.getActionEstimatedSuccessChance("contract", b);
|
|
});
|
|
|
|
for (let i = 0; i < contracts.length; ++i) {
|
|
let successChance = this.getActionEstimatedSuccessChance("contract", contracts[i]);
|
|
let count = this.getActionCountRemaining("contract", contracts[i]);
|
|
if (successChance >= 0.80 && count > 10) {
|
|
return {type: "contract", name: contracts[i]};
|
|
}
|
|
}
|
|
|
|
return {type:"general", name:"Training"};
|
|
}
|
|
|
|
|
|
BladeburnerHandler.prototype.process = async function() {
|
|
this.handle();
|
|
await this.ns.sleep(60000);
|
|
}
|
|
|
|
export async function main(ns) {
|
|
ns.disableLog("sleep");
|
|
//Check if Bladeburner is available. This'll throw a runtime error if it's not
|
|
ns.bladeburner.getContractNames();
|
|
|
|
var startFieldAnalysis = true;
|
|
if (ns.args.length >= 1 && ns.args[0] == "false") {
|
|
startFieldAnalysis = false;
|
|
}
|
|
|
|
var handler = new BladeburnerHandler(ns, {
|
|
startFieldAnalysis: startFieldAnalysis
|
|
});
|
|
while(true) {
|
|
await handler.process();
|
|
}
|
|
}
|
|
</pre></div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="sidebar">
|
|
<h3>Table Of Contents</h3>
|
|
<p class="caption"><span class="caption-text">Contents:</span></p>
|
|
<ul class="current">
|
|
<li class="toctree-l1 current"><a class="reference internal" href="netscript.html"> Netscript</a><ul class="current">
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptjs.html"> NetscriptJS (Netscript 2.0)</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptdatatypes.html"> Data Types and Variables</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptoperators.html"> Operators</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptloopsandconditionals.html"> Loops and Conditionals</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptscriptarguments.html"> Script Arguments</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptfunctions.html"> Basic Functions</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptadvancedfunctions.html"> Advanced Functions</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscripthacknetnodeapi.html"> Hacknet Node API</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptixapi.html"> Trade Information eXchange (TIX) API</a></li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptsingularityfunctions.html"> Singularity Functions</a></li>
|
|
<li class="toctree-l2 current"><a class="current reference internal" href="#"> Bladeburner API</a><ul>
|
|
<li class="toctree-l3"><a class="reference internal" href="#bladeburner-action-types">Bladeburner Action Types</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getcontractnames">getContractNames</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getoperationnames">getOperationNames</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getblackopnames">getBlackOpNames</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getgeneralactionnames">getGeneralActionNames</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getskillnames">getSkillNames</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#startaction">startAction</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#stopbladeburneraction">stopBladeburnerAction</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getactiontime">getActionTime</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getactionestimatedsuccesschance">getActionEstimatedSuccessChance</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getactioncountremaining">getActionCountRemaining</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getrank">getRank</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getskillpoints">getSkillPoints</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getskilllevel">getSkillLevel</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#upgradeskill">upgradeSkill</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getteamsize">getTeamSize</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#setteamsize">setTeamSize</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getcityestimatedpopulation">getCityEstimatedPopulation</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getcityestimatedcommunities">getCityEstimatedCommunities</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getcitychaos">getCityChaos</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#switchcity">switchCity</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#getstamina">getStamina</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#joinbladeburnerfaction">joinBladeburnerFaction</a></li>
|
|
<li class="toctree-l3"><a class="reference internal" href="#examples">Examples</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l2"><a class="reference internal" href="netscriptmisc.html"> Miscellaneous</a></li>
|
|
</ul>
|
|
</li>
|
|
<li class="toctree-l1"><a class="reference internal" href="terminal.html"> Terminal</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="shortcuts.html"> Keyboard Shortcuts</a></li>
|
|
<li class="toctree-l1"><a class="reference internal" href="changelog.html"> Changelog</a></li>
|
|
</ul>
|
|
|
|
<div role="search">
|
|
<h3 style="margin-top: 1.5em;">Search</h3>
|
|
<form class="search" action="search.html" method="get">
|
|
<input type="text" name="q" />
|
|
<input type="submit" value="Go" />
|
|
<input type="hidden" name="check_keywords" value="yes" />
|
|
<input type="hidden" name="area" value="default" />
|
|
</form>
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="footer-wrapper">
|
|
<div class="footer">
|
|
<div class="left">
|
|
<div role="navigation" aria-label="related navigaton">
|
|
<a href="netscriptsingularityfunctions.html" title="Netscript Singularity Functions"
|
|
>previous</a> |
|
|
<a href="netscriptmisc.html" title="Netscript Miscellaneous"
|
|
>next</a> |
|
|
<a href="genindex.html" title="General Index"
|
|
>index</a>
|
|
</div>
|
|
<div role="note" aria-label="source link">
|
|
<br/>
|
|
<a href="_sources/netscriptbladeburnerapi.rst.txt"
|
|
rel="nofollow">Show Source</a>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="right">
|
|
|
|
<div class="footer" role="contentinfo">
|
|
© Copyright 2017, Bitburner.
|
|
Created using <a href="http://sphinx-doc.org/">Sphinx</a> 1.6.4.
|
|
</div>
|
|
</div>
|
|
<div class="clearer"></div>
|
|
</div>
|
|
</div>
|
|
|
|
</body>
|
|
</html> |