forked from alainbryden/bitburner-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfarm-intelligence.js
64 lines (60 loc) · 2.61 KB
/
farm-intelligence.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
import { formatMoney, formatDuration, formatNumberShort, disableLogs } from './helpers.js'
const argsSchema = [
['trips-per-cycle', 1000],
['money-threshold', 1000000000000]
];
export function autocomplete(data, args) {
data.flags(argsSchema);
return [];
}
// TODO: Joining factions gives a small amount of int xp.
// With singularity functions, soft reset, and the 10 corp factions you can create a script that farms int xp rather quickly.
// This would be faster than the below travel-based method, which has been nerfed quite heavily
/** @param {NS} ns
* Script contributed by https://github.com/ShawnPatton
* Concept: A small amount of intelligence is granted when you (successfully) travel to a new city. This script converts money into intelligence exp! **/
export async function main(ns) {
disableLogs(ns, ["travelToCity", "sleep"]);
ns.tail();
let options = ns.flags(argsSchema);
let tripsPerCycle = options['trips-per-cycle'];
let moneyThreshold = options['money-threshold'];
ns.print(`trips-per-cycle: ` + tripsPerCycle);
ns.print(`money-threshold: ` + formatMoney(moneyThreshold));
let justStarted = true;
let previousInt = ns.getPlayer().intelligence;
let currentInt = previousInt;
let previousLevelTime = Date.now();
let levelupTime;
let cycles = 0;
let duration = 0;
let tripsPerLevel = 0;
let tripsPerMs = 0;
ns.print(`Starting Script at Int ` + currentInt);
while (true) {
while (ns.getPlayer().money > moneyThreshold) {
for (let i = 0; i < tripsPerCycle; i++) {
ns.travelToCity("Aevum");
ns.travelToCity("Sector-12");
}
await ns.sleep(1);
cycles++;
if (previousInt != ns.getPlayer().intelligence) {
currentInt = ns.getPlayer().intelligence;
levelupTime = Date.now();
duration = levelupTime - previousLevelTime;
tripsPerLevel = cycles * tripsPerCycle * 2;
tripsPerMs = Math.floor(tripsPerLevel / duration);
ns.print(`Level Up: Int ` + currentInt + (justStarted ? ` Partial` : ` Full`) + ` Level in `
+ formatDuration(duration) + ` & ` + formatNumberShort(tripsPerLevel) + ` Travels`);
ns.print(`Approximately ` + tripsPerMs + ` Trips/Millisecond`);
previousLevelTime = levelupTime;
previousInt = currentInt;
justStarted = false;
cycles = 0;
}
}
await ns.sleep(10000);
ns.print(`Below money threshold, waiting 10 seconds`);
}
}