Merge pull request #36 from danielyxie/dev

Dev v0.18.3
This commit is contained in:
danielyxie 2017-06-01 13:57:59 -05:00 committed by GitHub
commit 157a75c8c7
6 changed files with 18 additions and 27 deletions

@ -12,20 +12,6 @@
background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
/*
.dialog-box-container {
display: block;
position: relative;
z-index: 2;
margin: auto;
width: 50%;
height: 100%;
vertical-align: middle;
overflow: auto;
background-color: black;
background-color: rgba(0,0,0,0.4);
}
*/
.dialog-box-container {
display: block;
position: absolute;

@ -1,5 +1,5 @@
CONSTANTS = {
Version: "0.18.2",
Version: "0.18.3",
//Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience
//and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then
@ -18,7 +18,7 @@ CONSTANTS = {
BaseCostForHacknetNodeCore: 500000,
/* Hacknet Node constants */
HacknetNodeMoneyGainPerLevel: 1.5,
HacknetNodeMoneyGainPerLevel: 1.6,
HacknetNodePurchaseNextMult: 1.39, //Multiplier when purchasing an additional hacknet node
HacknetNodeUpgradeLevelMult: 1.04, //Multiplier for cost when upgrading level
HacknetNodeUpgradeRamMult: 1.26, //Multiplier for cost when upgrading RAM
@ -247,7 +247,11 @@ CONSTANTS = {
"It is important to note that for this reason, conditionals such as if/else statements and certain " +
"commands such as purchaseHacknetNode() or nuke() will not work while the game is offline.<br><br>" +
"However, Scripts WILL continue to generate money and hacking exp for you while the game is offline. This " +
"offline production is based off of the scripts' production while the game is online.<br><br> " +
"offline production is based off of the scripts' production while the game is online. <br><br>" +
"grow() and weaken() are two Netscript commands that will also be applied when the game is offline, although at a slower rate " +
"compared to if the game was open. This is done by having each script keep track of the " +
"rate at which the grow() and weaken() commands are called when the game is online. These calculated rates are used to determine how many times " +
"these function calls would be made while the game is offline. <br><br> " +
"Also, note that because of the way the Netscript interpreter is implemented, " +
"whenever you reload or re-open the game all of the scripts that you are running will " +
"start running from the BEGINNING of the code. The game does not keep track of where exactly " +
@ -291,10 +295,10 @@ CONSTANTS = {
"<i>grow(hostname/ip)</i><br>Use your hacking skills to increase the amount of money available on a server. The argument passed in " +
"must be a string with either the IP or hostname of the target server. The grow() command requires root access to the target server, but " +
"there is no required hacking level to run the command. " +
"Grants 1 hacking exp when it completes. <br> Example: grow('foodnstuff');<br><br>" +
"Grants 1 hacking exp when it completes. 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 " +
"in must be a string with either the IP or hostname of the target server. This command requires root access to the target server, but " +
"there is no required hacking level to run the command. Grants 5 hacking exp when it completes. <br> Example: weaken('foodnstuff');<br><br>" +
"there is no required hacking level to run the command. Grants 5 hacking exp when it completes. 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>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>" +

@ -49,7 +49,7 @@ HacknetNode.prototype.updateMoneyGainRate = function() {
var gainPerLevel = CONSTANTS.HacknetNodeMoneyGainPerLevel;
this.moneyGainRatePerSecond = (this.level * gainPerLevel) *
Math.pow(1.03, this.ram-1) *
Math.pow(1.035, this.ram-1) *
((this.numCores + 5) / 6) * Player.hacknet_node_money_mult;
if (isNaN(this.moneyGainRatePerSecond)) {
this.moneyGainRatePerSecond = 0;
@ -76,7 +76,7 @@ HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
if (isNaN(cost)) {return false;}
if (cost > Player.money) {return false;}
Player.loseMoney(cost);
if (this.level + levels >= CONSTANTS.HacknetNodeMaxLevel) {
if (this.level + levels > CONSTANTS.HacknetNodeMaxLevel) {
var diff = Math.max(0, CONSTANTS.HacknetNodeMaxLevel - this.level);
return this.purchaseLevelUpgrade(diff);
}

@ -33,7 +33,7 @@ function runScriptsLoop() {
var ast = Parser(Tokenizer(InputStream(workerScripts[i].code)));
//console.log(ast);
} catch (e) {
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":", e, "", "");
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":<br>" + e);
workerScripts[i].env.stopFlag = true;
continue;
}

@ -406,7 +406,7 @@ scriptCalculateOfflineProduction = function(script) {
if (serv == null) {continue;}
var timesHacked = Math.round(0.5 * script.numTimesHackMap[ip] / script.onlineRunningTime * timePassed);
console.log(script.filename + " hacked " + serv.hostname + " " + timesHacked + " times while offline");
script.log(script.filename + " hacked " + serv.hostname + " " + timesHacked + " times while offline");
script.log("Hacked " + serv.hostname + " " + timesHacked + " times while offline");
serv.fortify(CONSTANTS.ServerFortifyAmount * timesHacked);
}
}
@ -419,7 +419,7 @@ scriptCalculateOfflineProduction = function(script) {
if (serv == null) {continue;}
var timesWeakened = Math.round(0.5 * script.numTimesWeakenMap[ip] / script.onlineRunningTime * timePassed);
console.log(script.filename + " called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline");
script.log(script.filename + " called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline");
script.log("Called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline");
serv.weaken(CONSTANTS.ServerWeakenAmount * timesWeakened);
}
}
@ -432,12 +432,12 @@ scriptCalculateOfflineProduction = function(script) {
if (serv == null) {continue;}
var timesGrown = Math.round(0.5 * script.numTimesGrowMap[ip] / script.onlineRunningTime * timePassed);
console.log(script.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
script.log(script.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
//TODO
script.log("Called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
var growth = processSingleServerGrowth(serv, timesGrown * 450);
script.log(serv.hostname + " grown by " + formatNumber(growth * 100 - 100, 6) + "% from grow() calls made while offline");
}
}
return totalOfflineProduction;
}

@ -22,6 +22,7 @@ function Server() {
this.scripts = [];
this.runningScripts = []; //Names (and only names) of scripts being run
this.programs = [];
this.messages = [];
/* Hacking information (only valid for "foreign" aka non-purchased servers) */