Update getUpdatedPrice

This commit is contained in:
Platinum 2024-02-06 19:18:43 +11:00
parent b85c2d01f6
commit 503b6ba3a2
4 changed files with 11 additions and 50 deletions

View File

@ -4,6 +4,6 @@
"bulletDamageMultiplierRedutionFactor": 0.7,
"enableDebug": false,
"excludedCategories": ["5b5f78b786f77447ed5636af", "5b47574386f77428ca22b33c"],
"gunPriceFallback": 100000,
"useTraderPriceForOffersIfHigher": true
"useTraderPriceForOffersIfHigher": true,
"handbookPriceMultiplier": 3
}

View File

@ -47,18 +47,6 @@ export function isBulletOrShotgunShell(item: ITemplateItem): boolean {
return props.ammoType === "bullet" || props.ammoType === "buckshot";
}
// Some blacklisted guns are very cheap because they don't have a flea price, just a handbook price. The ones listed below will get a much higher default price.
export function isGun(item: ITemplateItem): boolean {
const marksmanRiflesItemCategoryId = "5447b6194bdc2d67278b4567";
const assaultRiflesItemCategoryId = "5447b5f14bdc2d61278b4567";
const sniperRiflesItemCategoryId = "5447b6254bdc2dc3278b4568";
const smgsItemCategoryId = "5447b5e04bdc2d62278b4567";
const carbinesItemCategoryId = "5447b5fc4bdc2d87278b4567";
const gunCategories = [marksmanRiflesItemCategoryId, assaultRiflesItemCategoryId, sniperRiflesItemCategoryId, smgsItemCategoryId, carbinesItemCategoryId];
return gunCategories.includes(item._parent);
}
export function getUpdatedAmmoPrice(item: ITemplateItem): number {
const baselinePen = this.baselineBullet._props.PenetrationPower;
const baselineDamage = this.baselineBullet._props.Damage;
@ -82,8 +70,4 @@ export function getUpdatedAmmoPrice(item: ITemplateItem): number {
const damageMultiplier = baseDamageMultiplier + (1 - baseDamageMultiplier) * advancedConfig.bulletDamageMultiplierRedutionFactor;
return advancedConfig.baselineBulletPrice * penetrationMultiplier * damageMultiplier * config.blacklistedAmmoAdditionalPriceMultiplier;
}
export function getFallbackGunPrice(): number {
return advancedConfig.gunPriceFallback || 100000;
}

View File

@ -24,11 +24,11 @@ import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
import { IRagfairConfig } from "@spt-aki/models/spt/config/IRagfairConfig";
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { Category, HandbookItem } from "@spt-aki/models/eft/common/tables/IHandbookBase";
import { HandbookItem } from "@spt-aki/models/eft/common/tables/IHandbookBase";
import config from "../config.json";
import advancedConfig from "../advancedConfig.json";
import { getAttachmentCategoryIds, getFallbackGunPrice, getUpdatedAmmoPrice, isBulletOrShotgunShell, isGun } from "./helpers";
import { getAttachmentCategoryIds, getUpdatedAmmoPrice, isBulletOrShotgunShell } from "./helpers";
class TheBlacklistMod implements IPostDBLoadModAsync {
private logger: ILogger;
@ -95,7 +95,7 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
return;
}
prices[item._id] = this.getUpdatedPrice(item, prices);
prices[item._id] = this.getUpdatedPrice(handbookItem, item, prices);
if (!prices[item._id]) {
this.debug(`There are no flea prices for ${item._id} - ${item._name}!`);
@ -106,8 +106,6 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
this.blacklistedItemsUpdatedCount++;
}
});
this.logger.success(`${this.modName}: Success! Found ${this.blacklistedItemsUpdatedCount} blacklisted & ${this.nonBlacklistedItemsUpdatedCount} non-blacklisted items to update.`);
@ -186,19 +184,15 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
this.ammoPricesUpdatedCount++;
}
private getUpdatedPrice(item: ITemplateItem, prices: Record<string, number>): number | undefined {
const currentFleaPrice = prices[item._id];
let newPrice: number;
private getUpdatedPrice(handbookItem: HandbookItem, item: ITemplateItem, prices: Record<string, number>): number | undefined {
// If a flea price doesn't exist for an item, we can multiply its handbook price which usually exists.
if (prices[item._id] == null) {
const handbookPrice = handbookItem.Price;
if (isBulletOrShotgunShell(item)) {
newPrice = getUpdatedAmmoPrice(item);
} else if (isGun(item) && currentFleaPrice == null) {
newPrice = getFallbackGunPrice();
return handbookPrice * advancedConfig.handbookPriceMultiplier;
}
// Avoids NaN. Also we shouldn't have any prices of 0.
const price = newPrice || currentFleaPrice;
return price && price * config.blacklistedItemPriceMultiplier;
return prices[item._id] * config.blacklistedItemPriceMultiplier;
}
private debug(message: string) {

View File

@ -1,17 +0,0 @@
// 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/>.