Fix Bonuses in various Services using Find and not filter.
This commit is contained in:
parent
2a52af1275
commit
7b835f1501
@ -28,6 +28,7 @@ import { IAddItemDirectRequest } from "@spt/models/eft/inventory/IAddItemDirectR
|
|||||||
import { IAddItemsDirectRequest } from "@spt/models/eft/inventory/IAddItemsDirectRequest";
|
import { IAddItemsDirectRequest } from "@spt/models/eft/inventory/IAddItemsDirectRequest";
|
||||||
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
import { IItemEventRouterResponse } from "@spt/models/eft/itemEvent/IItemEventRouterResponse";
|
||||||
import { BackendErrorCodes } from "@spt/models/enums/BackendErrorCodes";
|
import { BackendErrorCodes } from "@spt/models/enums/BackendErrorCodes";
|
||||||
|
import { BonusType } from "@spt/models/enums/BonusType";
|
||||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||||
import { HideoutAreas } from "@spt/models/enums/HideoutAreas";
|
import { HideoutAreas } from "@spt/models/enums/HideoutAreas";
|
||||||
import { SkillTypes } from "@spt/models/enums/SkillTypes";
|
import { SkillTypes } from "@spt/models/enums/SkillTypes";
|
||||||
@ -224,6 +225,14 @@ export class HideoutController {
|
|||||||
this.checkAndUpgradeWall(pmcData);
|
this.checkAndUpgradeWall(pmcData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 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 buffs
|
||||||
|
pmcData.Bonuses = pmcData.Bonuses.filter(bonus => bonus.type !== BonusType.FUEL_CONSUMPTION && bonus.value >= -10 && bonus.value <= 0);
|
||||||
|
}
|
||||||
|
|
||||||
// Add Skill Points Per Area Upgrade
|
// Add Skill Points Per Area Upgrade
|
||||||
this.profileHelper.addSkillPointsToPlayer(
|
this.profileHelper.addSkillPointsToPlayer(
|
||||||
pmcData,
|
pmcData,
|
||||||
|
@ -419,11 +419,11 @@ export class HideoutHelper {
|
|||||||
this.databaseService.getHideout().settings.generatorFuelFlowRate *
|
this.databaseService.getHideout().settings.generatorFuelFlowRate *
|
||||||
this.getTimeElapsedSinceLastServerTick(pmcData, isGeneratorOn);
|
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
|
// 0 to 1
|
||||||
const fuelConsumptionBonusMultipler =
|
const fuelConsumptionBonusMultipler = (profileFuelConsomptionBonusSum + 100) / 100;
|
||||||
(profileFuelConsumptionBonus ? Math.abs(profileFuelConsumptionBonus.value) : 0) / 100;
|
|
||||||
|
|
||||||
// 0 to 1
|
// 0 to 1
|
||||||
const hideoutManagementConsumptionBonusMultipler = this.getHideoutManagementConsumptionBonus(pmcData);
|
const hideoutManagementConsumptionBonusMultipler = this.getHideoutManagementConsumptionBonus(pmcData);
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
import { ItemHelper } from "@spt/helpers/ItemHelper";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
import { TraderHelper } from "@spt/helpers/TraderHelper";
|
||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||||
@ -35,6 +36,7 @@ export class InsuranceService {
|
|||||||
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
@inject("TimeUtil") protected timeUtil: TimeUtil,
|
||||||
@inject("SaveServer") protected saveServer: SaveServer,
|
@inject("SaveServer") protected saveServer: SaveServer,
|
||||||
@inject("TraderHelper") protected traderHelper: TraderHelper,
|
@inject("TraderHelper") protected traderHelper: TraderHelper,
|
||||||
|
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||||
@inject("LocalisationService") protected localisationService: LocalisationService,
|
@inject("LocalisationService") protected localisationService: LocalisationService,
|
||||||
@inject("MailSendService") protected mailSendService: MailSendService,
|
@inject("MailSendService") protected mailSendService: MailSendService,
|
||||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||||
@ -138,11 +140,11 @@ export class InsuranceService {
|
|||||||
return this.timeUtil.getTimestamp() + this.insuranceConfig.returnTimeOverrideSeconds;
|
return this.timeUtil.getTimestamp() + this.insuranceConfig.returnTimeOverrideSeconds;
|
||||||
}
|
}
|
||||||
|
|
||||||
const insuranceReturnTimeBonus = pmcData.Bonuses.find(
|
const insuranceReturnTimeBonusSum = this.profileHelper.getBonusValueFromProfile(
|
||||||
(bonus) => bonus.type === BonusType.INSURANCE_RETURN_TIME,
|
pmcData,
|
||||||
|
BonusType.INSURANCE_RETURN_TIME,
|
||||||
);
|
);
|
||||||
const insuranceReturnTimeBonusPercent =
|
const insuranceReturnTimeBonusPercent = 1.0 - (insuranceReturnTimeBonusSum + 100) / 100;
|
||||||
1.0 - (insuranceReturnTimeBonus ? Math.abs(insuranceReturnTimeBonus.value ?? 0) : 0) / 100;
|
|
||||||
|
|
||||||
const traderMinReturnAsSeconds = trader.insurance.min_return_hour * TimeUtil.ONE_HOUR_AS_SECONDS;
|
const traderMinReturnAsSeconds = trader.insurance.min_return_hour * TimeUtil.ONE_HOUR_AS_SECONDS;
|
||||||
const traderMaxReturnAsSeconds = trader.insurance.max_return_hour * TimeUtil.ONE_HOUR_AS_SECONDS;
|
const traderMaxReturnAsSeconds = trader.insurance.max_return_hour * TimeUtil.ONE_HOUR_AS_SECONDS;
|
||||||
|
@ -8,6 +8,7 @@ import { ILogger } from "@spt/models/spt/utils/ILogger";
|
|||||||
import { DatabaseService } from "@spt/services/DatabaseService";
|
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||||
import { RagfairPriceService } from "@spt/services/RagfairPriceService";
|
import { RagfairPriceService } from "@spt/services/RagfairPriceService";
|
||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
|
import { ProfileHelper } from "@spt/helpers/ProfileHelper";
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class RagfairTaxService {
|
export class RagfairTaxService {
|
||||||
@ -18,6 +19,7 @@ export class RagfairTaxService {
|
|||||||
@inject("DatabaseService") protected databaseService: DatabaseService,
|
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||||
@inject("RagfairPriceService") protected ragfairPriceService: RagfairPriceService,
|
@inject("RagfairPriceService") protected ragfairPriceService: RagfairPriceService,
|
||||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||||
|
@inject("ProfileHelper") protected profileHelper: ProfileHelper,
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
public storeClientOfferTaxValue(sessionId: string, offer: IStorePlayerOfferTaxAmountRequestData): void {
|
public storeClientOfferTaxValue(sessionId: string, offer: IStorePlayerOfferTaxAmountRequestData): void {
|
||||||
@ -64,7 +66,7 @@ export class RagfairTaxService {
|
|||||||
const requirementsPrice = requirementsValue * (sellInOnePiece ? 1 : offerItemCount);
|
const requirementsPrice = requirementsValue * (sellInOnePiece ? 1 : offerItemCount);
|
||||||
|
|
||||||
const itemTaxMult = globals.config.RagFair.communityItemTax / 100.0;
|
const itemTaxMult = globals.config.RagFair.communityItemTax / 100.0;
|
||||||
const requirementTaxMult = globals.config.RagFair.communityRequirementTax / 100.0;
|
const requirementTaxMult = globals!.config.RagFair.communityRequirementTax / 100.0;
|
||||||
|
|
||||||
let itemPriceMult = Math.log10(itemWorth / requirementsPrice);
|
let itemPriceMult = Math.log10(itemWorth / requirementsPrice);
|
||||||
let requirementPriceMult = Math.log10(requirementsPrice / itemWorth);
|
let requirementPriceMult = Math.log10(requirementsPrice / itemWorth);
|
||||||
@ -78,12 +80,12 @@ export class RagfairTaxService {
|
|||||||
itemPriceMult = 4 ** itemPriceMult;
|
itemPriceMult = 4 ** itemPriceMult;
|
||||||
requirementPriceMult = 4 ** requirementPriceMult;
|
requirementPriceMult = 4 ** requirementPriceMult;
|
||||||
|
|
||||||
const hideoutFleaTaxDiscountBonus = pmcData.Bonuses.find((b) => b.type === BonusType.RAGFAIR_COMMISSION);
|
const hideoutFleaTaxDiscountBonusSum = this.profileHelper.getBonusValueFromProfile(pmcData,BonusType.RAGFAIR_COMMISSION);
|
||||||
const taxDiscountPercent = hideoutFleaTaxDiscountBonus ? Math.abs(hideoutFleaTaxDiscountBonus.value ?? 0) : 0;
|
const taxDiscountPercent = (hideoutFleaTaxDiscountBonusSum + 100) / 100.0;
|
||||||
|
|
||||||
const tax =
|
const tax =
|
||||||
itemWorth * itemTaxMult * itemPriceMult + requirementsPrice * requirementTaxMult * requirementPriceMult;
|
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
|
const itemComissionMult = itemTemplate._props.RagFairCommissionModifier
|
||||||
? itemTemplate._props.RagFairCommissionModifier
|
? itemTemplate._props.RagFairCommissionModifier
|
||||||
: 1;
|
: 1;
|
||||||
@ -123,7 +125,7 @@ export class RagfairTaxService {
|
|||||||
worth += this.calculateItemWorth(
|
worth += this.calculateItemWorth(
|
||||||
child,
|
child,
|
||||||
this.itemHelper.getItem(child._tpl)[1],
|
this.itemHelper.getItem(child._tpl)[1],
|
||||||
child.upd.StackObjectsCount,
|
child.upd!.StackObjectsCount!,
|
||||||
pmcData,
|
pmcData,
|
||||||
false,
|
false,
|
||||||
);
|
);
|
||||||
@ -131,39 +133,39 @@ export class RagfairTaxService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("Dogtag" in item.upd) {
|
if ("Dogtag" in item.upd!) {
|
||||||
worth *= item.upd.Dogtag.Level;
|
worth *= item.upd!.Dogtag!.Level;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("Key" in item.upd && (itemTemplate._props.MaximumNumberOfUsage ?? 0) > 0) {
|
if ("Key" in item.upd! && (itemTemplate._props.MaximumNumberOfUsage ?? 0) > 0) {
|
||||||
worth =
|
worth =
|
||||||
(worth / itemTemplate._props.MaximumNumberOfUsage) *
|
(worth / itemTemplate._props.MaximumNumberOfUsage!) *
|
||||||
(itemTemplate._props.MaximumNumberOfUsage - item.upd.Key.NumberOfUsages);
|
(itemTemplate._props.MaximumNumberOfUsage! - item.upd!.Key!.NumberOfUsages);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("Resource" in item.upd && itemTemplate._props.MaxResource > 0) {
|
if ("Resource" in item.upd! && itemTemplate._props.MaxResource! > 0) {
|
||||||
worth = worth * 0.1 + ((worth * 0.9) / itemTemplate._props.MaxResource) * item.upd.Resource.Value;
|
worth = worth * 0.1 + ((worth * 0.9) / itemTemplate._props.MaxResource!) * item.upd.Resource!.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("SideEffect" in item.upd && itemTemplate._props.MaxResource > 0) {
|
if ("SideEffect" in item.upd! && itemTemplate._props.MaxResource! > 0) {
|
||||||
worth = worth * 0.1 + ((worth * 0.9) / itemTemplate._props.MaxResource) * item.upd.SideEffect.Value;
|
worth = worth * 0.1 + ((worth * 0.9) / itemTemplate._props.MaxResource!) * item.upd.SideEffect!.Value;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("MedKit" in item.upd && itemTemplate._props.MaxHpResource > 0) {
|
if ("MedKit" in item.upd! && itemTemplate._props.MaxHpResource! > 0) {
|
||||||
worth = (worth / itemTemplate._props.MaxHpResource) * item.upd.MedKit.HpResource;
|
worth = (worth / itemTemplate._props.MaxHpResource!) * item.upd.MedKit!.HpResource;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("FoodDrink" in item.upd && itemTemplate._props.MaxResource > 0) {
|
if ("FoodDrink" in item.upd! && itemTemplate._props.MaxResource! > 0) {
|
||||||
worth = (worth / itemTemplate._props.MaxResource) * item.upd.FoodDrink.HpPercent;
|
worth = (worth / itemTemplate._props.MaxResource!) * item.upd.FoodDrink!.HpPercent;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("Repairable" in item.upd && <number>itemTemplate._props.armorClass > 0) {
|
if ("Repairable" in item.upd! && <number>itemTemplate._props.armorClass > 0) {
|
||||||
const num2 = 0.01 * 0.0 ** item.upd.Repairable.MaxDurability;
|
const num2 = 0.01 * 0.0 ** item.upd.Repairable!.MaxDurability;
|
||||||
worth =
|
worth =
|
||||||
worth * (item.upd.Repairable.MaxDurability / itemTemplate._props.Durability - num2) -
|
worth * (item.upd.Repairable!.MaxDurability / itemTemplate._props.Durability! - num2) -
|
||||||
Math.floor(
|
Math.floor(
|
||||||
itemTemplate._props.RepairCost *
|
itemTemplate._props.RepairCost! *
|
||||||
(item.upd.Repairable.MaxDurability - item.upd.Repairable.Durability),
|
(item.upd.Repairable!.MaxDurability - item.upd.Repairable!.Durability),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user