mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-18 21:53:50 +01:00
Refactored functions that calculate hacking time/exp gain/chance/ etc into a separate file
This commit is contained in:
parent
63cd269d5e
commit
5ede6be8e5
@ -493,32 +493,11 @@ let CONSTANTS = {
|
|||||||
"World Stock Exchange account and TIX API Access<br>",
|
"World Stock Exchange account and TIX API Access<br>",
|
||||||
|
|
||||||
LatestUpdate:
|
LatestUpdate:
|
||||||
"v0.40.2<br>" +
|
"v0.40.3<br>" +
|
||||||
"------------------------------<br>" +
|
"* b1t_flum3.exe program can now be created immediately at Hacking level 1 (rather than hacking level 5)<br>" +
|
||||||
"* Bladeburner Changes:<br>" +
|
"* UI improvements for the character overview panel and the left-hand menu (by mat-jaworski)<br>" +
|
||||||
"*** Added getBonusTime(), getSkillUpgradeCost(), and getCity() Netscript functions to the API<br>" +
|
"* Improved the introductory tutorial<br>"
|
||||||
"*** Buffed the effects of many Bladeburner Augmentations<br>" +
|
|
||||||
"*** The Blade's Simulacrum Augmentation requires significantly less reputation but slightly more money<br>" +
|
|
||||||
"*** Slightly increased the amount of successes needed for a Contract/Operation in order to increase its max level<br>" +
|
|
||||||
"*** Increased the amount of money gained from Contracts by ~25%<br>" +
|
|
||||||
"*** Increased the base amount of rank gained from Operations by 10%<br>" +
|
|
||||||
"*** Significantly increased the 'randomness' in determining a Contract/Operation's initial count and rate of count increase<br>" +
|
|
||||||
"*** The number (count) of Operations should now increase significantly faster<br>" +
|
|
||||||
"*** There are now, on average, more Synthoid communities in a city<br>" +
|
|
||||||
"*** If automation is enabled (the feature in Bladeburner console), then switching to another action such as working for a company will now disable the automation<br>" +
|
|
||||||
"------------------------------<br>" +
|
|
||||||
"* Stock Market Changes:<br>" +
|
|
||||||
"***Added a watchlist filter feature to the UI that allows you to specify which stocks to show<br>" +
|
|
||||||
"***Added the Four Sigma (4S) Market Data feed, which provides volatility and price forecast information about stocks<br>" +
|
|
||||||
"***Added the 4S Market Data TIX API, which lets you access the aforementioned data through Netscript<br>" +
|
|
||||||
"------------------------------<br>" +
|
|
||||||
"* There is now a setting for enabling/disabling the popup that appears when you are hospitalized<br>" +
|
|
||||||
"* Bug Fix: Stock market should now be correctly initialized in BitNode-8 (by Kline-)<br>" +
|
|
||||||
"* Bug Fix: bladeburner.getCurrentAction() should now properly an 'Idle' object rather than null (by Kline-)<br>" +
|
|
||||||
"* Bug Fix: Bladeburner skill cost multiplier should now properly increase in BitNode-12 (by hydroflame)<br>" +
|
|
||||||
"* Bug Fix: 'document', 'hacknet', and 'window' keywords should no longer be counted multiple times in RAM calculations<br>" +
|
|
||||||
"* Bug Fix: Joining factions through Singularity functions should now prevent you from joining opposing factions<br>" +
|
|
||||||
"* Bug Fix: Four Sigma should no longer have two 'Speech Enhancement' Augmentations (by Kline-)<br>"
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
90
src/Hacking.js
Normal file
90
src/Hacking.js
Normal file
@ -0,0 +1,90 @@
|
|||||||
|
import { BitNodeMultipliers } from "./BitNodeMultipliers";
|
||||||
|
import { Player } from "./Player";
|
||||||
|
import { Server } from "./Server";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the chance the player has to successfully hack a server
|
||||||
|
*/
|
||||||
|
export function calculateHackingChance(server) {
|
||||||
|
const hackFactor = 1.75;
|
||||||
|
const intFactor = 0.2;
|
||||||
|
const difficultyMult = (100 - server.hackDifficulty) / 100;
|
||||||
|
const skillMult = (hackFactor * Player.hacking_skill) + (intFactor * Player.intelligence);
|
||||||
|
const skillChance = (skillMult - server.requiredHackingSkill) / skillMult;
|
||||||
|
const chance = skillChance * difficultyMult * Player.hacking_chance_mult;
|
||||||
|
if (chance > 1) { return 1; }
|
||||||
|
if (chance < 0) { return 0; }
|
||||||
|
|
||||||
|
return chance;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the amount of hacking experience the player will gain upon
|
||||||
|
* successfully hacking a server
|
||||||
|
*/
|
||||||
|
export function calculateHackingExpGain(server) {
|
||||||
|
const baseExpGain = 3;
|
||||||
|
const diffFactor = 0.3;
|
||||||
|
if (server.baseDifficulty == null) {
|
||||||
|
server.baseDifficulty = server.hackDifficulty;
|
||||||
|
}
|
||||||
|
var expGain = baseExpGain;
|
||||||
|
expGain += (server.baseDifficulty * Player.hacking_exp_mult * diffFactor);
|
||||||
|
|
||||||
|
return expGain * BitNodeMultipliers.HackExpGain;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the percentage of money that will be stolen from a server if
|
||||||
|
* it is successfully hacked (returns the decimal form, not the actual percent value)
|
||||||
|
*/
|
||||||
|
export function calculatePercentMoneyHacked(server) {
|
||||||
|
// Adjust if needed for balancing. This is the divisor for the final calculation
|
||||||
|
const balanceFactor = 240;
|
||||||
|
|
||||||
|
const difficultyMult = (100 - server.hackDifficulty) / 100;
|
||||||
|
const skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill;
|
||||||
|
const percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / balanceFactor;
|
||||||
|
if (percentMoneyHacked < 0) { return 0; }
|
||||||
|
if (percentMoneyHacked > 1) { return 1; }
|
||||||
|
|
||||||
|
return percentMoneyHacked * BitNodeMultipliers.ScriptHackMoney;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns time it takes to complete a hack on a server, in seconds
|
||||||
|
*/
|
||||||
|
export function calculateHackingTime(server) {
|
||||||
|
const difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
|
||||||
|
|
||||||
|
const baseDiff = 500;
|
||||||
|
const baseSkill = 50;
|
||||||
|
const diffFactor = 2.5;
|
||||||
|
const intFactor = 0.1;
|
||||||
|
var skillFactor = (diffFactor * difficultyMult + baseDiff);
|
||||||
|
// tslint:disable-next-line
|
||||||
|
skillFactor /= (Player.hacking_skill + baseSkill + (intFactor * Player.intelligence));
|
||||||
|
|
||||||
|
const hackTimeMultiplier = 5;
|
||||||
|
const hackingTime = hackTimeMultiplier * skillFactor / Player.hacking_speed_mult;
|
||||||
|
|
||||||
|
return hackingTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns time it takes to complete a grow operation on a server, in seconds
|
||||||
|
*/
|
||||||
|
export function calculateGrowTime(server) {
|
||||||
|
const growTimeMultiplier = 3.2; // Relative to hacking time. 16/5 = 3.2
|
||||||
|
|
||||||
|
return growTimeMultiplier * calculateHackingTime(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns time it takes to complete a weaken operation on a server, in seconds
|
||||||
|
*/
|
||||||
|
export function calculateWeakenTime(server) {
|
||||||
|
const weakenTimeMultiplier = 4; // Relative to hacking time
|
||||||
|
|
||||||
|
return weakenTimeMultiplier * calculateHackingTime(server);
|
||||||
|
}
|
@ -1,7 +1,6 @@
|
|||||||
import {Engine} from "./engine";
|
import {Engine} from "./engine";
|
||||||
import {Player} from "./Player";
|
import {Player} from "./Player";
|
||||||
import {Settings} from "./Settings";
|
import {Settings} from "./Settings";
|
||||||
import {Terminal} from "./Terminal";
|
|
||||||
import {clearEventListeners} from "../utils/uiHelpers/clearEventListeners";
|
import {clearEventListeners} from "../utils/uiHelpers/clearEventListeners";
|
||||||
import {createElement} from "../utils/uiHelpers/createElement";
|
import {createElement} from "../utils/uiHelpers/createElement";
|
||||||
import {createPopup} from "../utils/uiHelpers/createPopup";
|
import {createPopup} from "../utils/uiHelpers/createPopup";
|
||||||
@ -62,7 +61,6 @@ function iTutorialStart() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
Engine.loadTerminalContent();
|
Engine.loadTerminalContent();
|
||||||
Terminal.resetTerminalInput();
|
|
||||||
|
|
||||||
//Don't autosave during this interactive tutorial
|
//Don't autosave during this interactive tutorial
|
||||||
Engine.Counters.autoSaveCounter = Infinity;
|
Engine.Counters.autoSaveCounter = Infinity;
|
||||||
|
@ -911,61 +911,5 @@ function isScriptErrorMessage(msg) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
//The same as Player's calculateHackingChance() function but takes in the server as an argument
|
export {makeRuntimeRejectMsg, netscriptDelay, runScriptFromScript, evaluate,
|
||||||
function scriptCalculateHackingChance(server) {
|
|
||||||
var difficultyMult = (100 - server.hackDifficulty) / 100;
|
|
||||||
var skillMult = (1.75 * Player.hacking_skill) + (0.2 * Player.intelligence);
|
|
||||||
var skillChance = (skillMult - server.requiredHackingSkill) / skillMult;
|
|
||||||
var chance = skillChance * difficultyMult * Player.hacking_chance_mult;
|
|
||||||
if (chance > 1) {return 1;}
|
|
||||||
if (chance < 0) {return 0;}
|
|
||||||
else {return chance;}
|
|
||||||
}
|
|
||||||
|
|
||||||
//The same as Player's calculateHackingTime() function but takes in the server as an argument
|
|
||||||
function scriptCalculateHackingTime(server) {
|
|
||||||
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
|
|
||||||
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50 + (0.1 * Player.intelligence));
|
|
||||||
var hackingTime = 5 * skillFactor / Player.hacking_speed_mult; //This is in seconds
|
|
||||||
return hackingTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
//The same as Player's calculateExpGain() function but takes in the server as an argument
|
|
||||||
function scriptCalculateExpGain(server) {
|
|
||||||
if (server.baseDifficulty == null) {
|
|
||||||
server.baseDifficulty = server.hackDifficulty;
|
|
||||||
}
|
|
||||||
return (server.baseDifficulty * Player.hacking_exp_mult * 0.3 + 3) * BitNodeMultipliers.HackExpGain;
|
|
||||||
}
|
|
||||||
|
|
||||||
//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument
|
|
||||||
function scriptCalculatePercentMoneyHacked(server) {
|
|
||||||
var difficultyMult = (100 - server.hackDifficulty) / 100;
|
|
||||||
var skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill;
|
|
||||||
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 240;
|
|
||||||
if (percentMoneyHacked < 0) {return 0;}
|
|
||||||
if (percentMoneyHacked > 1) {return 1;}
|
|
||||||
return percentMoneyHacked * BitNodeMultipliers.ScriptHackMoney;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Amount of time to execute grow() in milliseconds
|
|
||||||
function scriptCalculateGrowTime(server) {
|
|
||||||
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
|
|
||||||
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50 + (0.1 * Player.intelligence));
|
|
||||||
var growTime = 16 * skillFactor / Player.hacking_speed_mult; //This is in seconds
|
|
||||||
return growTime * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Amount of time to execute weaken() in milliseconds
|
|
||||||
function scriptCalculateWeakenTime(server) {
|
|
||||||
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
|
|
||||||
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50 + (0.1 * Player.intelligence));
|
|
||||||
var weakenTime = 20 * skillFactor / Player.hacking_speed_mult; //This is in seconds
|
|
||||||
return weakenTime * 1000;
|
|
||||||
}
|
|
||||||
|
|
||||||
export {makeRuntimeRejectMsg, netscriptDelay, runScriptFromScript,
|
|
||||||
scriptCalculateHackingChance, scriptCalculateHackingTime,
|
|
||||||
scriptCalculateExpGain, scriptCalculatePercentMoneyHacked,
|
|
||||||
scriptCalculateGrowTime, scriptCalculateWeakenTime, evaluate,
|
|
||||||
isScriptErrorMessage, killNetscriptDelay, evaluateImport};
|
isScriptErrorMessage, killNetscriptDelay, evaluateImport};
|
||||||
|
@ -13,6 +13,12 @@ import {Companies, Company, CompanyPosition,
|
|||||||
import {CONSTANTS} from "./Constants";
|
import {CONSTANTS} from "./Constants";
|
||||||
import {Programs} from "./CreateProgram";
|
import {Programs} from "./CreateProgram";
|
||||||
import {DarkWebItems} from "./DarkWeb";
|
import {DarkWebItems} from "./DarkWeb";
|
||||||
|
import {calculateHackingChance,
|
||||||
|
calculateHackingExpGain,
|
||||||
|
calculatePercentMoneyHacked,
|
||||||
|
calculateHackingTime,
|
||||||
|
calculateGrowTime,
|
||||||
|
calculateWeakenTime} from "./Hacking";
|
||||||
import {AllGangs} from "./Gang";
|
import {AllGangs} from "./Gang";
|
||||||
import {Factions, Faction, joinFaction,
|
import {Factions, Faction, joinFaction,
|
||||||
factionExists, purchaseAugmentation} from "./Faction";
|
factionExists, purchaseAugmentation} from "./Faction";
|
||||||
@ -42,10 +48,8 @@ import {unknownBladeburnerActionErrorMessage,
|
|||||||
checkBladeburnerAccess} from "./NetscriptBladeburner.js";
|
checkBladeburnerAccess} from "./NetscriptBladeburner.js";
|
||||||
import {WorkerScript, workerScripts,
|
import {WorkerScript, workerScripts,
|
||||||
killWorkerScript, NetscriptPorts} from "./NetscriptWorker";
|
killWorkerScript, NetscriptPorts} from "./NetscriptWorker";
|
||||||
import {makeRuntimeRejectMsg, netscriptDelay, runScriptFromScript,
|
import {makeRuntimeRejectMsg, netscriptDelay,
|
||||||
scriptCalculateHackingChance, scriptCalculateHackingTime,
|
runScriptFromScript} from "./NetscriptEvaluator";
|
||||||
scriptCalculateExpGain, scriptCalculatePercentMoneyHacked,
|
|
||||||
scriptCalculateGrowTime, scriptCalculateWeakenTime} from "./NetscriptEvaluator";
|
|
||||||
import {NetscriptPort} from "./NetscriptPort";
|
import {NetscriptPort} from "./NetscriptPort";
|
||||||
|
|
||||||
import Decimal from "decimal.js";
|
import Decimal from "decimal.js";
|
||||||
@ -292,7 +296,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Calculate the hacking time
|
//Calculate the hacking time
|
||||||
var hackingTime = scriptCalculateHackingTime(server); //This is in seconds
|
var hackingTime = calculateHackingTime(server); //This is in seconds
|
||||||
|
|
||||||
//No root access or skill level too low
|
//No root access or skill level too low
|
||||||
if (server.hasAdminRights == false) {
|
if (server.hasAdminRights == false) {
|
||||||
@ -308,14 +312,14 @@ function NetscriptFunctions(workerScript) {
|
|||||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
|
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
|
||||||
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
|
workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
|
||||||
}
|
}
|
||||||
return netscriptDelay(hackingTime* 1000, workerScript).then(function() {
|
return netscriptDelay(hackingTime * 1000, workerScript).then(function() {
|
||||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
||||||
var hackChance = scriptCalculateHackingChance(server);
|
var hackChance = calculateHackingChance(server);
|
||||||
var rand = Math.random();
|
var rand = Math.random();
|
||||||
var expGainedOnSuccess = scriptCalculateExpGain(server) * threads;
|
var expGainedOnSuccess = calculateHackingExpGain(server) * threads;
|
||||||
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
||||||
if (rand < hackChance) { //Success!
|
if (rand < hackChance) { //Success!
|
||||||
const percentHacked = scriptCalculatePercentMoneyHacked(server);
|
const percentHacked = calculatePercentMoneyHacked(server);
|
||||||
let maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax));
|
let maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax));
|
||||||
if (isNaN(maxThreadNeeded)) {
|
if (isNaN(maxThreadNeeded)) {
|
||||||
//Server has a 'max money' of 0 (probably).
|
//Server has a 'max money' of 0 (probably).
|
||||||
@ -390,18 +394,18 @@ function NetscriptFunctions(workerScript) {
|
|||||||
throw makeRuntimeRejectMsg(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access");
|
throw makeRuntimeRejectMsg(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access");
|
||||||
}
|
}
|
||||||
|
|
||||||
var growTime = scriptCalculateGrowTime(server);
|
var growTime = calculateGrowTime(server);
|
||||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
|
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
|
||||||
workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds (t=" + threads + ")");
|
workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime, 3) + " seconds (t=" + threads + ")");
|
||||||
}
|
}
|
||||||
return netscriptDelay(growTime, workerScript).then(function() {
|
return netscriptDelay(growTime * 1000, workerScript).then(function() {
|
||||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
||||||
const moneyBefore = server.moneyAvailable;
|
const moneyBefore = server.moneyAvailable;
|
||||||
server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
|
server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
|
||||||
var growthPercentage = processSingleServerGrowth(server, 450 * threads);
|
var growthPercentage = processSingleServerGrowth(server, 450 * threads);
|
||||||
const moneyAfter = server.moneyAvailable;
|
const moneyAfter = server.moneyAvailable;
|
||||||
workerScript.scriptRef.recordGrow(server.ip, threads);
|
workerScript.scriptRef.recordGrow(server.ip, threads);
|
||||||
var expGain = scriptCalculateExpGain(server) * threads;
|
var expGain = calculateHackingExpGain(server) * threads;
|
||||||
if (growthPercentage == 1) {
|
if (growthPercentage == 1) {
|
||||||
expGain = 0;
|
expGain = 0;
|
||||||
}
|
}
|
||||||
@ -437,16 +441,16 @@ function NetscriptFunctions(workerScript) {
|
|||||||
throw makeRuntimeRejectMsg(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access");
|
throw makeRuntimeRejectMsg(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access");
|
||||||
}
|
}
|
||||||
|
|
||||||
var weakenTime = scriptCalculateWeakenTime(server);
|
var weakenTime = calculateWeakenTime(server);
|
||||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
|
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
|
||||||
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
|
workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
|
||||||
formatNumber(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
|
formatNumber(weakenTime, 3) + " seconds (t=" + threads + ")");
|
||||||
}
|
}
|
||||||
return netscriptDelay(weakenTime, workerScript).then(function() {
|
return netscriptDelay(weakenTime * 1000, workerScript).then(function() {
|
||||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
||||||
server.weaken(CONSTANTS.ServerWeakenAmount * threads);
|
server.weaken(CONSTANTS.ServerWeakenAmount * threads);
|
||||||
workerScript.scriptRef.recordWeaken(server.ip, threads);
|
workerScript.scriptRef.recordWeaken(server.ip, threads);
|
||||||
var expGain = scriptCalculateExpGain(server) * threads;
|
var expGain = calculateHackingExpGain(server) * threads;
|
||||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
|
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
|
||||||
workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
|
workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
|
||||||
". Gained " + formatNumber(expGain, 4) + " hacking exp (t=" + threads + ")");
|
". Gained " + formatNumber(expGain, 4) + " hacking exp (t=" + threads + ")");
|
||||||
@ -2057,7 +2061,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip);
|
workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
throw makeRuntimeRejectMsg(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip);
|
throw makeRuntimeRejectMsg(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
}
|
}
|
||||||
return scriptCalculateHackingTime(server); //Returns seconds
|
return calculateHackingTime(server); //Returns seconds
|
||||||
},
|
},
|
||||||
getGrowTime : function(ip) {
|
getGrowTime : function(ip) {
|
||||||
if (workerScript.checkingRam) {
|
if (workerScript.checkingRam) {
|
||||||
@ -2069,7 +2073,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
|
workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
throw makeRuntimeRejectMsg(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
|
throw makeRuntimeRejectMsg(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
}
|
}
|
||||||
return scriptCalculateGrowTime(server) / 1000; //Returns seconds
|
return calculateGrowTime(server); //Returns seconds
|
||||||
},
|
},
|
||||||
getWeakenTime : function(ip) {
|
getWeakenTime : function(ip) {
|
||||||
if (workerScript.checkingRam) {
|
if (workerScript.checkingRam) {
|
||||||
@ -2081,7 +2085,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
|
workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
throw makeRuntimeRejectMsg(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
|
throw makeRuntimeRejectMsg(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
|
||||||
}
|
}
|
||||||
return scriptCalculateWeakenTime(server) / 1000; //Returns seconds
|
return calculateWeakenTime(server); //Returns seconds
|
||||||
},
|
},
|
||||||
getScriptIncome : function(scriptname, ip) {
|
getScriptIncome : function(scriptname, ip) {
|
||||||
if (workerScript.checkingRam) {
|
if (workerScript.checkingRam) {
|
||||||
|
@ -119,11 +119,6 @@ function PlayerObject() {
|
|||||||
this.crime_money_mult = 1;
|
this.crime_money_mult = 1;
|
||||||
this.crime_success_mult = 1;
|
this.crime_success_mult = 1;
|
||||||
|
|
||||||
//Flag to let the engine know the player is starting an action
|
|
||||||
// Current actions: hack, analyze
|
|
||||||
this.startAction = false;
|
|
||||||
this.actionTime = 0;
|
|
||||||
|
|
||||||
//Flags/variables for working (Company, Faction, Creating Program, Taking Class)
|
//Flags/variables for working (Company, Faction, Creating Program, Taking Class)
|
||||||
this.isWorking = false;
|
this.isWorking = false;
|
||||||
this.workType = "";
|
this.workType = "";
|
||||||
@ -265,9 +260,6 @@ PlayerObject.prototype.prestigeAugmentation = function() {
|
|||||||
|
|
||||||
this.queuedAugmentations = [];
|
this.queuedAugmentations = [];
|
||||||
|
|
||||||
this.startAction = false;
|
|
||||||
this.actionTime = 0;
|
|
||||||
|
|
||||||
this.isWorking = false;
|
this.isWorking = false;
|
||||||
this.currentWorkFactionName = "";
|
this.currentWorkFactionName = "";
|
||||||
this.currentWorkFactionDescription = "";
|
this.currentWorkFactionDescription = "";
|
||||||
@ -349,9 +341,6 @@ PlayerObject.prototype.prestigeSourceFile = function() {
|
|||||||
this.queuedAugmentations = [];
|
this.queuedAugmentations = [];
|
||||||
this.augmentations = [];
|
this.augmentations = [];
|
||||||
|
|
||||||
this.startAction = false;
|
|
||||||
this.actionTime = 0;
|
|
||||||
|
|
||||||
this.isWorking = false;
|
this.isWorking = false;
|
||||||
this.currentWorkFactionName = "";
|
this.currentWorkFactionName = "";
|
||||||
this.currentWorkFactionDescription = "";
|
this.currentWorkFactionDescription = "";
|
||||||
@ -498,72 +487,6 @@ PlayerObject.prototype.resetMultipliers = function() {
|
|||||||
this.bladeburner_success_chance_mult = 1;
|
this.bladeburner_success_chance_mult = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Calculates the chance of hacking a server
|
|
||||||
//The formula is:
|
|
||||||
// (2 * hacking_chance_multiplier * hacking_skill - requiredLevel) 100 - difficulty
|
|
||||||
// ----------------------------------------------------------- * -----------------
|
|
||||||
// (2 * hacking_chance_multiplier * hacking_skill) 100
|
|
||||||
PlayerObject.prototype.calculateHackingChance = function() {
|
|
||||||
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
|
||||||
var skillMult = (1.75 * this.hacking_skill) + (0.2 * this.intelligence);
|
|
||||||
var skillChance = (skillMult - this.getCurrentServer().requiredHackingSkill) / skillMult;
|
|
||||||
var chance = skillChance * difficultyMult * this.hacking_chance_mult;
|
|
||||||
if (chance > 1) {return 1;}
|
|
||||||
if (chance < 0) {return 0;}
|
|
||||||
return chance;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Calculate the time it takes to hack a server in seconds. Returns the time
|
|
||||||
//The formula is:
|
|
||||||
// (2.5 * requiredLevel * difficulty + 200)
|
|
||||||
// ----------------------------------- * hacking_speed_multiplier
|
|
||||||
// hacking_skill + 100
|
|
||||||
PlayerObject.prototype.calculateHackingTime = function() {
|
|
||||||
var difficultyMult = this.getCurrentServer().requiredHackingSkill * this.getCurrentServer().hackDifficulty;
|
|
||||||
var skillFactor = (2.5 * difficultyMult + 200) / (this.hacking_skill + 100 + (0.1 * this.intelligence));
|
|
||||||
return 5 * skillFactor / this.hacking_speed_mult;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Calculates the PERCENTAGE of a server's money that the player will hack from the server if successful
|
|
||||||
//The formula is:
|
|
||||||
// (hacking_skill - (requiredLevel-1)) 100 - difficulty
|
|
||||||
// --------------------------------------* ----------------------- * hacking_money_multiplier
|
|
||||||
// hacking_skill 100
|
|
||||||
PlayerObject.prototype.calculatePercentMoneyHacked = function() {
|
|
||||||
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
|
|
||||||
var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill;
|
|
||||||
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult / 240;
|
|
||||||
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
|
||||||
if (percentMoneyHacked < 0) {return 0;}
|
|
||||||
if (percentMoneyHacked > 1) {return 1;}
|
|
||||||
return percentMoneyHacked * BitNodeMultipliers.ManualHackMoney;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Returns how much EXP the player gains on a successful hack
|
|
||||||
//The formula is:
|
|
||||||
// difficulty * requiredLevel * hacking_multiplier
|
|
||||||
PlayerObject.prototype.calculateExpGain = function() {
|
|
||||||
var s = this.getCurrentServer();
|
|
||||||
if (s.baseDifficulty == null) {
|
|
||||||
s.baseDifficulty = s.hackDifficulty;
|
|
||||||
}
|
|
||||||
return (s.baseDifficulty * this.hacking_exp_mult * 0.3 + 3) * BitNodeMultipliers.HackExpGain;
|
|
||||||
}
|
|
||||||
|
|
||||||
//Hack/Analyze a server. Return the amount of time the hack will take. This lets the Terminal object know how long to disable itself for
|
|
||||||
//This assumes that the server being hacked is not purchased by the player, that the player's hacking skill is greater than the
|
|
||||||
//required hacking skill and that the player has admin rights.
|
|
||||||
PlayerObject.prototype.hack = function() {
|
|
||||||
this.actionTime = this.calculateHackingTime();
|
|
||||||
console.log("Hacking time: " + this.actionTime);
|
|
||||||
this.startAction = true; //Set the startAction flag so the engine starts the hacking process
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerObject.prototype.analyze = function() {
|
|
||||||
this.actionTime = 1;
|
|
||||||
this.startAction = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PlayerObject.prototype.hasProgram = function(programName) {
|
PlayerObject.prototype.hasProgram = function(programName) {
|
||||||
var home = Player.getHomeComputer();
|
var home = Player.getHomeComputer();
|
||||||
if (home == null) {return false;}
|
if (home == null) {return false;}
|
||||||
|
122
src/Terminal.js
122
src/Terminal.js
@ -10,14 +10,17 @@ import {executeDarkwebTerminalCommand,
|
|||||||
import {Engine} from "./engine";
|
import {Engine} from "./engine";
|
||||||
import {FconfSettings, parseFconfSettings,
|
import {FconfSettings, parseFconfSettings,
|
||||||
createFconf} from "./Fconf";
|
createFconf} from "./Fconf";
|
||||||
|
import {calculateHackingChance,
|
||||||
|
calculateHackingExpGain,
|
||||||
|
calculatePercentMoneyHacked,
|
||||||
|
calculateHackingTime,
|
||||||
|
calculateGrowTime,
|
||||||
|
calculateWeakenTime} from "./Hacking";
|
||||||
import {TerminalHelpText, HelpTexts} from "./HelpText";
|
import {TerminalHelpText, HelpTexts} from "./HelpText";
|
||||||
import {iTutorialNextStep, iTutorialSteps,
|
import {iTutorialNextStep, iTutorialSteps,
|
||||||
ITutorial} from "./InteractiveTutorial";
|
ITutorial} from "./InteractiveTutorial";
|
||||||
import {showLiterature} from "./Literature";
|
import {showLiterature} from "./Literature";
|
||||||
import {showMessage, Message} from "./Message";
|
import {showMessage, Message} from "./Message";
|
||||||
import {scriptCalculateHackingTime,
|
|
||||||
scriptCalculateGrowTime,
|
|
||||||
scriptCalculateWeakenTime} from "./NetscriptEvaluator";
|
|
||||||
import {killWorkerScript, addWorkerScript} from "./NetscriptWorker";
|
import {killWorkerScript, addWorkerScript} from "./NetscriptWorker";
|
||||||
import numeral from "numeral/min/numeral.min";
|
import numeral from "numeral/min/numeral.min";
|
||||||
import {Player} from "./Player";
|
import {Player} from "./Player";
|
||||||
@ -514,6 +517,8 @@ let Terminal = {
|
|||||||
//Flags to determine whether the player is currently running a hack or an analyze
|
//Flags to determine whether the player is currently running a hack or an analyze
|
||||||
hackFlag: false,
|
hackFlag: false,
|
||||||
analyzeFlag: false,
|
analyzeFlag: false,
|
||||||
|
actionStarted: false,
|
||||||
|
actionTime: 0,
|
||||||
|
|
||||||
commandHistory: [],
|
commandHistory: [],
|
||||||
commandHistoryIndex: 0,
|
commandHistoryIndex: 0,
|
||||||
@ -619,6 +624,32 @@ let Terminal = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
startHack: function() {
|
||||||
|
Terminal.hackFlag = true;
|
||||||
|
|
||||||
|
//Hacking through Terminal should be faster than hacking through a script
|
||||||
|
Terminal.actionTime = calculateHackingTime(Player.getCurrentServer()) / 4;
|
||||||
|
Terminal.startAction();
|
||||||
|
},
|
||||||
|
|
||||||
|
startAnalyze: function() {
|
||||||
|
Terminal.analyzeFlag = true;
|
||||||
|
Terminal.actionTime = 1;
|
||||||
|
post("Analyzing system...");
|
||||||
|
Terminal.startAction();
|
||||||
|
},
|
||||||
|
|
||||||
|
startAction: function() {
|
||||||
|
Terminal.actionStarted = true;
|
||||||
|
|
||||||
|
hackProgressPost("Time left:");
|
||||||
|
hackProgressBarPost("[");
|
||||||
|
|
||||||
|
//Disable terminal
|
||||||
|
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
||||||
|
$('input[class=terminal-input]').prop('disabled', true);
|
||||||
|
},
|
||||||
|
|
||||||
finishAction: function(cancelled = false) {
|
finishAction: function(cancelled = false) {
|
||||||
if (Terminal.hackFlag) {
|
if (Terminal.hackFlag) {
|
||||||
Terminal.finishHack(cancelled);
|
Terminal.finishHack(cancelled);
|
||||||
@ -633,10 +664,10 @@ let Terminal = {
|
|||||||
var server = Player.getCurrentServer();
|
var server = Player.getCurrentServer();
|
||||||
|
|
||||||
//Calculate whether hack was successful
|
//Calculate whether hack was successful
|
||||||
var hackChance = Player.calculateHackingChance();
|
var hackChance = calculateHackingChance(server);
|
||||||
var rand = Math.random();
|
var rand = Math.random();
|
||||||
console.log("Hack success chance: " + hackChance + ", rand: " + rand);
|
console.log("Hack success chance: " + hackChance + ", rand: " + rand);
|
||||||
var expGainedOnSuccess = Player.calculateExpGain();
|
var expGainedOnSuccess = calculateHackingExpGain(server);
|
||||||
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
||||||
if (rand < hackChance) { //Success!
|
if (rand < hackChance) { //Success!
|
||||||
if (SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
if (SpecialServerIps[SpecialServerNames.WorldDaemon] &&
|
||||||
@ -648,7 +679,7 @@ let Terminal = {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
server.manuallyHacked = true;
|
server.manuallyHacked = true;
|
||||||
var moneyGained = Player.calculatePercentMoneyHacked();
|
var moneyGained = calculatePercentMoneyHacked(server);
|
||||||
moneyGained = Math.floor(server.moneyAvailable * moneyGained);
|
moneyGained = Math.floor(server.moneyAvailable * moneyGained);
|
||||||
|
|
||||||
if (moneyGained <= 0) {moneyGained = 0;} //Safety check
|
if (moneyGained <= 0) {moneyGained = 0;} //Safety check
|
||||||
@ -679,43 +710,44 @@ let Terminal = {
|
|||||||
|
|
||||||
finishAnalyze: function(cancelled = false) {
|
finishAnalyze: function(cancelled = false) {
|
||||||
if (cancelled == false) {
|
if (cancelled == false) {
|
||||||
post(Player.getCurrentServer().hostname + ": ");
|
let currServ = Player.getCurrentServer();
|
||||||
post("Organization name: " + Player.getCurrentServer().organizationName);
|
post(currServ.hostname + ": ");
|
||||||
|
post("Organization name: " + currServ.organizationName);
|
||||||
var rootAccess = "";
|
var rootAccess = "";
|
||||||
if (Player.getCurrentServer().hasAdminRights) {rootAccess = "YES";}
|
if (currServ.hasAdminRights) {rootAccess = "YES";}
|
||||||
else {rootAccess = "NO";}
|
else {rootAccess = "NO";}
|
||||||
post("Root Access: " + rootAccess);
|
post("Root Access: " + rootAccess);
|
||||||
post("Required hacking skill: " + Player.getCurrentServer().requiredHackingSkill);
|
post("Required hacking skill: " + currServ.requiredHackingSkill);
|
||||||
post("Estimated server security level: " + formatNumber(addOffset(Player.getCurrentServer().hackDifficulty, 5), 3));
|
post("Server security level: " + formatNumber(currServ.hackDifficulty, 3));
|
||||||
post("Estimated chance to hack: " + formatNumber(addOffset(Player.calculateHackingChance() * 100, 5), 2) + "%");
|
post("Chance to hack: " + formatNumber(calculateHackingChance(currServ) * 100, 2) + "%");
|
||||||
post("Estimated time to hack: " + formatNumber(addOffset(Player.calculateHackingTime(), 5), 3) + " seconds");
|
post("Time to hack: " + formatNumber(calculateHackingTime(currServ), 3) + " seconds");
|
||||||
post("Estimated total money available on server: $" + formatNumber(addOffset(Player.getCurrentServer().moneyAvailable, 5), 2));
|
post("Total money available on server: $" + formatNumber(currServ.moneyAvailable, 2));
|
||||||
post("Required number of open ports for NUKE: " + Player.getCurrentServer().numOpenPortsRequired);
|
post("Required number of open ports for NUKE: " + currServ.numOpenPortsRequired);
|
||||||
if (Player.getCurrentServer().sshPortOpen) {
|
if (currServ.sshPortOpen) {
|
||||||
post("SSH port: Open")
|
post("SSH port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("SSH port: Closed")
|
post("SSH port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Player.getCurrentServer().ftpPortOpen) {
|
if (currServ.ftpPortOpen) {
|
||||||
post("FTP port: Open")
|
post("FTP port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("FTP port: Closed")
|
post("FTP port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Player.getCurrentServer().smtpPortOpen) {
|
if (currServ.smtpPortOpen) {
|
||||||
post("SMTP port: Open")
|
post("SMTP port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("SMTP port: Closed")
|
post("SMTP port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Player.getCurrentServer().httpPortOpen) {
|
if (currServ.httpPortOpen) {
|
||||||
post("HTTP port: Open")
|
post("HTTP port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("HTTP port: Closed")
|
post("HTTP port: Closed")
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Player.getCurrentServer().sqlPortOpen) {
|
if (currServ.sqlPortOpen) {
|
||||||
post("SQL port: Open")
|
post("SQL port: Open")
|
||||||
} else {
|
} else {
|
||||||
post("SQL port: Closed")
|
post("SQL port: Closed")
|
||||||
@ -815,17 +847,7 @@ let Terminal = {
|
|||||||
if (commandArray.length != 1) {
|
if (commandArray.length != 1) {
|
||||||
post("Incorrect usage of analyze command. Usage: analyze"); return;
|
post("Incorrect usage of analyze command. Usage: analyze"); return;
|
||||||
}
|
}
|
||||||
//Analyze the current server for information
|
Terminal.startAnalyze();
|
||||||
Terminal.analyzeFlag = true;
|
|
||||||
post("Analyzing system...");
|
|
||||||
hackProgressPost("Time left:");
|
|
||||||
hackProgressBarPost("[");
|
|
||||||
Player.analyze();
|
|
||||||
|
|
||||||
//Disable terminal
|
|
||||||
//Terminal.resetTerminalInput();
|
|
||||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
|
||||||
$('input[class=terminal-input]').prop('disabled', true);
|
|
||||||
iTutorialNextStep();
|
iTutorialNextStep();
|
||||||
} else {
|
} else {
|
||||||
post("Bad command. Please follow the tutorial");
|
post("Bad command. Please follow the tutorial");
|
||||||
@ -841,15 +863,7 @@ let Terminal = {
|
|||||||
break;
|
break;
|
||||||
case iTutorialSteps.TerminalManualHack:
|
case iTutorialSteps.TerminalManualHack:
|
||||||
if (commandArray.length == 1 && commandArray[0] == "hack") {
|
if (commandArray.length == 1 && commandArray[0] == "hack") {
|
||||||
Terminal.hackFlag = true;
|
Terminal.startHack();
|
||||||
hackProgressPost("Time left:");
|
|
||||||
hackProgressBarPost("[");
|
|
||||||
Player.hack();
|
|
||||||
|
|
||||||
//Disable terminal
|
|
||||||
//Terminal.resetTerminalInput();
|
|
||||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
|
||||||
$('input[class=terminal-input]').prop('disabled', true);
|
|
||||||
iTutorialNextStep();
|
iTutorialNextStep();
|
||||||
} else {post("Bad command. Please follow the tutorial");}
|
} else {post("Bad command. Please follow the tutorial");}
|
||||||
break;
|
break;
|
||||||
@ -920,17 +934,7 @@ let Terminal = {
|
|||||||
if (commandArray.length != 1) {
|
if (commandArray.length != 1) {
|
||||||
post("Incorrect usage of analyze command. Usage: analyze"); return;
|
post("Incorrect usage of analyze command. Usage: analyze"); return;
|
||||||
}
|
}
|
||||||
//Analyze the current server for information
|
Terminal.startAnalyze();
|
||||||
Terminal.analyzeFlag = true;
|
|
||||||
post("Analyzing system...");
|
|
||||||
hackProgressPost("Time left:");
|
|
||||||
hackProgressBarPost("[");
|
|
||||||
Player.analyze();
|
|
||||||
|
|
||||||
//Disable terminal
|
|
||||||
//Terminal.resetTerminalInput();
|
|
||||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
|
||||||
$('input[class=terminal-input]').prop('disabled', true);
|
|
||||||
break;
|
break;
|
||||||
case "buy":
|
case "buy":
|
||||||
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
||||||
@ -1083,15 +1087,7 @@ let Terminal = {
|
|||||||
} else if (Player.getCurrentServer().requiredHackingSkill > Player.hacking_skill) {
|
} else if (Player.getCurrentServer().requiredHackingSkill > Player.hacking_skill) {
|
||||||
post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill");
|
post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill");
|
||||||
} else {
|
} else {
|
||||||
Terminal.hackFlag = true;
|
Terminal.startHack();
|
||||||
hackProgressPost("Time left:");
|
|
||||||
hackProgressBarPost("[");
|
|
||||||
Player.hack();
|
|
||||||
|
|
||||||
//Disable terminal
|
|
||||||
//Terminal.resetTerminalInput();
|
|
||||||
document.getElementById("terminal-input-td").innerHTML = '<input type="text" class="terminal-input"/>';
|
|
||||||
$('input[class=terminal-input]').prop('disabled', true);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case "help":
|
case "help":
|
||||||
@ -1891,9 +1887,9 @@ let Terminal = {
|
|||||||
post("Server base security level: " + targetServer.baseDifficulty);
|
post("Server base security level: " + targetServer.baseDifficulty);
|
||||||
post("Server current security level: " + targetServer.hackDifficulty);
|
post("Server current security level: " + targetServer.hackDifficulty);
|
||||||
post("Server growth rate: " + targetServer.serverGrowth);
|
post("Server growth rate: " + targetServer.serverGrowth);
|
||||||
post("Netscript hack() execution time: " + formatNumber(scriptCalculateHackingTime(targetServer), 1) + "s");
|
post("Netscript hack() execution time: " + formatNumber(calculateHackingTime(targetServer), 1) + "s");
|
||||||
post("Netscript grow() execution time: " + formatNumber(scriptCalculateGrowTime(targetServer)/1000, 1) + "s");
|
post("Netscript grow() execution time: " + formatNumber(calculateGrowTime(targetServer), 1) + "s");
|
||||||
post("Netscript weaken() execution time: " + formatNumber(scriptCalculateWeakenTime(targetServer)/1000, 1) + "s");
|
post("Netscript weaken() execution time: " + formatNumber(calculateWeakenTime(targetServer), 1) + "s");
|
||||||
};
|
};
|
||||||
programHandlers[Programs.AutoLink.name] = () => {
|
programHandlers[Programs.AutoLink.name] = () => {
|
||||||
post("This executable cannot be run.");
|
post("This executable cannot be run.");
|
||||||
|
@ -923,14 +923,14 @@ let Engine = {
|
|||||||
Player.playtimeSinceLastBitnode += time;
|
Player.playtimeSinceLastBitnode += time;
|
||||||
|
|
||||||
//Start Manual hack
|
//Start Manual hack
|
||||||
if (Player.startAction == true) {
|
if (Terminal.actionStarted === true) {
|
||||||
Engine._totalActionTime = Player.actionTime;
|
Engine._totalActionTime = Terminal.actionTime;
|
||||||
Engine._actionTimeLeft = Player.actionTime;
|
Engine._actionTimeLeft = Terminal.actionTime;
|
||||||
Engine._actionInProgress = true;
|
Engine._actionInProgress = true;
|
||||||
Engine._actionProgressBarCount = 1;
|
Engine._actionProgressBarCount = 1;
|
||||||
Engine._actionProgressStr = "[ ]";
|
Engine._actionProgressStr = "[ ]";
|
||||||
Engine._actionTimeStr = "Time left: ";
|
Engine._actionTimeStr = "Time left: ";
|
||||||
Player.startAction = false;
|
Terminal.actionStarted = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Working
|
//Working
|
||||||
|
@ -48,6 +48,7 @@
|
|||||||
"ignore-params",
|
"ignore-params",
|
||||||
"ignore-properties"
|
"ignore-properties"
|
||||||
],
|
],
|
||||||
|
"no-magic-numbers": [true, -1, 0, 1, 2, 10, 100],
|
||||||
"no-null-keyword": false,
|
"no-null-keyword": false,
|
||||||
"no-unsafe-any": false,
|
"no-unsafe-any": false,
|
||||||
"object-literal-key-quotes": [
|
"object-literal-key-quotes": [
|
||||||
@ -59,6 +60,7 @@
|
|||||||
"allow-declarations",
|
"allow-declarations",
|
||||||
"allow-named-functions"
|
"allow-named-functions"
|
||||||
],
|
],
|
||||||
|
"triple-equals": [true, "allow-null-check", "allow-undefined-check"],
|
||||||
"typedef": [
|
"typedef": [
|
||||||
true,
|
true,
|
||||||
"call-signatures",
|
"call-signatures",
|
||||||
|
Loading…
Reference in New Issue
Block a user