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
This commit is contained in:
zeddrak 2022-01-07 23:12:44 -08:00 committed by GitHub
parent d2193e017d
commit cb109d8a3f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -49,7 +49,7 @@ export function calculatePercentMoneyHacked(server: Server, player: IPlayer): nu
const difficultyMult = (100 - server.hackDifficulty) / 100; const difficultyMult = (100 - server.hackDifficulty) / 100;
const skillMult = (player.hacking - (server.requiredHackingSkill - 1)) / player.hacking; 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) { if (percentMoneyHacked < 0) {
return 0; return 0;
} }
@ -57,7 +57,7 @@ export function calculatePercentMoneyHacked(server: Server, player: IPlayer): nu
return 1; return 1;
} }
return percentMoneyHacked * BitNodeMultipliers.ScriptHackMoney; return percentMoneyHacked;
} }
/** /**