Smarter icarus.msg, new truthgazer.msg, fix long-standing message bug

Sorry for putting this all in one commit; it all happened at the same time
as a direct conscequence of trying to get icarus.msg to be smarter.
There's a compilation error on MessageHelpers.ts:24, but the game
seems to run fine so I'm committing and coming back to it later.
This commit is contained in:
Undeemiss 2022-04-13 01:53:22 -05:00
parent f47f2239bd
commit dfadfcea09
5 changed files with 135 additions and 151 deletions

@ -10,7 +10,7 @@ import Button from "@mui/material/Button";
import { Money } from "../../ui/React/Money"; import { Money } from "../../ui/React/Money";
import { IPlayer } from "../../PersonObjects/IPlayer"; import { IPlayer } from "../../PersonObjects/IPlayer";
import { IRouter } from "../../ui/Router"; import { IRouter } from "../../ui/Router";
import { checkForMessagesToSend } from "../../Message/MessageHelpers" import { checkForMessagesToSend } from "../../Message/MessageHelpers";
interface IProps { interface IProps {
player: IPlayer; player: IPlayer;

@ -5,23 +5,23 @@ import { Programs } from "../Programs/Programs";
import { Player } from "../Player"; import { Player } from "../Player";
import { Page } from "../ui/Router"; import { Page } from "../ui/Router";
import { GetServer } from "../Server/AllServers"; import { GetServer } from "../Server/AllServers";
import { SpecialServers } from "../Server/data/SpecialServers";
import { Settings } from "../Settings/Settings"; import { Settings } from "../Settings/Settings";
import { dialogBoxCreate } from "../ui/React/DialogBox"; import { dialogBoxCreate } from "../ui/React/DialogBox";
import { Reviver } from "../utils/JSONReviver";
import { FactionNames } from "../Faction/data/FactionNames"; import { FactionNames } from "../Faction/data/FactionNames";
import { Server } from "../Server/Server";
//Sends message to player, including a pop up //Sends message to player, including a pop up
function sendMessage(msg: Message, forced = false): void { function sendMessage(msg: Message, forced = false): void {
msg.recvd = true;
if (forced || !Settings.SuppressMessages) { if (forced || !Settings.SuppressMessages) {
showMessage(msg.filename); showMessage(msg.filename);
} }
addMessageToServer(msg, "home"); addMessageToServer(msg);
} }
function showMessage(name: string): void { function showMessage(name: string): void {
const msg = Messages[name]; const msg = Messages[name];
if (!msg) throw new Error("trying to display unexistent message"); if (!(msg instanceof Message)) throw new Error("trying to display unexistent message");
const txt = const txt =
"Message received from unknown sender: <br><br>" + "Message received from unknown sender: <br><br>" +
"<i>" + "<i>" +
@ -34,21 +34,27 @@ function showMessage(name: string): void {
} }
//Adds a message to a server //Adds a message to a server
function addMessageToServer(msg: Message, serverHostname: string): void { function addMessageToServer(msg: Message): void {
const server = GetServer(serverHostname); //Short-circuit if the message has already been saved
if (server == null) { if (recvd(msg)) {
console.warn(`Could not find server ${serverHostname}`);
return; return;
} }
for (let i = 0; i < server.messages.length; ++i) { const server = GetServer("home");
const other = server.messages[i]; if (server == null) {
if (msg.filename === other) { throw new Error("The home server doesn't exist. You done goofed.");
return; //Already exists
}
} }
server.messages.push(msg.filename); server.messages.push(msg.filename);
} }
//Returns whether the given message has already been received
function recvd(msg: Message): boolean {
const server = GetServer("home");
if (server == null) {
throw new Error("The home server doesn't exist. You done goofed.");
}
return server.messages.includes(msg.filename);
}
//Checks if any of the 'timed' messages should be sent //Checks if any of the 'timed' messages should be sent
function checkForMessagesToSend(): void { function checkForMessagesToSend(): void {
if (Router.page() === Page.BitVerse) return; if (Router.page() === Page.BitVerse) return;
@ -60,45 +66,47 @@ function checkForMessagesToSend(): void {
const cybersecTest = Messages[MessageFilenames.CyberSecTest]; const cybersecTest = Messages[MessageFilenames.CyberSecTest];
const nitesecTest = Messages[MessageFilenames.NiteSecTest]; const nitesecTest = Messages[MessageFilenames.NiteSecTest];
const bitrunnersTest = Messages[MessageFilenames.BitRunnersTest]; const bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
const truthGazer = Messages[MessageFilenames.TruthGazer];
const redpill = Messages[MessageFilenames.RedPill]; const redpill = Messages[MessageFilenames.RedPill];
if (Player.hasAugmentation(AugmentationNames.TheRedPill)) { if (Player.hasAugmentation(AugmentationNames.TheRedPill)) {
//Force the message if the player has never destroyed a BitNode //Get the world daemon required hacking level
sendMessage(redpill, Player.sourceFiles.length === 0); const worldDaemon = GetServer(SpecialServers.WorldDaemon);
} else if (!jumper0.recvd && Player.hacking >= 25) { if (!(worldDaemon instanceof Server)) {
throw new Error("The world daemon is not a server???? Please un-break reality");
}
//If the daemon can be hacked, send the player icarus.msg
if (Player.hacking >= worldDaemon.requiredHackingSkill) {
sendMessage(redpill, Player.sourceFiles.length === 0);
}
//If the daemon cannot be hacked, send the player truthgazer.msg a single time.
else if (!recvd(truthGazer)) {
sendMessage(truthGazer);
}
} else if (!recvd(jumper0) && Player.hacking >= 25) {
sendMessage(jumper0); sendMessage(jumper0);
const flightName = Programs.Flight.name; const flightName = Programs.Flight.name;
const homeComp = Player.getHomeComputer(); const homeComp = Player.getHomeComputer();
if (!homeComp.programs.includes(flightName)) { if (!homeComp.programs.includes(flightName)) {
homeComp.programs.push(flightName); homeComp.programs.push(flightName);
} }
} else if (!jumper1.recvd && Player.hacking >= 40) { } else if (!recvd(jumper1) && Player.hacking >= 40) {
sendMessage(jumper1); sendMessage(jumper1);
} else if (!cybersecTest.recvd && Player.hacking >= 50) { } else if (!recvd(cybersecTest) && Player.hacking >= 50) {
sendMessage(cybersecTest); sendMessage(cybersecTest);
} else if (!jumper2.recvd && Player.hacking >= 175) { } else if (!recvd(jumper2) && Player.hacking >= 175) {
sendMessage(jumper2); sendMessage(jumper2);
} else if (!nitesecTest.recvd && Player.hacking >= 200) { } else if (!recvd(nitesecTest) && Player.hacking >= 200) {
sendMessage(nitesecTest); sendMessage(nitesecTest);
} else if (!jumper3.recvd && Player.hacking >= 350) { } else if (!recvd(jumper3) && Player.hacking >= 350) {
sendMessage(jumper3); sendMessage(jumper3);
} else if (!jumper4.recvd && Player.hacking >= 490) { } else if (!recvd(jumper4) && Player.hacking >= 490) {
sendMessage(jumper4); sendMessage(jumper4);
} else if (!bitrunnersTest.recvd && Player.hacking >= 500) { } else if (!recvd(bitrunnersTest) && Player.hacking >= 500) {
sendMessage(bitrunnersTest); sendMessage(bitrunnersTest);
} }
} }
function AddToAllMessages(msg: Message): void {
Messages[msg.filename] = msg;
}
let Messages: { [key: string]: Message } = {};
function loadMessages(saveString: string): void {
Messages = JSON.parse(saveString, Reviver);
}
enum MessageFilenames { enum MessageFilenames {
Jumper0 = "j0.msg", Jumper0 = "j0.msg",
Jumper1 = "j1.msg", Jumper1 = "j1.msg",
@ -108,105 +116,103 @@ enum MessageFilenames {
CyberSecTest = "csec-test.msg", CyberSecTest = "csec-test.msg",
NiteSecTest = "nitesec-test.msg", NiteSecTest = "nitesec-test.msg",
BitRunnersTest = "19dfj3l1nd.msg", BitRunnersTest = "19dfj3l1nd.msg",
TruthGazer = "truthgazer.msg",
RedPill = "icarus.msg", RedPill = "icarus.msg",
} }
function initMessages(): void { //Reset
//Reset const Messages = {
Messages = {};
//jump3R Messages //jump3R Messages
AddToAllMessages( [MessageFilenames.Jumper0]: new Message(
new Message( MessageFilenames.Jumper0,
MessageFilenames.Jumper0, "I know you can sense it. I know you're searching for it. " +
"I know you can sense it. I know you're searching for it. " + "It's why you spend night after " +
"It's why you spend night after " + "night at your computer. <br><br>It's real, I've seen it. And I can " +
"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.<br><br>" +
"help you find it. But not right now. You're not ready yet.<br><br>" + "Use this program to track your progress<br><br>" +
"Use this program to track your progress<br><br>" + "The fl1ght.exe program was added to your home computer<br><br>" +
"The fl1ght.exe program was added to your home computer<br><br>" + "-jump3R",
"-jump3R", ),
),
); [MessageFilenames.Jumper1]: new Message(
AddToAllMessages( MessageFilenames.Jumper1,
new Message( `Soon you will be contacted by a hacking group known as ${FactionNames.NiteSec}. ` +
MessageFilenames.Jumper1, "They can help you with your search. <br><br>" +
`Soon you will be contacted by a hacking group known as ${FactionNames.NiteSec}. ` + "You should join them, garner their favor, and " +
"They can help you with your search. <br><br>" + "exploit them for their Augmentations. But do not trust them. " +
"You should join them, garner their favor, and " + "They are not what they seem. No one is.<br><br>" +
"exploit them for their Augmentations. But do not trust them. " + "-jump3R",
"They are not what they seem. No one is.<br><br>" + ),
"-jump3R",
), [MessageFilenames.Jumper2]: new Message(
); MessageFilenames.Jumper2,
AddToAllMessages( "Do not try to save the world. There is no world to save. If " +
new Message( "you want to find the truth, worry only about yourself. Ethics and " +
MessageFilenames.Jumper2, `morals will get you killed. <br><br>Watch out for a hacking group known as ${FactionNames.NiteSec}.` +
"Do not try to save the world. There is no world to save. If " + "<br><br>-jump3R",
"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 ${FactionNames.NiteSec}.` +
"<br><br>-jump3R", [MessageFilenames.Jumper3]: new Message(
), MessageFilenames.Jumper3,
); "You must learn to walk before you can run. And you must " +
AddToAllMessages( `run before you can fly. Look for ${FactionNames.TheBlackHand}. <br><br>` +
new Message( "I.I.I.I <br><br>-jump3R",
MessageFilenames.Jumper3, ),
"You must learn to walk before you can run. And you must " +
`run before you can fly. Look for ${FactionNames.TheBlackHand}. <br><br>` + [MessageFilenames.Jumper4]: new Message(
"I.I.I.I <br><br>-jump3R", 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>" +
AddToAllMessages( "-jump3R",
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",
),
);
//Messages from hacking factions //Messages from hacking factions
AddToAllMessages( [MessageFilenames.CyberSecTest]: new Message(
new Message( MessageFilenames.CyberSecTest,
MessageFilenames.CyberSecTest, "We've been watching you. Your skills are very impressive. But you're wasting " +
"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 " +
"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>" +
"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 install the backdoor on our server. <br><br>" +
"But first, you must pass our test. Find and install the backdoor on our server. <br><br>" + `-${FactionNames.CyberSec}`,
`-${FactionNames.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 install the backdoor on our server. Then, we will contact you again." +
`<br><br>-${FactionNames.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",
),
);
AddToAllMessages( [MessageFilenames.NiteSecTest]: new Message(
new Message( MessageFilenames.NiteSecTest,
MessageFilenames.RedPill, "People say that the corrupted governments and corporations rule the world. " +
"@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%<br>" + "Yes, maybe they do. But do you know who everyone really fears? People " +
")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)<br>" + "like us. Because they can't hide from us. Because they can't fight shadows " +
"@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB<br>" + "and ideas with bullets. <br><br>" +
"DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)", "Join us, and people will fear you, too. <br><br>" +
), "Find and install the backdoor on our server. Then, we will contact you again." +
); `<br><br>-${FactionNames.NiteSec}`,
} ),
export { Messages, checkForMessagesToSend, showMessage, loadMessages, initMessages }; [MessageFilenames.BitRunnersTest]: 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",
),
//Messages to guide players to the daemon
[MessageFilenames.TruthGazer]: new Message(
MessageFilenames.TruthGazer,
//"THE TRUTH CAN NO LONGER ESCAPE YOUR GAZE"
"@&*($#@&__TH3__#@A&#@*)__TRU1H__(*)&*)($#@&()E&R)W&<br>" +
"%@*$^$()@&$)$*@__CAN__()(@^#)@&@)#__N0__(#@&#)@&@&(<br>" +
"*(__LON6ER__^#)@)(()*#@)@__ESCAP3__)#(@(#@*@()@(#*$<br>" +
"()@)#$*%)$#()$#__Y0UR__(*)$#()%(&(%)*!)($__GAZ3__#(",
),
[MessageFilenames.RedPill]: new Message(
MessageFilenames.RedPill,
//"FIND THE-CAVE"
"@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%<br>" +
")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)<br>" +
"@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB<br>" +
"DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)",
),
};
export { Messages, checkForMessagesToSend, showMessage };

@ -12,7 +12,6 @@ import { Faction } from "./Faction/Faction";
import { Factions, initFactions } from "./Faction/Factions"; import { Factions, initFactions } from "./Faction/Factions";
import { joinFaction } from "./Faction/FactionHelpers"; import { joinFaction } from "./Faction/FactionHelpers";
import { updateHashManagerCapacity } from "./Hacknet/HacknetHelpers"; import { updateHashManagerCapacity } from "./Hacknet/HacknetHelpers";
import { initMessages } from "./Message/MessageHelpers";
import { prestigeWorkerScripts } from "./NetscriptWorker"; import { prestigeWorkerScripts } from "./NetscriptWorker";
import { Player } from "./Player"; import { Player } from "./Player";
import { Router } from "./ui/GameRoot"; import { Router } from "./ui/GameRoot";
@ -105,9 +104,6 @@ export function prestigeAugmentation(): void {
Player.reapplyAllSourceFiles(); Player.reapplyAllSourceFiles();
initCompanies(); initCompanies();
// Messages
initMessages();
// Apply entropy from grafting // Apply entropy from grafting
Player.applyEntropy(Player.entropy); Player.applyEntropy(Player.entropy);
@ -251,9 +247,6 @@ export function prestigeSourceFile(flume: boolean): void {
Player.reapplyAllSourceFiles(); Player.reapplyAllSourceFiles();
initCompanies(); initCompanies();
// Messages
initMessages();
if (Player.sourceFileLvl(5) > 0 || Player.bitNodeN === 5) { if (Player.sourceFileLvl(5) > 0 || Player.bitNodeN === 5) {
homeComp.programs.push(Programs.Formulas.name); homeComp.programs.push(Programs.Formulas.name);
} }

@ -3,7 +3,6 @@ import { Companies, loadCompanies } from "./Company/Companies";
import { CONSTANTS } from "./Constants"; import { CONSTANTS } from "./Constants";
import { Factions, loadFactions } from "./Faction/Factions"; import { Factions, loadFactions } from "./Faction/Factions";
import { loadAllGangs, AllGangs } from "./Gang/AllGangs"; import { loadAllGangs, AllGangs } from "./Gang/AllGangs";
import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers";
import { Player, loadPlayer } from "./Player"; import { Player, loadPlayer } from "./Player";
import { saveAllServers, loadAllServers, GetAllServers } from "./Server/AllServers"; import { saveAllServers, loadAllServers, GetAllServers } from "./Server/AllServers";
import { Settings } from "./Settings/Settings"; import { Settings } from "./Settings/Settings";
@ -67,7 +66,6 @@ class BitburnerSaveObject {
FactionsSave = ""; FactionsSave = "";
AliasesSave = ""; AliasesSave = "";
GlobalAliasesSave = ""; GlobalAliasesSave = "";
MessagesSave = "";
StockMarketSave = ""; StockMarketSave = "";
SettingsSave = ""; SettingsSave = "";
VersionSave = ""; VersionSave = "";
@ -83,7 +81,6 @@ class BitburnerSaveObject {
this.FactionsSave = JSON.stringify(Factions); this.FactionsSave = JSON.stringify(Factions);
this.AliasesSave = JSON.stringify(Aliases); this.AliasesSave = JSON.stringify(Aliases);
this.GlobalAliasesSave = JSON.stringify(GlobalAliases); this.GlobalAliasesSave = JSON.stringify(GlobalAliases);
this.MessagesSave = JSON.stringify(Messages);
this.StockMarketSave = JSON.stringify(StockMarket); this.StockMarketSave = JSON.stringify(StockMarket);
this.SettingsSave = JSON.stringify(Settings); this.SettingsSave = JSON.stringify(Settings);
this.VersionSave = JSON.stringify(CONSTANTS.VersionNumber); this.VersionSave = JSON.stringify(CONSTANTS.VersionNumber);
@ -441,17 +438,6 @@ function loadGame(saveString: string): boolean {
console.warn(`Save file did not contain a GlobalAliases property`); console.warn(`Save file did not contain a GlobalAliases property`);
loadGlobalAliases(""); loadGlobalAliases("");
} }
if (saveObj.hasOwnProperty("MessagesSave")) {
try {
loadMessages(saveObj.MessagesSave);
} catch (e) {
console.warn(`Could not load Messages from save`);
initMessages();
}
} else {
console.warn(`Save file did not contain a Messages property`);
initMessages();
}
if (saveObj.hasOwnProperty("StockMarketSave")) { if (saveObj.hasOwnProperty("StockMarketSave")) {
try { try {
loadStockMarket(saveObj.StockMarketSave); loadStockMarket(saveObj.StockMarketSave);

@ -25,7 +25,7 @@ import {
} from "./PersonObjects/formulas/reputation"; } from "./PersonObjects/formulas/reputation";
import { hasHacknetServers, processHacknetEarnings } from "./Hacknet/HacknetHelpers"; import { hasHacknetServers, processHacknetEarnings } from "./Hacknet/HacknetHelpers";
import { iTutorialStart } from "./InteractiveTutorial"; import { iTutorialStart } from "./InteractiveTutorial";
import { checkForMessagesToSend, initMessages } from "./Message/MessageHelpers"; import { checkForMessagesToSend } from "./Message/MessageHelpers";
import { loadAllRunningScripts, updateOnlineScriptTimes } from "./NetscriptWorker"; import { loadAllRunningScripts, updateOnlineScriptTimes } from "./NetscriptWorker";
import { Player } from "./Player"; import { Player } from "./Player";
import { saveObject, loadGame } from "./SaveObject"; import { saveObject, loadGame } from "./SaveObject";
@ -439,7 +439,6 @@ const Engine: {
initCompanies(); initCompanies();
initFactions(); initFactions();
initAugmentations(); initAugmentations();
initMessages();
updateSourceFileFlags(Player); updateSourceFileFlags(Player);
// Start interactive tutorial // Start interactive tutorial