mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 02:50:44 -05:00
Renamed getRandomLoot
to generateRandomisedItemsAndAddToRewardPool
Removed hard-coded money/ammo blacklist from `generateRandomisedItemsAndAddToRewardPool()` and moved into config Updated function to check chosen reward items parentid against item reward blacklist
This commit is contained in:
parent
b20777e1c3
commit
050edec9f3
@ -630,7 +630,7 @@ export class CircleOfCultistService {
|
|||||||
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.getRandomLoot(rewardPool, itemRewardBlacklist, isHighValueReward);
|
this.generateRandomisedItemsAndAddToRewardPool(rewardPool, itemRewardBlacklist, isHighValueReward);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -641,7 +641,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.getRandomLoot(rewardPool, itemRewardBlacklist, true);
|
this.generateRandomisedItemsAndAddToRewardPool(rewardPool, itemRewardBlacklist, true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -737,10 +737,14 @@ 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 Reward Blacklist
|
||||||
* @param valuable Should these items meet the valuable threshold
|
* @param itemsShouldBeHighValue Should these items meet the valuable threshold
|
||||||
* @returns rewardPool
|
* @returns rewardPool
|
||||||
*/
|
*/
|
||||||
protected getRandomLoot(rewardPool: Set<string>, itemRewardBlacklist: string[], valuable: boolean): Set<string> {
|
protected generateRandomisedItemsAndAddToRewardPool(
|
||||||
|
rewardPool: Set<string>,
|
||||||
|
itemRewardBlacklist: string[],
|
||||||
|
itemsShouldBeHighValue: boolean,
|
||||||
|
): Set<string> {
|
||||||
const allItems = this.itemHelper.getItems();
|
const allItems = this.itemHelper.getItems();
|
||||||
let currentItemCount = 0;
|
let currentItemCount = 0;
|
||||||
let attempts = 0;
|
let attempts = 0;
|
||||||
@ -753,15 +757,14 @@ export class CircleOfCultistService {
|
|||||||
const randomItem = this.randomUtil.getArrayValue(allItems);
|
const randomItem = this.randomUtil.getArrayValue(allItems);
|
||||||
if (
|
if (
|
||||||
itemRewardBlacklist.includes(randomItem._id) ||
|
itemRewardBlacklist.includes(randomItem._id) ||
|
||||||
BaseClasses.AMMO === randomItem._parent ||
|
itemRewardBlacklist.includes(randomItem._parent) ||
|
||||||
BaseClasses.MONEY === randomItem._parent ||
|
|
||||||
!this.itemHelper.isValidItem(randomItem._id)
|
!this.itemHelper.isValidItem(randomItem._id)
|
||||||
) {
|
) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Valuable check
|
// Valuable check
|
||||||
if (valuable) {
|
if (itemsShouldBeHighValue) {
|
||||||
const itemValue = this.itemHelper.getItemMaxPrice(randomItem._id);
|
const itemValue = this.itemHelper.getItemMaxPrice(randomItem._id);
|
||||||
if (itemValue < this.hideoutConfig.cultistCircle.highValueThresholdRub) {
|
if (itemValue < this.hideoutConfig.cultistCircle.highValueThresholdRub) {
|
||||||
this.logger.debug(`Ignored due to value: ${this.itemHelper.getItemName(randomItem._id)}`);
|
this.logger.debug(`Ignored due to value: ${this.itemHelper.getItemName(randomItem._id)}`);
|
||||||
@ -772,6 +775,7 @@ export class CircleOfCultistService {
|
|||||||
rewardPool.add(randomItem._id);
|
rewardPool.add(randomItem._id);
|
||||||
currentItemCount++;
|
currentItemCount++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return rewardPool;
|
return rewardPool;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user