Update types

This commit is contained in:
Dev 2023-10-12 15:18:14 +01:00
parent a0516f9d38
commit 469fe00902
336 changed files with 6300 additions and 4242 deletions

View File

@ -62,10 +62,10 @@ export declare class InraidController {
savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void;
/**
* Handle updating player profile post-pmc raid
* @param sessionID session id
* @param offraidData post-raid data
* @param sessionID Session id
* @param postRaidRequest Post-raid data
*/
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Make changes to pmc profile after they've died in raid,
* Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items
@ -91,10 +91,10 @@ export declare class InraidController {
protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void;
/**
* Handle updating the profile post-pscav raid
* @param sessionID session id
* @param offraidData post-raid data of raid
* @param sessionID Session id
* @param postRaidRequest Post-raid data of raid
*/
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
* @param statusOnExit exit value from offraidData object

View File

@ -9,7 +9,7 @@ import { IGetInsuranceCostRequestData } from "../models/eft/insurance/IGetInsura
import { IGetInsuranceCostResponseData } from "../models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "../models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { Insurance } from "../models/eft/profile/IAkiProfile";
import { Insurance, ISystemData } from "../models/eft/profile/IAkiProfile";
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
@ -66,6 +66,14 @@ export declare class InsuranceController {
* @returns void
*/
protected processInsuredItems(insuranceDetails: Insurance[], sessionID: string): void;
/**
* Remove an insurance package from a profile using the package's system data information.
*
* @param sessionID The session ID of the profile to remove the package from.
* @param index The array index of the insurance package to remove.
* @returns void
*/
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void;
/**
* Build an array of items to delete from the insured items.
*
@ -78,7 +86,7 @@ export declare class InsuranceController {
* @param insured - The insured items to build a removal array from.
* @returns An array of IDs representing items that should be deleted.
*/
protected findItemsToDelete(insured: Insurance): string[];
protected findItemsToDelete(insured: Insurance): Set<string>;
/**
* Filters an item based on its existence in the database, raid moddability, and slot requirements.
*
@ -108,7 +116,7 @@ export declare class InsuranceController {
* @param toDelete The array accumulating the IDs of items to be deleted.
* @returns true if the item is marked for deletion, otherwise false.
*/
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: string[]): boolean;
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: Set<string>): boolean;
/**
* Groups child items by their parent IDs in a Map data structure.
*
@ -127,7 +135,7 @@ export declare class InsuranceController {
* @param toDelete The array that accumulates the IDs of the items to be deleted.
* @returns void
*/
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: string[]): void;
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: Set<string>): void;
/**
* Remove items from the insured items that should not be returned to the player.
*
@ -135,7 +143,7 @@ export declare class InsuranceController {
* @param toDelete The items that should be deleted.
* @returns void
*/
protected removeItemsFromInsurance(insured: Insurance, toDelete: string[]): void;
protected removeItemsFromInsurance(insured: Insurance, toDelete: Set<string>): void;
/**
* Handle sending the insurance message to the user that potentially contains the valid insurance items.
*
@ -154,7 +162,7 @@ export declare class InsuranceController {
* @param itemsBeingDeleted List of items that are already slated for removal.
* @returns true if the insured item should be removed from inventory, false otherwise.
*/
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: string[]): boolean;
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: Set<string>): boolean;
/**
* Handle Insure event
* Add insurance to an item

View File

@ -1,81 +1,41 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { RepeatableQuestGenerator } from "../generators/RepeatableQuestGenerator";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData";
import { Exit } from "../models/eft/common/ILocationBase";
import { IPmcData } from "../models/eft/common/IPmcData";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IPmcDataRepeatableQuest, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IPmcDataRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { IRepeatableQuestChangeRequest } from "../models/eft/quests/IRepeatableQuestChangeRequest";
import { ELocationName } from "../models/enums/ELocationName";
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "../utils/RandomUtil";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKojaniy?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}
export declare class RepeatableQuestController {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestGenerator: RepeatableQuestGenerator;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, configServer: ConfigServer);
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, paymentService: PaymentService, objectId: ObjectId, repeatableQuestGenerator: RepeatableQuestGenerator, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* Handle client/repeatalbeQuests/activityPeriods
* Returns an array of objects in the format of repeatable quests to the client.
@ -109,103 +69,10 @@ export declare class RepeatableQuestController {
* @returns IPmcDataRepeatableQuest
*/
protected getRepeatableQuestSubTypeFromProfile(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): IPmcDataRepeatableQuest;
/**
* This method is called by GetClientRepeatableQuests and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
*/
protected generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps
*/
generateDebugDailies(dailiesPool: any, factory: any, number: number): any;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* Generates a valid Elimination quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
protected getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[]): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number): IEliminationCondition;
/**
* Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently
* narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests
@ -215,53 +82,10 @@ export declare class RepeatableQuestController {
* @returns IQuestTypePool
*/
protected generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
protected createBaseQuestPool(repeatableConfig: IRepeatableQuestConfig): IQuestTypePool;
debugLogRepeatableQuestIds(pmcData: IPmcData): void;
protected probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
/**
* Handle RepeatableQuestChange event
*/
changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
changeRepeatableQuest(pmcData: IPmcData, changeRequest: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
}

View File

@ -0,0 +1,183 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { Exit } from "../models/eft/common/ILocationBase";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export declare class RepeatableQuestGenerator {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* This method is called by /GetClientRepeatableQuests/ and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
* @param pmcLevel Player's level for requested items and reward generation
* @param pmcTraderInfo Players traper standing/rep levels
* @param questTypePool Possible quest types pool
* @param repeatableConfig Repeatable quest config
* @returns IRepeatableQuest
*/
generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Generate a randomised Elimination quest
* @param pmcLevel Player's level for requested items and reward generation
* @param traderId Trader from which the quest will be provided
* @param questTypePool Pools for quests (used to avoid redundant quests)
* @param repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns Object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[], allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number, allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
}

View File

