mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:30:45 -05:00
Added trader assort item blacklist system. Can be applied per profile
Enabled for Tournament profile Added support to server to handle `AssortmentUnlockRule` mails
This commit is contained in:
parent
50f224d03a
commit
86c383c97b
@ -36757,7 +36757,10 @@
|
||||
"initialSalesSum": 0,
|
||||
"initialStanding": 0.2,
|
||||
"jaegerUnlocked": false,
|
||||
"fleaBlockedDays": 365
|
||||
"fleaBlockedDays": 365,
|
||||
"lockedByDefaultOverride": [
|
||||
"579dc571d53a0658a154fbec"
|
||||
]
|
||||
},
|
||||
"weaponbuilds": {}
|
||||
},
|
||||
|
@ -1007,6 +1007,14 @@ export class InventoryController
|
||||
pmcData.TradersInfo[mailEvent.entity].unlocked = true;
|
||||
this.logger.success(`Trader ${mailEvent.entity} Unlocked`);
|
||||
break;
|
||||
case "AssortmentUnlockRule":
|
||||
if (!fullProfile.spt.blacklistedItemTpls)
|
||||
{
|
||||
fullProfile.spt.blacklistedItemTpls = [];
|
||||
}
|
||||
fullProfile.spt.blacklistedItemTpls.push(mailEvent.entity);
|
||||
this.logger.success(`Item ${mailEvent.entity} is now blacklisted`);
|
||||
break;
|
||||
default:
|
||||
this.logger.warning(`Unhandled profile reward event: ${mailEvent.Type}`);
|
||||
break;
|
||||
|
@ -69,7 +69,8 @@ export class TraderAssortHelper
|
||||
}
|
||||
|
||||
const traderClone = this.cloner.clone(this.databaseServer.getTables().traders[traderId]);
|
||||
const pmcProfile = this.profileHelper.getPmcProfile(sessionId);
|
||||
const fullProfile = this.profileHelper.getFullProfile(sessionId);
|
||||
const pmcProfile = fullProfile.characters.pmc;
|
||||
|
||||
if (traderId === Traders.FENCE)
|
||||
{
|
||||
@ -131,6 +132,12 @@ export class TraderAssortHelper
|
||||
flea,
|
||||
);
|
||||
|
||||
// Filter out root assorts that are blacklisted for this profile
|
||||
if (fullProfile.spt.blacklistedItemTpls?.length > 0)
|
||||
{
|
||||
this.removeItemsFromAssort(traderClone.assort, fullProfile.spt.blacklistedItemTpls);
|
||||
}
|
||||
|
||||
// Multiply price if multiplier is other than 1
|
||||
if (this.traderConfig.traderPriceMultipler !== 1)
|
||||
{
|
||||
@ -140,6 +147,28 @@ export class TraderAssortHelper
|
||||
return traderClone.assort;
|
||||
}
|
||||
|
||||
/**
|
||||
* Given the blacklist provided, remove root items from assort
|
||||
* @param assortToFilter Trader assort to modify
|
||||
* @param itemsTplsToRemove Item TPLs the assort should not have
|
||||
*/
|
||||
protected removeItemsFromAssort(assortToFilter: ITraderAssort, itemsTplsToRemove: string[]): void
|
||||
{
|
||||
function isValid(item: Item, blacklist: string[]): boolean
|
||||
{
|
||||
// Is root item + blacklisted
|
||||
if (item.parentId === "hideout" && blacklist.includes(item._tpl))
|
||||
{
|
||||
// We want it gone
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
assortToFilter.items = assortToFilter.items.filter((item) => isValid(item, itemsTplsToRemove));
|
||||
}
|
||||
|
||||
/**
|
||||
* Reset every traders root item `BuyRestrictionCurrent` property to 0
|
||||
* @param assortItems Items to adjust
|
||||
|
@ -128,10 +128,11 @@ export class TraderHelper
|
||||
*/
|
||||
public resetTrader(sessionID: string, traderID: string): void
|
||||
{
|
||||
const db = this.databaseServer.getTables();
|
||||
const account = this.saveServer.getProfile(sessionID);
|
||||
const pmcData = this.profileHelper.getPmcProfile(sessionID);
|
||||
const rawProfileTemplate: ProfileTraderTemplate
|
||||
= this.databaseServer.getTables().templates.profiles[account.info.edition][pmcData.Info.Side.toLowerCase()]
|
||||
= db.templates.profiles[account.info.edition][pmcData.Info.Side.toLowerCase()]
|
||||
.trader;
|
||||
|
||||
pmcData.TradersInfo[traderID] = {
|
||||
@ -139,10 +140,16 @@ export class TraderHelper
|
||||
loyaltyLevel: rawProfileTemplate.initialLoyaltyLevel[traderID] ?? 1,
|
||||
salesSum: rawProfileTemplate.initialSalesSum,
|
||||
standing: this.getStartingStanding(traderID, rawProfileTemplate),
|
||||
nextResupply: this.databaseServer.getTables().traders[traderID].base.nextResupply,
|
||||
unlocked: this.databaseServer.getTables().traders[traderID].base.unlockedByDefault,
|
||||
nextResupply: db.traders[traderID].base.nextResupply,
|
||||
unlocked: db.traders[traderID].base.unlockedByDefault,
|
||||
};
|
||||
|
||||
// Check if trader should be locked by default
|
||||
if (rawProfileTemplate.lockedByDefaultOverride?.includes(traderID))
|
||||
{
|
||||
pmcData.TradersInfo[traderID].unlocked = false;
|
||||
}
|
||||
|
||||
if (rawProfileTemplate.fleaBlockedDays > 0)
|
||||
{
|
||||
const newBanDateTime = this.timeUtil.getTimeStampFromNowDays(rawProfileTemplate.fleaBlockedDays);
|
||||
|
@ -40,5 +40,8 @@ export interface ProfileTraderTemplate
|
||||
initialStanding: number
|
||||
initialSalesSum: number
|
||||
jaegerUnlocked: boolean
|
||||
/** How many days is usage of the flea blocked for upon profile creation */
|
||||
fleaBlockedDays?: number
|
||||
/** What traders default to being locked on profile creation */
|
||||
lockedByDefaultOverride?: string[]
|
||||
}
|
||||
|
@ -207,9 +207,14 @@ export interface DateTime
|
||||
|
||||
export interface Spt
|
||||
{
|
||||
/** What version of SPT was this profile made with */
|
||||
version: string
|
||||
/** What mods has this profile loaded at any point in time */
|
||||
mods?: ModDetails[]
|
||||
/** What gifts has this profile received and how many */
|
||||
receivedGifts: ReceivedGift[]
|
||||
/** item TPLs blacklisted from being sold on flea for this profile */
|
||||
blacklistedItemTpls?: string[]
|
||||
}
|
||||
|
||||
export interface ModDetails
|
||||
|
@ -47,4 +47,5 @@ export enum ProfileChangeEventType
|
||||
SKILL_POINTS = "SkillPoints",
|
||||
EXAMINE_ALL_ITEMS = "ExamineAllItems",
|
||||
UNLOCK_TRADER = "UnlockTrader",
|
||||
ASSORT_UNLOCK_RULE = "AssortmentUnlockRule",
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user