mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
BUGFIX: Fix Bladeburner city chaos reaching Infinity/NaN (#1588)
This commit is contained in:
parent
79bb0d289a
commit
385a9dc11d
@ -645,8 +645,8 @@ export class Bladeburner {
|
||||
}
|
||||
} else if (chance <= 0.7) {
|
||||
// Synthoid Riots (+chaos), 20%
|
||||
sourceCity.chaos += 1;
|
||||
sourceCity.chaos *= 1 + getRandomIntInclusive(5, 20) / 100;
|
||||
sourceCity.changeChaosByCount(1);
|
||||
sourceCity.changeChaosByPercentage(getRandomIntInclusive(5, 20));
|
||||
if (this.logging.events) {
|
||||
this.log("Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased");
|
||||
}
|
||||
@ -700,14 +700,14 @@ export class Bladeburner {
|
||||
};
|
||||
}
|
||||
|
||||
getDiplomacyEffectiveness(person: Person): number {
|
||||
// Returns a decimal by which the city's chaos level should be multiplied (e.g. 0.98)
|
||||
getDiplomacyPercentage(person: Person): number {
|
||||
// Returns a percentage by which the city's chaos level should be modified (e.g. 2 for 2%)
|
||||
const CharismaLinearFactor = 1e3;
|
||||
const CharismaExponentialFactor = 0.045;
|
||||
|
||||
const charismaEff =
|
||||
Math.pow(person.skills.charisma, CharismaExponentialFactor) + person.skills.charisma / CharismaLinearFactor;
|
||||
return (100 - charismaEff) / 100;
|
||||
return charismaEff;
|
||||
}
|
||||
|
||||
getRecruitmentSuccessChance(person: Person): number {
|
||||
@ -1155,15 +1155,12 @@ export class Bladeburner {
|
||||
break;
|
||||
}
|
||||
case BladeGeneralActionName.diplomacy: {
|
||||
const eff = this.getDiplomacyEffectiveness(person);
|
||||
this.getCurrentCity().chaos *= eff;
|
||||
if (this.getCurrentCity().chaos < 0) {
|
||||
this.getCurrentCity().chaos = 0;
|
||||
}
|
||||
const diplomacyPct = this.getDiplomacyPercentage(person);
|
||||
this.getCurrentCity().changeChaosByPercentage(-diplomacyPct);
|
||||
if (this.logging.general) {
|
||||
this.log(
|
||||
`${person.whoAmI()}: Diplomacy completed. Chaos levels in the current city fell by ${formatPercent(
|
||||
1 - eff,
|
||||
diplomacyPct / 100,
|
||||
)}.`,
|
||||
);
|
||||
}
|
||||
@ -1203,8 +1200,8 @@ export class Bladeburner {
|
||||
}
|
||||
for (const cityName of Object.values(CityName)) {
|
||||
const city = this.cities[cityName];
|
||||
city.chaos += 10;
|
||||
city.chaos += city.chaos / (Math.log(city.chaos) / Math.log(10));
|
||||
city.changeChaosByCount(10);
|
||||
city.changeChaosByCount(city.chaos / Math.log10(city.chaos));
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -50,10 +50,10 @@ export function BladeburnerDev({ bladeburner }: { bladeburner: Bladeburner }): R
|
||||
const wipeAllChaos = () => Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos = 0));
|
||||
const wipeActiveCityChaos = () => (bladeburner.cities[bladeburner.city].chaos = 0);
|
||||
const addAllChaos = (modify: number) => (chaos: number) => {
|
||||
Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos += chaos * modify));
|
||||
Object.values(CityName).forEach((city) => bladeburner.cities[city].changeChaosByCount(chaos * modify));
|
||||
};
|
||||
const addTonsAllChaos = () => {
|
||||
Object.values(CityName).forEach((city) => (bladeburner.cities[city].chaos += bigNumber));
|
||||
Object.values(CityName).forEach((city) => bladeburner.cities[city].changeChaosByCount(bigNumber));
|
||||
};
|
||||
|
||||
// Skill functions
|
||||
|
Loading…
Reference in New Issue
Block a user