From a82a41f3df268b0c33fc58c92bfb424183a40a2f Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 29 Sep 2024 17:29:08 +0100 Subject: [PATCH] Tiered flea: Added system to limit single items by tpl to player level Added: Oakley Mechanism - level 32 Tri-zip - level 30 Beta 2 - level 30 Gruppa 99 T30 - level 30 Eberlestock F5 - level 30 Poyas-A - level 26 Velocity Systems MPPV - level 25 labs keycard - level 30 Sledgehammer - level 25 ledx - level 25 Graphics card - level 35 --- project/assets/configs/ragfair.json | 19 ++++++++++++-- project/src/helpers/RagfairOfferHelper.ts | 26 +++++++++++++------ .../src/models/spt/config/IRagfairConfig.ts | 5 +++- 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/project/assets/configs/ragfair.json b/project/assets/configs/ragfair.json index ca56418b..1fe8a824 100644 --- a/project/assets/configs/ragfair.json +++ b/project/assets/configs/ragfair.json @@ -333,9 +333,24 @@ }, "tieredFlea": { "enabled": false, - "unlocks": { + "unlocksTpl": { + "5d5d940f86f7742797262046": 32, + "545cdae64bdc2d39198b4568": 30, + "5b44c6ae86f7742d1627baea": 30, + "628e1ffc83ec92260c0f437f": 30, + "5f5e467b0bc58666c37e7821": 30, + + "5c0e6a1586f77404597b4965": 26, + "5df8a42886f77412640e2e75": 25, + + "5c94bbff86f7747ee735c08f": 30, + "63a0b208f444d32d6f03ea1e": 25, + "5c0530ee86f774697952d952": 25, + "57347ca924597744596b4e71": 35 + }, + "unlocksType": { "57864a3d24597754843f8721": 35, - "57864bb7245977548b3b66c2": 35, + "57864bb7245977548b3b66c2": 30, "57864a66245977548f04a81f": 25, "57864ada245977548638de91": 20, "590c745b86f7743cc433c5f2": 35, diff --git a/project/src/helpers/RagfairOfferHelper.ts b/project/src/helpers/RagfairOfferHelper.ts index 66a69ab4..39f1a7c2 100644 --- a/project/src/helpers/RagfairOfferHelper.ts +++ b/project/src/helpers/RagfairOfferHelper.ts @@ -87,7 +87,7 @@ export class RagfairOfferHelper { ): IRagfairOffer[] { const playerIsFleaBanned = this.profileHelper.playerIsFleaBanned(pmcData); const tieredFlea = this.ragfairConfig.tieredFlea; - const tieredFleaLimitTypes = Object.keys(tieredFlea.unlocks); + const tieredFleaLimitTypes = Object.keys(tieredFlea.unlocksType); return this.ragfairOfferService.getOffers().filter((offer) => { if (!this.passesSearchFilterCriteria(searchRequest, offer, pmcData)) { return false; @@ -125,18 +125,28 @@ export class RagfairOfferHelper { tieredFleaLimitTypes: string[], playerLevel: number, ): boolean { - if (tieredFlea.ammoTplUnlocks && this.itemHelper.isOfBaseclass(offer.items[0]._tpl, BaseClasses.AMMO)) { - const unlockLevel = tieredFlea.ammoTplUnlocks[offer.items[0]._tpl]; + const offerItemTpl = offer.items[0]._tpl; + if (tieredFlea.ammoTplUnlocks && this.itemHelper.isOfBaseclass(offerItemTpl, BaseClasses.AMMO)) { + const unlockLevel = tieredFlea.ammoTplUnlocks[offerItemTpl]; if (unlockLevel && playerLevel < unlockLevel) { return true; } } + + // Check for a direct level requirement for the offer item + const itemLevelRequirement = tieredFlea.unlocksTpl[offerItemTpl]; + if (itemLevelRequirement) { + if (playerLevel < itemLevelRequirement) { + return true; + } + } + // Optimisation - Ensure the item has at least one of the limited base types - else if (this.itemHelper.isOfBaseclasses(offer.items[0]._tpl, tieredFleaLimitTypes)) { + if (this.itemHelper.isOfBaseclasses(offerItemTpl, tieredFleaLimitTypes)) { // Loop over all flea types to find the matching one for (const tieredItemType of tieredFleaLimitTypes) { - if (this.itemHelper.isOfBaseclass(offer.items[0]._tpl, tieredItemType)) { - if (playerLevel < tieredFlea.unlocks[tieredItemType]) { + if (this.itemHelper.isOfBaseclass(offerItemTpl, tieredItemType)) { + if (playerLevel < tieredFlea.unlocksType[tieredItemType]) { return true; } @@ -158,7 +168,7 @@ export class RagfairOfferHelper { // Get all offers that requre the desired item and filter out offers from non traders if player below ragifar unlock const requiredOffers = this.ragfairRequiredItemsService.getRequiredItemsById(searchRequest.neededSearchId); const tieredFlea = this.ragfairConfig.tieredFlea; - const tieredFleaLimitTypes = Object.keys(tieredFlea.unlocks); + const tieredFleaLimitTypes = Object.keys(tieredFlea.unlocksType); return requiredOffers.filter((offer: IRagfairOffer) => { if (!this.passesSearchFilterCriteria(searchRequest, offer, pmcData)) { @@ -195,7 +205,7 @@ export class RagfairOfferHelper { const offers: IRagfairOffer[] = []; const playerIsFleaBanned = this.profileHelper.playerIsFleaBanned(pmcData); const tieredFlea = this.ragfairConfig.tieredFlea; - const tieredFleaLimitTypes = Object.keys(tieredFlea.unlocks); + const tieredFleaLimitTypes = Object.keys(tieredFlea.unlocksType); for (const offer of this.ragfairOfferService.getOffers()) { if (!this.passesSearchFilterCriteria(searchRequest, offer, pmcData)) { diff --git a/project/src/models/spt/config/IRagfairConfig.ts b/project/src/models/spt/config/IRagfairConfig.ts index 5d3ce3e2..60e73c9f 100644 --- a/project/src/models/spt/config/IRagfairConfig.ts +++ b/project/src/models/spt/config/IRagfairConfig.ts @@ -174,7 +174,10 @@ export interface IArmorSettings { export interface ITieredFlea { enabled: boolean; - unlocks: Record; + /** key: tpl, value: playerlevel */ + unlocksTpl: Record; + /** key: item type id, value: playerlevel */ + unlocksType: Record; ammoTiersEnabled: boolean; ammoTplUnlocks: Record; }