@ -111,11 +111,11 @@ export declare class InRaidHelper {
* Add new items found in raid to profile
* Store insurance items in profile
* @param sessionID Session id
* @param pmcData Profile to update
* @param serverProfile Profile to update
* @param postRaidProfile Profile returned by client after a raid
* @returns Updated profile
*/
setInventory(sessionID: string, pmcData: IPmcData, postRaidProfile: IPmcData): IPmcData;
setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): IPmcData;
/**
* Clear pmc inventory of all items except those that are exempt
* Used post-raid to remove items after death

View File

@ -303,6 +303,7 @@ declare class ItemHelper {
* @returns Name of item
*/
getItemName(itemTpl: string): string;
getItemTplsOfBaseType(desiredBaseType: string): string[];
}
declare namespace ItemHelper {
interface ItemSize {

View File

@ -0,0 +1,20 @@
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { ConfigServer } from "../servers/ConfigServer";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ProbabilityObject, ProbabilityObjectArray } from "../utils/RandomUtil";
export declare class RepeatableQuestHelper {
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(mathUtil: MathUtil, jsonUtil: JsonUtil, configServer: ConfigServer);
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
}

View File

@ -161,6 +161,8 @@ export interface ICompletionAvailableForProps extends IAvailableForProps {
}
export interface ILocationConditionProps extends IConditionProps {
target: string[];
weapon?: string[];
weaponCategories?: string[];
}
export interface IKillConditionProps extends IConditionProps {
target: string;
@ -168,6 +170,8 @@ export interface IKillConditionProps extends IConditionProps {
savageRole?: string[];
bodyPart?: string[];
distance?: IDistanceCheck;
weapon?: string[];
weaponCategories?: string[];
}
export interface IDistanceCheck {
compareMethod: string;

View File

@ -52,4 +52,6 @@ export interface AirdropLoot {
itemStackLimits: Record<string, MinMax>;
/** Armor levels to allow inside crate e.g. [4,5,6] */
armorLevelWhitelist?: number[];
/** Should boss items be added to airdrop crate */
allowBossItems: boolean;
}

View File

@ -23,4 +23,5 @@ export interface ISealedAirdropContainerSettings {
weaponModRewardLimits: Record<string, MinMax>;
rewardTypeLimits: Record<string, MinMax>;
ammoBoxWhitelist: string[];
allowBossItems: boolean;
}

View File

@ -1,5 +1,8 @@
import { IBaseConfig } from "./IBaseConfig";
export interface IItemConfig extends IBaseConfig {
kind: "aki-item";
/** Items that should be globally blacklisted */
blacklist: string[];
/** Items that can only be found on bosses */
bossItems: string[];
}

View File

@ -92,6 +92,12 @@ export interface IEliminationConfig {
minDist: number;
maxKills: number;
minKills: number;
minBossKills: number;
maxBossKills: number;
weaponCategoryRequirementProb: number;
weaponCategoryRequirements: IWeaponRequirement[];
weaponRequirementProb: number;
weaponRequirements: IWeaponRequirement[];
}
export interface ITarget extends IProbabilityObject {
data: IBossInfo;
@ -102,6 +108,9 @@ export interface IBossInfo {
export interface IBodyPart extends IProbabilityObject {
data: string[];
}
export interface IWeaponRequirement extends IProbabilityObject {
data: string[];
}
export interface IProbabilityObject {
key: string;
relativeProbability: number;

View File

@ -9,6 +9,7 @@ export interface IScavCaseConfig extends IBaseConfig {
rewardItemBlacklist: string[];
allowMultipleMoneyRewardsPerRarity: boolean;
allowMultipleAmmoRewardsPerRarity: boolean;
allowBossItemsAsRewards: boolean;
}
export interface MoneyRewards {
moneyRewardChancePercent: number;

View File

@ -0,0 +1,31 @@
import { ELocationName } from "../../../models/enums/ELocationName";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKnight?: ITargetLocation;
bossZryachiy?: ITargetLocation;
bossBoar?: ITargetLocation;
bossBoarSniper?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}

View File

@ -9,4 +9,5 @@ export interface LootRequest {
itemLimits: Record<string, number>;
itemStackLimits: Record<string, MinMax>;
armorLevelWhitelist: number[];
allowBossItems: boolean;
}

View File

@ -7,7 +7,6 @@ export declare class ItemFilterService {
protected logger: ILogger;
protected databaseServer: DatabaseServer;
protected configServer: ConfigServer;
protected blacklist: string[];
protected itemConfig: IItemConfig;
constructor(logger: ILogger, databaseServer: DatabaseServer, configServer: ConfigServer);
/**
@ -21,4 +20,15 @@ export declare class ItemFilterService {
* @returns string array of blacklisted tempalte ids
*/
getBlacklistedItems(): string[];
/**
* Check if the provided template id is boss item in config/item.json
* @param tpl template id
* @returns true if boss item
*/
isBossItem(tpl: string): boolean;
/**
* Return boss items in config/item.json
* @returns string array of boss item tempalte ids
*/
getBossItems(): string[];
}

View File

@ -62,10 +62,10 @@ export declare class InraidController {
savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void;
/**
* Handle updating player profile post-pmc raid
* @param sessionID session id
* @param offraidData post-raid data
* @param sessionID Session id
* @param postRaidRequest Post-raid data
*/
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Make changes to pmc profile after they've died in raid,
* Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items
@ -91,10 +91,10 @@ export declare class InraidController {
protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void;
/**
* Handle updating the profile post-pscav raid
* @param sessionID session id
* @param offraidData post-raid data of raid
* @param sessionID Session id
* @param postRaidRequest Post-raid data of raid
*/
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
* @param statusOnExit exit value from offraidData object

View File

@ -9,7 +9,7 @@ import { IGetInsuranceCostRequestData } from "../models/eft/insurance/IGetInsura
import { IGetInsuranceCostResponseData } from "../models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "../models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { Insurance } from "../models/eft/profile/IAkiProfile";
import { Insurance, ISystemData } from "../models/eft/profile/IAkiProfile";
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
@ -66,6 +66,14 @@ export declare class InsuranceController {
* @returns void
*/
protected processInsuredItems(insuranceDetails: Insurance[], sessionID: string): void;
/**
* Remove an insurance package from a profile using the package's system data information.
*
* @param sessionID The session ID of the profile to remove the package from.
* @param index The array index of the insurance package to remove.
* @returns void
*/
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void;
/**
* Build an array of items to delete from the insured items.
*
@ -78,7 +86,7 @@ export declare class InsuranceController {
* @param insured - The insured items to build a removal array from.
* @returns An array of IDs representing items that should be deleted.
*/
protected findItemsToDelete(insured: Insurance): string[];
protected findItemsToDelete(insured: Insurance): Set<string>;
/**
* Filters an item based on its existence in the database, raid moddability, and slot requirements.
*
@ -108,7 +116,7 @@ export declare class InsuranceController {
* @param toDelete The array accumulating the IDs of items to be deleted.
* @returns true if the item is marked for deletion, otherwise false.
*/
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: string[]): boolean;
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: Set<string>): boolean;
/**
* Groups child items by their parent IDs in a Map data structure.
*
@ -127,7 +135,7 @@ export declare class InsuranceController {
* @param toDelete The array that accumulates the IDs of the items to be deleted.
* @returns void
*/
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: string[]): void;
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: Set<string>): void;
/**
* Remove items from the insured items that should not be returned to the player.
*
@ -135,7 +143,7 @@ export declare class InsuranceController {
* @param toDelete The items that should be deleted.
* @returns void
*/
protected removeItemsFromInsurance(insured: Insurance, toDelete: string[]): void;
protected removeItemsFromInsurance(insured: Insurance, toDelete: Set<string>): void;
/**
* Handle sending the insurance message to the user that potentially contains the valid insurance items.
*
@ -154,7 +162,7 @@ export declare class InsuranceController {
* @param itemsBeingDeleted List of items that are already slated for removal.
* @returns true if the insured item should be removed from inventory, false otherwise.
*/
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: string[]): boolean;
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: Set<string>): boolean;
/**
* Handle Insure event
* Add insurance to an item

View File

@ -1,81 +1,41 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { RepeatableQuestGenerator } from "../generators/RepeatableQuestGenerator";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData";
import { Exit } from "../models/eft/common/ILocationBase";
import { IPmcData } from "../models/eft/common/IPmcData";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IPmcDataRepeatableQuest, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IPmcDataRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { IRepeatableQuestChangeRequest } from "../models/eft/quests/IRepeatableQuestChangeRequest";
import { ELocationName } from "../models/enums/ELocationName";
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "../utils/RandomUtil";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKojaniy?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}
export declare class RepeatableQuestController {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestGenerator: RepeatableQuestGenerator;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, configServer: ConfigServer);
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, paymentService: PaymentService, objectId: ObjectId, repeatableQuestGenerator: RepeatableQuestGenerator, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* Handle client/repeatalbeQuests/activityPeriods
* Returns an array of objects in the format of repeatable quests to the client.
@ -109,103 +69,10 @@ export declare class RepeatableQuestController {
* @returns IPmcDataRepeatableQuest
*/
protected getRepeatableQuestSubTypeFromProfile(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): IPmcDataRepeatableQuest;
/**
* This method is called by GetClientRepeatableQuests and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
*/
protected generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps
*/
generateDebugDailies(dailiesPool: any, factory: any, number: number): any;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* Generates a valid Elimination quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
protected getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[]): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number): IEliminationCondition;
/**
* Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently
* narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests
@ -215,53 +82,10 @@ export declare class RepeatableQuestController {
* @returns IQuestTypePool
*/
protected generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
protected createBaseQuestPool(repeatableConfig: IRepeatableQuestConfig): IQuestTypePool;
debugLogRepeatableQuestIds(pmcData: IPmcData): void;
protected probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
/**
* Handle RepeatableQuestChange event
*/
changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
changeRepeatableQuest(pmcData: IPmcData, changeRequest: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
}

View File

@ -0,0 +1,183 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { Exit } from "../models/eft/common/ILocationBase";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export declare class RepeatableQuestGenerator {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* This method is called by /GetClientRepeatableQuests/ and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
* @param pmcLevel Player's level for requested items and reward generation
* @param pmcTraderInfo Players traper standing/rep levels
* @param questTypePool Possible quest types pool
* @param repeatableConfig Repeatable quest config
* @returns IRepeatableQuest
*/
generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Generate a randomised Elimination quest
* @param pmcLevel Player's level for requested items and reward generation
* @param traderId Trader from which the quest will be provided
* @param questTypePool Pools for quests (used to avoid redundant quests)
* @param repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns Object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[], allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number, allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
}

View File

@ -111,11 +111,11 @@ export declare class InRaidHelper {
* Add new items found in raid to profile
* Store insurance items in profile
* @param sessionID Session id
* @param pmcData Profile to update
* @param serverProfile Profile to update
* @param postRaidProfile Profile returned by client after a raid
* @returns Updated profile
*/
setInventory(sessionID: string, pmcData: IPmcData, postRaidProfile: IPmcData): IPmcData;
setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): IPmcData;
/**
* Clear pmc inventory of all items except those that are exempt
* Used post-raid to remove items after death

View File

@ -303,6 +303,7 @@ declare class ItemHelper {
* @returns Name of item
*/
getItemName(itemTpl: string): string;
getItemTplsOfBaseType(desiredBaseType: string): string[];
}
declare namespace ItemHelper {
interface ItemSize {

View File

@ -0,0 +1,20 @@
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { ConfigServer } from "../servers/ConfigServer";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ProbabilityObject, ProbabilityObjectArray } from "../utils/RandomUtil";
export declare class RepeatableQuestHelper {
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(mathUtil: MathUtil, jsonUtil: JsonUtil, configServer: ConfigServer);
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
}

View File

@ -161,6 +161,8 @@ export interface ICompletionAvailableForProps extends IAvailableForProps {
}
export interface ILocationConditionProps extends IConditionProps {
target: string[];
weapon?: string[];
weaponCategories?: string[];
}
export interface IKillConditionProps extends IConditionProps {
target: string;
@ -168,6 +170,8 @@ export interface IKillConditionProps extends IConditionProps {
savageRole?: string[];
bodyPart?: string[];
distance?: IDistanceCheck;
weapon?: string[];
weaponCategories?: string[];
}
export interface IDistanceCheck {
compareMethod: string;

View File

@ -52,4 +52,6 @@ export interface AirdropLoot {
itemStackLimits: Record<string, MinMax>;
/** Armor levels to allow inside crate e.g. [4,5,6] */
armorLevelWhitelist?: number[];
/** Should boss items be added to airdrop crate */
allowBossItems: boolean;
}

View File

@ -23,4 +23,5 @@ export interface ISealedAirdropContainerSettings {
weaponModRewardLimits: Record<string, MinMax>;
rewardTypeLimits: Record<string, MinMax>;
ammoBoxWhitelist: string[];
allowBossItems: boolean;
}

View File

@ -1,5 +1,8 @@
import { IBaseConfig } from "./IBaseConfig";
export interface IItemConfig extends IBaseConfig {
kind: "aki-item";
/** Items that should be globally blacklisted */
blacklist: string[];
/** Items that can only be found on bosses */
bossItems: string[];
}

View File

@ -92,6 +92,12 @@ export interface IEliminationConfig {
minDist: number;
maxKills: number;
minKills: number;
minBossKills: number;
maxBossKills: number;
weaponCategoryRequirementProb: number;
weaponCategoryRequirements: IWeaponRequirement[];
weaponRequirementProb: number;
weaponRequirements: IWeaponRequirement[];
}
export interface ITarget extends IProbabilityObject {
data: IBossInfo;
@ -102,6 +108,9 @@ export interface IBossInfo {
export interface IBodyPart extends IProbabilityObject {
data: string[];
}
export interface IWeaponRequirement extends IProbabilityObject {
data: string[];
}
export interface IProbabilityObject {
key: string;
relativeProbability: number;

View File

@ -9,6 +9,7 @@ export interface IScavCaseConfig extends IBaseConfig {
rewardItemBlacklist: string[];
allowMultipleMoneyRewardsPerRarity: boolean;
allowMultipleAmmoRewardsPerRarity: boolean;
allowBossItemsAsRewards: boolean;
}
export interface MoneyRewards {
moneyRewardChancePercent: number;

View File

@ -0,0 +1,31 @@
import { ELocationName } from "../../../models/enums/ELocationName";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKnight?: ITargetLocation;
bossZryachiy?: ITargetLocation;
bossBoar?: ITargetLocation;
bossBoarSniper?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}

View File

@ -9,4 +9,5 @@ export interface LootRequest {
itemLimits: Record<string, number>;
itemStackLimits: Record<string, MinMax>;
armorLevelWhitelist: number[];
allowBossItems: boolean;
}

View File

@ -7,7 +7,6 @@ export declare class ItemFilterService {
protected logger: ILogger;
protected databaseServer: DatabaseServer;
protected configServer: ConfigServer;
protected blacklist: string[];
protected itemConfig: IItemConfig;
constructor(logger: ILogger, databaseServer: DatabaseServer, configServer: ConfigServer);
/**
@ -21,4 +20,15 @@ export declare class ItemFilterService {
* @returns string array of blacklisted tempalte ids
*/
getBlacklistedItems(): string[];
/**
* Check if the provided template id is boss item in config/item.json
* @param tpl template id
* @returns true if boss item
*/
isBossItem(tpl: string): boolean;
/**
* Return boss items in config/item.json
* @returns string array of boss item tempalte ids
*/
getBossItems(): string[];
}

View File

@ -62,10 +62,10 @@ export declare class InraidController {
savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void;
/**
* Handle updating player profile post-pmc raid
* @param sessionID session id
* @param offraidData post-raid data
* @param sessionID Session id
* @param postRaidRequest Post-raid data
*/
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Make changes to pmc profile after they've died in raid,
* Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items
@ -91,10 +91,10 @@ export declare class InraidController {
protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void;
/**
* Handle updating the profile post-pscav raid
* @param sessionID session id
* @param offraidData post-raid data of raid
* @param sessionID Session id
* @param postRaidRequest Post-raid data of raid
*/
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
* @param statusOnExit exit value from offraidData object

View File

@ -9,7 +9,7 @@ import { IGetInsuranceCostRequestData } from "../models/eft/insurance/IGetInsura
import { IGetInsuranceCostResponseData } from "../models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "../models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { Insurance } from "../models/eft/profile/IAkiProfile";
import { Insurance, ISystemData } from "../models/eft/profile/IAkiProfile";
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
@ -66,6 +66,14 @@ export declare class InsuranceController {
* @returns void
*/
protected processInsuredItems(insuranceDetails: Insurance[], sessionID: string): void;
/**
* Remove an insurance package from a profile using the package's system data information.
*
* @param sessionID The session ID of the profile to remove the package from.
* @param index The array index of the insurance package to remove.
* @returns void
*/
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void;
/**
* Build an array of items to delete from the insured items.
*
@ -78,7 +86,7 @@ export declare class InsuranceController {
* @param insured - The insured items to build a removal array from.
* @returns An array of IDs representing items that should be deleted.
*/
protected findItemsToDelete(insured: Insurance): string[];
protected findItemsToDelete(insured: Insurance): Set<string>;
/**
* Filters an item based on its existence in the database, raid moddability, and slot requirements.
*
@ -108,7 +116,7 @@ export declare class InsuranceController {
* @param toDelete The array accumulating the IDs of items to be deleted.
* @returns true if the item is marked for deletion, otherwise false.
*/
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: string[]): boolean;
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: Set<string>): boolean;
/**
* Groups child items by their parent IDs in a Map data structure.
*
@ -127,7 +135,7 @@ export declare class InsuranceController {
* @param toDelete The array that accumulates the IDs of the items to be deleted.
* @returns void
*/
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: string[]): void;
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: Set<string>): void;
/**
* Remove items from the insured items that should not be returned to the player.
*
@ -135,7 +143,7 @@ export declare class InsuranceController {
* @param toDelete The items that should be deleted.
* @returns void
*/
protected removeItemsFromInsurance(insured: Insurance, toDelete: string[]): void;
protected removeItemsFromInsurance(insured: Insurance, toDelete: Set<string>): void;
/**
* Handle sending the insurance message to the user that potentially contains the valid insurance items.
*
@ -154,7 +162,7 @@ export declare class InsuranceController {
* @param itemsBeingDeleted List of items that are already slated for removal.
* @returns true if the insured item should be removed from inventory, false otherwise.
*/
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: string[]): boolean;
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: Set<string>): boolean;
/**
* Handle Insure event
* Add insurance to an item

View File

@ -1,81 +1,41 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { RepeatableQuestGenerator } from "../generators/RepeatableQuestGenerator";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData";
import { Exit } from "../models/eft/common/ILocationBase";
import { IPmcData } from "../models/eft/common/IPmcData";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IPmcDataRepeatableQuest, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IPmcDataRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { IRepeatableQuestChangeRequest } from "../models/eft/quests/IRepeatableQuestChangeRequest";
import { ELocationName } from "../models/enums/ELocationName";
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "../utils/RandomUtil";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKojaniy?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}
export declare class RepeatableQuestController {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestGenerator: RepeatableQuestGenerator;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, configServer: ConfigServer);
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, paymentService: PaymentService, objectId: ObjectId, repeatableQuestGenerator: RepeatableQuestGenerator, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* Handle client/repeatalbeQuests/activityPeriods
* Returns an array of objects in the format of repeatable quests to the client.
@ -109,103 +69,10 @@ export declare class RepeatableQuestController {
* @returns IPmcDataRepeatableQuest
*/
protected getRepeatableQuestSubTypeFromProfile(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): IPmcDataRepeatableQuest;
/**
* This method is called by GetClientRepeatableQuests and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
*/
protected generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps
*/
generateDebugDailies(dailiesPool: any, factory: any, number: number): any;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* Generates a valid Elimination quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
protected getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[]): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number): IEliminationCondition;
/**
* Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently
* narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests
@ -215,53 +82,10 @@ export declare class RepeatableQuestController {
* @returns IQuestTypePool
*/
protected generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
protected createBaseQuestPool(repeatableConfig: IRepeatableQuestConfig): IQuestTypePool;
debugLogRepeatableQuestIds(pmcData: IPmcData): void;
protected probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
/**
* Handle RepeatableQuestChange event
*/
changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
changeRepeatableQuest(pmcData: IPmcData, changeRequest: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
}

View File

@ -0,0 +1,183 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { Exit } from "../models/eft/common/ILocationBase";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export declare class RepeatableQuestGenerator {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* This method is called by /GetClientRepeatableQuests/ and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
* @param pmcLevel Player's level for requested items and reward generation
* @param pmcTraderInfo Players traper standing/rep levels
* @param questTypePool Possible quest types pool
* @param repeatableConfig Repeatable quest config
* @returns IRepeatableQuest
*/
generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Generate a randomised Elimination quest
* @param pmcLevel Player's level for requested items and reward generation
* @param traderId Trader from which the quest will be provided
* @param questTypePool Pools for quests (used to avoid redundant quests)
* @param repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns Object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[], allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number, allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
}

View File

@ -111,11 +111,11 @@ export declare class InRaidHelper {
* Add new items found in raid to profile
* Store insurance items in profile
* @param sessionID Session id
* @param pmcData Profile to update
* @param serverProfile Profile to update
* @param postRaidProfile Profile returned by client after a raid
* @returns Updated profile
*/
setInventory(sessionID: string, pmcData: IPmcData, postRaidProfile: IPmcData): IPmcData;
setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): IPmcData;
/**
* Clear pmc inventory of all items except those that are exempt
* Used post-raid to remove items after death

View File

@ -303,6 +303,7 @@ declare class ItemHelper {
* @returns Name of item
*/
getItemName(itemTpl: string): string;
getItemTplsOfBaseType(desiredBaseType: string): string[];
}
declare namespace ItemHelper {
interface ItemSize {

View File

@ -0,0 +1,20 @@
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { ConfigServer } from "../servers/ConfigServer";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ProbabilityObject, ProbabilityObjectArray } from "../utils/RandomUtil";
export declare class RepeatableQuestHelper {
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(mathUtil: MathUtil, jsonUtil: JsonUtil, configServer: ConfigServer);
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
}

View File

@ -161,6 +161,8 @@ export interface ICompletionAvailableForProps extends IAvailableForProps {
}
export interface ILocationConditionProps extends IConditionProps {
target: string[];
weapon?: string[];
weaponCategories?: string[];
}
export interface IKillConditionProps extends IConditionProps {
target: string;
@ -168,6 +170,8 @@ export interface IKillConditionProps extends IConditionProps {
savageRole?: string[];
bodyPart?: string[];
distance?: IDistanceCheck;
weapon?: string[];
weaponCategories?: string[];
}
export interface IDistanceCheck {
compareMethod: string;

View File

@ -52,4 +52,6 @@ export interface AirdropLoot {
itemStackLimits: Record<string, MinMax>;
/** Armor levels to allow inside crate e.g. [4,5,6] */
armorLevelWhitelist?: number[];
/** Should boss items be added to airdrop crate */
allowBossItems: boolean;
}

View File

@ -23,4 +23,5 @@ export interface ISealedAirdropContainerSettings {
weaponModRewardLimits: Record<string, MinMax>;
rewardTypeLimits: Record<string, MinMax>;
ammoBoxWhitelist: string[];
allowBossItems: boolean;
}

View File

@ -1,5 +1,8 @@
import { IBaseConfig } from "./IBaseConfig";
export interface IItemConfig extends IBaseConfig {
kind: "aki-item";
/** Items that should be globally blacklisted */
blacklist: string[];
/** Items that can only be found on bosses */
bossItems: string[];
}

View File

@ -92,6 +92,12 @@ export interface IEliminationConfig {
minDist: number;
maxKills: number;
minKills: number;
minBossKills: number;
maxBossKills: number;
weaponCategoryRequirementProb: number;
weaponCategoryRequirements: IWeaponRequirement[];
weaponRequirementProb: number;
weaponRequirements: IWeaponRequirement[];
}
export interface ITarget extends IProbabilityObject {
data: IBossInfo;
@ -102,6 +108,9 @@ export interface IBossInfo {
export interface IBodyPart extends IProbabilityObject {
data: string[];
}
export interface IWeaponRequirement extends IProbabilityObject {
data: string[];
}
export interface IProbabilityObject {
key: string;
relativeProbability: number;

View File

@ -9,6 +9,7 @@ export interface IScavCaseConfig extends IBaseConfig {
rewardItemBlacklist: string[];
allowMultipleMoneyRewardsPerRarity: boolean;
allowMultipleAmmoRewardsPerRarity: boolean;
allowBossItemsAsRewards: boolean;
}
export interface MoneyRewards {
moneyRewardChancePercent: number;

View File

@ -0,0 +1,31 @@
import { ELocationName } from "../../../models/enums/ELocationName";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKnight?: ITargetLocation;
bossZryachiy?: ITargetLocation;
bossBoar?: ITargetLocation;
bossBoarSniper?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}

View File

@ -9,4 +9,5 @@ export interface LootRequest {
itemLimits: Record<string, number>;
itemStackLimits: Record<string, MinMax>;
armorLevelWhitelist: number[];
allowBossItems: boolean;
}

View File

@ -7,7 +7,6 @@ export declare class ItemFilterService {
protected logger: ILogger;
protected databaseServer: DatabaseServer;
protected configServer: ConfigServer;
protected blacklist: string[];
protected itemConfig: IItemConfig;
constructor(logger: ILogger, databaseServer: DatabaseServer, configServer: ConfigServer);
/**
@ -21,4 +20,15 @@ export declare class ItemFilterService {
* @returns string array of blacklisted tempalte ids
*/
getBlacklistedItems(): string[];
/**
* Check if the provided template id is boss item in config/item.json
* @param tpl template id
* @returns true if boss item
*/
isBossItem(tpl: string): boolean;
/**
* Return boss items in config/item.json
* @returns string array of boss item tempalte ids
*/
getBossItems(): string[];
}

View File

@ -62,10 +62,10 @@ export declare class InraidController {
savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void;
/**
* Handle updating player profile post-pmc raid
* @param sessionID session id
* @param offraidData post-raid data
* @param sessionID Session id
* @param postRaidRequest Post-raid data
*/
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Make changes to pmc profile after they've died in raid,
* Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items
@ -91,10 +91,10 @@ export declare class InraidController {
protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void;
/**
* Handle updating the profile post-pscav raid
* @param sessionID session id
* @param offraidData post-raid data of raid
* @param sessionID Session id
* @param postRaidRequest Post-raid data of raid
*/
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
* @param statusOnExit exit value from offraidData object

View File

@ -9,7 +9,7 @@ import { IGetInsuranceCostRequestData } from "../models/eft/insurance/IGetInsura
import { IGetInsuranceCostResponseData } from "../models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "../models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { Insurance } from "../models/eft/profile/IAkiProfile";
import { Insurance, ISystemData } from "../models/eft/profile/IAkiProfile";
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
@ -66,6 +66,14 @@ export declare class InsuranceController {
* @returns void
*/
protected processInsuredItems(insuranceDetails: Insurance[], sessionID: string): void;
/**
* Remove an insurance package from a profile using the package's system data information.
*
* @param sessionID The session ID of the profile to remove the package from.
* @param index The array index of the insurance package to remove.
* @returns void
*/
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void;
/**
* Build an array of items to delete from the insured items.
*
@ -78,7 +86,7 @@ export declare class InsuranceController {
* @param insured - The insured items to build a removal array from.
* @returns An array of IDs representing items that should be deleted.
*/
protected findItemsToDelete(insured: Insurance): string[];
protected findItemsToDelete(insured: Insurance): Set<string>;
/**
* Filters an item based on its existence in the database, raid moddability, and slot requirements.
*
@ -108,7 +116,7 @@ export declare class InsuranceController {
* @param toDelete The array accumulating the IDs of items to be deleted.
* @returns true if the item is marked for deletion, otherwise false.
*/
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: string[]): boolean;
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: Set<string>): boolean;
/**
* Groups child items by their parent IDs in a Map data structure.
*
@ -127,7 +135,7 @@ export declare class InsuranceController {
* @param toDelete The array that accumulates the IDs of the items to be deleted.
* @returns void
*/
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: string[]): void;
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: Set<string>): void;
/**
* Remove items from the insured items that should not be returned to the player.
*
@ -135,7 +143,7 @@ export declare class InsuranceController {
* @param toDelete The items that should be deleted.
* @returns void
*/
protected removeItemsFromInsurance(insured: Insurance, toDelete: string[]): void;
protected removeItemsFromInsurance(insured: Insurance, toDelete: Set<string>): void;
/**
* Handle sending the insurance message to the user that potentially contains the valid insurance items.
*
@ -154,7 +162,7 @@ export declare class InsuranceController {
* @param itemsBeingDeleted List of items that are already slated for removal.
* @returns true if the insured item should be removed from inventory, false otherwise.
*/
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: string[]): boolean;
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: Set<string>): boolean;
/**
* Handle Insure event
* Add insurance to an item

View File

@ -1,81 +1,41 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { RepeatableQuestGenerator } from "../generators/RepeatableQuestGenerator";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData";
import { Exit } from "../models/eft/common/ILocationBase";
import { IPmcData } from "../models/eft/common/IPmcData";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IPmcDataRepeatableQuest, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IPmcDataRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { IRepeatableQuestChangeRequest } from "../models/eft/quests/IRepeatableQuestChangeRequest";
import { ELocationName } from "../models/enums/ELocationName";
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "../utils/RandomUtil";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKojaniy?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}
export declare class RepeatableQuestController {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestGenerator: RepeatableQuestGenerator;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, configServer: ConfigServer);
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, paymentService: PaymentService, objectId: ObjectId, repeatableQuestGenerator: RepeatableQuestGenerator, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* Handle client/repeatalbeQuests/activityPeriods
* Returns an array of objects in the format of repeatable quests to the client.
@ -109,103 +69,10 @@ export declare class RepeatableQuestController {
* @returns IPmcDataRepeatableQuest
*/
protected getRepeatableQuestSubTypeFromProfile(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): IPmcDataRepeatableQuest;
/**
* This method is called by GetClientRepeatableQuests and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
*/
protected generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps
*/
generateDebugDailies(dailiesPool: any, factory: any, number: number): any;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* Generates a valid Elimination quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
protected getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[]): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number): IEliminationCondition;
/**
* Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently
* narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests
@ -215,53 +82,10 @@ export declare class RepeatableQuestController {
* @returns IQuestTypePool
*/
protected generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
protected createBaseQuestPool(repeatableConfig: IRepeatableQuestConfig): IQuestTypePool;
debugLogRepeatableQuestIds(pmcData: IPmcData): void;
protected probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
/**
* Handle RepeatableQuestChange event
*/
changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
changeRepeatableQuest(pmcData: IPmcData, changeRequest: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
}

View File

@ -0,0 +1,183 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { Exit } from "../models/eft/common/ILocationBase";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export declare class RepeatableQuestGenerator {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* This method is called by /GetClientRepeatableQuests/ and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
* @param pmcLevel Player's level for requested items and reward generation
* @param pmcTraderInfo Players traper standing/rep levels
* @param questTypePool Possible quest types pool
* @param repeatableConfig Repeatable quest config
* @returns IRepeatableQuest
*/
generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Generate a randomised Elimination quest
* @param pmcLevel Player's level for requested items and reward generation
* @param traderId Trader from which the quest will be provided
* @param questTypePool Pools for quests (used to avoid redundant quests)
* @param repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns Object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[], allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number, allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
}

View File

@ -111,11 +111,11 @@ export declare class InRaidHelper {
* Add new items found in raid to profile
* Store insurance items in profile
* @param sessionID Session id
* @param pmcData Profile to update
* @param serverProfile Profile to update
* @param postRaidProfile Profile returned by client after a raid
* @returns Updated profile
*/
setInventory(sessionID: string, pmcData: IPmcData, postRaidProfile: IPmcData): IPmcData;
setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): IPmcData;
/**
* Clear pmc inventory of all items except those that are exempt
* Used post-raid to remove items after death

View File

@ -303,6 +303,7 @@ declare class ItemHelper {
* @returns Name of item
*/
getItemName(itemTpl: string): string;
getItemTplsOfBaseType(desiredBaseType: string): string[];
}
declare namespace ItemHelper {
interface ItemSize {

View File

@ -0,0 +1,20 @@
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { ConfigServer } from "../servers/ConfigServer";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ProbabilityObject, ProbabilityObjectArray } from "../utils/RandomUtil";
export declare class RepeatableQuestHelper {
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(mathUtil: MathUtil, jsonUtil: JsonUtil, configServer: ConfigServer);
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
}

View File

@ -161,6 +161,8 @@ export interface ICompletionAvailableForProps extends IAvailableForProps {
}
export interface ILocationConditionProps extends IConditionProps {
target: string[];
weapon?: string[];
weaponCategories?: string[];
}
export interface IKillConditionProps extends IConditionProps {
target: string;
@ -168,6 +170,8 @@ export interface IKillConditionProps extends IConditionProps {
savageRole?: string[];
bodyPart?: string[];
distance?: IDistanceCheck;
weapon?: string[];
weaponCategories?: string[];
}
export interface IDistanceCheck {
compareMethod: string;

View File

@ -52,4 +52,6 @@ export interface AirdropLoot {
itemStackLimits: Record<string, MinMax>;
/** Armor levels to allow inside crate e.g. [4,5,6] */
armorLevelWhitelist?: number[];
/** Should boss items be added to airdrop crate */
allowBossItems: boolean;
}

View File

@ -23,4 +23,5 @@ export interface ISealedAirdropContainerSettings {
weaponModRewardLimits: Record<string, MinMax>;
rewardTypeLimits: Record<string, MinMax>;
ammoBoxWhitelist: string[];
allowBossItems: boolean;
}

View File

@ -1,5 +1,8 @@
import { IBaseConfig } from "./IBaseConfig";
export interface IItemConfig extends IBaseConfig {
kind: "aki-item";
/** Items that should be globally blacklisted */
blacklist: string[];
/** Items that can only be found on bosses */
bossItems: string[];
}

View File

@ -92,6 +92,12 @@ export interface IEliminationConfig {
minDist: number;
maxKills: number;
minKills: number;
minBossKills: number;
maxBossKills: number;
weaponCategoryRequirementProb: number;
weaponCategoryRequirements: IWeaponRequirement[];
weaponRequirementProb: number;
weaponRequirements: IWeaponRequirement[];
}
export interface ITarget extends IProbabilityObject {
data: IBossInfo;
@ -102,6 +108,9 @@ export interface IBossInfo {
export interface IBodyPart extends IProbabilityObject {
data: string[];
}
export interface IWeaponRequirement extends IProbabilityObject {
data: string[];
}
export interface IProbabilityObject {
key: string;
relativeProbability: number;

View File

@ -9,6 +9,7 @@ export interface IScavCaseConfig extends IBaseConfig {
rewardItemBlacklist: string[];
allowMultipleMoneyRewardsPerRarity: boolean;
allowMultipleAmmoRewardsPerRarity: boolean;
allowBossItemsAsRewards: boolean;
}
export interface MoneyRewards {
moneyRewardChancePercent: number;

View File

@ -0,0 +1,31 @@
import { ELocationName } from "../../../models/enums/ELocationName";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKnight?: ITargetLocation;
bossZryachiy?: ITargetLocation;
bossBoar?: ITargetLocation;
bossBoarSniper?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}

View File

@ -9,4 +9,5 @@ export interface LootRequest {
itemLimits: Record<string, number>;
itemStackLimits: Record<string, MinMax>;
armorLevelWhitelist: number[];
allowBossItems: boolean;
}

View File

@ -7,7 +7,6 @@ export declare class ItemFilterService {
protected logger: ILogger;
protected databaseServer: DatabaseServer;
protected configServer: ConfigServer;
protected blacklist: string[];
protected itemConfig: IItemConfig;
constructor(logger: ILogger, databaseServer: DatabaseServer, configServer: ConfigServer);
/**
@ -21,4 +20,15 @@ export declare class ItemFilterService {
* @returns string array of blacklisted tempalte ids
*/
getBlacklistedItems(): string[];
/**
* Check if the provided template id is boss item in config/item.json
* @param tpl template id
* @returns true if boss item
*/
isBossItem(tpl: string): boolean;
/**
* Return boss items in config/item.json
* @returns string array of boss item tempalte ids
*/
getBossItems(): string[];
}

View File

@ -62,10 +62,10 @@ export declare class InraidController {
savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void;
/**
* Handle updating player profile post-pmc raid
* @param sessionID session id
* @param offraidData post-raid data
* @param sessionID Session id
* @param postRaidRequest Post-raid data
*/
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Make changes to pmc profile after they've died in raid,
* Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items
@ -91,10 +91,10 @@ export declare class InraidController {
protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void;
/**
* Handle updating the profile post-pscav raid
* @param sessionID session id
* @param offraidData post-raid data of raid
* @param sessionID Session id
* @param postRaidRequest Post-raid data of raid
*/
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
* @param statusOnExit exit value from offraidData object

View File

@ -9,7 +9,7 @@ import { IGetInsuranceCostRequestData } from "../models/eft/insurance/IGetInsura
import { IGetInsuranceCostResponseData } from "../models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "../models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { Insurance } from "../models/eft/profile/IAkiProfile";
import { Insurance, ISystemData } from "../models/eft/profile/IAkiProfile";
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
@ -66,6 +66,14 @@ export declare class InsuranceController {
* @returns void
*/
protected processInsuredItems(insuranceDetails: Insurance[], sessionID: string): void;
/**
* Remove an insurance package from a profile using the package's system data information.
*
* @param sessionID The session ID of the profile to remove the package from.
* @param index The array index of the insurance package to remove.
* @returns void
*/
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void;
/**
* Build an array of items to delete from the insured items.
*
@ -78,7 +86,7 @@ export declare class InsuranceController {
* @param insured - The insured items to build a removal array from.
* @returns An array of IDs representing items that should be deleted.
*/
protected findItemsToDelete(insured: Insurance): string[];
protected findItemsToDelete(insured: Insurance): Set<string>;
/**
* Filters an item based on its existence in the database, raid moddability, and slot requirements.
*
@ -108,7 +116,7 @@ export declare class InsuranceController {
* @param toDelete The array accumulating the IDs of items to be deleted.
* @returns true if the item is marked for deletion, otherwise false.
*/
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: string[]): boolean;
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: Set<string>): boolean;
/**
* Groups child items by their parent IDs in a Map data structure.
*
@ -127,7 +135,7 @@ export declare class InsuranceController {
* @param toDelete The array that accumulates the IDs of the items to be deleted.
* @returns void
*/
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: string[]): void;
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: Set<string>): void;
/**
* Remove items from the insured items that should not be returned to the player.
*
@ -135,7 +143,7 @@ export declare class InsuranceController {
* @param toDelete The items that should be deleted.
* @returns void
*/
protected removeItemsFromInsurance(insured: Insurance, toDelete: string[]): void;
protected removeItemsFromInsurance(insured: Insurance, toDelete: Set<string>): void;
/**
* Handle sending the insurance message to the user that potentially contains the valid insurance items.
*
@ -154,7 +162,7 @@ export declare class InsuranceController {
* @param itemsBeingDeleted List of items that are already slated for removal.
* @returns true if the insured item should be removed from inventory, false otherwise.
*/
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: string[]): boolean;
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: Set<string>): boolean;
/**
* Handle Insure event
* Add insurance to an item

View File

@ -1,81 +1,41 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { RepeatableQuestGenerator } from "../generators/RepeatableQuestGenerator";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData";
import { Exit } from "../models/eft/common/ILocationBase";
import { IPmcData } from "../models/eft/common/IPmcData";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IPmcDataRepeatableQuest, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IPmcDataRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { IRepeatableQuestChangeRequest } from "../models/eft/quests/IRepeatableQuestChangeRequest";
import { ELocationName } from "../models/enums/ELocationName";
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "../utils/RandomUtil";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKojaniy?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}
export declare class RepeatableQuestController {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestGenerator: RepeatableQuestGenerator;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, configServer: ConfigServer);
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, paymentService: PaymentService, objectId: ObjectId, repeatableQuestGenerator: RepeatableQuestGenerator, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* Handle client/repeatalbeQuests/activityPeriods
* Returns an array of objects in the format of repeatable quests to the client.
@ -109,103 +69,10 @@ export declare class RepeatableQuestController {
* @returns IPmcDataRepeatableQuest
*/
protected getRepeatableQuestSubTypeFromProfile(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): IPmcDataRepeatableQuest;
/**
* This method is called by GetClientRepeatableQuests and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
*/
protected generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps
*/
generateDebugDailies(dailiesPool: any, factory: any, number: number): any;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* Generates a valid Elimination quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
protected getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[]): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number): IEliminationCondition;
/**
* Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently
* narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests
@ -215,53 +82,10 @@ export declare class RepeatableQuestController {
* @returns IQuestTypePool
*/
protected generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
protected createBaseQuestPool(repeatableConfig: IRepeatableQuestConfig): IQuestTypePool;
debugLogRepeatableQuestIds(pmcData: IPmcData): void;
protected probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
/**
* Handle RepeatableQuestChange event
*/
changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
changeRepeatableQuest(pmcData: IPmcData, changeRequest: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
}

View File

@ -0,0 +1,183 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { Exit } from "../models/eft/common/ILocationBase";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export declare class RepeatableQuestGenerator {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* This method is called by /GetClientRepeatableQuests/ and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
* @param pmcLevel Player's level for requested items and reward generation
* @param pmcTraderInfo Players traper standing/rep levels
* @param questTypePool Possible quest types pool
* @param repeatableConfig Repeatable quest config
* @returns IRepeatableQuest
*/
generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Generate a randomised Elimination quest
* @param pmcLevel Player's level for requested items and reward generation
* @param traderId Trader from which the quest will be provided
* @param questTypePool Pools for quests (used to avoid redundant quests)
* @param repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns Object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[], allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number, allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
}

View File

@ -111,11 +111,11 @@ export declare class InRaidHelper {
* Add new items found in raid to profile
* Store insurance items in profile
* @param sessionID Session id
* @param pmcData Profile to update
* @param serverProfile Profile to update
* @param postRaidProfile Profile returned by client after a raid
* @returns Updated profile
*/
setInventory(sessionID: string, pmcData: IPmcData, postRaidProfile: IPmcData): IPmcData;
setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): IPmcData;
/**
* Clear pmc inventory of all items except those that are exempt
* Used post-raid to remove items after death

View File

@ -303,6 +303,7 @@ declare class ItemHelper {
* @returns Name of item
*/
getItemName(itemTpl: string): string;
getItemTplsOfBaseType(desiredBaseType: string): string[];
}
declare namespace ItemHelper {
interface ItemSize {

View File

@ -0,0 +1,20 @@
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { ConfigServer } from "../servers/ConfigServer";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ProbabilityObject, ProbabilityObjectArray } from "../utils/RandomUtil";
export declare class RepeatableQuestHelper {
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(mathUtil: MathUtil, jsonUtil: JsonUtil, configServer: ConfigServer);
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
}

View File

@ -161,6 +161,8 @@ export interface ICompletionAvailableForProps extends IAvailableForProps {
}
export interface ILocationConditionProps extends IConditionProps {
target: string[];
weapon?: string[];
weaponCategories?: string[];
}
export interface IKillConditionProps extends IConditionProps {
target: string;
@ -168,6 +170,8 @@ export interface IKillConditionProps extends IConditionProps {
savageRole?: string[];
bodyPart?: string[];
distance?: IDistanceCheck;
weapon?: string[];
weaponCategories?: string[];
}
export interface IDistanceCheck {
compareMethod: string;

View File

@ -52,4 +52,6 @@ export interface AirdropLoot {
itemStackLimits: Record<string, MinMax>;
/** Armor levels to allow inside crate e.g. [4,5,6] */
armorLevelWhitelist?: number[];
/** Should boss items be added to airdrop crate */
allowBossItems: boolean;
}

View File

@ -23,4 +23,5 @@ export interface ISealedAirdropContainerSettings {
weaponModRewardLimits: Record<string, MinMax>;
rewardTypeLimits: Record<string, MinMax>;
ammoBoxWhitelist: string[];
allowBossItems: boolean;
}

View File

@ -1,5 +1,8 @@
import { IBaseConfig } from "./IBaseConfig";
export interface IItemConfig extends IBaseConfig {
kind: "aki-item";
/** Items that should be globally blacklisted */
blacklist: string[];
/** Items that can only be found on bosses */
bossItems: string[];
}

View File

@ -92,6 +92,12 @@ export interface IEliminationConfig {
minDist: number;
maxKills: number;
minKills: number;
minBossKills: number;
maxBossKills: number;
weaponCategoryRequirementProb: number;
weaponCategoryRequirements: IWeaponRequirement[];
weaponRequirementProb: number;
weaponRequirements: IWeaponRequirement[];
}
export interface ITarget extends IProbabilityObject {
data: IBossInfo;
@ -102,6 +108,9 @@ export interface IBossInfo {
export interface IBodyPart extends IProbabilityObject {
data: string[];
}
export interface IWeaponRequirement extends IProbabilityObject {
data: string[];
}
export interface IProbabilityObject {
key: string;
relativeProbability: number;

View File

@ -9,6 +9,7 @@ export interface IScavCaseConfig extends IBaseConfig {
rewardItemBlacklist: string[];
allowMultipleMoneyRewardsPerRarity: boolean;
allowMultipleAmmoRewardsPerRarity: boolean;
allowBossItemsAsRewards: boolean;
}
export interface MoneyRewards {
moneyRewardChancePercent: number;

View File

@ -0,0 +1,31 @@
import { ELocationName } from "../../../models/enums/ELocationName";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKnight?: ITargetLocation;
bossZryachiy?: ITargetLocation;
bossBoar?: ITargetLocation;
bossBoarSniper?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}

View File

@ -9,4 +9,5 @@ export interface LootRequest {
itemLimits: Record<string, number>;
itemStackLimits: Record<string, MinMax>;
armorLevelWhitelist: number[];
allowBossItems: boolean;
}

View File

@ -7,7 +7,6 @@ export declare class ItemFilterService {
protected logger: ILogger;
protected databaseServer: DatabaseServer;
protected configServer: ConfigServer;
protected blacklist: string[];
protected itemConfig: IItemConfig;
constructor(logger: ILogger, databaseServer: DatabaseServer, configServer: ConfigServer);
/**
@ -21,4 +20,15 @@ export declare class ItemFilterService {
* @returns string array of blacklisted tempalte ids
*/
getBlacklistedItems(): string[];
/**
* Check if the provided template id is boss item in config/item.json
* @param tpl template id
* @returns true if boss item
*/
isBossItem(tpl: string): boolean;
/**
* Return boss items in config/item.json
* @returns string array of boss item tempalte ids
*/
getBossItems(): string[];
}

View File

@ -62,10 +62,10 @@ export declare class InraidController {
savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void;
/**
* Handle updating player profile post-pmc raid
* @param sessionID session id
* @param offraidData post-raid data
* @param sessionID Session id
* @param postRaidRequest Post-raid data
*/
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Make changes to pmc profile after they've died in raid,
* Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items
@ -91,10 +91,10 @@ export declare class InraidController {
protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void;
/**
* Handle updating the profile post-pscav raid
* @param sessionID session id
* @param offraidData post-raid data of raid
* @param sessionID Session id
* @param postRaidRequest Post-raid data of raid
*/
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
* @param statusOnExit exit value from offraidData object

View File

@ -9,7 +9,7 @@ import { IGetInsuranceCostRequestData } from "../models/eft/insurance/IGetInsura
import { IGetInsuranceCostResponseData } from "../models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "../models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { Insurance } from "../models/eft/profile/IAkiProfile";
import { Insurance, ISystemData } from "../models/eft/profile/IAkiProfile";
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
@ -66,6 +66,14 @@ export declare class InsuranceController {
* @returns void
*/
protected processInsuredItems(insuranceDetails: Insurance[], sessionID: string): void;
/**
* Remove an insurance package from a profile using the package's system data information.
*
* @param sessionID The session ID of the profile to remove the package from.
* @param index The array index of the insurance package to remove.
* @returns void
*/
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void;
/**
* Build an array of items to delete from the insured items.
*
@ -78,7 +86,7 @@ export declare class InsuranceController {
* @param insured - The insured items to build a removal array from.
* @returns An array of IDs representing items that should be deleted.
*/
protected findItemsToDelete(insured: Insurance): string[];
protected findItemsToDelete(insured: Insurance): Set<string>;
/**
* Filters an item based on its existence in the database, raid moddability, and slot requirements.
*
@ -108,7 +116,7 @@ export declare class InsuranceController {
* @param toDelete The array accumulating the IDs of items to be deleted.
* @returns true if the item is marked for deletion, otherwise false.
*/
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: string[]): boolean;
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: Set<string>): boolean;
/**
* Groups child items by their parent IDs in a Map data structure.
*
@ -127,7 +135,7 @@ export declare class InsuranceController {
* @param toDelete The array that accumulates the IDs of the items to be deleted.
* @returns void
*/
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: string[]): void;
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: Set<string>): void;
/**
* Remove items from the insured items that should not be returned to the player.
*
@ -135,7 +143,7 @@ export declare class InsuranceController {
* @param toDelete The items that should be deleted.
* @returns void
*/
protected removeItemsFromInsurance(insured: Insurance, toDelete: string[]): void;
protected removeItemsFromInsurance(insured: Insurance, toDelete: Set<string>): void;
/**
* Handle sending the insurance message to the user that potentially contains the valid insurance items.
*
@ -154,7 +162,7 @@ export declare class InsuranceController {
* @param itemsBeingDeleted List of items that are already slated for removal.
* @returns true if the insured item should be removed from inventory, false otherwise.
*/
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: string[]): boolean;
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: Set<string>): boolean;
/**
* Handle Insure event
* Add insurance to an item

View File

@ -1,81 +1,41 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { RepeatableQuestGenerator } from "../generators/RepeatableQuestGenerator";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData";
import { Exit } from "../models/eft/common/ILocationBase";
import { IPmcData } from "../models/eft/common/IPmcData";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IPmcDataRepeatableQuest, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IPmcDataRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { IRepeatableQuestChangeRequest } from "../models/eft/quests/IRepeatableQuestChangeRequest";
import { ELocationName } from "../models/enums/ELocationName";
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "../utils/RandomUtil";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKojaniy?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}
export declare class RepeatableQuestController {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestGenerator: RepeatableQuestGenerator;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, configServer: ConfigServer);
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, paymentService: PaymentService, objectId: ObjectId, repeatableQuestGenerator: RepeatableQuestGenerator, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* Handle client/repeatalbeQuests/activityPeriods
* Returns an array of objects in the format of repeatable quests to the client.
@ -109,103 +69,10 @@ export declare class RepeatableQuestController {
* @returns IPmcDataRepeatableQuest
*/
protected getRepeatableQuestSubTypeFromProfile(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): IPmcDataRepeatableQuest;
/**
* This method is called by GetClientRepeatableQuests and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
*/
protected generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps
*/
generateDebugDailies(dailiesPool: any, factory: any, number: number): any;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* Generates a valid Elimination quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
protected getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[]): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number): IEliminationCondition;
/**
* Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently
* narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests
@ -215,53 +82,10 @@ export declare class RepeatableQuestController {
* @returns IQuestTypePool
*/
protected generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
protected createBaseQuestPool(repeatableConfig: IRepeatableQuestConfig): IQuestTypePool;
debugLogRepeatableQuestIds(pmcData: IPmcData): void;
protected probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
/**
* Handle RepeatableQuestChange event
*/
changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
changeRepeatableQuest(pmcData: IPmcData, changeRequest: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
}

View File

@ -0,0 +1,183 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { Exit } from "../models/eft/common/ILocationBase";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export declare class RepeatableQuestGenerator {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* This method is called by /GetClientRepeatableQuests/ and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
* @param pmcLevel Player's level for requested items and reward generation
* @param pmcTraderInfo Players traper standing/rep levels
* @param questTypePool Possible quest types pool
* @param repeatableConfig Repeatable quest config
* @returns IRepeatableQuest
*/
generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Generate a randomised Elimination quest
* @param pmcLevel Player's level for requested items and reward generation
* @param traderId Trader from which the quest will be provided
* @param questTypePool Pools for quests (used to avoid redundant quests)
* @param repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns Object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[], allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number, allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
}

View File

@ -111,11 +111,11 @@ export declare class InRaidHelper {
* Add new items found in raid to profile
* Store insurance items in profile
* @param sessionID Session id
* @param pmcData Profile to update
* @param serverProfile Profile to update
* @param postRaidProfile Profile returned by client after a raid
* @returns Updated profile
*/
setInventory(sessionID: string, pmcData: IPmcData, postRaidProfile: IPmcData): IPmcData;
setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): IPmcData;
/**
* Clear pmc inventory of all items except those that are exempt
* Used post-raid to remove items after death

View File

@ -303,6 +303,7 @@ declare class ItemHelper {
* @returns Name of item
*/
getItemName(itemTpl: string): string;
getItemTplsOfBaseType(desiredBaseType: string): string[];
}
declare namespace ItemHelper {
interface ItemSize {

View File

@ -0,0 +1,20 @@
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { ConfigServer } from "../servers/ConfigServer";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ProbabilityObject, ProbabilityObjectArray } from "../utils/RandomUtil";
export declare class RepeatableQuestHelper {
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(mathUtil: MathUtil, jsonUtil: JsonUtil, configServer: ConfigServer);
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
}

View File

@ -161,6 +161,8 @@ export interface ICompletionAvailableForProps extends IAvailableForProps {
}
export interface ILocationConditionProps extends IConditionProps {
target: string[];
weapon?: string[];
weaponCategories?: string[];
}
export interface IKillConditionProps extends IConditionProps {
target: string;
@ -168,6 +170,8 @@ export interface IKillConditionProps extends IConditionProps {
savageRole?: string[];
bodyPart?: string[];
distance?: IDistanceCheck;
weapon?: string[];
weaponCategories?: string[];
}
export interface IDistanceCheck {
compareMethod: string;

View File

@ -52,4 +52,6 @@ export interface AirdropLoot {
itemStackLimits: Record<string, MinMax>;
/** Armor levels to allow inside crate e.g. [4,5,6] */
armorLevelWhitelist?: number[];
/** Should boss items be added to airdrop crate */
allowBossItems: boolean;
}

View File

@ -23,4 +23,5 @@ export interface ISealedAirdropContainerSettings {
weaponModRewardLimits: Record<string, MinMax>;
rewardTypeLimits: Record<string, MinMax>;
ammoBoxWhitelist: string[];
allowBossItems: boolean;
}

View File

@ -1,5 +1,8 @@
import { IBaseConfig } from "./IBaseConfig";
export interface IItemConfig extends IBaseConfig {
kind: "aki-item";
/** Items that should be globally blacklisted */
blacklist: string[];
/** Items that can only be found on bosses */
bossItems: string[];
}

View File

@ -92,6 +92,12 @@ export interface IEliminationConfig {
minDist: number;
maxKills: number;
minKills: number;
minBossKills: number;
maxBossKills: number;
weaponCategoryRequirementProb: number;
weaponCategoryRequirements: IWeaponRequirement[];
weaponRequirementProb: number;
weaponRequirements: IWeaponRequirement[];
}
export interface ITarget extends IProbabilityObject {
data: IBossInfo;
@ -102,6 +108,9 @@ export interface IBossInfo {
export interface IBodyPart extends IProbabilityObject {
data: string[];
}
export interface IWeaponRequirement extends IProbabilityObject {
data: string[];
}
export interface IProbabilityObject {
key: string;
relativeProbability: number;

View File

@ -9,6 +9,7 @@ export interface IScavCaseConfig extends IBaseConfig {
rewardItemBlacklist: string[];
allowMultipleMoneyRewardsPerRarity: boolean;
allowMultipleAmmoRewardsPerRarity: boolean;
allowBossItemsAsRewards: boolean;
}
export interface MoneyRewards {
moneyRewardChancePercent: number;

View File

@ -0,0 +1,31 @@
import { ELocationName } from "../../../models/enums/ELocationName";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKnight?: ITargetLocation;
bossZryachiy?: ITargetLocation;
bossBoar?: ITargetLocation;
bossBoarSniper?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}

View File

@ -9,4 +9,5 @@ export interface LootRequest {
itemLimits: Record<string, number>;
itemStackLimits: Record<string, MinMax>;
armorLevelWhitelist: number[];
allowBossItems: boolean;
}

View File

@ -7,7 +7,6 @@ export declare class ItemFilterService {
protected logger: ILogger;
protected databaseServer: DatabaseServer;
protected configServer: ConfigServer;
protected blacklist: string[];
protected itemConfig: IItemConfig;
constructor(logger: ILogger, databaseServer: DatabaseServer, configServer: ConfigServer);
/**
@ -21,4 +20,15 @@ export declare class ItemFilterService {
* @returns string array of blacklisted tempalte ids
*/
getBlacklistedItems(): string[];
/**
* Check if the provided template id is boss item in config/item.json
* @param tpl template id
* @returns true if boss item
*/
isBossItem(tpl: string): boolean;
/**
* Return boss items in config/item.json
* @returns string array of boss item tempalte ids
*/
getBossItems(): string[];
}

View File

@ -62,10 +62,10 @@ export declare class InraidController {
savePostRaidProgress(offraidData: ISaveProgressRequestData, sessionID: string): void;
/**
* Handle updating player profile post-pmc raid
* @param sessionID session id
* @param offraidData post-raid data
* @param sessionID Session id
* @param postRaidRequest Post-raid data
*/
protected savePmcProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePmcProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Make changes to pmc profile after they've died in raid,
* Alter bodypart hp, handle insurance, delete inventory items, remove carried quest items
@ -91,10 +91,10 @@ export declare class InraidController {
protected reducePmcHealthToPercent(pmcData: IPmcData, multipler: number): void;
/**
* Handle updating the profile post-pscav raid
* @param sessionID session id
* @param offraidData post-raid data of raid
* @param sessionID Session id
* @param postRaidRequest Post-raid data of raid
*/
protected savePlayerScavProgress(sessionID: string, offraidData: ISaveProgressRequestData): void;
protected savePlayerScavProgress(sessionID: string, postRaidRequest: ISaveProgressRequestData): void;
/**
* Is the player dead after a raid - dead is anything other than "survived" / "runner"
* @param statusOnExit exit value from offraidData object

View File

@ -9,7 +9,7 @@ import { IGetInsuranceCostRequestData } from "../models/eft/insurance/IGetInsura
import { IGetInsuranceCostResponseData } from "../models/eft/insurance/IGetInsuranceCostResponseData";
import { IInsureRequestData } from "../models/eft/insurance/IInsureRequestData";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { Insurance } from "../models/eft/profile/IAkiProfile";
import { Insurance, ISystemData } from "../models/eft/profile/IAkiProfile";
import { IInsuranceConfig } from "../models/spt/config/IInsuranceConfig";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
@ -66,6 +66,14 @@ export declare class InsuranceController {
* @returns void
*/
protected processInsuredItems(insuranceDetails: Insurance[], sessionID: string): void;
/**
* Remove an insurance package from a profile using the package's system data information.
*
* @param sessionID The session ID of the profile to remove the package from.
* @param index The array index of the insurance package to remove.
* @returns void
*/
protected removeInsurancePackageFromProfile(sessionID: string, packageInfo: ISystemData): void;
/**
* Build an array of items to delete from the insured items.
*
@ -78,7 +86,7 @@ export declare class InsuranceController {
* @param insured - The insured items to build a removal array from.
* @returns An array of IDs representing items that should be deleted.
*/
protected findItemsToDelete(insured: Insurance): string[];
protected findItemsToDelete(insured: Insurance): Set<string>;
/**
* Filters an item based on its existence in the database, raid moddability, and slot requirements.
*
@ -108,7 +116,7 @@ export declare class InsuranceController {
* @param toDelete The array accumulating the IDs of items to be deleted.
* @returns true if the item is marked for deletion, otherwise false.
*/
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: string[]): boolean;
protected makeRollAndMarkForDeletion(item: Item, traderId: string, toDelete: Set<string>): boolean;
/**
* Groups child items by their parent IDs in a Map data structure.
*
@ -127,7 +135,7 @@ export declare class InsuranceController {
* @param toDelete The array that accumulates the IDs of the items to be deleted.
* @returns void
*/
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: string[]): void;
protected sortAndFilterChildren(children: Item[], traderId: string, toDelete: Set<string>): void;
/**
* Remove items from the insured items that should not be returned to the player.
*
@ -135,7 +143,7 @@ export declare class InsuranceController {
* @param toDelete The items that should be deleted.
* @returns void
*/
protected removeItemsFromInsurance(insured: Insurance, toDelete: string[]): void;
protected removeItemsFromInsurance(insured: Insurance, toDelete: Set<string>): void;
/**
* Handle sending the insurance message to the user that potentially contains the valid insurance items.
*
@ -154,7 +162,7 @@ export declare class InsuranceController {
* @param itemsBeingDeleted List of items that are already slated for removal.
* @returns true if the insured item should be removed from inventory, false otherwise.
*/
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: string[]): boolean;
protected rollForItemDelete(insuredItem: Item, traderId: string, itemsBeingDeleted: Set<string>): boolean;
/**
* Handle Insure event
* Add insurance to an item

View File

@ -1,81 +1,41 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { RepeatableQuestGenerator } from "../generators/RepeatableQuestGenerator";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { IEmptyRequestData } from "../models/eft/common/IEmptyRequestData";
import { Exit } from "../models/eft/common/ILocationBase";
import { IPmcData } from "../models/eft/common/IPmcData";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IPmcDataRepeatableQuest, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IPmcDataRepeatableQuest } from "../models/eft/common/tables/IRepeatableQuests";
import { IItemEventRouterResponse } from "../models/eft/itemEvent/IItemEventRouterResponse";
import { IRepeatableQuestChangeRequest } from "../models/eft/quests/IRepeatableQuestChangeRequest";
import { ELocationName } from "../models/enums/ELocationName";
import { IEliminationConfig, IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { ProbabilityObject, ProbabilityObjectArray, RandomUtil } from "../utils/RandomUtil";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export interface IQuestTypePool {
types: string[];
pool: IQuestPool;
}
export interface IQuestPool {
Exploration: IExplorationPool;
Elimination: IEliminationPool;
}
export interface IExplorationPool {
locations: Partial<Record<ELocationName, string[]>>;
}
export interface IEliminationPool {
targets: IEliminationTargetPool;
}
export interface IEliminationTargetPool {
Savage?: ITargetLocation;
AnyPmc?: ITargetLocation;
bossBully?: ITargetLocation;
bossGluhar?: ITargetLocation;
bossKilla?: ITargetLocation;
bossSanitar?: ITargetLocation;
bossTagilla?: ITargetLocation;
bossKojaniy?: ITargetLocation;
}
export interface ITargetLocation {
locations: string[];
}
export declare class RepeatableQuestController {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestGenerator: RepeatableQuestGenerator;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, configServer: ConfigServer);
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, jsonUtil: JsonUtil, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, paymentService: PaymentService, objectId: ObjectId, repeatableQuestGenerator: RepeatableQuestGenerator, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* Handle client/repeatalbeQuests/activityPeriods
* Returns an array of objects in the format of repeatable quests to the client.
@ -109,103 +69,10 @@ export declare class RepeatableQuestController {
* @returns IPmcDataRepeatableQuest
*/
protected getRepeatableQuestSubTypeFromProfile(repeatableConfig: IRepeatableQuestConfig, pmcData: IPmcData): IPmcDataRepeatableQuest;
/**
* This method is called by GetClientRepeatableQuests and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
*/
protected generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Just for debug reasons. Draws dailies a random assort of dailies extracted from dumps
*/
generateDebugDailies(dailiesPool: any, factory: any, number: number): any;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* Generates a valid Elimination quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* Get the relevant elimination config based on the current players PMC level
* @param pmcLevel Level of PMC character
* @param repeatableConfig Main repeatable config
* @returns IEliminationConfig
*/
protected getEliminationConfigByPmcLevel(pmcLevel: number, repeatableConfig: IRepeatableQuestConfig): IEliminationConfig;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[]): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number): IEliminationCondition;
/**
* Used to create a quest pool during each cycle of repeatable quest generation. The pool will be subsequently
* narrowed down during quest generation to avoid duplicate quests. Like duplicate extractions or elimination quests
@ -215,53 +82,10 @@ export declare class RepeatableQuestController {
* @returns IQuestTypePool
*/
protected generateQuestPool(repeatableConfig: IRepeatableQuestConfig, pmcLevel: number): IQuestTypePool;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
protected createBaseQuestPool(repeatableConfig: IRepeatableQuestConfig): IQuestTypePool;
debugLogRepeatableQuestIds(pmcData: IPmcData): void;
protected probabilityObjectArray<K, V>(configArrayInput: ProbabilityObject<K, V>[]): ProbabilityObjectArray<K, V>;
/**
* Handle RepeatableQuestChange event
*/
changeRepeatableQuest(pmcData: IPmcData, body: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
changeRepeatableQuest(pmcData: IPmcData, changeRequest: IRepeatableQuestChangeRequest, sessionID: string): IItemEventRouterResponse;
}

View File

@ -0,0 +1,183 @@
import { HandbookHelper } from "../helpers/HandbookHelper";
import { ItemHelper } from "../helpers/ItemHelper";
import { PresetHelper } from "../helpers/PresetHelper";
import { ProfileHelper } from "../helpers/ProfileHelper";
import { RagfairServerHelper } from "../helpers/RagfairServerHelper";
import { RepeatableQuestHelper } from "../helpers/RepeatableQuestHelper";
import { Exit } from "../models/eft/common/ILocationBase";
import { TraderInfo } from "../models/eft/common/tables/IBotBase";
import { ICompletion, ICompletionAvailableFor, IElimination, IEliminationCondition, IExploration, IExplorationCondition, IRepeatableQuest, IReward, IRewards } from "../models/eft/common/tables/IRepeatableQuests";
import { ITemplateItem } from "../models/eft/common/tables/ITemplateItem";
import { IQuestConfig, IRepeatableQuestConfig } from "../models/spt/config/IQuestConfig";
import { IQuestTypePool } from "../models/spt/repeatable/IQuestTypePool";
import { ILogger } from "../models/spt/utils/ILogger";
import { EventOutputHolder } from "../routers/EventOutputHolder";
import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer";
import { ItemFilterService } from "../services/ItemFilterService";
import { LocalisationService } from "../services/LocalisationService";
import { PaymentService } from "../services/PaymentService";
import { ProfileFixerService } from "../services/ProfileFixerService";
import { HttpResponseUtil } from "../utils/HttpResponseUtil";
import { JsonUtil } from "../utils/JsonUtil";
import { MathUtil } from "../utils/MathUtil";
import { ObjectId } from "../utils/ObjectId";
import { RandomUtil } from "../utils/RandomUtil";
import { TimeUtil } from "../utils/TimeUtil";
export declare class RepeatableQuestGenerator {
protected timeUtil: TimeUtil;
protected logger: ILogger;
protected randomUtil: RandomUtil;
protected httpResponse: HttpResponseUtil;
protected mathUtil: MathUtil;
protected jsonUtil: JsonUtil;
protected databaseServer: DatabaseServer;
protected itemHelper: ItemHelper;
protected presetHelper: PresetHelper;
protected profileHelper: ProfileHelper;
protected profileFixerService: ProfileFixerService;
protected handbookHelper: HandbookHelper;
protected ragfairServerHelper: RagfairServerHelper;
protected eventOutputHolder: EventOutputHolder;
protected localisationService: LocalisationService;
protected paymentService: PaymentService;
protected objectId: ObjectId;
protected itemFilterService: ItemFilterService;
protected repeatableQuestHelper: RepeatableQuestHelper;
protected configServer: ConfigServer;
protected questConfig: IQuestConfig;
constructor(timeUtil: TimeUtil, logger: ILogger, randomUtil: RandomUtil, httpResponse: HttpResponseUtil, mathUtil: MathUtil, jsonUtil: JsonUtil, databaseServer: DatabaseServer, itemHelper: ItemHelper, presetHelper: PresetHelper, profileHelper: ProfileHelper, profileFixerService: ProfileFixerService, handbookHelper: HandbookHelper, ragfairServerHelper: RagfairServerHelper, eventOutputHolder: EventOutputHolder, localisationService: LocalisationService, paymentService: PaymentService, objectId: ObjectId, itemFilterService: ItemFilterService, repeatableQuestHelper: RepeatableQuestHelper, configServer: ConfigServer);
/**
* This method is called by /GetClientRepeatableQuests/ and creates one element of quest type format (see assets/database/templates/repeatableQuests.json).
* It randomly draws a quest type (currently Elimination, Completion or Exploration) as well as a trader who is providing the quest
* @param pmcLevel Player's level for requested items and reward generation
* @param pmcTraderInfo Players traper standing/rep levels
* @param questTypePool Possible quest types pool
* @param repeatableConfig Repeatable quest config
* @returns IRepeatableQuest
*/
generateRepeatableQuest(pmcLevel: number, pmcTraderInfo: Record<string, TraderInfo>, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IRepeatableQuest;
/**
* Generate a randomised Elimination quest
* @param pmcLevel Player's level for requested items and reward generation
* @param traderId Trader from which the quest will be provided
* @param questTypePool Pools for quests (used to avoid redundant quests)
* @param repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns Object of quest type format for "Elimination" (see assets/database/templates/repeatableQuests.json)
*/
protected generateEliminationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IElimination;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a location condition.
*
* @param {string} location the location on which to fulfill the elimination quest
* @returns {object} object of "Elimination"-location-subcondition
*/
protected generateEliminationLocation(location: string[], allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateEliminationQuest to create a kill condition.
*
* @param {string} target array of target npcs e.g. "AnyPmc", "Savage"
* @param {array} bodyParts array of body parts with which to kill e.g. ["stomach", "thorax"]
* @param {number} distance distance from which to kill (currently only >= supported)
* @returns {object} object of "Elimination"-kill-subcondition
*/
protected generateEliminationCondition(target: string, bodyPart: string[], distance: number, allowedWeapon: string, allowedWeaponCategory: string): IEliminationCondition;
/**
* Generates a valid Completion quest
*
* @param {integer} pmcLevel player's level for requested items and reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Completion" (see assets/database/templates/repeatableQuests.json)
*/
protected generateCompletionQuest(pmcLevel: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): ICompletion;
/**
* A repeatable quest, besides some more or less static components, exists of reward and condition (see assets/database/templates/repeatableQuests.json)
* This is a helper method for GenerateCompletionQuest to create a completion condition (of which a completion quest theoretically can have many)
*
* @param {string} targetItemId id of the item to request
* @param {integer} value amount of items of this specific type to request
* @returns {object} object of "Completion"-condition
*/
protected generateCompletionAvailableForFinish(targetItemId: string, value: number): ICompletionAvailableFor;
/**
* Generates a valid Exploration quest
*
* @param {integer} pmcLevel player's level for reward generation
* @param {string} traderId trader from which the quest will be provided
* @param {object} questTypePool Pools for quests (used to avoid redundant quests)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of quest type format for "Exploration" (see assets/database/templates/repeatableQuests.json)
*/
protected generateExplorationQuest(pmcLevel: number, traderId: string, questTypePool: IQuestTypePool, repeatableConfig: IRepeatableQuestConfig): IExploration;
/**
* Convert a location into an quest code can read (e.g. factory4_day into 55f2d3fd4bdc2d5f408b4567)
* @param locationKey e.g factory4_day
* @returns guid
*/
protected getQuestLocationByMapId(locationKey: string): string;
/**
* Exploration repeatable quests can specify a required extraction point.
* This method creates the according object which will be appended to the conditions array
*
* @param {string} exit The exit name to generate the condition for
* @returns {object} Exit condition
*/
protected generateExplorationExitCondition(exit: Exit): IExplorationCondition;
/**
* Generate the reward for a mission. A reward can consist of
* - Experience
* - Money
* - Items
* - Trader Reputation
*
* The reward is dependent on the player level as given by the wiki. The exact mapping of pmcLevel to
* experience / money / items / trader reputation can be defined in QuestConfig.js
*
* There's also a random variation of the reward the spread of which can be also defined in the config.
*
* Additonaly, a scaling factor w.r.t. quest difficulty going from 0.2...1 can be used
*
* @param {integer} pmcLevel player's level
* @param {number} difficulty a reward scaling factor goint from 0.2 to 1
* @param {string} traderId the trader for reputation gain (and possible in the future filtering of reward item type based on trader)
* @param {object} repeatableConfig The configuration for the repeatably kind (daily, weekly) as configured in QuestConfig for the requestd quest
* @returns {object} object of "Reward"-type that can be given for a repeatable mission
*/
protected generateReward(pmcLevel: number, difficulty: number, traderId: string, repeatableConfig: IRepeatableQuestConfig): IRewards;
/**
* Helper to create a reward item structured as required by the client
*
* @param {string} tpl itemId of the rewarded item
* @param {integer} value amount of items to give
* @param {integer} index all rewards will be appended to a list, for unkown reasons the client wants the index
* @returns {object} object of "Reward"-item-type
*/
protected generateRewardItem(tpl: string, value: number, index: number, preset?: any): IReward;
/**
* Picks rewardable items from items.json. This means they need to fit into the inventory and they shouldn't be keys (debatable)
* @param repeatableQuestConfig config file
* @returns a list of rewardable items [[_tpl, itemTemplate],...]
*/
protected getRewardableItems(repeatableQuestConfig: IRepeatableQuestConfig): [string, ITemplateItem][];
/**
* Checks if an id is a valid item. Valid meaning that it's an item that may be a reward
* or content of bot loot. Items that are tested as valid may be in a player backpack or stash.
* @param {string} tpl template id of item to check
* @returns boolean: true if item is valid reward
*/
protected isValidRewardItem(tpl: string, repeatableQuestConfig: IRepeatableQuestConfig): boolean;
/**
* Generates the base object of quest type format given as templates in assets/database/templates/repeatableQuests.json
* The templates include Elimination, Completion and Extraction quest types
*
* @param {string} type quest type: "Elimination", "Completion" or "Extraction"
* @param {string} traderId trader from which the quest will be provided
* @param {string} side scav daily or pmc daily/weekly quest
* @returns {object} a object which contains the base elements for repeatable quests of the requests type
* (needs to be filled with reward and conditions by called to make a valid quest)
*/
protected generateRepeatableTemplate(type: string, traderId: string, side: string): IRepeatableQuest;
}

Some files were not shown because too many files have changed in this diff Show More