BUGFIX: Scripts are killed too late when prestiging (#1683)

* Scripts are killed too late when prestiging
* Kill all scripts earlier
This commit is contained in:
catloversg 2024-10-08 13:20:58 +07:00 committed by GitHub
parent e644c0e91e
commit b829534067
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 16 additions and 6 deletions

@ -12,6 +12,7 @@ import { Router } from "../ui/GameRoot";
import { Page } from "../ui/Router"; import { Page } from "../ui/Router";
import { mergeMultipliers } from "../PersonObjects/Multipliers"; import { mergeMultipliers } from "../PersonObjects/Multipliers";
import { currentNodeMults } from "../BitNode/BitNodeMultipliers"; import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
import { prestigeWorkerScripts } from "../NetscriptWorker";
const soaAugmentationNames = [ const soaAugmentationNames = [
AugmentationName.BeautyOfAphrodite, AugmentationName.BeautyOfAphrodite,
@ -67,6 +68,10 @@ export function installAugmentations(force?: boolean): boolean {
dialogBoxCreate("You have not purchased any Augmentations to install!"); dialogBoxCreate("You have not purchased any Augmentations to install!");
return false; return false;
} }
// We must kill all scripts before installing augmentations.
prestigeWorkerScripts();
let augmentationList = ""; let augmentationList = "";
let nfgIndex = -1; let nfgIndex = -1;
for (let i = Player.queuedAugmentations.length - 1; i >= 0; i--) { for (let i = Player.queuedAugmentations.length - 1; i >= 0; i--) {
@ -93,7 +98,7 @@ export function installAugmentations(force?: boolean): boolean {
augmentationList += aug.name + level + "\n"; augmentationList += aug.name + level + "\n";
} }
Player.queuedAugmentations = []; Player.queuedAugmentations = [];
if (!force) { if (!force && augmentationList !== "") {
dialogBoxCreate( dialogBoxCreate(
"You slowly drift to sleep as scientists put you under in order " + "You slowly drift to sleep as scientists put you under in order " +
"to install the following Augmentations:\n" + "to install the following Augmentations:\n" +

@ -48,6 +48,9 @@ function setInitialExpForPlayer() {
// Prestige by purchasing augmentation // Prestige by purchasing augmentation
export function prestigeAugmentation(): void { export function prestigeAugmentation(): void {
// We must kill all scripts before doing anything else.
prestigeWorkerScripts();
initBitNodeMultipliers(); initBitNodeMultipliers();
// Maintain invites to factions with the 'keepOnInstall' flag, and rumors about others // Maintain invites to factions with the 'keepOnInstall' flag, and rumors about others
@ -64,9 +67,6 @@ export function prestigeAugmentation(): void {
Player.prestigeAugmentation(); Player.prestigeAugmentation();
Go.prestigeAugmentation(); Go.prestigeAugmentation();
// Delete all Worker Scripts objects
prestigeWorkerScripts();
const homeComp = Player.getHomeComputer(); const homeComp = Player.getHomeComputer();
// Delete all servers except home computer // Delete all servers except home computer
prestigeAllServers(); prestigeAllServers();
@ -188,13 +188,14 @@ export function prestigeAugmentation(): void {
// Prestige by destroying Bit Node and gaining a Source File // Prestige by destroying Bit Node and gaining a Source File
export function prestigeSourceFile(isFlume: boolean): void { export function prestigeSourceFile(isFlume: boolean): void {
// We must kill all scripts before doing anything else.
prestigeWorkerScripts();
initBitNodeMultipliers(); initBitNodeMultipliers();
Player.prestigeSourceFile(); Player.prestigeSourceFile();
Go.prestigeSourceFile(); Go.prestigeSourceFile();
prestigeWorkerScripts(); // Delete all Worker Scripts objects
const homeComp = Player.getHomeComputer(); const homeComp = Player.getHomeComputer();
// Stop a Terminal action if there is one. // Stop a Terminal action if there is one.

@ -9,6 +9,7 @@ import { Router } from "./ui/GameRoot";
import { Page } from "./ui/Router"; import { Page } from "./ui/Router";
import { prestigeSourceFile } from "./Prestige"; import { prestigeSourceFile } from "./Prestige";
import { getDefaultBitNodeOptions, setBitNodeOptions } from "./BitNode/BitNodeUtils"; import { getDefaultBitNodeOptions, setBitNodeOptions } from "./BitNode/BitNodeUtils";
import { prestigeWorkerScripts } from "./NetscriptWorker";
function giveSourceFile(bitNodeNumber: number): void { function giveSourceFile(bitNodeNumber: number): void {
const sourceFileKey = "SourceFile" + bitNodeNumber.toString(); const sourceFileKey = "SourceFile" + bitNodeNumber.toString();
@ -56,6 +57,9 @@ export function enterBitNode(
newBitNode: number, newBitNode: number,
bitNodeOptions: BitNodeOptions, bitNodeOptions: BitNodeOptions,
): void { ): void {
// We must kill all scripts before setting up BitNode data and performing the prestige.
prestigeWorkerScripts();
if (!isFlume) { if (!isFlume) {
giveSourceFile(destroyedBitNode); giveSourceFile(destroyedBitNode);
} else if (Player.sourceFileLvl(5) === 0 && newBitNode !== 5) { } else if (Player.sourceFileLvl(5) === 0 && newBitNode !== 5) {