(dll SubMod) Buy/Exchange Renown, Influence, XP; Food (donate town), Horses; Fast menu-craft (refine), Hire/Upgrade Villager-Recruit-Elite

Users who are viewing this thread

Oltopeteeh

Regular
Base .dll mod: MedicalDistrict

Small Change:
Change cost healing 1.000 -> 100 (testing the ability to compile an edited file);

___
Buy Renown
Code:
campaignGameStarter.AddGameMenuOption("town_medical_district", "town_medical_district_buy_renown", "{=*}1 Renown {PRICE_RENOWN}{GOLD_ICON}", new GameMenuOption.OnConditionDelegate(player_buy_renown_on_condition), delegate (MenuCallbackArgs x)
            {
                int price_renown = 100 + Hero.MainHero.Level * Hero.MainHero.Level;
                if (Hero.MainHero.Gold >= price_renown)
                {
                    Hero.MainHero.Clan.AddRenown(1, true);
                    GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, -price_renown, false);
                };
            }, false, -1, false);
and technical addition (hiding the option, if the conditions are not met):
Code:
private bool player_buy_renown_on_condition(MenuCallbackArgs args)
        {
            int price_renown = 100 + Hero.MainHero.Level * Hero.MainHero.Level;
            MBTextManager.SetTextVariable("PRICE_RENOWN", price_renown);
            if (Hero.MainHero.Gold >= price_renown && Hero.MainHero.Gold < price_renown*100 && Hero.MainHero.Clan.Renown < 6150)
            {
                return true;
            };
            return false;
        }

___
Buy Influence
Code:
campaignGameStarter.AddGameMenuOption("town_medical_district", "town_medical_district_buy_influence", "{=*}1 Influence {PRICE_INFLUENCE}{GOLD_ICON}", new GameMenuOption.OnConditionDelegate(player_buy_influence_on_condition), delegate (MenuCallbackArgs x)
            {
                int price_influence = 100 + Hero.MainHero.Level * Hero.MainHero.Level;
                if (Hero.MainHero.Gold >= price_influence)
                {
                    Hero.MainHero.AddInfluenceWithKingdom(1);
                    GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, -price_influence, false);
                };
            }, false, -1, false);
plus technical addition

___
Change Renown over 6150 to Influence
Code:
campaignGameStarter.AddGameMenuOption("town_medical_district", "town_medical_district_swap_influence_all", "{=*}Influence on Renown over 6150", new GameMenuOption.OnConditionDelegate(player_swap_influence_all_on_condition), delegate (MenuCallbackArgs x)
            {
                if (Hero.MainHero.Clan.Renown > 6150)
                {
                    float renown_to_influence = Hero.MainHero.Clan.Renown - 6150;
                    Hero.MainHero.AddInfluenceWithKingdom(renown_to_influence);
                    Hero.MainHero.Clan.Renown -= renown_to_influence;
                };
            }, false, -1, false);

===
Bannerlord.MedicalDistrict_OltoMod.rar (dll only, need to insert with replacement into the original mod):
===

Question: How add item to the player's inventory?
For example, coal (id = "charcoal").
Campaign.Current.MainParty.ItemRoster.Add(new ItemRosterElement(new ItemObject("charcoal"), 1));
This do not work and I don't understand "why" :sad:
 
Last edited:
Try
ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("charcoal"), 1)
It works!)
Thank you very much!)))
Now I can continue working on the modification =)

___
Update mod: 0.2

Additional menu - "Support district" - for buy and exchange crafting materials (wood, coal, iron0-6).

Code example:
Code:
campaignGameStarter.AddGameMenuOption("town_support_district", "town_support_district_buy_coal", "{=*}1 Coal: {PRICE_COAL}{GOLD_ICON}", new GameMenuOption.OnConditionDelegate(player_buy_coal_on_condition), delegate (MenuCallbackArgs x)
            {
                int price_coal = 50;
                if (Hero.MainHero.Gold >= price_coal)
                {
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("charcoal"), 1);
                    GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, -price_coal, false);
                };

Iron Ore, exchange

Code:
campaignGameStarter.AddGameMenuOption("town_support_district", "town_support_district_swap_iron", "{=*}IronOre (Iron2, Iron1): {IRON_AMOUNT}", new GameMenuOption.OnConditionDelegate(player_swap_iron_on_condition), delegate (MenuCallbackArgs x)
            {
                int iron_amount = Campaign.Current.MainParty.ItemRoster.GetItemNumber(Game.Current.ObjectManager.GetObject<ItemObject>("iron"));
                if (iron_amount >= 1)
                {
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot2"), iron_amount);
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), iron_amount);
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("iron"), -iron_amount);
                };
            }, false, -1, false);

Iron Ingot, exchange
(I tried to add "rounding", but it was not necessary XD)

Code:
campaignGameStarter.AddGameMenuOption("town_support_district", "town_support_district_swap_iron2", "{=*}Iron2 on 2 Iron1 x{IRONINGOT1_AMOUNT2}", new GameMenuOption.OnConditionDelegate(player_swap_iron2_on_condition), delegate (MenuCallbackArgs x)
            {
                int ironIngot1_amount = Campaign.Current.MainParty.ItemRoster.GetItemNumber(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"));
                int ironIngot1_amount2 = (int)ironIngot1_amount / 2;
                if (ironIngot1_amount2 >= 1)
                {
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot2"), ironIngot1_amount2);
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), -ironIngot1_amount2 * 2);
                };
            }, false, -1, false);

And test of crafting non-combat items (for example, wheat), with the expenditure of stamina.
Still working for this :smile:

Code:
campaignGameStarter.AddGameMenuOption("town_support_district", "town_support_district_craft_grain", "{=*}TestCraft: Grain 30{GOLD_ICON}", new GameMenuOption.OnConditionDelegate(player_craft_grain_on_condition), delegate (MenuCallbackArgs x)
            {
                if (Hero.MainHero.GetSkillValue(DefaultSkills.Crafting) >= 25 && Hero.MainHero.Gold >= 30)
                {
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("grain"), 1);
                    // stamina -2 (grain 10 money, 1 for 5m)
                    GiveGoldAction.ApplyBetweenCharacters(null, Hero.MainHero, -30, false);
                    Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 1);
                };
            }, false, -1, false);

___
Update:
___

Hire looter
Code:
campaignGameStarter.AddGameMenuOption("town_support_district", "town_support_district_hire_looter", "{=*}Hire: 1 Looter {HIRE_LOOTER}{GOLD_ICON}", new GameMenuOption.OnConditionDelegate(player_hire_looter_on_condition), delegate (MenuCallbackArgs x)
            {
                int hire_looter = 100;
                if (Hero.MainHero.Gold >= hire_looter)
                {
                    Campaign.Current.MainParty.MemberRoster.AddToCounts(Game.Current.ObjectManager.GetObject<CharacterObject>("looter"), 1, false, 0, 0, true, -1);
                    GiveGoldAction.ApplyForSettlementToCharacter(Settlement.CurrentSettlement, Hero.MainHero, -hire_looter, false);
                    Hero.MainHero.AddSkillXp(DefaultSkills.Roguery, 1);
                    GameMenu.SwitchToMenu("town_support_district");
                };
            }, false, -1, false);
 
Last edited:
Craft Armor (with menu):

Example
Code:
campaignGameStarter.AddGameMenuOption("town_support_b_district", "town_support_b_gloves_t6_k", "{=*}(t6, 24) Eastern Plated Leather Vambraces (4 Iron6)", new GameMenuOption.OnConditionDelegate(town_support_b_gloves_t6_on_condition), delegate (MenuCallbackArgs x)
            {
                int ironIngot6_amount = Campaign.Current.MainParty.ItemRoster.GetItemNumber(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot6"));
                if (ironIngot6_amount >= 4 && Hero.MainHero.GetSkillValue(DefaultSkills.Crafting) >= 100 && Settlement.CurrentSettlement.Culture.GetCultureCode() == CultureCode.Khuzait)
                {
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("eastern_plated_leather_vambraces"), 1);
                    Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot6"), -4);
                    Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 128);
                    GameMenu.SwitchToMenu("town_support_b_district");
                };
            }, false, -1, false);

