diff --git a/markdown/bitburner.hackingformulas.md b/markdown/bitburner.hackingformulas.md
index b084112e0..81e812281 100644
--- a/markdown/bitburner.hackingformulas.md
+++ b/markdown/bitburner.hackingformulas.md
@@ -126,6 +126,17 @@ Calculate hack percent for one thread. (Ex: 0.25 would steal 25% of the server's
Calculate hack time.
+
+
diff --git a/markdown/bitburner.hackingformulas.weakeneffect.md b/markdown/bitburner.hackingformulas.weakeneffect.md
new file mode 100644
index 000000000..4917ca838
--- /dev/null
+++ b/markdown/bitburner.hackingformulas.weakeneffect.md
@@ -0,0 +1,72 @@
+
+
+[Home](./index.md) > [bitburner](./bitburner.md) > [HackingFormulas](./bitburner.hackingformulas.md) > [weakenEffect](./bitburner.hackingformulas.weakeneffect.md)
+
+## HackingFormulas.weakenEffect() method
+
+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 .
+
+**Signature:**
+
+```typescript
+weakenEffect(threads: number, cores?: number): number;
+```
+
+## Parameters
+
+|
+
+Parameter
+
+
+ |
+
+Type
+
+
+ |
+
+Description
+
+
+ |
+|
+
+threads
+
+
+ |
+
+number
+
+
+ |
+
+Number of threads running weaken.
+
+
+ |
+|
+
+cores
+
+
+ |
+
+number
+
+
+ |
+
+_(Optional)_ Number of cores on the host server. Default 1.
+
+
+ |
+
+
+**Returns:**
+
+number
+
+The security decrease amount.
+
diff --git a/src/Documentation/pages.ts b/src/Documentation/pages.ts
index 69d7a8d26..09581d0c9 100644
--- a/src/Documentation/pages.ts
+++ b/src/Documentation/pages.ts
@@ -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;
diff --git a/src/Netscript/RamCostGenerator.ts b/src/Netscript/RamCostGenerator.ts
index b6a71c37f..f038eb0ca 100644
--- a/src/Netscript/RamCostGenerator.ts
+++ b/src/Netscript/RamCostGenerator.ts
@@ -692,6 +692,7 @@ export const RamCosts: RamCostTree = {
hackTime: 0,
growTime: 0,
weakenTime: 0,
+ weakenEffect: 0,
},
hacknetNodes: {
moneyGainRate: 0,
diff --git a/src/NetscriptFunctions/Formulas.ts b/src/NetscriptFunctions/Formulas.ts
index 0a10a14b1..a31573a70 100644
--- a/src/NetscriptFunctions/Formulas.ts
+++ b/src/NetscriptFunctions/Formulas.ts
@@ -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 {
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:
diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts
index 87b392a3c..3e603df97 100644
--- a/src/ScriptEditor/NetscriptDefinitions.d.ts
+++ b/src/ScriptEditor/NetscriptDefinitions.d.ts
@@ -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;
}
/**
diff --git a/test/jest/Netscript/WeakenEffect.test.ts b/test/jest/Netscript/WeakenEffect.test.ts
new file mode 100644
index 000000000..34d6de071
--- /dev/null
+++ b/test/jest/Netscript/WeakenEffect.test.ts
@@ -0,0 +1,30 @@
+import { getWeakenEffect } from "../../../src/Server/ServerHelpers";
+
+describe("getWeakenEffect (formulas.hacking.weakenEffect)", () => {
+ it("returns 0.05 per thread with single core", () => {
+ expect(getWeakenEffect(1, 1)).toBe(0.05);
+ expect(getWeakenEffect(100, 1)).toBe(5.0);
+ });
+
+ it("applies core bonus correctly", () => {
+ // Core bonus: 1 + (cores - 1) / 16
+ // 8 cores: 1 + 7/16 = 1.4375
+ expect(getWeakenEffect(1, 8)).toBeCloseTo(0.071875);
+ expect(getWeakenEffect(100, 8)).toBeCloseTo(7.1875);
+ });
+
+ it("returns 0 for 0 threads", () => {
+ expect(getWeakenEffect(0, 1)).toBe(0);
+ });
+
+ it("handles single core (no bonus)", () => {
+ // Core bonus with 1 core: 1 + 0/16 = 1.0
+ expect(getWeakenEffect(50, 1)).toBe(2.5);
+ });
+
+ it("handles max cores (8)", () => {
+ // 8 cores: 1 + 7/16 = 1.4375
+ // 10 threads * 0.05 * 1.4375 = 0.71875
+ expect(getWeakenEffect(10, 8)).toBeCloseTo(0.71875);
+ });
+});
|