API: Add weakenEffect to formulas.hacking namespace (#2626)

This commit is contained in:
Lee Stutzman
2026-04-11 00:36:45 +01:00
committed by GitHub
parent 8cbd6ff9e1
commit fb3fa00b3d
7 changed files with 135 additions and 1 deletions

View File

@@ -746,6 +746,7 @@ import nsDoc_bitburner_hackingformulas_hackexp_md from "../../markdown/bitburner
import nsDoc_bitburner_hackingformulas_hackpercent_md from "../../markdown/bitburner.hackingformulas.hackpercent.md?raw";
import nsDoc_bitburner_hackingformulas_hacktime_md from "../../markdown/bitburner.hackingformulas.hacktime.md?raw";
import nsDoc_bitburner_hackingformulas_md from "../../markdown/bitburner.hackingformulas.md?raw";
import nsDoc_bitburner_hackingformulas_weakeneffect_md from "../../markdown/bitburner.hackingformulas.weakeneffect.md?raw";
import nsDoc_bitburner_hackingformulas_weakentime_md from "../../markdown/bitburner.hackingformulas.weakentime.md?raw";
import nsDoc_bitburner_hackingmultipliers_chance_md from "../../markdown/bitburner.hackingmultipliers.chance.md?raw";
import nsDoc_bitburner_hackingmultipliers_growth_md from "../../markdown/bitburner.hackingmultipliers.growth.md?raw";
@@ -2342,6 +2343,7 @@ AllPages["nsDoc/bitburner.hackingformulas.hackexp.md"] = nsDoc_bitburner_hacking
AllPages["nsDoc/bitburner.hackingformulas.hackpercent.md"] = nsDoc_bitburner_hackingformulas_hackpercent_md;
AllPages["nsDoc/bitburner.hackingformulas.hacktime.md"] = nsDoc_bitburner_hackingformulas_hacktime_md;
AllPages["nsDoc/bitburner.hackingformulas.md"] = nsDoc_bitburner_hackingformulas_md;
AllPages["nsDoc/bitburner.hackingformulas.weakeneffect.md"] = nsDoc_bitburner_hackingformulas_weakeneffect_md;
AllPages["nsDoc/bitburner.hackingformulas.weakentime.md"] = nsDoc_bitburner_hackingformulas_weakentime_md;
AllPages["nsDoc/bitburner.hackingmultipliers.chance.md"] = nsDoc_bitburner_hackingmultipliers_chance_md;
AllPages["nsDoc/bitburner.hackingmultipliers.growth.md"] = nsDoc_bitburner_hackingmultipliers_growth_md;

View File

@@ -692,6 +692,7 @@ export const RamCosts: RamCostTree<NSFull> = {
hackTime: 0,
growTime: 0,
weakenTime: 0,
weakenEffect: 0,
},
hacknetNodes: {
moneyGainRate: 0,

View File

@@ -1,6 +1,6 @@
import { Player } from "@player";
import { calculateServerGrowth, calculateGrowMoney } from "../Server/formulas/grow";
import { numCycleForGrowthCorrected } from "../Server/ServerHelpers";
import { getWeakenEffect, numCycleForGrowthCorrected } from "../Server/ServerHelpers";
import {
calculateMoneyGainRate,
calculateLevelUpgradeCost,
@@ -235,6 +235,14 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
checkFormulasAccess(ctx);
return calculateWeakenTime(server, person) * 1000;
},
weakenEffect:
(ctx) =>
(_threads, _cores = 1) => {
const threads = helpers.number(ctx, "threads", _threads);
const cores = helpers.number(ctx, "cores", _cores);
checkFormulasAccess(ctx);
return getWeakenEffect(threads, cores);
},
},
hacknetNodes: {
moneyGainRate:

View File

@@ -6299,6 +6299,16 @@ interface HackingFormulas {
* @returns The calculated weaken time, in milliseconds.
*/
weakenTime(server: Server, player: Person): number;
/**
* Calculate the security decrease from a weaken operation.
* Unlike other hacking formulas, weaken effect depends only on thread count and
* core count, not on server or player properties. The core bonus formula is
* {@code 1 + (cores - 1) / 16}.
* @param threads - Number of threads running weaken.
* @param cores - Number of cores on the host server. Default 1.
* @returns The security decrease amount.
*/
weakenEffect(threads: number, cores?: number): number;
}
/**