Fixed armors being listed with plates above the allowed level on flea
This commit is contained in:
parent
6378ac6f87
commit
27bc7cfa6e
@ -201,7 +201,8 @@
|
||||
"custom": [],
|
||||
"enableBsgList": true,
|
||||
"enableQuestList": true,
|
||||
"traderItems": false
|
||||
"traderItems": false,
|
||||
"armorPlateMaxProtectionLevel": 4
|
||||
},
|
||||
"unreasonableModPrices": {
|
||||
"5448fe124bdc2da5018b4567": {
|
||||
|
@ -98,12 +98,12 @@ export class RagfairAssortGenerator
|
||||
continue;
|
||||
}
|
||||
|
||||
results.push(this.createRagfairAssortItem(item._id, item._id)); // tplid and id must be the same so hideout recipe reworks work
|
||||
results.push(this.createRagfairAssortItem(item._id, item._id)); // tplid and id must be the same so hideout recipe rewards work
|
||||
}
|
||||
|
||||
for (const weapon of presets)
|
||||
for (const preset of presets)
|
||||
{
|
||||
results.push(this.createRagfairAssortItem(weapon._items[0]._tpl, weapon._id)); // Preset id must be passed through to ensure flea shows presets
|
||||
results.push(this.createRagfairAssortItem(preset._items[0]._tpl, preset._id)); // Preset id must be passed through to ensure flea shows preset
|
||||
}
|
||||
|
||||
return results;
|
||||
|
@ -357,7 +357,7 @@ export class RagfairOfferGenerator
|
||||
return;
|
||||
}
|
||||
|
||||
// Get item + sub-items if preset, otherwise just get item
|
||||
// Get item + sub-items (weapons + armors), otherwise just get item
|
||||
const itemWithChildren: Item[] = isPreset
|
||||
? this.ragfairServerHelper.getPresetItems(assortItem)
|
||||
: [
|
||||
@ -366,6 +366,12 @@ export class RagfairOfferGenerator
|
||||
),
|
||||
];
|
||||
|
||||
// Armor presets can hold plates above the allowed flea level, remove if necessary
|
||||
if (isPreset && this.ragfairConfig.dynamic.blacklist.enableBsgList)
|
||||
{
|
||||
this.removeBannedPlatesFromPreset(itemWithChildren, this.ragfairConfig.dynamic.blacklist.armorPlateMaxProtectionLevel);
|
||||
}
|
||||
|
||||
// Get number of offers to create
|
||||
// Limit to 1 offer when processing expired
|
||||
const offerCount = expiredOffers
|
||||
@ -376,16 +382,14 @@ export class RagfairOfferGenerator
|
||||
const assortSingleOfferProcesses = [];
|
||||
for (let index = 0; index < offerCount; index++)
|
||||
{
|
||||
delete itemWithChildren[0].parentId;
|
||||
delete itemWithChildren[0].slotId;
|
||||
|
||||
if (!isPreset)
|
||||
{
|
||||
// presets get unique id generated during getPresetItems() earlier
|
||||
// Presets get unique id generated during getPresetItems() earlier + would require regenerating all children to match
|
||||
itemWithChildren[0]._id = this.hashUtil.generate();
|
||||
}
|
||||
|
||||
delete itemWithChildren[0].parentId;
|
||||
delete itemWithChildren[0].slotId;
|
||||
|
||||
assortSingleOfferProcesses.push(this.createSingleOfferForItem(itemWithChildren, isPreset, itemDetails));
|
||||
}
|
||||
@ -393,6 +397,41 @@ export class RagfairOfferGenerator
|
||||
await Promise.all(assortSingleOfferProcesses);
|
||||
}
|
||||
|
||||
/**
|
||||
* iterate over an items chidren and look for plates above desired level and remove them
|
||||
* @param presetWithChildren preset to check for plates
|
||||
* @param plateProtectionLimit Max level of plates an armor can have without being removed
|
||||
* @returns True if plate removed
|
||||
*/
|
||||
protected removeBannedPlatesFromPreset(presetWithChildren: Item[], plateProtectionLimit: number): boolean
|
||||
{
|
||||
if (!this.itemHelper.armorItemCanHoldMods(presetWithChildren[0]._tpl))
|
||||
{
|
||||
// Cant hold armor inserts, skip
|
||||
return false;
|
||||
}
|
||||
|
||||
const plateSlots = presetWithChildren.filter(item => this.itemHelper.getRemovablePlateSlotIds().includes(item.slotId?.toLowerCase()));
|
||||
if (plateSlots.length === 0)
|
||||
{
|
||||
// Has no plate slots e.g. "left_side_plate", exit
|
||||
return false;
|
||||
}
|
||||
|
||||
let removedPlate = false;
|
||||
for (const plateSlot of plateSlots)
|
||||
{
|
||||
const plateArmorLevel = Number.parseInt(<string>this.itemHelper.getItem(plateSlot._tpl)[1]._props.armorClass) ?? 0;
|
||||
if (plateArmorLevel > plateProtectionLimit)
|
||||
{
|
||||
presetWithChildren.splice(presetWithChildren.indexOf(plateSlot), 1);
|
||||
removedPlate = true;
|
||||
}
|
||||
}
|
||||
|
||||
return removedPlate
|
||||
}
|
||||
|
||||
/**
|
||||
* Create one flea offer for a specific item
|
||||
* @param itemWithChildren Item to create offer for
|
||||
|
@ -1332,14 +1332,14 @@ export class ItemHelper
|
||||
*/
|
||||
public isRemovablePlateSlot(slotName: string): boolean
|
||||
{
|
||||
return this.getRevovablePlateSlotIds().includes(slotName.toLowerCase());
|
||||
return this.getRemovablePlateSlotIds().includes(slotName.toLowerCase());
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of slot names that hold removable plates
|
||||
* @returns Array of slot ids (e.g. front_plate)
|
||||
*/
|
||||
public getRevovablePlateSlotIds(): string[]
|
||||
public getRemovablePlateSlotIds(): string[]
|
||||
{
|
||||
return ["front_plate", "back_plate", "side_plate", "left_side_plate", "right_side_plate"];
|
||||
}
|
||||
|
@ -159,6 +159,8 @@ export interface Blacklist
|
||||
enableQuestList: boolean;
|
||||
/** Should trader items that are blacklisted by bsg be listed on flea */
|
||||
traderItems: boolean;
|
||||
/** Maximum level an armor plate can be found in a flea-listed armor item */
|
||||
armorPlateMaxProtectionLevel: number;
|
||||
}
|
||||
|
||||
export interface IUnreasonableModPrices
|
||||
|
Loading…
x
Reference in New Issue
Block a user