41 lines
1.4 KiB
JavaScript
41 lines
1.4 KiB
JavaScript
/** @param {NS} ns */
|
|
export async function main(ns) {
|
|
ns.tail();
|
|
const sTarget = ns.args[0]; // run on this target instead of best
|
|
const nHackThreads = ns.args[1] ? ns.args[1] : 1;
|
|
|
|
ns.disableLog("sleep");
|
|
|
|
ns.print("nHackThreads = " + nHackThreads);
|
|
|
|
//ns.tprint(ns.getHackingMultipliers());
|
|
|
|
let nHackAmountPercent = ns.hackAnalyze(sTarget) * nHackThreads;
|
|
let nTargetMoney = ns.getServerMoneyAvailable(sTarget);
|
|
let nHackAmount = nTargetMoney * nHackAmountPercent;
|
|
ns.print("nHackAmountPercent = " + nHackAmountPercent);
|
|
ns.print("nTargetMoney = " + nTargetMoney);
|
|
ns.print("nHackAmount = " + nHackAmount);
|
|
|
|
let nGrowthThreads = ns.growthAnalyze(sTarget, 1 + nHackAmountPercent, 1);
|
|
ns.print("nGrowthThreads = " + nGrowthThreads);
|
|
let nGrowThreadsINT = Math.ceil(nGrowthThreads);
|
|
ns.print("Hack() : Grow() Ratio = " + nHackThreads + ":" + nGrowThreadsINT);
|
|
|
|
|
|
|
|
//test hack() and grow()
|
|
/*
|
|
let nHackPID = ns.exec("RMhack.js", "home", nHackThreads, sTarget);
|
|
ns.tail(nHackPID);
|
|
let nGrowPID = ns.exec("RMgrow.js", "home", nGrowThreadsINT, sTarget);
|
|
ns.tail(nGrowPID);
|
|
ns.print("Wait for Hack and Grow...");
|
|
while (ns.isRunning(nHackPID) || ns.isRunning(nGrowPID)) {
|
|
await ns.sleep(1000);
|
|
}
|
|
ns.print("Wait complete");
|
|
nTargetMoney = ns.getServerMoneyAvailable(sTarget);
|
|
ns.print("nTargetMoney = " + nTargetMoney);
|
|
*/
|
|
} |