Compare commits
No commits in common. "000e69a418695acb7a4fafae0eaa9e3df19debb0" and "070a48f298a63c5dc47cb6a89bb315697fb703ea" have entirely different histories.
000e69a418
...
070a48f298
@ -1,15 +0,0 @@
|
|||||||
import {NS} from "NetscriptDefinitions";
|
|
||||||
export async function main(ns: NS) {
|
|
||||||
const server: string = <string>ns.args[0];
|
|
||||||
const moneyThresh: number = <number>ns.args[1];
|
|
||||||
const securityThresh: number = <number>ns.args[2];
|
|
||||||
while (true) {
|
|
||||||
if (ns.getServerSecurityLevel(server) > securityThresh) {
|
|
||||||
await ns.weaken(server);
|
|
||||||
} else if (ns.getServerMoneyAvailable(server) < moneyThresh) {
|
|
||||||
await ns.grow(server);
|
|
||||||
} else {
|
|
||||||
await ns.hack(server);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,15 +0,0 @@
|
|||||||
import {NS} from "NetscriptDefinitions";
|
|
||||||
import {recursiveScan} from "./utils";
|
|
||||||
import {executeScriptOnServerFromAnother} from "./utils";
|
|
||||||
|
|
||||||
export async function main(ns: NS) {
|
|
||||||
let servers: string[] = recursiveScan(ns);
|
|
||||||
|
|
||||||
for (const server of servers) {
|
|
||||||
let moneyThresh = ns.getServerMaxMoney(server) * 0.75;
|
|
||||||
let securityThresh = ns.getServerMinSecurityLevel(server) + 5;
|
|
||||||
let numThreads = ns.getServerMaxRam(server) / ns.getScriptRam("hack.js")
|
|
||||||
numThreads = Math.floor(numThreads);
|
|
||||||
executeScriptOnServerFromAnother(ns, server, "hack.js", numThreads, [server, moneyThresh, securityThresh])
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
import {NS} from "NetscriptDefinitions";
|
|
||||||
import {recursiveScan} from "./utils";
|
|
||||||
|
|
||||||
export async function main(ns: NS) {
|
|
||||||
let servers: string[] = recursiveScan(ns)
|
|
||||||
for (const server of servers) {
|
|
||||||
ns.killall(server)
|
|
||||||
}
|
|
||||||
}
|
|
15
servers/home/no-ports/hack.js
Normal file
15
servers/home/no-ports/hack.js
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
/** @param {NS} ns */
|
||||||
|
export async function main(ns) {
|
||||||
|
var target = ns.args[0]
|
||||||
|
var moneyThresh = ns.args[1]
|
||||||
|
var securityThresh = ns.args[2]
|
||||||
|
while (true) {
|
||||||
|
if (ns.getServerSecurityLevel(target) > securityThresh) {
|
||||||
|
await ns.weaken(target);
|
||||||
|
} else if (ns.getServerMoneyAvailable(target) < moneyThresh) {
|
||||||
|
await ns.grow(target);
|
||||||
|
} else {
|
||||||
|
await ns.hack(target);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -2,5 +2,5 @@ import {NS} from "NetscriptDefinitions";
|
|||||||
import {executeScriptOnServerFromAnother} from "./utils";
|
import {executeScriptOnServerFromAnother} from "./utils";
|
||||||
|
|
||||||
export async function main(ns: NS) {
|
export async function main(ns: NS) {
|
||||||
executeScriptOnServerFromAnother(ns, "home", "servers/home/ramcost.ts", 1, [])
|
executeScriptOnServerFromAnother(ns, "servers/home/ramcost.ts", [], "home")
|
||||||
}
|
}
|
@ -118,14 +118,13 @@ export function performFunctionIfCapable(ns: NS, server: string, func: CallableF
|
|||||||
/**
|
/**
|
||||||
* Executes a script on a server from another server
|
* Executes a script on a server from another server
|
||||||
* @param ns Global NS object
|
* @param ns Global NS object
|
||||||
* @param server The server to execute the script on
|
|
||||||
* @param script The file path of the script to execute
|
* @param script The file path of the script to execute
|
||||||
* @param threads The number of threads to use
|
|
||||||
* @param args The arguments to pass to the script
|
* @param args The arguments to pass to the script
|
||||||
|
* @param server The server to execute the script on
|
||||||
*/
|
*/
|
||||||
export function executeScriptOnServerFromAnother(ns: NS, server: string, script: string, threads: number = 1, args: any[]) {
|
export function executeScriptOnServerFromAnother(ns: NS, script: string, args: any[], server: string) {
|
||||||
ns.scp(script, server);
|
ns.scp(script, server);
|
||||||
performFunctionIfCapable(ns, server, ns.exec, [script, server, threads, ...args])
|
performFunctionIfCapable(ns, server, ns.exec, [script, server, ...args])
|
||||||
ns.atExit(
|
ns.atExit(
|
||||||
() => {
|
() => {
|
||||||
ns.rm(script, server);
|
ns.rm(script, server);
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
import {NS} from "NetscriptDefinitions";
|
|
||||||
export async function main(ns: NS) {
|
|
||||||
let hackingLevel = ns.getHackingLevel();
|
|
||||||
while (hackingLevel < 9999) {
|
|
||||||
ns.run("hackallservers.js");
|
|
||||||
let seconds = 60 * 1000; // 1 minute
|
|
||||||
await ns.sleep(seconds)
|
|
||||||
|
|
||||||
let oldHackingLevel = hackingLevel;
|
|
||||||
hackingLevel = ns.getHackingLevel();
|
|
||||||
if(oldHackingLevel !== hackingLevel) {
|
|
||||||
ns.tprint(`Hacking level increased from ${oldHackingLevel} to ${hackingLevel}`);
|
|
||||||
ns.run("killall.js");
|
|
||||||
await ns.sleep(1000) // 1 second
|
|
||||||
ns.run("hackallservers.js");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user