Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

BUGFIX: Scripts are killed too late when prestiging #1683

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/Augmentation/AugmentationHelpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { Router } from "../ui/GameRoot";
import { Page } from "../ui/Router";
import { mergeMultipliers } from "../PersonObjects/Multipliers";
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
import { prestigeWorkerScripts } from "../NetscriptWorker";

const soaAugmentationNames = [
AugmentationName.BeautyOfAphrodite,
Expand Down Expand Up @@ -67,6 +68,10 @@ export function installAugmentations(force?: boolean): boolean {
dialogBoxCreate("You have not purchased any Augmentations to install!");
return false;
}

// We must kill all scripts before installing augmentations.
prestigeWorkerScripts();

let augmentationList = "";
let nfgIndex = -1;
for (let i = Player.queuedAugmentations.length - 1; i >= 0; i--) {
Expand All @@ -93,7 +98,7 @@ export function installAugmentations(force?: boolean): boolean {
augmentationList += aug.name + level + "\n";
}
Player.queuedAugmentations = [];
if (!force) {
if (!force && augmentationList !== "") {
dialogBoxCreate(
"You slowly drift to sleep as scientists put you under in order " +
"to install the following Augmentations:\n" +
Expand Down
11 changes: 6 additions & 5 deletions src/Prestige.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ function setInitialExpForPlayer() {

// Prestige by purchasing augmentation
export function prestigeAugmentation(): void {
// We must kill all scripts before doing anything else.
prestigeWorkerScripts();

initBitNodeMultipliers();

// Maintain invites to factions with the 'keepOnInstall' flag, and rumors about others
Expand All @@ -64,9 +67,6 @@ export function prestigeAugmentation(): void {
Player.prestigeAugmentation();
Go.prestigeAugmentation();

// Delete all Worker Scripts objects
prestigeWorkerScripts();

const homeComp = Player.getHomeComputer();
// Delete all servers except home computer
prestigeAllServers();
Expand Down Expand Up @@ -188,13 +188,14 @@ export function prestigeAugmentation(): void {

// Prestige by destroying Bit Node and gaining a Source File
export function prestigeSourceFile(isFlume: boolean): void {
// We must kill all scripts before doing anything else.
prestigeWorkerScripts();

initBitNodeMultipliers();

Player.prestigeSourceFile();
Go.prestigeSourceFile();

prestigeWorkerScripts(); // Delete all Worker Scripts objects

const homeComp = Player.getHomeComputer();

// Stop a Terminal action if there is one.
Expand Down
4 changes: 4 additions & 0 deletions src/RedPill.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { Router } from "./ui/GameRoot";
import { Page } from "./ui/Router";
import { prestigeSourceFile } from "./Prestige";
import { getDefaultBitNodeOptions, setBitNodeOptions } from "./BitNode/BitNodeUtils";
import { prestigeWorkerScripts } from "./NetscriptWorker";

function giveSourceFile(bitNodeNumber: number): void {
const sourceFileKey = "SourceFile" + bitNodeNumber.toString();
Expand Down Expand Up @@ -56,6 +57,9 @@ export function enterBitNode(
newBitNode: number,
bitNodeOptions: BitNodeOptions,
): void {
// We must kill all scripts before setting up BitNode data and performing the prestige.
prestigeWorkerScripts();

if (!isFlume) {
giveSourceFile(destroyedBitNode);
} else if (Player.sourceFileLvl(5) === 0 && newBitNode !== 5) {
Expand Down