chrisrabe / bitburner-automation

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

auto-starter.js doesn't get to run hack command #36

Open rfsjim opened 1 year ago

rfsjim commented 1 year ago

I stumbled across the YouTube series and BitBurner late, and I am running BitBurner v2.3.1 I have tested this script (commit 874e690)

Running the auto-starter.js script using run auto-starter.js the targets get selected, the virus script gets distributed as expected, the grow and weaken commands get run and the servers get purchased.

However, I have not seen any hack commands run and no online production rate is reported. The targets change too quickly for hack to be called.

If I use run auto-deploy.js n00dles instead hack is called quickly and online production is increased

The workaround I have implemented to change this was to take on board a tip from the Getting Started Guide for Beginner Programmers — Bitburner 2.2.2 documentation that said - "As a rule of thumb, your hacking target should be the server with highest max money that’s required hacking level is under 1/2 of your hacking level."

Based on that tip I suggest changing the utils.js function canHack() to /** @param {NS} ns **/ export function canHack(ns, server) { var pHackLvl = ns.getHackingLevel(); // player var sHackLvl = ns.getServerRequiredHackingLevel(server); return pHackLvl >= 2*sHackLvl; }

This should only select servers that have half the required hacking level.