Improve fence multi-stack assort handling

This commit is contained in:
Dev 2024-02-16 13:41:16 +00:00
parent cfe321cf4b
commit 21caeed3db
2 changed files with 44 additions and 4 deletions

View File

@ -160,6 +160,22 @@
"5b432b965acfc47a8774094e": {
"min": 120,
"max": 352
},
"544fb25a4bdc2dfb738b4567": {
"min": 120,
"max": 700
},
"5e831507ea0a7c419c2f9bd9": {
"min": 5,
"max": 100
},
"5755356824597772cb798962": {
"min": 1,
"max": 400
},
"544fb3364bdc2d34748b456a": {
"min": 1,
"max": 800
}
},
"itemCategoryRoublePriceLimit": {
@ -183,8 +199,8 @@
"5447bedf4bdc2d87278b4568": 27008,
"5447bed64bdc2d97278b4568": 27007,
"5447b5e04bdc2d62278b4567": 33006,
"5447b5fc4bdc2d87278b4567": 42005,
"5447b5f14bdc2d61278b4567": 44004,
"5447b5fc4bdc2d87278b4567": 60000,
"5447b5f14bdc2d61278b4567": 60000,
"5447b5cf4bdc2d65278b4567": 28003,
"5447b6254bdc2dc3278b4568": 28002,
"5447e1d04bdc2dff2f8b4567": 19001,
@ -194,7 +210,7 @@
"590c745b86f7743cc433c5f2": 64000,
"57864bb7245977548b3b66c2": 85000,
"5448e5284bdc2dcb718b4567": 40001,
"5448e5284bdc2dcb718b4567": 59001,
"5a341c4086f77401f2541505": 35000,
"5d21f59b6dbe99052b54ef83": 45000,

View File

@ -46,6 +46,9 @@ export class FenceService
/** Hydrated on initial assort generation as part of generateFenceAssorts() */
protected desiredAssortCounts: IFenceAssortGenerationValues;
/** Items that have a multi-stack */
protected multiStackItems: Record<string, boolean> = {};
constructor(
@inject("WinstonLogger") protected logger: ILogger,
@inject("JsonUtil") protected jsonUtil: JsonUtil,
@ -554,6 +557,10 @@ export class FenceService
{
const priceLimits = this.traderConfig.fence.itemCategoryRoublePriceLimit;
const assortRootItems = baseFenceAssort.items.filter((x) => x.parentId === "hideout" && !x.upd?.sptPresetId);
// Clear cache of multi-stack items
this.multiStackItems = {};
for (let i = 0; i < assortCount; i++)
{
const chosenBaseAssortRoot = this.randomUtil.getArrayValue(assortRootItems);
@ -606,12 +613,29 @@ export class FenceService
this.itemHelper.remapRootItemId(desiredAssortItemAndChildrenClone);
const rootItemBeingAdded = desiredAssortItemAndChildrenClone[0];
this.randomiseItemUpdProperties(itemDbDetails, rootItemBeingAdded);
rootItemBeingAdded.upd.StackObjectsCount = this.getSingleItemStackCount(itemDbDetails);
// rootItemBeingAdded.upd.BuyRestrictionCurrent = 0;
// rootItemBeingAdded.upd.UnlimitedCount = false;
// Only randomise single items
if (rootItemBeingAdded.upd.StackObjectsCount === 1)
{
this.randomiseItemUpdProperties(itemDbDetails, rootItemBeingAdded);
}
else
{
// Already have multi-stack, skip
if (this.multiStackItems[itemDbDetails._id])
{
i--;
continue;
}
// Flag item as added as multi stack
this.multiStackItems[itemDbDetails._id] = true;
}
// Need to add mods to armors so they dont show as red in the trade screen
if (this.itemHelper.itemRequiresSoftInserts(rootItemBeingAdded._tpl))
{