Add 40% chance armors with plates do not have them whem listed on flea - mimics live behaviour

This commit is contained in:
Dev 2024-02-14 11:12:20 +00:00
parent 9403ff796e
commit d5217928c2
4 changed files with 48 additions and 3 deletions

View File

@ -265,6 +265,10 @@
"min": -2,
"max": 20
},
"armor": {
"removeRemovablePlateChance": 40,
"plateSlotIdToRemovePool": ["front_plate", "back_plate"]
},
"itemPriceMultiplier": {
"5737292724597765e5728562": 6,
"57372ac324597767001bc261": 5,

View File

@ -384,9 +384,7 @@ export class RagfairOfferGenerator
delete clonedAssort[0].parentId;
delete clonedAssort[0].slotId;
assortSingleOfferProcesses.push(
this.createSingleOfferForItem(clonedAssort, isPreset, itemDetails),
);
assortSingleOfferProcesses.push(this.createSingleOfferForItem(clonedAssort, isPreset, itemDetails));
}
await Promise.all(assortSingleOfferProcesses);
@ -465,8 +463,28 @@ export class RagfairOfferGenerator
itemWithChildren[0]._tpl,
this.ragfairConfig.dynamic.pack.itemTypeWhitelist,
);
const randomUserId = this.hashUtil.generate();
// Remove removable plates if % check passes
if (this.itemHelper.armorItemCanHoldMods(itemWithChildren[0]._tpl))
{
const armorConfig = this.ragfairConfig.dynamic.armor;
const shouldRemovePlates = this.randomUtil.getChance100(armorConfig.removeRemovablePlateChance);
if (shouldRemovePlates && this.itemHelper.armorItemHasRemovablePlateSlots(itemWithChildren[0]._tpl))
{
const offerItemPlatesToRemove = itemWithChildren.filter((item) =>
armorConfig.plateSlotIdToRemovePool.includes(item.slotId?.toLowerCase())
);
for (const plateItem of offerItemPlatesToRemove)
{
itemWithChildren.splice(itemWithChildren.indexOf(plateItem), 1);
}
}
}
let barterScheme: IBarterScheme[];
if (isPackOffer)
{

View File

@ -106,6 +106,19 @@ export class ItemHelper
return this.isOfBaseclasses(itemTpl, [BaseClasses.HEADWEAR, BaseClasses.VEST, BaseClasses.ARMOR]);
}
/**
* Does the pased in tpl have ability to hold removable plate items
* @param itemTpl item tpl to check for plate support
* @returns True when armor can hold plates
*/
public armorItemHasRemovablePlateSlots(itemTpl: string): boolean
{
const itemTemplate = this.getItem(itemTpl);
const plateSlotIds = this.getRemovablePlateSlotIds();
return itemTemplate[1]._props.Slots.some((slot) => plateSlotIds.includes(slot._name.toLowerCase()));
}
/**
* Does the provided item tpl require soft inserts to become a valid armor item
* @param itemTpl Item tpl to check

View File

@ -78,6 +78,8 @@ export interface Dynamic
nonStackableCount: MinMax;
/** Range of rating offers for items being listed */
rating: MinMax;
/** Armor specific flea settings */
armor: IArmorSettings;
/** A multipler to apply to individual tpls price just prior to item quality adjustment */
itemPriceMultiplier: Record<string, number>;
/** Percentages to sell offers in each currency */
@ -180,3 +182,11 @@ export interface IUnreasonableModPrices
/** The new multiplier for items found using above property, e.g. a value of 4 means set items price to 4x handbook price */
newPriceHandbookMultiplier: number;
}
export interface IArmorSettings
{
/** % chance / 100 that armor plates will be removed from an offer before listing */
removeRemovablePlateChance: number;
/** What slots are to be removed when removeRemovablePlateChance is true */
plateSlotIdToRemovePool: string[];
}