mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +01:00
Implemented server growth (might need rebalancing). No wwhen a script is killed it is properly removed from the Active Scripts tab
This commit is contained in:
parent
e2316e4a1d
commit
f1ec376f33
11
README.md
11
README.md
@ -28,12 +28,21 @@ TESTING TODO:
|
|||||||
Seems to work, at least the basics (for online production)
|
Seems to work, at least the basics (for online production)
|
||||||
Script offline progress
|
Script offline progress
|
||||||
|
|
||||||
|
Delete a script from Active scripts when the WorkerScript is deleted
|
||||||
|
Seems to work
|
||||||
|
|
||||||
|
Server growth
|
||||||
|
Implemented but it might need to be balance/formula readjusted
|
||||||
|
|
||||||
|
|
||||||
Tasks TODO:
|
Tasks TODO:
|
||||||
ctrl+C functionality for all running command like hack(), analyze(), and tail
|
ctrl+C functionality for all running command like hack(), analyze(), and tail
|
||||||
Scroll all the way down when something is post()ed
|
Scroll all the way down when something is post()ed
|
||||||
Script logging functionality? Logs to internal "log file" (property of script itself)
|
Script logging functionality? Logs to internal "log file" (property of script itself)
|
||||||
Tutorial and help
|
Tutorial and help
|
||||||
Server growth
|
Secret Servers
|
||||||
|
|
||||||
|
Purchasing Servers
|
||||||
|
|
||||||
Hack time formula needs rebalancing I think
|
Hack time formula needs rebalancing I think
|
||||||
|
|
||||||
|
@ -19,6 +19,7 @@ Faction.prototype.setAugmentations = function(augs) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Factions = {}
|
||||||
Factions = {
|
Factions = {
|
||||||
//TODO Saving this for later, IShima is a kinda cool name maybe use it for something
|
//TODO Saving this for later, IShima is a kinda cool name maybe use it for something
|
||||||
//Endgame
|
//Endgame
|
||||||
|
@ -105,6 +105,9 @@ function runScriptsLoop() {
|
|||||||
|
|
||||||
//Delete script from workerScripts
|
//Delete script from workerScripts
|
||||||
workerScripts.splice(i, 1);
|
workerScripts.splice(i, 1);
|
||||||
|
|
||||||
|
//Delete script from Active Scripts
|
||||||
|
Engine.deleteActiveScriptsItem(i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,8 +197,6 @@ scriptCalculateOfflineProduction = function(script) {
|
|||||||
script.offlineRunningTime += timePassed;
|
script.offlineRunningTime += timePassed;
|
||||||
script.offlineExpGained += expGain;
|
script.offlineExpGained += expGain;
|
||||||
|
|
||||||
//TODO EXP
|
|
||||||
|
|
||||||
//DEBUG
|
//DEBUG
|
||||||
var serverName = AllServers[script.server].hostname;
|
var serverName = AllServers[script.server].hostname;
|
||||||
console.log(script.filename + " from server " + serverName + " generated $" + production.toString() + " while offline");
|
console.log(script.filename + " from server " + serverName + " generated $" + production.toString() + " while offline");
|
||||||
|
@ -32,11 +32,11 @@ function Server() {
|
|||||||
//Total money available on this server. How much of this you hack will be determined
|
//Total money available on this server. How much of this you hack will be determined
|
||||||
//by a formula related to hacking skill. The money available on a server will steadily increase
|
//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
|
//over time, and it will decrease when you hack it
|
||||||
this.moneyAvailable = 500;
|
this.moneyAvailable = 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)
|
||||||
this.serverGrowth = 1; //Affects how the moneyAvailable increases (1-100)
|
this.serverGrowth = 0; //Affects how the moneyAvailable increases (0-100)
|
||||||
this.timesHacked = 0;
|
this.timesHacked = 0;
|
||||||
|
|
||||||
//The IP's of all servers reachable from this one (what shows up if you run scan/netstat)
|
//The IP's of all servers reachable from this one (what shows up if you run scan/netstat)
|
||||||
@ -111,11 +111,8 @@ Server.fromJSON = function(value) {
|
|||||||
|
|
||||||
Reviver.constructors.Server = Server;
|
Reviver.constructors.Server = Server;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//world_daemon: new Server(), //Final server for 2nd tier prestige. Discover that the world is a simulation
|
//world_daemon: new Server(), //Final server for 2nd tier prestige. Discover that the world is a simulation
|
||||||
|
|
||||||
|
|
||||||
/* Initialization. Called only when loading a new game( no save file) */
|
/* Initialization. Called only when loading a new game( no save file) */
|
||||||
initForeignServers = function() {
|
initForeignServers = function() {
|
||||||
//MegaCorporations
|
//MegaCorporations
|
||||||
@ -607,6 +604,29 @@ initForeignServers = function() {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
||||||
|
//Server growth
|
||||||
|
processServerGrowth = function(numCycles) {
|
||||||
|
var numServerGrowthCycles = Math.max(Math.floor(numCycles / 450), 0);
|
||||||
|
|
||||||
|
for (var ip in AllServers) {
|
||||||
|
if (AllServers.hasOwnProperty(ip)) {
|
||||||
|
var server = AllServers[ip];
|
||||||
|
|
||||||
|
//Get the number of server growth cycles that will be applied based on the
|
||||||
|
//server's serverGrowth property
|
||||||
|
var serverGrowthPercentage = server.serverGrowth / 100;
|
||||||
|
var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage;
|
||||||
|
|
||||||
|
//Apply serverGrowth for the calculated number of growth cycles
|
||||||
|
var serverGrowth = Math.pow(1.0001, numServerGrowthCyclesAdjusted);
|
||||||
|
console.log("serverGrowth ratio: " + serverGrowth);
|
||||||
|
server.moneyAvailable *= serverGrowth;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
console.log("Server growth processed for " + numServerGrowthCycles + " cycles");
|
||||||
|
},
|
||||||
|
|
||||||
//List of all servers that exist in the game, indexed by their ip
|
//List of all servers that exist in the game, indexed by their ip
|
||||||
AllServers = {};
|
AllServers = {};
|
||||||
|
|
||||||
@ -637,7 +657,7 @@ GetServerByHostname = function(hostname) {
|
|||||||
for (var ip in AllServers) {
|
for (var ip in AllServers) {
|
||||||
if (AllServers.hasOwnProperty(ip)) {
|
if (AllServers.hasOwnProperty(ip)) {
|
||||||
if (AllServers[ip].hostname == hostname) {
|
if (AllServers[ip].hostname == hostname) {
|
||||||
return AllServers[i];
|
return AllServers[ip];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -181,6 +181,16 @@ var Engine = {
|
|||||||
Engine.ActiveScriptsList.appendChild(item);
|
Engine.ActiveScriptsList.appendChild(item);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
deleteActiveScriptsItem: function(i) {
|
||||||
|
var list = Engine.ActiveScriptsList.querySelectorAll('#active-scripts-list li');
|
||||||
|
if (i >= list.length) {
|
||||||
|
throw new Error("Trying to delete an out-of-range Active Scripts item");
|
||||||
|
}
|
||||||
|
|
||||||
|
var li = list[i];
|
||||||
|
li.parentNode.removeChild(li);
|
||||||
|
},
|
||||||
|
|
||||||
//Update the ActiveScriptsItems array
|
//Update the ActiveScriptsItems array
|
||||||
updateActiveScriptsItems: function() {
|
updateActiveScriptsItems: function() {
|
||||||
for (var i = 0; i < workerScripts.length; ++i) {
|
for (var i = 0; i < workerScripts.length; ++i) {
|
||||||
@ -216,7 +226,7 @@ var Engine = {
|
|||||||
|
|
||||||
//Server ip/hostname
|
//Server ip/hostname
|
||||||
var hostname = workerscript.getServer().hostname;
|
var hostname = workerscript.getServer().hostname;
|
||||||
var serverIpHostname = "Server: " + hostname + " (" + workerscript.serverIp + ")";
|
var serverIpHostname = "Server: " + hostname + "(" + workerscript.serverIp + ")";
|
||||||
|
|
||||||
//Online
|
//Online
|
||||||
var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
|
var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
|
||||||
@ -285,6 +295,7 @@ var Engine = {
|
|||||||
autoSaveCounter: 300, //Autosave every minute
|
autoSaveCounter: 300, //Autosave every minute
|
||||||
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
|
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
|
||||||
updateDisplays: 10, //Update displays such as Active Scripts display and character display
|
updateDisplays: 10, //Update displays such as Active Scripts display and character display
|
||||||
|
serverGrowth: 450, //Process server growth every minute and a half
|
||||||
},
|
},
|
||||||
|
|
||||||
decrementAllCounters: function(numCycles = 1) {
|
decrementAllCounters: function(numCycles = 1) {
|
||||||
@ -317,6 +328,12 @@ var Engine = {
|
|||||||
|
|
||||||
Engine.Counters.updateDisplays = 10;
|
Engine.Counters.updateDisplays = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Engine.Counters.serverGrowth <= 0) {
|
||||||
|
var numCycles = Math.floor((450 - Engine.Counters.serverGrowth));
|
||||||
|
processServerGrowth(numCycles);
|
||||||
|
Engine.Counters.serverGrowth = 450;
|
||||||
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
/* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */
|
/* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */
|
||||||
@ -363,7 +380,14 @@ var Engine = {
|
|||||||
if (Engine.loadSave()) {
|
if (Engine.loadSave()) {
|
||||||
console.log("Loaded game from save");
|
console.log("Loaded game from save");
|
||||||
CompanyPositions.init();
|
CompanyPositions.init();
|
||||||
loadAllRunningScripts(); //This also takes care of offline production
|
|
||||||
|
//Calculate the number of cycles have elapsed while offline
|
||||||
|
var thisUpdate = new Date().getTime();
|
||||||
|
var lastUpdate = Player.lastUpdate;
|
||||||
|
var numCyclesOffline = Math.floor((thisUpdate - lastUpdate) / Engine._idleSpeed);
|
||||||
|
|
||||||
|
processServerGrowth(numCyclesOffline); //Should be done before offline production for scripts
|
||||||
|
loadAllRunningScripts(); //This also takes care of offline production for those scripts
|
||||||
} else {
|
} else {
|
||||||
//No save found, start new game
|
//No save found, start new game
|
||||||
console.log("Initializing new game");
|
console.log("Initializing new game");
|
||||||
|
Loading…
Reference in New Issue
Block a user