Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"inRaid": 60,
"outOfRaid": 10
},
"expCraftAmount": 10,
"craftingExpAmount": 12.5,
"craftingExpForHoursOfCrafting": 3.75,
"overrideCraftTimeSeconds": -1,
"overrideBuildTimeSeconds": -1,
"updateProfileHideoutWhenActiveWithinMinutes": 90,
Expand Down
8 changes: 4 additions & 4 deletions Libraries/SPTarkov.Server.Assets/SPT_Data/configs/repair.json
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
{
"priceMultiplier": 1,
"applyRandomizeDurabilityLoss": true,
"armorKitSkillPointGainPerRepairPointMultiplier": 0.05,
"armorKitSkillPointGainPerRepairPointMultiplier": 0.1,
"repairKitIntellectGainMultiplier": {
"weapon": 0.111,
"armor": 0.077
"weapon": 0.1,
"armor": 0.1
},
"weaponTreatment": {
"critSuccessChance": 0.1,
"critSuccessAmount": 4,
"critFailureChance": 0.1,
"critFailureAmount": 4,
"pointGainMultiplier": 0.6
"pointGainMultiplier": 0.2
},
"repairKit": {
"armor": {
Expand Down
26 changes: 17 additions & 9 deletions Libraries/SPTarkov.Server.Core/Controllers/HideoutController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,8 @@ ItemEventRouterResponse output
profileHelper.AddSkillPointsToPlayer(
pmcData,
SkillTypes.HideoutManagement,
globals.Configuration.SkillsSettings.HideoutManagement.SkillPointsPerAreaUpgrade
globals.Configuration.SkillsSettings.HideoutManagement.SkillPointsPerAreaUpgrade,
true
);
}

Expand Down Expand Up @@ -687,8 +688,9 @@ public ItemEventRouterResponse ScavCaseProductionStart(PmcData pmcData, HideoutS
);
pmcData.Hideout.Production[request.RecipeId].SptIsScavCase = true;

// reward charisma based on skill progress rate for each scav production start
// reward charisma and hideout management based on skill progress rate for each scav production start
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.Charisma, 1, true);
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.HideoutManagement, 1, true);

return output;
}
Expand Down Expand Up @@ -822,7 +824,7 @@ ItemEventRouterResponse output
}

// Variables for management of skill
var craftingExpAmount = 0;
double craftingExpAmount = 0;
var counterHoursCrafting = GetCustomSptHoursCraftingTaskConditionCounter(pmcData, recipe);
var totalCraftingHours = counterHoursCrafting.Value;

Expand Down Expand Up @@ -863,19 +865,19 @@ ItemEventRouterResponse output
// Check if the recipe is the same as the last one - get bonus when crafting same thing multiple times
var area = pmcData.Hideout.Areas.FirstOrDefault(area => area.Type == recipe.AreaType);
if (area is not null && request.RecipeId != area.LastRecipe)
// 1 point per craft upon the end of production for alternating between 2 different crafting recipes in the same module
// 5 points per craft upon the end of production for alternating between 2 different crafting recipes in the same module
{
craftingExpAmount += HideoutConfig.ExpCraftAmount; // Default is 10
craftingExpAmount += HideoutConfig.CraftingExpAmount; // Default is 12.5, scaled (at 0.4 scale => 5 points per alternating craft)
}

// Update variable with time spent crafting item(s)
// 1 point per 8 hours of crafting
// 1.5 (3.75 w/ applying default 0.4 scale) points per 8 hours of crafting
totalCraftingHours += recipe.ProductionTime;
if (totalCraftingHours / HideoutConfig.HoursForSkillCrafting >= 1)
{
// Spent enough time crafting to get a bonus xp multiplier
var multiplierCrafting = Math.Floor(totalCraftingHours.Value / HideoutConfig.HoursForSkillCrafting);
craftingExpAmount += (int)(1 * multiplierCrafting);
craftingExpAmount += (HideoutConfig.CraftingExpForHoursOfCrafting * multiplierCrafting);
totalCraftingHours -= HideoutConfig.HoursForSkillCrafting * multiplierCrafting;
}

Expand Down Expand Up @@ -943,12 +945,18 @@ ItemEventRouterResponse output
// Add Crafting skill to player profile
if (craftingExpAmount > 0)
{
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.Crafting, craftingExpAmount);
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.Crafting, craftingExpAmount, true);

// TODO: verify this is still giving intellect skill points on live
var intellectAmountToGive = 0.5 * Math.Round((double)(craftingExpAmount / 15));
if (intellectAmountToGive > 0)
{
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.Intellect, intellectAmountToGive);
profileHelper.AddSkillPointsToPlayer(
pmcData,
SkillTypes.Intellect,
intellectAmountToGive,
useSkillProgressRateMultiplier: false
);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,13 @@ protected void FlagItemsAsInspectedAndRewardXp(IEnumerable<MongoId> itemTpls, Sp
}

