Fix Bonuses in various Services using Find and not filter. (!393)

Fix for SPT/Issues#743
FuelConsumptionBonus only looked for the first value, not all Bonuses a PMC has.
TODO: Find a way for the Broken Wall to not give too much bonus when a player mops the floor in between the stages. Resulting with too much negative bonus once the broken wall is completed.

Co-authored-by: Dev <dev@dev.sp-tarkov.com>
Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/393
Co-authored-by: TetrisGG <dmiller2606@gmail.com>
Co-committed-by: TetrisGG <dmiller2606@gmail.com>
This commit is contained in:
TetrisGG 2024-08-09 08:50:57 +00:00 committed by chomp
parent 15a83a0da3
commit 915c96d40c
4 changed files with 16 additions and 14 deletions

View File

@ -225,11 +225,12 @@ export class HideoutController {
this.checkAndUpgradeWall(pmcData);
}
// Cleanup temporary fuel usage debuffs if wall is complete
// Cleanup temporary fuel usage buffs from mopping floor if wall is complete as it would result in too many bonuses
// TODO: Clean up all buffs from mopping floor.
if (profileHideoutArea.type === HideoutAreas.EMERGENCY_WALL && profileHideoutArea.level === 6)
{
// Get everything except specific fuel consumption debuffs
pmcData.Bonuses = pmcData.Bonuses.filter(bonus => bonus.type !== BonusType.FUEL_CONSUMPTION && bonus.value === 5);
// Get everything except specific fuel consumption buffs
pmcData.Bonuses = pmcData.Bonuses.filter(bonus => bonus.type !== BonusType.FUEL_CONSUMPTION && bonus.value >= -10 && bonus.value <= 0);
}
// Add Skill Points Per Area Upgrade

View File

@ -419,11 +419,11 @@ export class HideoutHelper {
this.databaseService.getHideout().settings.generatorFuelFlowRate *
this.getTimeElapsedSinceLastServerTick(pmcData, isGeneratorOn);
const profileFuelConsumptionBonus = pmcData.Bonuses.find((bonus) => bonus.type === BonusType.FUEL_CONSUMPTION);
// Get all fuel consumption bonuses, returns an empty array if none found
const profileFuelConsomptionBonusSum = this.profileHelper.getBonusValueFromProfile(pmcData,BonusType.FUEL_CONSUMPTION)
// 0 to 1
const fuelConsumptionBonusMultipler =
(profileFuelConsumptionBonus ? Math.abs(profileFuelConsumptionBonus.value) : 0) / 100;
const fuelConsumptionBonusMultipler = (profileFuelConsomptionBonusSum + 100) / 100;
// 0 to 1
const hideoutManagementConsumptionBonusMultipler = this.getHideoutManagementConsumptionBonus(pmcData);

View File

@ -27,6 +27,7 @@ import { RandomUtil } from "@spt/utils/RandomUtil";
import { TimeUtil } from "@spt/utils/TimeUtil";
import { ICloner } from "@spt/utils/cloners/ICloner";
import { inject, injectable } from "tsyringe";
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
@injectable()
export class InsuranceService {
@ -51,6 +52,7 @@ export class InsuranceService {
@inject("MailSendService") protected mailSendService: MailSendService,
@inject("ConfigServer") protected configServer: ConfigServer,
@inject("PrimaryCloner") protected cloner: ICloner,
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
) {
this.insuranceConfig = this.configServer.getConfig(ConfigTypes.INSURANCE);
this.lostOnDeathConfig = this.configServer.getConfig(ConfigTypes.LOST_ON_DEATH);
@ -179,11 +181,8 @@ export class InsuranceService {
return this.timeUtil.getTimestamp() + this.insuranceConfig.returnTimeOverrideSeconds;
}
const insuranceReturnTimeBonus = pmcData.Bonuses.find(
(bonus) => bonus.type === BonusType.INSURANCE_RETURN_TIME,
);
const insuranceReturnTimeBonusPercent =
1.0 - (insuranceReturnTimeBonus ? Math.abs(insuranceReturnTimeBonus!.value ?? 0) : 0) / 100;
const insuranceReturnTimeBonusSum = this.profileHelper.getBonusValueFromProfile(pmcData,BonusType.INSURANCE_RETURN_TIME);
const insuranceReturnTimeBonusPercent = 1.0 - ((insuranceReturnTimeBonusSum + 100) / 100);
const traderMinReturnAsSeconds = trader.insurance.min_return_hour * TimeUtil.ONE_HOUR_AS_SECONDS;
const traderMaxReturnAsSeconds = trader.insurance.max_return_hour * TimeUtil.ONE_HOUR_AS_SECONDS;

View File

@ -8,6 +8,7 @@ import { ILogger } from "@spt/models/spt/utils/ILogger";
import { DatabaseService } from "@spt/services/DatabaseService";
import { RagfairPriceService } from "@spt/services/RagfairPriceService";
import { inject, injectable } from "tsyringe";
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
@injectable()
export class RagfairTaxService {
@ -18,6 +19,7 @@ export class RagfairTaxService {
@inject("DatabaseService") protected databaseService: DatabaseService,
@inject("RagfairPriceService") protected ragfairPriceService: RagfairPriceService,
@inject("ItemHelper") protected itemHelper: ItemHelper,
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
) {}
public storeClientOfferTaxValue(sessionId: string, offer: IStorePlayerOfferTaxAmountRequestData): void {
@ -78,12 +80,12 @@ export class RagfairTaxService {
itemPriceMult = 4 ** itemPriceMult;
requirementPriceMult = 4 ** requirementPriceMult;
const hideoutFleaTaxDiscountBonus = pmcData.Bonuses.find((b) => b.type === BonusType.RAGFAIR_COMMISSION);
const taxDiscountPercent = hideoutFleaTaxDiscountBonus ? Math.abs(hideoutFleaTaxDiscountBonus!.value ?? 0) : 0;
const hideoutFleaTaxDiscountBonusSum = this.profileHelper.getBonusValueFromProfile(pmcData,BonusType.RAGFAIR_COMMISSION);
const taxDiscountPercent = (hideoutFleaTaxDiscountBonusSum + 100) / 100.0;
const tax =
itemWorth * itemTaxMult * itemPriceMult + requirementsPrice * requirementTaxMult * requirementPriceMult;
const discountedTax = tax * (1.0 - taxDiscountPercent / 100.0);
const discountedTax = tax * (1.0 - taxDiscountPercent);
const itemComissionMult = itemTemplate._props.RagFairCommissionModifier
? itemTemplate._props.RagFairCommissionModifier
: 1;