Buffed crimes and hacking. Increased growth rate of servers. Added getHostanme command. Added preventDefault() for ctrl+b in script editor. Buffed Neuroflux Governor, which adds 1% to all multipliers, and made it more expensive. Nerfed Hacknet Node base production. Fixed nested for loop issue

This commit is contained in:
Daniel Xie 2017-05-29 17:37:38 -05:00
parent a453d96d50
commit af47baf4fa
14 changed files with 180 additions and 85 deletions

@ -3,7 +3,6 @@ function Augmentation(name) {
this.name = name; this.name = name;
this.info = ""; this.info = "";
this.owned = false; //Whether the player has it (you can only have each augmentation once) this.owned = false; //Whether the player has it (you can only have each augmentation once)
this.factionInstalledBy = ""; //Which faction the Player got this from
//Price and reputation base requirements (can change based on faction multipliers) //Price and reputation base requirements (can change based on faction multipliers)
this.baseRepRequirement = 0; this.baseRepRequirement = 0;
@ -818,7 +817,7 @@ initAugmentations = function() {
NeuroFluxGovernor.owned = oldAug.owned; NeuroFluxGovernor.owned = oldAug.owned;
NeuroFluxGovernor.level = oldAug.level; NeuroFluxGovernor.level = oldAug.level;
mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level); mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level);
NeuroFluxGovernor.setRequirements(250 * mult, 500000 * mult); NeuroFluxGovernor.setRequirements(300 * mult, 600000 * mult);
delete Augmentations[AugmentationNames.NeuroFluxGovernor]; delete Augmentations[AugmentationNames.NeuroFluxGovernor];
} else { } else {
NeuroFluxGovernor.setRequirements(250, 500000); NeuroFluxGovernor.setRequirements(250, 500000);
@ -827,10 +826,8 @@ initAugmentations = function() {
"monitors and regulates nervous impulses coming to and from the spinal column, " + "monitors and regulates nervous impulses coming to and from the spinal column, " +
"essentially 'governing' the body. By doing so, it improves the functionality of the " + "essentially 'governing' the body. By doing so, it improves the functionality of the " +
"body's nervous system. <br><br> " + "body's nervous system. <br><br> " +
"This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation: <br> " + "This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation " +
"Increases all of the player's stats by 1%<br>" + "increases ALL of the player's multipliers by 1%");
"Increases the player's experience gain rate for all stats by 1%<br>" +
"Increases the amount of reputation the player gains from companies and factions by 1%")
NeuroFluxGovernor.addToAllFactions(); NeuroFluxGovernor.addToAllFactions();
AddToAugmentations(NeuroFluxGovernor); AddToAugmentations(NeuroFluxGovernor);
@ -1331,8 +1328,8 @@ initAugmentations = function() {
AddToAugmentations(SNA); AddToAugmentations(SNA);
} }
applyAugmentation = function(aug, faction) { applyAugmentation = function(aug, reapply=false) {
if (aug.name != AugmentationNames.NeuroFluxGovernor && aug.owned) { if (reapply == false && aug.name != AugmentationNames.NeuroFluxGovernor && aug.owned) {
throw new Error("This Augmentation is already owned/applied...somethings wrong"); throw new Error("This Augmentation is already owned/applied...somethings wrong");
return; return;
} }
@ -1539,21 +1536,42 @@ applyAugmentation = function(aug, faction) {
//Misc augmentations //Misc augmentations
case AugmentationNames.NeuroFluxGovernor: case AugmentationNames.NeuroFluxGovernor:
Player.hacking_mult *= 1.01; Player.hacking_chance_mult *= 1.01;
Player.strength_mult *= 1.01; Player.hacking_speed_mult *= 0.99;
Player.defense_mult *= 1.01; Player.hacking_money_mult *= 1.01;
Player.dexterity_mult *= 1.01; //Player.hacking_grow_mult *= 1.01;
Player.agility_mult *= 1.01; Player.hacking_mult *= 1.01;
Player.charisma_mult *= 1.01;
Player.hacking_exp_mult *= 1.01; Player.strength_mult *= 1.01;
Player.strength_exp_mult *= 1.01; Player.defense_mult *= 1.01;
Player.defense_exp_mult *= 1.01; Player.dexterity_mult *= 1.01;
Player.dexterity_exp_mult *= 1.01; Player.agility_mult *= 1.01;
Player.agility_exp_mult *= 1.01; Player.charisma_mult *= 1.01;
Player.charisma_exp_mult *= 1.01;
Player.company_rep_mult *= 1.01; Player.hacking_exp_mult *= 1.01;
Player.faction_rep_mult *= 1.01; Player.strength_exp_mult *= 1.01;
++aug.level; Player.defense_exp_mult *= 1.01;
Player.dexterity_exp_mult *= 1.01;
Player.agility_exp_mult *= 1.01;
Player.charisma_exp_mult *= 1.01;
Player.company_rep_mult *= 1.01;
Player.faction_rep_mult *= 1.01;
Player.crime_money_mult *= 1.01;
Player.crime_success_mult *= 1.01;
Player.hacknet_node_money_mult *= 1.01;
Player.hacknet_node_purchase_cost_mult *= 1.01;
Player.hacknet_node_ram_cost_mult *= 1.01;
Player.hacknet_node_core_cost_mult *= 1.01;
Player.hacknet_node_level_cost_mult *= 1.01;
Player.work_money_mult *= 1.01;
if (!reapply) {
++aug.level;
}
break; break;
case AugmentationNames.Neurotrainer1: //Low Level case AugmentationNames.Neurotrainer1: //Low Level
Player.hacking_exp_mult *= 1.1; Player.hacking_exp_mult *= 1.1;
@ -1752,14 +1770,68 @@ applyAugmentation = function(aug, faction) {
} }
aug.owned = true; aug.owned = true;
aug.factionInstalledBy = faction.name;
if (aug.name == AugmentationNames.NeuroFluxGovernor && if (aug.name == AugmentationNames.NeuroFluxGovernor &&
Player.augmentations.indexOf(AugmentationNames.NeuroFluxGovernor) != -1) { Player.augmentations.indexOf(AugmentationNames.NeuroFluxGovernor) != -1) {
//Already have this aug, just upgrade the level //Already have this aug, just upgrade the level
return; return;
} }
Player.augmentations.push(aug.name);
++Player.numAugmentations; if (!reapply) {
Player.augmentations.push(aug.name);
++Player.numAugmentations;
}
}
PlayerObject.prototype.reapplyAllAugmentations = function() {
console.log("Re-applying augmentations");
//Reset multipliers
this.hacking_chance_mult = 1; //Increase through ascensions/augmentations
this.hacking_speed_mult = 1; //Decrease through ascensions/augmentations
this.hacking_money_mult = 1; //Increase through ascensions/augmentations. Can't go above 1
this.hacking_grow_mult = 1;
this.hacking_mult = 1;
this.strength_mult = 1;
this.defense_mult = 1;
this.dexterity_mult = 1;
this.agility_mult = 1;
this.charisma_mult = 1;
this.hacking_exp_mult = 1;
this.strength_exp_mult = 1;
this.defense_exp_mult = 1;
this.dexterity_exp_mult = 1;
this.agility_exp_mult = 1;
this.charisma_exp_mult = 1;
this.company_rep_mult = 1;
this.faction_rep_mult = 1;
this.crime_money_mult = 1;
this.crime_success_mult = 1;
this.hacknet_node_money_mult = 1;
this.hacknet_node_purchase_cost_mult = 1;
this.hacknet_node_ram_cost_mult = 1;
this.hacknet_node_core_cost_mult = 1;
this.hacknet_node_level_cost_mult = 1;
this.work_money_mult = 1;
for (i = 0; i < this.augmentations.length; ++i) {
var aug = Augmentations[this.augmentations[i]];
if (aug == null) {
console.log("WARNING: Invalid augmentation name");
continue;
}
if (aug.name == AugmentationNames.NeuroFluxGovernor) {
for (j = 0; j < aug.level; ++j) {
applyAugmentation(aug, true);
}
continue;
}
applyAugmentation(aug, true);
}
} }
function augmentationExists(name) { function augmentationExists(name) {

@ -18,7 +18,7 @@ CONSTANTS = {
BaseCostForHacknetNodeCore: 500000, BaseCostForHacknetNodeCore: 500000,
/* Hacknet Node constants */ /* Hacknet Node constants */
HacknetNodeMoneyGainPerLevel: 1.75, HacknetNodeMoneyGainPerLevel: 1.65,
HacknetNodePurchaseNextMult: 1.33, //Multiplier when purchasing an additional hacknet node HacknetNodePurchaseNextMult: 1.33, //Multiplier when purchasing an additional hacknet node
HacknetNodeUpgradeLevelMult: 1.04, //Multiplier for cost when upgrading level HacknetNodeUpgradeLevelMult: 1.04, //Multiplier for cost when upgrading level
HacknetNodeUpgradeRamMult: 1.22, //Multiplier for cost when upgrading RAM HacknetNodeUpgradeRamMult: 1.22, //Multiplier for cost when upgrading RAM
@ -30,7 +30,7 @@ CONSTANTS = {
/* Augmentation */ /* Augmentation */
//NeuroFlux Governor cost multiplier as you level up //NeuroFlux Governor cost multiplier as you level up
NeuroFluxGovernorLevelMult: 1.09, NeuroFluxGovernorLevelMult: 1.18,
/* Script related things */ /* Script related things */
//Time (ms) it takes to run one operation in Netscript. //Time (ms) it takes to run one operation in Netscript.
@ -59,7 +59,7 @@ CONSTANTS = {
ScriptHNUpgCoreRamCost: 0.8, ScriptHNUpgCoreRamCost: 0.8,
//Server growth rate //Server growth rate
ServerGrowthRate: 1.00075, ServerGrowthRate: 1.001,
//Maximum number of log entries for a script //Maximum number of log entries for a script
MaxLogCapacity: 40, MaxLogCapacity: 40,
@ -283,6 +283,7 @@ CONSTANTS = {
"<i>hasRootAccess(hostname/ip)</i><br> Returns a boolean (true or false) indicating whether or not the Player has root access to a server. " + "<i>hasRootAccess(hostname/ip)</i><br> Returns a boolean (true or false) indicating whether or not the Player has root access to a server. " +
"The argument passed in must be a string with either the hostname or IP of the target server. Does NOT work while offline.<br> " + "The argument passed in must be a string with either the hostname or IP of the target server. Does NOT work while offline.<br> " +
"Example:<br>if (hasRootAccess('foodnstuff') == false) {<br>&nbsp;&nbsp;&nbsp;&nbsp;nuke('foodnstuff');<br>}<br><br>" + "Example:<br>if (hasRootAccess('foodnstuff') == false) {<br>&nbsp;&nbsp;&nbsp;&nbsp;nuke('foodnstuff');<br>}<br><br>" +
"<i>getHostname()<i><br>Returns a string with the hostname of the server that the script is running on<br><br>" +
"<i>getHackingLevel() </i><br> Returns the Player's current hacking level. Does NOT work while offline <br><br> " + "<i>getHackingLevel() </i><br> Returns the Player's current hacking level. Does NOT work while offline <br><br> " +
"<i>getServerMoneyAvailable(hostname/ip)</i><br> Returns the amount of money available on a server. The argument passed in must be a string with either the " + "<i>getServerMoneyAvailable(hostname/ip)</i><br> Returns the amount of money available on a server. The argument passed in must be a string with either the " +
"hostname or IP of the target server. Does NOT work while offline <br> Example: getServerMoneyAvailable('foodnstuff');<br><br>" + "hostname or IP of the target server. Does NOT work while offline <br> Example: getServerMoneyAvailable('foodnstuff');<br><br>" +

@ -1,47 +1,47 @@
/* Crimes.js */ /* Crimes.js */
function commitShopliftCrime() { function commitShopliftCrime() {
Player.crimeType = CONSTANTS.CrimeShoplift; Player.crimeType = CONSTANTS.CrimeShoplift;
Player.startCrime(0, 0.75, 0.75, 0.75, 0.75, 0, 1000, 2000); //$500/s, .375 exp/s Player.startCrime(0, 0.75, 0.75, 0.75, 0.75, 0, 5000, 2000); //$2500/s, .375 exp/s
} }
function commitMugCrime() { function commitMugCrime() {
Player.crimeType = CONSTANTS.CrimeMug; Player.crimeType = CONSTANTS.CrimeMug;
Player.startCrime(0, 1.5, 1.5, 1.5, 1.5, 0, 3000, 4000); //$750/s, .375 exp/s Player.startCrime(0, 1.5, 1.5, 1.5, 1.5, 0, 15000, 4000); //$3750/s, .375 exp/s
} }
function commitDealDrugsCrime() { function commitDealDrugsCrime() {
Player.crimeType = CONSTANTS.CrimeDrugs; Player.crimeType = CONSTANTS.CrimeDrugs;
Player.startCrime(0, 4, 4, 4, 4, 4, 10000, 10000); //$1000/s, .4 exp/s Player.startCrime(0, 4, 4, 4, 4, 4, 50000, 10000); //$5000/s, .4 exp/s
} }
function commitTraffickArmsCrime() { function commitTraffickArmsCrime() {
Player.crimeType = CONSTANTS.CrimeTraffickArms; Player.crimeType = CONSTANTS.CrimeTraffickArms;
Player.startCrime(0, 10, 10, 10, 10, 15, 60000, 40000); //$1500/s, .25 combat exp/s, .375 cha exp/s Player.startCrime(0, 10, 10, 10, 10, 15, 300000, 40000); //$7500/s, .25 combat exp/s, .375 cha exp/s
} }
function commitHomicideCrime() { function commitHomicideCrime() {
Player.crimeType = CONSTANTS.CrimeHomicide; Player.crimeType = CONSTANTS.CrimeHomicide;
Player.startCrime(0, 2, 2, 2, 2, 0, 3000, 3000); //$1000/s, 0.66 combat exp/s Player.startCrime(0, 2, 2, 2, 2, 0, 15000, 3000); //$5000/s, 0.66 combat exp/s
} }
function commitGrandTheftAutoCrime() { function commitGrandTheftAutoCrime() {
Player.crimeType = CONSTANTS.CrimeGrandTheftAuto; Player.crimeType = CONSTANTS.CrimeGrandTheftAuto;
Player.startCrime(0, 10, 10, 10, 40, 20, 150000, 80000); //$1875/2, .125 exp/s, .5 exp/s, .25 exp/s Player.startCrime(0, 10, 10, 10, 40, 20, 750000, 80000); //$9375/s, .125 exp/s, .5 exp/s, .25 exp/s
} }
function commitKidnapCrime() { function commitKidnapCrime() {
Player.crimeType = CONSTANTS.CrimeKidnap; Player.crimeType = CONSTANTS.CrimeKidnap;
Player.startCrime(0, 30, 30, 30, 30, 30, 300000, 120000); //$2500/s. .25 exp/s Player.startCrime(0, 30, 30, 30, 30, 30, 1500000, 120000); //$12500/s. .25 exp/s
} }
function commitAssassinationCrime() { function commitAssassinationCrime() {
Player.crimeType = CONSTANTS.CrimeAssassination; Player.crimeType = CONSTANTS.CrimeAssassination;
Player.startCrime(0, 75, 75, 75, 75, 0, 1000000, 300000); //$3333.33/s, .25 exp/s Player.startCrime(0, 75, 75, 75, 75, 0, 5000000, 300000); //$16666.66/s, .25 exp/s
} }
function commitHeistCrime() { function commitHeistCrime() {
Player.crimeType = CONSTANTS.CrimeHeist; Player.crimeType = CONSTANTS.CrimeHeist;
Player.startCrime(120, 120, 120, 120, 120, 120, 25000000, 600000); //$41,666.67/s, .2exp/s Player.startCrime(120, 120, 120, 120, 120, 120, 75000000, 600000); //$125000/s, .2exp/s
} }
function determineCrimeSuccess(crime, moneyGained) { function determineCrimeSuccess(crime, moneyGained) {

@ -371,7 +371,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
if (speakersforthedeadFac.isBanned == false && speakersforthedeadFac.isMember == false && if (speakersforthedeadFac.isBanned == false && speakersforthedeadFac.isMember == false &&
this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 && this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 10 && this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 10 &&
this.numPeopleKilledTotal >= 100 && this.karma <= -50 && this.companyName != Locations.Sector12CIA && this.numPeopleKilledTotal >= 100 && this.karma <= -45 && this.companyName != Locations.Sector12CIA &&
this.companyName != Locations.Sector12NSA) { this.companyName != Locations.Sector12NSA) {
invitedFactions.push(speakersforthedeadFac); invitedFactions.push(speakersforthedeadFac);
} }
@ -381,7 +381,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
if (thedarkarmyFac.isBanned == false && thedarkarmyFac.isMember == false && if (thedarkarmyFac.isBanned == false && thedarkarmyFac.isMember == false &&
this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 && this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 &&
this.dexterity >= 300 && this.agility >= 300 && this.city == Locations.Chongqing && this.dexterity >= 300 && this.agility >= 300 && this.city == Locations.Chongqing &&
this.numPeopleKilled >= 5 && this.karma <= -50 && this.companyName != Locations.Sector12CIA && this.numPeopleKilled >= 5 && this.karma <= -45 && this.companyName != Locations.Sector12CIA &&
this.companyName != Locations.Sector12NSA) { this.companyName != Locations.Sector12NSA) {
invitedFactions.push(thedarkarmyFac); invitedFactions.push(thedarkarmyFac);
} }
@ -392,7 +392,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 && this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 &&
this.dexterity >= 200 && this.agility >= 200 && this.dexterity >= 200 && this.agility >= 200 &&
(this.city == Locations.Aevum || this.city == Locations.Sector12) && (this.city == Locations.Aevum || this.city == Locations.Sector12) &&
this.money >= 10000000 && this.karma <= -100 && this.money >= 10000000 && this.karma <= -90 &&
this.companyName != Locations.Sector12CIA && this.companyName != Locations.Sector12NSA) { this.companyName != Locations.Sector12CIA && this.companyName != Locations.Sector12NSA) {
invitedFactions.push(thesyndicateFac); invitedFactions.push(thesyndicateFac);
} }
@ -403,7 +403,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
(this.companyPosition.positionName == CompanyPositions.CTO.positionName || (this.companyPosition.positionName == CompanyPositions.CTO.positionName ||
this.companyPosition.positionName == CompanyPositions.CFO.positionName || this.companyPosition.positionName == CompanyPositions.CFO.positionName ||
this.companyPosition.positionName == CompanyPositions.CEO.positionName) && this.companyPosition.positionName == CompanyPositions.CEO.positionName) &&
this.money >= 15000000 && this.karma <= -25) { this.money >= 15000000 && this.karma <= -22) {
invitedFactions.push(silhouetteFac); invitedFactions.push(silhouetteFac);
} }
@ -412,7 +412,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
if (tetradsFac.isBanned == false && tetradsFac.isMember == false && if (tetradsFac.isBanned == false && tetradsFac.isMember == false &&
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo || (this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
this.city == Locations.Ishima) && this.strength >= 75 && this.defense >= 75 && this.city == Locations.Ishima) && this.strength >= 75 && this.defense >= 75 &&
this.dexterity >= 75 && this.agility >= 75 && this.karma <= -20) { this.dexterity >= 75 && this.agility >= 75 && this.karma <= -18) {
invitedFactions.push(tetradsFac); invitedFactions.push(tetradsFac);
} }
@ -420,7 +420,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
var slumsnakesFac = Factions["Slum Snakes"]; var slumsnakesFac = Factions["Slum Snakes"];
if (slumsnakesFac.isBanned == false && slumsnakesFac.isMember == false && if (slumsnakesFac.isBanned == false && slumsnakesFac.isMember == false &&
this.strength >= 30 && this.defense >= 30 && this.dexterity >= 30 && this.strength >= 30 && this.defense >= 30 && this.dexterity >= 30 &&
this.agility >= 30 && this.karma <= -10 && this.money >= 1000000) { this.agility >= 30 && this.karma <= -9 && this.money >= 1000000) {
invitedFactions.push(slumsnakesFac); invitedFactions.push(slumsnakesFac);
} }
@ -446,7 +446,6 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
this.money >= 1000000 && this.hacking_skill >= 50 && this.money >= 1000000 && this.hacking_skill >= 50 &&
(this.city == Locations.Chongqing || this.city == Locations.NewTokyo || (this.city == Locations.Chongqing || this.city == Locations.NewTokyo ||
this.city == Locations.Ishima)) { this.city == Locations.Ishima)) {
console.log("invited");
invitedFactions.push(tiandihuiFac); invitedFactions.push(tiandihuiFac);
} }
@ -457,6 +456,7 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
invitedFactions.push(cybersecFac); invitedFactions.push(cybersecFac);
} }
console.log("invited factions: " + invitedFactions);
return invitedFactions; return invitedFactions;
} }