// TODO: update this with correct calculation using values from globals json
profileHelper.AddSkillPointsToPlayer(fullProfile.CharacterData.PmcData, SkillTypes.Intellect, 0.05 * itemTpls.Count());
// TODO: verify this is still giving intellect skill points on live
profileHelper.AddSkillPointsToPlayer(
fullProfile.CharacterData.PmcData,
SkillTypes.Intellect,
0.05 * itemTpls.Count(),
useSkillProgressRateMultiplier: false
);
}

/// <summary>
Expand Down
6 changes: 3 additions & 3 deletions Libraries/SPTarkov.Server.Core/Helpers/HideoutHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,7 @@ protected void UpdateFuel(BotHideoutArea generatorArea, PmcData pmcData, bool is
// Fuel consumed / 10 is over 1, add hideout management skill point
if (pmcData is not null && Math.Floor(pointsConsumed / 10) >= 1)
{
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.HideoutManagement, 1);
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.HideoutManagement, 2, useSkillProgressRateMultiplier: true);
pointsConsumed -= 10;
}

Expand Down Expand Up @@ -925,7 +925,7 @@ protected void UpdateWaterFilters(BotHideoutArea waterFilterArea, Production pro
// Check units consumed for possible increment of hideout mgmt skill point
if (pmcData is not null && Math.Floor(pointsConsumed / 10) >= 1)
{
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.HideoutManagement, 1);
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.HideoutManagement, 2, useSkillProgressRateMultiplier: true);
pointsConsumed -= 10;
}

Expand Down Expand Up @@ -1076,7 +1076,7 @@ protected void UpdateAirFilters(BotHideoutArea airFilterArea, PmcData pmcData, b
// check unit consumed for increment skill point
if (pmcData is not null && Math.Floor(pointsConsumed / 10) >= 1)
{
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.HideoutManagement, 1);
profileHelper.AddSkillPointsToPlayer(pmcData, SkillTypes.HideoutManagement, 2, useSkillProgressRateMultiplier: true);
pointsConsumed -= 10;
}

