chrisrabe / bitburner-automation

Automation scripts I use for my Bitburner gameplay videos.
125 stars 41 forks source link

Fix weaken threads calculation #8

Closed chrisrabe closed 2 years ago

chrisrabe commented 2 years ago

Background

Comment from colin bougie

I noticed something while going through the code that I think is an error. The number of weakenThreads should use the difference between the current security and the security threshold. Right now, it calculates the number of weaken threads necessary to go from 0 security to our threshold, which doesn't really make sense.

Fix

chrisrabe commented 2 years ago

Updated thread calculations to:

const weakenEffect = ns.weakenAnalyze(1);
const secToDecrease = Math.abs(ns.getServerSecurityLevel(node) - secThresh);
const weakenThreads = weakenEffect > 0 ? Math.round(secToDecrease / weakenEffect) : 0;
chrisrabe commented 2 years ago

Implemented in #19