mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 11:33:47 +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 { Myrian } from "./Myrian";
|
||||
import { Myrian, findDevice } from "./Myrian";
|
||||
import { getNextISocketRequest } from "./formulas/formulas";
|
||||
|
||||
export const myrianSize = 12;
|
||||
@ -21,6 +21,7 @@ const defaultMyrian: Myrian = {
|
||||
totalVulns: 0,
|
||||
devices: [],
|
||||
glitches: { ...defaultGlitches },
|
||||
rust: {},
|
||||
};
|
||||
|
||||
export const myrian: Myrian = defaultMyrian;
|
||||
@ -134,6 +135,7 @@ export const resetMyrian = () => {
|
||||
myrian.totalVulns = 0;
|
||||
myrian.devices = [];
|
||||
myrian.glitches = { ...defaultGlitches };
|
||||
myrian.rust = {};
|
||||
|
||||
Object.assign(myrian, defaultMyrian);
|
||||
|
||||
@ -156,4 +158,24 @@ setInterval(() => {
|
||||
});
|
||||
}, 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();
|
||||
|
@ -22,6 +22,7 @@ export interface Myrian {
|
||||
totalVulns: number;
|
||||
devices: Device[];
|
||||
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);
|
||||
@ -133,3 +134,15 @@ export const getTotalGlitchMult = () =>
|
||||
Object.entries(myrian.glitches).reduce((acc, [glitch, lvl]) => {
|
||||
return acc * glitchMult(glitch as Glitch, lvl);
|
||||
}, 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> = {
|
||||
[Glitch.Segmentation]: 0, // 1,
|
||||
[Glitch.Segmentation]: 1,
|
||||
[Glitch.Roaming]: 0, // 1,
|
||||
[Glitch.Encryption]: 0, // 0.1,
|
||||
[Glitch.Magnetism]: 0.2,
|
||||
[Glitch.Rust]: 0, // 1,
|
||||
[Glitch.Rust]: 1,
|
||||
[Glitch.Friction]: 0.2,
|
||||
[Glitch.Isolation]: 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.
|
||||
|
||||
## 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
|
||||
|
||||
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
|
||||
|
||||
When Virtualization is active busses install and uninstall devices more slowly.
|
||||
|
@ -24,6 +24,7 @@ import {
|
||||
isDeviceBus,
|
||||
removeDevice,
|
||||
getTotalGlitchMult,
|
||||
rustBus,
|
||||
} from "../Myrian/Myrian";
|
||||
import {
|
||||
deviceCost,
|
||||
@ -118,6 +119,7 @@ export function NetscriptMyrian(): InternalAPI<IMyrian> {
|
||||
}
|
||||
bus.x = x;
|
||||
bus.y = y;
|
||||
if (myrian.rust[`${x}:${y}`]) rustBus(bus, myrian.glitches[Glitch.Rust]);
|
||||
return Promise.resolve(true);
|
||||
})
|
||||
.finally(() => {
|
||||
|
Loading…
Reference in New Issue
Block a user