mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-18 23:38:35 +02:00
bladeburner slowly being converted to typescript, added ScriptHackMoneyGain multiplier which is the money you actually gain from script hacks, not money drained, important for BN8
This commit is contained in:
@@ -431,14 +431,18 @@ function NetscriptFunctions(workerScript) {
|
||||
}
|
||||
}
|
||||
|
||||
const checkBladeburnerAccess = function(func) {
|
||||
const accessDenied = `You do not ` +
|
||||
"currently have access to the Bladeburner API. To access the Bladeburner API " +
|
||||
"you must be employed at the Bladeburner division, AND you must either be in " +
|
||||
"BitNode-7 or have Source-File 7.";
|
||||
const hasAccess = Player.bladeburner instanceof Bladeburner && (Player.bitNodeN === 7 || Player.sourceFiles.some(a=>{return a.n === 7}));
|
||||
if(!hasAccess) {
|
||||
throw makeRuntimeErrorMsg(`bladeburner.${func}`, accessDenied);
|
||||
const checkBladeburnerAccess = function(func, skipjoined=false) {
|
||||
const apiAccess = (Player.bitNodeN === 7 || Player.sourceFiles.some(a=>{return a.n === 7}));
|
||||
if (!apiAccess) {
|
||||
const apiDenied = `You do not currently have access to the Bladeburner API. You must either be in BitNode-7 or have Source-File 7.`;
|
||||
throw makeRuntimeErrorMsg(`bladeburner.${func}`, apiDenied);
|
||||
}
|
||||
if (!skipjoined) {
|
||||
const bladeburnerAccess = Player.bladeburner instanceof Bladeburner;
|
||||
if(!bladeburnerAccess) {
|
||||
const bladeburnerDenied = `You must be a member of the Bladeburner division to use this API.`;
|
||||
throw makeRuntimeErrorMsg(`bladeburner.${func}`, bladeburnerDenied);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -707,17 +711,19 @@ function NetscriptFunctions(workerScript) {
|
||||
maxThreadNeeded = 1e6;
|
||||
}
|
||||
|
||||
let moneyGained = Math.floor(server.moneyAvailable * percentHacked) * threads;
|
||||
let moneyDrained = Math.floor(server.moneyAvailable * percentHacked) * threads;
|
||||
|
||||
// Over-the-top safety checks
|
||||
if (moneyGained <= 0) {
|
||||
moneyGained = 0;
|
||||
if (moneyDrained <= 0) {
|
||||
moneyDrained = 0;
|
||||
expGainedOnSuccess = expGainedOnFailure;
|
||||
}
|
||||
if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}
|
||||
server.moneyAvailable -= moneyGained;
|
||||
if (moneyDrained > server.moneyAvailable) {moneyDrained = server.moneyAvailable;}
|
||||
server.moneyAvailable -= moneyDrained;
|
||||
if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
|
||||
|
||||
const moneyGained = moneyDrained * BitNodeMultipliers.ScriptHackMoneyGain;
|
||||
|
||||
Player.gainMoney(moneyGained);
|
||||
workerScript.scriptRef.onlineMoneyMade += moneyGained;
|
||||
Player.scriptProdSinceLastAug += moneyGained;
|
||||
@@ -1681,7 +1687,8 @@ function NetscriptFunctions(workerScript) {
|
||||
checkTixApiAccess("buyStock");
|
||||
const stock = getStockFromSymbol(symbol, "buyStock");
|
||||
const res = buyStock(stock, shares, workerScript, { rerenderFn: displayStockMarketContent });
|
||||
|
||||
console.log(stock);
|
||||
console.log(res);
|
||||
return res ? stock.price : 0;
|
||||
},
|
||||
sellStock: function(symbol, shares) {
|
||||
@@ -3696,12 +3703,12 @@ function NetscriptFunctions(workerScript) {
|
||||
},
|
||||
joinBladeburnerFaction: function() {
|
||||
updateDynamicRam("joinBladeburnerFaction", getRamCost("bladeburner", "joinBladeburnerFaction"));
|
||||
checkBladeburnerAccess("joinBladeburnerFaction");
|
||||
checkBladeburnerAccess("joinBladeburnerFaction", true);
|
||||
return Player.bladeburner.joinBladeburnerFactionNetscriptFn(workerScript);
|
||||
},
|
||||
joinBladeburnerDivision: function() {
|
||||
updateDynamicRam("joinBladeburnerDivision", getRamCost("bladeburner", "joinBladeburnerDivision"));
|
||||
checkBladeburnerAccess("joinBladeburnerDivision");
|
||||
checkBladeburnerAccess("joinBladeburnerDivision", true);
|
||||
if ((Player.bitNodeN === 7 || SourceFileFlags[7] > 0)) {
|
||||
if (Player.bitNodeN === 8) { return false; }
|
||||
if (Player.bladeburner instanceof Bladeburner) {
|
||||
|
||||
Reference in New Issue
Block a user