Implement weights for food/drink on bots

This commit is contained in:
Dev 2024-04-08 12:31:51 +01:00
parent 6d2c17596b
commit ef2442178a
47 changed files with 856 additions and 29 deletions

View File

@ -2110,6 +2110,22 @@
"2": 0
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {

View File

@ -2343,6 +2343,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 30,
@ -2351,6 +2359,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 8,

View File

@ -2508,11 +2508,27 @@
"2": 1
},
"whitelist": []
},
"food": {
"weights": {
"0": 6,
"1": 5,
"2": 2
},
"whitelist": []
},
"drink": {
"weights": {
"0": 6,
"1": 5,
"2": 1
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,
"1": 4,
"0": 2,
"1": 6,
"2": 5,
"3": 2,
"4": 1

View File

@ -2302,6 +2302,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2310,6 +2318,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2038,6 +2038,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2046,6 +2054,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2029,6 +2029,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2036,6 +2044,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2317,6 +2317,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2324,6 +2332,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2019,6 +2019,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2026,6 +2034,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2167,6 +2167,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2175,6 +2183,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2070,6 +2070,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2078,6 +2086,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2322,6 +2322,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2330,6 +2338,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2114,6 +2114,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2122,6 +2130,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2113,6 +2113,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2121,6 +2129,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -1946,6 +1946,22 @@
"healing": {
"max": 2,
"min": 1
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"looseLoot": {
"max": 3,

View File

@ -2024,6 +2024,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2032,6 +2040,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2365,6 +2365,22 @@
"2": 0
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {

View File

@ -2391,6 +2391,22 @@
"2": 0
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {

View File

@ -2254,6 +2254,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2261,6 +2269,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2053,6 +2053,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2061,6 +2069,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2085,6 +2085,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2093,6 +2101,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2253,6 +2253,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 9,
@ -2263,6 +2271,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2173,6 +2173,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2181,6 +2189,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2173,6 +2173,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2181,6 +2189,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2044,6 +2044,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2052,6 +2060,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2212,6 +2212,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2220,6 +2228,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2214,6 +2214,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2222,6 +2230,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2217,6 +2217,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2225,6 +2233,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2099,6 +2099,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2107,6 +2115,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2232,6 +2232,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2240,6 +2248,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2245,6 +2245,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2253,6 +2261,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2144,6 +2144,22 @@
"2": 0
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {

View File

@ -2003,6 +2003,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2011,6 +2019,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2064,6 +2064,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2072,6 +2080,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2298,6 +2298,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2306,6 +2314,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,
@ -2337,10 +2353,10 @@
},
"pocketLoot": {
"weights": {
"0": 3,
"1": 10,
"0": 10,
"1": 35,
"2": 3,
"3": 1,
"3": 2,
"4": 1
},
"whitelist": []

View File

@ -2004,33 +2004,108 @@
],
"generation": {
"items": {
"backpackLoot": {
"weights": {
"0": 1,
"1": 1,
"2": 2,
"3": 1,
"4": 1,
"5": 1,
"6": 1,
"7": 0
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"max": 1,
"min": 0
"weights": {
"0": 1,
"1": 2,
"2": 0
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"max": 5,
"min": 0
"weights": {
"0": 1,
"1": 2,
"2": 1,
"3": 1,
"4": 0,
"5": 0
},
"whitelist": []
},
"healing": {
"max": 2,
"min": 1
"weights": {
"0": 1,
"1": 2,
"2": 1
},
"looseLoot": {
"max": 3,
"min": 0
"whitelist": []
},
"magazines": {
"max": 4,
"min": 2
"weights": {
"0": 0,
"1": 0,
"2": 1,
"3": 3,
"4": 1
},
"whitelist": []
},
"pocketLoot": {
"weights": {
"0": 1,
"1": 6,
"2": 3,
"3": 1,
"4": 1
},
"whitelist": []
},
"specialItems": {
"max": 0,
"min": 0
"weights": {
"0": 1,
"1": 0
},
"whitelist": []
},
"stims": {
"max": 1,
"min": 0
"weights": {
"0": 2,
"1": 1,
"2": 0
},
"whitelist": []
},
"vestLoot": {
"weights": {
"0": 1,
"1": 1,
"2": 2,
"3": 1,
"4": 0,
"5": 0,
"6": 0
},
"whitelist": []
}
}
},

View File

@ -2119,6 +2119,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2127,6 +2135,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2085,6 +2085,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2093,6 +2101,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2101,6 +2101,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2109,6 +2117,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2112,6 +2112,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2120,6 +2128,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -2146,6 +2146,14 @@
},
"whitelist": []
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"drugs": {
"weights": {
"0": 1,
@ -2154,6 +2162,14 @@
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,

View File

@ -1938,6 +1938,22 @@
"drugs": {
"max": 1,
"min": 0
},
"drink": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"food": {
"weights": {
"0": 10,
"1": 5,
"2": 2
},
"whitelist": []
},
"grenades": {
"max": 5,

View File

@ -2505,11 +2505,27 @@
"2": 1
},
"whitelist": []
},
"food": {
"weights": {
"0": 6,
"1": 5,
"2": 2
},
"whitelist": []
},
"drink": {
"weights": {
"0": 6,
"1": 5,
"2": 1
},
"whitelist": []
},
"grenades": {
"weights": {
"0": 1,
"1": 4,
"0": 2,
"1": 6,
"2": 5,
"3": 2,
"4": 1

View File

@ -98,6 +98,10 @@ export class BotLootGenerator
);
const healingItemCount = Number(this.weightedRandomHelper.getWeightedValue<number>(itemCounts.healing.weights));
const drugItemCount = Number(this.weightedRandomHelper.getWeightedValue<number>(itemCounts.drugs.weights));
const foodItemCount = Number(this.weightedRandomHelper.getWeightedValue<number>(itemCounts.food.weights));
const drinkItemCount = Number(this.weightedRandomHelper.getWeightedValue<number>(itemCounts.drink.weights));
const stimItemCount = Number(this.weightedRandomHelper.getWeightedValue<number>(itemCounts.stims.weights));
const grenadeCount = Number(this.weightedRandomHelper.getWeightedValue<number>(itemCounts.grenades.weights));
@ -145,6 +149,30 @@ export class BotLootGenerator
isPmc,
);
// Food
this.addLootFromPool(
this.botLootCacheService.getLootFromCache(botRole, isPmc, LootCacheType.FOOD_ITEMS, botJsonTemplate),
containersBotHasAvailable,
foodItemCount,
botInventory,
botRole,
null,
0,
isPmc,
);
// Drink
this.addLootFromPool(
this.botLootCacheService.getLootFromCache(botRole, isPmc, LootCacheType.DRINK_ITEMS, botJsonTemplate),
containersBotHasAvailable,
drinkItemCount,
botInventory,
botRole,
null,
0,
isPmc,
);
// Stims
this.addLootFromPool(
this.botLootCacheService.getLootFromCache(botRole, isPmc, LootCacheType.STIM_ITEMS, botJsonTemplate),

View File

@ -192,7 +192,7 @@ export class PMCLootGenerator
for (const itemToAdd of itemsToAdd)
{
// If pmc has override, use that. Otherwise use flea price
// If pmc has price override, use that. Otherwise use flea price
if (pmcPriceOverrides[itemToAdd._id])
{
this.backpackLootPool[itemToAdd._id] = pmcPriceOverrides[itemToAdd._id];

View File

@ -130,6 +130,8 @@ export interface GenerationWeightingItems
grenades: GenerationData;
healing: GenerationData;
drugs: GenerationData;
food: GenerationData;
drink: GenerationData;
stims: GenerationData;
backpackLoot: GenerationData;
pocketLoot: GenerationData;

View File

@ -1,5 +1,3 @@
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
export interface IBotLootCache
{
backpackLoot: Record<string, number>;
@ -11,6 +9,8 @@ export interface IBotLootCache
specialItems: Record<string, number>;
healingItems: Record<string, number>;
drugItems: Record<string, number>;
foodItems: Record<string, number>;
drinkItems: Record<string, number>;
stimItems: Record<string, number>;
grenadeItems: Record<string, number>;
}
@ -27,4 +27,6 @@ export enum LootCacheType
DRUG_ITEMS = "DrugItems",
STIM_ITEMS = "StimItems",
GRENADE_ITEMS = "GrenadeItems",
FOOD_ITEMS = "FoodItems",
DRINK_ITEMS = "DrinkItems",
}

View File

@ -89,6 +89,12 @@ export class BotLootCacheService
case LootCacheType.DRUG_ITEMS:
result = this.lootCache[botRole].drugItems;
break;
case LootCacheType.FOOD_ITEMS:
result = this.lootCache[botRole].foodItems;
break;
case LootCacheType.DRINK_ITEMS:
result = this.lootCache[botRole].drinkItems;
break;
case LootCacheType.STIM_ITEMS:
result = this.lootCache[botRole].stimItems;
break;
@ -219,7 +225,7 @@ export class BotLootCacheService
? botJsonTemplate.generation.items.drugs.whitelist
: {};
// no whitelist, find and assign from combined item pool
// no drugs whitelist, find and assign from combined item pool
if (Object.keys(drugItems).length === 0)
{
for (const [tpl, weight] of Object.entries(combinedLootPool))
@ -232,6 +238,44 @@ export class BotLootCacheService
}
}
// Assign whitelisted food to bot if any exist
const foodItems: Record<string, number> =
(Object.keys(botJsonTemplate.generation.items.food.whitelist)?.length > 0)
? botJsonTemplate.generation.items.food.whitelist
: {};
// No food whitelist, find and assign from combined item pool
if (Object.keys(foodItems).length === 0)
{
for (const [tpl, weight] of Object.entries(combinedLootPool))
{
const itemTemplate = this.itemHelper.getItem(tpl)[1];
if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.FOOD))
{
foodItems[tpl] = weight;
}
}
}
// Assign whitelisted drink to bot if any exist
const drinkItems: Record<string, number> =
(Object.keys(botJsonTemplate.generation.items.food.whitelist)?.length > 0)
? botJsonTemplate.generation.items.food.whitelist
: {};
// No drink whitelist, find and assign from combined item pool
if (Object.keys(drinkItems).length === 0)
{
for (const [tpl, weight] of Object.entries(combinedLootPool))
{
const itemTemplate = this.itemHelper.getItem(tpl)[1];
if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.DRINK))
{
drinkItems[tpl] = weight;
}
}
}
// Assign whitelisted stims to bot if any exist
const stimItems: Record<string, number> =
(Object.keys(botJsonTemplate.generation.items.stims.whitelist)?.length > 0)
@ -270,7 +314,7 @@ export class BotLootCacheService
}
}
// Get backpack loot (excluding magazines, bullets, grenades and healing items)
// Get backpack loot (excluding magazines, bullets, grenades, drink, food and healing/stim items)
const filteredBackpackItems = {};
for (const itemKey of Object.keys(backpackLootPool))
{
@ -285,6 +329,8 @@ export class BotLootCacheService
|| this.isMagazine(itemTemplate._props)
|| this.isMedicalItem(itemTemplate._props)
|| this.isGrenade(itemTemplate._props)
|| this.isFood(itemTemplate._id)
|| this.isDrink(itemTemplate._id)
)
{
// Is type we dont want as backpack loot, skip
@ -294,7 +340,7 @@ export class BotLootCacheService
filteredBackpackItems[itemKey] = backpackLootPool[itemKey];
}
// Get pocket loot (excluding magazines, bullets, grenades, medical and healing items)
// Get pocket loot (excluding magazines, bullets, grenades, drink, food medical and healing/stim items)
const filteredPocketItems = {};
for (const itemKey of Object.keys(pocketLootPool))
{
@ -309,6 +355,8 @@ export class BotLootCacheService
|| this.isMagazine(itemTemplate._props)
|| this.isMedicalItem(itemTemplate._props)
|| this.isGrenade(itemTemplate._props)
|| this.isFood(itemTemplate._id)
|| this.isDrink(itemTemplate._id)
|| !("Height" in itemTemplate._props) // lacks height
|| !("Width" in itemTemplate._props) // lacks width
)
@ -319,7 +367,7 @@ export class BotLootCacheService
filteredPocketItems[itemKey] = pocketLootPool[itemKey];
}
// Get vest loot (excluding magazines, bullets, grenades, medical and healing items)
// Get vest loot (excluding magazines, bullets, grenades, medical and healing/stim items)
const filteredVestItems = {};
for (const itemKey of Object.keys(vestLootPool))
{
@ -334,6 +382,8 @@ export class BotLootCacheService
|| this.isMagazine(itemTemplate._props)
|| this.isMedicalItem(itemTemplate._props)
|| this.isGrenade(itemTemplate._props)
|| this.isFood(itemTemplate._id)
|| this.isDrink(itemTemplate._id)
)
{
continue;
@ -344,6 +394,8 @@ export class BotLootCacheService
this.lootCache[botRole].healingItems = healingItems;
this.lootCache[botRole].drugItems = drugItems;
this.lootCache[botRole].foodItems = foodItems;
this.lootCache[botRole].drinkItems = drinkItems;
this.lootCache[botRole].stimItems = stimItems;
this.lootCache[botRole].grenadeItems = grenadeItems;
@ -429,6 +481,16 @@ export class BotLootCacheService
return ("ThrowType" in props);
}
protected isFood(tpl: string): boolean
{
return this.itemHelper.isOfBaseclass(tpl, BaseClasses.FOOD);
}
protected isDrink(tpl: string): boolean
{
return this.itemHelper.isOfBaseclass(tpl, BaseClasses.DRINK);
}
/**
* Check if a bot type exists inside the loot cache
* @param botRole role to check for
@ -455,6 +517,8 @@ export class BotLootCacheService
specialItems: {},
grenadeItems: {},
drugItems: {},
foodItems: {},
drinkItems: {},
healingItems: {},
stimItems: {},
};