From 925d9b3f079c8b842959933fa2f1f70ed374fa06 Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 16 Nov 2023 11:38:55 +0000 Subject: [PATCH] Add fence rep gain on taking COOP extract Refactored fence rep handling code for Car extracts --- project/assets/configs/inraid.json | 3 +- project/src/controllers/MatchController.ts | 64 +++++++++++++++---- project/src/controllers/ProfileController.ts | 1 + .../src/models/eft/common/tables/IBotBase.ts | 8 +-- .../src/models/spt/config/IInRaidConfig.ts | 4 +- 5 files changed, 58 insertions(+), 22 deletions(-) diff --git a/project/assets/configs/inraid.json b/project/assets/configs/inraid.json index 0efebce0..7a0980d4 100644 --- a/project/assets/configs/inraid.json +++ b/project/assets/configs/inraid.json @@ -24,9 +24,10 @@ "tunnel_shared", "EXFIL_ScavCooperation", "Factory Gate", - "Exit_E10_coop" + "Exit_E10_coop" ], "carExtractBaseStandingGain": 0.4, + "coopExtractBaseStandingGain": 0.25, "scavExtractGain": 0.01, "keepFiRSecureContainerOnDeath": false } diff --git a/project/src/controllers/MatchController.ts b/project/src/controllers/MatchController.ts index 319fe499..bd4fa79e 100644 --- a/project/src/controllers/MatchController.ts +++ b/project/src/controllers/MatchController.ts @@ -198,6 +198,7 @@ export class MatchController if (extractName && this.extractWasViaCoop(extractName) && this.traderConfig.fence.coopExtractGift.sendGift) { + this.handleCoopExtract(pmcData, extractName); this.sendCoopTakenFenceMessage(sessionId); } } @@ -252,6 +253,37 @@ export class MatchController ); } + /** + * Handle when a player extracts using a coop extract - add rep to fence + * @param pmcData Profile + * @param extractName Name of extract taken + */ + protected handleCoopExtract(pmcData: IPmcData, extractName: string): void + { + if (!pmcData.CoopExtractCounts) + { + pmcData.CoopExtractCounts = {}; + } + + // Ensure key exists for extract + if (!(extractName in pmcData.CoopExtractCounts)) + { + pmcData.CoopExtractCounts[extractName] = 0; + } + + // Increment extract count value + pmcData.CoopExtractCounts[extractName] += 1; + + // Get new fence standing value + const newFenceStanding = this.getFenceStandingAfterExtract(pmcData, this.inraidConfig.coopExtractBaseStandingGain, pmcData.CoopExtractCounts[extractName]); + const fenceId: string = Traders.FENCE; + pmcData.TradersInfo[fenceId].standing = newFenceStanding; + + // Check if new standing has leveled up trader + this.traderHelper.lvlUp(fenceId, pmcData); + pmcData.TradersInfo[fenceId].loyaltyLevel = Math.max(pmcData.TradersInfo[fenceId].loyaltyLevel, 1); + } + /** * Was extract by car * @param extractName name of extract @@ -290,9 +322,13 @@ export class MatchController // Increment extract count value pmcData.CarExtractCounts[extractName] += 1; + // Not exact replica of Live behaviour + // Simplified for now, no real reason to do the whole (unconfirmed) extra 0.01 standing per day regeneration mechanic + const newFenceStanding = this.getFenceStandingAfterExtract(pmcData, this.inraidConfig.carExtractBaseStandingGain, pmcData.CarExtractCounts[extractName]); const fenceId: string = Traders.FENCE; - this.updateFenceStandingInProfile(pmcData, fenceId, extractName); - + pmcData.TradersInfo[fenceId].standing = newFenceStanding; + + // Check if new standing has leveled up trader this.traderHelper.lvlUp(fenceId, pmcData); pmcData.TradersInfo[fenceId].loyaltyLevel = Math.max(pmcData.TradersInfo[fenceId].loyaltyLevel, 1); @@ -300,25 +336,25 @@ export class MatchController } /** - * Update players fence trader standing value in profile - * @param pmcData Player profile - * @param fenceId Id of fence trader - * @param extractName Name of extract used + * Get the fence rep gain from using a car or coop extract + * @param pmcData Profile + * @param baseGain amount gained for the first extract + * @param extractCount Number of times extract was taken + * @returns Fence standing after taking extract */ - protected updateFenceStandingInProfile(pmcData: IPmcData, fenceId: string, extractName: string): void + protected getFenceStandingAfterExtract(pmcData: IPmcData, baseGain: number, extractCount: number): number { + // Get current standing + const fenceId: string = Traders.FENCE; let fenceStanding = Number(pmcData.TradersInfo[fenceId].standing); - // Not exact replica of Live behaviour - // Simplified for now, no real reason to do the whole (unconfirmed) extra 0.01 standing per day regeneration mechanic - const baseGain: number = this.inraidConfig.carExtractBaseStandingGain; - const extractCount: number = pmcData.CarExtractCounts[extractName]; - + // get standing after taking extract x times, x.xx format, gain from extract can be no smaller than 0.01 fenceStanding += Math.max(baseGain / extractCount, 0.01); - // Ensure fence loyalty level is not above/below the range -7 - 15 + // Ensure fence loyalty level is not above/below the range -7 to 15 const newFenceStanding = Math.min(Math.max(fenceStanding, -7), 15); this.logger.debug(`Old vs new fence standing: ${pmcData.TradersInfo[fenceId].standing}, ${newFenceStanding}`); - pmcData.TradersInfo[fenceId].standing = newFenceStanding; + + return Number(newFenceStanding.toFixed(2)); } } \ No newline at end of file diff --git a/project/src/controllers/ProfileController.ts b/project/src/controllers/ProfileController.ts index e5b1adc5..7caf7fad 100644 --- a/project/src/controllers/ProfileController.ts +++ b/project/src/controllers/ProfileController.ts @@ -144,6 +144,7 @@ export class ProfileController pmcData.Hideout.Seed = this.timeUtil.getTimestamp() + (8 * 60 * 60 * 24 * 365); // 8 years in future why? who knows, we saw it in live pmcData.RepeatableQuests = []; pmcData.CarExtractCounts = {}; + pmcData.CoopExtractCounts = {}; if (!pmcData.UnlockedInfo) { diff --git a/project/src/models/eft/common/tables/IBotBase.ts b/project/src/models/eft/common/tables/IBotBase.ts index f279df12..aa23dc97 100644 --- a/project/src/models/eft/common/tables/IBotBase.ts +++ b/project/src/models/eft/common/tables/IBotBase.ts @@ -31,7 +31,8 @@ export interface IBotBase RepeatableQuests: IPmcDataRepeatableQuest[] Bonuses: Bonus[] Notes: Notes - CarExtractCounts: CarExtractCounts + CarExtractCounts: Record + CoopExtractCounts: Record SurvivorClass: SurvivorClass WishList: string[] /** SPT specific property used during bot generation in raid */ @@ -445,11 +446,6 @@ export interface Notes Notes: Note[] } -export interface CarExtractCounts -{ - -} - export enum SurvivorClass { UNKNOWN = 0, diff --git a/project/src/models/spt/config/IInRaidConfig.ts b/project/src/models/spt/config/IInRaidConfig.ts index a0248170..9a4d5f16 100644 --- a/project/src/models/spt/config/IInRaidConfig.ts +++ b/project/src/models/spt/config/IInRaidConfig.ts @@ -12,8 +12,10 @@ export interface IInRaidConfig extends IBaseConfig carExtracts: string[] /** Names of coop extracts */ coopExtracts: string[] - /** Fene rep gain from a single car extract */ + /** Fence rep gain from a single car extract */ carExtractBaseStandingGain: number + /** Fence rep gain from a single coop extract */ + coopExtractBaseStandingGain: number /** Fence rep gain when successfully extracting as pscav */ scavExtractGain: number /** On death should items in your secure keep their Find in raid status regardless of how you finished the raid */