Expand Down
9 changes: 8 additions & 1 deletion Libraries/SPTarkov.Server.Core/Helpers/PrestigeHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,14 @@ private void AddPrestigeRewardsToProfile(MongoId sessionId, SptProfile newProfil
case RewardType.Skill:
if (Enum.TryParse(reward.Target, out SkillTypes result))
{
profileHelper.AddSkillPointsToPlayer(newProfile.CharacterData!.PmcData!, result, reward.Value.GetValueOrDefault(0));
// skill reward values are always 100 (+1 level), so adjustment for low levels will give a wrong result
profileHelper.AddSkillPointsToPlayer(
newProfile.CharacterData!.PmcData!,
result,
reward.Value.GetValueOrDefault(0),
useSkillProgressRateMultiplier: false,
adjustSkillExpForLowLevels: false
);
}
else
{
Expand Down
25 changes: 23 additions & 2 deletions Libraries/SPTarkov.Server.Core/Helpers/ProfileHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ public bool HasEliteSkillLevel(SkillTypes skill, PmcData pmcProfile)
}

/// <summary>
/// Add points to a specific skill in player profile
/// Add points to a specific skill in player profile, adjusted for low levels by default
/// </summary>
/// <param name="pmcProfile">Player profile with skill</param>
/// <param name="skill">Skill to add points to</param>
Expand All @@ -473,6 +473,25 @@ public void AddSkillPointsToPlayer(
double pointsToAddToSkill,
bool useSkillProgressRateMultiplier = false
)
{
AddSkillPointsToPlayer(pmcProfile, skill, pointsToAddToSkill, useSkillProgressRateMultiplier, true);
}

/// <summary>
/// Add points to a specific skill in player profile
/// </summary>
/// <param name="pmcProfile">Player profile with skill</param>
/// <param name="skill">Skill to add points to</param>
/// <param name="pointsToAddToSkill">Points to add</param>
/// <param name="useSkillProgressRateMultiplier">Skills are multiplied by a value in globals, default is off to maintain compatibility with legacy code</param>
/// <param name="adjustSkillExpForLowLevels">Skills are multiplied by a multiplier for lower levels; if false, treats every level as requiring 100 points</param>
public void AddSkillPointsToPlayer(
PmcData pmcProfile,
SkillTypes skill,
double pointsToAddToSkill,
bool useSkillProgressRateMultiplier = false,
bool adjustSkillExpForLowLevels = true
)
{
if (pointsToAddToSkill < 0D)
{
Expand Down Expand Up @@ -517,7 +536,9 @@ public void AddSkillPointsToPlayer(
pointsToAddToSkill *= multiplier;
}

var adjustedSkillProgress = AdjustSkillExpForLowLevels(profileSkill.Progress, pointsToAddToSkill);
var adjustedSkillProgress = adjustSkillExpForLowLevels
? AdjustSkillExpForLowLevels(profileSkill.Progress, pointsToAddToSkill)
: pointsToAddToSkill;
profileSkill.Progress += adjustedSkillProgress;
profileSkill.Progress = Math.Min(profileSkill.Progress, 5100); // Prevent skill from ever going above level 51 (5100)

Expand Down
5 changes: 4 additions & 1 deletion Libraries/SPTarkov.Server.Core/Helpers/RewardHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,10 +73,13 @@ public List<Item> ApplyRewards(
{
case RewardType.Skill:
// This needs to use the passed in profileData, as it could be the scav profile
// skill reward values are always 100 (+1 level), so adjustment for low levels will give a wrong result
profileHelper.AddSkillPointsToPlayer(
profileData,
Enum.Parse<SkillTypes>(reward.Target),
reward.Value.GetValueOrDefault(0)
reward.Value.GetValueOrDefault(0),
useSkillProgressRateMultiplier: false,
adjustSkillExpForLowLevels: false
);
break;
case RewardType.Experience:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,14 @@ public record HideoutConfig : BaseConfig
[JsonPropertyName("hoursForSkillCrafting")]
public int HoursForSkillCrafting { get; set; }

[JsonPropertyName("expCraftAmount")]
public int ExpCraftAmount { get; set; }
[Obsolete("Will be removed in 4.1, use CraftingExpAmount")]
public int ExpCraftAmount { get; set; } = 0;

[JsonPropertyName("craftingExpAmount")]
public double CraftingExpAmount { get; set; }

[JsonPropertyName("craftingExpForHoursOfCrafting")]
public double CraftingExpForHoursOfCrafting { get; set; }

[JsonPropertyName("overrideCraftTimeSeconds")]
public int OverrideCraftTimeSeconds { get; set; }
Expand Down
19 changes: 6 additions & 13 deletions Libraries/SPTarkov.Server.Core/Services/RepairService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -185,10 +185,12 @@ public void AddRepairSkillPoints(MongoId sessionId, RepairDetails repairDetails,
);
}

// Every 10 points of repair gives 1 skill point scaled by skillProgressRate
// ArmorKitSkillPointGainPerRepairPointMultiplier is 0.1
var pointsToAddToVestSkill = repairDetails.RepairPoints * RepairConfig.ArmorKitSkillPointGainPerRepairPointMultiplier;

logger.Debug($"Added: {pointsToAddToVestSkill} {vestSkillToLevel} skill");
profileHelper.AddSkillPointsToPlayer(pmcData, vestSkillToLevel, pointsToAddToVestSkill.GetValueOrDefault(0));
profileHelper.AddSkillPointsToPlayer(pmcData, vestSkillToLevel, pointsToAddToVestSkill.GetValueOrDefault(0), true);
}

// Handle trader repair - gives charisma based on (repair cost/10 * skill progress rate)
Expand Down Expand Up @@ -245,18 +247,9 @@ protected double GetIntellectGainedFromRepair(RepairDetails repairDetails)
protected double GetWeaponRepairSkillPoints(RepairDetails repairDetails)
{
var random = new Random();
// This formula and associated configs is calculated based on 30 repairs done on live
// The points always came out 2-aligned, which is why there's a divide/multiply by 2 with ceil calls
var gainMult = RepairConfig.WeaponTreatment.PointGainMultiplier;

// First we get a baseline based on our repair amount, and gain multiplier with a bit of rounding
var step1 = Math.Ceiling(repairDetails.RepairAmount.Value / 2) * gainMult;

// Then we have to get the next even number
var step2 = Math.Ceiling(step1 / 2) * 2;

// Then multiply by 2 again to hopefully get to what live would give us
var skillPoints = step2 * 2;
// Every 5 points repaired with kit should give 0.4 skill points, so PointGainMultiplier is 0.2
// The return value is later scaled in AddSkillPointsToPlayer, i.e. 1 skill point returned here = 0.4 skill points added
var skillPoints = repairDetails.RepairAmount.GetValueOrDefault(0) * RepairConfig.WeaponTreatment.PointGainMultiplier;

// You can both crit fail and succeed at the same time, for fun (Balances out to 0 with default settings)
// Add a random chance to crit-fail
Expand Down
Loading