mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 20:55:44 +01:00
Lowered cost for NeuroFlux governor. Fixed tab completion for scp command. Fixed bugs with Netscript scp command
This commit is contained in:
parent
7d22691ac2
commit
ad6f74a16d
@ -30,7 +30,7 @@ CONSTANTS = {
|
||||
|
||||
/* Augmentation */
|
||||
//NeuroFlux Governor cost multiplier as you level up
|
||||
NeuroFluxGovernorLevelMult: 1.18,
|
||||
NeuroFluxGovernorLevelMult: 1.14,
|
||||
|
||||
/* Script related things */
|
||||
//Time (ms) it takes to run one operation in Netscript.
|
||||
@ -49,6 +49,7 @@ CONSTANTS = {
|
||||
ScriptHttpwormRamCost: 0.05,
|
||||
ScriptSqlinjectRamCost: 0.05,
|
||||
ScriptRunRamCost: 0.8,
|
||||
ScriptScpRamCost: 0.5,
|
||||
ScriptHasRootAccessRamCost: 0.05,
|
||||
ScriptGetHostnameRamCost: 0.1,
|
||||
ScriptGetHackingLevelRamCost: 0.1,
|
||||
|
@ -708,7 +708,7 @@ function evaluate(exp, workerScript) {
|
||||
reject(e);
|
||||
});
|
||||
} else if (exp.func.value == "scp") {
|
||||
if (exp.args.length != 1) {
|
||||
if (exp.args.length != 2) {
|
||||
reject(makeRuntimeRejectMsg(workerScript, "scp() call has incorrect number of arguments. Takes 2 arguments"));
|
||||
return;
|
||||
}
|
||||
@ -725,7 +725,7 @@ function evaluate(exp, workerScript) {
|
||||
//Check that a script with this filename does not already exist
|
||||
for (var i = 0; i < destServer.scripts.length; ++i) {
|
||||
if (scriptname == destServer.scripts[i].filename) {
|
||||
workerScript.scriptRef.log(destServ.hostname + " already contains a script named " + scriptname);
|
||||
workerScript.scriptRef.log(destServer.hostname + " already contains a script named " + scriptname);
|
||||
resolve(false);
|
||||
return;
|
||||
}
|
||||
@ -742,9 +742,9 @@ function evaluate(exp, workerScript) {
|
||||
newScript.filename = scriptname;
|
||||
newScript.code = currServ.scripts[i].code;
|
||||
newScript.ramUsage = currServ.scripts[i].ramUsage;
|
||||
newScript.server = ip;
|
||||
server.scripts.push(newScript);
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + server.hostname);
|
||||
newScript.server = destServer.ip;
|
||||
destServer.scripts.push(newScript);
|
||||
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
|
||||
resolve(true);
|
||||
return;
|
||||
}
|
||||
@ -1259,7 +1259,7 @@ function scriptCalculateExpGain(server) {
|
||||
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 / 825;
|
||||
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 725;
|
||||
if (percentMoneyHacked < 0) {return 0;}
|
||||
if (percentMoneyHacked > 1) {return 1;}
|
||||
return percentMoneyHacked;
|
||||
|
@ -243,7 +243,7 @@ PlayerObject.prototype.calculateHackingTime = function() {
|
||||
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 / 825;
|
||||
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult / 725;
|
||||
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
|
||||
if (percentMoneyHacked < 0) {return 0;}
|
||||
if (percentMoneyHacked > 1) {return 1;}
|
||||
|
@ -182,6 +182,7 @@ Script.prototype.updateRamUsage = function() {
|
||||
var httpwormCount = numOccurrences(codeCopy, "httpworm(");
|
||||
var sqlinjectCount = numOccurrences(codeCopy, "sqlinject(");
|
||||
var runCount = numOccurrences(codeCopy, "run(");
|
||||
var scpCount = numOccurrences(codeCopy, "scp(");
|
||||
var hasRootAccessCount = numOccurrences(codeCopy, "hasRootAccess(");
|
||||
var getHostnameCount = numOccurrences(codeCopy, "getHostname(");
|
||||
var getHackingLevelCount = numOccurrences(codeCopy, "getHackingLevel(");
|
||||
@ -206,6 +207,7 @@ Script.prototype.updateRamUsage = function() {
|
||||
(httpwormCount * CONSTANTS.ScriptHttpwormRamCost) +
|
||||
(sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) +
|
||||
(runCount * CONSTANTS.ScriptRunRamCost) +
|
||||
(scpCount * CONSTANTS.ScriptScpRamCost) +
|
||||
(hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) +
|
||||
(getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) +
|
||||
(getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) +
|
||||
|
@ -102,18 +102,28 @@ $(document).keydown(function(event) {
|
||||
input = input.trim();
|
||||
input = input.replace(/\s\s+/g, ' ');
|
||||
|
||||
var allPos = determineAllPossibilitiesForTabCompletion(input);
|
||||
var commandArray = input.split(" ");
|
||||
var index = commandArray.length - 2;
|
||||
if (index < 0) {index = 0;}
|
||||
var allPos = determineAllPossibilitiesForTabCompletion(input, index);
|
||||
if (allPos.length == 0) {return;}
|
||||
|
||||
var commandArray = input.split(" ");
|
||||
|
||||
|
||||
var arg = "";
|
||||
var command = "";
|
||||
if (commandArray.length == 0) {return;}
|
||||
else if (commandArray.length > 1) {
|
||||
else if (commandArray.length == 2) {
|
||||
command = commandArray[0];
|
||||
arg = commandArray[1];
|
||||
} else if (commandArray.length == 3) {
|
||||
command = commandArray[0] + " " + commandArray[1];
|
||||
arg = commandArray[2];
|
||||
} else {
|
||||
command = commandArray[0];
|
||||
}
|
||||
|
||||
tabCompletion(commandArray[0], arg, allPos);
|
||||
tabCompletion(command, arg, allPos);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -155,7 +165,8 @@ $(document).keyup(function(e) {
|
||||
// a series of possible options for
|
||||
// allPossibilities - Array of strings containing all possibilities that the
|
||||
// string can complete to
|
||||
function tabCompletion(command, arg, allPossibilities) {
|
||||
// index - index of argument that is being "tab completed". By default is 0, the first argument
|
||||
function tabCompletion(command, arg, allPossibilities, index=0) {
|
||||
if (!(allPossibilities.constructor === Array)) {return;}
|
||||
if (!containsAllStrings(allPossibilities)) {return;}
|
||||
|
||||
@ -191,9 +202,19 @@ function tabCompletion(command, arg, allPossibilities) {
|
||||
}
|
||||
}
|
||||
|
||||
function determineAllPossibilitiesForTabCompletion(input) {
|
||||
function determineAllPossibilitiesForTabCompletion(input, index=0) {
|
||||
var allPos = [];
|
||||
var currServ = Player.getCurrentServer();
|
||||
|
||||
if (input.startsWith("scp ") && index == 1) {
|
||||
for (var iphostname in AllServers) {
|
||||
if (AllServers.hasOwnProperty(iphostname)) {
|
||||
allPos.push(AllServers[iphostname].ip);
|
||||
allPos.push(AllServers[iphostname].hostname);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (input.startsWith("connect ") || input.startsWith("telnet ")) {
|
||||
//All network connections
|
||||
for (var i = 0; i < currServ.serversOnNetwork.length; ++i) {
|
||||
@ -207,7 +228,8 @@ function determineAllPossibilitiesForTabCompletion(input) {
|
||||
|
||||
if (input.startsWith("kill ") || input.startsWith("nano ") ||
|
||||
input.startsWith("tail ") || input.startsWith("rm ") ||
|
||||
input.startsWith("mem ")) {
|
||||
input.startsWith("mem ") ||
|
||||
(input.startsWith("scp ") && index == 0)) {
|
||||
//All Scripts
|
||||
for (var i = 0; i < currServ.scripts.length; ++i) {
|
||||
allPos.push(currServ.scripts[i].filename);
|
||||
|
Loading…
Reference in New Issue
Block a user