From cb109d8a3ff3cf2bd8c4c38e04dab9f06bf5c680 Mon Sep 17 00:00:00 2001 From: zeddrak <57454318+zeddrak@users.noreply.github.com> Date: Fri, 7 Jan 2022 23:12:44 -0800 Subject: [PATCH] Apply bitnode multiplier before capping at 1 It is entirely possible to hack more than the BN multiplier, which means this function is reporting the effects of the multiplier incorrectly. By moving the BN multiplier before to before the caps are applied, the functionality is corrected. (ie, hack % * BN multiplier, THEN cap to 1; not cap to 1, then BM multiply the 1) TESTED: I'm currently running in BN 5 ( * BitNodeMultipliers.ScriptHackMoney = 0.15), and sent a 4b thread hack against several fully grown servers (Avail Money = 100% of Max Money). Each went down to 0% (not 85% as the current implementation would suggest) after the hack hit --- src/Hacking.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Hacking.ts b/src/Hacking.ts index adb6ef44e..fa6855341 100644 --- a/src/Hacking.ts +++ b/src/Hacking.ts @@ -49,7 +49,7 @@ export function calculatePercentMoneyHacked(server: Server, player: IPlayer): nu const difficultyMult = (100 - server.hackDifficulty) / 100; const skillMult = (player.hacking - (server.requiredHackingSkill - 1)) / player.hacking; - const percentMoneyHacked = (difficultyMult * skillMult * player.hacking_money_mult) / balanceFactor; + const percentMoneyHacked = (difficultyMult * skillMult * player.hacking_money_mult * BitNodeMultipliers.ScriptHackMoney) / balanceFactor; if (percentMoneyHacked < 0) { return 0; } @@ -57,7 +57,7 @@ export function calculatePercentMoneyHacked(server: Server, player: IPlayer): nu return 1; } - return percentMoneyHacked * BitNodeMultipliers.ScriptHackMoney; + return percentMoneyHacked; } /**