add checks before logging debug
This commit is contained in:
@@ -60,7 +60,9 @@ public abstract class StaticRouter : Router
|
||||
var type = action.bodyType;
|
||||
IRequestData? info = null;
|
||||
if (type != null && !string.IsNullOrEmpty(body))
|
||||
info = (IRequestData?) _jsonUtil.Deserialize(body, type);
|
||||
{
|
||||
info = (IRequestData?)_jsonUtil.Deserialize(body, type);
|
||||
}
|
||||
return action.action(url, info, sessionID, output);
|
||||
}
|
||||
|
||||
@@ -87,7 +89,9 @@ public abstract class DynamicRouter : Router
|
||||
var type = action.bodyType;
|
||||
IRequestData? info = null;
|
||||
if (type != null && !string.IsNullOrEmpty(body))
|
||||
info = (IRequestData?) _jsonUtil.Deserialize(body, type);
|
||||
{
|
||||
info = (IRequestData?)_jsonUtil.Deserialize(body, type);
|
||||
}
|
||||
return action.action(url, info, sessionID, output);
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,8 @@ using Core.Services;
|
||||
using Core.Utils;
|
||||
using Core.Utils.Cloners;
|
||||
using Core.Utils.Collections;
|
||||
using LogLevel = Core.Models.Spt.Logging.LogLevel;
|
||||
|
||||
namespace Core.Generators;
|
||||
|
||||
[Injectable]
|
||||
@@ -128,9 +130,12 @@ public class BotEquipmentModGenerator(
|
||||
switch (plateSlotFilteringOutcome.Result)
|
||||
{
|
||||
case Result.UNKNOWN_FAILURE or Result.NO_DEFAULT_FILTER:
|
||||
_logger.Debug(
|
||||
$"Plate slot: {modSlotName} selection for armor: {parentTemplate.Id} failed: {plateSlotFilteringOutcome.Result}, skipping"
|
||||
);
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Plate slot: {modSlotName} selection for armor: {parentTemplate.Id} failed: {plateSlotFilteringOutcome.Result}, skipping"
|
||||
);
|
||||
}
|
||||
|
||||
continue;
|
||||
case Result.LACKS_PLATE_WEIGHTS:
|
||||
@@ -283,11 +288,11 @@ public class BotEquipmentModGenerator(
|
||||
// no plates found that fit requirements, lets get creative
|
||||
|
||||
// Get lowest and highest plate classes available for this armor
|
||||
var minMaxArmorPlateClass = GetMinMaxArmorPlateClass(platesFromDb.ToList());
|
||||
var minMaxArmorPlateClass = GetMinMaxArmorPlateClass(platesFromDb.ToList());
|
||||
|
||||
// Increment plate class level in attempt to get useable plate
|
||||
var findCompatiblePlateAttempts = 0;
|
||||
var maxAttempts = 3;
|
||||
var maxAttempts = 3;
|
||||
for (var i = 0; i < maxAttempts; i++)
|
||||
{
|
||||
var chosenArmorPlateLevelDouble = int.Parse(chosenArmorPlateLevelString) + 1;
|
||||
@@ -311,9 +316,12 @@ public class BotEquipmentModGenerator(
|
||||
// No valid plate class found in 3 tries, attempt default plates
|
||||
if (findCompatiblePlateAttempts >= maxAttempts)
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Plate filter too restrictive for armor: {armorItem.Name} {armorItem.Id}, unable to find plates of level: {chosenArmorPlateLevelString}, using items default plate"
|
||||
);
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Plate filter too restrictive for armor: {armorItem.Name} {armorItem.Id}, unable to find plates of level: {chosenArmorPlateLevelString}, using items default plate"
|
||||
);
|
||||
}
|
||||
|
||||
var defaultPlate = GetDefaultPlateTpl(armorItem, modSlot);
|
||||
if (defaultPlate is not null)
|
||||
@@ -328,11 +336,11 @@ public class BotEquipmentModGenerator(
|
||||
// No plate found after filtering AND no default plate
|
||||
|
||||
// Last attempt, get default preset and see if it has a plate default
|
||||
var defaultPresetPlateSlot = GetDefaultPresetArmorSlot(armorItem.Id, modSlot);
|
||||
var defaultPresetPlateSlot = GetDefaultPresetArmorSlot(armorItem.Id, modSlot);
|
||||
if (defaultPresetPlateSlot is not null)
|
||||
{
|
||||
// Found a plate, exit
|
||||
var plateItem = _itemHelper.GetItem(defaultPresetPlateSlot.Template);
|
||||
var plateItem = _itemHelper.GetItem(defaultPresetPlateSlot.Template);
|
||||
platesOfDesiredLevel = [plateItem.Value];
|
||||
|
||||
break;
|
||||
@@ -344,7 +352,7 @@ public class BotEquipmentModGenerator(
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Only return the items ids
|
||||
result.Result = Result.SUCCESS;
|
||||
result.PlateModTemplates = platesOfDesiredLevel.Select(item => item.Id).ToHashSet();
|
||||
@@ -354,21 +362,25 @@ public class BotEquipmentModGenerator(
|
||||
|
||||
private MinMax GetMinMaxArmorPlateClass(List<TemplateItem> platePool)
|
||||
{
|
||||
platePool.Sort((x, y) => {
|
||||
if (x.Properties.ArmorClass < y.Properties.ArmorClass)
|
||||
platePool.Sort(
|
||||
(x, y) =>
|
||||
{
|
||||
return -1;
|
||||
if (x.Properties.ArmorClass < y.Properties.ArmorClass)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (x.Properties.ArmorClass > y.Properties.ArmorClass)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
);
|
||||
|
||||
if (x.Properties.ArmorClass > y.Properties.ArmorClass)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
});
|
||||
|
||||
return new MinMax {
|
||||
return new MinMax
|
||||
{
|
||||
Min = (platePool[0].Properties.ArmorClass),
|
||||
Max = (platePool[platePool.Count - 1].Properties.ArmorClass),
|
||||
};
|
||||
@@ -502,8 +514,7 @@ public class BotEquipmentModGenerator(
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!IsModValidForSlot(modToAdd, modsParentSlot, modSlot, request.ParentTemplate, request.BotData.Role)
|
||||
)
|
||||
if (!IsModValidForSlot(modToAdd, modsParentSlot, modSlot, request.ParentTemplate, request.BotData.Role))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -591,11 +602,7 @@ public class BotEquipmentModGenerator(
|
||||
request.WeaponStats.HasRearIronSight = true;
|
||||
}
|
||||
}
|
||||
else if (
|
||||
!request.WeaponStats.HasOptic ??
|
||||
false &&
|
||||
_itemHelper.IsOfBaseclass(modToAddTemplate.Value.Id, BaseClasses.SIGHTS)
|
||||
)
|
||||
else if (!(request.WeaponStats.HasOptic ?? false) && _itemHelper.IsOfBaseclass(modToAddTemplate.Value.Id, BaseClasses.SIGHTS))
|
||||
{
|
||||
request.WeaponStats.HasOptic = true;
|
||||
}
|
||||
@@ -687,9 +694,7 @@ public class BotEquipmentModGenerator(
|
||||
|
||||
protected bool ItemLacksSlotsCartridgesAndChambers(TemplateItem item)
|
||||
{
|
||||
return item.Properties.Slots?.Count == 0
|
||||
&& item.Properties.Cartridges?.Count == 0
|
||||
&& item.Properties.Chambers?.Count == 0;
|
||||
return item.Properties.Slots?.Count == 0 && item.Properties.Cartridges?.Count == 0 && item.Properties.Chambers?.Count == 0;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -972,7 +977,11 @@ public class BotEquipmentModGenerator(
|
||||
if (modPool is null && !(parentSlot?.Required ?? false))
|
||||
{
|
||||
// Nothing in mod pool + item not required
|
||||
_logger.Debug($"Mod pool for optional slot: {request.ModSlot} on item: {request.ParentTemplate.Name} was empty, skipping mod");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Mod pool for optional slot: {request.ModSlot} on item: {request.ParentTemplate.Name} was empty, skipping mod");
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -1041,7 +1050,10 @@ public class BotEquipmentModGenerator(
|
||||
// Log if mod chosen was incompatible
|
||||
if (chosenModResult.Incompatible.GetValueOrDefault(false) && !(parentSlot.Required.GetValueOrDefault(false)))
|
||||
{
|
||||
_logger.Debug($"Unable to find compatible mod of type: {parentSlot.Name}, in slot: {request.ModSlot} reason: {chosenModResult.Reason}");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to find compatible mod of type: {parentSlot.Name}, in slot: {request.ModSlot} reason: {chosenModResult.Reason}");
|
||||
}
|
||||
}
|
||||
|
||||
// Get random mod to attach from items db for required slots if none found above
|
||||
@@ -1279,7 +1291,10 @@ public class BotEquipmentModGenerator(
|
||||
{
|
||||
if (request.ItemModPool[request.ModSlot]?.Count > 1)
|
||||
{
|
||||
_logger.Debug($"{request.BotData.Role} No default: {request.ModSlot} mod found for: {weaponTemplate.Name}, using existing pool");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"{request.BotData.Role} No default: {request.ModSlot} mod found for: {weaponTemplate.Name}, using existing pool");
|
||||
}
|
||||
}
|
||||
|
||||
// Couldn't find default in globals, use existing mod pool data
|
||||
@@ -1305,8 +1320,7 @@ public class BotEquipmentModGenerator(
|
||||
|
||||
// Mod isn't in existing pool, only add if it has no children and exists inside parent filter
|
||||
if (
|
||||
parentSlotCompatibleItems?.Contains(matchingModFromPreset.Template) ??
|
||||
false &&
|
||||
(parentSlotCompatibleItems?.Contains(matchingModFromPreset.Template) ?? false) &&
|
||||
_itemHelper.GetItem(matchingModFromPreset.Template).Value.Properties.Slots?.Count == 0
|
||||
)
|
||||
{
|
||||
@@ -1317,17 +1331,23 @@ public class BotEquipmentModGenerator(
|
||||
}
|
||||
|
||||
// Above chosen mod had conflicts with existing weapon mods
|
||||
_logger.Debug(
|
||||
$"{request.BotData.Role} Chosen default: {request.ModSlot} mod found for: {weaponTemplate.Name} weapon conflicts with item on weapon, cannot use default"
|
||||
);
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"{request.BotData.Role} Chosen default: {request.ModSlot} mod found for: {weaponTemplate.Name} weapon conflicts with item on weapon, cannot use default"
|
||||
);
|
||||
}
|
||||
|
||||
var existingModPool = request.ItemModPool[request.ModSlot];
|
||||
if (existingModPool.Count == 1)
|
||||
{
|
||||
// The only item in pool isn't compatible
|
||||
_logger.Debug(
|
||||
$"{request.BotData.Role} {request.ModSlot} Mod pool for: {weaponTemplate.Name} weapon has only incompatible items, using parent list instead"
|
||||
);
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"{request.BotData.Role} {request.ModSlot} Mod pool for: {weaponTemplate.Name} weapon has only incompatible items, using parent list instead"
|
||||
);
|
||||
}
|
||||
|
||||
// Last ditch, use full pool of items minus conflicts
|
||||
var newListOfModsForSlot = parentSlotCompatibleItems.Where((tpl) => !request.ConflictingItemTpls.Contains(tpl));
|
||||
@@ -1481,7 +1501,10 @@ public class BotEquipmentModGenerator(
|
||||
}
|
||||
)
|
||||
);
|
||||
_logger.Debug($"Item -> {parentTemplate?.Id}; Slot -> {modSlot}");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Item -> {parentTemplate?.Id}; Slot -> {modSlot}");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -1724,9 +1747,12 @@ public class BotEquipmentModGenerator(
|
||||
var whitelistedSightTypes = botWeaponSightWhitelist[weaponDetails.Value.Parent];
|
||||
if (whitelistedSightTypes is null)
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Unable to find whitelist for weapon type: {weaponDetails.Value.Parent} {weaponDetails.Value.Name}, skipping sight filtering"
|
||||
);
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Unable to find whitelist for weapon type: {weaponDetails.Value.Parent} {weaponDetails.Value.Name}, skipping sight filtering"
|
||||
);
|
||||
}
|
||||
|
||||
return scopes;
|
||||
}
|
||||
@@ -1777,7 +1803,10 @@ public class BotEquipmentModGenerator(
|
||||
// No mods added to return list after filtering has occurred, send back the original mod list
|
||||
if (filteredScopesAndMods is null || filteredScopesAndMods.Count() == 0)
|
||||
{
|
||||
_logger.Debug($"Scope whitelist too restrictive for: {weapon.Template} {weaponDetails.Value.Name}, skipping filter");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Scope whitelist too restrictive for: {weapon.Template} {weaponDetails.Value.Name}, skipping filter");
|
||||
}
|
||||
|
||||
return scopes;
|
||||
}
|
||||
|
||||
@@ -324,7 +324,9 @@ public class BotGenerator(
|
||||
if (!experiences.TryGetValue(botDifficulty.ToLower(), out var result))
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to find experience: {botDifficulty} for {role} bot, falling back to `normal`");
|
||||
}
|
||||
|
||||
return _randomUtil.GetDouble(experiences["normal"].Min.Value, experiences["normal"].Max.Value);
|
||||
}
|
||||
@@ -482,7 +484,9 @@ public class BotGenerator(
|
||||
{
|
||||
var pmcCount = output.Aggregate(0, (acc, cur) => { return cur.Info.Side is "Bear" or "Usec" ? acc + 1 : acc; });
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Generated {output.Count} total bots. Replaced {pmcCount} with PMCs");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -344,7 +344,9 @@ public class BotInventoryGenerator(
|
||||
if (!tacVestsWithArmor.Any())
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to filter to only armored rigs as bot: {botRole} has none in pool");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -368,7 +370,9 @@ public class BotInventoryGenerator(
|
||||
if (!allowEmptyResult && !tacVestsWithoutArmor.Any())
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to filter to only unarmored rigs as bot: {botRole} has none in pool");
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
@@ -424,7 +428,9 @@ public class BotInventoryGenerator(
|
||||
{
|
||||
_logger.Error(_localisationService.GetText("bot-missing_item_template", chosenItemTpl));
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"EquipmentSlot-> {settings.RootEquipmentSlot}");
|
||||
}
|
||||
|
||||
// Remove picked item
|
||||
settings.RootEquipmentPool.Remove(chosenItemTpl);
|
||||
|
||||
@@ -539,7 +539,9 @@ public class BotLootGenerator(
|
||||
{
|
||||
// Bot has no container to put item in, exit
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to add: {totalItemCount} items to bot as it lacks a container to include them");
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -547,11 +549,13 @@ public class BotLootGenerator(
|
||||
if (fitItemIntoContainerAttempts >= 4)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Failed placing item: {itemToAddTemplate.Name}: {i} of: {totalItemCount} items into: {botRole} " +
|
||||
$"containers: {string.Join(",", equipmentSlots)}. Tried: {fitItemIntoContainerAttempts} " +
|
||||
$"times, reason: {itemAddedResult}, skipping"
|
||||
);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -707,7 +711,9 @@ public class BotLootGenerator(
|
||||
if (result != ItemAddedResult.SUCCESS)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Failed to add additional weapon {generatedWeapon.Weapon[0].Id} to bot backpack, reason: {result.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -759,6 +765,7 @@ public class BotLootGenerator(
|
||||
if (currentLimitCount > currentLimitCount * 10)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
_localisationService.GetText(
|
||||
"bot-item_spawn_limit_reached_skipping_item",
|
||||
@@ -770,6 +777,7 @@ public class BotLootGenerator(
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -531,9 +531,11 @@ public class BotWeaponGenerator(
|
||||
|
||||
var defaultMagTplId = _botWeaponGeneratorHelper.GetWeaponsDefaultMagazineTpl(weaponTemplate);
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"[{botRole}] Unable to find magazine for weapon: {weaponTemplate.Id} {weaponTemplate.Name}, using mag template default: {defaultMagTplId}."
|
||||
);
|
||||
}
|
||||
|
||||
return defaultMagTplId;
|
||||
}
|
||||
@@ -553,6 +555,7 @@ public class BotWeaponGenerator(
|
||||
if (!cartridgePool.TryGetValue(desiredCaliber, out var cartridgePoolForWeapon) || cartridgePoolForWeapon?.Keys.Count == 0)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
_localisationService.GetText(
|
||||
"bot-no_caliber_data_for_weapon_falling_back_to_default",
|
||||
@@ -564,6 +567,7 @@ public class BotWeaponGenerator(
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
// Immediately returns, default ammo is guaranteed to be compatible
|
||||
return weaponTemplate.Properties.DefAmmo;
|
||||
|
||||
@@ -115,7 +115,9 @@ public class LocationLootGenerator(
|
||||
}
|
||||
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Added {guaranteedContainers.Count} guaranteed containers");
|
||||
}
|
||||
|
||||
// Randomisation is turned off globally or just turned off for this map
|
||||
if (
|
||||
@@ -126,9 +128,11 @@ public class LocationLootGenerator(
|
||||
)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Container randomisation disabled, Adding {staticRandomisableContainersOnMap.Count} containers to {locationBase.Name}"
|
||||
);
|
||||
}
|
||||
foreach (var container in staticRandomisableContainersOnMap)
|
||||
{
|
||||
var containerWithLoot = AddLootToContainer(
|
||||
@@ -170,7 +174,9 @@ public class LocationLootGenerator(
|
||||
if (data.ContainerIdsWithProbability.Count == 0)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"`Group: {key} has no containers with< 100 % spawn chance to choose from, skipping");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -208,9 +214,11 @@ public class LocationLootGenerator(
|
||||
if (containerObject is null)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Container: {chosenContainerId} not found in staticRandomisableContainersOnMap, this is bad"
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -289,9 +297,11 @@ public class LocationLootGenerator(
|
||||
if (containerData.ChosenCount > containerIds.Count)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Group: {groupId} wants {containerData.ChosenCount} containers but pool only has {containerIds.Count}, add what's available"
|
||||
);
|
||||
}
|
||||
return containerIds;
|
||||
}
|
||||
|
||||
@@ -364,9 +374,11 @@ public class LocationLootGenerator(
|
||||
if (container.Probability >= 1)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Container {container.Template.Id} with group ${groupData.GroupId} had 100 % chance to spawn was picked as random container, skipping"
|
||||
);
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -685,7 +697,9 @@ public class LocationLootGenerator(
|
||||
if (blacklistedSpawnpoints?.Contains(spawnpoint.Template.Id) ?? false)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Ignoring loose loot location: {spawnpoint.Template.Id}");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -729,6 +743,7 @@ public class LocationLootGenerator(
|
||||
if (tooManySpawnPointsRequested)
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
_localisationService.GetText(
|
||||
"location-spawn_point_count_requested_vs_found",
|
||||
@@ -740,6 +755,7 @@ public class LocationLootGenerator(
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate over spawnpoints
|
||||
@@ -849,7 +865,9 @@ public class LocationLootGenerator(
|
||||
if (items is null || !items.Any())
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to adjust loot item {itemTpl} as it does not exist inside {locationName} forced loot.");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -928,9 +946,11 @@ public class LocationLootGenerator(
|
||||
else
|
||||
{
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Attempted to add a forced loot location with Id: {locationTemplateToAdd.Id} to map {locationName} that already has that id in use, skipping"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1088,7 +1108,9 @@ public class LocationLootGenerator(
|
||||
{
|
||||
// RSP30 (62178be9d0050232da3485d9/624c0b3340357b5f566e8766/6217726288ed9f0845317459) doesn't have any default presets and kills this code below as it has no chidren to reparent
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"createStaticLootItem() No preset found for weapon: {chosenTpl}");
|
||||
}
|
||||
}
|
||||
|
||||
rootItem = items[0];
|
||||
|
||||
@@ -362,7 +362,9 @@ public class LootGenerator(
|
||||
// No `_encyclopedia` property, not possible to reliably get root item tpl
|
||||
if (chosenPreset.Encyclopedia is null) {
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug("$Preset with id: {chosenPreset?.Id} lacks encyclopedia property, skipping");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -371,7 +373,9 @@ public class LootGenerator(
|
||||
var itemDbDetails = _itemHelper.GetItem(chosenPreset.Encyclopedia);
|
||||
if (!itemDbDetails.Key) {
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"$Unable to find preset with tpl: {chosenPreset.Encyclopedia}, skipping");
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
@@ -497,7 +501,9 @@ public class LootGenerator(
|
||||
x.Properties.AmmoCaliber == weaponCaliber);
|
||||
if (!ammoBoxesMatchingCaliber.Any()) {
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"No ammo box with caliber {weaponCaliber} found, skipping");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -524,7 +530,9 @@ public class LootGenerator(
|
||||
|
||||
if (rewardItemPool.Count() == 0) {
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"No items with base type of {rewardKey} found, skipping");
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
@@ -567,9 +575,11 @@ public class LootGenerator(
|
||||
);
|
||||
if (relatedItems is null || relatedItems.Count() == 0) {
|
||||
if(_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"No items found to fulfil reward type: {rewardKey} for weapon: {chosenWeaponPreset.Name}, skipping type"
|
||||
);
|
||||
);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ using Core.Servers;
|
||||
using Core.Services;
|
||||
using Core.Utils;
|
||||
using Core.Utils.Cloners;
|
||||
using LogLevel = Core.Models.Spt.Logging.LogLevel;
|
||||
|
||||
|
||||
namespace Core.Generators;
|
||||
@@ -56,7 +57,10 @@ public class PlayerScavGenerator(
|
||||
_logger.Error(_localisationService.GetText("scav-missing_karma_settings", scavKarmaLevel));
|
||||
}
|
||||
|
||||
_logger.Debug($"Generated player scav loadout with karma level {scavKarmaLevel}");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Generated player scav loadout with karma level {scavKarmaLevel}");
|
||||
}
|
||||
|
||||
// Edit baseBotNode values
|
||||
var baseBotNode = ConstructBotBaseTemplate(playerScavKarmaSettings.BotTypeForLoot);
|
||||
@@ -164,7 +168,12 @@ public class PlayerScavGenerator(
|
||||
);
|
||||
|
||||
if (result != ItemAddedResult.SUCCESS)
|
||||
_logger.Debug($"Unable to add keycard to bot. Reason: {result.ToString()}");
|
||||
{
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to add keycard to bot. Reason: {result.ToString()}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -194,7 +194,7 @@ public class RepeatableQuestGenerator(
|
||||
else
|
||||
{
|
||||
// never should reach this if everything works out
|
||||
_logger.Debug("Encountered issue when creating Elimination quest. Please report.");
|
||||
_logger.Error("Encountered issue when creating Elimination quest. Please report.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,7 @@ using Core.Utils;
|
||||
using Core.Utils.Cloners;
|
||||
using Core.Utils.Collections;
|
||||
using SptCommon.Annotations;
|
||||
using LogLevel = Core.Models.Spt.Logging.LogLevel;
|
||||
|
||||
namespace Core.Generators;
|
||||
|
||||
@@ -136,9 +137,12 @@ public class RepeatableQuestRewardGenerator(
|
||||
}
|
||||
|
||||
|
||||
_logger.Debug(
|
||||
$"Generating: {repeatableConfig.Name} quest for: {traderId} with budget: {itemRewardBudget} totalling: {rewardParams.RewardNumItems} items"
|
||||
);
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug(
|
||||
$"Generating: {repeatableConfig.Name} quest for: {traderId} with budget: {itemRewardBudget} totalling: {rewardParams.RewardNumItems} items"
|
||||
);
|
||||
}
|
||||
if (inBudgetRewardItemPool.Count > 0)
|
||||
{
|
||||
var itemsToReward = GetRewardableItemsFromPoolWithinBudget(
|
||||
@@ -173,7 +177,10 @@ public class RepeatableQuestRewardGenerator(
|
||||
rewards.Success.Add(reward);
|
||||
rewardIndex++;
|
||||
|
||||
_logger.Debug($"Adding: {rewardParams.RewardReputation} {traderId} trader reputation reward");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Adding: {rewardParams.RewardReputation} {traderId} trader reputation reward");
|
||||
}
|
||||
}
|
||||
|
||||
// Chance of adding skill reward
|
||||
@@ -193,7 +200,10 @@ public class RepeatableQuestRewardGenerator(
|
||||
};
|
||||
rewards.Success.Add(reward);
|
||||
|
||||
_logger.Debug($"Adding {rewardParams.SkillPointReward} skill points to {targetSkill}");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Adding {rewardParams.SkillPointReward} skill points to {targetSkill}");
|
||||
}
|
||||
}
|
||||
|
||||
return rewards;
|
||||
@@ -349,7 +359,10 @@ public class RepeatableQuestRewardGenerator(
|
||||
|
||||
var itemCost = _presetHelper.GetDefaultPresetOrItemPrice(chosenItemFromPool.Id);
|
||||
var calculatedItemRewardBudget = itemRewardBudget - rewardItemStackCount * itemCost;
|
||||
_logger.Debug($"Added item: {chosenItemFromPool.Id} with price: {rewardItemStackCount * itemCost}");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Added item: {chosenItemFromPool.Id} with price: {rewardItemStackCount * itemCost}");
|
||||
}
|
||||
|
||||
// If we still have budget narrow down possible items
|
||||
if (calculatedItemRewardBudget > 0)
|
||||
@@ -363,7 +376,10 @@ public class RepeatableQuestRewardGenerator(
|
||||
|
||||
if (!exhausableItemPool.HasValues())
|
||||
{
|
||||
_logger.Debug($"Reward pool empty with: {calculatedItemRewardBudget} roubles of budget remaining");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Reward pool empty with: {calculatedItemRewardBudget} roubles of budget remaining");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,6 +5,7 @@ using Core.Models.Enums;
|
||||
using Core.Models.Utils;
|
||||
using Core.Services;
|
||||
using Core.Utils;
|
||||
using LogLevel = Core.Models.Spt.Logging.LogLevel;
|
||||
|
||||
namespace Core.Generators.WeaponGen.Implementations;
|
||||
|
||||
@@ -71,7 +72,10 @@ public class ExternalInventoryMagGen(
|
||||
// Prevent infinite loop by only allowing 5 attempts at fitting a magazine into inventory
|
||||
if (fitAttempts > 5)
|
||||
{
|
||||
_logger.Debug($"Failed {fitAttempts} times to add magazine {magazineTpl} to bot inventory, stopping");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Failed {fitAttempts} times to add magazine {magazineTpl} to bot inventory, stopping");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
@@ -129,7 +133,10 @@ public class ExternalInventoryMagGen(
|
||||
break;
|
||||
}
|
||||
|
||||
_logger.Debug($"Unable to add additional magazine into bot inventory: vest/pockets for weapon: {weapon.Name}, attempted: {fitAttempts} times. Reason: {fitsIntoInventory}");
|
||||
if (_logger.IsLogEnabled(LogLevel.Debug))
|
||||
{
|
||||
_logger.Debug($"Unable to add additional magazine into bot inventory: vest/pockets for weapon: {weapon.Name}, attempted: {fitAttempts} times. Reason: {fitsIntoInventory}");
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user