Added EXP gains to weaken() and grow() after refactoring, and rebalanced hacking mechanics:

This commit is contained in:
Daniel Xie 2017-06-05 03:08:04 -05:00
parent 71999ea2eb
commit 9adce1dd2f
4 changed files with 20 additions and 7 deletions

@ -65,7 +65,7 @@ CONSTANTS = {
ScriptHNUpgCoreRamCost: 0.8,
//Server constants
ServerGrowthRate: 1.002, //Growth rate
ServerGrowthRate: 1.0015, //Growth rate
ServerFortifyAmount: 0.002, //Amount by which server's security increases when its hacked
ServerWeakenAmount: 0.1, //Amount by which server's security decreases when weakened
@ -489,10 +489,13 @@ CONSTANTS = {
Changelog:
"v0.20.0<br>" +
"Refactor Netscript Interpreter code. Operations in Netscript should now run significantly faster (Every operation " +
"-Refactored Netscript Interpreter code. Operations in Netscript should now run significantly faster (Every operation " +
"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> " +
""
"-Percentage money stolen when hacking lowered to compensate for faster script speeds<br>" +
"-Lowered base growth rate by 25%(which affects amount of money gained from grow())<br>" +
"-Hacking experience granted by grow() halved<b>" +
"-Weaken() is now 10% faster, but only grants 3 hacking exp upon completion instead of 5 <br>"
"v0.19.7<br>" +
"-Added changelog to Options menu<br>" +
"-Bug fix with autocompletion (wasn't working properly for capitalized filenames/programs<br><br>" +

@ -838,7 +838,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 / 150;
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 200;
if (percentMoneyHacked < 0) {return 0;}
if (percentMoneyHacked > 1) {return 1;}
return percentMoneyHacked;
@ -848,7 +848,7 @@ function scriptCalculatePercentMoneyHacked(server) {
function scriptCalculateGrowTime(server) {
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50);
var growTime = skillFactor * Player.hacking_speed_mult * 16; //This is in seconds
var growTime = skillFactor * Player.hacking_speed_mult * 17; //This is in seconds
return growTime * 1000;
}
@ -856,6 +856,6 @@ function scriptCalculateGrowTime(server) {
function scriptCalculateWeakenTime(server) {
var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
var skillFactor = (2.5 * difficultyMult + 500) / (Player.hacking_skill + 50);
var weakenTime = skillFactor * Player.hacking_speed_mult * 50; //This is in seconds
var weakenTime = skillFactor * Player.hacking_speed_mult * 45; //This is in seconds
return weakenTime * 1000;
}

@ -147,6 +147,11 @@ function netscriptGrow(exp, workerScript) {
server.moneyAvailable += 1; //It can be grown even if it has no money
var growthPercentage = processSingleServerGrowth(server, 450);
workerScript.scriptRef.recordGrow(server.ip);
workerScript.scriptRef.log("Available money on " + server.hostname + " grown by "
+ formatNumber(growthPercentage*100 - 100, 6) + "%");
var expGain = 0.5 * Player.hacking_exp_mult;
workerScript.scriptRef.log("Gained " + expGain + " hacking experience");
Player.gainHackingExp(expGain);
return Promise.resolve(growthPercentage);
});
}).then(function(res) {
@ -188,6 +193,11 @@ function netscriptWeaken(exp, workerScript) {
if (env.stopFlag) {return Promise.reject(workerScript);}
server.weaken(CONSTANTS.ServerWeakenAmount);
workerScript.scriptRef.recordWeaken(server.ip);
workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty);
workerScript.scriptRef.log("Gained 3 hacking experience");
var expGain = 3 * Player.hacking_exp_mult;
workerScript.scriptRef.log("Gained " + expGain + " hacking experience");
Player.gainHackingExp(expGain);
return Promise.resolve(CONSTANTS.ServerWeakenAmount);
});
}).then(function(res) {

@ -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 / 150;
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult / 200;
console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
if (percentMoneyHacked < 0) {return 0;}
if (percentMoneyHacked > 1) {return 1;}