2022-10-10 00:42:14 +02:00
|
|
|
import { Player } from "@player";
|
2022-10-05 16:42:07 +02:00
|
|
|
import { NSFull } from "../NetscriptFunctions";
|
2019-05-05 06:03:40 +02:00
|
|
|
|
2023-01-04 15:23:20 +01:00
|
|
|
/** The API does not include enums, args, or pid. */
|
|
|
|
export type RamCostTree<API> = {
|
|
|
|
[key in keyof API]: API[key] extends () => unknown ? number | (() => number) : RamCostTree<API[key]>;
|
|
|
|
};
|
2022-05-25 00:34:00 +02:00
|
|
|
|
2022-10-05 16:42:07 +02:00
|
|
|
/** Constants for assigning costs to ns functions */
|
2022-12-30 02:28:53 +01:00
|
|
|
export const RamCostConstants = {
|
|
|
|
Base: 1.6,
|
|
|
|
Dom: 25,
|
|
|
|
Corporation: 1024,
|
|
|
|
Max: 1024,
|
|
|
|
Hack: 0.1,
|
|
|
|
HackAnalyze: 1,
|
|
|
|
Grow: 0.15,
|
|
|
|
GrowthAnalyze: 1,
|
|
|
|
Weaken: 0.15,
|
|
|
|
WeakenAnalyze: 1,
|
|
|
|
Scan: 0.2,
|
|
|
|
RecentScripts: 0.2,
|
|
|
|
PortProgram: 0.05,
|
|
|
|
Run: 1.0,
|
|
|
|
Exec: 1.3,
|
|
|
|
Spawn: 2.0,
|
|
|
|
Scp: 0.6,
|
|
|
|
Kill: 0.5,
|
|
|
|
HasRootAccess: 0.05,
|
|
|
|
GetHostname: 0.05,
|
|
|
|
GetHackingLevel: 0.05,
|
|
|
|
GetServer: 0.1,
|
|
|
|
GetServerMaxRam: 0.05,
|
|
|
|
GetServerUsedRam: 0.05,
|
|
|
|
FileExists: 0.1,
|
|
|
|
IsRunning: 0.1,
|
|
|
|
HacknetNodes: 4.0,
|
|
|
|
HNUpgLevel: 0.4,
|
|
|
|
HNUpgRam: 0.6,
|
|
|
|
HNUpgCore: 0.8,
|
|
|
|
GetStock: 2.0,
|
|
|
|
BuySellStock: 2.5,
|
|
|
|
GetPurchaseServer: 0.25,
|
|
|
|
PurchaseServer: 2.25,
|
|
|
|
GetPurchasedServerLimit: 0.05,
|
|
|
|
GetPurchasedServerMaxRam: 0.05,
|
|
|
|
Round: 0.05,
|
|
|
|
ReadWrite: 1.0,
|
|
|
|
ArbScript: 1.0,
|
|
|
|
GetScript: 0.1,
|
|
|
|
GetRunningScript: 0.3,
|
|
|
|
GetHackTime: 0.05,
|
|
|
|
GetFavorToDonate: 0.1,
|
|
|
|
CodingContractBase: 10,
|
|
|
|
SleeveBase: 4,
|
|
|
|
ClearTerminalCost: 0.2,
|
|
|
|
GetMoneySourcesCost: 1.0,
|
2019-05-05 06:03:40 +02:00
|
|
|
|
2022-12-30 02:28:53 +01:00
|
|
|
SingularityFn1: 2,
|
|
|
|
SingularityFn2: 3,
|
|
|
|
SingularityFn3: 5,
|
2019-05-05 06:03:40 +02:00
|
|
|
|
2022-12-30 02:28:53 +01:00
|
|
|
GangApiBase: 4,
|
2019-05-05 06:03:40 +02:00
|
|
|
|
2022-12-30 02:28:53 +01:00
|
|
|
BladeburnerApiBase: 4,
|
2021-09-25 23:21:50 +02:00
|
|
|
|
2022-12-30 02:28:53 +01:00
|
|
|
StanekWidth: 0.4,
|
|
|
|
StanekHeight: 0.4,
|
|
|
|
StanekCharge: 0.4,
|
|
|
|
StanekFragmentDefinitions: 0,
|
|
|
|
StanekPlacedFragments: 5,
|
|
|
|
StanekClear: 0,
|
|
|
|
StanekCanPlace: 0.5,
|
|
|
|
StanekPlace: 5,
|
|
|
|
StanekFragmentAt: 2,
|
|
|
|
StanekDeleteAt: 0.15,
|
|
|
|
InfiltrationCalculateDifficulty: 2.5,
|
|
|
|
InfiltrationCalculateRewards: 2.5,
|
|
|
|
InfiltrationGetLocations: 5,
|
|
|
|
InfiltrationGetInfiltrations: 15,
|
|
|
|
StanekAcceptGift: 2,
|
2021-09-05 01:09:30 +02:00
|
|
|
};
|
2019-05-05 06:03:40 +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;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2022-04-12 08:51:10 +02:00
|
|
|
// Hacknet API
|
2022-05-25 00:34:00 +02:00
|
|
|
const hacknet = {
|
2022-04-12 08:51:10 +02:00
|
|
|
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,
|
2022-05-21 17:24:20 +02:00
|
|
|
maxNumNodes: 0,
|
2022-05-25 00:34:00 +02:00
|
|
|
hashCapacity: 0,
|
|
|
|
getHashUpgrades: 0,
|
|
|
|
getHashUpgradeLevel: 0,
|
|
|
|
getStudyMult: 0,
|
|
|
|
getTrainingMult: 0,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// Stock API
|
2022-05-25 00:34:00 +02:00
|
|
|
const stock = {
|
2022-07-28 20:35:55 +02:00
|
|
|
hasWSEAccount: 0.05,
|
|
|
|
hasTIXAPIAccess: 0.05,
|
|
|
|
has4SData: 0.05,
|
|
|
|
has4SDataTIXAPI: 0.05,
|
2022-12-30 02:28:53 +01:00
|
|
|
getSymbols: RamCostConstants.GetStock,
|
|
|
|
getPrice: RamCostConstants.GetStock,
|
|
|
|
getOrganization: RamCostConstants.GetStock,
|
|
|
|
getAskPrice: RamCostConstants.GetStock,
|
|
|
|
getBidPrice: RamCostConstants.GetStock,
|
|
|
|
getPosition: RamCostConstants.GetStock,
|
|
|
|
getMaxShares: RamCostConstants.GetStock,
|
|
|
|
getPurchaseCost: RamCostConstants.GetStock,
|
|
|
|
getSaleGain: RamCostConstants.GetStock,
|
|
|
|
buyStock: RamCostConstants.BuySellStock,
|
|
|
|
sellStock: RamCostConstants.BuySellStock,
|
|
|
|
buyShort: RamCostConstants.BuySellStock,
|
|
|
|
sellShort: RamCostConstants.BuySellStock,
|
|
|
|
placeOrder: RamCostConstants.BuySellStock,
|
|
|
|
cancelOrder: RamCostConstants.BuySellStock,
|
|
|
|
getOrders: RamCostConstants.BuySellStock,
|
|
|
|
getVolatility: RamCostConstants.BuySellStock,
|
|
|
|
getForecast: RamCostConstants.BuySellStock,
|
|
|
|
purchase4SMarketData: RamCostConstants.BuySellStock,
|
|
|
|
purchase4SMarketDataTixApi: RamCostConstants.BuySellStock,
|
|
|
|
purchaseWseAccount: RamCostConstants.BuySellStock,
|
|
|
|
purchaseTixApi: RamCostConstants.BuySellStock,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// Singularity API
|
2022-05-25 00:34:00 +02:00
|
|
|
const singularity = {
|
2022-12-30 02:28:53 +01:00
|
|
|
universityCourse: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
gymWorkout: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
travelToCity: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
goToLocation: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
purchaseTor: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
purchaseProgram: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
getCurrentServer: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
connect: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
manualHack: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
installBackdoor: SF4Cost(RamCostConstants.SingularityFn1),
|
|
|
|
getDarkwebProgramCost: SF4Cost(RamCostConstants.SingularityFn1 / 4),
|
|
|
|
getDarkwebPrograms: SF4Cost(RamCostConstants.SingularityFn1 / 4),
|
|
|
|
hospitalize: SF4Cost(RamCostConstants.SingularityFn1 / 4),
|
|
|
|
isBusy: SF4Cost(RamCostConstants.SingularityFn1 / 4),
|
|
|
|
stopAction: SF4Cost(RamCostConstants.SingularityFn1 / 2),
|
|
|
|
upgradeHomeRam: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
upgradeHomeCores: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
getUpgradeHomeRamCost: SF4Cost(RamCostConstants.SingularityFn2 / 2),
|
|
|
|
getUpgradeHomeCoresCost: SF4Cost(RamCostConstants.SingularityFn2 / 2),
|
|
|
|
workForCompany: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
applyToCompany: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
quitJob: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
getCompanyRep: SF4Cost(RamCostConstants.SingularityFn2 / 3),
|
|
|
|
getCompanyFavor: SF4Cost(RamCostConstants.SingularityFn2 / 3),
|
|
|
|
getCompanyFavorGain: SF4Cost(RamCostConstants.SingularityFn2 / 4),
|
|
|
|
checkFactionInvitations: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
joinFaction: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
workForFaction: SF4Cost(RamCostConstants.SingularityFn2),
|
|
|
|
getFactionRep: SF4Cost(RamCostConstants.SingularityFn2 / 3),
|
|
|
|
getFactionFavor: SF4Cost(RamCostConstants.SingularityFn2 / 3),
|
|
|
|
getFactionFavorGain: SF4Cost(RamCostConstants.SingularityFn2 / 4),
|
|
|
|
donateToFaction: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
createProgram: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
commitCrime: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
getCrimeChance: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
getCrimeStats: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
getOwnedAugmentations: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
getOwnedSourceFiles: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
getAugmentationsFromFaction: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
getAugmentationPrereq: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
getAugmentationPrice: SF4Cost(RamCostConstants.SingularityFn3 / 2),
|
|
|
|
getAugmentationBasePrice: SF4Cost(RamCostConstants.SingularityFn3 / 2),
|
|
|
|
getAugmentationRepReq: SF4Cost(RamCostConstants.SingularityFn3 / 2),
|
|
|
|
getAugmentationStats: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
purchaseAugmentation: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
softReset: SF4Cost(RamCostConstants.SingularityFn3),
|
|
|
|
installAugmentations: SF4Cost(RamCostConstants.SingularityFn3),
|
2022-04-12 08:51:10 +02:00
|
|
|
isFocused: SF4Cost(0.1),
|
|
|
|
setFocus: SF4Cost(0.1),
|
2022-12-30 02:28:53 +01:00
|
|
|
exportGame: SF4Cost(RamCostConstants.SingularityFn1 / 2),
|
|
|
|
exportGameBonus: SF4Cost(RamCostConstants.SingularityFn1 / 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),
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// Gang API
|
2022-05-25 00:34:00 +02:00
|
|
|
const gang = {
|
2022-12-30 02:28:53 +01:00
|
|
|
createGang: RamCostConstants.GangApiBase / 4,
|
|
|
|
inGang: RamCostConstants.GangApiBase / 4,
|
|
|
|
getMemberNames: RamCostConstants.GangApiBase / 4,
|
|
|
|
getGangInformation: RamCostConstants.GangApiBase / 2,
|
|
|
|
getOtherGangInformation: RamCostConstants.GangApiBase / 2,
|
|
|
|
getMemberInformation: RamCostConstants.GangApiBase / 2,
|
|
|
|
canRecruitMember: RamCostConstants.GangApiBase / 4,
|
|
|
|
recruitMember: RamCostConstants.GangApiBase / 2,
|
|
|
|
getTaskNames: RamCostConstants.GangApiBase / 4,
|
|
|
|
getTaskStats: RamCostConstants.GangApiBase / 4,
|
|
|
|
setMemberTask: RamCostConstants.GangApiBase / 2,
|
|
|
|
getEquipmentNames: RamCostConstants.GangApiBase / 4,
|
|
|
|
getEquipmentCost: RamCostConstants.GangApiBase / 2,
|
|
|
|
getEquipmentType: RamCostConstants.GangApiBase / 2,
|
|
|
|
getEquipmentStats: RamCostConstants.GangApiBase / 2,
|
|
|
|
purchaseEquipment: RamCostConstants.GangApiBase,
|
|
|
|
ascendMember: RamCostConstants.GangApiBase,
|
|
|
|
getAscensionResult: RamCostConstants.GangApiBase / 2,
|
|
|
|
setTerritoryWarfare: RamCostConstants.GangApiBase / 2,
|
|
|
|
getChanceToWinClash: RamCostConstants.GangApiBase,
|
2022-04-12 08:51:10 +02:00
|
|
|
getBonusTime: 0,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// Bladeburner API
|
2022-05-25 00:34:00 +02:00
|
|
|
const bladeburner = {
|
2022-12-30 02:28:53 +01:00
|
|
|
inBladeburner: RamCostConstants.BladeburnerApiBase / 4,
|
|
|
|
getContractNames: RamCostConstants.BladeburnerApiBase / 10,
|
|
|
|
getOperationNames: RamCostConstants.BladeburnerApiBase / 10,
|
|
|
|
getBlackOpNames: RamCostConstants.BladeburnerApiBase / 10,
|
|
|
|
getBlackOpRank: RamCostConstants.BladeburnerApiBase / 2,
|
|
|
|
getGeneralActionNames: RamCostConstants.BladeburnerApiBase / 10,
|
|
|
|
getSkillNames: RamCostConstants.BladeburnerApiBase / 10,
|
|
|
|
startAction: RamCostConstants.BladeburnerApiBase,
|
|
|
|
stopBladeburnerAction: RamCostConstants.BladeburnerApiBase / 2,
|
|
|
|
getCurrentAction: RamCostConstants.BladeburnerApiBase / 4,
|
|
|
|
getActionTime: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getActionCurrentTime: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getActionEstimatedSuccessChance: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getActionRepGain: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getActionCountRemaining: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getActionMaxLevel: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getActionCurrentLevel: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getActionAutolevel: RamCostConstants.BladeburnerApiBase,
|
|
|
|
setActionAutolevel: RamCostConstants.BladeburnerApiBase,
|
|
|
|
setActionLevel: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getRank: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getSkillPoints: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getSkillLevel: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getSkillUpgradeCost: RamCostConstants.BladeburnerApiBase,
|
|
|
|
upgradeSkill: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getTeamSize: RamCostConstants.BladeburnerApiBase,
|
|
|
|
setTeamSize: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getCityEstimatedPopulation: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getCityCommunities: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getCityChaos: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getCity: RamCostConstants.BladeburnerApiBase,
|
|
|
|
switchCity: RamCostConstants.BladeburnerApiBase,
|
|
|
|
getStamina: RamCostConstants.BladeburnerApiBase,
|
|
|
|
joinBladeburnerFaction: RamCostConstants.BladeburnerApiBase,
|
|
|
|
joinBladeburnerDivision: RamCostConstants.BladeburnerApiBase,
|
2022-04-12 08:51:10 +02:00
|
|
|
getBonusTime: 0,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
2022-05-25 00:34:00 +02:00
|
|
|
const infiltration = {
|
2022-12-30 02:28:53 +01:00
|
|
|
getPossibleLocations: RamCostConstants.InfiltrationGetLocations,
|
|
|
|
getInfiltration: RamCostConstants.InfiltrationGetInfiltrations,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-13 12:50:42 +02:00
|
|
|
|
2022-04-12 08:51:10 +02:00
|
|
|
// Coding Contract API
|
2022-05-25 00:34:00 +02:00
|
|
|
const codingcontract = {
|
2022-12-30 02:28:53 +01:00
|
|
|
attempt: RamCostConstants.CodingContractBase,
|
|
|
|
getContractType: RamCostConstants.CodingContractBase / 2,
|
|
|
|
getData: RamCostConstants.CodingContractBase / 2,
|
|
|
|
getDescription: RamCostConstants.CodingContractBase / 2,
|
|
|
|
getNumTriesRemaining: RamCostConstants.CodingContractBase / 5,
|
|
|
|
createDummyContract: RamCostConstants.CodingContractBase / 5,
|
|
|
|
getContractTypes: RamCostConstants.CodingContractBase / 5,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// Duplicate Sleeve API
|
2022-05-25 00:34:00 +02:00
|
|
|
const sleeve = {
|
2022-12-30 02:28:53 +01:00
|
|
|
getNumSleeves: RamCostConstants.SleeveBase,
|
|
|
|
setToShockRecovery: RamCostConstants.SleeveBase,
|
|
|
|
setToSynchronize: RamCostConstants.SleeveBase,
|
|
|
|
setToCommitCrime: RamCostConstants.SleeveBase,
|
|
|
|
setToUniversityCourse: RamCostConstants.SleeveBase,
|
|
|
|
travel: RamCostConstants.SleeveBase,
|
|
|
|
setToCompanyWork: RamCostConstants.SleeveBase,
|
|
|
|
setToFactionWork: RamCostConstants.SleeveBase,
|
|
|
|
setToGymWorkout: RamCostConstants.SleeveBase,
|
|
|
|
getTask: RamCostConstants.SleeveBase,
|
|
|
|
getSleeve: RamCostConstants.SleeveBase,
|
|
|
|
getSleeveAugmentations: RamCostConstants.SleeveBase,
|
|
|
|
getSleevePurchasableAugs: RamCostConstants.SleeveBase,
|
|
|
|
purchaseSleeveAug: RamCostConstants.SleeveBase,
|
|
|
|
setToBladeburnerAction: RamCostConstants.SleeveBase,
|
|
|
|
getSleeveAugmentationPrice: RamCostConstants.SleeveBase,
|
|
|
|
getSleeveAugmentationRepReq: RamCostConstants.SleeveBase,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// Stanek API
|
2022-05-25 00:34:00 +02:00
|
|
|
const stanek = {
|
2022-12-30 02:28:53 +01:00
|
|
|
giftWidth: RamCostConstants.StanekWidth,
|
|
|
|
giftHeight: RamCostConstants.StanekHeight,
|
|
|
|
chargeFragment: RamCostConstants.StanekCharge,
|
|
|
|
fragmentDefinitions: RamCostConstants.StanekFragmentDefinitions,
|
|
|
|
activeFragments: RamCostConstants.StanekPlacedFragments,
|
|
|
|
clearGift: RamCostConstants.StanekClear,
|
|
|
|
canPlaceFragment: RamCostConstants.StanekCanPlace,
|
|
|
|
placeFragment: RamCostConstants.StanekPlace,
|
|
|
|
getFragment: RamCostConstants.StanekFragmentAt,
|
|
|
|
removeFragment: RamCostConstants.StanekDeleteAt,
|
|
|
|
acceptGift: RamCostConstants.StanekAcceptGift,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// UI API
|
2022-05-25 00:34:00 +02:00
|
|
|
const ui = {
|
2022-04-12 08:51:10 +02:00
|
|
|
getTheme: 0,
|
|
|
|
setTheme: 0,
|
|
|
|
resetTheme: 0,
|
|
|
|
getStyles: 0,
|
|
|
|
setStyles: 0,
|
|
|
|
resetStyles: 0,
|
|
|
|
getGameInfo: 0,
|
2022-05-25 00:34:00 +02:00
|
|
|
clearTerminal: 0,
|
2022-08-30 00:07:17 +02:00
|
|
|
windowSize: 0,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
|
|
|
// Grafting API
|
2022-05-25 00:34:00 +02:00
|
|
|
const grafting = {
|
2022-04-12 08:51:10 +02:00
|
|
|
getAugmentationGraftPrice: 3.75,
|
|
|
|
getAugmentationGraftTime: 3.75,
|
2022-04-13 16:43:27 +02:00
|
|
|
getGraftableAugmentations: 5,
|
2022-04-12 08:51:10 +02:00
|
|
|
graftAugmentation: 7.5,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-04-12 08:51:10 +02:00
|
|
|
|
2022-05-25 00:34:00 +02:00
|
|
|
const corporation = {
|
2022-12-30 02:28:53 +01:00
|
|
|
hasCorporation: 0, // This one is free
|
|
|
|
getConstants: RamCostConstants.Corporation,
|
|
|
|
getIndustryData: RamCostConstants.Corporation,
|
|
|
|
getMaterialData: RamCostConstants.Corporation,
|
|
|
|
issueNewShares: RamCostConstants.Corporation,
|
|
|
|
createCorporation: RamCostConstants.Corporation,
|
|
|
|
hasUnlockUpgrade: RamCostConstants.Corporation,
|
|
|
|
getUnlockUpgradeCost: RamCostConstants.Corporation,
|
|
|
|
getUpgradeLevel: RamCostConstants.Corporation,
|
|
|
|
getUpgradeLevelCost: RamCostConstants.Corporation,
|
|
|
|
getInvestmentOffer: RamCostConstants.Corporation,
|
|
|
|
acceptInvestmentOffer: RamCostConstants.Corporation,
|
|
|
|
goPublic: RamCostConstants.Corporation,
|
|
|
|
bribe: RamCostConstants.Corporation,
|
|
|
|
getCorporation: RamCostConstants.Corporation,
|
|
|
|
getDivision: RamCostConstants.Corporation,
|
|
|
|
expandIndustry: RamCostConstants.Corporation,
|
|
|
|
expandCity: RamCostConstants.Corporation,
|
|
|
|
unlockUpgrade: RamCostConstants.Corporation,
|
|
|
|
levelUpgrade: RamCostConstants.Corporation,
|
|
|
|
issueDividends: RamCostConstants.Corporation,
|
|
|
|
buyBackShares: RamCostConstants.Corporation,
|
|
|
|
sellShares: RamCostConstants.Corporation,
|
2023-01-03 18:23:38 +01:00
|
|
|
getBonusTime: 0,
|
2022-12-30 02:28:53 +01:00
|
|
|
sellMaterial: RamCostConstants.Corporation,
|
|
|
|
sellProduct: RamCostConstants.Corporation,
|
|
|
|
discontinueProduct: RamCostConstants.Corporation,
|
|
|
|
setSmartSupply: RamCostConstants.Corporation,
|
|
|
|
setSmartSupplyUseLeftovers: RamCostConstants.Corporation,
|
|
|
|
buyMaterial: RamCostConstants.Corporation,
|
|
|
|
bulkPurchase: RamCostConstants.Corporation,
|
|
|
|
getWarehouse: RamCostConstants.Corporation,
|
|
|
|
getProduct: RamCostConstants.Corporation,
|
|
|
|
getMaterial: RamCostConstants.Corporation,
|
|
|
|
setMaterialMarketTA1: RamCostConstants.Corporation,
|
|
|
|
setMaterialMarketTA2: RamCostConstants.Corporation,
|
|
|
|
setProductMarketTA1: RamCostConstants.Corporation,
|
|
|
|
setProductMarketTA2: RamCostConstants.Corporation,
|
|
|
|
exportMaterial: RamCostConstants.Corporation,
|
|
|
|
cancelExportMaterial: RamCostConstants.Corporation,
|
|
|
|
purchaseWarehouse: RamCostConstants.Corporation,
|
|
|
|
upgradeWarehouse: RamCostConstants.Corporation,
|
|
|
|
makeProduct: RamCostConstants.Corporation,
|
|
|
|
limitMaterialProduction: RamCostConstants.Corporation,
|
|
|
|
limitProductProduction: RamCostConstants.Corporation,
|
|
|
|
getUpgradeWarehouseCost: RamCostConstants.Corporation,
|
|
|
|
hasWarehouse: RamCostConstants.Corporation,
|
|
|
|
hireEmployee: RamCostConstants.Corporation,
|
|
|
|
upgradeOfficeSize: RamCostConstants.Corporation,
|
|
|
|
throwParty: RamCostConstants.Corporation,
|
|
|
|
buyCoffee: RamCostConstants.Corporation,
|
|
|
|
hireAdVert: RamCostConstants.Corporation,
|
|
|
|
research: RamCostConstants.Corporation,
|
|
|
|
getOffice: RamCostConstants.Corporation,
|
|
|
|
getHireAdVertCost: RamCostConstants.Corporation,
|
|
|
|
getHireAdVertCount: RamCostConstants.Corporation,
|
|
|
|
getResearchCost: RamCostConstants.Corporation,
|
|
|
|
hasResearched: RamCostConstants.Corporation,
|
|
|
|
setAutoJobAssignment: RamCostConstants.Corporation,
|
|
|
|
getOfficeSizeUpgradeCost: RamCostConstants.Corporation,
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-05-25 00:34:00 +02:00
|
|
|
|
2022-10-05 16:42:07 +02:00
|
|
|
/** 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. */
|
2022-11-09 19:46:21 +01:00
|
|
|
export const RamCosts: RamCostTree<NSFull> = {
|
2022-05-25 00:34:00 +02:00
|
|
|
corporation,
|
2022-04-12 08:51:10 +02:00
|
|
|
hacknet,
|
|
|
|
stock,
|
|
|
|
singularity,
|
|
|
|
gang,
|
|
|
|
bladeburner,
|
2022-04-13 12:50:42 +02:00
|
|
|
infiltration,
|
2022-04-12 08:51:10 +02:00
|
|
|
codingcontract,
|
|
|
|
sleeve,
|
|
|
|
stanek,
|
|
|
|
ui,
|
|
|
|
grafting,
|
|
|
|
|
2021-10-27 21:16:16 +02:00
|
|
|
sprintf: 0,
|
|
|
|
vsprintf: 0,
|
2022-12-30 02:28:53 +01:00
|
|
|
scan: RamCostConstants.Scan,
|
|
|
|
hack: RamCostConstants.Hack,
|
|
|
|
hackAnalyzeThreads: RamCostConstants.HackAnalyze,
|
|
|
|
hackAnalyze: RamCostConstants.HackAnalyze,
|
|
|
|
hackAnalyzeSecurity: RamCostConstants.HackAnalyze,
|
|
|
|
hackAnalyzeChance: RamCostConstants.HackAnalyze,
|
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,
|
2022-12-30 02:28:53 +01:00
|
|
|
grow: RamCostConstants.Grow,
|
|
|
|
growthAnalyze: RamCostConstants.GrowthAnalyze,
|
|
|
|
growthAnalyzeSecurity: RamCostConstants.GrowthAnalyze,
|
|
|
|
weaken: RamCostConstants.Weaken,
|
|
|
|
weakenAnalyze: RamCostConstants.WeakenAnalyze,
|
2021-10-27 21:16:16 +02:00
|
|
|
print: 0,
|
2022-01-21 12:34:10 +01:00
|
|
|
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,
|
2022-11-09 13:26:26 +01:00
|
|
|
hasTorRouter: 0.05,
|
2022-12-30 02:28:53 +01:00
|
|
|
nuke: RamCostConstants.PortProgram,
|
|
|
|
brutessh: RamCostConstants.PortProgram,
|
|
|
|
ftpcrack: RamCostConstants.PortProgram,
|
|
|
|
relaysmtp: RamCostConstants.PortProgram,
|
|
|
|
httpworm: RamCostConstants.PortProgram,
|
|
|
|
sqlinject: RamCostConstants.PortProgram,
|
|
|
|
run: RamCostConstants.Run,
|
|
|
|
exec: RamCostConstants.Exec,
|
|
|
|
spawn: RamCostConstants.Spawn,
|
|
|
|
kill: RamCostConstants.Kill,
|
|
|
|
killall: RamCostConstants.Kill,
|
2021-10-27 21:16:16 +02:00
|
|
|
exit: 0,
|
2022-03-29 23:24:38 +02:00
|
|
|
atExit: 0,
|
2022-12-30 02:28:53 +01:00
|
|
|
scp: RamCostConstants.Scp,
|
|
|
|
ls: RamCostConstants.Scan,
|
|
|
|
ps: RamCostConstants.Scan,
|
|
|
|
getRecentScripts: RamCostConstants.RecentScripts,
|
|
|
|
hasRootAccess: RamCostConstants.HasRootAccess,
|
|
|
|
getHostname: RamCostConstants.GetHostname,
|
|
|
|
getHackingLevel: RamCostConstants.GetHackingLevel,
|
|
|
|
getHackingMultipliers: 0.25,
|
|
|
|
getHacknetMultipliers: 0.25,
|
|
|
|
getBitNodeMultipliers: 4,
|
|
|
|
getServer: 2,
|
|
|
|
getServerMoneyAvailable: RamCostConstants.GetServer,
|
|
|
|
getServerSecurityLevel: RamCostConstants.GetServer,
|
|
|
|
getServerBaseSecurityLevel: RamCostConstants.GetServer,
|
|
|
|
getServerMinSecurityLevel: RamCostConstants.GetServer,
|
|
|
|
getServerRequiredHackingLevel: RamCostConstants.GetServer,
|
|
|
|
getServerMaxMoney: RamCostConstants.GetServer,
|
|
|
|
getServerGrowth: RamCostConstants.GetServer,
|
|
|
|
getServerNumPortsRequired: RamCostConstants.GetServer,
|
|
|
|
getServerMaxRam: RamCostConstants.GetServerMaxRam,
|
|
|
|
getServerUsedRam: RamCostConstants.GetServerUsedRam,
|
|
|
|
serverExists: RamCostConstants.GetServer,
|
|
|
|
fileExists: RamCostConstants.FileExists,
|
|
|
|
isRunning: RamCostConstants.IsRunning,
|
|
|
|
getPurchasedServerLimit: RamCostConstants.GetPurchasedServerLimit,
|
|
|
|
getPurchasedServerMaxRam: RamCostConstants.GetPurchasedServerMaxRam,
|
|
|
|
getPurchasedServerCost: RamCostConstants.GetPurchaseServer,
|
2022-10-09 08:32:13 +02:00
|
|
|
getPurchasedServerUpgradeCost: 0.1,
|
|
|
|
upgradePurchasedServer: 0.25,
|
|
|
|
renamePurchasedServer: 2,
|
2022-12-30 02:28:53 +01:00
|
|
|
purchaseServer: RamCostConstants.PurchaseServer,
|
|
|
|
deleteServer: RamCostConstants.PurchaseServer,
|
|
|
|
getPurchasedServers: RamCostConstants.PurchaseServer,
|
2021-11-03 03:11:22 +01:00
|
|
|
write: 0,
|
2021-11-12 21:42:57 +01:00
|
|
|
tryWritePort: 0,
|
2021-11-03 03:11:22 +01:00
|
|
|
read: 0,
|
|
|
|
peek: 0,
|
|
|
|
clear: 0,
|
2021-11-04 01:19:52 +01:00
|
|
|
writePort: 0,
|
|
|
|
readPort: 0,
|
2021-11-03 03:11:22 +01:00
|
|
|
getPortHandle: 0,
|
2022-12-30 02:28:53 +01:00
|
|
|
rm: RamCostConstants.ReadWrite,
|
|
|
|
scriptRunning: RamCostConstants.ArbScript,
|
|
|
|
scriptKill: RamCostConstants.ArbScript,
|
2021-10-27 21:16:16 +02:00
|
|
|
getScriptName: 0,
|
2022-12-30 02:28:53 +01:00
|
|
|
getScriptRam: RamCostConstants.GetScript,
|
|
|
|
getHackTime: RamCostConstants.GetHackTime,
|
|
|
|
getGrowTime: RamCostConstants.GetHackTime,
|
|
|
|
getWeakenTime: RamCostConstants.GetHackTime,
|
|
|
|
getTotalScriptIncome: RamCostConstants.GetScript,
|
|
|
|
getScriptIncome: RamCostConstants.GetScript,
|
|
|
|
getTotalScriptExpGain: RamCostConstants.GetScript,
|
|
|
|
getScriptExpGain: RamCostConstants.GetScript,
|
|
|
|
getRunningScript: RamCostConstants.GetRunningScript,
|
2021-10-27 21:16:16 +02:00
|
|
|
nFormat: 0,
|
2022-03-19 04:21:52 +01:00
|
|
|
tFormat: 0,
|
2022-12-30 02:28:53 +01:00
|
|
|
getTimeSinceLastAug: RamCostConstants.GetHackTime,
|
2021-10-27 21:16:16 +02:00
|
|
|
prompt: 0,
|
|
|
|
wget: 0,
|
2022-12-30 02:28:53 +01:00
|
|
|
getFavorToDonate: RamCostConstants.GetFavorToDonate,
|
|
|
|
getPlayer: RamCostConstants.SingularityFn1 / 4,
|
|
|
|
getMoneySources: RamCostConstants.GetMoneySourcesCost,
|
2022-01-12 18:53:54 +01:00
|
|
|
mv: 0,
|
2022-03-18 21:35:56 +01:00
|
|
|
tail: 0,
|
|
|
|
toast: 0,
|
2022-08-30 00:07:17 +02:00
|
|
|
moveTail: 0,
|
|
|
|
resizeTail: 0,
|
2022-05-25 00:34:00 +02:00
|
|
|
closeTail: 0,
|
|
|
|
clearPort: 0,
|
|
|
|
openDevMenu: 0,
|
|
|
|
alert: 0,
|
|
|
|
flags: 0,
|
|
|
|
exploit: 0,
|
|
|
|
bypass: 0,
|
|
|
|
alterReality: 0,
|
|
|
|
rainbow: 0,
|
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: {
|
2022-08-23 22:01:34 +02:00
|
|
|
mockServer: 0,
|
|
|
|
mockPlayer: 0,
|
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,
|
2022-08-17 20:32:52 +02:00
|
|
|
},
|
|
|
|
work: {
|
2022-11-09 13:26:26 +01:00
|
|
|
crimeSuccessChance: 0,
|
2022-08-17 20:32:52 +02:00
|
|
|
crimeGains: 0,
|
2022-11-20 14:37:11 +01:00
|
|
|
gymGains: 0,
|
|
|
|
universityGains: 0,
|
2022-08-17 20:32:52 +02:00
|
|
|
factionGains: 0,
|
2022-11-06 23:27:04 +01:00
|
|
|
companyGains: 0,
|
2022-05-24 23:51:48 +02:00
|
|
|
},
|
|
|
|
},
|
2022-10-05 16:42:07 +02:00
|
|
|
} as const;
|
2022-05-25 00:34:00 +02:00
|
|
|
|
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;
|
|
|
|
}
|
2019-05-05 06:03:40 +02:00
|
|
|
|
2022-10-05 16:42:07 +02:00
|
|
|
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;
|
2019-05-05 06:03:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
const currType = typeof curr;
|
2021-09-05 01:09:30 +02:00
|
|
|
if (currType === "function" || currType === "number") {
|
|
|
|
break;
|
2019-05-05 06:03:40 +02:00
|
|
|
}
|
|
|
|
|
2022-10-05 16:42:07 +02:00
|
|
|
curr = curr[args[i] as keyof typeof curr];
|
2021-09-05 01:09:30 +02:00
|
|
|
}
|
2019-05-05 06:03:40 +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;
|
2019-05-05 06:03:40 +02:00
|
|
|
}
|