mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-02-17 02:22:23 +01:00
limit fortifying to the amount of hck thread you needed to drain the server
This commit is contained in:
@ -239,8 +239,9 @@ function NetscriptFunctions(workerScript) {
|
|||||||
var expGainedOnSuccess = scriptCalculateExpGain(server) * threads;
|
var expGainedOnSuccess = scriptCalculateExpGain(server) * threads;
|
||||||
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
var expGainedOnFailure = (expGainedOnSuccess / 4);
|
||||||
if (rand < hackChance) { //Success!
|
if (rand < hackChance) { //Success!
|
||||||
var moneyGained = scriptCalculatePercentMoneyHacked(server);
|
const percentHacked = scriptCalculatePercentMoneyHacked(server);
|
||||||
moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
|
const maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax))
|
||||||
|
let moneyGained = Math.floor(server.moneyAvailable * percentHacked) * threads;
|
||||||
|
|
||||||
//Over-the-top safety checks
|
//Over-the-top safety checks
|
||||||
if (moneyGained <= 0) {
|
if (moneyGained <= 0) {
|
||||||
@ -260,7 +261,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
|
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
|
||||||
workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
|
workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
|
||||||
}
|
}
|
||||||
server.fortify(CONSTANTS.ServerFortifyAmount * threads);
|
server.fortify(CONSTANTS.ServerFortifyAmount * Math.min(threads, maxThreadNeeded));
|
||||||
return Promise.resolve(moneyGained);
|
return Promise.resolve(moneyGained);
|
||||||
} else {
|
} else {
|
||||||
//Player only gains 25% exp for failure?
|
//Player only gains 25% exp for failure?
|
||||||
|
Reference in New Issue
Block a user