public static void InitHeroSkill(Hero hero) { int minSkillLevel = 5; int maxSikllLevel = 100; Random random = new Random(); if (MBRandom.RandomFloat < 0.2f) { minSkillLevel += 30; maxSikllLevel += 30; InformationManager.DisplayMessage(new InformationMessage(hero.Name + " gain more power")); } foreach (SkillObject sk in DefaultSkills.GetAllSkills()) { for (int i = 0; i < random.Next(5); i++) { random.Next(minSkillLevel, maxSikllLevel); } int skillLevel = random.Next(minSkillLevel, maxSikllLevel); hero.HeroDeveloper.ChangeSkillLevel(sk, skillLevel, false); } if (MoreSpouseSetting.Instance.SettingData.NPCCharaObjectSkillAuto) { foreach (SkillObject sk3 in DefaultSkills.GetAllSkills()) { hero.HeroDeveloper.TakeAllPerks(sk3); } } }
public static void FillUp(Hero hero, int skillValue, bool ignorePerks = true) { if (hero == default) { return; } try { DisplayMessage(string.Format("FillUp {0}", hero)); hero.HeroDeveloper.ClearFocuses(); hero.ClearAttributes(); //hero.ClearPerks(); foreach (var skill in DefaultSkills.GetAllSkills()) { hero.SetSkillValue(skill, skillValue); var xpValue = Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(skillValue); hero.HeroDeveloper.SetPropertyValue(skill, xpValue); //var focus = hero.HeroDeveloper.GetFocus(skill); //var changeAmount = HeroDeveloper.MaxFocusPerSkill - focus; //hero.HeroDeveloper.AddFocus(skill, changeAmount, false); // 因为上面调用了 ClearFocuses 这里直接给max hero.HeroDeveloper.AddFocus(skill, HeroDeveloper.MaxFocusPerSkill, false); } for (var i = CharacterAttributesEnum.First; i < CharacterAttributesEnum.End; i++) { try { //hero.HeroDeveloper.AddAttribute((CharacterAttributesEnum)item, HeroDeveloper.MaxAttribute, false); hero.SetAttributeValue(i, HeroDeveloper.MaxAttribute); } catch (Exception e) { DisplayMessage($"Attr(catch) item: {i}" + e.ToString()); } } if (!ignorePerks) { #region Perks foreach (var item in AllPerks) { try { hero.HeroDeveloper.AddPerk(item); } catch (Exception e) { DisplayMessage($"Perk(catch) item: {item}" + e.ToString()); } } #endregion } hero.Level = 1; hero.HeroDeveloper.UnspentAttributePoints = 0; hero.HeroDeveloper.UnspentFocusPoints = 0; } catch (Exception ex) { DisplayMessage(ex.ToString()); } }
/* ---- End Jiros Adds ---- */ private static void GrowUpForFixSkill(Hero hero) { // InformationManager.DisplayMessage(new InformationMessage("MoreSpouse GrowUpForFixSkill " + hero.Name)); if (hero == Hero.MainHero) { return; } hero.ClearSkills(); // hero.HeroDeveloper.ClearHeroLevel(); float fatherInheritDivider = 0; float motherInheritDivider = 0; if (hero.IsFemale == true) { fatherInheritDivider = 0.4f; motherInheritDivider = 0.6f; } else { fatherInheritDivider = 0.6f; motherInheritDivider = 0.4f; } Hero InheritFather = hero.Father != null ? hero.Father : hero; Hero InheritMother = hero.Mother != null ? hero.Mother : hero; float skillTimes = (new Random().Next(2) == 1) ? 1.5f : 1f; if (Hero.MainHero.Children.Contains(hero) || Hero.MainHero.Father.Children.Contains(hero)) { int randomTims = new Random().Next(5); if (randomTims == 1) { skillTimes = skillTimes * 1.5f; InformationManager.AddQuickInformation(new TextObject($"Your children {hero.Name} get more power"), 0, null, "event:/ui/notification/quest_finished"); } } foreach (SkillObject skillIT in DefaultSkills.GetAllSkills()) { int sikillValue = (int)(InheritFather.GetSkillValue(skillIT) * fatherInheritDivider + InheritMother.GetSkillValue(skillIT) * motherInheritDivider); hero.HeroDeveloper.ChangeSkillLevel(skillIT, (int)(sikillValue * skillTimes), false); hero.HeroDeveloper.TakeAllPerks(skillIT); } hero.ClearTraits(); hero.SetTraitLevel(DefaultTraits.Honor, InheritMother.GetTraitLevel(DefaultTraits.Honor)); hero.SetTraitLevel(DefaultTraits.Valor, InheritMother.GetTraitLevel(DefaultTraits.Valor)); hero.SetTraitLevel(DefaultTraits.Mercy, InheritMother.GetTraitLevel(DefaultTraits.Mercy)); hero.SetTraitLevel(DefaultTraits.Generosity, InheritMother.GetTraitLevel(DefaultTraits.Generosity)); hero.SetTraitLevel(DefaultTraits.Calculating, InheritMother.GetTraitLevel(DefaultTraits.Calculating)); hero.Level = 0; hero.HeroDeveloper.UnspentFocusPoints = 20; hero.HeroDeveloper.UnspentAttributePoints = 20; }
private void RePerksHero(Hero hero) { foreach (SkillObject skill in DefaultSkills.GetAllSkills()) { hero.HeroDeveloper.TakeAllPerks(skill); } hero.ClearPerks(); }
private void RespecHero(Hero hero) { InformationManager.DisplayMessage(new InformationMessage($"{hero.Name} will be demolished.")); InformationManager.DisplayMessage(new InformationMessage($"Clearing Perks...")); hero.ClearPerks(); // re-initialize skills to activate perks foreach (SkillObject skill in DefaultSkills.GetAllSkills()) { int skill_level = hero.GetSkillValue(skill); hero.HeroDeveloper.SetInitialSkillLevel(skill, skill_level); } int statpoints = hero.HeroDeveloper.UnspentAttributePoints; int focuspoints = hero.HeroDeveloper.UnspentFocusPoints; int focus_to_add = 0; int statpoints_to_add = 0; InformationManager.DisplayMessage(new InformationMessage($"Unspent: {statpoints} stat | {focuspoints} focus")); InformationManager.DisplayMessage(new InformationMessage($"Demolishing focus...")); foreach (SkillObject skill in DefaultSkills.GetAllSkills()) { int focus_in_skill = hero.HeroDeveloper.GetFocus(skill); if (focus_in_skill > 0) { InformationManager.DisplayMessage(new InformationMessage($"{skill.Name}; {focus_in_skill}")); focus_to_add += focus_in_skill; } } InformationManager.DisplayMessage(new InformationMessage($"{focus_to_add} focus points reclaimed")); hero.HeroDeveloper.UnspentFocusPoints += MBMath.ClampInt(focus_to_add, 0, 999); hero.HeroDeveloper.ClearFocuses(); InformationManager.DisplayMessage(new InformationMessage($"Demolishing stats...")); for (CharacterAttributesEnum statEnum = CharacterAttributesEnum.Vigor; statEnum < CharacterAttributesEnum.NumCharacterAttributes; statEnum++) { int attributeValue = hero.GetAttributeValue(statEnum); InformationManager.DisplayMessage(new InformationMessage($"{statEnum} {attributeValue} --> 0")); statpoints_to_add += attributeValue; hero.SetAttributeValue(statEnum, 0); } InformationManager.DisplayMessage(new InformationMessage($"{statpoints_to_add} stat points reclaimed")); hero.HeroDeveloper.UnspentAttributePoints += MBMath.ClampInt(statpoints_to_add, 0, 999); InformationManager.DisplayMessage(new InformationMessage($"Unspent: {hero.HeroDeveloper.UnspentAttributePoints} stat | {hero.HeroDeveloper.UnspentFocusPoints} focus")); }
private void GiveRandomSkillXP() { List <SkillObject> allSkills = DefaultSkills.GetAllSkills().ToList(); int index = MBRandom.RandomInt(allSkills.Count); float xpToGive = Settings.GeneralSettings.GeneralLevelXpMultiplier * Hero.MainHero.GetSkillValue(allSkills[index]); Hero.MainHero.AddSkillXp(allSkills[index], xpToGive); }
/// <summary> /// This constructor is used purely to set up the object with defaults. /// </summary> protected internal PerkBase() { PrimaryBonus = default; PrimaryRole = SkillEffect.PerkRole.None; SecondaryBonus = default; SecondaryRole = SkillEffect.PerkRole.None; EffectType = SkillEffect.EffectIncrementType.Add; Skill = DefaultSkills.GetAllSkills().First(); }
public static void ResetPerksCheckSmithPerk(Hero hero) { if (hero.HeroDeveloper.GetPerkValue(DefaultPerks.Crafting.VigorousSmith)) { // 第一排第六个 // 有力的铁匠,立刻提升一点活力 int value = hero.GetAttributeValue(CharacterAttributesEnum.Vigor) - 1; DisplayMessage($"VigorousSmith Vigor: {value}"); if (value > 0) { hero.SetAttributeValue(CharacterAttributesEnum.Vigor, value); } } if (hero.HeroDeveloper.GetPerkValue(DefaultPerks.Crafting.StrongSmith)) { // 第二排第六个 // 精密锻造,立刻增加一点控制 int value = hero.GetAttributeValue(CharacterAttributesEnum.Control) - 1; DisplayMessage($"StrongSmith Control: {value}"); if (value > 0) { hero.SetAttributeValue(CharacterAttributesEnum.Control, value); } } if (hero.HeroDeveloper.GetPerkValue(DefaultPerks.Crafting.EnduringSmith)) { // 第一排倒数第二个 // 正规铁匠,立刻提高忍耐1级 int value = hero.GetAttributeValue(CharacterAttributesEnum.Endurance) - 1; DisplayMessage($"EnduringSmith Endurance: {value}"); if (value > 0) { hero.SetAttributeValue(CharacterAttributesEnum.Endurance, value); } } if (hero.HeroDeveloper.GetPerkValue(DefaultPerks.Crafting.WeaponMasterSmith)) { // 第二排倒数第二个 // 击剑铁匠,单手系和双手系技能各获得1点专精点 hero.HeroDeveloper.AddFocus(DefaultSkills.OneHanded, -1, false); hero.HeroDeveloper.AddFocus(DefaultSkills.TwoHanded, -1, false); DisplayMessage($"WeaponMasterSmith"); } hero.ClearPerks(); // ??? why setInitialSkillLevel foreach (var item in DefaultSkills.GetAllSkills()) { int skillValue = hero.GetSkillValue(item); hero.HeroDeveloper.SetInitialSkillLevel(item, skillValue); } }
public static void ResetPerks([NotNull] this Hero hero) { if (reset_perks_check_smith) { if (DefaultPerks.Crafting.VigorousSmith.Exist(hero)) { // 第一排第六个 // 有力的铁匠,立刻提升一点活力 int value = hero.GetAttributeValue(CharacterAttributesEnum.Vigor) - 1; if (value > 0) { hero.SetAttributeValue(CharacterAttributesEnum.Vigor, value); } } if (DefaultPerks.Crafting.StrongSmith.Exist(hero)) { // 第二排第六个 // 精密锻造,立刻增加一点控制 int value = hero.GetAttributeValue(CharacterAttributesEnum.Control) - 1; if (value > 0) { hero.SetAttributeValue(CharacterAttributesEnum.Control, value); } } if (DefaultPerks.Crafting.EnduringSmith.Exist(hero)) { // 第一排倒数第二个 // 正规铁匠,立刻提高忍耐1级 int value = hero.GetAttributeValue(CharacterAttributesEnum.Endurance) - 1; if (value > 0) { hero.SetAttributeValue(CharacterAttributesEnum.Endurance, value); } } if (DefaultPerks.Crafting.WeaponMasterSmith.Exist(hero)) { // 第二排倒数第二个 // 击剑铁匠,单手系和双手系技能各获得1点专精点 hero.HeroDeveloper.AddFocus(DefaultSkills.OneHanded, -1, false); hero.HeroDeveloper.AddFocus(DefaultSkills.TwoHanded, -1, false); } } hero.ClearPerks(); // ↓ 设置初始技能等级,不设置会导致加点无法保存 foreach (var item in DefaultSkills.GetAllSkills()) { int skillValue = hero.GetSkillValue(item); hero.HeroDeveloper.SetInitialSkillLevel(item, skillValue); } }
public static void ResetFocus([NotNull] this Hero hero) { //var focus = DefaultSkills.GetAllSkills().Sum(skill => hero.HeroDeveloper.GetFocus(skill)); //hero.HeroDeveloper.UnspentFocusPoints += MBMath.ClampInt(focus, 0, 999); //hero.HeroDeveloper.ClearFocuses(); int count = 0; foreach (var item in DefaultSkills.GetAllSkills()) { var focus = hero.HeroDeveloper.GetFocus(item); hero.HeroDeveloper.AddFocus(item, 0 - focus, false); count += focus; } hero.HeroDeveloper.UnspentFocusPoints += MBMath.ClampInt(count, 0, 999); }
public void RefocusHero(Hero hero) { int num = 0; int num2 = 0; foreach (SkillObject skill in DefaultSkills.GetAllSkills()) { int focus = hero.HeroDeveloper.GetFocus(skill); if (focus > 0) { num += focus; hero.HeroDeveloper.AddFocus(skill, num2 - focus, false); } } hero.HeroDeveloper.UnspentFocusPoints += MBMath.ClampInt(num, 0, 999); }
public static void Inherit(Hero targetInheriter) { if (targetInheriter == null) { return; } try { GrowthDebug.LogInfo($"Enter inherit method, handling inherit of {targetInheriter}"); targetInheriter.ClearSkills(); targetInheriter.HeroDeveloper.ClearHeroLevel(); int fatherInheritDivider = 0; int motherInheritDivider = 0; if (targetInheriter.IsFemale == true) { fatherInheritDivider = 10; motherInheritDivider = 5; } else { fatherInheritDivider = 5; motherInheritDivider = 10; } foreach (SkillObject skillIT in DefaultSkills.GetAllSkills()) { Hero InheritFather = targetInheriter.Father != null ? targetInheriter.Father : targetInheriter; Hero InheritMother = targetInheriter.Mother != null ? targetInheriter.Mother : targetInheriter; targetInheriter.HeroDeveloper.ChangeSkillLevel(skillIT, InheritFather.GetSkillValue(skillIT) / fatherInheritDivider + InheritMother.GetSkillValue(skillIT) / motherInheritDivider, false); } targetInheriter.Level = 0; targetInheriter.HeroDeveloper.UnspentFocusPoints = 10; targetInheriter.HeroDeveloper.UnspentAttributePoints = 10; } catch (Exception e) { GrowthDebug.ShowError($"Error during inheritance", "Error During Inheritance", e); } }
static void Postfix(Hero hero, CharacterObject templateCharacter = null) { if (MoreSpouseSetting.Instance.SettingData.ChildrenSkillFixEnable) { int zeroCount = 0; foreach (SkillObject skillIT in DefaultSkills.GetAllSkills()) { if (hero.GetSkillValue(skillIT) <= 10) { zeroCount++; } } if (zeroCount >= (DefaultSkills.GetAllSkills().Count() - 3)) { GrowUpForFixSkill(hero); } } }
public static void RespecHero(Hero hero) { if (hero == default) { return; } int num1 = 0; int num2 = 0; DisplayMessage(string.Format("{0}", hero)); RespecPerks(hero); DisplayMessage("Clearing focus..."); using (IEnumerator <SkillObject> enumerator = DefaultSkills.GetAllSkills().GetEnumerator()) { while (enumerator.MoveNext()) { var current = enumerator.Current; int focus = hero.HeroDeveloper.GetFocus(current); if (focus > 0) { num1 += focus; } } } hero.HeroDeveloper.UnspentFocusPoints += MBMath.ClampInt(num1, 0, 999); hero.HeroDeveloper.ClearFocuses(); DisplayMessage("Clearing stats..."); for (CharacterAttributesEnum characterAttributesEnum = 0; characterAttributesEnum < CharacterAttributesEnum.End; characterAttributesEnum += 1) { int attributeValue = hero.GetAttributeValue(characterAttributesEnum); if (hero == Hero.MainHero) { num2 += attributeValue - 2; hero.SetAttributeValue(characterAttributesEnum, 2); } else { num2 += attributeValue - 1; hero.SetAttributeValue(characterAttributesEnum, 1); } } hero.HeroDeveloper.UnspentAttributePoints += MBMath.ClampInt(num2, 0, 999); DisplayMessage(string.Format("Unspent: {0} stat | {1} focus", hero.HeroDeveloper.UnspentAttributePoints, hero.HeroDeveloper.UnspentFocusPoints)); }
public static void RespecReset(Hero hero) { if (hero == default) { return; } DisplayMessage(string.Format("Reset {0}", hero)); hero.HeroDeveloper.ClearFocuses(); hero.ClearAttributes(); using (IEnumerator <SkillObject> enumerator = DefaultSkills.GetAllSkills().GetEnumerator()) { while (enumerator.MoveNext()) { var current = enumerator.Current; hero.HeroDeveloper.SetInitialSkillLevel(current, 5); } } hero.HeroDeveloper.SetInitialSkillLevel(DefaultSkills.OneHanded, 10); hero.HeroDeveloper.SetInitialSkillLevel(DefaultSkills.TwoHanded, 10); hero.HeroDeveloper.SetInitialSkillLevel(DefaultSkills.Polearm, 10); hero.HeroDeveloper.SetInitialSkillLevel(DefaultSkills.Bow, 10); hero.HeroDeveloper.SetInitialSkillLevel(DefaultSkills.Crossbow, 10); hero.HeroDeveloper.SetInitialSkillLevel(DefaultSkills.Throwing, 10); hero.ClearPerks(); HeroHelper.DetermineInitialLevel(hero); if (hero == Hero.MainHero) { for (CharacterAttributesEnum characterAttributesEnum = 0; characterAttributesEnum < CharacterAttributesEnum.End; characterAttributesEnum += 1) { hero.SetAttributeValue(characterAttributesEnum, 2); } hero.HeroDeveloper.UnspentAttributePoints = 6; hero.HeroDeveloper.UnspentFocusPoints = 13; } else { hero.HeroDeveloper.UnspentAttributePoints = 9; hero.HeroDeveloper.UnspentFocusPoints = 5; } }
private void DailyTick() { if (this._companionHeroSaves.Count == 0) { return; } Dictionary <SkillObject, int> max = new Dictionary <SkillObject, int>(); var heroes = new HashSet <Hero>() { Hero.MainHero }; foreach (var item in Hero.MainHero.CompanionsInParty) { heroes.Add(item); } foreach (var item in Hero.MainHero.Clan.Heroes) { if (item.PartyBelongedTo == MobileParty.MainParty) { heroes.Add(item); } } foreach (var hero in heroes) { if (hero.IsWounded) { continue; } foreach (var skill in DefaultSkills.GetAllSkills()) { var value = hero.GetSkillValue(skill); if (max.ContainsKey(skill)) { max[skill] = max[skill] > value ? max[skill] : value; } else { max.Add(skill, value); } } } foreach (var hero in heroes) { if (hero.IsWounded) { continue; } var learningSkill = getHeroLearningSkill(hero); if (learningSkill == null || !max.ContainsKey(learningSkill) || max[learningSkill] < 50) { continue; } var companionSkillValue = hero.GetSkillValue(learningSkill); if (max[learningSkill] > (companionSkillValue + 3)) { //升到下一级的经验 var baseXp = 0.01f * (Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(companionSkillValue) - Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(companionSkillValue - 1)); var xp = (1 + XPGlobalSetting.Instance.LearningXPMultipier) * baseXp * Math.Min(10, Math.Sqrt(max[learningSkill] - companionSkillValue)); xp /= (Math.Max(30, companionSkillValue) / 30); //xp += companionSkillValue; hero.AddSkillXp(learningSkill, (float)xp); } } }
public static void FixCappedKids() { Hero.MainHero.Children.ForEach((kid) => { if (!kid.IsChild && kid.Age < 30) { bool ShouldFixChildrenFlag = false; int CappedSkillCounter = 0; int SkillTotal = 0; foreach (var skillObject in DefaultSkills.GetAllSkills()) { SkillTotal += kid.GetSkillValue(skillObject); if (kid.HeroDeveloper.GetSkillXpProgress(skillObject) < 0) { CappedSkillCounter++; } if (CappedSkillCounter > 5) { ShouldFixChildrenFlag = true; } } if (SkillTotal <= 10 && kid.Level > 5) { ShouldFixChildrenFlag = true; } if (kid.HeroDeveloper.GetTotalSkillPoints() < 80 && kid.Level >= 5) { ShouldFixChildrenFlag = true; } int attrAccumulator = 0; foreach (var VARIABLE in CharacterAttributes.All) { attrAccumulator += kid.GetAttributeValue(VARIABLE.AttributeEnum); } attrAccumulator += kid.HeroDeveloper.UnspentAttributePoints; GrowthDebug.LogInfo($"Kids{kid.Name} attribute sum: {attrAccumulator}"); if (attrAccumulator < 9 && kid.Level > 8) { ShouldFixChildrenFlag = true; } if (attrAccumulator >= 10 || kid.Level == 0) { ShouldFixChildrenFlag = false; } if (ShouldFixChildrenFlag) { InformationManager.DisplayMessage(new InformationMessage( SettingClass.CurrentLanguage == "zh" ? $"检测到你的孩子{kid.Name}属性异常, 已经修复" : $"Detected Your Child {kid.Name}'s stats are abnormal, already fixed", Colors.Magenta)); GrowthDebug.LogInfo($"Detected Your Child{kid.Name}'s stats are abnormal, already fixed", "Fixed"); Inherit(kid); } } }); }
public static void FillUp([NotNull] this Hero hero, int?maxSkillValue) { if (hero == default) { return; } try { var maxFocus = HeroDeveloper.MaxFocusPerSkill; maxSkillValue ??= MaxSkillValue; //DisplayMessage(string.Format("FillUp {0}", hero)); //hero.HeroDeveloper.ClearFocuses(); hero.ClearAttributes(); var allSkills = DefaultSkills.GetAllSkills().ToArray(); foreach (var skill in allSkills) { hero.SetSkillValue(skill, maxSkillValue.Value); var xpValue = Campaign.Current.Models.CharacterDevelopmentModel.GetXpRequiredForSkillLevel(maxSkillValue.Value); hero.HeroDeveloper.SetPropertyValue(skill, xpValue); var focus = hero.HeroDeveloper.GetFocus(skill); focus = maxFocus - focus; if (focus > 0) { hero.HeroDeveloper.AddFocus(skill, focus, false); } } for (var i = CharacterAttributesEnum.First; i < CharacterAttributesEnum.End; i++) { try { hero.SetAttributeValue(i, HeroDeveloper.MaxAttribute); } catch (Exception e) { DisplayMessage($"Attr(catch) item: {i}" + e.ToString()); } } var allPerks = Perks.All; foreach (var item in allPerks) { try { if (!hero.GetPerkValue(item)) { hero.SetPerkValue(item, true); } } catch (Exception e) { DisplayMessage($"Perk(catch) item: {item}" + e.ToString()); } } var openedPerks = lazy_field_openedPerks.Value.GetValue(hero.HeroDeveloper); if (openedPerks is List <PerkObject> _openedPerks) { _openedPerks.Clear(); } hero.Level = 1; hero.HeroDeveloper.UnspentAttributePoints = 0; hero.HeroDeveloper.UnspentFocusPoints = 0; } catch (Exception ex) { DisplayMessage(ex); } }