Remove attachment limit logic
This commit is contained in:
parent
643f777dc2
commit
91e02dc3aa
@ -11,12 +11,6 @@
|
|||||||
// Adds an extra offer for your current flea market rating bracket. So a new account at level 15 can create 3 offers instead of 2. Default is false. Extra amount is configurable in advancedConfigs.
|
// Adds an extra offer for your current flea market rating bracket. So a new account at level 15 can create 3 offers instead of 2. Default is false. Extra amount is configurable in advancedConfigs.
|
||||||
"addExtraOfferSlot": true,
|
"addExtraOfferSlot": true,
|
||||||
|
|
||||||
// Limits the flea price of many attachments as these prices can be inflated heavily by Gunsmith tasks in Live Tarkov. Default true.
|
|
||||||
"limitMaxPriceOfAttachments": true,
|
|
||||||
|
|
||||||
// If above is true, this is the max ratio of the flea price to the handbook price (generally double the trader sell price). Default 5.
|
|
||||||
"maxFleaPriceOfAttachmentsToHandbookPrice": 5,
|
|
||||||
|
|
||||||
// Balances the flea price of all ammo types, not just the blacklisted ammo types. Can be useful if you find some ammo prices are unbalanced, this generally makes them very balanced for what they do. Default false.
|
// Balances the flea price of all ammo types, not just the blacklisted ammo types. Can be useful if you find some ammo prices are unbalanced, this generally makes them very balanced for what they do. Default false.
|
||||||
"useBalancedPricingForAllAmmo": false,
|
"useBalancedPricingForAllAmmo": false,
|
||||||
|
|
||||||
|
@ -1,43 +1,5 @@
|
|||||||
// Copyright (C) 2024 Platinum
|
|
||||||
//
|
|
||||||
// This file is part of spt-the-blacklist.
|
|
||||||
//
|
|
||||||
// spt-the-blacklist is free software: you can redistribute it and/or modify
|
|
||||||
// it under the terms of the GNU General Public License as published by
|
|
||||||
// the Free Software Foundation, either version 3 of the License, or
|
|
||||||
// (at your option) any later version.
|
|
||||||
//
|
|
||||||
// spt-the-blacklist is distributed in the hope that it will be useful,
|
|
||||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
// GNU General Public License for more details.
|
|
||||||
//
|
|
||||||
// You should have received a copy of the GNU General Public License
|
|
||||||
// along with spt-the-blacklist. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import { Category } from "@spt-aki/models/eft/common/tables/IHandbookBase";
|
|
||||||
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
||||||
|
|
||||||
// There are so many child categories of attachments, this will return all categories using recursion so I don't have to type each ID.
|
|
||||||
export function getAttachmentCategoryIds(handbookCategories: Category[]): string[] {
|
|
||||||
const weaponPartsAndModsId = "5b5f71a686f77447ed5636ab";
|
|
||||||
const weaponPartsChildrenCategories = getChildCategoriesRecursively(handbookCategories, weaponPartsAndModsId);
|
|
||||||
const childrenIds = weaponPartsChildrenCategories.map(category => category.Id);
|
|
||||||
const attachmentCategoryIds = [weaponPartsAndModsId];
|
|
||||||
|
|
||||||
return attachmentCategoryIds.concat(childrenIds);
|
|
||||||
}
|
|
||||||
|
|
||||||
function getChildCategoriesRecursively(handbookCategories: Category[], parentId: string): Category[] {
|
|
||||||
const childCategories = handbookCategories.filter(category => category.ParentId === parentId);
|
|
||||||
const grandChildrenCategories = childCategories.reduce(
|
|
||||||
(memo, category) => memo.concat(getChildCategoriesRecursively(handbookCategories, category.Id)),
|
|
||||||
[]
|
|
||||||
);
|
|
||||||
|
|
||||||
return childCategories.concat(grandChildrenCategories);
|
|
||||||
}
|
|
||||||
|
|
||||||
export function isBulletOrShotgunShell(item: ITemplateItem): boolean {
|
export function isBulletOrShotgunShell(item: ITemplateItem): boolean {
|
||||||
const props = item._props;
|
const props = item._props;
|
||||||
|
|
||||||
|
32
src/mod.ts
32
src/mod.ts
@ -28,7 +28,7 @@ import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig";
|
|||||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||||
import { HandbookItem } from "@spt-aki/models/eft/common/tables/IHandbookBase";
|
import { HandbookItem } from "@spt-aki/models/eft/common/tables/IHandbookBase";
|
||||||
|
|
||||||
import { getAttachmentCategoryIds, isBulletOrShotgunShell } from "./helpers";
|
import { isBulletOrShotgunShell } from "./helpers";
|
||||||
import { IGlobals } from "@spt-aki/models/eft/common/IGlobals";
|
import { IGlobals } from "@spt-aki/models/eft/common/IGlobals";
|
||||||
|
|
||||||
class TheBlacklistMod implements IPostDBLoadModAsync {
|
class TheBlacklistMod implements IPostDBLoadModAsync {
|
||||||
@ -39,11 +39,7 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
|
|||||||
// We to adjust for pricing using a baseline when mods like SPT Realism are used
|
// We to adjust for pricing using a baseline when mods like SPT Realism are used
|
||||||
private baselineBullet: ITemplateItem;
|
private baselineBullet: ITemplateItem;
|
||||||
|
|
||||||
// Store the category IDs of all attachments in the handbook so we don't have to manually enter them in json
|
|
||||||
private attachmentCategoryIds: string[] = [];
|
|
||||||
|
|
||||||
private blacklistedItemsUpdatedCount = 0;
|
private blacklistedItemsUpdatedCount = 0;
|
||||||
private attachmentPriceLimitedCount = 0;
|
|
||||||
private nonBlacklistedItemsUpdatedCount = 0;
|
private nonBlacklistedItemsUpdatedCount = 0;
|
||||||
private ammoPricesUpdatedCount = 0;
|
private ammoPricesUpdatedCount = 0;
|
||||||
|
|
||||||
@ -70,10 +66,6 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
|
|||||||
this.updateRagfairConfig(ragfairConfig);
|
this.updateRagfairConfig(ragfairConfig);
|
||||||
this.updateGlobals(globals);
|
this.updateGlobals(globals);
|
||||||
|
|
||||||
if (this.config.limitMaxPriceOfAttachments) {
|
|
||||||
this.attachmentCategoryIds = getAttachmentCategoryIds(tables.templates.handbook.Categories);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Find all items to update by looping through handbook which is a better indicator of useable items.
|
// Find all items to update by looping through handbook which is a better indicator of useable items.
|
||||||
handbookItems.forEach(handbookItem => {
|
handbookItems.forEach(handbookItem => {
|
||||||
const item = itemTable[handbookItem.Id];
|
const item = itemTable[handbookItem.Id];
|
||||||
@ -86,10 +78,6 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.config.limitMaxPriceOfAttachments && this.attachmentCategoryIds.includes(handbookItem.ParentId)) {
|
|
||||||
this.updateAttachmentPrice(handbookItem, item, prices);
|
|
||||||
}
|
|
||||||
|
|
||||||
const itemProps = item._props;
|
const itemProps = item._props;
|
||||||
|
|
||||||
if (isBulletOrShotgunShell(item)) {
|
if (isBulletOrShotgunShell(item)) {
|
||||||
@ -122,9 +110,7 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.logger.success(`${this.modName}: Success! Found ${this.blacklistedItemsUpdatedCount} blacklisted & ${this.nonBlacklistedItemsUpdatedCount} non-blacklisted items to update.`);
|
this.logger.success(`${this.modName}: Success! Found ${this.blacklistedItemsUpdatedCount} blacklisted & ${this.nonBlacklistedItemsUpdatedCount} non-blacklisted items to update.`);
|
||||||
if (this.config.limitMaxPriceOfAttachments) {
|
|
||||||
this.logger.success(`${this.modName}: config.limitMaxPriceOfAttachments is enabled! Updated ${this.attachmentPriceLimitedCount} flea prices of attachments.`);
|
|
||||||
}
|
|
||||||
if (this.config.useBalancedPricingForAllAmmo) {
|
if (this.config.useBalancedPricingForAllAmmo) {
|
||||||
this.logger.success(`${this.modName}: config.useBalancedPricingForAllAmmo is enabled! Updated ${this.ammoPricesUpdatedCount} ammo prices.`);
|
this.logger.success(`${this.modName}: config.useBalancedPricingForAllAmmo is enabled! Updated ${this.ammoPricesUpdatedCount} ammo prices.`);
|
||||||
}
|
}
|
||||||
@ -197,20 +183,6 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private updateAttachmentPrice(handbookItem: HandbookItem, item: ITemplateItem, prices: Record<string, number>) {
|
|
||||||
const handbookPrice = handbookItem.Price;
|
|
||||||
const existingFleaPrice = prices[item._id];
|
|
||||||
const maxFleaPrice = handbookPrice * this.config.maxFleaPriceOfAttachmentsToHandbookPrice;
|
|
||||||
|
|
||||||
if (existingFleaPrice > maxFleaPrice) {
|
|
||||||
prices[item._id] = maxFleaPrice;
|
|
||||||
|
|
||||||
this.attachmentPriceLimitedCount++;
|
|
||||||
|
|
||||||
this.debug(`Attachment ${item._id} - ${item._name} was updated from ${existingFleaPrice} to ${maxFleaPrice}.`)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private updateAmmoPrice(item: ITemplateItem, prices: Record<string, number>) {
|
private updateAmmoPrice(item: ITemplateItem, prices: Record<string, number>) {
|
||||||
const itemProps = item._props;
|
const itemProps = item._props;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user