BUGFIX: update weaken results to correctly reflect change when close to minSecurity (#1887)

This commit is contained in:
nanogyth 2024-12-29 21:08:55 -05:00 committed by GitHub
parent a6d6aa7410
commit 85fa15c5a5
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -394,7 +394,10 @@ export const ns: InternalAPI<NSFull> = {
throw helpers.errorMessage(ctx, `Cannot find host of WorkerScript. Hostname: ${ctx.workerScript.hostname}.`);
}
const weakenAmt = getWeakenEffect(threads, host.cpuCores);
const securityBeforeWeaken = server.hackDifficulty;
server.weaken(weakenAmt);
const securityAfterWeaken = server.hackDifficulty;
const securityReduction = securityBeforeWeaken - securityAfterWeaken;
ctx.workerScript.scriptRef.recordWeaken(server.hostname, threads);
const expGain = calculateHackingExpGain(server, Player) * threads;
helpers.log(
@ -407,7 +410,7 @@ export const ns: InternalAPI<NSFull> = {
ctx.workerScript.scriptRef.onlineExpGained += expGain;
Player.gainHackingExp(expGain);
// Account for hidden multiplier in Server.weaken()
return Promise.resolve(weakenAmt);
return Promise.resolve(securityReduction);
});
},
weakenAnalyze: