Mount & Blade II: Bannerlord
0 of 0

File information

Last updated

Original upload

Created by

Oltopeteeh

Uploaded by

Oltopeteeh

Virus scan

Safe to use

About this mod

Donate all type items for XP (not only weapons / armor). Cost of item = XP (instead 35-300xp). Donation perks double XP. Add Settings (mod*xp, max.xp). Work with v1.03-1.1.0b.

Permissions and credits
Changelogs
Return lost type of items for Discard XP (not only weapons and armor).

Return base cost (.Value) = XP (instead of 35xp for tier 0 - 300 for tier 3-6).
TW added this... stub in a late patch, although they could fix the gear value formula and don't suffer.


Donation perks double the experience bonus (instead of limiting the ability to donate).


====
v1.1 (custom)
====

-- Add settings (file settings.xml, in mod folder):

  • mod for xp (default: value x1.0).
  • max xp (default: 100k). Note: border is not rigid, but very noticeable, because the formula for extracting the root ("MathF.Sqrt") from a value that exceeds the allowed maximum works).

Note: 1 dinar (selfcost) = 20 XP.
Its mean, If item cost 10d and give 200 xp, this normally.

Example: Elite (50d) = Recruit (20d) + upgrade (15d) + 300 xp (15d).

-- Add min xp (for weapon and armor, as vanila).
Formula = 37.5f * Pow(2, tierF).
Note: Using "TierF" (float, min "-1.5", max "7.5") allows get more flexible cost than "Tier" (int, 0-6).
If tier <=0: xp 37 (~vanila), t1=75, t2=150, t3=300, t4=600, etc.
Sequence of numbers does not break as in the original fast patch for donate XP.


____
Sourse code (v1.1):

Spoiler:  
Show
namespace OltoMod_Discard
{
    public class OltoMod_Discard_SubModule : MBSubModuleBase
    {
        public static float discard_xp_mod;
        public static int discard_max;
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            base.OnGameStart(game, gameStarterObject);
            gameStarterObject.AddModel((GameModel)new OltoItemDiscardModel());
        }
        protected override void OnSubModuleLoad()
        {
            base.OnSubModuleLoad();
            this.loadSettings();
        }
        private void loadSettings()
        {
            Settings settings = new XmlSerializer(typeof(Settings)).Deserialize((Stream)File.OpenRead(Path.Combine(BasePath.Name, "Modules/OltoMod_Discard/settings.xml"))) as Settings;
            OltoMod_Discard_SubModule.discard_xp_mod = settings.discard_xp_mod;
            OltoMod_Discard_SubModule.discard_max = settings.discard_max;
        }
    }
    [Serializable]
    public class Settings
    {
        public float discard_xp_mod;
        public int discard_max;
    }
   
    internal class OltoItemDiscardModel : DefaultItemDiscardModel
    {
        public override bool PlayerCanDonateItem(ItemObject item) { return true; }
        public override int GetXpBonusForDiscardingItem(ItemObject item, int amount = 1)
        {
            int num = 0;
            float num1 = item.Value * OltoMod_Discard_SubModule.discard_xp_mod;
            float num2 = 0;
            if (item.HasWeaponComponent && MobileParty.MainParty.HasPerk(DefaultPerks.Steward.GivingHands)) num1 *= 2;
            else if (item.HasArmorComponent && MobileParty.MainParty.HasPerk(DefaultPerks.Steward.PaidInPromise, checkSecondaryRole: true)) num1 *= 2;
            if (item.HasWeaponComponent || item.HasArmorComponent)
                if (item.Tierf >= 0) num2 = 37.5f * MathF.Pow(2, item.Tierf);
                else { num2 = 37; };
            num = (int)MathF.Round(MathF.Max(num1, num2));
            if (num > OltoMod_Discard_SubModule.discard_max) num = (int)(OltoMod_Discard_SubModule.discard_max + MathF.Sqrt(num - OltoMod_Discard_SubModule.discard_max));
            return num * amount;
        }
    }
}


Note: thanks HP from Level for simple add settings solution :)


____
Old version:
Spoiler:  
Show

====
v1 (basic)
====

Differences in versions of mod (1.7.2 and 1.7.0) lie in method of conversion ("using"), not pure code of mod (thanks TW for this).

(both version)


using TaleWorlds.Core;
using TaleWorlds.MountAndBlade;


(170)

using TaleWorlds.CampaignSystem; // 170
using TaleWorlds.CampaignSystem.SandBox.GameComponents; // 170


(172)

using TaleWorlds.CampaignSystem.CharacterDevelopment; // 172 // Discard XP 
using TaleWorlds.CampaignSystem.Party; // 172
using TaleWorlds.CampaignSystem.GameComponents; // 172



____
Small source code (version 1.0):

        public override bool PlayerCanDonateItem(ItemObject item) { return true; }
       
        public override int GetXpBonusForDiscardingItem(ItemObject item, int amount = 1) {
            int num = item.Value;
            if (item.HasWeaponComponent && MobileParty.MainParty.HasPerk(DefaultPerks.Steward.GivingHands)) num *= 2;
            else if (item.HasArmorComponent && MobileParty.MainParty.HasPerk(DefaultPerks.Steward.PaidInPromise, checkSecondaryRole: true)) num *= 2;
            return num * amount; }


____
Vanila code:

Spoiler:  
Show
        public override bool PlayerCanDonateItem(ItemObject item)
        {
            bool result = false;
            if (item.HasWeaponComponent)
            {
                result = MobileParty.MainParty.HasPerk(DefaultPerks.Steward.GivingHands);
            }
            else if (item.HasArmorComponent)
            {
                result = MobileParty.MainParty.HasPerk(DefaultPerks.Steward.PaidInPromise, checkSecondaryRole: true);
            }
            return result;
        }
        public override int GetXpBonusForDiscardingItem(ItemObject item, int amount = 1)
        {
            int num = 0;
            if (PlayerCanDonateItem(item))
            {
                switch (item.Tier)
                {
                    case ItemObject.ItemTiers.Tier1:
                        num = 75;
                        break;
                    case ItemObject.ItemTiers.Tier2:
                        num = 150;
                        break;
                    case ItemObject.ItemTiers.Tier3:
                        num = 250;
                        break;
                    case ItemObject.ItemTiers.Tier4:
                    case ItemObject.ItemTiers.Tier5:
                    case ItemObject.ItemTiers.Tier6:
                        num = 300;
                        break;
                    default:
                        num = 35;
                        break;
                }
            }
            return num * amount;
        }


Note: if add more logic for this plug, tier 0 = 37 (vs 35), tier 1 and 2 = ok, 3 = 300 (vs 250), 4 = 600, 5 = 1200, 6 = 2400 (vs 300), 7 = 4800 (because clamp formula in tierF may contain max 7.5f, not only 6).

____



====
Install mod (standart)
Unpack archive in module. Enable in launcher. Play =)