diff --git a/project/assets/configs/inraid.json b/project/assets/configs/inraid.json index e08176c6..5e836fe9 100644 --- a/project/assets/configs/inraid.json +++ b/project/assets/configs/inraid.json @@ -35,5 +35,6 @@ "carExtractBaseStandingGain": 0.4, "coopExtractBaseStandingGain": 0.25, "scavExtractGain": 0.01, + "pmcKillProbabilityForScavGain": 0.2, "keepFiRSecureContainerOnDeath": false } diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index c1138995..0e44b5c2 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -46,7 +46,7 @@ export class InraidController { protected airdropConfig: IAirdropConfig; protected btrConfig: IBTRConfig; - protected inraidConfig: IInRaidConfig; + protected inRaidConfig: IInRaidConfig; protected traderConfig: ITraderConfig; constructor( @@ -74,7 +74,7 @@ export class InraidController { this.airdropConfig = this.configServer.getConfig(ConfigTypes.AIRDROP); this.btrConfig = this.configServer.getConfig(ConfigTypes.BTR); - this.inraidConfig = this.configServer.getConfig(ConfigTypes.IN_RAID); + this.inRaidConfig = this.configServer.getConfig(ConfigTypes.IN_RAID); this.traderConfig = this.configServer.getConfig(ConfigTypes.TRADER); } @@ -100,7 +100,7 @@ export class InraidController { this.logger.debug(`Raid outcome: ${offraidData.exit}`); - if (!this.inraidConfig.save.loot) + if (!this.inRaidConfig.save.loot) { return; } @@ -486,7 +486,7 @@ export class InraidController // Successful extract with scav adds 0.01 standing if (offraidData.exit === PlayerRaidEndState.SURVIVED) { - fenceStanding += this.inraidConfig.scavExtractGain; + fenceStanding += this.inRaidConfig.scavExtractGain; } // Make standing changes to pmc profile @@ -502,7 +502,7 @@ export class InraidController */ public getInraidConfig(): IInRaidConfig { - return this.inraidConfig; + return this.inRaidConfig; } /** diff --git a/project/src/controllers/MatchController.ts b/project/src/controllers/MatchController.ts index 10f2d544..64f287b8 100644 --- a/project/src/controllers/MatchController.ts +++ b/project/src/controllers/MatchController.ts @@ -38,7 +38,7 @@ import { TimeUtil } from "@spt-aki/utils/TimeUtil"; export class MatchController { protected matchConfig: IMatchConfig; - protected inraidConfig: IInRaidConfig; + protected inRaidConfig: IInRaidConfig; protected traderConfig: ITraderConfig; protected pmcConfig: IPmcConfig; @@ -61,7 +61,7 @@ export class MatchController ) { this.matchConfig = this.configServer.getConfig(ConfigTypes.MATCH); - this.inraidConfig = this.configServer.getConfig(ConfigTypes.IN_RAID); + this.inRaidConfig = this.configServer.getConfig(ConfigTypes.IN_RAID); this.traderConfig = this.configServer.getConfig(ConfigTypes.TRADER); this.pmcConfig = this.configServer.getConfig(ConfigTypes.PMC); } @@ -213,7 +213,7 @@ export class MatchController return false; } - return (this.inraidConfig.coopExtracts.includes(extractName.trim())); + return (this.inRaidConfig.coopExtracts.includes(extractName.trim())); } protected sendCoopTakenFenceMessage(sessionId: string): void @@ -269,7 +269,7 @@ export class MatchController // Get new fence standing value const newFenceStanding = this.getFenceStandingAfterExtract( pmcData, - this.inraidConfig.coopExtractBaseStandingGain, + this.inRaidConfig.coopExtractBaseStandingGain, pmcData.CoopExtractCounts[extractName], ); const fenceId: string = Traders.FENCE; @@ -298,7 +298,7 @@ export class MatchController return true; } - return this.inraidConfig.carExtracts.includes(extractName.trim()); + return this.inRaidConfig.carExtracts.includes(extractName.trim()); } /** @@ -322,7 +322,7 @@ export class MatchController // 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, + this.inRaidConfig.carExtractBaseStandingGain, pmcData.CarExtractCounts[extractName], ); const fenceId: string = Traders.FENCE; diff --git a/project/src/helpers/InRaidHelper.ts b/project/src/helpers/InRaidHelper.ts index d200eccc..c081320b 100644 --- a/project/src/helpers/InRaidHelper.ts +++ b/project/src/helpers/InRaidHelper.ts @@ -22,6 +22,7 @@ import { LocalisationService } from "@spt-aki/services/LocalisationService"; import { ProfileFixerService } from "@spt-aki/services/ProfileFixerService"; import { JsonUtil } from "@spt-aki/utils/JsonUtil"; import { TimeUtil } from "@spt-aki/utils/TimeUtil"; +import { RandomUtil } from "@spt-aki/utils/RandomUtil"; import { ProfileHelper } from "./ProfileHelper"; @injectable() @@ -44,6 +45,7 @@ export class InRaidHelper @inject("LocalisationService") protected localisationService: LocalisationService, @inject("ProfileFixerService") protected profileFixerService: ProfileFixerService, @inject("ConfigServer") protected configServer: ConfigServer, + @inject("RandomUtil") protected randomUtil: RandomUtil ) { this.lostOnDeathConfig = this.configServer.getConfig(ConfigTypes.LOST_ON_DEATH); @@ -124,7 +126,15 @@ export class InRaidHelper } // PMCs - get by bear/usec - return botTypes[victim.Side.toLowerCase()]?.experience?.standingForKill; + let pmcStandingForKill = botTypes[victim.Side.toLowerCase()]?.experience?.standingForKill; + const pmcKillProbabilityForScavGain = this.inRaidConfig.pmcKillProbabilityForScavGain; + + if(this.randomUtil.rollForChanceProbability(pmcKillProbabilityForScavGain)) + { + pmcStandingForKill += this.inRaidConfig.scavExtractGain + } + + return pmcStandingForKill; } /** diff --git a/project/src/models/spt/config/IInRaidConfig.ts b/project/src/models/spt/config/IInRaidConfig.ts index 7f357594..201e2db1 100644 --- a/project/src/models/spt/config/IInRaidConfig.ts +++ b/project/src/models/spt/config/IInRaidConfig.ts @@ -18,6 +18,8 @@ export interface IInRaidConfig extends IBaseConfig coopExtractBaseStandingGain: number; /** Fence rep gain when successfully extracting as pscav */ scavExtractGain: number; + /** The likelihood of PMC eliminating a minimum of 2 scavs while you engage them as a pscav. */ + pmcKillProbabilityForScavGain: number; /** On death should items in your secure keep their Find in raid status regardless of how you finished the raid */ keepFiRSecureContainerOnDeath: boolean; } diff --git a/project/src/utils/RandomUtil.ts b/project/src/utils/RandomUtil.ts index 6ff7f7a3..4f3ae262 100644 --- a/project/src/utils/RandomUtil.ts +++ b/project/src/utils/RandomUtil.ts @@ -472,4 +472,21 @@ export class RandomUtil return array; } + + /** + * Rolls for a probability based on chance + * @param number Probability Chance as float (0-1) + * @returns If roll succeed or not + * @example + * rollForChanceProbability(0.25); // returns true 25% probability + */ + public rollForChanceProbability(probabilityChance: number): boolean + { + const maxRoll = 9999; + + // Roll a number between 0 and 1 + const rolledChance = this.getInt(0, maxRoll) / 10000; + + return rolledChance <= probabilityChance; + } }