Merge pull request #25 from danielyxie/dev

Dev v0.17
This commit is contained in:
danielyxie 2017-05-29 21:07:32 -05:00 committed by GitHub
commit d5e5c105e9
15 changed files with 321 additions and 106 deletions

@ -3,7 +3,6 @@ function Augmentation(name) {
this.name = name;
this.info = "";
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)
this.baseRepRequirement = 0;
@ -790,7 +789,7 @@ initAugmentations = function() {
HacknetNodeKernelDNI.setInfo("Installs a Direct-Neural Interface jack into the arm that is capable of connecting to a " +
"Hacknet Node. This lets the user access and manipulate the Node's kernel using the mind's " +
"electrochemical signals.<br><br>" +
"This augmentation increases the amount of money produced by Hacknet Nodes by 30%.");
"This augmentation increases the amount of money produced by Hacknet Nodes by 25%.");
HacknetNodeKernelDNI.addToFactions(["Netburners"]);
if (augmentationExists(AugmentationNames.HacknetNodeKernelDNI)) {
HacknetNodeKernelDNI.owned = Augmentations[AugmentationNames.HacknetNodeKernelDNI].owned;
@ -803,7 +802,7 @@ initAugmentations = function() {
HacknetNodeCoreDNI.setInfo("Installs a Direct-Neural Interface jack into the arm that is capable of connecting " +
"to a Hacknet Node. This lets the user access and manipulate the Node's processing logic using " +
"the mind's electrochemical signals.<br><br>" +
"This augmentation increases the amount of money produced by Hacknet Nodes by 50%.");
"This augmentation increases the amount of money produced by Hacknet Nodes by 45%.");
HacknetNodeCoreDNI.addToFactions(["Netburners"]);
if (augmentationExists(AugmentationNames.HacknetNodeCoreDNI)) {
HacknetNodeCoreDNI.owned = Augmentations[AugmentationNames.HacknetNodeCoreDNI].owned;
@ -818,7 +817,7 @@ initAugmentations = function() {
NeuroFluxGovernor.owned = oldAug.owned;
NeuroFluxGovernor.level = oldAug.level;
mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level);
NeuroFluxGovernor.setRequirements(250 * mult, 500000 * mult);
NeuroFluxGovernor.setRequirements(300 * mult, 600000 * mult);
delete Augmentations[AugmentationNames.NeuroFluxGovernor];
} else {
NeuroFluxGovernor.setRequirements(250, 500000);
@ -827,10 +826,8 @@ initAugmentations = function() {
"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 " +
"body's nervous system. <br><br> " +
"This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation: <br> " +
"Increases all of the player's stats by 1%<br>" +
"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%")
"This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation " +
"increases ALL of the player's multipliers by 1%");
NeuroFluxGovernor.addToAllFactions();
AddToAugmentations(NeuroFluxGovernor);
@ -1331,8 +1328,8 @@ initAugmentations = function() {
AddToAugmentations(SNA);
}
applyAugmentation = function(aug, faction) {
if (aug.name != AugmentationNames.NeuroFluxGovernor && aug.owned) {
applyAugmentation = function(aug, reapply=false) {
if (reapply == false && aug.name != AugmentationNames.NeuroFluxGovernor && aug.owned) {
throw new Error("This Augmentation is already owned/applied...somethings wrong");
return;
}
@ -1531,29 +1528,50 @@ applyAugmentation = function(aug, faction) {
Player.hacknet_node_purchase_cost_mult *= 0.9;
break;
case AugmentationNames.HacknetNodeKernelDNI:
Player.hacknet_node_money_mult *= 1.30;
Player.hacknet_node_money_mult *= 1.25;
break;
case AugmentationNames.HacknetNodeCoreDNI:
Player.hacknet_node_money_mult *= 1.50;
Player.hacknet_node_money_mult *= 1.45;
break;
//Misc augmentations
case AugmentationNames.NeuroFluxGovernor:
Player.hacking_mult *= 1.01;
Player.strength_mult *= 1.01;
Player.defense_mult *= 1.01;
Player.dexterity_mult *= 1.01;
Player.agility_mult *= 1.01;
Player.charisma_mult *= 1.01;
Player.hacking_exp_mult *= 1.01;
Player.strength_exp_mult *= 1.01;
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;
++aug.level;
Player.hacking_chance_mult *= 1.01;
Player.hacking_speed_mult *= 0.99;
Player.hacking_money_mult *= 1.01;
//Player.hacking_grow_mult *= 1.01;
Player.hacking_mult *= 1.01;
Player.strength_mult *= 1.01;
Player.defense_mult *= 1.01;
Player.dexterity_mult *= 1.01;
Player.agility_mult *= 1.01;
Player.charisma_mult *= 1.01;
Player.hacking_exp_mult *= 1.01;
Player.strength_exp_mult *= 1.01;
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;
case AugmentationNames.Neurotrainer1: //Low Level
Player.hacking_exp_mult *= 1.1;
@ -1752,14 +1770,68 @@ applyAugmentation = function(aug, faction) {
}
aug.owned = true;
aug.factionInstalledBy = faction.name;
if (aug.name == AugmentationNames.NeuroFluxGovernor &&
Player.augmentations.indexOf(AugmentationNames.NeuroFluxGovernor) != -1) {
//Already have this aug, just upgrade the level
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) {

@ -107,7 +107,6 @@ PlayerObject.prototype.applyForJob = function(entryPosType) {
}
}
this.companyName = company.companyName;
this.companyPosition = pos;

@ -1,5 +1,5 @@
CONSTANTS = {
Version: "0.16",
Version: "0.17",
//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.75,
HacknetNodeMoneyGainPerLevel: 1.65,
HacknetNodePurchaseNextMult: 1.33, //Multiplier when purchasing an additional hacknet node
HacknetNodeUpgradeLevelMult: 1.04, //Multiplier for cost when upgrading level
HacknetNodeUpgradeRamMult: 1.22, //Multiplier for cost when upgrading RAM
@ -30,7 +30,7 @@ CONSTANTS = {
/* Augmentation */
//NeuroFlux Governor cost multiplier as you level up
NeuroFluxGovernorLevelMult: 1.09,
NeuroFluxGovernorLevelMult: 1.14,
/* Script related things */
//Time (ms) it takes to run one operation in Netscript.
@ -49,6 +49,9 @@ CONSTANTS = {
ScriptHttpwormRamCost: 0.05,
ScriptSqlinjectRamCost: 0.05,
ScriptRunRamCost: 0.8,
ScriptScpRamCost: 0.5,
ScriptHasRootAccessRamCost: 0.05,
ScriptGetHostnameRamCost: 0.1,
ScriptGetHackingLevelRamCost: 0.1,
ScriptGetServerMoneyRamCost: 0.1,
ScriptOperatorRamCost: 0.01,
@ -59,7 +62,7 @@ CONSTANTS = {
ScriptHNUpgCoreRamCost: 0.8,
//Server growth rate
ServerGrowthRate: 1.00075,
ServerGrowthRate: 1.001,
//Maximum number of log entries for a script
MaxLogCapacity: 40,
@ -145,15 +148,16 @@ CONSTANTS = {
"home Connect to home computer<br>" +
"hostname Displays the hostname of the machine<br>" +
"ifconfig Displays the IP address of the machine<br>" +
"kill [script name] Stops a script that is running on the current machine<br>" +
"kill [script] Stops a script that is running on the current machine<br>" +
"ls Displays all programs and scripts on the machine<br>" +
"mem [script name] Displays the amount of RAM the script requires to run<br>" +
"nano [script name] Text editor - Open up and edit a script<br>" +
"mem [script] Displays the amount of RAM the script requires to run<br>" +
"nano [script] Text editor - Open up and edit a script<br>" +
"ps Display all scripts that are currently running<br>" +
"rm Delete a script/program from the machine. (WARNING: Permanent)<br>" +
"run [script/program] Execute a program or a script<br>" +
"scan Displays all available network connections<br>" +
"scan-analyze [depth] Displays hacking-related information for all servers up to <i>depth</i> nodes away<br>" +
"scp [script] [server] Copies a script to a destination server (specified by ip or hostname)<br>" +
"sudov Shows whether or not you have root access on this computer<br>" +
"tail [script] Display script logs (logs contain details about active scripts)<br>" +
"top Display all running scripts and their RAM usage<br>",
@ -283,6 +287,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. " +
"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>" +
"<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>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>" +

@ -1,47 +1,47 @@
/* Crimes.js */
function commitShopliftCrime() {
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() {
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() {
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() {
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() {
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() {
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() {
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() {
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() {
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) {

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

@ -861,7 +861,7 @@ displayLocationContent = function() {
case Locations.AevumSlums:
case Locations.ChongqingSlums:
case Locations.Sector12Slums:
case Locations.NewTokyokSlums:
case Locations.NewTokyoSlums:
case Locations.IshimaSlums:
case Locations.VolhavenSlums:
var shopliftChance = determineCrimeChanceShoplift();
@ -1394,7 +1394,7 @@ initLocationButtons = function() {
});
itJob.addEventListener("click", function() {
Player.applyForSoftwareJob()
Player.applyForItJob();
return false;
});

@ -25,8 +25,10 @@ Environment.prototype = {
//Get the current value of a variable
get: function(name) {
if (name in this.vars)
if (name in this.vars) {
return this.vars[name];
}
console.log("here");
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)
// 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);
}
return (scope || this).vars[name] = value;
},

@ -44,7 +44,6 @@ function evaluate(exp, workerScript) {
//Can currently only assign to "var"s
case "assign":
return new Promise(function(resolve, reject) {
console.log("Evaluating assign");
if (env.stopFlag) {reject(workerScript);}
if (exp.left.type != "var")
@ -65,8 +64,7 @@ function evaluate(exp, workerScript) {
try {
env.set(exp.left.value, expRight);
} catch (e) {
console.log("here");
throw new Error("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString());
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString());
}
resolve(false); //Return false so this doesnt cause loops/ifs to evaluate
}, function(e) {
@ -119,7 +117,6 @@ function evaluate(exp, workerScript) {
//TODO
case "if":
return new Promise(function(resolve, reject) {
console.log("Evaluating if");
var numConds = exp.cond.length;
var numThens = exp.then.length;
if (numConds == 0 || numThens == 0 || numConds != numThens) {
@ -157,13 +154,11 @@ function evaluate(exp, workerScript) {
return new Promise(function(resolve, reject) {
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) {
setTimeout(function() {
var resInit = evaluate(exp.init, workerScript);
resInit.then(function(foo) {
resolve(resInit);
resolve(foo);
}, function(e) {
reject(e);
});
@ -174,7 +169,6 @@ function evaluate(exp, workerScript) {
var pForLoop = evaluateFor(exp, workerScript);
pForLoop.then(function(forLoopRes) {
resolve("forLoopDone");
workerScript.scriptRef.log("Exiting for loop");
}, function(e) {
reject(e);
});
@ -670,7 +664,7 @@ function evaluate(exp, workerScript) {
});
} else if (exp.func.value == "hasRootAccess") {
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;
}
var ipPromise = evaluate(exp.args[0], workerScript);
@ -691,14 +685,13 @@ function evaluate(exp, workerScript) {
});
} else if (exp.func.value == "run") {
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;
}
var scriptNamePromise = evaluate(exp.args[0], workerScript);
scriptNamePromise.then(function(scriptname) {
if (env.stopFlag) {reject(workerScript);}
var serverIp = workerScript.serverIp;
var scriptServer = AllServers[serverIp];
var scriptServer = getServer(workerScript.serverIp);
if (scriptServer == null) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|Could not find server. This is a bug in the game. Report to game dev");
return;
@ -714,6 +707,71 @@ function evaluate(exp, workerScript) {
}, function(e) {
reject(e);
});
} else if (exp.func.value == "scp") {
if (exp.args.length != 2) {
reject(makeRuntimeRejectMsg(workerScript, "scp() call has incorrect number of arguments. Takes 2 arguments"));
return;
}
var scriptNamePromise = evaluate(exp.args[0], workerScript);
scriptNamePromise.then(function(scriptname) {
var ipPromise = evaluate(exp.args[1], workerScript);
ipPromise.then(function(ip) {
var destServer = getServer(ip);
if (destServer == null) {
reject(makeRuntimeRejectMsg(workerScript, "Invalid hostname/ip passed into scp() command: " + ip));
return;
}
//Check that a script with this filename does not already exist
for (var i = 0; i < destServer.scripts.length; ++i) {
if (scriptname == destServer.scripts[i].filename) {
workerScript.scriptRef.log(destServer.hostname + " already contains a script named " + scriptname);
resolve(false);
return;
}
}
var currServ = getServer(workerScript.serverIp);
if (currServ == null) {
reject(makeRuntimeRejectMsg(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"));
return;
}
for (var i = 0; i < currServ.scripts.length; ++i) {
if (scriptname == currServ.scripts[i].filename) {
var newScript = new Script();
newScript.filename = scriptname;
newScript.code = currServ.scripts[i].code;
newScript.ramUsage = currServ.scripts[i].ramUsage;
newScript.server = destServer.ip;
destServer.scripts.push(newScript);
workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
resolve(true);
return;
}
}
workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
resolve(false);
}, function(e) {
reject(e);
});
}, function(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") {
if (exp.args.length != 0) {
reject("|"+workerScript.serverIp+"|"+workerScript.name+"|getHackingLevel() call has incorrect number of arguments. Takes 0 arguments");
@ -793,7 +851,6 @@ function evaluateIf(exp, workerScript, i) {
//Catch out of bounds errors
resolve(false);
} else {
console.log("Evaluating cond " + i + " in if");
var cond = evaluate(exp.cond[i], workerScript);
cond.then(function(condRes) {
console.log("cond evaluated to: " + condRes);
@ -1202,7 +1259,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 / 875;
var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 725;
if (percentMoneyHacked < 0) {return 0;}
if (percentMoneyHacked > 1) {return 1;}
return percentMoneyHacked;

@ -151,14 +151,14 @@ function Parser(input) {
* code: prog node
*/
function parse_for() {
console.log("Parsing for token");
checkKeywordAndSkip("for");
splitExpressions = delimited("(", ")", ";", parse_expression);
temp = delimited("(", ")", ";", parse_expression);
var splitExpressions = temp.slice();
code = parse_expression();
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
@ -196,7 +196,6 @@ function Parser(input) {
if (is_punc("[")) {
index = parse_expression();
if (index.type != "index") {
console.log("Failed here");
unexpected();
}
}
@ -214,7 +213,6 @@ function Parser(input) {
op: op,
}
}
console.log("Failed here");
unexpected();
}

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

@ -37,7 +37,8 @@ document.addEventListener("DOMContentLoaded", scriptEditorInit, false);
$(document).keydown(function(e) {
if (Engine.currentPage == Engine.Page.ScriptEditor) {
//Ctrl + b
if (e.keyCode == 66 && e.ctrlKey) {
if (e.keyCode == 66 && e.ctrlKey) {
e.preventDefault();
saveAndCloseScriptEditor();
}
}
@ -181,6 +182,9 @@ Script.prototype.updateRamUsage = function() {
var httpwormCount = numOccurrences(codeCopy, "httpworm(");
var sqlinjectCount = numOccurrences(codeCopy, "sqlinject(");
var runCount = numOccurrences(codeCopy, "run(");
var scpCount = numOccurrences(codeCopy, "scp(");
var hasRootAccessCount = numOccurrences(codeCopy, "hasRootAccess(");
var getHostnameCount = numOccurrences(codeCopy, "getHostname(");
var getHackingLevelCount = numOccurrences(codeCopy, "getHackingLevel(");
var getServerMoneyAvailableCount = numOccurrences(codeCopy, "getServerMoneyAvailable(");
var numOperators = numNetscriptOperators(codeCopy);
@ -203,6 +207,9 @@ Script.prototype.updateRamUsage = function() {
(httpwormCount * CONSTANTS.ScriptHttpwormRamCost) +
(sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) +
(runCount * CONSTANTS.ScriptRunRamCost) +
(scpCount * CONSTANTS.ScriptScpRamCost) +
(hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) +
(getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) +
(getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) +
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
(numOperators * CONSTANTS.ScriptOperatorRamCost) +

@ -403,19 +403,19 @@ initForeignServers = function() {
//"Low level" targets
var FoodNStuffServer = new Server();
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);
AddToAllServers(FoodNStuffServer);
var SigmaCosmeticsServer = new Server();
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);
AddToAllServers(SigmaCosmeticsServer);
var JoesGunsServer = new Server();
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);
AddToAllServers(JoesGunsServer);
@ -427,13 +427,13 @@ initForeignServers = function() {
var NectarNightclubServer = new Server();
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);
AddToAllServers(NectarNightclubServer);
var NeoNightclubServer = new Server();
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);
AddToAllServers(NeoNightclubServer);
@ -445,12 +445,12 @@ initForeignServers = function() {
var HongFangTeaHouseServer = new Server();
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);
AddToAllServers(HongFangTeaHouseServer);
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.setPortProperties(0);
AddToAllServers(HaraKiriSushiBarServer);
@ -651,7 +651,11 @@ processServerGrowth = function(numCycles) {
var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage;
//Apply serverGrowth for the calculated number of growth cycles
var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted);
var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted) * Player.hacking_grow_mult;
if (serverGrowth < 1) {
console.log("WARN: serverGrowth calculated to be less than 1");
serverGrowth = 1;
}
//console.log("serverGrowth ratio: " + serverGrowth);
server.moneyAvailable *= serverGrowth;
}
@ -670,7 +674,11 @@ processSingleServerGrowth = function(server, numCycles) {
var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage;
//Apply serverGrowth for the calculated number of growth cycles
var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted);
var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted) * Player.hacking_grow_mult;
if (serverGrowth < 1) {
console.log("WARN: serverGrowth calculated to be less than 1");
serverGrowth = 1;
}
server.moneyAvailable *= serverGrowth;
return serverGrowth;

@ -102,18 +102,28 @@ $(document).keydown(function(event) {
input = input.trim();
input = input.replace(/\s\s+/g, ' ');
var allPos = determineAllPossibilitiesForTabCompletion(input);
var commandArray = input.split(" ");
var index = commandArray.length - 2;
if (index < 0) {index = 0;}
var allPos = determineAllPossibilitiesForTabCompletion(input, index);
if (allPos.length == 0) {return;}
var commandArray = input.split(" ");
var arg = "";
var command = "";
if (commandArray.length == 0) {return;}
else if (commandArray.length > 1) {
else if (commandArray.length == 2) {
command = commandArray[0];
arg = commandArray[1];
} else if (commandArray.length == 3) {
command = commandArray[0] + " " + commandArray[1];
arg = commandArray[2];
} else {
command = commandArray[0];
}
tabCompletion(commandArray[0], arg, allPos);
tabCompletion(command, arg, allPos);
}
}
});
@ -155,7 +165,8 @@ $(document).keyup(function(e) {
// a series of possible options for
// allPossibilities - Array of strings containing all possibilities that the
// string can complete to
function tabCompletion(command, arg, allPossibilities) {
// index - index of argument that is being "tab completed". By default is 0, the first argument
function tabCompletion(command, arg, allPossibilities, index=0) {
if (!(allPossibilities.constructor === Array)) {return;}
if (!containsAllStrings(allPossibilities)) {return;}
@ -191,9 +202,19 @@ function tabCompletion(command, arg, allPossibilities) {
}
}
function determineAllPossibilitiesForTabCompletion(input) {
function determineAllPossibilitiesForTabCompletion(input, index=0) {
var allPos = [];
var currServ = Player.getCurrentServer();
if (input.startsWith("scp ") && index == 1) {
for (var iphostname in AllServers) {
if (AllServers.hasOwnProperty(iphostname)) {
allPos.push(AllServers[iphostname].ip);
allPos.push(AllServers[iphostname].hostname);
}
}
}
if (input.startsWith("connect ") || input.startsWith("telnet ")) {
//All network connections
for (var i = 0; i < currServ.serversOnNetwork.length; ++i) {
@ -207,7 +228,8 @@ function determineAllPossibilitiesForTabCompletion(input) {
if (input.startsWith("kill ") || input.startsWith("nano ") ||
input.startsWith("tail ") || input.startsWith("rm ") ||
input.startsWith("mem ")) {
input.startsWith("mem ") ||
(input.startsWith("scp ") && index == 0)) {
//All Scripts
for (var i = 0; i < currServ.scripts.length; ++i) {
allPos.push(currServ.scripts[i].filename);
@ -539,7 +561,7 @@ var Terminal = {
case "connect":
//Disconnect from current server in terminal and connect to new one
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;
}
@ -762,7 +784,45 @@ var Terminal = {
}
break;
case "scp":
//TODO
if (commandArray.length != 2) {
post("Incorrect usage of scp command. Usage: scp [scriptname] [destination hostname/ip]");
return;
}
var args = commandArray[1].split(" ");
if (args.length != 2) {
post("Incorrect usage of scp command. Usage: scp [scriptname] [destination hostname/ip]");
return;
}
var scriptname = args[0];
var server = getServer(args[1]);
if (server == null) {
post("Invalid destination. " + args[1] + " not found");
return;
}
var ip = server.ip;
//Check that a script with this filename does not already exist
for (var i = 0; i < server.scripts.length; ++i) {
if (scriptname == server.scripts[i].filename) {
post(server.hostname + " already contains a script named " + scriptname);
return;
}
}
var currServ = Player.getCurrentServer();
for (var i = 0; i < currServ.scripts.length; ++i) {
if (scriptname == currServ.scripts[i].filename) {
var newScript = new Script();
newScript.filename = scriptname;
newScript.code = currServ.scripts[i].code;
newScript.ramUsage = currServ.scripts[i].ramUsage;
newScript.server = ip;
server.scripts.push(newScript);
post(scriptname + " copied over to " + server.hostname);
return;
}
}
post("Script not found");
break;
case "sudov":
if (commandArray.length != 1) {

@ -277,12 +277,13 @@ var Engine = {
'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 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 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>' +
'Company reputation gain multiplier: ' + formatNumber(Player.company_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>' +
'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 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>' +
'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_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>' +
'<b>Misc</b><br><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
createProgramNotifications: 10, //Checks whether any programs can be created and notifies
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,
},
@ -659,7 +660,7 @@ var Engine = {
var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)];
inviteToFaction(randFaction);
}
Engine.Counters.checkFactionInvitations = 1500;
Engine.Counters.checkFactionInvitations = 1000;
}
if (Engine.Counters.passiveFactionGrowth <= 0) {
@ -765,6 +766,9 @@ var Engine = {
if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;}
Player.totalPlaytime += time;
//Re-apply augmentations
Player.reapplyAllAugmentations();
Player.lastUpdate = Engine._lastUpdate;
Engine.start(); //Run main game loop and Scripts loop
dialogBoxCreate("While you were offline, your scripts generated $" +
@ -1088,6 +1092,7 @@ var Engine = {
document.getElementById("debug-delete-scripts-link").addEventListener("click", function() {
console.log("Deleting running scripts on home computer");
Player.getHomeComputer().runningScripts = [];
dialogBoxCreate("Forcefully deleted scripts. Please refresh page");
return false;
});
},

@ -153,7 +153,7 @@ purchaseAugmentationBoxCreate = function(aug, fac) {
dialogBoxCreate("You must first install the Bionic Arms augmentation before installing this upgrade");
}
} 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 " +
" in order to install the " + aug.name + " Augmentation. <br><br>" +
"You wake up in your home...you feel different...");