From af47baf4faa2c076675d5fe907abdc7881a54e25 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 29 May 2017 17:37:38 -0500 Subject: [PATCH 1/6] 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 --- src/Augmentations.js | 124 ++++++++++++++++++++++++------- src/Constants.js | 7 +- src/Crimes.js | 18 ++--- src/Faction.js | 14 ++-- src/Location.js | 2 +- src/NetscriptEnvironment.js | 8 +- src/NetscriptEvaluator.js | 33 ++++---- src/NetscriptParser.js | 8 +- src/Player.js | 2 +- src/Script.js | 3 +- src/Server.js | 22 ++++-- src/Terminal.js | 2 +- src/engine.js | 20 +++-- utils/PurchaseAugmentationBox.js | 2 +- 14 files changed, 180 insertions(+), 85 deletions(-) diff --git a/src/Augmentations.js b/src/Augmentations.js index 68e6f6a68..d14729103 100644 --- a/src/Augmentations.js +++ b/src/Augmentations.js @@ -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; @@ -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.

" + - "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%
" + - "Increases the player's experience gain rate for all stats by 1%
" + - "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; } @@ -1539,21 +1536,42 @@ applyAugmentation = function(aug, faction) { //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) { diff --git a/src/Constants.js b/src/Constants.js index 8c693ef1b..ae5a82591 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -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.18, /* Script related things */ //Time (ms) it takes to run one operation in Netscript. @@ -59,7 +59,7 @@ CONSTANTS = { ScriptHNUpgCoreRamCost: 0.8, //Server growth rate - ServerGrowthRate: 1.00075, + ServerGrowthRate: 1.001, //Maximum number of log entries for a script MaxLogCapacity: 40, @@ -283,6 +283,7 @@ CONSTANTS = { "hasRootAccess(hostname/ip)
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.
" + "Example:
if (hasRootAccess('foodnstuff') == false) {
    nuke('foodnstuff');
}

" + + "getHostname()
Returns a string with the hostname of the server that the script is running on

" + "getHackingLevel()
Returns the Player's current hacking level. Does NOT work while offline

" + "getServerMoneyAvailable(hostname/ip)
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
Example: getServerMoneyAvailable('foodnstuff');

" + diff --git a/src/Crimes.js b/src/Crimes.js index c2239595d..01a2c94cf 100644 --- a/src/Crimes.js +++ b/src/Crimes.js @@ -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) { diff --git a/src/Faction.js b/src/Faction.js index 5c7e998ec..41579a3f1 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -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; } diff --git a/src/Location.js b/src/Location.js index 7fdaf666b..6e163f5a8 100644 --- a/src/Location.js +++ b/src/Location.js @@ -1394,7 +1394,7 @@ initLocationButtons = function() { }); itJob.addEventListener("click", function() { - Player.applyForSoftwareJob() + Player.applyForItJob(); return false; }); diff --git a/src/NetscriptEnvironment.js b/src/NetscriptEnvironment.js index a3d3f58ae..7ce792582 100644 --- a/src/NetscriptEnvironment.js +++ b/src/NetscriptEnvironment.js @@ -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; }, diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index c3298cea1..aa4da914a 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -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") @@ -64,9 +63,9 @@ function evaluate(exp, workerScript) { p.then(function(expRight) { try { env.set(exp.left.value, expRight); + workerScript.scriptRef.log("Variable " + exp.left.value + " set to " + 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 +118,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 +155,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); }); @@ -670,7 +666,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 +687,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 +709,19 @@ function evaluate(exp, workerScript) { }, 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 +801,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 +1209,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 / 825; if (percentMoneyHacked < 0) {return 0;} if (percentMoneyHacked > 1) {return 1;} return percentMoneyHacked; diff --git a/src/NetscriptParser.js b/src/NetscriptParser.js index 9f57b12fc..394ad4c59 100644 --- a/src/NetscriptParser.js +++ b/src/NetscriptParser.js @@ -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(); } diff --git a/src/Player.js b/src/Player.js index 74e53b11d..cb9757fa4 100644 --- a/src/Player.js +++ b/src/Player.js @@ -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 / 825; console.log("Percent money hacked calculated to be: " + percentMoneyHacked); if (percentMoneyHacked < 0) {return 0;} if (percentMoneyHacked > 1) {return 1;} diff --git a/src/Script.js b/src/Script.js index 2624489bc..89e24057f 100644 --- a/src/Script.js +++ b/src/Script.js @@ -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(); } } diff --git a/src/Server.js b/src/Server.js index 83b875b05..a4ade1bfd 100644 --- a/src/Server.js +++ b/src/Server.js @@ -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); @@ -652,6 +652,10 @@ processServerGrowth = function(numCycles) { //Apply serverGrowth for the calculated number of growth cycles 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); server.moneyAvailable *= serverGrowth; } @@ -671,6 +675,10 @@ processSingleServerGrowth = function(server, numCycles) { //Apply serverGrowth for the calculated number of growth cycles 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; return serverGrowth; diff --git a/src/Terminal.js b/src/Terminal.js index 971e58f13..3137a2e59 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -539,7 +539,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; } diff --git a/src/engine.js b/src/engine.js index 03fb348a7..ce4647542 100644 --- a/src/engine.js +++ b/src/engine.js @@ -277,12 +277,13 @@ var Engine = { 'Charisma Experience multiplier: ' + formatNumber(Player.charisma_exp_mult * 100, 2) + '%

' + 'Hacknet Node production multiplier: ' + formatNumber(Player.hacknet_node_money_mult * 100, 2) + '%
' + 'Hacknet Node purchase cost multiplier: ' + formatNumber(Player.hacknet_node_purchase_cost_mult * 100, 2) + '%
' + - 'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%
' + - 'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%
' + - 'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%

' + - 'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%
' + - 'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%
' + - 'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%
' + + 'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%
' + + 'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%
' + + 'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%

' + + 'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%
' + + 'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%
' + + 'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%
' + + 'Crime success multiplier: ' + formatNumber(Player.crime_success_mult * 100, 2) + '%
' + 'Crime money multiplier: ' + formatNumber(Player.crime_money_mult * 100, 2) + '%


' + 'Misc

' + 'Servers owned: ' + Player.purchasedServers.length + '
' + @@ -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 $" + diff --git a/utils/PurchaseAugmentationBox.js b/utils/PurchaseAugmentationBox.js index d27e8196c..99a007804 100644 --- a/utils/PurchaseAugmentationBox.js +++ b/utils/PurchaseAugmentationBox.js @@ -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.

" + "You wake up in your home...you feel different..."); From d8fd1e1164582ca543adbd71d6a3e4f863ea7ee6 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 29 May 2017 17:42:42 -0500 Subject: [PATCH 2/6] Removed a log statement from Netscriopt --- src/CompanyJobApplication.js | 1 - src/NetscriptEvaluator.js | 1 - 2 files changed, 2 deletions(-) diff --git a/src/CompanyJobApplication.js b/src/CompanyJobApplication.js index 78802352c..62546a05d 100644 --- a/src/CompanyJobApplication.js +++ b/src/CompanyJobApplication.js @@ -107,7 +107,6 @@ PlayerObject.prototype.applyForJob = function(entryPosType) { } } - this.companyName = company.companyName; this.companyPosition = pos; diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index aa4da914a..fdf1ee66a 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -63,7 +63,6 @@ function evaluate(exp, workerScript) { p.then(function(expRight) { try { env.set(exp.left.value, expRight); - workerScript.scriptRef.log("Variable " + exp.left.value + " set to " + expRight); } catch (e) { reject("|" + workerScript.serverIp + "|" + workerScript.name + "|" + e.toString()); } From 66d311f9d891e5adc5d68f38a4c30e510177050f Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 29 May 2017 18:12:57 -0500 Subject: [PATCH 3/6] Added RAM cost for getHostname() and hasRootAccess(). Applied hacking grow_mult to server growth) git p --- src/Constants.js | 2 ++ src/NetscriptEvaluator.js | 1 - src/Script.js | 4 ++++ src/Server.js | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index ae5a82591..77932c6af 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -49,6 +49,8 @@ CONSTANTS = { ScriptHttpwormRamCost: 0.05, ScriptSqlinjectRamCost: 0.05, ScriptRunRamCost: 0.8, + ScriptHasRootAccessRamCost: 0.05, + ScriptGetHostnameRamCost: 0.1, ScriptGetHackingLevelRamCost: 0.1, ScriptGetServerMoneyRamCost: 0.1, ScriptOperatorRamCost: 0.01, diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index fdf1ee66a..26a345423 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -169,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); }); diff --git a/src/Script.js b/src/Script.js index 89e24057f..147bae1e8 100644 --- a/src/Script.js +++ b/src/Script.js @@ -182,6 +182,8 @@ Script.prototype.updateRamUsage = function() { var httpwormCount = numOccurrences(codeCopy, "httpworm("); var sqlinjectCount = numOccurrences(codeCopy, "sqlinject("); var runCount = numOccurrences(codeCopy, "run("); + var hasRootAccessCount = numOccurrences(codeCopy, "hasRootAccess("); + var getHostnameCount = numOccurrences(codeCopy, "getHostname("); var getHackingLevelCount = numOccurrences(codeCopy, "getHackingLevel("); var getServerMoneyAvailableCount = numOccurrences(codeCopy, "getServerMoneyAvailable("); var numOperators = numNetscriptOperators(codeCopy); @@ -204,6 +206,8 @@ Script.prototype.updateRamUsage = function() { (httpwormCount * CONSTANTS.ScriptHttpwormRamCost) + (sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) + (runCount * CONSTANTS.ScriptRunRamCost) + + (hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) + + (getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) + (getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) + (getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) + (numOperators * CONSTANTS.ScriptOperatorRamCost) + diff --git a/src/Server.js b/src/Server.js index a4ade1bfd..aff18b744 100644 --- a/src/Server.js +++ b/src/Server.js @@ -651,7 +651,7 @@ 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; @@ -674,7 +674,7 @@ 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; From 54bf26689fe76bc3b2ae3f1bafb6dc9d51d8db20 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 29 May 2017 19:18:48 -0500 Subject: [PATCH 4/6] Added scp terminal command --- src/Constants.js | 2 +- src/Terminal.js | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 2 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 77932c6af..600b1d2fd 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -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 diff --git a/src/Terminal.js b/src/Terminal.js index 3137a2e59..ca2a2ee10 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -762,7 +762,46 @@ 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) { From 3ff1e8e87d599acaa865a28ae7e102cc86b56f8a Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 29 May 2017 20:25:52 -0500 Subject: [PATCH 5/6] Added scp command to netscript. Nerfed Hacknet Node augmentations --- src/Augmentations.js | 8 +++--- src/Constants.js | 7 +++--- src/Location.js | 2 +- src/NetscriptEvaluator.js | 52 +++++++++++++++++++++++++++++++++++++++ src/Terminal.js | 3 +-- src/engine.js | 1 + 6 files changed, 63 insertions(+), 10 deletions(-) diff --git a/src/Augmentations.js b/src/Augmentations.js index d14729103..8737d8f57 100644 --- a/src/Augmentations.js +++ b/src/Augmentations.js @@ -789,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.

" + - "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; @@ -802,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.

" + - "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; @@ -1528,10 +1528,10 @@ applyAugmentation = function(aug, reapply=false) { 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 diff --git a/src/Constants.js b/src/Constants.js index 600b1d2fd..c9eb92ae5 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -147,15 +147,16 @@ CONSTANTS = { "home Connect to home computer
" + "hostname Displays the hostname of the machine
" + "ifconfig Displays the IP address of the machine
" + - "kill [script name] Stops a script that is running on the current machine
" + + "kill [script] Stops a script that is running on the current machine
" + "ls Displays all programs and scripts on the machine
" + - "mem [script name] Displays the amount of RAM the script requires to run
" + - "nano [script name] Text editor - Open up and edit a script
" + + "mem [script] Displays the amount of RAM the script requires to run
" + + "nano [script] Text editor - Open up and edit a script
" + "ps Display all scripts that are currently running
" + "rm Delete a script/program from the machine. (WARNING: Permanent)
" + "run [script/program] Execute a program or a script
" + "scan Displays all available network connections
" + "scan-analyze [depth] Displays hacking-related information for all servers up to depth nodes away
" + + "scp [script] [server] Copies a script to a destination server (specified by ip or hostname)
" + "sudov Shows whether or not you have root access on this computer
" + "tail [script] Display script logs (logs contain details about active scripts)
" + "top Display all running scripts and their RAM usage
", diff --git a/src/Location.js b/src/Location.js index 6e163f5a8..8f302f23e 100644 --- a/src/Location.js +++ b/src/Location.js @@ -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(); diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index 26a345423..50a6a48a1 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -707,6 +707,58 @@ function evaluate(exp, workerScript) { }, function(e) { reject(e); }); + } else if (exp.func.value == "scp") { + if (exp.args.length != 1) { + 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(destServ.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 = ip; + server.scripts.push(newScript); + workerScript.scriptRef.log(scriptname + " copied over to " + server.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")); diff --git a/src/Terminal.js b/src/Terminal.js index ca2a2ee10..144baa912 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -789,8 +789,7 @@ var Terminal = { var currServ = Player.getCurrentServer(); for (var i = 0; i < currServ.scripts.length; ++i) { - if (scriptname == currServ.scripts[i].filename){ - + if (scriptname == currServ.scripts[i].filename) { var newScript = new Script(); newScript.filename = scriptname; newScript.code = currServ.scripts[i].code; diff --git a/src/engine.js b/src/engine.js index ce4647542..56535293d 100644 --- a/src/engine.js +++ b/src/engine.js @@ -1092,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; }); }, From ad6f74a16d79c0c583ccf2cafe9786ce6bd26e55 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 29 May 2017 21:02:41 -0500 Subject: [PATCH 6/6] Lowered cost for NeuroFlux governor. Fixed tab completion for scp command. Fixed bugs with Netscript scp command --- src/Constants.js | 3 ++- src/NetscriptEvaluator.js | 12 ++++++------ src/Player.js | 2 +- src/Script.js | 2 ++ src/Terminal.js | 36 +++++++++++++++++++++++++++++------- 5 files changed, 40 insertions(+), 15 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index c9eb92ae5..6c788c83b 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -30,7 +30,7 @@ CONSTANTS = { /* Augmentation */ //NeuroFlux Governor cost multiplier as you level up - NeuroFluxGovernorLevelMult: 1.18, + NeuroFluxGovernorLevelMult: 1.14, /* Script related things */ //Time (ms) it takes to run one operation in Netscript. @@ -49,6 +49,7 @@ CONSTANTS = { ScriptHttpwormRamCost: 0.05, ScriptSqlinjectRamCost: 0.05, ScriptRunRamCost: 0.8, + ScriptScpRamCost: 0.5, ScriptHasRootAccessRamCost: 0.05, ScriptGetHostnameRamCost: 0.1, ScriptGetHackingLevelRamCost: 0.1, diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index 50a6a48a1..4ddc07895 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -708,7 +708,7 @@ function evaluate(exp, workerScript) { reject(e); }); } else if (exp.func.value == "scp") { - if (exp.args.length != 1) { + if (exp.args.length != 2) { reject(makeRuntimeRejectMsg(workerScript, "scp() call has incorrect number of arguments. Takes 2 arguments")); return; } @@ -725,7 +725,7 @@ function evaluate(exp, workerScript) { //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(destServ.hostname + " already contains a script named " + scriptname); + workerScript.scriptRef.log(destServer.hostname + " already contains a script named " + scriptname); resolve(false); return; } @@ -742,9 +742,9 @@ function evaluate(exp, workerScript) { newScript.filename = scriptname; newScript.code = currServ.scripts[i].code; newScript.ramUsage = currServ.scripts[i].ramUsage; - newScript.server = ip; - server.scripts.push(newScript); - workerScript.scriptRef.log(scriptname + " copied over to " + server.hostname); + newScript.server = destServer.ip; + destServer.scripts.push(newScript); + workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); resolve(true); return; } @@ -1259,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 / 825; + var percentMoneyHacked = difficultyMult * skillMult * Player.hacking_money_mult / 725; if (percentMoneyHacked < 0) {return 0;} if (percentMoneyHacked > 1) {return 1;} return percentMoneyHacked; diff --git a/src/Player.js b/src/Player.js index cb9757fa4..19eda9588 100644 --- a/src/Player.js +++ b/src/Player.js @@ -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 / 825; + 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;} diff --git a/src/Script.js b/src/Script.js index 147bae1e8..14f793d87 100644 --- a/src/Script.js +++ b/src/Script.js @@ -182,6 +182,7 @@ 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("); @@ -206,6 +207,7 @@ 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) + diff --git a/src/Terminal.js b/src/Terminal.js index 144baa912..b96a39363 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -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);