From dfadfcea0932ace33cd82af654836d3cf088133d Mon Sep 17 00:00:00 2001 From: Undeemiss Date: Wed, 13 Apr 2022 01:53:22 -0500 Subject: [PATCH] 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. --- src/DevMenu/ui/General.tsx | 2 +- src/Message/MessageHelpers.ts | 260 +++++++++++++++++----------------- src/Prestige.ts | 7 - src/SaveObject.tsx | 14 -- src/engine.tsx | 3 +- 5 files changed, 135 insertions(+), 151 deletions(-) diff --git a/src/DevMenu/ui/General.tsx b/src/DevMenu/ui/General.tsx index 39ae31742..ba01ee10a 100644 --- a/src/DevMenu/ui/General.tsx +++ b/src/DevMenu/ui/General.tsx @@ -10,7 +10,7 @@ import Button from "@mui/material/Button"; import { Money } from "../../ui/React/Money"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { IRouter } from "../../ui/Router"; -import { checkForMessagesToSend } from "../../Message/MessageHelpers" +import { checkForMessagesToSend } from "../../Message/MessageHelpers"; interface IProps { player: IPlayer; diff --git a/src/Message/MessageHelpers.ts b/src/Message/MessageHelpers.ts index 3134e63d4..ee1058756 100644 --- a/src/Message/MessageHelpers.ts +++ b/src/Message/MessageHelpers.ts @@ -5,23 +5,23 @@ import { Programs } from "../Programs/Programs"; import { Player } from "../Player"; import { Page } from "../ui/Router"; import { GetServer } from "../Server/AllServers"; +import { SpecialServers } from "../Server/data/SpecialServers"; import { Settings } from "../Settings/Settings"; import { dialogBoxCreate } from "../ui/React/DialogBox"; -import { Reviver } from "../utils/JSONReviver"; import { FactionNames } from "../Faction/data/FactionNames"; +import { Server } from "../Server/Server"; //Sends message to player, including a pop up function sendMessage(msg: Message, forced = false): void { - msg.recvd = true; if (forced || !Settings.SuppressMessages) { showMessage(msg.filename); } - addMessageToServer(msg, "home"); + addMessageToServer(msg); } function showMessage(name: string): void { 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 = "Message received from unknown sender:

" + "" + @@ -34,21 +34,27 @@ function showMessage(name: string): void { } //Adds a message to a server -function addMessageToServer(msg: Message, serverHostname: string): void { - const server = GetServer(serverHostname); - if (server == null) { - console.warn(`Could not find server ${serverHostname}`); +function addMessageToServer(msg: Message): void { + //Short-circuit if the message has already been saved + if (recvd(msg)) { return; } - for (let i = 0; i < server.messages.length; ++i) { - const other = server.messages[i]; - if (msg.filename === other) { - return; //Already exists - } + const server = GetServer("home"); + if (server == null) { + throw new Error("The home server doesn't exist. You done goofed."); } 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 function checkForMessagesToSend(): void { if (Router.page() === Page.BitVerse) return; @@ -60,45 +66,47 @@ function checkForMessagesToSend(): void { const cybersecTest = Messages[MessageFilenames.CyberSecTest]; const nitesecTest = Messages[MessageFilenames.NiteSecTest]; const bitrunnersTest = Messages[MessageFilenames.BitRunnersTest]; + const truthGazer = Messages[MessageFilenames.TruthGazer]; const redpill = Messages[MessageFilenames.RedPill]; if (Player.hasAugmentation(AugmentationNames.TheRedPill)) { - //Force the message if the player has never destroyed a BitNode - sendMessage(redpill, Player.sourceFiles.length === 0); - } else if (!jumper0.recvd && Player.hacking >= 25) { + //Get the world daemon required hacking level + const worldDaemon = GetServer(SpecialServers.WorldDaemon); + 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); const flightName = Programs.Flight.name; const homeComp = Player.getHomeComputer(); if (!homeComp.programs.includes(flightName)) { homeComp.programs.push(flightName); } - } else if (!jumper1.recvd && Player.hacking >= 40) { + } else if (!recvd(jumper1) && Player.hacking >= 40) { sendMessage(jumper1); - } else if (!cybersecTest.recvd && Player.hacking >= 50) { + } else if (!recvd(cybersecTest) && Player.hacking >= 50) { sendMessage(cybersecTest); - } else if (!jumper2.recvd && Player.hacking >= 175) { + } else if (!recvd(jumper2) && Player.hacking >= 175) { sendMessage(jumper2); - } else if (!nitesecTest.recvd && Player.hacking >= 200) { + } else if (!recvd(nitesecTest) && Player.hacking >= 200) { sendMessage(nitesecTest); - } else if (!jumper3.recvd && Player.hacking >= 350) { + } else if (!recvd(jumper3) && Player.hacking >= 350) { sendMessage(jumper3); - } else if (!jumper4.recvd && Player.hacking >= 490) { + } else if (!recvd(jumper4) && Player.hacking >= 490) { sendMessage(jumper4); - } else if (!bitrunnersTest.recvd && Player.hacking >= 500) { + } else if (!recvd(bitrunnersTest) && Player.hacking >= 500) { 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 { Jumper0 = "j0.msg", Jumper1 = "j1.msg", @@ -108,105 +116,103 @@ enum MessageFilenames { CyberSecTest = "csec-test.msg", NiteSecTest = "nitesec-test.msg", BitRunnersTest = "19dfj3l1nd.msg", + TruthGazer = "truthgazer.msg", RedPill = "icarus.msg", } -function initMessages(): void { - //Reset - Messages = {}; - +//Reset +const 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.

It's real, I've seen it. And I can " + - "help you find it. But not right now. You're not ready yet.

" + - "Use this program to track your progress

" + - "The fl1ght.exe program was added to your home computer

" + - "-jump3R", - ), - ); - AddToAllMessages( - new Message( - MessageFilenames.Jumper1, - `Soon you will be contacted by a hacking group known as ${FactionNames.NiteSec}. ` + - "They can help you with your search.

" + - "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.

" + - "-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.

Watch out for a hacking group known as ${FactionNames.NiteSec}.` + - "

-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 ${FactionNames.TheBlackHand}.

` + - "I.I.I.I

-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.

" + - "-jump3R", - ), - ); + [MessageFilenames.Jumper0]: 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.

It's real, I've seen it. And I can " + + "help you find it. But not right now. You're not ready yet.

" + + "Use this program to track your progress

" + + "The fl1ght.exe program was added to your home computer

" + + "-jump3R", + ), + + [MessageFilenames.Jumper1]: new Message( + MessageFilenames.Jumper1, + `Soon you will be contacted by a hacking group known as ${FactionNames.NiteSec}. ` + + "They can help you with your search.

" + + "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.

" + + "-jump3R", + ), + + [MessageFilenames.Jumper2]: 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.

Watch out for a hacking group known as ${FactionNames.NiteSec}.` + + "

-jump3R", + ), + + [MessageFilenames.Jumper3]: new Message( + MessageFilenames.Jumper3, + "You must learn to walk before you can run. And you must " + + `run before you can fly. Look for ${FactionNames.TheBlackHand}.

` + + "I.I.I.I

-jump3R", + ), + + [MessageFilenames.Jumper4]: 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.

" + + "-jump3R", + ), //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.

" + - "But first, you must pass our test. Find and install the backdoor on our server.

" + - `-${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.

" + - "Join us, and people will fear you, too.

" + - "Find and install the backdoor on our server. Then, we will contact you again." + - `

-${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.

" + - "We can help you find the answers.

" + - "run4theh111z", - ), - ); + [MessageFilenames.CyberSecTest]: 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.

" + + "But first, you must pass our test. Find and install the backdoor on our server.

" + + `-${FactionNames.CyberSec}`, + ), - AddToAllMessages( - new Message( - MessageFilenames.RedPill, - "@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%
" + - ")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)
" + - "@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB
" + - "DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)", - ), - ); -} + [MessageFilenames.NiteSecTest]: 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.

