From a56d33b5f20a3cf353e35f2e199e567b15198ebd Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 1 Nov 2024 13:15:38 +0000 Subject: [PATCH] Fixed `adjustBotHostilitySettings()` failing when location lacks various properties --- project/src/services/LocationLifecycleService.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/project/src/services/LocationLifecycleService.ts b/project/src/services/LocationLifecycleService.ts index 59301734..f5e52c19 100644 --- a/project/src/services/LocationLifecycleService.ts +++ b/project/src/services/LocationLifecycleService.ts @@ -201,6 +201,7 @@ export class LocationLifecycleService { // Add/edit chance settings if (configHostilityChanges.chancedEnemies) { + locationBotHostilityDetails.ChancedEnemies ||= []; for (const chanceDetailsToApply of configHostilityChanges.chancedEnemies) { const locationBotDetails = locationBotHostilityDetails.ChancedEnemies.find( (botChance) => botChance.Role === chanceDetailsToApply.Role, @@ -217,6 +218,7 @@ export class LocationLifecycleService { // Add new permanent friends if they don't already exist if (configHostilityChanges.additionalFriendlyTypes) { + locationBotHostilityDetails.AlwaysFriends ||= []; for (const friendlyTypeToAdd of configHostilityChanges.additionalFriendlyTypes) { if (!locationBotHostilityDetails.AlwaysFriends.includes(friendlyTypeToAdd)) { locationBotHostilityDetails.AlwaysFriends.push(friendlyTypeToAdd);