static bool Prefix(Hero __instance, SkillObject skill, int xpAmount) { try { HeroDeveloper hd = (HeroDeveloper)(typeof(Hero).GetField("_heroDeveloper", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(__instance)); if (hd != null) { if (xpAmount > 0) { double multiplier = GetMultiplier(__instance.GetSkillValue(skill)); int newXpAmount = (int)Math.Ceiling(xpAmount * multiplier); hd.AddSkillXp(skill, newXpAmount); } else { hd.AddSkillXp(skill, xpAmount); } } } catch (Exception ex) { ModDebug.ShowError($"An exception occurred whilst trying to apply the hero xp multiplier.", "", ex); } return(false); }
//private static float GetMultiplier() //{ // if (Settings.Instance.HeroSkillExperienceOverrideMultiplierEnabled) //return Settings.Instance.HeroSkillExperienceMultiplier; //else // return Math.Max(1, 0.0315769 * Math.Pow(skillLevel, 1.020743)); //} static bool Prefix(Hero __instance, SkillObject skill, float xpAmount) { try { if (hdFieldInfo == null) { GetFieldInfo(); } HeroDeveloper hd = (HeroDeveloper)hdFieldInfo.GetValue(__instance); if (hd != null) { if (xpAmount > 0) { float newXpAmount = (int)Math.Ceiling(xpAmount * Settings.Instance.HeroSkillExperienceMultiplier); hd.AddSkillXp(skill, newXpAmount, true, true); } else { hd.AddSkillXp(skill, xpAmount, true, true); } } } catch (Exception ex) { ModDebug.ShowError($"An exception occurred whilst trying to apply the hero xp multiplier.", "", ex); } return(false); }
static bool Prefix(Hero __instance, SkillObject skill, float xpAmount) { try { if (hdFieldInfo == null) { GetFieldInfo(); } HeroDeveloper hd = (HeroDeveloper)hdFieldInfo !.GetValue(__instance); if (!(BannerlordTweaksSettings.Instance is { } settings)) { return(true); } if (hd != null) { if (xpAmount > 0) { if (settings.HeroSkillExperienceMultiplierEnabled && hd.Hero.IsHumanPlayerCharacter) { if (settings.PerSkillBonusEnabled) { float PerSkillBonus = GetPerSkillBonus(skill, xpAmount); xpAmount = PerSkillBonus; } float newXpAmount = (int)Math.Ceiling(xpAmount * settings.HeroSkillExperienceMultiplier); hd.AddSkillXp(skill, newXpAmount, true, true); } else if (settings.CompanionSkillExperienceMultiplierEnabled && !hd.Hero.IsHumanPlayerCharacter && (hd.Hero.Clan == Hero.MainHero.Clan)) { if (settings.PerSkillBonusEnabled) { float PerSkillBonus = GetPerSkillBonus(skill, xpAmount); xpAmount = PerSkillBonus; } float newXpAmount = (int)Math.Ceiling(xpAmount * settings.CompanionSkillExperienceMultiplier); hd.AddSkillXp(skill, newXpAmount, true, true); } else { hd.AddSkillXp(skill, xpAmount, true, true); } } else { hd.AddSkillXp(skill, xpAmount, true, true); } } } catch (Exception ex) { DebugHelpers.ShowError("An exception occurred while trying to apply the hero xp multiplier.", "", ex); } return(false); }
static bool Prefix(Hero __instance, SkillObject skill, int xpAmount) { try { HeroDeveloper hd = (HeroDeveloper)(typeof(Hero).GetField("_heroDeveloper", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(__instance)); if (hd != null) { double multiplier = GetMultiplier(__instance.GetSkillValue(skill)); int newXpAmount = (int)Math.Ceiling(xpAmount * multiplier); hd.AddSkillXp(skill, newXpAmount); //MessageBox.Show($"Skill: {skill.Name}\nLevel: {__instance.GetSkillValue(skill)}\nMultiplier: {multiplier}\nOld xp amount: {xpAmount}\nNew xp amount: {newXpAmount}"); } } catch (Exception ex) { MessageBox.Show($"An exception occurred whilst trying to apply the xp multiplier.\n\nException:\n{ex.Message}\n\n{ex.InnerException?.Message}"); } return(false); }
static bool Prefix(Hero __instance, SkillObject skill, int xpAmount) { try { HeroDeveloper hd = (HeroDeveloper)(typeof(Hero).GetField("_heroDeveloper", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic).GetValue(__instance)); if (hd != null) { if (xpAmount > 0) { double multiplier = GetMultiplier(__instance, __instance.GetSkillValue(skill), skill); int newXpAmount = (int)Math.Ceiling(xpAmount * multiplier); hd.AddSkillXp(skill, newXpAmount); } else { hd.AddSkillXp(skill, xpAmount); } } } catch (Exception ex) { } return(false); }
public invoke() { // Замовник var customer = new Customer(); // Із певних міркуваня, бос завжди знає, що грошей стає тільки // на бригаду Z var team = new Team("Z"); // Також бос отримав список вимог, що треба буде передати бригаді var requirements = new List<Requirement>() { new Requirement("Cool web site"), new Requirement("Ability to book beer on site") }; // Ви повинні бути готові бути викликаними замовником ICommand commandX = new YouAsProjectManagerCommand(team, requirements); // Передача вас у «найми» замовнику customer.AddCommand(commandX); // В компанії також є програміст-герой, що кодує на швидкості світла var heroDeveloper = new HeroDeveloper(); // Бос вирішив віддати йому проект A ICommand commandA = new HeroDeveloperCommand(heroDeveloper, "A"); customer.AddCommand(commandA); // Як тільки замовник підписує контракт із вашим босом, // ваша бригада і програміст-герой готові виконати все, що треба // згідно вихідного коду контракту customer.SignContractWithBoss(); }
public HeroDeveloperCommand(HeroDeveloper heroDeveloper, string projectName) { HeroDeveloper = heroDeveloper; ProjectName = projectName; }
public void Execute() { // реалізація делегує роботу до потрібного отримувача HeroDeveloper.DoAllHardWork(ProjectName); }
static void Postfix(HeroDeveloper __instance, ref int __result) { __result -= FreeSkill.Get(__instance.StringId).SpentSkillPoints; }