mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 20:55:44 +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)
|
||||
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:
|
||||
ctrl+C functionality for all running command like hack(), analyze(), and tail
|
||||
Scroll all the way down when something is post()ed
|
||||
Script logging functionality? Logs to internal "log file" (property of script itself)
|
||||
Tutorial and help
|
||||
Server growth
|
||||
Secret Servers
|
||||
|
||||
Purchasing Servers
|
||||
|
||||
Hack time formula needs rebalancing I think
|
||||
|
||||
|
@ -19,6 +19,7 @@ Faction.prototype.setAugmentations = function(augs) {
|
||||
}
|
||||
}
|
||||
|
||||
Factions = {}
|
||||
Factions = {
|
||||
//TODO Saving this for later, IShima is a kinda cool name maybe use it for something
|
||||
//Endgame
|
||||
|
@ -105,6 +105,9 @@ function runScriptsLoop() {
|
||||
|
||||
//Delete script from workerScripts
|
||||
workerScripts.splice(i, 1);
|
||||
|
||||
//Delete script from Active Scripts
|
||||
Engine.deleteActiveScriptsItem(i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -197,8 +197,6 @@ scriptCalculateOfflineProduction = function(script) {
|
||||
script.offlineRunningTime += timePassed;
|
||||
script.offlineExpGained += expGain;
|
||||
|
||||
//TODO EXP
|
||||
|
||||
//DEBUG
|
||||
var serverName = AllServers[script.server].hostname;
|
||||
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
|
||||
//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 = 500;
|
||||
this.moneyAvailable = 0;
|
||||
|
||||
//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.serverGrowth = 1; //Affects how the moneyAvailable increases (1-100)
|
||||
this.serverGrowth = 0; //Affects how the moneyAvailable increases (0-100)
|
||||
this.timesHacked = 0;
|
||||
|
||||
//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;
|
||||
|
||||
|
||||
|
||||
//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) */
|
||||
initForeignServers = function() {
|
||||
//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
|
||||
AllServers = {};
|
||||
|
||||
@ -637,7 +657,7 @@ GetServerByHostname = function(hostname) {
|
||||
for (var ip in AllServers) {
|
||||
if (AllServers.hasOwnProperty(ip)) {
|
||||
if (AllServers[ip].hostname == hostname) {
|
||||
return AllServers[i];
|
||||
return AllServers[ip];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -181,6 +181,16 @@ var Engine = {
|
||||
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
|
||||
updateActiveScriptsItems: function() {
|
||||
for (var i = 0; i < workerScripts.length; ++i) {
|
||||
@ -216,7 +226,7 @@ var Engine = {
|
||||
|
||||
//Server ip/hostname
|
||||
var hostname = workerscript.getServer().hostname;
|
||||
var serverIpHostname = "Server: " + hostname + " (" + workerscript.serverIp + ")";
|
||||
var serverIpHostname = "Server: " + hostname + "(" + workerscript.serverIp + ")";
|
||||
|
||||
//Online
|
||||
var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime;
|
||||
@ -285,6 +295,7 @@ var Engine = {
|
||||
autoSaveCounter: 300, //Autosave every minute
|
||||
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
|
||||
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) {
|
||||
@ -317,6 +328,12 @@ var Engine = {
|
||||
|
||||
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 */
|
||||
@ -363,7 +380,14 @@ var Engine = {
|
||||
if (Engine.loadSave()) {
|
||||
console.log("Loaded game from save");
|
||||
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 {
|
||||
//No save found, start new game
|
||||
console.log("Initializing new game");
|
||||
|
Loading…
Reference in New Issue
Block a user