All player-facing information available in the UI (somewhere) is now accessible to netscripts. This includes:
Corp-wide upgrade-added multipliers (eg. the +10% intelligence from Neural Accelerators) including science, general production, and warehouse space.
Division research-added employee multipliers (eg. the +25% intelligence and efficiency from Overclock) including science, general production, and warehouse space.
Material sizes (not directly shown to the player, but can be figured out just by purchasing 1 of each and looking at used space), crucial for knowing how many can be purchased without overfilling the warehouse.
FormulasAPI method to fetch Industry Type data (currently only shown as [|||||---------------] which is too imprecise for corp automation)
Industry type info moved to constant instead of switch case to ease exposure of the data to ns scripts.
FormulasAPI method for full production multiplier from materials (eg. "if I have X hardware, Y robots, and Z real estate for industry Q, what multiplier would be contributed per city?")
FormulasAPI method to fetch Product rating weights (eg. Food desires Quality but not Reliability). Not currently conveyed to the player, but also makes only about a 0.1% difference in market price.
All formulas require both Formulas API access as well as owning a corp and having the relevant corp API access (warehouse, in all three cases).
Sample code
The following shows an example of the kind of thing that would now be possible with the changes in this PR
/** @param {NS} ns */
export async function main(ns) {
const ind = "Food"; //industry to query
const city = "Aevum"; //city to query
const mat = "Robots"; //material to query
const buffer = 0.25; //percentage of warehouse to keep empty (for purchases and production)
const div = ns.corporation.getCorporation().divisions.filter(d => d.type == ind)[0].name;
const availableSpace = ns.corporation.getWarehouse(div,city).size;
const usedSpace = ns.corporation.getWarehouse(div,city).sizeUsed;
const coreSize = ns.corporation.getMaterialSize(mat);
const re = ns.corporation.getMaterial(div,city,"RealEstate").qty;
const hd = ns.corporation.getMaterial(div,city,"Hardware").qty;
const ro = ns.corporation.getMaterial(div,city,"Robots").qty;
const ai = ns.corporation.getMaterial(div,city,"AI Cores").qty;
const canHold = ((availableSpace-usedSpace) * (1-buffer))/coreSize;
const buyAmt = canHold;
ns.tprint(`${div} in ${city} can buy ${buyAmt} more ${mat}`);
const oldMulti = ns.formulas.corp.calculateProductionMultiplier(ind,re,hd,ro,ai);
const newMulti = ns.formulas.corp.calculateProductionMultiplier(ind,re,hd,ro+buyAmt,ai);
ns.tprint(`This would improve production from ${oldMulti} to ${newMulti}`);
}
Linked issues
closes #4202 partially addresses #4199
Documentation
All player-facing information available in the UI (somewhere) is now accessible to netscripts. This includes:
[|||||---------------]
which is too imprecise for corp automation)Sample code
The following shows an example of the kind of thing that would now be possible with the changes in this PR