@ -1394,7 +1394,7 @@ initLocationButtons = function() {
}); });
itJob.addEventListener("click", function() { itJob.addEventListener("click", function() {
Player.applyForSoftwareJob() Player.applyForItJob();
return false; return false;
}); });

@ -25,8 +25,10 @@ Environment.prototype = {
//Get the current value of a variable //Get the current value of a variable
get: function(name) { get: function(name) {
if (name in this.vars) if (name in this.vars) {
return this.vars[name]; return this.vars[name];
}
console.log("here");
throw new Error("Undefined variable " + name); throw new Error("Undefined variable " + name);
}, },
@ -37,8 +39,10 @@ Environment.prototype = {
// //
// If scope is null (aka existing variable with name could not be found) // If scope is null (aka existing variable with name could not be found)
// and this is NOT the global scope, throw error // and this is NOT the global scope, throw error
if (!scope && this.parent) if (!scope && this.parent) {
console.log("Here");
throw new Error("Undefined variable " + name); throw new Error("Undefined variable " + name);
}
return (scope || this).vars[name] = value; return (scope || this).vars[name] = value;
}, },

@ -44,7 +44,6 @@ function evaluate(exp, workerScript) {
//Can currently only assign to "var"s //Can currently only assign to "var"s
case "assign": case "assign":
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
console.log("Evaluating assign");
if (env.stopFlag) {reject(workerScript);} if (env.stopFlag) {reject(workerScript);}
if (exp.left.type != "var") if (exp.left.type != "var")
@ -64,9 +63,9 @@ function evaluate(exp, workerScript) {
p.then(function(expRight) { p.then(function(expRight) {
try { try {
env.set(exp.left.value, expRight); env.set(exp.left.value, expRight);
workerScript.scriptRef.log("Variable " + exp.left.value + " set to " + expRight);
} catch (e) { } catch (e) {
console.log("here"); reject("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString());
throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString());
} }
resolve(false); //Return false so this doesnt cause loops/ifs to evaluate resolve(false); //Return false so this doesnt cause loops/ifs to evaluate
}, function(e) { }, function(e) {
@ -119,7 +118,6 @@ function evaluate(exp, workerScript) {
//TODO //TODO
case "if": case "if":
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
console.log("Evaluating if");
var numConds = exp.cond.length; var numConds = exp.cond.length;
var numThens = exp.then.length; var numThens = exp.then.length;
if (numConds == 0 || numThens == 0 || numConds != numThens) { if (numConds == 0 || numThens == 0 || numConds != numThens) {
@ -157,13 +155,11 @@ function evaluate(exp, workerScript) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
if (env.stopFlag) {reject(workerScript);} if (env.stopFlag) {reject(workerScript);}
console.log("for loop encountered in evaluator");
workerScript.scriptRef.log("Entering for loop");
var pInit = new Promise(function(resolve, reject) { var pInit = new Promise(function(resolve, reject) {
setTimeout(function() { setTimeout(function() {
var resInit = evaluate(exp.init, workerScript); var resInit = evaluate(exp.init, workerScript);
resInit.then(function(foo) { resInit.then(function(foo) {
resolve(resInit); resolve(foo);
}, function(e) { }, function(e) {
reject(e); reject(e);
}); });
@ -670,7 +666,7 @@ function evaluate(exp, workerScript) {
}); });
} else if (exp.func.value == "hasRootAccess") { } else if (exp.func.value == "hasRootAccess") {
if (exp.args.length != 1) { if (exp.args.length != 1) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|hasRootAccess() call has incorrect number of arguments. Takes 1 argument"); reject(makeRuntimeRejectMsg(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument"));
return; return;
} }
var ipPromise = evaluate(exp.args[0], workerScript); var ipPromise = evaluate(exp.args[0], workerScript);
@ -691,14 +687,13 @@ function evaluate(exp, workerScript) {
}); });
} else if (exp.func.value == "run") { } else if (exp.func.value == "run") {
if (exp.args.length != 1) { if (exp.args.length != 1) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|run() call has incorrect number of arguments. Takes 1 argument"); reject(makeRuntimeRejectMsg(workerScript, "run() call has incorrect number of arguments. Takes 1 argument"));
return; return;
} }
var scriptNamePromise = evaluate(exp.args[0], workerScript); var scriptNamePromise = evaluate(exp.args[0], workerScript);
scriptNamePromise.then(function(scriptname) { scriptNamePromise.then(function(scriptname) {
if (env.stopFlag) {reject(workerScript);} if (env.stopFlag) {reject(workerScript);}
var serverIp = workerScript.serverIp; var scriptServer = getServer(workerScript.serverIp);
var scriptServer = AllServers[serverIp];
if (scriptServer == null) { if (scriptServer == null) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|Could not find server. This is a bug in the game. Report to game dev"); reject("|"+workerScript.serverIp+"|"+workerScript.name+"|Could not find server. This is a bug in the game. Report to game dev");
return; return;
@ -714,6 +709,19 @@ function evaluate(exp, workerScript) {
}, function(e) { }, function(e) {
reject(e); reject(e);
}); });
} else if (exp.func.value == "getHostname") {
if (exp.args.length != 0) {
reject(makeRuntimeRejectMsg(workerScript, "getHostname() call has incorrect number of arguments. Takes 0 arguments"));
return;
}
setTimeout(function() {
var scriptServer = getServer(workerScript.serverIp);
if (scriptServer == null) {
reject(makeRuntimeRejectMsg(workerScript, "Could not find server. This is a bug in the game. Report to game dev"));
return;
}
resolve(scriptServer.hostname);
}, CONSTANTS.CodeInstructionRunTime);
} else if (exp.func.value == "getHackingLevel") { } else if (exp.func.value == "getHackingLevel") {
if (exp.args.length != 0) { if (exp.args.length != 0) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|getHackingLevel() call has incorrect number of arguments. Takes 0 arguments"); reject("|"+workerScript.serverIp+"|"+workerScript.name+"|getHackingLevel() call has incorrect number of arguments. Takes 0 arguments");
@ -793,7 +801,6 @@ function evaluateIf(exp, workerScript, i) {
//Catch out of bounds errors //Catch out of bounds errors
resolve(false); resolve(false);
} else { } else {
console.log("Evaluating cond " + i + " in if");
var cond = evaluate(exp.cond[i], workerScript); var cond = evaluate(exp.cond[i], workerScript);
cond.then(function(condRes) { cond.then(function(condRes) {
console.log("cond evaluated to: " + condRes); console.log("cond evaluated to: " + condRes);
@ -1202,7 +1209,7 @@ function scriptCalculateExpGain(server) {
function scriptCalculatePercentMoneyHacked(server) { function scriptCalculatePercentMoneyHacked(server) {
var difficultyMult = (100 - server.hackDifficulty) / 100; var difficultyMult = (100 - server.hackDifficulty) / 100;
var skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill; var skillMult = (Player.hacking_skill - (server.requiredHackingSkill - 1)) / Player.hacking_skill;
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 875; var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 825;
if (percentMoneyHacked < 0) {return 0;} if (percentMoneyHacked < 0) {return 0;}
if (percentMoneyHacked > 1) {return 1;} if (percentMoneyHacked > 1) {return 1;}
return percentMoneyHacked; return percentMoneyHacked;

@ -151,14 +151,14 @@ function Parser(input) {
* code: prog node * code: prog node
*/ */
function parse_for() { function parse_for() {
console.log("Parsing for token");
checkKeywordAndSkip("for"); checkKeywordAndSkip("for");
splitExpressions = delimited("(", ")", ";", parse_expression); temp = delimited("(", ")", ";", parse_expression);
var splitExpressions = temp.slice();
code = parse_expression(); code = parse_expression();
if (splitExpressions.length != 3) { if (splitExpressions.length != 3) {
throw new Error("for statement has incorrect number of arugments"); throw new Error("for statement has incorrect number of arguments");
} }
//TODO Check type of the init, cond, and postloop nodes //TODO Check type of the init, cond, and postloop nodes
@ -196,7 +196,6 @@ function Parser(input) {
if (is_punc("[")) { if (is_punc("[")) {
index = parse_expression(); index = parse_expression();
if (index.type != "index") { if (index.type != "index") {
console.log("Failed here");
unexpected(); unexpected();
} }
} }
@ -214,7 +213,6 @@ function Parser(input) {
op: op, op: op,
} }
} }
console.log("Failed here");
unexpected(); unexpected();
} }

@ -243,7 +243,7 @@ PlayerObject.prototype.calculateHackingTime = function() {
PlayerObject.prototype.calculatePercentMoneyHacked = function() { PlayerObject.prototype.calculatePercentMoneyHacked = function() {
var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100; var difficultyMult = (100 - this.getCurrentServer().hackDifficulty) / 100;
var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill; var skillMult = (this.hacking_skill - (this.getCurrentServer().requiredHackingSkill - 1)) / this.hacking_skill;
var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult / 875; var percentMoneyHacked = difficultyMult * skillMult * this.hacking_money_mult / 825;
console.log("Percent money hacked calculated to be: " + percentMoneyHacked); console.log("Percent money hacked calculated to be: " + percentMoneyHacked);
if (percentMoneyHacked < 0) {return 0;} if (percentMoneyHacked < 0) {return 0;}
if (percentMoneyHacked > 1) {return 1;} if (percentMoneyHacked > 1) {return 1;}

@ -37,7 +37,8 @@ document.addEventListener("DOMContentLoaded", scriptEditorInit, false);
$(document).keydown(function(e) { $(document).keydown(function(e) {
if (Engine.currentPage == Engine.Page.ScriptEditor) { if (Engine.currentPage == Engine.Page.ScriptEditor) {
//Ctrl + b //Ctrl + b
if (e.keyCode == 66 && e.ctrlKey) { if (e.keyCode == 66 && e.ctrlKey) {
e.preventDefault();
saveAndCloseScriptEditor(); saveAndCloseScriptEditor();
} }
} }

@ -403,19 +403,19 @@ initForeignServers = function() {
//"Low level" targets //"Low level" targets
var FoodNStuffServer = new Server(); var FoodNStuffServer = new Server();
FoodNStuffServer.init(createRandomIp(), "foodnstuff", "Food N Stuff Supermarket", true, false, false, false, 4); FoodNStuffServer.init(createRandomIp(), "foodnstuff", "Food N Stuff Supermarket", true, false, false, false, 4);
FoodNStuffServer.setHackingParameters(1, 750000, 10, 5); FoodNStuffServer.setHackingParameters(1, 1000000, 10, 5);
FoodNStuffServer.setPortProperties(0); FoodNStuffServer.setPortProperties(0);
AddToAllServers(FoodNStuffServer); AddToAllServers(FoodNStuffServer);
var SigmaCosmeticsServer = new Server(); var SigmaCosmeticsServer = new Server();
SigmaCosmeticsServer.init(createRandomIp(), "sigma-cosmetics", "Sigma Cosmetics", true, false, false, false, 4); SigmaCosmeticsServer.init(createRandomIp(), "sigma-cosmetics", "Sigma Cosmetics", true, false, false, false, 4);
SigmaCosmeticsServer.setHackingParameters(5, 1000000, 10, 10); SigmaCosmeticsServer.setHackingParameters(5, 1300000, 10, 10);
SigmaCosmeticsServer.setPortProperties(0); SigmaCosmeticsServer.setPortProperties(0);
AddToAllServers(SigmaCosmeticsServer); AddToAllServers(SigmaCosmeticsServer);
var JoesGunsServer = new Server(); var JoesGunsServer = new Server();
JoesGunsServer.init(createRandomIp(), "joesguns", "Joe's Guns", true, false, false, false, 4); JoesGunsServer.init(createRandomIp(), "joesguns", "Joe's Guns", true, false, false, false, 4);
JoesGunsServer.setHackingParameters(10, 1500000, 20, 20); JoesGunsServer.setHackingParameters(10, 1750000, 20, 20);
JoesGunsServer.setPortProperties(0); JoesGunsServer.setPortProperties(0);
AddToAllServers(JoesGunsServer); AddToAllServers(JoesGunsServer);
@ -427,13 +427,13 @@ initForeignServers = function() {
var NectarNightclubServer = new Server(); var NectarNightclubServer = new Server();
NectarNightclubServer.init(createRandomIp(), "nectar-net", "Nectar Nightclub Network", true, false, false, false, 4); NectarNightclubServer.init(createRandomIp(), "nectar-net", "Nectar Nightclub Network", true, false, false, false, 4);
NectarNightclubServer.setHackingParameters(20, 1750000, 20, 25); NectarNightclubServer.setHackingParameters(20, 2000000, 20, 25);
NectarNightclubServer.setPortProperties(0); NectarNightclubServer.setPortProperties(0);
AddToAllServers(NectarNightclubServer); AddToAllServers(NectarNightclubServer);
var NeoNightclubServer = new Server(); var NeoNightclubServer = new Server();
NeoNightclubServer.init(createRandomIp(), "neo-net", "Neo Nightclub Network", true, false, false, false, 2); NeoNightclubServer.init(createRandomIp(), "neo-net", "Neo Nightclub Network", true, false, false, false, 2);
NeoNightclubServer.setHackingParameters(50, 3500000, 25, 25); NeoNightclubServer.setHackingParameters(50, 4500000, 25, 25);
NeoNightclubServer.setPortProperties(1); NeoNightclubServer.setPortProperties(1);
AddToAllServers(NeoNightclubServer); AddToAllServers(NeoNightclubServer);
@ -445,12 +445,12 @@ initForeignServers = function() {
var HongFangTeaHouseServer = new Server(); var HongFangTeaHouseServer = new Server();
HongFangTeaHouseServer.init(createRandomIp(), "hong-fang-tea", "HongFang Teahouse", true, false, false, false, 4); HongFangTeaHouseServer.init(createRandomIp(), "hong-fang-tea", "HongFang Teahouse", true, false, false, false, 4);
HongFangTeaHouseServer.setHackingParameters(30, 2000000, 15, 15); HongFangTeaHouseServer.setHackingParameters(30, 2500000, 15, 15);
HongFangTeaHouseServer.setPortProperties(0); HongFangTeaHouseServer.setPortProperties(0);
AddToAllServers(HongFangTeaHouseServer); AddToAllServers(HongFangTeaHouseServer);
var HaraKiriSushiBarServer = new Server(); var HaraKiriSushiBarServer = new Server();
HaraKiriSushiBarServer.setHackingParameters(40, 3000000, 15, 40); HaraKiriSushiBarServer.setHackingParameters(40, 3500000, 15, 40);
HaraKiriSushiBarServer.init(createRandomIp(), "harakiri-sushi", "HaraKiri Sushi Bar Network", true, false, false, false, 4); HaraKiriSushiBarServer.init(createRandomIp(), "harakiri-sushi", "HaraKiri Sushi Bar Network", true, false, false, false, 4);
HaraKiriSushiBarServer.setPortProperties(0); HaraKiriSushiBarServer.setPortProperties(0);
AddToAllServers(HaraKiriSushiBarServer); AddToAllServers(HaraKiriSushiBarServer);
@ -652,6 +652,10 @@ processServerGrowth = function(numCycles) {
//Apply serverGrowth for the calculated number of growth cycles //Apply serverGrowth for the calculated number of growth cycles
var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted); var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted);
if (serverGrowth < 1) {
console.log("WARN: serverGrowth calculated to be less than 1");
serverGrowth = 1;
}
//console.log("serverGrowth ratio: " + serverGrowth); //console.log("serverGrowth ratio: " + serverGrowth);
server.moneyAvailable *= serverGrowth; server.moneyAvailable *= serverGrowth;
} }
@ -671,6 +675,10 @@ processSingleServerGrowth = function(server, numCycles) {
//Apply serverGrowth for the calculated number of growth cycles //Apply serverGrowth for the calculated number of growth cycles
var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted); var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted);
if (serverGrowth < 1) {
console.log("WARN: serverGrowth calculated to be less than 1");
serverGrowth = 1;
}
server.moneyAvailable *= serverGrowth; server.moneyAvailable *= serverGrowth;
return serverGrowth; return serverGrowth;

@ -539,7 +539,7 @@ var Terminal = {
case "connect": case "connect":
//Disconnect from current server in terminal and connect to new one //Disconnect from current server in terminal and connect to new one
if (commandArray.length != 2) { if (commandArray.length != 2) {
post("Incorrect usage of connect/telnet command. Usage: connect/telnet [ip/hostname]"); post("Incorrect usage of connect command. Usage: connect [ip/hostname]");
return; return;
} }

@ -277,12 +277,13 @@ var Engine = {
'Charisma Experience multiplier: ' + formatNumber(Player.charisma_exp_mult * 100, 2) + '%<br><br>' + 'Charisma Experience multiplier: ' + formatNumber(Player.charisma_exp_mult * 100, 2) + '%<br><br>' +
'Hacknet Node production multiplier: ' + formatNumber(Player.hacknet_node_money_mult * 100, 2) + '%<br>' + 'Hacknet Node production multiplier: ' + formatNumber(Player.hacknet_node_money_mult * 100, 2) + '%<br>' +
'Hacknet Node purchase cost multiplier: ' + formatNumber(Player.hacknet_node_purchase_cost_mult * 100, 2) + '%<br>' + 'Hacknet Node purchase cost multiplier: ' + formatNumber(Player.hacknet_node_purchase_cost_mult * 100, 2) + '%<br>' +
'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%<br>' + 'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%<br>' +
'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%<br>' + 'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%<br>' +
'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%<br><br>' + 'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%<br><br>' +
'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%<br>' + 'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%<br>' +
'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%<br>' + 'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%<br>' +
'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%<br>' + 'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%<br>' +
'Crime success multiplier: ' + formatNumber(Player.crime_success_mult * 100, 2) + '%<br>' +
'Crime money multiplier: ' + formatNumber(Player.crime_money_mult * 100, 2) + '%<br><br><br>' + 'Crime money multiplier: ' + formatNumber(Player.crime_money_mult * 100, 2) + '%<br><br><br>' +
'<b>Misc</b><br><br>' + '<b>Misc</b><br><br>' +
'Servers owned: ' + Player.purchasedServers.length + '<br>' + 'Servers owned: ' + Player.purchasedServers.length + '<br>' +
@ -594,7 +595,7 @@ var Engine = {
updateDisplays: 3, //Update displays such as Active Scripts display and character display updateDisplays: 3, //Update displays such as Active Scripts display and character display
createProgramNotifications: 10, //Checks whether any programs can be created and notifies createProgramNotifications: 10, //Checks whether any programs can be created and notifies
serverGrowth: 450, //Process server growth every minute and a half serverGrowth: 450, //Process server growth every minute and a half
checkFactionInvitations: 1500, //Check whether you qualify for any faction invitations every 5 minutes checkFactionInvitations: 1000, //Check whether you qualify for any faction invitations every 5 minutes
passiveFactionGrowth: 600, passiveFactionGrowth: 600,
}, },
@ -659,7 +660,7 @@ var Engine = {
var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)]; var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)];
inviteToFaction(randFaction); inviteToFaction(randFaction);
} }
Engine.Counters.checkFactionInvitations = 1500; Engine.Counters.checkFactionInvitations = 1000;
} }
if (Engine.Counters.passiveFactionGrowth <= 0) { if (Engine.Counters.passiveFactionGrowth <= 0) {
@ -765,6 +766,9 @@ var Engine = {
if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;} if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;}
Player.totalPlaytime += time; Player.totalPlaytime += time;
//Re-apply augmentations
Player.reapplyAllAugmentations();
Player.lastUpdate = Engine._lastUpdate; Player.lastUpdate = Engine._lastUpdate;
Engine.start(); //Run main game loop and Scripts loop Engine.start(); //Run main game loop and Scripts loop
dialogBoxCreate("While you were offline, your scripts generated $" + dialogBoxCreate("While you were offline, your scripts generated $" +

@ -153,7 +153,7 @@ purchaseAugmentationBoxCreate = function(aug, fac) {
dialogBoxCreate("You must first install the Bionic Arms augmentation before installing this upgrade"); dialogBoxCreate("You must first install the Bionic Arms augmentation before installing this upgrade");
} }
} else if (Player.money >= (aug.baseCost * fac.augmentationPriceMult)) { } else if (Player.money >= (aug.baseCost * fac.augmentationPriceMult)) {
applyAugmentation(aug, fac); applyAugmentation(aug);
dialogBoxCreate("You slowly drift to sleep as " + fac.name + "'s scientists put you under " + dialogBoxCreate("You slowly drift to sleep as " + fac.name + "'s scientists put you under " +
" in order to install the " + aug.name + " Augmentation. <br><br>" + " in order to install the " + aug.name + " Augmentation. <br><br>" +
"You wake up in your home...you feel different..."); "You wake up in your home...you feel different...");