Added system to filter out ammos from fence by its penetration value

Removed redundant hard-coded ammos from blacklist
This commit is contained in:
Dev 2024-04-09 10:29:12 +01:00
parent 4830d474e7
commit 46d48c7531
3 changed files with 50 additions and 7 deletions

View File

@ -319,6 +319,7 @@
"left_side_plate": 75,
"right_side_plate": 75
},
"ammoMaxPenLimit": 20,
"blacklistSeasonalItems": true,
"blacklist": [
"5c164d2286f774194c5e69fa",
@ -343,12 +344,6 @@
"5422acb9af1c889c16000029",
"64d0b40fbe2eed70e254e2d4",
"5fc22d7c187fea44d52eda44",
"65702577cfc010a0f5006a2c",
"65702591c5d7d4cb4d07857c",
"6570240ecfc010a0f50069f2",
"65702606cfc010a0f5006a3e",
"65702640cfc010a0f5006a4d",
"657024011419851aef03e6f4",
"646372518610c40fc20204e8"
],
"coopExtractGift": {

View File

@ -74,7 +74,7 @@ export class FenceBaseAssortGenerator
}
}
// Only allow rigs with no slots (carrier rigs)
// Only allow rigs with no slots (carrier rigs)
if (this.itemHelper.isOfBaseclass(rootItemDb._id, BaseClasses.VEST) && rootItemDb._props.Slots.length > 0)
{
continue;
@ -95,6 +95,15 @@ export class FenceBaseAssortGenerator
upd: { StackObjectsCount: 9999999 },
}];
// Ensure ammo is not above penetration limit value
if (this.itemHelper.isOfBaseclasses(rootItemDb._id, [BaseClasses.AMMO_BOX, BaseClasses.AMMO]))
{
if (this.isAmmoAbovePenetrationLimit(rootItemDb))
{
continue;
}
}
if (this.itemHelper.isOfBaseclass(rootItemDb._id, BaseClasses.AMMO_BOX))
{
this.itemHelper.addCartridgesToAmmoBox(itemWithChildrenToAdd, rootItemDb);
@ -175,6 +184,43 @@ export class FenceBaseAssortGenerator
}
}
/**
* Check ammo in boxes + loose ammos has a penetration value above the configured value in trader.json / ammoMaxPenLimit
* @param rootItemDb Item to check penetration value of
* @returns True if penetration value is above limit set in config
*/
protected isAmmoAbovePenetrationLimit(rootItemDb: ITemplateItem): boolean
{
if (this.itemHelper.isOfBaseclass(rootItemDb._id, BaseClasses.AMMO_BOX))
{
// Get ammo inside box
const ammoTplInBox = rootItemDb._props.StackSlots[0]._props.filters[0].Filter[0];
const ammoItemDb = this.itemHelper.getItem(ammoTplInBox);
if (!ammoItemDb[0])
{
this.logger.warning(`Ammo: ${ammoTplInBox} not an item, skipping`);
return true;
}
// Check if above limit
if (ammoItemDb[1]._props.PenetrationPower > this.traderConfig.fence.ammoMaxPenLimit)
{
return true;
}
}
else if (this.itemHelper.isOfBaseclass(rootItemDb._id, BaseClasses.AMMO))
{
// Just a normal ammo, check if above limit
if (rootItemDb._props.PenetrationPower > this.traderConfig.fence.ammoMaxPenLimit)
{
return true;
}
}
return false;
}
protected getItemPrice(itemTpl: string, items: Item[]): number
{
return this.itemHelper.isOfBaseclass(itemTpl, BaseClasses.AMMO_BOX)

View File

@ -46,6 +46,8 @@ export interface FenceConfig
presetSlotsToRemoveChancePercent: Record<string, number>;
/** Block seasonal items from appearing when season is inactive */
blacklistSeasonalItems: boolean;
/** Max pen value allowed to be listed on flea - affects ammo + ammo boxes */
ammoMaxPenLimit: number;
blacklist: string[];
coopExtractGift: CoopExtractReward;
btrDeliveryExpireHours: number;