public static CharacterAttribute GetCharacterAttribute(
            CharacterAttributesEnum attributeType)
        {
            switch (attributeType)
            {
            case CharacterAttributesEnum.Vigor:
                return(CharacterAttributes.Vigor);

            case CharacterAttributesEnum.Control:
                return(CharacterAttributes.Control);

            case CharacterAttributesEnum.Endurance:
                return(CharacterAttributes.Endurance);

            case CharacterAttributesEnum.Cunning:
                return(CharacterAttributes.Cunning);

            case CharacterAttributesEnum.Social:
                return(CharacterAttributes.Social);

            case CharacterAttributesEnum.Intelligence:
                return(CharacterAttributes.Intelligence);

            default:
                return(CharacterAttributes.Vigor);
            }
        }
Beispiel #2
0
        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"));
        }
        public void SetAttributeValue(CharacterAttributesEnum attributesEnum, int newValue)
        {
            HeroAdminCharacterAttribute result = Attributes.FirstOrDefault((obj) => obj.AttributeName.Equals(Enum.GetName(typeof(CharacterAttributesEnum), attributesEnum)));

            if (null != result)
            {
                result.AttributeValue = newValue;
            }
        }
        public HeroAdminAttributeItemVM(CharacterAttributesEnum attributesEnum, int value, Action <CharacterAttributesEnum, int> onAttributeChange)
        {
            this._attributesEnum    = attributesEnum;
            this._attributeValue    = value;
            this._onAttributeChange = onAttributeChange;
            CharacterAttribute characterAttribute = CharacterAttributes.GetCharacterAttribute(attributesEnum);

            this._nameText = characterAttribute.Abbreviation.ToString();
        }
 private static void AddAttribute(Hero hero, CharacterAttributesEnum attr, int val)
 {
     if (val > 0 && hero.HeroDeveloper.UnspentAttributePoints >= val)
     {
         int c = hero.GetAttributeValue(attr);
         hero.SetAttributeValue(attr, c + val);
         int diff = hero.GetAttributeValue(attr) - c;
         hero.HeroDeveloper.UnspentAttributePoints -= diff;
     }
 }
Beispiel #6
0
        private void UpdateList(bool full = false)
        {
            var excludes = new CharacterAttributesEnum[] { CharacterAttributesEnum.NumCharacterAttributes, CharacterAttributesEnum.End };
            var values   = Enum.GetValues(typeof(CharacterAttributesEnum)).OfType <CharacterAttributesEnum>().Except(excludes).ToArray();

            if (full)
            {
                this.lstItems.SetObjects(values);
            }
            this.lstItems.UpdateObjects(values);
        }
Beispiel #7
0
 public void Initialize(
     TextObject name,
     TextObject description,
     TextObject abbreviation,
     CharacterAttributesEnum attributeEnum)
 {
     this.Initialize(name, description);
     this.AttributeEnum = attributeEnum;
     this.Abbreviation  = abbreviation;
     this._skills       = new SkillObject[0];
     this.AfterInitialized();
 }
Beispiel #8
0
        public void ReAttHero(Hero hero)
        {
            int num = 0;

            for (CharacterAttributesEnum characterAttributesEnum = CharacterAttributesEnum.Vigor; characterAttributesEnum < CharacterAttributesEnum.NumCharacterAttributes; characterAttributesEnum++)
            {
                int attributeValue = hero.GetAttributeValue(characterAttributesEnum);
                num += attributeValue;
                hero.SetAttributeValue(characterAttributesEnum, 0);
            }
            hero.HeroDeveloper.UnspentAttributePoints += MBMath.ClampInt(num, 0, 999);
        }
        public int GetAttributeValue(CharacterAttributesEnum attributesEnum)
        {
            HeroAdminCharacterAttribute result = Attributes.FirstOrDefault((obj) => obj.AttributeName.Equals(Enum.GetName(typeof(CharacterAttributesEnum), attributesEnum)));

            if (null != result)
            {
                return(result.AttributeValue);
            }
            else
            {
                return(0);
            }
        }
Beispiel #10
0
        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));
        }
Beispiel #11
0
        private static void AddPoint(CharacterAttributesEnum type)
        {
            var charVM = ScreenManager.TopScreen.GetViewModel <CharacterDeveloperVM>();

            var currentHero = charVM.CurrentCharacter.Hero;

            var oldValue = currentHero.GetAttributeValue(type);

            if (oldValue >= 10)
            {
                return;
            }

            currentHero.SetAttributeValue(type, oldValue + 1);

            charVM.RefreshValues();

            var message = string.Format(L10N.GetText("AddAttributePointMessage"), Enum.GetName(typeof(CharacterAttributesEnum), type), currentHero.Name);

            InformationManager.DisplayMessage(new InformationMessage(message, Color.White));
        }
 private void InitializeCharacter()
 {
     this.HeroCharacter = new HeroViewModel(CharacterViewModel.StanceTypes.None);
     this.Skills        = new MBBindingList <CSSkillVM>();
     this.Traits        = new MBBindingList <EncyclopediaTraitItemVM>();
     //this.Attributes.Clear();
     this.HeroCharacter.FillFrom(this.hero, -1);
     this.HeroCharacter.SetEquipment(EquipmentIndex.ArmorItemEndSlot, default(EquipmentElement));
     this.HeroCharacter.SetEquipment(EquipmentIndex.HorseHarness, default(EquipmentElement));
     this.HeroCharacter.SetEquipment(EquipmentIndex.NumAllWeaponSlots, default(EquipmentElement));
     foreach (SkillObject skill in (from s in SkillObject.All
                                    group s by s.CharacterAttribute.Id).SelectMany((IGrouping <MBGUID, SkillObject> s) => s).ToList <SkillObject>())
     {
         this.Skills.Add(new CSSkillVM(skill, this, _screenData));
     }
     for (CharacterAttributesEnum characterAttributesEnum = CharacterAttributesEnum.Vigor; characterAttributesEnum < CharacterAttributesEnum.NumCharacterAttributes; characterAttributesEnum++)
     {
         //CharacterAttributeItemVM item = new CharacterAttributeItemVM(this.Hero, characterAttributesEnum, this, new Action<CharacterAttributeItemVM>(this.OnInspectAttribute), new Action<CharacterAttributeItemVM>(this.OnAddAttributePoint));
         //this.Attributes.Add(item);
     }
 }
