Tie random weapon reward to rouble reward

Prevents daily quests from choosing high-level weapons as a reward for low level dailies
This commit is contained in:
Dev 2024-02-11 19:22:00 +00:00
parent 9e70b1135c
commit 575f467f78

View File

@ -1,11 +1,13 @@
import { inject, injectable } from "tsyringe"; import { inject, injectable } from "tsyringe";
import { ExhaustableArray } from "@spt-aki/helpers/BotGeneratorHelper";
import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper"; import { HandbookHelper } from "@spt-aki/helpers/HandbookHelper";
import { ItemHelper } from "@spt-aki/helpers/ItemHelper"; import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
import { PresetHelper } from "@spt-aki/helpers/PresetHelper"; import { PresetHelper } from "@spt-aki/helpers/PresetHelper";
import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper"; import { ProfileHelper } from "@spt-aki/helpers/ProfileHelper";
import { RagfairServerHelper } from "@spt-aki/helpers/RagfairServerHelper"; import { RagfairServerHelper } from "@spt-aki/helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "@spt-aki/helpers/RepeatableQuestHelper"; import { RepeatableQuestHelper } from "@spt-aki/helpers/RepeatableQuestHelper";
import { IPreset } from "@spt-aki/models/eft/common/IGlobals";
import { Exit, ILocationBase } from "@spt-aki/models/eft/common/ILocationBase"; import { Exit, ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
import { TraderInfo } from "@spt-aki/models/eft/common/tables/IBotBase"; import { TraderInfo } from "@spt-aki/models/eft/common/tables/IBotBase";
import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { Item } from "@spt-aki/models/eft/common/tables/IItem";
@ -981,14 +983,32 @@ export class RepeatableQuestGenerator
) )
{ {
// Add a random default preset weapon as reward // Add a random default preset weapon as reward
const defaultPresets = Object.values(this.presetHelper.getDefaultWeaponPresets()); const defaultPresetPool = new ExhaustableArray(
const defaultPresetClone = this.jsonUtil.clone(this.randomUtil.getArrayValue(defaultPresets)); Object.values(this.presetHelper.getDefaultWeaponPresets()),
this.randomUtil,
// use _encyclopedia as its always the base items _tpl, items[0] isn't guaranteed to be base item this.jsonUtil,
rewards.Success.push(
this.generateRewardItem(defaultPresetClone._encyclopedia, 1, rewardIndex, defaultPresetClone._items),
); );
rewardIndex++; let chosenPreset: IPreset;
while (defaultPresetPool.hasValues())
{
const randomPreset = defaultPresetPool.getRandomValue();
const tpls = randomPreset._items.map((item) => item._tpl);
const presetPrice = this.itemHelper.getItemAndChildrenPrice(tpls);
if (presetPrice <= roublesBudget)
{
chosenPreset = this.jsonUtil.clone(randomPreset);
break;
}
}
if (chosenPreset)
{
// use _encyclopedia as its always the base items _tpl, items[0] isn't guaranteed to be base item
rewards.Success.push(
this.generateRewardItem(chosenPreset._encyclopedia, 1, rewardIndex, chosenPreset._items),
);
rewardIndex++;
}
} }
if (rewardItemPool.length > 0) if (rewardItemPool.length > 0)