/// <summary> /// Prestiges a skill, resetting it to level 0, removing all recipes and effects of the skill at higher levels /// and grants one prestige point in that skill to the player. /// </summary> /// <param name="skill">the skill you wish to prestige.</param> public static void PrestigeSkill(Skill skill) { try { if (PerSaveOptions.Instance.PainlessPrestigeMode) { Logger.LogInformation($"Prestiging skill {skill.Type.Name} via Painless Mode."); skill.SetSkillExperience(Game1.player.experiencePoints[skill.Type.Ordinal] - PerSaveOptions.Instance.ExperienceNeededPerPainlessPrestige); Logger.LogInformation($"Removed {PerSaveOptions.Instance.ExperienceNeededPerPainlessPrestige} experience points from {skill.Type.Name} skill."); } else { Logger.LogInformation($"Prestiging skill {skill.Type.Name}."); skill.SetSkillExperience(0); skill.SetSkillLevel(0); Logger.LogInformation($"Skill {skill.Type.Name} experience and level reset."); if (PerSaveOptions.Instance.ResetRecipesOnPrestige) { RemovePlayerCraftingRecipesForSkill(skill.Type); RemovePlayerCookingRecipesForSkill(skill.Type); } Profession.RemoveProfessions(skill); PlayerManager.CorrectStats(skill); Profession.AddMissingProfessions(); } PrestigeSaveData.CurrentlyLoadedPrestigeSet.Prestiges.Single(x => x.SkillType == skill.Type).PrestigePoints += PerSaveOptions.Instance.PointsPerPrestige; Logger.LogInformation($"{PerSaveOptions.Instance.PointsPerPrestige} Prestige point(s) added to {skill.Type.Name} skill."); } catch (Exception exception) { Logger.LogError(exception.Message + Environment.NewLine + exception.StackTrace); } }
/// <summary> /// Purchases a profession to be part of the prestige set. /// </summary> /// <param name="professionId"></param> public static void AddPrestigeProfession(int professionId) { var skill = Skill.AllSkills.Single(x => x.Professions.Select(y => y.Id).Contains(professionId)); var prestige = PrestigeSaveData.CurrentlyLoadedPrestigeSet.Prestiges.Single(x => x.SkillType == skill.Type); var originalPrestigePointsForSkill = prestige.PrestigePoints; if (skill.Professions.Where(x => x.LevelAvailableAt == 5).Select(x => x.Id).Contains(professionId)) { prestige.PrestigePoints -= PerSaveOptions.Instance.CostOfTierOnePrestige; Logger.LogInformation($"Spent prestige point on {skill.Type.Name} skill."); } else if (skill.Professions.Where(x => x.LevelAvailableAt == 10).Select(x => x.Id).Contains(professionId)) { prestige.PrestigePoints -= PerSaveOptions.Instance.CostOfTierTwoPrestige; Logger.LogInformation($"Spent 2 prestige points on {skill.Type.Name} skill."); } else { Logger.LogError($"No skill found for selected profession: {professionId}"); } if (prestige.PrestigePoints < 0) { prestige.PrestigePoints = originalPrestigePointsForSkill; Logger.LogCritical($"Prestige amount for {skill.Type.Name} skill would have gone negative, unable to grant profession {professionId}. Prestige values reset."); } else { prestige.PrestigeProfessionsSelected.Add(professionId); Logger.LogInformation("Profession permanently added."); Profession.AddMissingProfessions(); } }
/// <summary>Raised after the player loads a save slot and the world is initialised.</summary> /// <param name="sender">The event sender.</param> /// <param name="e">The event data.</param> private void OnSaveLoaded(object sender, SaveLoadedEventArgs e) { PrestigeSaveData.Instance.UpdateCurrentSaveFileInformation(); PerSaveOptions.Instance.Check(); Profession.AddMissingProfessions(); SaveIsLoaded = true; }
private static void LocationChanged(object sender, EventArgs args) { Logger.LogVerbose("Location change detected."); //CurrentSaveOptionsPath = Path.Combine(ModPath, "psconfigs/", $@"{Game1.player.name.Value.RemoveNonAlphanumerics()}_{Game1.uniqueIDForThisGame}.json"); //PrestigeSaveData.Instance.UpdateCurrentSaveFileInformation(); PerSaveOptions.Instance.Check(); Profession.AddMissingProfessions(); }
private void LocationChanged(object sender, EventArgs args) { Logger.LogVerbose("Location change detected."); CurrentSaveOptionsPath = string.IsNullOrWhiteSpace(PerSaveConfigPath) ? Path.Combine(PerSaveConfigFolder, $@"{Game1.player.name.RemoveNumerics()}_{Game1.uniqueIDForThisGame}.json") : PerSaveConfigPath; PrestigeSaveData.Instance.UpdateCurrentSaveFileInformation(); PerSaveOptions.Instance.Check(); Profession.AddMissingProfessions(); }
/// <summary> /// Prestiges a skill, resetting it to level 0, removing all recipes and effects of the skill at higher levels /// and grants one prestige point in that skill to the player. /// </summary> /// <param name="skill">the skill you wish to prestige.</param> public static void PrestigeSkill(Skill skill) { try { Logger.LogInformation($"Prestiging skill {skill.Type.Name}."); skill.SetSkillExperience(0); skill.SetSkillLevel(0); Logger.LogInformation($"Skill {skill.Type.Name} experience and level reset."); if (PerSaveOptions.Instance.ResetRecipesOnPrestige) { RemovePlayerCraftingRecipesForSkill(skill.Type); RemovePlayerCookingRecipesForSkill(skill.Type); } Profession.RemoveProfessions(skill); Profession.AddMissingProfessions(); PrestigeSaveData.CurrentlyLoadedPrestigeSet.Prestiges.Single(x => x.SkillType == skill.Type).PrestigePoints++; Logger.LogInformation($"Prestige point added to {skill.Type.Name} skill."); } catch (Exception exception) { Logger.LogError(exception.Message + Environment.NewLine + exception.StackTrace); } }