Adding messages. Changed hacking factions to rely on hacking their specific servers to get the invite. Made Augmentations more expensive

This commit is contained in:
Daniel Xie 2017-06-01 23:15:45 -05:00
parent 236facab97
commit 94dd4395be
13 changed files with 287 additions and 44 deletions

@ -57,6 +57,7 @@
<script src="src/DarkWeb.js"></script>
<script src="src/InteractiveTutorial.js"></script>
<script src="src/Alias.js"></script>
<script src="src/Message.js"></script>
<script src="src/engine.js"></script>

@ -18,7 +18,7 @@ Augmentation.prototype.setInfo = function(inf) {
}
Augmentation.prototype.setRequirements = function(rep, cost) {
this.baseRepRequirement = rep;
this.baseRepRequirement = rep * CONSTANTS.AugmentationRepMultiplier;
this.baseCost = cost * CONSTANTS.AugmentationCostMultiplier;
}

@ -70,7 +70,8 @@ CONSTANTS = {
ServerWeakenAmount: 0.1, //Amount by which server's security decreases when weakened
//Augmentation Constants
AugmentationCostMultiplier: 3, //Used for balancing costs without having to readjust every Augmentation cost
AugmentationCostMultiplier: 4, //Used for balancing costs without having to readjust every Augmentation cost
AugmentationRepMultiplier: 1.2, //Used for balancing rep cost without having to readjust every value
//Maximum number of log entries for a script
MaxLogCapacity: 40,
@ -147,6 +148,7 @@ CONSTANTS = {
//Text that is displayed when the 'help' command is ran in Terminal
HelpText: 'alias [name="value"] Create aliases for Terminal commands, or list existing aliases<br>' +
"analyze Get statistics and information about current machine <br>" +
"cat [message] Display a .msg file<br>" +
"clear Clear all text on the terminal <br>" +
"cls See 'clear' command <br>" +
"connect [ip/hostname] Connects to the machine given by its IP or hostname <br>" +

@ -8,6 +8,7 @@ Programs = {
SQLInjectProgram: "SQLInject.exe",
DeepscanV1: "DeepscanV1.exe",
DeepscanV2: "DeepscanV2.exe",
Flight: "fl1ght.exe",
}
//TODO Right now the times needed to complete work are hard-coded...

@ -290,12 +290,12 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company
var fulcrumsecrettechonologiesFac = Factions["Fulcrum Secret Technologies"];
var fulcrumSecretServer = AllServers[SpecialServerIps["Fulcrum Secret Technologies Server"]];
var fulcrumSecretServer = AllServers[SpecialServerIps[SpecialServerNames.FulcrumSecretTechnologies]];
if (fulcrumSecretServer == null) {
console.log("Error: Could not find Fulcrum Secret Technologies Server");
console.log("ERROR: Could not find Fulcrum Secret Technologies Server");
} else {
if (fulcrumsecrettechonologiesFac.isBanned == false && fulcrumsecrettechonologiesFac.isMember == false &&
fulcrumSecretServer.hasAdminRights &&
fulcrumSecretServer.manuallyHacked &&
this.companyName == Locations.AevumFulcrumTechnologies && companyRep >= 250000) {
invitedFactions.push(fulcrumsecrettechonologiesFac);
}
@ -303,23 +303,31 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//BitRunners
var bitrunnersFac = Factions["BitRunners"];
var homeComp = Player.getHomeComputer();
if (bitrunnersFac.isBanned == false && bitrunnersFac.isMember == false &&
this.hacking_skill >= 500 && homeComp.maxRam >= 128) {
var homeComp = this.getHomeComputer();
var bitrunnersServer = AllServers[SpecialServerIps[SpecialServerNames.BitRunnersServer]];
if (bitrunnersServer == null) {
console.log("ERROR: Could not find BitRunners Server");
} else if (bitrunnersFac.isBanned == false && bitrunnersFac.isMember == false && bitrunnersServer.manuallyHacked &&
this.hacking_skill >= 500 && homeComp.maxRam >= 128) {
invitedFactions.push(bitrunnersFac);
}
//The Black Hand
var theblackhandFac = Factions["The Black Hand"];
if (theblackhandFac.isBanned == false && theblackhandFac.isMember == false &&
this.hacking_skill >= 300 && this.strength >= 100 && this.defense >= 100 &&
this.agility >= 100 && this.dexterity >= 100 && homeComp.maxRam >= 64) {
var blackhandServer = AllServers[SpecialServerIps[SpecialServerNames.TheBlackHandServer]];
if (blackhandServer == null) {
console.log("ERROR: Could not find The Black Hand Server");
} else if (!theblackhandFac.isBanned && !theblackhandFac.isMember && blackhandServer.manuallyHacked &&
this.hacking_skill >= 350 && homeComp.maxRam >= 64) {
invitedFactions.push(theblackhandFac);
}
//NiteSec
var nitesecFac = Factions["NiteSec"];
if (nitesecFac.isBanned == false && nitesecFac.isMember == false &&
var nitesecServer = AllServers[SpecialServerIps[SpecialServerNames.NiteSecServer]];
if (nitesecServer == null) {
console.log("ERROR: Could not find NiteSec Server");
} else if (!nitesecFac.isBanned && !nitesecFac.isMember && nitesecServer.manuallyHacked &&
this.hacking_skill >= 200 && homeComp.maxRam >= 32) {
invitedFactions.push(nitesecFac);
}
@ -451,7 +459,10 @@ PlayerObject.prototype.checkForFactionInvitations = function() {
//CyberSec
var cybersecFac = Factions["CyberSec"];
if (cybersecFac.isBanned == false && cybersecFac.isMember == false &&
var cybersecServer = AllServers[SpecialServerIps[SpecialServerNames.CyberSecServer]];
if (cybersecServer == null) {
console.log("ERROR: Could not find CyberSec Server");
} else if (!cybersecFac.isBanned && !cybersecFac.isMember && cybersecServer.manuallyHacked &&
this.hacking_skill >= 50) {
invitedFactions.push(cybersecFac);
}

153
src/Message.js Normal file

@ -0,0 +1,153 @@
/* Message.js */
function Message(filename, msg) {
this.filename = filename;
this.msg = msg;
this.recvd = false;
}
Message.prototype.toJSON = function() {
return Generic_toJSON("Message", this);
}
Message.fromJSON = function(value) {
return Generic_fromJSON(Message, value.data);
}
Reviver.constructors.Message = Message;
//Sends message to player, including a pop up
function sendMessage(msg) {
console.log("sending message: " + msg.filename);
msg.recvd = true;
showMessage(msg);
addMessageToServer(msg, "home");
}
function showMessage(msg) {
var txt = "Message received from unknown sender: <br><br>" +
"<i>" + msg.msg + "</i><br><br>" +
"This message was saved as " + msg.filename + " onto your home computer.";
dialogBoxCreate(txt);
}
//Adds a message to a server
function addMessageToServer(msg, serverHostname) {
var server = GetServerByHostname(serverHostname);
if (server == null) {
console.log("WARNING: Did not locate " + serverHostname);
return;
}
server.messages.push(msg);
}
//Checks if any of the 'timed' messages should be sent
function checkForMessagesToSend() {
console.log("checkForMessagesToSend() called");
var jumper0 = Messages[MessageFilenames.Jumper0];
var jumper1 = Messages[MessageFilenames.Jumper1];
var jumper2 = Messages[MessageFilenames.Jumper2];
var jumper3 = Messages[MessageFilenames.Jumper3];
var jumper4 = Messages[MessageFilenames.Jumper4];
var jumper5 = Messages[MessageFilenames.Jumper5];
var cybersecTest = Messages[MessageFilenames.CyberSecTest];
var nitesecTest = Messages[MessageFilenames.NiteSecTest];
var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
if (jumper0 && !jumper0.recvd && Player.hacking_skill >= 25) {
sendMessage(jumper0);
} else if (jumper1 && !jumper1.recvd && Player.hacking_skill >= 40) {
sendMessage(jumper1);
} else if (cybersecTest && !cybersecTest.recvd && Player.hacking_skill >= 50) {
sendMessage(cybersecTest);
} else if (jumper2 && !jumper2.recvd && Player.hacking_skill >= 175) {
sendMessage(jumper2);
} else if (nitesecTest && !nitesecTest.recvd && Player.hacking_skill >= 200) {
sendMessage(nitesecTest);
} else if (jumper3 && !jumper3.recvd && Player.hacking_skill >= 350) {
sendMessage(jumper3);
} else if (jumper4 && !jumper4.recvd && Player.hacking_skill >= 490) {
sendMessage(jumper4);
} else if (bitrunnersTest && !bitrunnersTest.recvd && Player.hacking_skill >= 500) {
sendMessage(bitrunnersTest);
Player.getHomeComputer.programs.push(Programs.Flight);
} if (!jumper5 && !jumper5.recvd && Player.hacking_skill >= 900) {
sendMessage(jumper5);
}
}
function AddToAllMessages(msg) {
Messages[msg.filename] = msg;
}
Messages = {}
MessageFilenames = {
Jumper0: "j0.msg",
Jumper1: "j1.msg",
Jumper2: "j2.msg",
Jumper3: "j3.msg",
Jumper4: "j4.msg",
Jumper5: "j4.msg",
CyberSecTest: "csec-test.msg",
NiteSecTest: "nitesec-test.msg",
BitRunnersTest: "19dfj3l1nd.msg",
}
function initMessages() {
//Reset
Messages = {};
//jump3R Messages
AddToAllMessages(new Message(MessageFilenames.Jumper0,
"I know you can sense it. I know you're searching for it. " +
"It's why you spend night after " +
"night at your computer. <br><br>It's real, I've seen it. And I can " +
"help you find it. But not right now. You're not ready yet. Keep searching, " +
"but don't fly too close to the sun.<br><br>-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper1,
"Soon you will be contacted by a hacking group known as CyberSec. " +
"They can help you with your search. <br><br>" +
"You should join them, garner their favor, and " +
"exploit them for their Augmentations. But do not trust them. " +
"They are not what they seem. No one is.<br><br>" +
"-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper2,
"Do not try to save the world. There is no world to save. If " +
"you want to find the truth, worry only about yourself. Ethics and " +
"morals will get you killed. <br><br>Watch out for a hacking group known as NiteSec." +
"<br><br>-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper3,
"You must learn to walk before you can run. And you must " +
"run before you can fly. Look for the black hand. <br><br>" +
"I.I.I.I <br><br>-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper4,
"To find what you are searching for, you must understand the bits. " +
"The bits are all around us. The runners will help you.<br><br>" +
"-jump3R"));
AddToAllMessages(new Message(MessageFilenames.Jumper5,
"Build your wings and fly<br><br>-jump3R<br><br> " +
"The fl1ght.exe program was added to your home computer"));
//Messages from hacking factions
AddToAllMessages(new Message(MessageFilenames.CyberSecTest,
"We've been watching you. Your skills are very impressive. But you're wasting " +
"your talents. If you join us, you can put your skills to good use and change " +
"the world for the better. If you join us, we can unlock your full potential. <br><br>" +
"But first, you must pass our test. Find and hack our server using the Terminal. <br><br>" +
"-CyberSec"));
AddToAllMessages(new Message(MessageFilenames.NiteSecTest,
"People say that the corrupted governments and corporations rule the world. " +
"Yes, maybe they do. But do you know who everyone really fears? People " +
"like us. Because they can't hide from us. Because they can't fight shadows " +
"and ideas with bullets. <br><br>" +
"Join us, and people will fear you, too. <br><br>" +
"Find and hack our hidden server using the Terminal. Then, we will contact you again." +
"<br><br>-NiteSec"));
AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,
"We know what you are doing. We know what drives you. We know " +
"what you are looking for. <br><br> " +
"We can help you find the answers.<br><br>" +
"run4theh111z"));
}

@ -120,7 +120,6 @@ function evaluate(exp, workerScript) {
var numConds = exp.cond.length;
var numThens = exp.then.length;
if (numConds == 0 || numThens == 0 || numConds != numThens) {
console.log("Number of ifs and conds dont match. Rejecting");
reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Number of conds and thens in if structure don't match (or there are none)");
}
@ -128,20 +127,17 @@ function evaluate(exp, workerScript) {
evalIfPromise.then(function(res) {
if (res) {
//One of the if/elif statements evaluated to true
console.log("done with if");
resolve("if statement done");
} else {
//None of the if/elif statements were true. Evaluate else if there is one
if (exp.else) {
var elseEval = evaluate(exp.else, workerScript);
elseEval.then(function(res) {
console.log("if statement done with else");
resolve("if statement done with else");
}, function(e) {
reject(e);
});
} else {
console.log("no else statement, resolving");
resolve("if statement done");
}
}
@ -960,12 +956,9 @@ function evaluateIf(exp, workerScript, i) {
} else {
var cond = evaluate(exp.cond[i], workerScript);
cond.then(function(condRes) {
console.log("cond evaluated to: " + condRes);
if (condRes) {
console.log("Evaluating then: " + exp.then[i]);
var evalThen = evaluate(exp.then[i], workerScript);
evalThen.then(function(res) {
console.log("If statement done");
resolve(true);
}, function(e) {
reject(e);

@ -11,6 +11,7 @@ function BitburnerSaveObject() {
this.SpecialServerIpsSave = "";
this.AugmentationsSave = "";
this.AliasesSave = "";
this.MessagesSave = "";
}
BitburnerSaveObject.prototype.saveGame = function() {
@ -21,6 +22,7 @@ BitburnerSaveObject.prototype.saveGame = function() {
this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps);
this.AugmentationsSave = JSON.stringify(Augmentations);
this.AliasesSave = JSON.stringify(Aliases);
this.MessagesSave = JSON.stringify(Messages);
var saveString = btoa(unescape(encodeURIComponent(JSON.stringify(this))));
window.localStorage.setItem("bitburnerSave", saveString);
@ -52,7 +54,15 @@ loadGame = function(saveObj) {
} else {
Aliases = {};
}
if (saveObj.hasOwnProperty("MessagesSave")) {
try {
Messages = JSON.parse(saveObj.MessagesSave, Reviver);
} catch(e) {
initMessages();
}
} else {
initMessages();
}
return true;
}

@ -13,6 +13,7 @@ function Server() {
//Access information
this.hasAdminRights = false; //Whether player has admin rights
this.purchasedByPlayer = false;
this.manuallyHacked = false; //Flag that tracks whether or not the server has been hacked at least once
//RAM, CPU speed and Scripts
this.maxRam = 1; //GB
@ -131,8 +132,6 @@ Server.fromJSON = function(value) {
Reviver.constructors.Server = Server;
//world_daemon: new Server(), //Final server for 2nd tier prestige. Discover that the world is a simulation
initForeignServers = function() {
//MegaCorporations
var ECorpServer = new Server();
@ -201,8 +200,7 @@ initForeignServers = function() {
FulcrumSecretTechnologiesServer.setHackingParameters(999, 1000000, 99, 1);
FulcrumSecretTechnologiesServer.setPortProperties(5);
AddToAllServers(FulcrumSecretTechnologiesServer);
SpecialServerIps.addIp("Fulcrum Secret Technologies Server", FulcrumSecretTechnologiesServer.ip);
SpecialServerIps.addIp(SpecialServerNames.FulcrumSecretTechnologies, FulcrumSecretTechnologiesServer.ip);
var StormTechnologiesServer = new Server();
StormTechnologiesServer.init(createRandomIp(), "stormtech", "Storm Technologies", true, false, false, false, 0);
@ -519,47 +517,72 @@ initForeignServers = function() {
//Faction servers, cannot hack money from these
var BitRunnersServer = new Server();
BitRunnersServer.init(createRandomIp(), "run4theh111z", "The Runners", true, false, false, false, 0);
BitRunnersServer.setHackingParameters(getRandomInt(505, 550), 0, 0, 0);
BitRunnersServer.setPortProperties(4);
AddToAllServers(BitRunnersServer);
SpecialServerIps.addIp(SpecialServerNames.BitRunnersServer, BitRunnersServer.ip);
var TheBlackHandServer = new Server();
TheBlackHandServer.init(createRandomIp(), "I.I.I.I", "I.I.I.I", true, false, false, false, false, 0);
TheBlackHandServer.setHackingParameters(getRandomInt(305, 350), 0, 0, 0);
TheBlackHandServer.setPortProperties(3);
AddToAllServers(TheBlackHandServer);
SpecialServerIps.addIp(SpecialServerNames.TheBlackHandServer, TheBlackHandServer.ip);
var NiteSecServer = new Server();
NiteSecServer.init(createRandomIp(), "avmnite-02h", "NiteSec", true, false, false, false, 0);
NiteSecServer.setHackingParameters(getRandomInt(202, 230), 0, 0, 0);
NiteSecServer.setPortProperties(2);
AddToAllServers(NiteSecServer);
SpecialServerIps.addIp(SpecialServerNames.NiteSecServer, NiteSecServer.ip);
var DarkArmyServer = new Server();
DarkArmyServer.init(createRandomIp(), ".", ".", true, false, false, false, 0);
DarkArmyServer.setPortProperties(5);
DarkArmyServer.setHackingParameters(getRandomInt(505, 550), 0, 0, 0);
DarkArmyServer.setPortProperties(4);
AddToAllServers(DarkArmyServer);
SpecialServerIps.addIp(SpecialServerNames.TheDarkArmyServer, DarkArmyServer.ip);
var CyberSecServer = new Server();
CyberSecServer.init(createRandomIp(), "CSEC", "CyberSec", true, false, false, false, 0);
CyberSecServer.setPortProperties(2);
CyberSecServer.setHackingParameters(getRandomInt(51, 60), 0, 0, 0);
CyberSecServer.setPortProperties(1);
AddToAllServers(CyberSecServer);
SpecialServerIps.addIp(SpecialServerNames.CyberSecServer, CyberSecServer.ip);
var DaedalusServer = new Server();
DaedalusServer.init(createRandomIp(), "Icarus", "Icarus", true, false, false, false, 0);
DaedalusServer.setHackingParameters(925, 0, 0, 0);
DaedalusServer.setPortProperties(5);
AddToAllServers(DaedalusServer);
SpecialServerIps.addIp(SpecialServerNames.DaedalusServer, DaedalusServer.ip);
//Super special Servers
var WorldDaemon = new Server();
WorldDaemon.init(createRandomIp(), SpecialServerNames.WorldDaemon, SpecialServerNames.WorldDaemon, true, false, false, false, 0);
WorldDaemon.setHackingParameters(950, 0, 0, 0);
WorldDaemon.setPortProperties(5);
AddToAllServers(WorldDaemon);
SpecialServerIps.addIp(SpecialServerNames.WorldDaemon, WorldDaemon.ip);
/* Create a randomized network for all the foreign servers */
//Groupings for creating a randomized network
var NetworkGroup1 = [IronGymServer, FoodNStuffServer, SigmaCosmeticsServer, JoesGunsServer, HongFangTeaHouseServer, HaraKiriSushiBarServer];
var NetworkGroup2 = [MaxHardwareServer, NectarNightclubServer, Zer0NightclubServer];
var NetworkGroup2 = [MaxHardwareServer, NectarNightclubServer, Zer0NightclubServer, CyberSecServer];
var NetworkGroup3 = [OmegaSoftwareServer, PhantasyServer, SilverHelixServer, NeoNightclubServer];
var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer];
var NetworkGroup5 = [CatalystVenturesServer, SysCoreSecuritiesServer, SummitUniversityServer, ZBInstituteOfTechnologyServer, RothmanUniversityServer];
var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer, NiteSecServer];
var NetworkGroup5 = [CatalystVenturesServer, SysCoreSecuritiesServer, SummitUniversityServer, ZBInstituteOfTechnologyServer, RothmanUniversityServer, TheBlackHandServer];
var NetworkGroup6 = [LexoCorpServer, RhoConstructionServer, AlphaEnterprisesServer, AevumPoliceServer, MilleniumFitnessGymServer, CyberSecServer, NiteSecServer];
var NetworkGroup7 = [GlobalPharmaceuticalsServer, AeroCorpServer, GalacticCyberSystemsServer, SnapFitnessGymServer];
var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer];
var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer, BitRunnersServer];
var NetworkGroup9 = [ZeusMedicalServer, SolarisSpaceSystemsServer, UniversalEnergyServer, IcarusMicrosystemsServer, DefCommServer];
var NetworkGroup10 = [NovaMedicalServer, ZBDefenseServer, TaiYangDigitalServer, InfoCommServer];
var NetworkGroup11 = [AppliedEnergeticsServer, MicrodyneTechnologiesServer, TitanLabsServer, BitRunnersServer];
var NetworkGroup12 = [VitaLifeServer, HeliosLabsServer, StormTechnologiesServer, FulcrumTechnologiesServer];
var NetworkGroup13 = [KuaiGongInternationalServer, FourSigmaServer, OmniTekIncorporatedServer, DarkArmyServer];
var NetworkGroup14 = [PowerhouseGymServer, ClarkeIncorporatedServer, NWOServer, BladeIndustriesServer, BachmanAndAssociatesServer];
var NetworkGroup15 = [FulcrumSecretTechnologiesServer, MegaCorpServer, ECorpServer];
var NetworkGroup15 = [FulcrumSecretTechnologiesServer, MegaCorpServer, ECorpServer, DaedalusServer];
for (var i = 0; i < NetworkGroup2.length; i++) {
var randomServerFromPrevGroup = NetworkGroup1[Math.floor(Math.random() * NetworkGroup1.length)];

@ -1,6 +1,15 @@
/* Holds IP of Special Servers */
function SpecialServerIpsMap() {
SpecialServerNames = {
FulcrumSecretTechnologies: "Fulcrum Secret Technologies Server",
CyberSecServer: "CyberSec Server",
NiteSecServer: "NiteSec Server",
TheBlackHandServer: "The Black Hand Server",
BitRunnersServer: "BitRunners Server",
TheDarkArmyServer: "The Dark Army Server",
DaedalusServer: "Daedalus Server",
WorldDaemon: "w0r1d_d43m0n",
}
function SpecialServerIpsMap() {}
SpecialServerIpsMap.prototype.addIp = function(name, ip) {
this[name] = ip;

@ -250,6 +250,13 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) {
}
return allPos;
}
if (input.startsWith("cat ")) {
for (var i = 0; i < currServ.messages.length; ++i) {
allPos.push(currServ.messages[i].filename);
}
return allPos;
}
return allPos;
}
@ -272,7 +279,8 @@ var Terminal = {
//Complete the hack/analyze command
finishHack: function(cancelled = false) {
if (cancelled == false) {
console.log("Hack done. Determining success/failure of hack. Re-enabling terminal and changing the id of the hack progress bar");
var server = Player.getCurrentServer();
server.manuallyHacked = true;
//Calculate whether hack was successful
var hackChance = Player.calculateHackingChance();
@ -282,23 +290,23 @@ var Terminal = {
var expGainedOnFailure = (expGainedOnSuccess / 4);
if (rand < hackChance) { //Success!
var moneyGained = Player.calculatePercentMoneyHacked();
moneyGained = Math.floor(Player.getCurrentServer().moneyAvailable * moneyGained);
moneyGained = Math.floor(server.moneyAvailable * moneyGained);
//Safety check
if (moneyGained <= 0) {moneyGained = 0;}
Player.getCurrentServer().moneyAvailable -= moneyGained;
server.moneyAvailable -= moneyGained;
Player.gainMoney(moneyGained);
Player.gainHackingExp(expGainedOnSuccess)
Player.getCurrentServer().fortify(CONSTANTS.ServerFortifyAmount);
server.fortify(CONSTANTS.ServerFortifyAmount);
post("Hack successful! Gained $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " hacking EXP");
} else { //Failure
//Player only gains 25% exp for failure? TODO Can change this later to balance
Player.gainHackingExp(expGainedOnFailure)
post("Failed to hack " + Player.getCurrentServer().hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " hacking EXP");
post("Failed to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " hacking EXP");
}
}
@ -550,6 +558,24 @@ var Terminal = {
break;
case "buy":
executeDarkwebTerminalCommand(commandArray);
break;
case "cat":
if (commandArray.length != 2) {
post("Incorrect usage of cat command. Usage: cat [message]"); return;
}
var filename = commandArray[1];
//Can only edit script files
if (filename.endsWith(".msg") == false) {
post("Error: Only .msg files are viewable with cat (filename must end with .msg)"); return;
}
var s = Player.getCurrentServer();
for (var i = 0; i < s.messages.length; ++i) {
if (s.messages[i].filename == filename) {
showMessage(s.messages[i]);
return;
}
}
post("Error: No such file " + filename);
break;
case "clear":
case "cls":
@ -877,11 +903,15 @@ var Terminal = {
var allFiles = [];
//Get all of the programs and scripts on the machine into one temporary array
for (var i = 0; i < Player.getCurrentServer().programs.length; i++) {
allFiles.push(Player.getCurrentServer().programs[i]);
var s = Player.getCurrentServer();
for (var i = 0; i < s.programs.length; i++) {
allFiles.push(s.programs[i]);
}
for (var i = 0; i < Player.getCurrentServer().scripts.length; i++) {
allFiles.push(Player.getCurrentServer().scripts[i].filename);
for (var i = 0; i < s.scripts.length; i++) {
allFiles.push(s.scripts[i].filename);
}
for (var i = 0; i < s.messages.length; i++) {
allFiles.push(s.messages[i].filename);
}
//Sort the files alphabetically then print each

@ -602,8 +602,9 @@ 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: 1000, //Check whether you qualify for any faction invitations every 5 minutes
checkFactionInvitations: 250, //Check whether you qualify for any faction invitations every 5 minutes
passiveFactionGrowth: 600,
messages: 300,
},
decrementAllCounters: function(numCycles = 1) {
@ -667,7 +668,7 @@ var Engine = {
var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)];
inviteToFaction(randFaction);
}
Engine.Counters.checkFactionInvitations = 1000;
Engine.Counters.checkFactionInvitations = 250;
}
if (Engine.Counters.passiveFactionGrowth <= 0) {
@ -675,6 +676,11 @@ var Engine = {
processPassiveFactionRepGain(adjustedCycles);
Engine.Counters.passiveFactionGrowth = 600;
}
if (Engine.Counters.messages <= 0) {
checkForMessagesToSend();
Engine.Counters.messages = 300;
}
},
/* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */

@ -28,4 +28,8 @@ function clearEventListeners(elemId) {
var newElem = elem.cloneNode(true);
elem.parentNode.replaceChild(newElem, elem);
return newElem;
}
function getRandomInt(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}