mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-27 18:13:52 +01:00
Add Segmentation and Rust
This commit is contained in:
parent
e2e71501a8
commit
e9edcd2008
@ -1,5 +1,5 @@
|
|||||||
import { DeviceType, Component, Lock, Glitch } from "@nsdefs";
|
import { DeviceType, Component, Lock, Glitch } from "@nsdefs";
|
||||||
import { Myrian } from "./Myrian";
|
import { Myrian, findDevice } from "./Myrian";
|
||||||
import { getNextISocketRequest } from "./formulas/formulas";
|
import { getNextISocketRequest } from "./formulas/formulas";
|
||||||
|
|
||||||
export const myrianSize = 12;
|
export const myrianSize = 12;
|
||||||
@ -21,6 +21,7 @@ const defaultMyrian: Myrian = {
|
|||||||
totalVulns: 0,
|
totalVulns: 0,
|
||||||
devices: [],
|
devices: [],
|
||||||
glitches: { ...defaultGlitches },
|
glitches: { ...defaultGlitches },
|
||||||
|
rust: {},
|
||||||
};
|
};
|
||||||
|
|
||||||
export const myrian: Myrian = defaultMyrian;
|
export const myrian: Myrian = defaultMyrian;
|
||||||
@ -134,6 +135,7 @@ export const resetMyrian = () => {
|
|||||||
myrian.totalVulns = 0;
|
myrian.totalVulns = 0;
|
||||||
myrian.devices = [];
|
myrian.devices = [];
|
||||||
myrian.glitches = { ...defaultGlitches };
|
myrian.glitches = { ...defaultGlitches };
|
||||||
|
myrian.rust = {};
|
||||||
|
|
||||||
Object.assign(myrian, defaultMyrian);
|
Object.assign(myrian, defaultMyrian);
|
||||||
|
|
||||||
@ -156,4 +158,24 @@ setInterval(() => {
|
|||||||
});
|
});
|
||||||
}, 1000);
|
}, 1000);
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
const segmentation = myrian.glitches[Glitch.Segmentation];
|
||||||
|
for (let i = 0; i < segmentation; i++) {
|
||||||
|
const x = Math.floor(Math.random() * myrianSize);
|
||||||
|
const y = Math.floor(Math.random() * myrianSize);
|
||||||
|
if (findDevice([x, y])) continue;
|
||||||
|
NewLock(`lock-${x}-${y}`, x, y);
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
|
setInterval(() => {
|
||||||
|
myrian.rust = {};
|
||||||
|
const rust = myrian.glitches[Glitch.Rust];
|
||||||
|
for (let i = 0; i < rust * 3; i++) {
|
||||||
|
const x = Math.floor(Math.random() * myrianSize);
|
||||||
|
const y = Math.floor(Math.random() * myrianSize);
|
||||||
|
myrian.rust[`${x}:${y}`] = true;
|
||||||
|
}
|
||||||
|
}, 30000);
|
||||||
|
|
||||||
resetMyrian();
|
resetMyrian();
|
||||||
|
@ -22,6 +22,7 @@ export interface Myrian {
|
|||||||
totalVulns: number;
|
totalVulns: number;
|
||||||
devices: Device[];
|
devices: Device[];
|
||||||
glitches: Record<Glitch, number>;
|
glitches: Record<Glitch, number>;
|
||||||
|
rust: Record<string, boolean>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const distance = (a: Device, b: Device) => Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
|
export const distance = (a: Device, b: Device) => Math.abs(a.x - b.x) + Math.abs(a.y - b.y);
|
||||||
@ -133,3 +134,15 @@ export const getTotalGlitchMult = () =>
|
|||||||
Object.entries(myrian.glitches).reduce((acc, [glitch, lvl]) => {
|
Object.entries(myrian.glitches).reduce((acc, [glitch, lvl]) => {
|
||||||
return acc * glitchMult(glitch as Glitch, lvl);
|
return acc * glitchMult(glitch as Glitch, lvl);
|
||||||
}, 1);
|
}, 1);
|
||||||
|
|
||||||
|
const rustStats: (keyof Bus)[] = ["moveLvl", "transferLvl", "reduceLvl", "installLvl", "maxEnergy"];
|
||||||
|
|
||||||
|
export const rustBus = (bus: Bus, rust: number) => {
|
||||||
|
const potential = rustStats.filter((stat) => {
|
||||||
|
const value = bus[stat];
|
||||||
|
if (typeof value !== "number") return false;
|
||||||
|
return value > 0;
|
||||||
|
});
|
||||||
|
const chosen = potential[Math.floor(Math.random() * potential.length)];
|
||||||
|
(bus[chosen] as any) = Math.max(0, (bus[chosen] as any) - rust * 0.1) as any;
|
||||||
|
};
|
||||||
|
@ -13,11 +13,11 @@ export const glitchMaxLvl: Record<Glitch, number> = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const giltchMultCoefficients: Record<Glitch, number> = {
|
export const giltchMultCoefficients: Record<Glitch, number> = {
|
||||||
[Glitch.Segmentation]: 0, // 1,
|
[Glitch.Segmentation]: 1,
|
||||||
[Glitch.Roaming]: 0, // 1,
|
[Glitch.Roaming]: 0, // 1,
|
||||||
[Glitch.Encryption]: 0, // 0.1,
|
[Glitch.Encryption]: 0, // 0.1,
|
||||||
[Glitch.Magnetism]: 0.2,
|
[Glitch.Magnetism]: 0.2,
|
||||||
[Glitch.Rust]: 0, // 1,
|
[Glitch.Rust]: 1,
|
||||||
[Glitch.Friction]: 0.2,
|
[Glitch.Friction]: 0.2,
|
||||||
[Glitch.Isolation]: 0.2,
|
[Glitch.Isolation]: 0.2,
|
||||||
[Glitch.Virtualization]: 0.2,
|
[Glitch.Virtualization]: 0.2,
|
||||||
|
@ -72,10 +72,18 @@ By default bus lose 0 energy when moving. But when this glitch is active they st
|
|||||||
|
|
||||||
When Friction is active busses move more slowly.
|
When Friction is active busses move more slowly.
|
||||||
|
|
||||||
|
## Rust
|
||||||
|
|
||||||
|
When rust is active, hidden tiles are set on the Myrian. When a bus steps on one of these hidden tiles one of their upgrade lowers. Higher Rust level means lowers by a larger amount and more rust tiles are set.
|
||||||
|
|
||||||
### Isolation
|
### Isolation
|
||||||
|
|
||||||
When Isolation is active busses transfer and charge more slowly.
|
When Isolation is active busses transfer and charge more slowly.
|
||||||
|
|
||||||
|
## Segmentation
|
||||||
|
|
||||||
|
When Segmentation is active random Locks will spawn on the Myrian. You have to remove these locks or the bord will be overrun with Locks and you won't be able to move.
|
||||||
|
|
||||||
### Virtualization
|
### Virtualization
|
||||||
|
|
||||||
When Virtualization is active busses install and uninstall devices more slowly.
|
When Virtualization is active busses install and uninstall devices more slowly.
|
||||||
|
@ -24,6 +24,7 @@ import {
|
|||||||
isDeviceBus,
|
isDeviceBus,
|
||||||
removeDevice,
|
removeDevice,
|
||||||
getTotalGlitchMult,
|
getTotalGlitchMult,
|
||||||
|
rustBus,
|
||||||
} from "../Myrian/Myrian";
|
} from "../Myrian/Myrian";
|
||||||
import {
|
import {
|
||||||
deviceCost,
|
deviceCost,
|
||||||
@ -118,6 +119,7 @@ export function NetscriptMyrian(): InternalAPI<IMyrian> {
|
|||||||
}
|
}
|
||||||
bus.x = x;
|
bus.x = x;
|
||||||
bus.y = y;
|
bus.y = y;
|
||||||
|
if (myrian.rust[`${x}:${y}`]) rustBus(bus, myrian.glitches[Glitch.Rust]);
|
||||||
return Promise.resolve(true);
|
return Promise.resolve(true);
|
||||||
})
|
})
|
||||||
.finally(() => {
|
.finally(() => {
|
||||||
|
Loading…
Reference in New Issue
Block a user