mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 09:43:54 +01:00
Edit scripts that are running. Implement maximum money on server
This commit is contained in:
parent
1a7a247b4d
commit
c331bd7add
@ -307,8 +307,9 @@ CONSTANTS = {
|
|||||||
"<i>hack(hostname/ip)</i><br>Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " +
|
"<i>hack(hostname/ip)</i><br>Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " +
|
||||||
"either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " +
|
"either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " +
|
||||||
" A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. " +
|
" A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. " +
|
||||||
"For example, you can create a script that hacks the 'foodnstuff' server and run that script on any server in the game. Calling hack() on " +
|
"For example, you can create a script that hacks the 'foodnstuff' server and run that script on any server in the game. A successful hack() on " +
|
||||||
"a server will raise that server's security level by " + this.ServerFortifyAmount + ".<br>" +
|
"a server will raise that server's security level by " + this.ServerFortifyAmount + ". Returns true if the hack is successful and " +
|
||||||
|
"false otherwise. <br>" +
|
||||||
"Examples: hack('foodnstuff'); or hack('148.192.0.12');<br><br>" +
|
"Examples: hack('foodnstuff'); or hack('148.192.0.12');<br><br>" +
|
||||||
"<i>sleep(n)</i><br>Suspends the script for n milliseconds. <br>Example: sleep(5000);<br><br>" +
|
"<i>sleep(n)</i><br>Suspends the script for n milliseconds. <br>Example: sleep(5000);<br><br>" +
|
||||||
"<i>grow(hostname/ip)</i><br>Use your hacking skills to increase the amount of money available on a server. The argument passed in " +
|
"<i>grow(hostname/ip)</i><br>Use your hacking skills to increase the amount of money available on a server. The argument passed in " +
|
||||||
@ -318,13 +319,15 @@ CONSTANTS = {
|
|||||||
"Like hack(), grow() can be called on any server, regardless of where the script is running. " +
|
"Like hack(), grow() can be called on any server, regardless of where the script is running. " +
|
||||||
"The grow() command requires root access to the target server, but there is no required hacking level to run the command. " +
|
"The grow() command requires root access to the target server, but there is no required hacking level to run the command. " +
|
||||||
"It grants 0.5 hacking exp when it completes. It also raises the security level of the target server by " + (2 * this.ServerFortifyAmount) + ". " +
|
"It grants 0.5 hacking exp when it completes. It also raises the security level of the target server by " + (2 * this.ServerFortifyAmount) + ". " +
|
||||||
|
"Returns the number by which the money on the server was multiplied for the growth. " +
|
||||||
"Works offline at a slower rate. <br> Example: grow('foodnstuff');<br><br>" +
|
"Works offline at a slower rate. <br> Example: grow('foodnstuff');<br><br>" +
|
||||||
"<i>weaken(hostname/ip)</i><br>Use your hacking skills to attack a server's security, lowering the server's security level. The argument passed " +
|
"<i>weaken(hostname/ip)</i><br>Use your hacking skills to attack a server's security, lowering the server's security level. The argument passed " +
|
||||||
"in must be a string with either the IP or hostname of the target server. The runtime for this command depends on your " +
|
"in must be a string with either the IP or hostname of the target server. The runtime for this command depends on your " +
|
||||||
"hacking level and the target server's security level. This function lowers the security level of the target server by " +
|
"hacking level and the target server's security level. This function lowers the security level of the target server by " +
|
||||||
this.ServerWeakenAmount + ".<br><br> Like hack() and grow(), weaken() can be called on " +
|
this.ServerWeakenAmount + ".<br><br> Like hack() and grow(), weaken() can be called on " +
|
||||||
"any server, regardless of where the script is running. This command requires root access to the target server, but " +
|
"any server, regardless of where the script is running. This command requires root access to the target server, but " +
|
||||||
"there is no required hacking level to run the command. Grants 3 hacking exp when it completes. Works offline at a slower rate<br> Example: weaken('foodnstuff');<br><br>" +
|
"there is no required hacking level to run the command. Grants 3 hacking exp when it completes. Returns " +
|
||||||
|
this.ServerWeakenAmount + ". Works offline at a slower rate<br> Example: weaken('foodnstuff');<br><br>" +
|
||||||
"<i>print(x)</i> <br> Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command )<br><br>" +
|
"<i>print(x)</i> <br> Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command )<br><br>" +
|
||||||
"<i>nuke(hostname/ip)</i><br>Run NUKE.exe on the target server. NUKE.exe must exist on your home computer. Does NOT work while offline <br> Example: nuke('foodnstuff'); <br><br>" +
|
"<i>nuke(hostname/ip)</i><br>Run NUKE.exe on the target server. NUKE.exe must exist on your home computer. Does NOT work while offline <br> Example: nuke('foodnstuff'); <br><br>" +
|
||||||
"<i>brutessh(hostname/ip)</i><br>Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer. Does NOT work while offline <br> Example: brutessh('foodnstuff');<br><br>" +
|
"<i>brutessh(hostname/ip)</i><br>Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer. Does NOT work while offline <br> Example: brutessh('foodnstuff');<br><br>" +
|
||||||
@ -537,7 +540,7 @@ CONSTANTS = {
|
|||||||
"such as a variable assignment, a function call, a binary operator, getting a variable's value, etc. used to take up to several seconds, " +
|
"such as a variable assignment, a function call, a binary operator, getting a variable's value, etc. used to take up to several seconds, " +
|
||||||
"now each one should only take 750 milliseconds). <br> " +
|
"now each one should only take 750 milliseconds). <br> " +
|
||||||
"-Percentage money stolen when hacking lowered to compensate for faster script speeds<br>" +
|
"-Percentage money stolen when hacking lowered to compensate for faster script speeds<br>" +
|
||||||
"-Hacking experience granted by grow() halved<b>" +
|
"-Hacking experience granted by grow() halved<br>" +
|
||||||
"-Weaken() is now ~11% faster, but only grants 3 base hacking exp upon completion instead of 5 <br>" +
|
"-Weaken() is now ~11% faster, but only grants 3 base hacking exp upon completion instead of 5 <br>" +
|
||||||
"-Rebalancing of script RAM costs. Base RAM Cost for a script increased from 1GB to 1.5GB. Loops, hack(), grow() " +
|
"-Rebalancing of script RAM costs. Base RAM Cost for a script increased from 1GB to 1.5GB. Loops, hack(), grow() " +
|
||||||
"and weaken() all cost slightly less RAM than before <br>" +
|
"and weaken() all cost slightly less RAM than before <br>" +
|
||||||
@ -555,6 +558,9 @@ CONSTANTS = {
|
|||||||
"server's security level by " + (2 * this.ServerFortifyAmount) + ". For reference, if a server has a security level of 10 " +
|
"server's security level by " + (2 * this.ServerFortifyAmount) + ". For reference, if a server has a security level of 10 " +
|
||||||
"it will have approximately the same growth rate as before. <br>" +
|
"it will have approximately the same growth rate as before. <br>" +
|
||||||
"-Server growth no longer happens naturally<br>" +
|
"-Server growth no longer happens naturally<br>" +
|
||||||
|
"-Servers now have a maximum limit to their money. This limit is 50 times it's starting money<br>" +
|
||||||
|
"-Hacking now grants 10% less hacking experience<br> " +
|
||||||
|
"-You can now edit scripts that are running<br>" +
|
||||||
"v0.19.7<br>" +
|
"v0.19.7<br>" +
|
||||||
"-Added changelog to Options menu<br>" +
|
"-Added changelog to Options menu<br>" +
|
||||||
"-Bug fix with autocompletion (wasn't working properly for capitalized filenames/programs<br><br>" +
|
"-Bug fix with autocompletion (wasn't working properly for capitalized filenames/programs<br><br>" +
|
||||||
|
@ -957,7 +957,7 @@ function scriptCalculateHackingTime(server) {
|
|||||||
|
|
||||||
//The same as Player's calculateExpGain() function but takes in the server as an argument
|
//The same as Player's calculateExpGain() function but takes in the server as an argument
|
||||||
function scriptCalculateExpGain(server) {
|
function scriptCalculateExpGain(server) {
|
||||||
return (server.hackDifficulty * Player.hacking_exp_mult);
|
return (server.hackDifficulty * Player.hacking_exp_mult * 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument
|
//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument
|
||||||
|
@ -254,7 +254,7 @@ PlayerObject.prototype.calculatePercentMoneyHacked = function() {
|
|||||||
//The formula is:
|
//The formula is:
|
||||||
// difficulty * requiredLevel * hacking_multiplier
|
// difficulty * requiredLevel * hacking_multiplier
|
||||||
PlayerObject.prototype.calculateExpGain = function() {
|
PlayerObject.prototype.calculateExpGain = function() {
|
||||||
return (this.getCurrentServer().hackDifficulty * this.hacking_exp_mult);
|
return (this.getCurrentServer().hackDifficulty * this.hacking_exp_mult * 0.9);
|
||||||
}
|
}
|
||||||
|
|
||||||
//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
|
//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
|
||||||
|
@ -12,6 +12,7 @@ function BitburnerSaveObject() {
|
|||||||
this.AugmentationsSave = "";
|
this.AugmentationsSave = "";
|
||||||
this.AliasesSave = "";
|
this.AliasesSave = "";
|
||||||
this.MessagesSave = "";
|
this.MessagesSave = "";
|
||||||
|
this.VersionSave = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
BitburnerSaveObject.prototype.saveGame = function() {
|
BitburnerSaveObject.prototype.saveGame = function() {
|
||||||
@ -23,6 +24,7 @@ BitburnerSaveObject.prototype.saveGame = function() {
|
|||||||
this.AugmentationsSave = JSON.stringify(Augmentations);
|
this.AugmentationsSave = JSON.stringify(Augmentations);
|
||||||
this.AliasesSave = JSON.stringify(Aliases);
|
this.AliasesSave = JSON.stringify(Aliases);
|
||||||
this.MessagesSave = JSON.stringify(Messages);
|
this.MessagesSave = JSON.stringify(Messages);
|
||||||
|
this.VersionSave = JSON.stringify(CONSTANTS.Version);
|
||||||
|
|
||||||
var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this))));
|
var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this))));
|
||||||
window.localStorage.setItem("bitburnerSave", saveString);
|
window.localStorage.setItem("bitburnerSave", saveString);
|
||||||
@ -63,6 +65,18 @@ loadGame = function(saveObj) {
|
|||||||
} else {
|
} else {
|
||||||
initMessages();
|
initMessages();
|
||||||
}
|
}
|
||||||
|
if (saveObj.hasOwnProperty("VersionSave")) {
|
||||||
|
try {
|
||||||
|
var ver = JSON.parse(saveObj.VersionSave, Reviver);
|
||||||
|
if (ver != CONSTANTS.Version) {
|
||||||
|
//TODO Create update pop up
|
||||||
|
}
|
||||||
|
} catch(e) {
|
||||||
|
Engine.version = CONSTANTS.Version;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Engine.version = CONSTANTS.Version;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -31,10 +31,9 @@ function Server() {
|
|||||||
//by a separate formula
|
//by a separate formula
|
||||||
this.requiredHackingSkill = 1;
|
this.requiredHackingSkill = 1;
|
||||||
|
|
||||||
//Total money available on this server. How much of this you hack will be determined
|
//Total money available on this server
|
||||||
//by a formula related to hacking skill. The money available on a server will steadily increase
|
|
||||||
//over time, and it will decrease when you hack it
|
|
||||||
this.moneyAvailable = 0;
|
this.moneyAvailable = 0;
|
||||||
|
this.moneyMax = 0;
|
||||||
|
|
||||||
//Parameters used in formulas that dictate how moneyAvailable and requiredHackingSkill change.
|
//Parameters used in formulas that dictate how moneyAvailable and requiredHackingSkill change.
|
||||||
this.hackDifficulty = 1; //Affects hack success rate and how the requiredHackingSkill increases over time (1-100)
|
this.hackDifficulty = 1; //Affects hack success rate and how the requiredHackingSkill increases over time (1-100)
|
||||||
@ -79,6 +78,7 @@ Server.prototype.init = function(ip, hostname, organizationName, onlineStatus, i
|
|||||||
Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) {
|
Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) {
|
||||||
this.requiredHackingSkill = requiredHackingSkill;
|
this.requiredHackingSkill = requiredHackingSkill;
|
||||||
this.moneyAvailable = moneyAvailable;
|
this.moneyAvailable = moneyAvailable;
|
||||||
|
this.moneyMax = 50 * moneyAvailable;
|
||||||
this.hackDifficulty = hackDifficulty;
|
this.hackDifficulty = hackDifficulty;
|
||||||
this.serverGrowth = serverGrowth;
|
this.serverGrowth = serverGrowth;
|
||||||
}
|
}
|
||||||
@ -696,7 +696,12 @@ processSingleServerGrowth = function(server, numCycles) {
|
|||||||
console.log("WARN: serverGrowth calculated to be less than 1");
|
console.log("WARN: serverGrowth calculated to be less than 1");
|
||||||
serverGrowth = 1;
|
serverGrowth = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
server.moneyAvailable *= serverGrowth;
|
server.moneyAvailable *= serverGrowth;
|
||||||
|
if (server.moneyMax && server.moneyAvailable >= server.moneyMax) {
|
||||||
|
server.moneyAvailable = server.moneyMax;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
server.fortify(2 * CONSTANTS.ServerFortifyAmount);
|
server.fortify(2 * CONSTANTS.ServerFortifyAmount);
|
||||||
return serverGrowth;
|
return serverGrowth;
|
||||||
}
|
}
|
||||||
|
@ -757,13 +757,6 @@ var Terminal = {
|
|||||||
//Script name is the filename without the .script at the end
|
//Script name is the filename without the .script at the end
|
||||||
var scriptname = filename.substr(0, filename.indexOf(".script"));
|
var scriptname = filename.substr(0, filename.indexOf(".script"));
|
||||||
|
|
||||||
//Cannot edit scripts that are currently running
|
|
||||||
for (var i = 0; i < Player.getCurrentServer().runningScripts.length; i++) {
|
|
||||||
if (filename == Player.getCurrentServer().runningScripts[i]) {
|
|
||||||
post("Cannot open/edit scripts that are currently running!"); return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//Check if the script already exists
|
//Check if the script already exists
|
||||||
for (var i = 0; i < Player.getCurrentServer().scripts.length; i++) {
|
for (var i = 0; i < Player.getCurrentServer().scripts.length; i++) {
|
||||||
if (filename == Player.getCurrentServer().scripts[i].filename) {
|
if (filename == Player.getCurrentServer().scripts[i].filename) {
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
var Engine = {
|
var Engine = {
|
||||||
|
version: "",
|
||||||
Debug: true,
|
Debug: true,
|
||||||
|
|
||||||
//Clickable objects
|
//Clickable objects
|
||||||
@ -698,7 +699,7 @@ var Engine = {
|
|||||||
initAugmentations();
|
initAugmentations();
|
||||||
|
|
||||||
//Start interactive tutorial
|
//Start interactive tutorial
|
||||||
iTutorialStart();
|
iTutorialStart();
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user