CrimeMonitor!
This commit is contained in:
86
Mizzajl/home/CrimeMonitor.js
Normal file
86
Mizzajl/home/CrimeMonitor.js
Normal file
@@ -0,0 +1,86 @@
|
||||
import { GetCrimeStat } from "./Library";
|
||||
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
ns.tail();
|
||||
ns.resizeTail(1876, 412);
|
||||
ns.disableLog("sleep");
|
||||
|
||||
let aCrimes = [
|
||||
"Shoplift",
|
||||
"Rob Store",
|
||||
"Mug",
|
||||
"Larceny",
|
||||
"Deal Drugs",
|
||||
"Bond Forgery",
|
||||
"Traffick Arms",
|
||||
"Homicide",
|
||||
"Grand Theft Auto",
|
||||
"Kidnap",
|
||||
"Assassination",
|
||||
"Heist"
|
||||
];
|
||||
|
||||
while (true) {
|
||||
// Clear the ns.tail() window for a fresh update
|
||||
ns.clearLog();
|
||||
|
||||
// Header with ASCII box
|
||||
ns.printRaw("╔══════════════════╦════════════╦═════════╦════════════════════╦════════════════════╦════════════════════╦════════════════════╦════════════════════╦════════════════════╦════════════╦════════════╗");
|
||||
ns.printRaw("║ Crime ║ Chance ║ $/%/s ║ Hack w/xp ║ Str w/xp ║ Def w/xp ║ Dex w/xp ║ Agi w/xp ║ Cha w/xp ║ Money/s ║ Karma/s ║");
|
||||
ns.printRaw("╠══════════════════╬════════════╬═════════╬════════════════════╬════════════════════╬════════════════════╬════════════════════╬════════════════════╬════════════════════╬════════════╬════════════╣");
|
||||
|
||||
// Loop through each crime and display stats
|
||||
for (let i = 0; i < aCrimes.length; i++) {
|
||||
let crime = aCrimes[i];
|
||||
let chance = ns.singularity.getCrimeChance(crime); // Get chance of success
|
||||
|
||||
// Experience per second for each attribute
|
||||
let hackingExpPerSecond = await GetCrimeStat(ns, crime, "hacking_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let strengthExpPerSecond = await GetCrimeStat(ns, crime, "strength_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let defenseExpPerSecond = await GetCrimeStat(ns, crime, "defense_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let dexterityExpPerSecond = await GetCrimeStat(ns, crime, "dexterity_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let agilityExpPerSecond = await GetCrimeStat(ns, crime, "agility_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let charismaExpPerSecond = await GetCrimeStat(ns, crime, "charisma_exp") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
|
||||
// Success weights for each attribute
|
||||
let hackingSuccessWeight = await GetCrimeStat(ns, crime, "hacking_success_weight");
|
||||
let strengthSuccessWeight = await GetCrimeStat(ns, crime, "strength_success_weight");
|
||||
let defenseSuccessWeight = await GetCrimeStat(ns, crime, "defense_success_weight");
|
||||
let dexteritySuccessWeight = await GetCrimeStat(ns, crime, "dexterity_success_weight");
|
||||
let agilitySuccessWeight = await GetCrimeStat(ns, crime, "agility_success_weight");
|
||||
let charismaSuccessWeight = await GetCrimeStat(ns, crime, "charisma_success_weight");
|
||||
|
||||
// Money and Karma per second
|
||||
let moneyPerSecond = await GetCrimeStat(ns, crime, "money") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
let karmaPerSecond = await GetCrimeStat(ns, crime, "karma") / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
|
||||
// Money per chance per second
|
||||
let nMoneyPerChancePerSecond = await GetCrimeStat(ns, crime, "money") * chance / (await GetCrimeStat(ns, crime, "time") / 1000);
|
||||
|
||||
// Format output with padding and rounding for success weight / exp per second
|
||||
let crimeDisplay = crime.padEnd(17, " ");
|
||||
let chanceDisplay = (chance * 100).toFixed(2).padEnd(11, " ");
|
||||
|
||||
let nMoneyPerChancePerSecondDisplay = nMoneyPerChancePerSecond.toFixed(0).padEnd(8, " ");
|
||||
|
||||
let hackingDisplay = `${hackingSuccessWeight.toFixed(2)} / ${hackingExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let strengthDisplay = `${strengthSuccessWeight.toFixed(2)} / ${strengthExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let defenseDisplay = `${defenseSuccessWeight.toFixed(2)} / ${defenseExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let dexterityDisplay = `${dexteritySuccessWeight.toFixed(2)} / ${dexterityExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let agilityDisplay = `${agilitySuccessWeight.toFixed(2)} / ${agilityExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
let charismaDisplay = `${charismaSuccessWeight.toFixed(2)} / ${charismaExpPerSecond.toFixed(4)}`.padEnd(19, " ");
|
||||
|
||||
let moneyDisplay = moneyPerSecond.toFixed(2).padEnd(11, " ");
|
||||
let karmaDisplay = karmaPerSecond.toFixed(4).padEnd(11, " ");
|
||||
|
||||
ns.printRaw(`║ ${crimeDisplay}║ ${chanceDisplay}║ ${nMoneyPerChancePerSecondDisplay}║ ${hackingDisplay}║ ${strengthDisplay}║ ${defenseDisplay}║ ${dexterityDisplay}║ ${agilityDisplay}║ ${charismaDisplay}║ ${moneyDisplay}║ ${karmaDisplay}║`);
|
||||
}
|
||||
|
||||
// Footer with ASCII box
|
||||
ns.printRaw("╚══════════════════╩════════════╩═════════╩════════════════════╩════════════════════╩════════════════════╩════════════════════╩════════════════════╩════════════════════╩════════════╩════════════╝");
|
||||
|
||||
// Wait for 1 second before updating the display again
|
||||
await ns.sleep(1000);
|
||||
}
|
||||
}
|
||||
37
Mizzajl/home/GenerateCrimeList.js
Normal file
37
Mizzajl/home/GenerateCrimeList.js
Normal file
@@ -0,0 +1,37 @@
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
ns.tail();
|
||||
const sCrimeStatsFile = "CrimeStats.txt";
|
||||
|
||||
let aCrimes = [
|
||||
"Shoplift",
|
||||
"Rob Store",
|
||||
"Mug",
|
||||
"Larceny",
|
||||
"Deal Drugs",
|
||||
"Bond Forgery",
|
||||
"Traffick Arms",
|
||||
"Homicide",
|
||||
"Grand Theft Auto",
|
||||
"Kidnap",
|
||||
"Assassination",
|
||||
"Heist"
|
||||
];
|
||||
|
||||
let aCrimeStatsList = [];
|
||||
|
||||
for (let i = 0; i < aCrimes.length; i++) {
|
||||
let oCrimeStats = ns.singularity.getCrimeStats(aCrimes[i]);
|
||||
|
||||
// Create a new object starting with the name of the crime
|
||||
let oCrimeWithStats = {
|
||||
name: aCrimes[i], // Name of the crime as the first item
|
||||
...oCrimeStats // Spread the rest of the stats into the object
|
||||
};
|
||||
|
||||
aCrimeStatsList.push(oCrimeWithStats);
|
||||
}
|
||||
|
||||
// Write the list of crime stats to the file as a JSON string
|
||||
ns.write(sCrimeStatsFile, JSON.stringify(aCrimeStatsList, null, 2), "w");
|
||||
}
|
||||
9
Mizzajl/home/GetCrimeStat.js
Normal file
9
Mizzajl/home/GetCrimeStat.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { GetCrimeStat } from "./Library";
|
||||
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
ns.tail();
|
||||
|
||||
let nStat = GetCrimeStat(ns, ...ns.args);
|
||||
ns.print(nStat);
|
||||
}
|
||||
@@ -422,4 +422,30 @@ export async function drun(ns, ...args ){
|
||||
nFreeRAM = ns.getServerMaxRam(entry.serverName) - ns.getServerUsedRam(entry.serverName);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/** @param {NS} ns */
|
||||
export function GetCrimeStat(ns, sCrime, sStat) {
|
||||
const sCrimeStatsFile = "CrimeStats.txt";
|
||||
|
||||
// Read the crime stats file
|
||||
let aCrimeStatsList = JSON.parse(ns.read(sCrimeStatsFile));
|
||||
|
||||
// Search for the crime in the list
|
||||
let oCrimeStats = aCrimeStatsList.find(crime => crime.name === sCrime);
|
||||
|
||||
// If the crime was not found, return undefined or an error message
|
||||
if (!oCrimeStats) {
|
||||
ns.tprint(`Crime "${sCrime}" not found.`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Check if the stat exists for the given crime
|
||||
if (!(sStat in oCrimeStats)) {
|
||||
ns.tprint(`Stat "${sStat}" not found for crime "${sCrime}".`);
|
||||
return undefined;
|
||||
}
|
||||
|
||||
// Return the value of the specified stat
|
||||
return oCrimeStats[sStat];
|
||||
}
|
||||
9
Mizzajl/home/RunGang.js
Normal file
9
Mizzajl/home/RunGang.js
Normal file
@@ -0,0 +1,9 @@
|
||||
import { drun } from "./Library";
|
||||
|
||||
/** @param {NS} ns */
|
||||
export async function main(ns) {
|
||||
if (ns.gang.inGang()){
|
||||
const sGangScript = "gang/auto-gang2.js";
|
||||
await drun(ns, sGangScript);
|
||||
}
|
||||
}
|
||||
@@ -5,7 +5,7 @@ export async function main(ns) {
|
||||
ns.tail();
|
||||
|
||||
const sServerListScript = "Serverlist.js";
|
||||
const sGangScript = "gang/auto-gang2.js";
|
||||
const sGangScript = "RunGang.js";
|
||||
const sPServScript = "purchaseServers.js";
|
||||
const sBatchController = "EveryServerRun.js";
|
||||
const sBackdoorScript = "backdoor.js";
|
||||
@@ -24,8 +24,10 @@ export async function main(ns) {
|
||||
await DistributeRunAndWait(ns, sBackdoorScript);
|
||||
await DistributeRunAndWait(ns, sUpdateTarget);
|
||||
|
||||
/*
|
||||
let oServerlist = JSON.parse(ns.read(sServerListFile));
|
||||
let nHomeMaxRAM = oServerlist.find((entry) => entry.serverName === "home").maxRam;
|
||||
ns.print("nHomeMaxRAM = " + nHomeMaxRAM);
|
||||
if (nHomeMaxRAM >= 256) { if (!ns.isRunning(sMonitorScript)) { ns.run(sMonitorScript); } }
|
||||
*/
|
||||
}
|
||||
@@ -88,7 +88,7 @@ export async function main(ns) {
|
||||
|
||||
let nPID1 = ns.run(sDistScript, 1, sHackScript, nHackThreads, sTarget, false, nHackDelay - 100);
|
||||
let nPID2 = ns.run(sDistScript, 1, sGrowScript, nGrowThreads, sTarget, false, nGrowDelay - 50);
|
||||
let nPID3 = ns.run(sDistScript, 1, sWeakenScript, nWeakenThreads, sTarget, false, 0);
|
||||
let nPID3 = ns.run(sDistScript, 1, sWeakenScript, nWeakenThreads + 1, sTarget, false, 0);
|
||||
if (nPID1 === 0 || nPID2 === 0 || nPID3 === 0) { bLoop = false; }
|
||||
|
||||
ns.print("Cash: " + (Math.floor(nCurrentMoney * 1000) / 1000) + " / " + nMaxMoney);
|
||||
|
||||
Reference in New Issue
Block a user