Beispiel #13
0
 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;
     }
 }
        public static void Postfix(CharacterAttributeItemVM __instance, Hero hero, CharacterAttributesEnum currAtt, CharacterVM developerVM, Action <CharacterAttributeItemVM> onInpectAttribute, Action <CharacterAttributeItemVM> onAddAttributePoint)
        {
            var bonuses = new CharacterAttributeBonuses(hero.CharacterObject);
            var text    = "";

            switch (currAtt)
            {
            case CharacterAttributesEnum.Vigor:
                text += bonuses.MeleeDamageMultiplier > 0
                        ? "Increases melee damage by " + bonuses.MeleeDamageMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.MeleeSpeedMultiplier > 0
                        ? "Increases melee atack speed by " + bonuses.MeleeSpeedMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.PositiveMoraleMultiplier > 0
                        ? "Increases morale gain by " + bonuses.PositiveMoraleMultiplier.ToString("P") + "\n"
                        : "";
                break;

            case CharacterAttributesEnum.Control:
                text += bonuses.RangeDamageMultiplier > 0
                        ? "Increases range damage by " + bonuses.RangeDamageMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.RangeSpeedMultiplier > 0
                        ? "Increases range atack speed by " + bonuses.RangeSpeedMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.NegativeMoraleMultiplier < 0
                        ? "Decrease morale loss by " + (-bonuses.NegativeMoraleMultiplier).ToString("P") + "\n"
                        : "";
                break;

            case CharacterAttributesEnum.Endurance:
                text += bonuses.HPMultiplier > 0
                        ? "Increases HP by " + bonuses.HPMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.MoveSpeedMultiplier > 0
                        ? "Increases move speed by " + bonuses.MoveSpeedMultiplier.ToString("P") + "\n"
                        : "";
                break;

            case CharacterAttributesEnum.Cunning:
                text += bonuses.AttributeEffectMultiplier > 0
                        ? "Increases effect of other attributes by " + (bonuses.AttributeEffectMultiplier - 1).ToString("P") + "\n"
                        : "";
                break;

            case CharacterAttributesEnum.Social:
                text += bonuses.PartySizeMultiplier > 0
                        ? "Increases party size limit by " + bonuses.PartySizeMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.PersuadeAddition > 0
                        ? "Increases persuade chance by " + bonuses.PersuadeAddition.ToString("P") + "\n"
                        : "";
                text += bonuses.RenownMultiplier > 0
                        ? "Increases renown gain by " + bonuses.RenownMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.InfluenceMultiplier > 0
                        ? "Increases influnce gain by " + bonuses.InfluenceMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.RenownAddition > 0
                        ? "Increases renown by " + bonuses.RenownAddition.ToString("F2") + " when you meet somebody at first\n"
                        : "";
                break;

            case CharacterAttributesEnum.Intelligence:
                text += bonuses.XPMultiplier > 0
                        ? "Increases learning rate for all skills by " + bonuses.XPMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.IncomeMultiplier > 0
                        ? "Increases clan income by " + bonuses.IncomeMultiplier.ToString("P") + "\n"
                        : "";
                text += bonuses.ExpensesMultiplier < 0
                        ? "Decrease clan spendings by " + (-bonuses.ExpensesMultiplier).ToString("P") + "\n"
                        : "";
                break;
            }
            __instance.IncreaseHelpText = text + __instance.IncreaseHelpText;
        }
 public void OnAttributeChange(CharacterAttributesEnum attribute, int newValue)
 {
     this.hero.SetAttributeValue(attribute, newValue);
 }
Beispiel #16
0
        public static int GetAttributeValue(int __result, CharacterObject __instance, CharacterAttributesEnum charAttribute)
        {
            var attribute = __result;

            // if following is true, then this attribute is already set by developers/other mods
            if (attribute >= 2)
            {
                return(attribute);
            }
            // we use maximum skill level to determine how big attribute should be
            var maxSkill = CharacterAttributes.GetCharacterAttribute(charAttribute).Skills.Select(skill => __instance.GetSkillValue(skill)).Max();

            // 0 - is minimal for any skill and we consider this amount as 2 for repsective attribute
            // 240 is a soft cap for skill leveling in Mount & Blade, so we consider this amount as 10 for  repsective attribute
            // between them we assume linear growth of attributes
            attribute = 2 + maxSkill / (240 / (10 - 2));

            return((attribute < 10)
                ? attribute
                : 10);
        }
Beispiel #17
0
 private void SetAttribute(TaleWorlds.CampaignSystem.Hero hero, CharacterAttributesEnum attribute, int value)
 {
     hero.SetAttributeValue(attribute, hero.GetAttributeValue(attribute) + value);
 }
Beispiel #18
0
 public static string GetAttributeName(CharacterAttributesEnum val) =>
 val switch
 {