Fixed pscav generation failure during prestige #556

This commit is contained in:
Chomp
2025-08-19 10:28:50 +01:00
parent 2c9667389c
commit bb566e32ad
4 changed files with 21 additions and 7 deletions
@@ -65,6 +65,7 @@ public class BotGenerator(
BotCountToGenerate = 1,
BotDifficulty = difficulty,
IsPlayerScav = true,
ClearBotContainerCacheAfterGeneration = false,
};
bot = GenerateBot(sessionId, bot, botTemplate, botGenDetails);
@@ -173,7 +174,7 @@ public class BotGenerator(
var botRoleLowercase = botGenerationDetails.Role.ToLowerInvariant();
var botLevel = botLevelGenerator.GenerateBotLevel(botJsonTemplate.BotExperience.Level, botGenerationDetails, bot);
// Generate new bot ID
// Generate Id/AId for bot
AddIdsToBot(bot, botGenerationDetails);
// Only filter bot equipment, never players
@@ -127,7 +127,10 @@ public class BotInventoryGenerator(
botLootGenerator.GenerateLoot(botId, sessionId, botJsonTemplate, botGenerationDetails, isPmc, botRole, botInventory, botLevel);
// Inventory cache isn't needed, clear to save memory
botInventoryContainerService.ClearCache(botId);
if (botGenerationDetails.ClearBotContainerCacheAfterGeneration)
{
botInventoryContainerService.ClearCache(botId);
}
return botInventory;
}
@@ -29,6 +29,7 @@ public class PlayerScavGenerator(
FenceService fenceService,
BotLootCacheService botLootCacheService,
ServerLocalisationService serverLocalisationService,
BotInventoryContainerService botInventoryContainerService,
BotGenerator botGenerator,
ConfigServer configServer,
ICloner cloner,
@@ -88,7 +89,7 @@ public class PlayerScavGenerator(
scavData.Savage = null;
scavData.Aid = pmcDataClone.Aid;
scavData.TradersInfo = pmcDataClone.TradersInfo;
scavData.Info.Settings = new BotInfoSettings();
scavData.Info.Settings = new();
scavData.Info.Bans = [];
scavData.Info.RegistrationDate = pmcDataClone.Info.RegistrationDate;
scavData.Info.GameVersion = pmcDataClone.Info.GameVersion;
@@ -106,10 +107,10 @@ public class PlayerScavGenerator(
scavData.Info.Level = GetScavLevel(existingScavDataClone);
scavData.Info.Experience = GetScavExperience(existingScavDataClone);
scavData.Quests = existingScavDataClone.Quests ?? [];
scavData.TaskConditionCounters = existingScavDataClone.TaskConditionCounters ?? new Dictionary<MongoId, TaskConditionCounter>();
scavData.TaskConditionCounters = existingScavDataClone.TaskConditionCounters ?? new();
scavData.Notes = existingScavDataClone.Notes ?? new Notes { DataNotes = [] };
scavData.WishList = existingScavDataClone.WishList ?? new();
scavData.Encyclopedia = pmcDataClone.Encyclopedia ?? new Dictionary<MongoId, bool>();
scavData.Encyclopedia = pmcDataClone.Encyclopedia ?? new();
// Add additional items to player scav as loot
AddAdditionalLootToPlayerScavContainers(
@@ -119,13 +120,16 @@ public class PlayerScavGenerator(
[EquipmentSlots.TacticalVest, EquipmentSlots.Pockets, EquipmentSlots.Backpack]
);
// No need for cache data, clear up
botInventoryContainerService.ClearCache(scavData.Id.Value);
// Remove secure container
scavData = profileHelper.RemoveSecureContainer(scavData);
// set cooldown timer
// Set cooldown timer
scavData = SetScavCooldownTimer(scavData, pmcDataClone);
// add scav to profile
// Add scav to profile
saveServer.GetProfile(sessionID).CharacterData.ScavData = scavData;
return scavData;
@@ -81,4 +81,10 @@ public record BotGenerationDetails
/// Map bots will be spawned on
/// </summary>
public string? Location { get; set; }
/// <summary>
/// Should the bot container cache be cleared after generating bot equipment + loot
/// </summary>
[JsonPropertyName("clearBotContainerCacheAfterGeneration")]
public bool ClearBotContainerCacheAfterGeneration { get; set; } = true;
}