===

The calculation of equipment and real hiring is interesting.

Let's say a peasant weapon. Average price 80-96, blacksmith's hammer contains 2 tier iron, iron pitchfork is too cheap, etc. Not the point. We consider how we can dress the unit ourselves.

Weapon. 4 slots.
Each - a tree for a handle, 2 wood or iron (weakly - one) for a blade, a pommel. Guard, pommel in tier 0 without resources, are designated as "no".

Simpler wooden weapons, 2 + 1 wood, x4. Sum 12. Cheap and cheerful: iron and wood, piece by piece.
Armor, too, for simplicity. 12 more wood. Or 4 + 4 wood and iron.
On additional weapons (3 and 4 slots, gloves, etc., in theory, you can save money, but I count the balance :smile:).

We get an average set of a peasant's set, 8 wood and 8 iron.
Or better yet, a premium set, 24 wood.
Or a complete very bad set, 2 wood and iron for the simplest weapons (one) and one worst armor (rags).

Roughly guessing, buy a tree - 6 coins.

Coal - buy 2 wood (12), spend stamina, get 1-3 coal. On average, 4-6-12 coins each.

Iron - buy ore (11), stamina, 2-3 iron, 4-6 each.

Min set, 20 coins, cool - 24 * 6 = 144 coins.
That is, hiring a peasant, at least 20-30, not 10 coins, as it is now.
And better up to 150-200, if we take the future elite))
 
Mod (test build): https://drive.google.com/file/d/1tdiq8jY1If2pxkDCr9liXx7atjZZq3v0/view?usp=sharing
Studio (source code): https://drive.google.com/file/d/1Km8g4QyQqhePtfg3O56Td_wyWRahskev/view?usp=sharing

____
smelt_armor
____

