From b9e227509ef773ecfff6a51aa3f0d4f5a23f72cc Mon Sep 17 00:00:00 2001 From: Snarling <84951833+Snarling@users.noreply.github.com> Date: Thu, 30 Mar 2023 16:31:50 -0400 Subject: [PATCH] Minor gang stuff (#454) * Fix a weird mismatch between gangFormulas and actual gang for calculating wanted penalty * Gang respect will not fall below 1. Previously, ascension did clamp this at 1 but members dying in warfare allowed respect to reach 0. * Gang member earned respect is now calculated correctly. Previously the actual gains were calculated, then the respect was added to the gang, and then the member earnedRespect was incorrectly being re-calculated using the increased respect. Now the respect is recorded on the member during the first/actual calculation. --- src/Gang/Gang.ts | 8 ++------ src/Gang/GangMember.ts | 6 ++++-- src/Gang/formulas/formulas.ts | 2 +- 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/src/Gang/Gang.ts b/src/Gang/Gang.ts index c76acdf14..a7f2c5217 100644 --- a/src/Gang/Gang.ts +++ b/src/Gang/Gang.ts @@ -111,7 +111,7 @@ export class Gang { let wantedLevelGains = 0; let justice = 0; for (let i = 0; i < this.members.length; ++i) { - respectGains += this.members[i].calculateRespectGain(this); + respectGains += this.members[i].earnRespect(numCycles, this); moneyGains += this.members[i].calculateMoneyGain(this); const wantedLevelGain = this.members[i].calculateWantedLevelGain(this); wantedLevelGains += wantedLevelGain; @@ -134,10 +134,6 @@ export class Gang { fac.playerReputation += (Player.mults.faction_rep * gain * favorMult) / GangConstants.GangRespectToReputationRatio; - // Keep track of respect gained per member - for (let i = 0; i < this.members.length; ++i) { - this.members[i].recordEarnedRespect(numCycles, this); - } if (!(this.wanted === 1 && wantedLevelGains < 0)) { const oldWanted = this.wanted; let newWanted = oldWanted + wantedLevelGains * numCycles; @@ -335,7 +331,7 @@ export class Gang { // Player loses a percentage of total respect, plus whatever respect that member has earned const totalRespect = this.respect; const lostRespect = 0.05 * totalRespect + member.earnedRespect; - this.respect = Math.max(0, totalRespect - lostRespect); + this.respect = Math.max(1, totalRespect - lostRespect); for (let i = 0; i < this.members.length; ++i) { if (member.name === this.members[i].name) { diff --git a/src/Gang/GangMember.ts b/src/Gang/GangMember.ts index bd36ea5f4..bb4f1acc6 100644 --- a/src/Gang/GangMember.ts +++ b/src/Gang/GangMember.ts @@ -191,8 +191,10 @@ export class GangMember { this.calculateAscensionMult(this.cha_asc_points); } - recordEarnedRespect(numCycles = 1, gang: Gang): void { - this.earnedRespect += this.calculateRespectGain(gang) * numCycles; + earnRespect(numCycles = 1, gang: Gang): number { + const earnedRespect = this.calculateRespectGain(gang) * numCycles; + this.earnedRespect += earnedRespect; + return earnedRespect; } getGainedAscensionPoints(): IMults { diff --git a/src/Gang/formulas/formulas.ts b/src/Gang/formulas/formulas.ts index 566863348..8d05b9247 100644 --- a/src/Gang/formulas/formulas.ts +++ b/src/Gang/formulas/formulas.ts @@ -9,7 +9,7 @@ export interface FormulaGang { } export function calculateWantedPenalty(gang: FormulaGang): number { - return Math.max(gang.respect + 0.0001) / (gang.respect + gang.wantedLevel); + return gang.respect / (gang.respect + gang.wantedLevel); } export function calculateRespectGain(gang: FormulaGang, member: GangMember, task: GangMemberTask): number {