bitburner-src/src/Netscript/RamCostGenerator.ts

646 lines
24 KiB
TypeScript
Raw Normal View History

import { Player } from "@player";
import { NSFull } from "../NetscriptFunctions";
2022-12-13 15:08:23 +01:00
/** This type assumes any value that isn't an API layer or a function has been omitted (enum) */
type RamCostTree<API> = Omit<
{
[Property in keyof API]: API[Property] extends () => unknown ? number | (() => number) : RamCostTree<API[Property]>;
},
2022-12-13 15:08:23 +01:00
"enums"
>;
/** Constants for assigning costs to ns functions */
2022-10-03 18:12:16 +02:00
export const RamCostConstants: Record<string, number> = {
2021-09-05 01:09:30 +02:00
ScriptBaseRamCost: 1.6,
ScriptDomRamCost: 25,
2021-12-04 05:06:04 +01:00
ScriptCorporationRamCost: 1024 - 1.6,
2021-09-05 01:09:30 +02:00
ScriptHackRamCost: 0.1,
ScriptHackAnalyzeRamCost: 1,
ScriptGrowRamCost: 0.15,
ScriptGrowthAnalyzeRamCost: 1,
ScriptWeakenRamCost: 0.15,
2021-10-28 03:13:57 +02:00
ScriptWeakenAnalyzeRamCost: 1,
2021-09-05 01:09:30 +02:00
ScriptScanRamCost: 0.2,
ScriptRecentScriptsRamCost: 0.2,
2021-09-05 01:09:30 +02:00
ScriptPortProgramRamCost: 0.05,
ScriptRunRamCost: 1.0,
ScriptExecRamCost: 1.3,
ScriptSpawnRamCost: 2.0,
ScriptScpRamCost: 0.6,
ScriptKillRamCost: 0.5,
ScriptHasRootAccessRamCost: 0.05,
ScriptGetHostnameRamCost: 0.05,
ScriptGetHackingLevelRamCost: 0.05,
ScriptGetMultipliersRamCost: 4.0,
ScriptGetServerRamCost: 0.1,
ScriptGetServerMaxRam: 0.05,
ScriptGetServerUsedRam: 0.05,
ScriptFileExistsRamCost: 0.1,
ScriptIsRunningRamCost: 0.1,
ScriptHacknetNodesRamCost: 4.0,
ScriptHNUpgLevelRamCost: 0.4,
ScriptHNUpgRamRamCost: 0.6,
ScriptHNUpgCoreRamCost: 0.8,
ScriptGetStockRamCost: 2.0,
ScriptBuySellStockRamCost: 2.5,
ScriptGetPurchaseServerRamCost: 0.25,
ScriptPurchaseServerRamCost: 2.25,
ScriptGetPurchasedServerLimit: 0.05,
ScriptGetPurchasedServerMaxRam: 0.05,
ScriptRoundRamCost: 0.05,
ScriptReadWriteRamCost: 1.0,
ScriptArbScriptRamCost: 1.0,
ScriptGetScriptRamCost: 0.1,
ScriptGetRunningScriptRamCost: 0.3,
ScriptGetHackTimeRamCost: 0.05,
ScriptGetFavorToDonate: 0.1,
ScriptCodingContractBaseRamCost: 10,
ScriptSleeveBaseRamCost: 4,
2022-05-06 12:29:21 +02:00
ScriptClearTerminalCost: 0.2,
2022-10-13 06:10:59 +02:00
ScriptGetMoneySourcesCost: 1.0,
2021-09-05 01:09:30 +02:00
ScriptSingularityFn1RamCost: 2,
ScriptSingularityFn2RamCost: 3,
ScriptSingularityFn3RamCost: 5,
2021-09-05 01:09:30 +02:00
ScriptGangApiBaseRamCost: 4,
2021-09-05 01:09:30 +02:00
ScriptBladeburnerApiBaseRamCost: 4,
2021-09-25 23:21:50 +02:00
ScriptStanekWidth: 0.4,
ScriptStanekHeight: 0.4,
2021-09-25 23:21:50 +02:00
ScriptStanekCharge: 0.4,
ScriptStanekFragmentDefinitions: 0,
ScriptStanekPlacedFragments: 5,
ScriptStanekClear: 0,
ScriptStanekCanPlace: 0.5,
ScriptStanekPlace: 5,
ScriptStanekFragmentAt: 2,
ScriptStanekDeleteAt: 0.15,
ScriptInfiltrationCalculateDifficulty: 2.5,
ScriptInfiltrationCalculateRewards: 2.5,
ScriptInfiltrationGetLocations: 5,
ScriptInfiltrationGetInfiltrations: 15,
ScriptStanekAcceptGift: 2,
2021-09-05 01:09:30 +02:00
};
2022-08-29 08:41:17 +02:00
function SF4Cost(cost: number): () => number {
return () => {
if (Player.bitNodeN === 4) return cost;
const sf4 = Player.sourceFileLvl(4);
2022-01-05 18:35:30 +01:00
if (sf4 <= 1) return cost * 16;
if (sf4 === 2) return cost * 4;
2022-01-05 01:09:34 +01:00
return cost;
};
}
// Hacknet API
const hacknet = {
numNodes: 0,
purchaseNode: 0,
getPurchaseNodeCost: 0,
getNodeStats: 0,
upgradeLevel: 0,
upgradeRam: 0,
upgradeCore: 0,
upgradeCache: 0,
getLevelUpgradeCost: 0,
getRamUpgradeCost: 0,
getCoreUpgradeCost: 0,
getCacheUpgradeCost: 0,
numHashes: 0,
hashCost: 0,
spendHashes: 0,
maxNumNodes: 0,
hashCapacity: 0,
getHashUpgrades: 0,
getHashUpgradeLevel: 0,
getStudyMult: 0,
getTrainingMult: 0,
} as const;
// Stock API
const stock = {
2022-07-28 20:35:55 +02:00
hasWSEAccount: 0.05,
hasTIXAPIAccess: 0.05,
has4SData: 0.05,
has4SDataTIXAPI: 0.05,
getSymbols: RamCostConstants.ScriptGetStockRamCost,
getPrice: RamCostConstants.ScriptGetStockRamCost,
getOrganization: RamCostConstants.ScriptGetStockRamCost,
getAskPrice: RamCostConstants.ScriptGetStockRamCost,
getBidPrice: RamCostConstants.ScriptGetStockRamCost,
getPosition: RamCostConstants.ScriptGetStockRamCost,
getMaxShares: RamCostConstants.ScriptGetStockRamCost,
getPurchaseCost: RamCostConstants.ScriptGetStockRamCost,
getSaleGain: RamCostConstants.ScriptGetStockRamCost,
2022-07-20 23:03:08 +02:00
buyStock: RamCostConstants.ScriptBuySellStockRamCost,
sellStock: RamCostConstants.ScriptBuySellStockRamCost,
2022-07-28 08:46:34 +02:00
buyShort: RamCostConstants.ScriptBuySellStockRamCost,
sellShort: RamCostConstants.ScriptBuySellStockRamCost,
placeOrder: RamCostConstants.ScriptBuySellStockRamCost,
cancelOrder: RamCostConstants.ScriptBuySellStockRamCost,
getOrders: RamCostConstants.ScriptBuySellStockRamCost,
getVolatility: RamCostConstants.ScriptBuySellStockRamCost,
getForecast: RamCostConstants.ScriptBuySellStockRamCost,
purchase4SMarketData: RamCostConstants.ScriptBuySellStockRamCost,
purchase4SMarketDataTixApi: RamCostConstants.ScriptBuySellStockRamCost,
purchaseWseAccount: RamCostConstants.ScriptBuySellStockRamCost,
purchaseTixApi: RamCostConstants.ScriptBuySellStockRamCost,
} as const;
// Singularity API
const singularity = {
universityCourse: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
gymWorkout: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
travelToCity: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
goToLocation: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
purchaseTor: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
purchaseProgram: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
getCurrentServer: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
connect: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
manualHack: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
installBackdoor: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost),
getDarkwebProgramCost: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 4),
getDarkwebPrograms: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 4),
hospitalize: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 4),
isBusy: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 4),
stopAction: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 2),
upgradeHomeRam: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
upgradeHomeCores: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
getUpgradeHomeRamCost: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 2),
getUpgradeHomeCoresCost: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 2),
workForCompany: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
applyToCompany: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
quitJob: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
getCompanyRep: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3),
getCompanyFavor: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3),
getCompanyFavorGain: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 4),
checkFactionInvitations: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
joinFaction: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
workForFaction: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost),
getFactionRep: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3),
getFactionFavor: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 3),
getFactionFavorGain: SF4Cost(RamCostConstants.ScriptSingularityFn2RamCost / 4),
donateToFaction: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
createProgram: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
commitCrime: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getCrimeChance: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getCrimeStats: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getOwnedAugmentations: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
2022-07-21 08:13:47 +02:00
getOwnedSourceFiles: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getAugmentationsFromFaction: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getAugmentationCost: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getAugmentationPrereq: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
getAugmentationPrice: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost / 2),
getAugmentationBasePrice: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost / 2),
getAugmentationRepReq: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost / 2),
getAugmentationStats: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
purchaseAugmentation: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
softReset: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
installAugmentations: SF4Cost(RamCostConstants.ScriptSingularityFn3RamCost),
isFocused: SF4Cost(0.1),
setFocus: SF4Cost(0.1),
exportGame: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 2),
exportGameBonus: SF4Cost(RamCostConstants.ScriptSingularityFn1RamCost / 4),
2022-04-13 23:34:02 +02:00
b1tflum3: SF4Cost(16),
destroyW0r1dD43m0n: SF4Cost(32),
2022-07-26 21:30:12 +02:00
getCurrentWork: SF4Cost(0.5),
} as const;
// Gang API
const gang = {
createGang: RamCostConstants.ScriptGangApiBaseRamCost / 4,
inGang: RamCostConstants.ScriptGangApiBaseRamCost / 4,
getMemberNames: RamCostConstants.ScriptGangApiBaseRamCost / 4,
getGangInformation: RamCostConstants.ScriptGangApiBaseRamCost / 2,
getOtherGangInformation: RamCostConstants.ScriptGangApiBaseRamCost / 2,
getMemberInformation: RamCostConstants.ScriptGangApiBaseRamCost / 2,
canRecruitMember: RamCostConstants.ScriptGangApiBaseRamCost / 4,
recruitMember: RamCostConstants.ScriptGangApiBaseRamCost / 2,
getTaskNames: RamCostConstants.ScriptGangApiBaseRamCost / 4,
getTaskStats: RamCostConstants.ScriptGangApiBaseRamCost / 4,
setMemberTask: RamCostConstants.ScriptGangApiBaseRamCost / 2,
getEquipmentNames: RamCostConstants.ScriptGangApiBaseRamCost / 4,
getEquipmentCost: RamCostConstants.ScriptGangApiBaseRamCost / 2,
getEquipmentType: RamCostConstants.ScriptGangApiBaseRamCost / 2,
getEquipmentStats: RamCostConstants.ScriptGangApiBaseRamCost / 2,
purchaseEquipment: RamCostConstants.ScriptGangApiBaseRamCost,
ascendMember: RamCostConstants.ScriptGangApiBaseRamCost,
getAscensionResult: RamCostConstants.ScriptGangApiBaseRamCost / 2,
setTerritoryWarfare: RamCostConstants.ScriptGangApiBaseRamCost / 2,
getChanceToWinClash: RamCostConstants.ScriptGangApiBaseRamCost,
getBonusTime: 0,
} as const;
// Bladeburner API
const bladeburner = {
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
inBladeburner: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 4,
getContractNames: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getOperationNames: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getBlackOpNames: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getBlackOpRank: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2,
getGeneralActionNames: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
getSkillNames: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 10,
startAction: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
stopBladeburnerAction: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 2,
getCurrentAction: RamCostConstants.ScriptBladeburnerApiBaseRamCost / 4,
getActionTime: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionCurrentTime: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionEstimatedSuccessChance: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionRepGain: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionCountRemaining: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionMaxLevel: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionCurrentLevel: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getActionAutolevel: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
setActionAutolevel: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
setActionLevel: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getRank: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getSkillPoints: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getSkillLevel: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getSkillUpgradeCost: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
upgradeSkill: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getTeamSize: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
setTeamSize: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCityEstimatedPopulation: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCityCommunities: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCityChaos: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getCity: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
switchCity: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getStamina: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
joinBladeburnerFaction: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
joinBladeburnerDivision: RamCostConstants.ScriptBladeburnerApiBaseRamCost,
getBonusTime: 0,
} as const;
const infiltration = {
getPossibleLocations: RamCostConstants.ScriptInfiltrationGetLocations,
getInfiltration: RamCostConstants.ScriptInfiltrationGetInfiltrations,
} as const;
2022-04-13 12:50:42 +02:00
// Coding Contract API
const codingcontract = {
attempt: RamCostConstants.ScriptCodingContractBaseRamCost,
getContractType: RamCostConstants.ScriptCodingContractBaseRamCost / 2,
getData: RamCostConstants.ScriptCodingContractBaseRamCost / 2,
getDescription: RamCostConstants.ScriptCodingContractBaseRamCost / 2,
getNumTriesRemaining: RamCostConstants.ScriptCodingContractBaseRamCost / 5,
2022-10-09 08:56:11 +02:00
createDummyContract: RamCostConstants.ScriptCodingContractBaseRamCost / 5,
getContractTypes: RamCostConstants.ScriptCodingContractBaseRamCost / 5,
} as const;
// Duplicate Sleeve API
const sleeve = {
getNumSleeves: RamCostConstants.ScriptSleeveBaseRamCost,
setToShockRecovery: RamCostConstants.ScriptSleeveBaseRamCost,
setToSynchronize: RamCostConstants.ScriptSleeveBaseRamCost,
setToCommitCrime: RamCostConstants.ScriptSleeveBaseRamCost,
setToUniversityCourse: RamCostConstants.ScriptSleeveBaseRamCost,
travel: RamCostConstants.ScriptSleeveBaseRamCost,
setToCompanyWork: RamCostConstants.ScriptSleeveBaseRamCost,
setToFactionWork: RamCostConstants.ScriptSleeveBaseRamCost,
setToGymWorkout: RamCostConstants.ScriptSleeveBaseRamCost,
getTask: RamCostConstants.ScriptSleeveBaseRamCost,
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
getSleeve: RamCostConstants.ScriptSleeveBaseRamCost,
getSleeveAugmentations: RamCostConstants.ScriptSleeveBaseRamCost,
getSleevePurchasableAugs: RamCostConstants.ScriptSleeveBaseRamCost,
purchaseSleeveAug: RamCostConstants.ScriptSleeveBaseRamCost,
setToBladeburnerAction: RamCostConstants.ScriptSleeveBaseRamCost,
2022-07-21 08:42:48 +02:00
getSleeveAugmentationPrice: RamCostConstants.ScriptSleeveBaseRamCost,
getSleeveAugmentationRepReq: RamCostConstants.ScriptSleeveBaseRamCost,
} as const;
// Stanek API
const stanek = {
giftWidth: RamCostConstants.ScriptStanekWidth,
giftHeight: RamCostConstants.ScriptStanekHeight,
chargeFragment: RamCostConstants.ScriptStanekCharge,
fragmentDefinitions: RamCostConstants.ScriptStanekFragmentDefinitions,
activeFragments: RamCostConstants.ScriptStanekPlacedFragments,
clearGift: RamCostConstants.ScriptStanekClear,
canPlaceFragment: RamCostConstants.ScriptStanekCanPlace,
placeFragment: RamCostConstants.ScriptStanekPlace,
getFragment: RamCostConstants.ScriptStanekFragmentAt,
removeFragment: RamCostConstants.ScriptStanekDeleteAt,
acceptGift: RamCostConstants.ScriptStanekAcceptGift,
} as const;
// UI API
const ui = {
getTheme: 0,
setTheme: 0,
resetTheme: 0,
getStyles: 0,
setStyles: 0,
resetStyles: 0,
getGameInfo: 0,
clearTerminal: 0,
windowSize: 0,
} as const;
// Grafting API
const grafting = {
getAugmentationGraftPrice: 3.75,
getAugmentationGraftTime: 3.75,
getGraftableAugmentations: 5,
graftAugmentation: 7.5,
} as const;
const corporation = {
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
hasCorporation: 0,
2022-08-10 00:25:02 +02:00
getMaterialNames: 0,
getIndustryTypes: 0,
getEmployeePositions: 0,
2022-08-10 00:25:02 +02:00
getUnlockables: 0,
getUpgradeNames: 0,
getResearchNames: 0,
createCorporation: 0,
hasUnlockUpgrade: 0,
getUnlockUpgradeCost: 0,
getUpgradeLevel: 0,
getUpgradeLevelCost: 0,
getExpandIndustryCost: 0,
getExpandCityCost: 0,
getInvestmentOffer: 0,
acceptInvestmentOffer: 0,
goPublic: 0,
bribe: 0,
getCorporation: 0,
getDivision: 0,
expandIndustry: 0,
expandCity: 0,
unlockUpgrade: 0,
levelUpgrade: 0,
issueDividends: 0,
buyBackShares: 0,
sellShares: 0,
getBonusTime: 0,
sellMaterial: 0,
sellProduct: 0,
discontinueProduct: 0,
setSmartSupply: 0,
setSmartSupplyUseLeftovers: 0,
buyMaterial: 0,
bulkPurchase: 0,
getWarehouse: 0,
getProduct: 0,
getMaterial: 0,
setMaterialMarketTA1: 0,
setMaterialMarketTA2: 0,
setProductMarketTA1: 0,
setProductMarketTA2: 0,
exportMaterial: 0,
cancelExportMaterial: 0,
purchaseWarehouse: 0,
upgradeWarehouse: 0,
makeProduct: 0,
limitMaterialProduction: 0,
limitProductProduction: 0,
getPurchaseWarehouseCost: 0,
getUpgradeWarehouseCost: 0,
hasWarehouse: 0,
hireEmployee: 0,
upgradeOfficeSize: 0,
throwParty: 0,
buyCoffee: 0,
hireAdVert: 0,
research: 0,
getOffice: 0,
getHireAdVertCost: 0,
getHireAdVertCount: 0,
getResearchCost: 0,
hasResearched: 0,
setAutoJobAssignment: 0,
getOfficeSizeUpgradeCost: 0,
} as const;
/** RamCosts guaranteed to match ns structure 1:1 (aside from args and enums).
* An error will be generated if there are missing OR additional ram costs defined.
* To avoid errors, define every function in NetscriptDefinition.d.ts and NetscriptFunctions,
* and have a ram cost associated here. */
export const RamCosts: RamCostTree<NSFull> = {
corporation,
hacknet,
stock,
singularity,
gang,
bladeburner,
2022-04-13 12:50:42 +02:00
infiltration,
codingcontract,
sleeve,
stanek,
ui,
grafting,
2021-10-27 21:16:16 +02:00
sprintf: 0,
vsprintf: 0,
scan: RamCostConstants.ScriptScanRamCost,
hack: RamCostConstants.ScriptHackRamCost,
hackAnalyzeThreads: RamCostConstants.ScriptHackAnalyzeRamCost,
2021-11-03 03:11:22 +01:00
hackAnalyze: RamCostConstants.ScriptHackAnalyzeRamCost,
2021-10-28 03:13:57 +02:00
hackAnalyzeSecurity: RamCostConstants.ScriptHackAnalyzeRamCost,
2021-11-03 03:11:22 +01:00
hackAnalyzeChance: RamCostConstants.ScriptHackAnalyzeRamCost,
2021-10-27 21:16:16 +02:00
sleep: 0,
2022-03-17 13:32:49 +01:00
asleep: 0,
2022-01-18 20:02:12 +01:00
share: 2.4,
getSharePower: 0.2,
2021-10-27 21:16:16 +02:00
grow: RamCostConstants.ScriptGrowRamCost,
growthAnalyze: RamCostConstants.ScriptGrowthAnalyzeRamCost,
2021-10-28 03:13:57 +02:00
growthAnalyzeSecurity: RamCostConstants.ScriptGrowthAnalyzeRamCost,
2021-10-27 21:16:16 +02:00
weaken: RamCostConstants.ScriptWeakenRamCost,
2021-10-28 03:13:57 +02:00
weakenAnalyze: RamCostConstants.ScriptWeakenAnalyzeRamCost,
2021-10-27 21:16:16 +02:00
print: 0,
printf: 0,
2021-10-27 21:16:16 +02:00
tprint: 0,
2022-05-23 09:57:23 +02:00
tprintf: 0,
2021-10-27 21:16:16 +02:00
clearLog: 0,
disableLog: 0,
enableLog: 0,
isLogEnabled: 0,
getScriptLogs: 0,
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
hasTorRouter: 0.05,
2021-10-27 21:16:16 +02:00
nuke: RamCostConstants.ScriptPortProgramRamCost,
brutessh: RamCostConstants.ScriptPortProgramRamCost,
ftpcrack: RamCostConstants.ScriptPortProgramRamCost,
relaysmtp: RamCostConstants.ScriptPortProgramRamCost,
httpworm: RamCostConstants.ScriptPortProgramRamCost,
sqlinject: RamCostConstants.ScriptPortProgramRamCost,
run: RamCostConstants.ScriptRunRamCost,
exec: RamCostConstants.ScriptExecRamCost,
spawn: RamCostConstants.ScriptSpawnRamCost,
kill: RamCostConstants.ScriptKillRamCost,
killall: RamCostConstants.ScriptKillRamCost,
exit: 0,
2022-03-29 23:24:38 +02:00
atExit: 0,
2021-10-27 21:16:16 +02:00
scp: RamCostConstants.ScriptScpRamCost,
ls: RamCostConstants.ScriptScanRamCost,
ps: RamCostConstants.ScriptScanRamCost,
getRecentScripts: RamCostConstants.ScriptRecentScriptsRamCost,
2021-10-27 21:16:16 +02:00
hasRootAccess: RamCostConstants.ScriptHasRootAccessRamCost,
getHostname: RamCostConstants.ScriptGetHostnameRamCost,
getHackingLevel: RamCostConstants.ScriptGetHackingLevelRamCost,
getHackingMultipliers: RamCostConstants.ScriptGetMultipliersRamCost,
getHacknetMultipliers: RamCostConstants.ScriptGetMultipliersRamCost,
getBitNodeMultipliers: RamCostConstants.ScriptGetMultipliersRamCost,
getServer: RamCostConstants.ScriptGetMultipliersRamCost / 2,
getServerMoneyAvailable: RamCostConstants.ScriptGetServerRamCost,
getServerSecurityLevel: RamCostConstants.ScriptGetServerRamCost,
getServerBaseSecurityLevel: RamCostConstants.ScriptGetServerRamCost,
getServerMinSecurityLevel: RamCostConstants.ScriptGetServerRamCost,
getServerRequiredHackingLevel: RamCostConstants.ScriptGetServerRamCost,
getServerMaxMoney: RamCostConstants.ScriptGetServerRamCost,
getServerGrowth: RamCostConstants.ScriptGetServerRamCost,
getServerNumPortsRequired: RamCostConstants.ScriptGetServerRamCost,
getServerRam: RamCostConstants.ScriptGetServerRamCost,
getServerMaxRam: RamCostConstants.ScriptGetServerMaxRam,
getServerUsedRam: RamCostConstants.ScriptGetServerUsedRam,
serverExists: RamCostConstants.ScriptGetServerRamCost,
fileExists: RamCostConstants.ScriptFileExistsRamCost,
isRunning: RamCostConstants.ScriptIsRunningRamCost,
getPurchasedServerLimit: RamCostConstants.ScriptGetPurchasedServerLimit,
getPurchasedServerMaxRam: RamCostConstants.ScriptGetPurchasedServerMaxRam,
getPurchasedServerCost: RamCostConstants.ScriptGetPurchaseServerRamCost,
2022-10-09 08:32:13 +02:00
getPurchasedServerUpgradeCost: 0.1,
upgradePurchasedServer: 0.25,
renamePurchasedServer: 2,
2021-10-27 21:16:16 +02:00
purchaseServer: RamCostConstants.ScriptPurchaseServerRamCost,
deleteServer: RamCostConstants.ScriptPurchaseServerRamCost,
getPurchasedServers: RamCostConstants.ScriptPurchaseServerRamCost,
2021-11-03 03:11:22 +01:00
write: 0,
tryWritePort: 0,
2021-11-03 03:11:22 +01:00
read: 0,
peek: 0,
clear: 0,
writePort: 0,
readPort: 0,
2021-11-03 03:11:22 +01:00
getPortHandle: 0,
2021-10-27 21:16:16 +02:00
rm: RamCostConstants.ScriptReadWriteRamCost,
scriptRunning: RamCostConstants.ScriptArbScriptRamCost,
scriptKill: RamCostConstants.ScriptArbScriptRamCost,
getScriptName: 0,
getScriptRam: RamCostConstants.ScriptGetScriptRamCost,
getHackTime: RamCostConstants.ScriptGetHackTimeRamCost,
getGrowTime: RamCostConstants.ScriptGetHackTimeRamCost,
getWeakenTime: RamCostConstants.ScriptGetHackTimeRamCost,
2022-07-20 01:04:06 +02:00
getTotalScriptIncome: RamCostConstants.ScriptGetScriptRamCost,
2021-10-27 21:16:16 +02:00
getScriptIncome: RamCostConstants.ScriptGetScriptRamCost,
2022-07-20 01:04:06 +02:00
getTotalScriptExpGain: RamCostConstants.ScriptGetScriptRamCost,
2021-10-27 21:16:16 +02:00
getScriptExpGain: RamCostConstants.ScriptGetScriptRamCost,
getRunningScript: RamCostConstants.ScriptGetRunningScriptRamCost,
nFormat: 0,
tFormat: 0,
2021-10-27 21:16:16 +02:00
getTimeSinceLastAug: RamCostConstants.ScriptGetHackTimeRamCost,
prompt: 0,
wget: 0,
getFavorToDonate: RamCostConstants.ScriptGetFavorToDonate,
2022-01-05 04:21:44 +01:00
getPlayer: RamCostConstants.ScriptSingularityFn1RamCost / 4,
2022-10-13 06:10:59 +02:00
getMoneySources: RamCostConstants.ScriptGetMoneySourcesCost,
2022-01-12 18:53:54 +01:00
mv: 0,
2022-03-18 21:35:56 +01:00
tail: 0,
toast: 0,
moveTail: 0,
resizeTail: 0,
closeTail: 0,
clearPort: 0,
openDevMenu: 0,
alert: 0,
flags: 0,
exploit: 0,
bypass: 0,
alterReality: 0,
rainbow: 0,
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
heart: { break: 0 },
2022-10-12 03:02:04 +02:00
iKnowWhatImDoing: 0,
2022-05-24 23:51:48 +02:00
formulas: {
mockServer: 0,
mockPlayer: 0,
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
mockPerson: 0,
2022-05-24 23:51:48 +02:00
reputation: {
calculateFavorToRep: 0,
calculateRepToFavor: 0,
repFromDonation: 0,
},
skills: {
calculateSkill: 0,
calculateExp: 0,
},
hacking: {
hackChance: 0,
hackExp: 0,
hackPercent: 0,
growPercent: 0,
hackTime: 0,
growTime: 0,
weakenTime: 0,
},
hacknetNodes: {
moneyGainRate: 0,
levelUpgradeCost: 0,
ramUpgradeCost: 0,
coreUpgradeCost: 0,
hacknetNodeCost: 0,
constants: 0,
},
hacknetServers: {
hashGainRate: 0,
levelUpgradeCost: 0,
ramUpgradeCost: 0,
coreUpgradeCost: 0,
cacheUpgradeCost: 0,
hashUpgradeCost: 0,
hacknetServerCost: 0,
constants: 0,
},
gang: {
wantedPenalty: 0,
respectGain: 0,
wantedLevelGain: 0,
moneyGain: 0,
ascensionPointsGain: 0,
ascensionMultiplier: 0,
},
work: {
NETSCRIPT: ns.sleeve.getSleeve added. getPlayer and getSleeve can both be used for formulas. (#200) * BREAKING CHANGE: Removed getSleeveStats and getSleeveInformation because this info is provided by getSleeve in a more usable form. * BREAKING CHANGE: Removed tor, inBladeburner, and hasCorporation fields from ns.getPlayer. Functionality still exists via added functions ns.hasTorRouter, ns.corporation.hasCorporation, and ns.bladeburner.inBladeburner. * Separated ns definitions for Person, Sleeve, and Player interfaces with both Player and Sleeve just extending Person. Added getSleeve, which provides a Sleeve object similar to getPlayer. * Renamed the sleeve ns layer's interface as sleeve lowercase because of name conflict. todo: May move all the ns layers interface names to lowercase for consistency * Added ns.formulas.work.crimeSuccessChance and reworked to allow both sleeve and player calculations. * Removed internal Person.getIntelligenceBonus function which was just a wrapper for calculateIntelligenceBonus. Any use of the former in formulas creates a conflict where ns-provided Person objects throw an error. * Renamed helpers.player to helpers.person for netscript person validation. Reduced number of fields validated due to Person being a smaller interface. * Fixed bug in bladeburner where Player multipliers and int were being used no matter which person was performing the task * Fixed leak of Player.jobs at ns.getPlayer * Person / Player / Sleeve classes now implement the netscript equivalent interfaces. Netscript helper for person no longer asserts that it's a real Person class member, only that it's a Person interface. Functions that use netscript persons have been changed to expect just a person interface to prevent needing this incorrect type assertion.
2022-11-09 13:26:26 +01:00
crimeSuccessChance: 0,
crimeGains: 0,
gymGains: 0,
universityGains: 0,
factionGains: 0,
companyGains: 0,
2022-05-24 23:51:48 +02:00
},
},
} as const;
2022-08-29 08:41:17 +02:00
export function getRamCost(...args: string[]): number {
2021-09-05 01:09:30 +02:00
if (args.length === 0) {
console.warn(`No arguments passed to getRamCost()`);
return 0;
}
let curr = RamCosts[args[0] as keyof typeof RamCosts];
2021-09-05 01:09:30 +02:00
for (let i = 1; i < args.length; ++i) {
if (curr == null) {
console.warn(`Invalid function passed to getRamCost: ${args}`);
return 0;
}
const currType = typeof curr;
2021-09-05 01:09:30 +02:00
if (currType === "function" || currType === "number") {
break;
}
curr = curr[args[i] as keyof typeof curr];
2021-09-05 01:09:30 +02:00
}
2021-10-27 21:16:16 +02:00
if (typeof curr === "number") {
2021-09-05 01:09:30 +02:00
return curr;
}
2022-01-05 01:09:34 +01:00
if (typeof curr === "function") {
2022-08-29 08:41:17 +02:00
return curr();
2022-01-05 01:09:34 +01:00
}
2021-10-27 21:16:16 +02:00
console.warn(`Unexpected type (${curr}) for value [${args}]`);
2021-09-05 01:09:30 +02:00
return 0;
}