Moveed handling of unreasonableModPrices
into ragfair code instead of on game start
Lowered weapon mod threshold from 9x to 6x
This commit is contained in:
parent
a16557b0e7
commit
791ebd4693
@ -303,8 +303,8 @@
|
|||||||
"5448fe124bdc2da5018b4567": {
|
"5448fe124bdc2da5018b4567": {
|
||||||
"itemType": "Weapon Mod",
|
"itemType": "Weapon Mod",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"handbookPriceOverMultiplier": 9,
|
"handbookPriceOverMultiplier": 6,
|
||||||
"newPriceHandbookMultiplier": 9
|
"newPriceHandbookMultiplier": 6
|
||||||
},
|
},
|
||||||
"57864a66245977548f04a81f": {
|
"57864a66245977548f04a81f": {
|
||||||
"itemType": "Electronics",
|
"itemType": "Electronics",
|
||||||
|
@ -158,11 +158,6 @@ export class ProfileFixerService
|
|||||||
|
|
||||||
this.fixNullTraderSalesSums(pmcProfile);
|
this.fixNullTraderSalesSums(pmcProfile);
|
||||||
this.updateProfileQuestDataValues(pmcProfile);
|
this.updateProfileQuestDataValues(pmcProfile);
|
||||||
|
|
||||||
if (Object.keys(this.ragfairConfig.dynamic.unreasonableModPrices).length > 0)
|
|
||||||
{
|
|
||||||
this.adjustUnreasonableModFleaPrices();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -391,47 +386,6 @@ export class ProfileFixerService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected adjustUnreasonableModFleaPrices(): void
|
|
||||||
{
|
|
||||||
const db = this.databaseServer.getTables();
|
|
||||||
const fleaPrices = db.templates.prices;
|
|
||||||
const handbookPrices = db.templates.handbook.Items;
|
|
||||||
|
|
||||||
for (const itemTypeKey in this.ragfairConfig.dynamic.unreasonableModPrices)
|
|
||||||
{
|
|
||||||
const details = this.ragfairConfig.dynamic.unreasonableModPrices[itemTypeKey];
|
|
||||||
if (!details?.enabled)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const itemTpl in fleaPrices)
|
|
||||||
{
|
|
||||||
if (!this.itemHelper.isOfBaseclass(itemTpl, itemTypeKey))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const itemHandbookPrice = handbookPrices.find((x) => x.Id === itemTpl);
|
|
||||||
if (!itemHandbookPrice)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fleaPrices[itemTpl] > (itemHandbookPrice.Price * details.handbookPriceOverMultiplier))
|
|
||||||
{
|
|
||||||
if (fleaPrices[itemTpl] <= 1)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Price is over limit, adjust
|
|
||||||
fleaPrices[itemTpl] = itemHandbookPrice.Price * details.newPriceHandbookMultiplier;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Add tag to profile to indicate when it was made
|
* Add tag to profile to indicate when it was made
|
||||||
* @param fullProfile
|
* @param fullProfile
|
||||||
|
@ -7,12 +7,13 @@ import { PresetHelper } from "@spt-aki/helpers/PresetHelper";
|
|||||||
import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
|
import { TraderHelper } from "@spt-aki/helpers/TraderHelper";
|
||||||
import { MinMax } from "@spt-aki/models/common/MinMax";
|
import { MinMax } from "@spt-aki/models/common/MinMax";
|
||||||
import { IPreset } from "@spt-aki/models/eft/common/IGlobals";
|
import { IPreset } from "@spt-aki/models/eft/common/IGlobals";
|
||||||
|
import { HandbookItem } from "@spt-aki/models/eft/common/tables/IHandbookBase";
|
||||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||||
import { IBarterScheme } from "@spt-aki/models/eft/common/tables/ITrader";
|
import { IBarterScheme } from "@spt-aki/models/eft/common/tables/ITrader";
|
||||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||||
import { Money } from "@spt-aki/models/enums/Money";
|
import { Money } from "@spt-aki/models/enums/Money";
|
||||||
import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig";
|
import { IRagfairConfig, IUnreasonableModPrices } from "@spt-aki/models/spt/config/IRagfairConfig";
|
||||||
import { IRagfairServerPrices } from "@spt-aki/models/spt/ragfair/IRagfairServerPrices";
|
import { IRagfairServerPrices } from "@spt-aki/models/spt/ragfair/IRagfairServerPrices";
|
||||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||||
@ -221,6 +222,8 @@ export class RagfairPriceService implements OnLoad
|
|||||||
*/
|
*/
|
||||||
public getDynamicOfferPriceForOffer(items: Item[], desiredCurrency: string, isPackOffer: boolean): number
|
public getDynamicOfferPriceForOffer(items: Item[], desiredCurrency: string, isPackOffer: boolean): number
|
||||||
{
|
{
|
||||||
|
const rootItem = items[0];
|
||||||
|
|
||||||
// Price to return
|
// Price to return
|
||||||
let price = 0;
|
let price = 0;
|
||||||
|
|
||||||
@ -278,6 +281,22 @@ export class RagfairPriceService implements OnLoad
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Skip items with children
|
||||||
|
if (items.length === 1)
|
||||||
|
{
|
||||||
|
const rootItemDb = this.itemHelper.getItem(rootItem._tpl)[1];
|
||||||
|
const unreasonableItemPriceChange = this.ragfairConfig.dynamic.unreasonableModPrices[rootItemDb._parent];
|
||||||
|
if (unreasonableItemPriceChange?.enabled)
|
||||||
|
{
|
||||||
|
price = this.adjustUnreasonablePrice(
|
||||||
|
this.databaseServer.getTables().templates.handbook.Items,
|
||||||
|
unreasonableItemPriceChange,
|
||||||
|
rootItem._tpl,
|
||||||
|
price,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const rangeValues = this.getOfferTypeRangeValues(isPreset, isPackOffer);
|
const rangeValues = this.getOfferTypeRangeValues(isPreset, isPackOffer);
|
||||||
price = this.randomiseOfferPrice(price, rangeValues);
|
price = this.randomiseOfferPrice(price, rangeValues);
|
||||||
|
|
||||||
@ -289,6 +308,43 @@ export class RagfairPriceService implements OnLoad
|
|||||||
return price;
|
return price;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* using data from config, adjust an items price to be relative to its handbook price
|
||||||
|
* @param handbookPrices Prices of items in handbook
|
||||||
|
* @param unreasonableItemChange Change object from config
|
||||||
|
* @param itemTpl Item being adjusted
|
||||||
|
* @param price Current price of item
|
||||||
|
* @returns Adjusted price of item
|
||||||
|
*/
|
||||||
|
protected adjustUnreasonablePrice(
|
||||||
|
handbookPrices: HandbookItem[],
|
||||||
|
unreasonableItemChange: IUnreasonableModPrices,
|
||||||
|
itemTpl: string,
|
||||||
|
price: number,
|
||||||
|
): number
|
||||||
|
{
|
||||||
|
const itemHandbookPrice = handbookPrices.find((handbookItem) => handbookItem.Id === itemTpl);
|
||||||
|
if (!itemHandbookPrice)
|
||||||
|
{
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flea price is over handbook price
|
||||||
|
if (price > (itemHandbookPrice.Price * unreasonableItemChange.handbookPriceOverMultiplier))
|
||||||
|
{
|
||||||
|
// Skip extreme values
|
||||||
|
if (price <= 1)
|
||||||
|
{
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Price is over limit, adjust
|
||||||
|
return itemHandbookPrice.Price * unreasonableItemChange.newPriceHandbookMultiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
return price;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get different min/max price multipliers for different offer types (preset/pack/default)
|
* Get different min/max price multipliers for different offer types (preset/pack/default)
|
||||||
* @param isPreset Offer is a preset
|
* @param isPreset Offer is a preset
|
||||||
|
Loading…
x
Reference in New Issue
Block a user