Converted GetSkillBonusMultipliedBySkillLevel into extension method
This commit is contained in:
@@ -138,7 +138,7 @@ public class TradeController(
|
||||
)
|
||||
{
|
||||
// Skip buying items when player doesn't have needed loyalty
|
||||
if (!pmcData.PlayerMeetsTraderLoyaltyLevelToBuyOffer(fleaOffer))
|
||||
if (!pmcData.ProfileMeetsTraderLoyaltyLevelToBuyOffer(fleaOffer))
|
||||
{
|
||||
var errorMessage =
|
||||
$"Unable to buy item: {fleaOffer.Items[0].Template} from trader: {fleaOffer.User.Id} as loyalty level too low, skipping";
|
||||
|
||||
@@ -69,6 +69,30 @@ public static class ProfileExtensions
|
||||
return profile?.Skills?.Common?.FirstOrDefault(s => s.Id == skill);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a multiplier based on player's skill level and value per level
|
||||
/// </summary>
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
/// <param name="skill">Player skill from profile</param>
|
||||
/// <param name="valuePerLevel">Value from globals.config.SkillsSettings - `PerLevel`</param>
|
||||
/// <returns>Multiplier from 0 to 1</returns>
|
||||
public static double GetSkillBonusMultipliedBySkillLevel(this PmcData pmcData, SkillTypes skill, double valuePerLevel)
|
||||
{
|
||||
var profileSkill = pmcData.GetSkillFromProfile(skill);
|
||||
if (profileSkill is null || profileSkill.Progress == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If the level is 51 we need to round it at 50 so on elite you dont get 25.5%
|
||||
// at level 1 you already get 0.5%, so it goes up until level 50. For some reason the wiki
|
||||
// says that it caps at level 51 with 25% but as per dump data that is incorrect apparently
|
||||
var roundedLevel = Math.Floor(profileSkill.Progress / 100);
|
||||
roundedLevel = roundedLevel.Approx(51d) ? roundedLevel - 1 : roundedLevel;
|
||||
|
||||
return roundedLevel * valuePerLevel / 100;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get the scav karma level for a profile
|
||||
/// Is also the fence trader rep level
|
||||
|
||||
@@ -991,13 +991,11 @@ public class HideoutHelper(
|
||||
// 100 resources last 8 hrs 20 min, 100/8.33/60/60 = 0.00333
|
||||
const double filterDrainRate = 0.00333d;
|
||||
|
||||
var hideoutManagementConsumptionBonus = GetSkillBonusMultipliedBySkillLevel(
|
||||
pmcData,
|
||||
var hideoutManagementConsumptionBonus = pmcData.GetSkillBonusMultipliedBySkillLevel(
|
||||
SkillTypes.HideoutManagement,
|
||||
globalSkillsDb.HideoutManagement.ConsumptionReductionPerLevel
|
||||
);
|
||||
var craftSkillTimeReductionMultiplier = GetSkillBonusMultipliedBySkillLevel(
|
||||
pmcData,
|
||||
var craftSkillTimeReductionMultiplier = pmcData.GetSkillBonusMultipliedBySkillLevel(
|
||||
SkillTypes.Crafting,
|
||||
globalSkillsDb.Crafting.CraftTimeReductionPerLevel
|
||||
);
|
||||
@@ -1324,30 +1322,6 @@ public class HideoutHelper(
|
||||
/ 100;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Get a multiplier based on player's skill level and value per level
|
||||
/// </summary>
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
/// <param name="skill">Player skill from profile</param>
|
||||
/// <param name="valuePerLevel">Value from globals.config.SkillsSettings - `PerLevel`</param>
|
||||
/// <returns>Multiplier from 0 to 1</returns>
|
||||
protected double GetSkillBonusMultipliedBySkillLevel(PmcData pmcData, SkillTypes skill, double valuePerLevel)
|
||||
{
|
||||
var profileSkill = pmcData.GetSkillFromProfile(skill);
|
||||
if (profileSkill is null || profileSkill.Progress == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// If the level is 51 we need to round it at 50 so on elite you dont get 25.5%
|
||||
// at level 1 you already get 0.5%, so it goes up until level 50. For some reason the wiki
|
||||
// says that it caps at level 51 with 25% but as per dump data that is incorrect apparently
|
||||
var roundedLevel = Math.Floor(profileSkill.Progress / 100);
|
||||
roundedLevel = roundedLevel.Approx(51d) ? roundedLevel - 1 : roundedLevel;
|
||||
|
||||
return roundedLevel * valuePerLevel / 100;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// </summary>
|
||||
/// <param name="pmcData">Player profile</param>
|
||||
@@ -1357,7 +1331,7 @@ public class HideoutHelper(
|
||||
/// <returns>Seconds to reduce craft time by</returns>
|
||||
public double GetSkillProductionTimeReduction(PmcData pmcData, double productionTime, SkillTypes skill, double amountPerLevel)
|
||||
{
|
||||
var skillTimeReductionMultiplier = GetSkillBonusMultipliedBySkillLevel(pmcData, skill, amountPerLevel);
|
||||
var skillTimeReductionMultiplier = pmcData.GetSkillBonusMultipliedBySkillLevel(skill, amountPerLevel);
|
||||
|
||||
return productionTime * skillTimeReductionMultiplier;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user