Kimmaz
Recruit
Hello, I want to try and make a mod for Bannerlord and learn the basics of C# along the way. I have downloaded Windows Visual Studio Community as per w3schools suggestion, and I used a free program "dotpeek" to look inside the .dll files of the game. So far I don't understand that much of the code but I can see the patterns. So far I have copied a few codes and saved them so I can look at them later.
I first want to make a simple mod, that I probably won't use. Here is the plan: I want to alter or add to the code for desertion so that there is a new way that causes soldiers to leave the party in addition to the ways the game intends, not instead of them. So far I have a submodule file, and I start editing in Visual Studio.
Am I on to something, does this make sense to you so far? It's not finished. How much of the game file's code do I need to repeat? does it gather stuff from the original or do I need to put everything in my file?
I first want to make a simple mod, that I probably won't use. Here is the plan: I want to alter or add to the code for desertion so that there is a new way that causes soldiers to leave the party in addition to the ways the game intends, not instead of them. So far I have a submodule file, and I start editing in Visual Studio.
Am I on to something, does this make sense to you so far? It's not finished. How much of the game file's code do I need to repeat? does it gather stuff from the original or do I need to put everything in my file?
C#:
using Helpers;
using Helpers;
using SandBox;
using System;
using System.IO;
using System.Reflection;
using TaleWorlds.CampaignSystem;
using TaleWorlds.Core;
using TaleWorlds.Engine;
using TaleWorlds.Engine.Screens;
using TaleWorlds.InputSystem;
using TaleWorlds.MountAndBlade;
namespace DeadlyHorses
{
public void DailyTickParty(MobileParty mobileParty)
{
if (!Campaign.Current.DesertionEnabled || !mobileParty.IsActive || (mobileParty.IsDisbanding || mobileParty.Party.MapEvent != null) || !mobileParty.IsLordParty && (!mobileParty.IsGarrison || mobileParty.CurrentSettlement == null) && !mobileParty.IsCaravan)
return;
TroopRoster desertedTroopList = (TroopRoster) null;
if (mobileParty.IsLordParty || mobileParty.IsCaravan)
this.PartiesCheckDesertionDueToDeadlyHorses(mobileParty, ref desertedTroopList);
if (desertedTroopList != (TroopRoster) null && desertedTroopList.Count > 0)
CampaignEventDispatcher.Instance.OnTroopsDeserted(mobileParty, desertedTroopList);
if (mobileParty.Party.NumberOfAllMembers > 0)
return;
mobileParty.RemoveParty();
}
}
public bool PartiesCheckDesertionDueToHorses(
MobileParty mobileParty,
ref TroopRoster desertedTroopList)
{
int MenWithHorse = CampaignSystem.Track.NumberOfMenWithHorse
int PackAnimals = CampaignSystem.Track.NumberOfPackAnimals
if (mobileParty.Party.MenWithHorse <= mobileParty.Party.PackAnimals)
{
++this._numberOfDesertersFromLordParty;
flag = true;
}
return flag;
}
}
}
}
Last edited: