moriakaice / bitburner

Collection of scripts for https://danielyxie.github.io/bitburner/
ISC License
114 stars 145 forks source link

extremely long delays even after patched mainHack.ns #14

Open skaffen-amtiskaw opened 2 years ago

skaffen-amtiskaw commented 2 years ago

Im still seeing day-long delay times on grow(), even after the merged patch. I had a single playthrough where things seemed to delay properly, but its never happened again and I am at a loss to explain why it would work once and never again. I've gone over the code but I guess I still don't understand why this var

const growDelay = Math.max(0, weakenTime - growTime - 15 * 1000)

subtracts the grow time from the weaken time? Shouldn't this simply be the weakenTime plus a few ms? Similarly, what is the point of subtracting hacktime from the hackDelay var?

Making these changes in my own mainHack.ns completely fixed the timing issues for me. I admit I only took a cursory scan of the code, so if someone has a deeper understanding of the game mechanics please do correct me.

christhegoalie commented 2 years ago

It aims to make the Grow/Hack calls end just before weaken (by sleeping the difference between the timings before any grow operation starts)

EX: Weaken = 2 minutes Grow = 1 minute (weakentime-grow= 45 seconds)

so when it runs cycles, it runs weaken, then the grow starts 45 seconds later (so it ends 15 seconds before weaken does)

One thing to check: the initHacking.ns script will re-download and overwrite mainHack.ns if you run it.