From 26f29e15227eef80c76baa85cc3342c45b4514c4 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 20 Jun 2023 16:59:15 +0100 Subject: [PATCH] Add sealed crates to airdrops --- project/assets/configs/airdrop.json | 16 +++++++++++++++ project/src/controllers/LocationController.ts | 1 + project/src/generators/LootGenerator.ts | 20 +++++++++++++++++++ .../src/models/spt/config/IAirdropConfig.ts | 1 + .../src/models/spt/services/LootRequest.ts | 1 + 5 files changed, 39 insertions(+) diff --git a/project/assets/configs/airdrop.json b/project/assets/configs/airdrop.json index 84db272e..98a352f0 100644 --- a/project/assets/configs/airdrop.json +++ b/project/assets/configs/airdrop.json @@ -31,6 +31,10 @@ "min": 12, "max": 25 }, + "weaponCrateCount": { + "min": 0, + "max": 2 + }, "itemBlacklist": [ "5e997f0b86f7741ac73993e2", "5b44abe986f774283e2e3512", @@ -132,6 +136,10 @@ "min": 10, "max": 20 }, + "weaponCrateCount": { + "min": 0, + "max": 2 + }, "itemBlacklist": [ "5e997f0b86f7741ac73993e2", "5b44abe986f774283e2e3512", @@ -204,6 +212,10 @@ "min": 17, "max": 28 }, + "weaponCrateCount": { + "min": 0, + "max": 0 + }, "itemBlacklist": [ "5e997f0b86f7741ac73993e2", "5b44abe986f774283e2e3512", @@ -282,6 +294,10 @@ "min": 16, "max": 25 }, + "weaponCrateCount": { + "min": 0, + "max": 0 + }, "itemBlacklist": [ "5e997f0b86f7741ac73993e2", "5b44abe986f774283e2e3512", diff --git a/project/src/controllers/LocationController.ts b/project/src/controllers/LocationController.ts index eab9d939..0a6a946a 100644 --- a/project/src/controllers/LocationController.ts +++ b/project/src/controllers/LocationController.ts @@ -185,6 +185,7 @@ export class LocationController return { presetCount: lootSettingsByType.presetCount, itemCount: lootSettingsByType.itemCount, + weaponCrateCount: lootSettingsByType.weaponCrateCount, itemBlacklist: lootSettingsByType.itemBlacklist, itemTypeWhitelist: lootSettingsByType.itemTypeWhitelist, itemLimits: lootSettingsByType.itemLimits, diff --git a/project/src/generators/LootGenerator.ts b/project/src/generators/LootGenerator.ts index a89e3e03..50c4aebf 100644 --- a/project/src/generators/LootGenerator.ts +++ b/project/src/generators/LootGenerator.ts @@ -57,6 +57,26 @@ export class LootGenerator const itemBlacklist = this.itemFilterService.getBlacklistedItems(); itemBlacklist.push(...options.itemBlacklist); + // Handle sealed weapon containers + const desiredWeaponCrateCount = this.randomUtil.getInt(options.weaponCrateCount.min, options.weaponCrateCount.max); + if (desiredWeaponCrateCount > 0) + { + // Get list of all sealed containers from db + const sealedWeaponContainerPool = Object.values(tables.templates.items).filter(x => x._name.includes("event_container_airdrop")); + + for (let index = 0; index < desiredWeaponCrateCount; index++) + { + // Choose one at random + add to results array + const chosenSealedContainer = this.randomUtil.getArrayValue(sealedWeaponContainerPool); + result.push({ + id: this.hashUtil.generate(), + tpl: chosenSealedContainer._id, + isPreset: false, + stackCount: 1 + }); + } + } + // Get items from items.json that have a type of item + not in global blacklist + basetype is in whitelist const items = Object.entries(tables.templates.items).filter(x => !itemBlacklist.includes(x[1]._id) && x[1]._type.toLowerCase() === "item" diff --git a/project/src/models/spt/config/IAirdropConfig.ts b/project/src/models/spt/config/IAirdropConfig.ts index 989eb646..58839beb 100644 --- a/project/src/models/spt/config/IAirdropConfig.ts +++ b/project/src/models/spt/config/IAirdropConfig.ts @@ -32,6 +32,7 @@ export interface AirdropLoot { presetCount?: MinMax itemCount: MinMax + weaponCrateCount: MinMax itemBlacklist: string[] itemTypeWhitelist: string[] /** key: item base type: value: max count */ diff --git a/project/src/models/spt/services/LootRequest.ts b/project/src/models/spt/services/LootRequest.ts index 0829f0f7..5b5bfe7c 100644 --- a/project/src/models/spt/services/LootRequest.ts +++ b/project/src/models/spt/services/LootRequest.ts @@ -4,6 +4,7 @@ export interface LootRequest { presetCount: MinMax itemCount: MinMax + weaponCrateCount: MinMax itemBlacklist: string[] itemTypeWhitelist: string[] /** key: item base type: value: max count */