Improved durability value generation

This commit is contained in:
Chomp
2025-01-27 19:41:04 +00:00
parent e836d3d0f8
commit 8fc0bb9547
3 changed files with 23 additions and 22 deletions
@@ -405,7 +405,7 @@ public class BotInventoryGenerator(
var found = false;
// Limit attempts to find a compatible item as it's expensive to check them all
var maxAttempts = Math.Round(settings.RootEquipmentPool.Count() * 0.75); // Roughly 75% of pool size
var maxAttempts = Math.Round(settings.RootEquipmentPool.Count * 0.75); // Roughly 75% of pool size
var attempts = 0;
while (!found)
{
+7 -7
View File
@@ -256,7 +256,7 @@ public class BotGeneratorHelper(
maxDurability
);
return new UpdRepairable { Durability = (int)currentDurability, MaxDurability = (int)maxDurability };
return new UpdRepairable { Durability = Math.Round(currentDurability, 5), MaxDurability = Math.Round(maxDurability, 5) };
}
/// <summary>
@@ -267,12 +267,12 @@ public class BotGeneratorHelper(
/// <returns>Repairable object</returns>
private UpdRepairable GenerateArmorRepairableProperties(TemplateItem itemTemplate, string? botRole = null)
{
double? maxDurability;
double? currentDurability;
double maxDurability;
double currentDurability;
if (itemTemplate.Properties?.ArmorClass == 0)
{
maxDurability = itemTemplate.Properties.MaxDurability;
currentDurability = itemTemplate.Properties.MaxDurability;
maxDurability = itemTemplate.Properties.MaxDurability.Value;
currentDurability = itemTemplate.Properties.MaxDurability.Value;
}
else
{
@@ -280,11 +280,11 @@ public class BotGeneratorHelper(
currentDurability = _durabilityLimitsHelper.GetRandomizedArmorDurability(
itemTemplate,
botRole,
maxDurability.Value
maxDurability
);
}
return new UpdRepairable { Durability = (int)currentDurability!, MaxDurability = (int)maxDurability! };
return new UpdRepairable { Durability = Math.Round(currentDurability, 5), MaxDurability = Math.Round(maxDurability, 5) };
}
/// <summary>
@@ -39,23 +39,24 @@ public class DurabilityLimitsHelper(
public double GetRandomizedMaxArmorDurability(TemplateItem? itemTemplate, string? botRole = null)
{
var itemMaxDurability = itemTemplate.Properties.MaxDurability.Value;
if (botRole is not null)
if (botRole is null)
{
if (_botHelper.IsBotPmc(botRole))
{
return GenerateMaxPmcArmorDurability(itemMaxDurability);
}
return itemMaxDurability;
}
if (_botHelper.IsBotBoss(botRole))
{
return itemMaxDurability;
}
if (_botHelper.IsBotPmc(botRole))
{
return GenerateMaxPmcArmorDurability(itemMaxDurability);
}
if (_botHelper.IsBotFollower(botRole))
{
return itemMaxDurability;
}
if (_botHelper.IsBotBoss(botRole))
{
return itemMaxDurability;
}
if (_botHelper.IsBotFollower(botRole))
{
return itemMaxDurability;
}
return itemMaxDurability;