From 2448fe24b5dbc2b1ef8c240bfde774b08562526d Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 11 Oct 2024 12:56:31 +0100 Subject: [PATCH] Split `AirdropTypeEnum` into 2 enums, a spt specific one and another for the `icon` property sent to client --- project/assets/configs/airdrop.json | 2 +- project/src/models/enums/AirdropType.ts | 7 +++++++ .../src/models/spt/config/IAirdropConfig.ts | 6 +++--- project/src/services/AirdropService.ts | 20 ++++++++++--------- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/project/assets/configs/airdrop.json b/project/assets/configs/airdrop.json index b9544929..e6b68030 100644 --- a/project/assets/configs/airdrop.json +++ b/project/assets/configs/airdrop.json @@ -1,7 +1,7 @@ { "airdropTypeWeightings": { "mixed": 5, - "weaponArmor": 2, + "weaponArmor": 4, "foodMedical": 1, "barter": 1, "radar": 0 diff --git a/project/src/models/enums/AirdropType.ts b/project/src/models/enums/AirdropType.ts index 41ed6390..cfd3a7be 100644 --- a/project/src/models/enums/AirdropType.ts +++ b/project/src/models/enums/AirdropType.ts @@ -1,4 +1,11 @@ export enum AirdropTypeEnum { + COMMON = "Common", + SUPPLY = "Supply", + MEDICAL = "Medical", + WEAPON_ARMOR = "Weapon", +} + +export enum SptAirdropTypeEnum { COMMON = "mixed", SUPPLY = "barter", FOOD_MEDICAL = "foodMedical", diff --git a/project/src/models/spt/config/IAirdropConfig.ts b/project/src/models/spt/config/IAirdropConfig.ts index a01eb2b1..051b6e5f 100644 --- a/project/src/models/spt/config/IAirdropConfig.ts +++ b/project/src/models/spt/config/IAirdropConfig.ts @@ -1,13 +1,13 @@ import { MinMax } from "@spt/models/common/MinMax"; -import { AirdropTypeEnum } from "@spt/models/enums/AirdropType"; +import { AirdropTypeEnum, SptAirdropTypeEnum } from "@spt/models/enums/AirdropType"; import { IBaseConfig } from "@spt/models/spt/config/IBaseConfig"; export interface IAirdropConfig extends IBaseConfig { kind: "spt-airdrop"; - airdropTypeWeightings: Record; + airdropTypeWeightings: Record; /** What rewards will the loot crate contain, keyed by drop type e.g. mixed/weaponArmor/foodMedical/barter */ loot: Record; - customAirdropMapping: Record; + customAirdropMapping: Record; } /** Chance map will have an airdrop occur out of 100 - locations not included count as 0% */ diff --git a/project/src/services/AirdropService.ts b/project/src/services/AirdropService.ts index 846e496b..466e89bc 100644 --- a/project/src/services/AirdropService.ts +++ b/project/src/services/AirdropService.ts @@ -4,7 +4,7 @@ import { WeightedRandomHelper } from "@spt/helpers/WeightedRandomHelper"; import { IItem } from "@spt/models/eft/common/tables/IItem"; import { IGetAirdropLootRequest } from "@spt/models/eft/location/IGetAirdropLootRequest"; import { IGetAirdropLootResponse } from "@spt/models/eft/location/IGetAirdropLootResponse"; -import { AirdropTypeEnum } from "@spt/models/enums/AirdropType"; +import { AirdropTypeEnum, SptAirdropTypeEnum } from "@spt/models/enums/AirdropType"; import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; import { ItemTpl } from "@spt/models/enums/ItemTpl"; import { IAirdropConfig, IAirdropLoot } from "@spt/models/spt/config/IAirdropConfig"; @@ -88,7 +88,7 @@ export class AirdropService { } } - return { icon: AirdropTypeEnum.COMMON, container: crateLoot }; + return { icon: airdropConfig.icon, container: crateLoot }; } /** @@ -96,7 +96,7 @@ export class AirdropService { * @param airdropType What tpye of container: weapon/common etc * @returns Item */ - protected getAirdropCrateItem(airdropType: AirdropTypeEnum): IItem { + protected getAirdropCrateItem(airdropType: SptAirdropTypeEnum): IItem { const airdropContainer = { _id: this.hashUtil.generate(), _tpl: "", // picked later @@ -107,19 +107,19 @@ export class AirdropService { }; switch (airdropType) { - case AirdropTypeEnum.FOOD_MEDICAL: + case SptAirdropTypeEnum.FOOD_MEDICAL: airdropContainer._tpl = ItemTpl.LOOTCONTAINER_AIRDROP_MEDICAL_CRATE; break; - case AirdropTypeEnum.SUPPLY: + case SptAirdropTypeEnum.SUPPLY: airdropContainer._tpl = ItemTpl.LOOTCONTAINER_AIRDROP_SUPPLY_CRATE; break; - case AirdropTypeEnum.WEAPON_ARMOR: + case SptAirdropTypeEnum.WEAPON_ARMOR: airdropContainer._tpl = ItemTpl.LOOTCONTAINER_AIRDROP_WEAPON_CRATE; break; - case AirdropTypeEnum.COMMON: + case SptAirdropTypeEnum.COMMON: airdropContainer._tpl = ItemTpl.LOOTCONTAINER_AIRDROP_COMMON_SUPPLY_CRATE; break; - case AirdropTypeEnum.RADAR: + case SptAirdropTypeEnum.RADAR: airdropContainer._tpl = ItemTpl.LOOTCONTAINER_AIRDROP_TECHNICAL_SUPPLY_CRATE_EVENT_1; break; default: @@ -134,7 +134,7 @@ export class AirdropService { * Randomly pick a type of airdrop loot using weighted values from config * @returns airdrop type value */ - protected chooseAirdropType(): AirdropTypeEnum { + protected chooseAirdropType(): SptAirdropTypeEnum { const possibleAirdropTypes = this.airdropConfig.airdropTypeWeightings; return this.weightedRandomHelper.getWeightedValue(possibleAirdropTypes); @@ -151,6 +151,8 @@ export class AirdropService { this.logger.error( this.localisationService.getText("location-unable_to_find_airdrop_drop_config_of_type", airdropType), ); + + // Default to common lootSettingsByType = this.airdropConfig.loot[AirdropTypeEnum.COMMON]; }