feature: add probability for extra rep gain on pmc kills as pscav (!204)
Feel free to rename everything. We can also use the new function from randomutil and replace code block below on InsuranceController.ts ``` const maxRoll = 9999; const conversionFactor = 100; const returnChance = this.randomUtil.getInt(0, maxRoll) / conversionFactor; const traderReturnChance = this.insuranceConfig.returnChancePercent[traderId]; const roll = returnChance >= traderReturnChance; ``` I killed 2 PMCs with 100% chance and gained 0.07 rep (rounding issue probably somewhere else) ![image](/attachments/00f00922-eb18-4fdc-8958-129b680af704) Some JS problems :S ![image](/attachments/dcbeb1d1-2ee3-4809-890e-e19fe3190840) Implements: https://dev.sp-tarkov.com/SPT-AKI/Issues/issues/150 Co-authored-by: alimoncul <alimoncul@gmail.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/204 Co-authored-by: CZPZ <czpz@noreply.dev.sp-tarkov.com> Co-committed-by: CZPZ <czpz@noreply.dev.sp-tarkov.com>
This commit is contained in:
parent
c68c9a72fb
commit
1551a5e793
@ -35,5 +35,6 @@
|
||||
"carExtractBaseStandingGain": 0.4,
|
||||
"coopExtractBaseStandingGain": 0.25,
|
||||
"scavExtractGain": 0.01,
|
||||
"pmcKillProbabilityForScavGain": 0.2,
|
||||
"keepFiRSecureContainerOnDeath": false
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user