mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 01:30:44 -05:00
Wired up item type blacklist across loot generator/airdrop and cultist circle in consistent way
Reworked Cultist circle code to pass blacklist around as a set rather than array Removed cultist circle use of `itemRewardBlacklist` to store item parent ids, feature is handled by new config property
This commit is contained in:
parent
55857a7e7a
commit
53599e46f3
@ -205,7 +205,14 @@ export class LootGenerator {
|
|||||||
|
|
||||||
if (useRewardItemBlacklist) {
|
if (useRewardItemBlacklist) {
|
||||||
const itemsToAdd = this.itemFilterService.getItemRewardBlacklist();
|
const itemsToAdd = this.itemFilterService.getItemRewardBlacklist();
|
||||||
itemBlacklist = new Set([...itemBlacklist, ...itemsToAdd]);
|
|
||||||
|
// Get all items that match the blacklisted types and fold into item blacklist
|
||||||
|
const itemTypeBlacklist = this.itemFilterService.getItemRewardBaseTypeBlacklist();
|
||||||
|
const itemsMatchingTypeBlacklist = Object.values(itemsDb)
|
||||||
|
.filter((templateItem) => this.itemHelper.isOfBaseclasses(templateItem._parent, itemTypeBlacklist))
|
||||||
|
.map((templateItem) => templateItem._id);
|
||||||
|
|
||||||
|
itemBlacklist = new Set([...itemBlacklist, ...itemsToAdd, ...itemsMatchingTypeBlacklist]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!allowBossItems) {
|
if (!allowBossItems) {
|
||||||
|
@ -157,17 +157,25 @@ export class AirdropService {
|
|||||||
lootSettingsByType = this.airdropConfig.loot[AirdropTypeEnum.COMMON];
|
lootSettingsByType = this.airdropConfig.loot[AirdropTypeEnum.COMMON];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get all items that match the blacklisted types and fold into item blacklist
|
||||||
|
const itemTypeBlacklist = this.itemFilterService.getItemRewardBaseTypeBlacklist();
|
||||||
|
const itemsMatchingTypeBlacklist = Object.values(this.itemHelper.getItems())
|
||||||
|
.filter((templateItem) => this.itemHelper.isOfBaseclasses(templateItem._parent, itemTypeBlacklist))
|
||||||
|
.map((templateItem) => templateItem._id);
|
||||||
|
const itemBlacklist = new Set([
|
||||||
|
...lootSettingsByType.itemBlacklist,
|
||||||
|
...this.itemFilterService.getItemRewardBlacklist(),
|
||||||
|
...this.itemFilterService.getBossItems(),
|
||||||
|
...itemsMatchingTypeBlacklist,
|
||||||
|
]);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
icon: lootSettingsByType.icon,
|
icon: lootSettingsByType.icon,
|
||||||
weaponPresetCount: lootSettingsByType.weaponPresetCount,
|
weaponPresetCount: lootSettingsByType.weaponPresetCount,
|
||||||
armorPresetCount: lootSettingsByType.armorPresetCount,
|
armorPresetCount: lootSettingsByType.armorPresetCount,
|
||||||
itemCount: lootSettingsByType.itemCount,
|
itemCount: lootSettingsByType.itemCount,
|
||||||
weaponCrateCount: lootSettingsByType.weaponCrateCount,
|
weaponCrateCount: lootSettingsByType.weaponCrateCount,
|
||||||
itemBlacklist: [
|
itemBlacklist: Array.from(itemBlacklist),
|
||||||
...lootSettingsByType.itemBlacklist,
|
|
||||||
...this.itemFilterService.getItemRewardBlacklist(),
|
|
||||||
...this.itemFilterService.getBossItems(),
|
|
||||||
],
|
|
||||||
itemTypeWhitelist: lootSettingsByType.itemTypeWhitelist,
|
itemTypeWhitelist: lootSettingsByType.itemTypeWhitelist,
|
||||||
itemLimits: lootSettingsByType.itemLimits,
|
itemLimits: lootSettingsByType.itemLimits,
|
||||||
itemStackLimits: lootSettingsByType.itemStackLimits,
|
itemStackLimits: lootSettingsByType.itemStackLimits,
|
||||||
|
@ -634,27 +634,28 @@ export class CircleOfCultistService {
|
|||||||
): string[] {
|
): string[] {
|
||||||
const rewardPool = new Set<string>();
|
const rewardPool = new Set<string>();
|
||||||
const hideoutDbData = this.databaseService.getHideout();
|
const hideoutDbData = this.databaseService.getHideout();
|
||||||
|
const itemsDb = this.databaseService.getItems();
|
||||||
|
|
||||||
// Merge reward item blacklist and boss item blacklist with cultist circle blacklist from config
|
// Get all items that match the blacklisted types and fold into item blacklist below
|
||||||
const itemRewardBlacklist = [
|
const itemTypeBlacklist = this.itemFilterService.getItemRewardBaseTypeBlacklist();
|
||||||
|
const itemsMatchingTypeBlacklist = Object.values(itemsDb)
|
||||||
|
.filter((templateItem) => this.itemHelper.isOfBaseclasses(templateItem._parent, itemTypeBlacklist))
|
||||||
|
.map((templateItem) => templateItem._id);
|
||||||
|
|
||||||
|
// Create set of unique values to ignore
|
||||||
|
const itemRewardBlacklist = new Set([
|
||||||
...this.seasonalEventService.getInactiveSeasonalEventItems(),
|
...this.seasonalEventService.getInactiveSeasonalEventItems(),
|
||||||
...this.itemFilterService.getItemRewardBlacklist(),
|
...this.itemFilterService.getItemRewardBlacklist(),
|
||||||
...cultistCircleConfig.rewardItemBlacklist,
|
...cultistCircleConfig.rewardItemBlacklist,
|
||||||
];
|
...itemsMatchingTypeBlacklist,
|
||||||
|
]);
|
||||||
const itemBaseTypeBlacklist = this.itemFilterService.getItemRewardBaseTypeBlacklist();
|
|
||||||
|
|
||||||
// Hideout and task rewards are ONLY if the bonus is active
|
// Hideout and task rewards are ONLY if the bonus is active
|
||||||
switch (craftingInfo.rewardType) {
|
switch (craftingInfo.rewardType) {
|
||||||
case CircleRewardType.RANDOM: {
|
case CircleRewardType.RANDOM: {
|
||||||
// Does reward pass the high value threshold
|
// Does reward pass the high value threshold
|
||||||
const isHighValueReward = craftingInfo.rewardAmountRoubles >= cultistCircleConfig.highValueThresholdRub;
|
const isHighValueReward = craftingInfo.rewardAmountRoubles >= cultistCircleConfig.highValueThresholdRub;
|
||||||
this.generateRandomisedItemsAndAddToRewardPool(
|
this.generateRandomisedItemsAndAddToRewardPool(rewardPool, itemRewardBlacklist, isHighValueReward);
|
||||||
rewardPool,
|
|
||||||
itemRewardBlacklist,
|
|
||||||
itemBaseTypeBlacklist,
|
|
||||||
isHighValueReward,
|
|
||||||
);
|
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -665,12 +666,7 @@ export class CircleOfCultistService {
|
|||||||
|
|
||||||
// If we have no tasks or hideout stuff left or need more loot to fill it out, default to high value
|
// If we have no tasks or hideout stuff left or need more loot to fill it out, default to high value
|
||||||
if (rewardPool.size < cultistCircleConfig.maxRewardItemCount + 2) {
|
if (rewardPool.size < cultistCircleConfig.maxRewardItemCount + 2) {
|
||||||
this.generateRandomisedItemsAndAddToRewardPool(
|
this.generateRandomisedItemsAndAddToRewardPool(rewardPool, itemRewardBlacklist, true);
|
||||||
rewardPool,
|
|
||||||
itemRewardBlacklist,
|
|
||||||
itemBaseTypeBlacklist,
|
|
||||||
true,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -679,7 +675,7 @@ export class CircleOfCultistService {
|
|||||||
// Add custom rewards from config
|
// Add custom rewards from config
|
||||||
if (cultistCircleConfig.additionalRewardItemPool.length > 0) {
|
if (cultistCircleConfig.additionalRewardItemPool.length > 0) {
|
||||||
for (const additionalReward of cultistCircleConfig.additionalRewardItemPool) {
|
for (const additionalReward of cultistCircleConfig.additionalRewardItemPool) {
|
||||||
if (itemRewardBlacklist.includes(additionalReward)) {
|
if (itemRewardBlacklist.has(additionalReward)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -699,7 +695,7 @@ export class CircleOfCultistService {
|
|||||||
*/
|
*/
|
||||||
protected addTaskItemRequirementsToRewardPool(
|
protected addTaskItemRequirementsToRewardPool(
|
||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
itemRewardBlacklist: string[],
|
itemRewardBlacklist: Set<string>,
|
||||||
rewardPool: Set<string>,
|
rewardPool: Set<string>,
|
||||||
): void {
|
): void {
|
||||||
const activeTasks = pmcData.Quests.filter((quest) => quest.status === QuestStatus.Started);
|
const activeTasks = pmcData.Quests.filter((quest) => quest.status === QuestStatus.Started);
|
||||||
@ -710,7 +706,7 @@ export class CircleOfCultistService {
|
|||||||
);
|
);
|
||||||
for (const condition of handoverConditions) {
|
for (const condition of handoverConditions) {
|
||||||
for (const neededItem of condition.target) {
|
for (const neededItem of condition.target) {
|
||||||
if (itemRewardBlacklist.includes(neededItem) || !this.itemHelper.isValidItem(neededItem)) {
|
if (itemRewardBlacklist.has(neededItem) || !this.itemHelper.isValidItem(neededItem)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
this.logger.debug(`Added Task Loot: ${this.itemHelper.getItemName(neededItem)}`);
|
this.logger.debug(`Added Task Loot: ${this.itemHelper.getItemName(neededItem)}`);
|
||||||
@ -730,7 +726,7 @@ export class CircleOfCultistService {
|
|||||||
protected addHideoutUpgradeRequirementsToRewardPool(
|
protected addHideoutUpgradeRequirementsToRewardPool(
|
||||||
hideoutDbData: IHideout,
|
hideoutDbData: IHideout,
|
||||||
pmcData: IPmcData,
|
pmcData: IPmcData,
|
||||||
itemRewardBlacklist: string[],
|
itemRewardBlacklist: Set<string>,
|
||||||
rewardPool: Set<string>,
|
rewardPool: Set<string>,
|
||||||
): void {
|
): void {
|
||||||
const dbAreas = hideoutDbData.areas;
|
const dbAreas = hideoutDbData.areas;
|
||||||
@ -746,7 +742,7 @@ export class CircleOfCultistService {
|
|||||||
const itemRequirements = this.getItemRequirements(nextStageDbData.requirements);
|
const itemRequirements = this.getItemRequirements(nextStageDbData.requirements);
|
||||||
for (const rewardToAdd of itemRequirements) {
|
for (const rewardToAdd of itemRequirements) {
|
||||||
if (
|
if (
|
||||||
itemRewardBlacklist.includes(rewardToAdd.templateId) ||
|
itemRewardBlacklist.has(rewardToAdd.templateId) ||
|
||||||
!this.itemHelper.isValidItem(rewardToAdd.templateId)
|
!this.itemHelper.isValidItem(rewardToAdd.templateId)
|
||||||
) {
|
) {
|
||||||
// Dont reward items sacrificed
|
// Dont reward items sacrificed
|
||||||
@ -779,14 +775,12 @@ export class CircleOfCultistService {
|
|||||||
* Get array of random reward items
|
* Get array of random reward items
|
||||||
* @param rewardPool Reward pool to add to
|
* @param rewardPool Reward pool to add to
|
||||||
* @param itemRewardBlacklist Item tpls to ignore
|
* @param itemRewardBlacklist Item tpls to ignore
|
||||||
* @param itemBaseTypeBlacklist Item base types to ignore
|
|
||||||
* @param itemsShouldBeHighValue Should these items meet the valuable threshold
|
* @param itemsShouldBeHighValue Should these items meet the valuable threshold
|
||||||
* @returns Set of item tpls
|
* @returns Set of item tpls
|
||||||
*/
|
*/
|
||||||
protected generateRandomisedItemsAndAddToRewardPool(
|
protected generateRandomisedItemsAndAddToRewardPool(
|
||||||
rewardPool: Set<string>,
|
rewardPool: Set<string>,
|
||||||
itemRewardBlacklist: string[],
|
itemRewardBlacklist: Set<string>,
|
||||||
itemBaseTypeBlacklist: string[],
|
|
||||||
itemsShouldBeHighValue: boolean,
|
itemsShouldBeHighValue: boolean,
|
||||||
): Set<string> {
|
): Set<string> {
|
||||||
const allItems = this.itemHelper.getItems();
|
const allItems = this.itemHelper.getItems();
|
||||||
@ -799,16 +793,7 @@ export class CircleOfCultistService {
|
|||||||
) {
|
) {
|
||||||
attempts++;
|
attempts++;
|
||||||
const randomItem = this.randomUtil.getArrayValue(allItems);
|
const randomItem = this.randomUtil.getArrayValue(allItems);
|
||||||
if (
|
if (itemRewardBlacklist.has(randomItem._id) || !this.itemHelper.isValidItem(randomItem._id)) {
|
||||||
itemRewardBlacklist.includes(randomItem._id) ||
|
|
||||||
itemRewardBlacklist.includes(randomItem._parent) ||
|
|
||||||
!this.itemHelper.isValidItem(randomItem._id)
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Item has a blacklisted type, skip
|
|
||||||
if (this.itemHelper.isOfBaseclasses(randomItem._parent, itemBaseTypeBlacklist)) {
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user