0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 01:50:44 -05:00

Wired up Cultist circle to use item type blacklist

This commit is contained in:
Chomp 2024-12-09 14:44:28 +00:00
parent b41d8683b3
commit 55857a7e7a

View File

@ -378,8 +378,7 @@ export class CircleOfCultistService {
} }
// Ensure preset has unique ids and is cloned so we don't alter the preset data stored in memory // Ensure preset has unique ids and is cloned so we don't alter the preset data stored in memory
const presetAndMods: IItem[] = this.itemHelper.replaceIDs(defaultPreset._items); const presetAndMods = this.itemHelper.replaceIDs(defaultPreset._items);
this.itemHelper.remapRootItemId(presetAndMods); this.itemHelper.remapRootItemId(presetAndMods);
rewardItemCount++; rewardItemCount++;
@ -396,7 +395,8 @@ export class CircleOfCultistService {
); );
// Not a weapon/armor, standard single item // Not a weapon/armor, standard single item
const rewardItem: IItem = { const rewardItem: IItem[] = [
{
_id: this.hashUtil.generate(), _id: this.hashUtil.generate(),
_tpl: randomItemTplFromPool, _tpl: randomItemTplFromPool,
parentId: cultistCircleStashId, parentId: cultistCircleStashId,
@ -405,7 +405,14 @@ export class CircleOfCultistService {
StackObjectsCount: stackSize, StackObjectsCount: stackSize,
SpawnedInSession: true, SpawnedInSession: true,
}, },
}; },
];
// Edge case - item is ammo container and needs cartridges added
if (this.itemHelper.isOfBaseclass(randomItemTplFromPool, BaseClasses.AMMO_BOX)) {
const itemDetails = this.itemHelper.getItem(randomItemTplFromPool)[1];
this.itemHelper.addCartridgesToAmmoBox(rewardItem, itemDetails);
}
// Increment price of rewards to give to player + add to reward array // Increment price of rewards to give to player + add to reward array
rewardItemCount++; rewardItemCount++;
@ -413,7 +420,7 @@ export class CircleOfCultistService {
const itemPrice = singleItemPrice * stackSize; const itemPrice = singleItemPrice * stackSize;
totalRewardCost += itemPrice; totalRewardCost += itemPrice;
rewards.push([rewardItem]); rewards.push(rewardItem);
} }
return rewards; return rewards;
@ -454,8 +461,7 @@ export class CircleOfCultistService {
} }
// Ensure preset has unique ids and is cloned so we don't alter the preset data stored in memory // Ensure preset has unique ids and is cloned so we don't alter the preset data stored in memory
const presetAndMods: IItem[] = this.itemHelper.replaceIDs(defaultPreset._items); const presetAndMods = this.itemHelper.replaceIDs(defaultPreset._items);
this.itemHelper.remapRootItemId(presetAndMods); this.itemHelper.remapRootItemId(presetAndMods);
rewards.push(presetAndMods); rewards.push(presetAndMods);
@ -465,7 +471,8 @@ export class CircleOfCultistService {
// 'Normal' item, non-preset // 'Normal' item, non-preset
const stackSize = this.getDirectRewardBaseTypeStackSize(rewardTpl); const stackSize = this.getDirectRewardBaseTypeStackSize(rewardTpl);
const rewardItem: IItem = { const rewardItem: IItem[] = [
{
_id: this.hashUtil.generate(), _id: this.hashUtil.generate(),
_tpl: rewardTpl, _tpl: rewardTpl,
parentId: cultistCircleStashId, parentId: cultistCircleStashId,
@ -474,8 +481,16 @@ export class CircleOfCultistService {
StackObjectsCount: stackSize, StackObjectsCount: stackSize,
SpawnedInSession: true, SpawnedInSession: true,
}, },
}; },
rewards.push([rewardItem]); ];
// Edge case - item is ammo container and needs cartridges added
if (this.itemHelper.isOfBaseclass(rewardTpl, BaseClasses.AMMO_BOX)) {
const itemDetails = this.itemHelper.getItem(rewardTpl)[1];
this.itemHelper.addCartridgesToAmmoBox(rewardItem, itemDetails);
}
rewards.push(rewardItem);
} }
// Direct reward is not repeatable, flag collected in profile // Direct reward is not repeatable, flag collected in profile
if (!directReward.repeatable) { if (!directReward.repeatable) {
@ -627,12 +642,19 @@ export class CircleOfCultistService {
...cultistCircleConfig.rewardItemBlacklist, ...cultistCircleConfig.rewardItemBlacklist,
]; ];
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(rewardPool, itemRewardBlacklist, isHighValueReward); this.generateRandomisedItemsAndAddToRewardPool(
rewardPool,
itemRewardBlacklist,
itemBaseTypeBlacklist,
isHighValueReward,
);
break; break;
} }
@ -643,7 +665,12 @@ 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(rewardPool, itemRewardBlacklist, true); this.generateRandomisedItemsAndAddToRewardPool(
rewardPool,
itemRewardBlacklist,
itemBaseTypeBlacklist,
true,
);
} }
break; break;
} }
@ -751,19 +778,21 @@ 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 Reward Blacklist * @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 rewardPool * @returns Set of item tpls
*/ */
protected generateRandomisedItemsAndAddToRewardPool( protected generateRandomisedItemsAndAddToRewardPool(
rewardPool: Set<string>, rewardPool: Set<string>,
itemRewardBlacklist: string[], itemRewardBlacklist: string[],
itemBaseTypeBlacklist: string[],
itemsShouldBeHighValue: boolean, itemsShouldBeHighValue: boolean,
): Set<string> { ): Set<string> {
const allItems = this.itemHelper.getItems(); const allItems = this.itemHelper.getItems();
let currentItemCount = 0; let currentItemCount = 0;
let attempts = 0; let attempts = 0;
// currentItemCount var will look for the correct number of items, attempts var will keep this from never stopping if the highValueThreshold is too high // `currentItemCount` var will look for the correct number of items, `attempts` var will keep this from never stopping if the highValueThreshold is too high
while ( while (
currentItemCount < this.hideoutConfig.cultistCircle.maxRewardItemCount + 2 && currentItemCount < this.hideoutConfig.cultistCircle.maxRewardItemCount + 2 &&
attempts < allItems.length attempts < allItems.length
@ -778,6 +807,11 @@ export class CircleOfCultistService {
continue; continue;
} }
// Item has a blacklisted type, skip
if (this.itemHelper.isOfBaseclasses(randomItem._parent, itemBaseTypeBlacklist)) {
continue;
}
// Valuable check // Valuable check
if (itemsShouldBeHighValue) { if (itemsShouldBeHighValue) {
const itemValue = this.itemHelper.getItemMaxPrice(randomItem._id); const itemValue = this.itemHelper.getItemMaxPrice(randomItem._id);