" + + "Join us, and people will fear you, too.

" + + "Find and install the backdoor on our server. Then, we will contact you again." + + `

-${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.

" + + "We can help you find the answers.

" + + "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&
" + + "%@*$^$()@&$)$*@__CAN__()(@^#)@&@)#__N0__(#@&#)@&@&(
" + + "*(__LON6ER__^#)@)(()*#@)@__ESCAP3__)#(@(#@*@()@(#*$
" + + "()@)#$*%)$#()$#__Y0UR__(*)$#()%(&(%)*!)($__GAZ3__#(", + ), + + [MessageFilenames.RedPill]: new Message( + MessageFilenames.RedPill, + //"FIND THE-CAVE" + "@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*%
" + + ")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B)
" + + "@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB
" + + "DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)", + ), +}; + +export { Messages, checkForMessagesToSend, showMessage }; diff --git a/src/Prestige.ts b/src/Prestige.ts index 405fe5a73..ab3df9ccc 100755 --- a/src/Prestige.ts +++ b/src/Prestige.ts @@ -12,7 +12,6 @@ import { Faction } from "./Faction/Faction"; import { Factions, initFactions } from "./Faction/Factions"; import { joinFaction } from "./Faction/FactionHelpers"; import { updateHashManagerCapacity } from "./Hacknet/HacknetHelpers"; -import { initMessages } from "./Message/MessageHelpers"; import { prestigeWorkerScripts } from "./NetscriptWorker"; import { Player } from "./Player"; import { Router } from "./ui/GameRoot"; @@ -105,9 +104,6 @@ export function prestigeAugmentation(): void { Player.reapplyAllSourceFiles(); initCompanies(); - // Messages - initMessages(); - // Apply entropy from grafting Player.applyEntropy(Player.entropy); @@ -251,9 +247,6 @@ export function prestigeSourceFile(flume: boolean): void { Player.reapplyAllSourceFiles(); initCompanies(); - // Messages - initMessages(); - if (Player.sourceFileLvl(5) > 0 || Player.bitNodeN === 5) { homeComp.programs.push(Programs.Formulas.name); } diff --git a/src/SaveObject.tsx b/src/SaveObject.tsx index fc6a5ff06..44573385d 100755 --- a/src/SaveObject.tsx +++ b/src/SaveObject.tsx @@ -3,7 +3,6 @@ import { Companies, loadCompanies } from "./Company/Companies"; import { CONSTANTS } from "./Constants"; import { Factions, loadFactions } from "./Faction/Factions"; import { loadAllGangs, AllGangs } from "./Gang/AllGangs"; -import { loadMessages, initMessages, Messages } from "./Message/MessageHelpers"; import { Player, loadPlayer } from "./Player"; import { saveAllServers, loadAllServers, GetAllServers } from "./Server/AllServers"; import { Settings } from "./Settings/Settings"; @@ -67,7 +66,6 @@ class BitburnerSaveObject { FactionsSave = ""; AliasesSave = ""; GlobalAliasesSave = ""; - MessagesSave = ""; StockMarketSave = ""; SettingsSave = ""; VersionSave = ""; @@ -83,7 +81,6 @@ class BitburnerSaveObject { this.FactionsSave = JSON.stringify(Factions); this.AliasesSave = JSON.stringify(Aliases); this.GlobalAliasesSave = JSON.stringify(GlobalAliases); - this.MessagesSave = JSON.stringify(Messages); this.StockMarketSave = JSON.stringify(StockMarket); this.SettingsSave = JSON.stringify(Settings); 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`); 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")) { try { loadStockMarket(saveObj.StockMarketSave); diff --git a/src/engine.tsx b/src/engine.tsx index 43d459bdd..766832af8 100644 --- a/src/engine.tsx +++ b/src/engine.tsx @@ -25,7 +25,7 @@ import { } from "./PersonObjects/formulas/reputation"; import { hasHacknetServers, processHacknetEarnings } from "./Hacknet/HacknetHelpers"; import { iTutorialStart } from "./InteractiveTutorial"; -import { checkForMessagesToSend, initMessages } from "./Message/MessageHelpers"; +import { checkForMessagesToSend } from "./Message/MessageHelpers"; import { loadAllRunningScripts, updateOnlineScriptTimes } from "./NetscriptWorker"; import { Player } from "./Player"; import { saveObject, loadGame } from "./SaveObject"; @@ -439,7 +439,6 @@ const Engine: { initCompanies(); initFactions(); initAugmentations(); - initMessages(); updateSourceFileFlags(Player); // Start interactive tutorial