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.
This commit is contained in:
Snarling 2023-03-30 16:31:50 -04:00 committed by GitHub
parent 8445af5f2b
commit b9e227509e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 9 deletions

@ -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) {

@ -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 {

@ -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 {