Code:
            campaignGameStarter.AddGameMenuOption("support_3", "support_smelt_armor_t1", "{=*}Smelt T1 Armor x{AMOUNT}", new GameMenuOption.OnConditionDelegate(support_smelt_armor1_on_condition), delegate (MenuCallbackArgs x)
            {
                var vlandia_bandit_c_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "vlandia_bandit_c"); //1-1
                var bandit_envelope_dress_v2_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "bandit_envelope_dress_v2"); //2-1-1
                var bandit_leather_water_flask_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "bandit_leather_water_flask"); //3-2-2
                var bandit_envelope_dress_v1_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "bandit_envelope_dress_v1"); //4-2-2
                var torn_bandit_clothes_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "torn_bandit_clothes"); // 6-2-1 (x2)
                var bandit_gambeson_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "bandit_gambeson"); // 14-7-3 (x4)

                int armor_body_amount = vlandia_bandit_c_item.Amount + bandit_envelope_dress_v2_item.Amount + bandit_leather_water_flask_item.Amount + bandit_envelope_dress_v1_item.Amount + torn_bandit_clothes_item.Amount + bandit_gambeson_item.Amount;

                var pilgrim_hood_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "pilgrim_hood"); //h 4
                var wrapped_headcloth_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "wrapped_headcloth"); //h 6

                int armor_head_amount = pilgrim_hood_item.Amount + wrapped_headcloth_item.Amount;

                var leather_shoes_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "leather_shoes"); //l 3
                var wrapped_shoes_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "wrapped_shoes"); //l 4
                var strapped_shoes_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "strapped_shoes");

                int armor_leg_amount = leather_shoes_item.Amount + wrapped_shoes_item.Amount + strapped_shoes_item.Amount;

                var ragged_armwraps_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "ragged_armwraps"); //g 3
                var armwraps_item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "armwraps"); //g 3

                int armor_arm_amount = ragged_armwraps_item.Amount + armwraps_item.Amount;

                int smelt_armor_amount = armor_arm_amount + armor_leg_amount + armor_head_amount + armor_body_amount;
                if (smelt_armor_amount >= 1)
                {
                    if (bandit_envelope_dress_v1_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), bandit_envelope_dress_v1_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(bandit_envelope_dress_v1_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (bandit_envelope_dress_v2_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), bandit_envelope_dress_v2_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(bandit_envelope_dress_v2_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (vlandia_bandit_c_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), vlandia_bandit_c_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(vlandia_bandit_c_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (bandit_leather_water_flask_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), bandit_leather_water_flask_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(bandit_leather_water_flask_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (torn_bandit_clothes_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), torn_bandit_clothes_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(torn_bandit_clothes_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (bandit_gambeson_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), 4 * bandit_gambeson_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(bandit_gambeson_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, (4 * 17) / 16);
                    };
                    //
                    if (pilgrim_hood_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), pilgrim_hood_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(pilgrim_hood_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (wrapped_headcloth_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), wrapped_headcloth_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(wrapped_headcloth_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    //
                    if (wrapped_shoes_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), wrapped_shoes_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(wrapped_shoes_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (leather_shoes_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), leather_shoes_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(leather_shoes_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    //
                    if (ragged_armwraps_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), ragged_armwraps_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(ragged_armwraps_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };
                    if (armwraps_item.Amount >= 1)
                    {
                        Campaign.Current.MainParty.ItemRoster.AddToCounts(Game.Current.ObjectManager.GetObject<ItemObject>("ironIngot1"), armwraps_item.Amount);
                        Campaign.Current.MainParty.ItemRoster.Remove(armwraps_item);
                        Hero.MainHero.AddSkillXp(DefaultSkills.Crafting, 17 / 16);
                    };

                };
                GameMenu.SwitchToMenu("support_3");
            }, false, -1, false);

====
I collected the mod at the request of the user, and decided at the same time to transfer some useful developments to the general theme of the mod :smile:

"var item = Campaign.Current.MainParty.ItemRoster.FirstOrDefault(z => z.EquipmentElement.Item.StringId == "y");"
"item.Amount"

thanks for @Snah1979 ( https://forums.taleworlds.com/index.php?members/snah1979.475905/ )
 
Test for editing the prices of things and units, 4 options.

* Bannerlord.OltoModH_ItemCost_us_only_test.rar (need Harmony, unstable, only for fast look/test)

TW uses exponentiation. OK. We use price root extraction :smile:
The advantage of the mod is that in the game you can see the prices as they would be if the equipment was purchased by units, and not by heroes.

* Bannerlord.OltoMod_ItemCost_reduce_pow.rar


TW lowered the base for exponentiation from 3 (2.95) to 2.75 in the e1.7 patch, which had a very beneficial effect on the balance of prices and values in the game.
I decided to continue the policy to its logical end - I put the base 2, because. in the game, the rule is x2 for each next shooting range (with some exceptions), and not x2.75-x3. Works stably.

* Bannerlord.OltoMod_UnitCost_Fix.rar


Fixed recruitment price (recruits 20-25, cavalry x2 instead of +150 or +500 to the price, and also mercenaries or bandits x1.25-1.5, but this is of little use). Specially customized for vanilla (original) price

* Bannerlord.OltoMod_UnitCost_t1m_x2cost.rar

Units, upkeep fix (for rule x2, instead of now x1.5, which is why high tiers are exceptionally cheap in upkeep compared to their power... or recruits basically don't pay back their fee... depending on how you look at the outrage that is happening) .
The recruitment price has also been fixed (x2 from the standard), which is close to the formula that is clearly spelled out in the code, but has not been used for a long time.
There, a peasant is 1 coin, a recruit is 40, an elite is 100, etc. The higher, the weaker the markup (plus the annoying exception at the beginning).
So x2 prices, from now, surprisingly canonical, TW-friendly =)

Added horse recruits and looters, for testing, with the ability to rush/supply horses for a fee, in a separate menu item.
Plus, I tightened up the recruitment menu, from peasants to the elite of tier 6, inclusive, and removed the clan tier requirement for hiring, so that the test turned out to be the most comprehensive. According to the main idea, tier-1, i.e. 6 (max) clan tier allows you to hire tier 7 (technical max) without restrictions.

Well, every little thing...
 
Back
Top Bottom