I want to edit something that's inside the SandBox dll, but I can't recompile?

Users who are viewing this thread

RagerSigma

Recruit
I'm currently trying to edit LordConversationsCampaignBehavior.cs, I'm very new to modding within Bannerlord but have some decent experience in general. I'm currently stuck on finding a way to have my changes apply to the game code. My original intention was to decompile the dll, edit the specific file, and then recompile the .dll, but I had major issues with compiling & it's definitely not a good idea for me to replace the entire sandbox .dll,

So instead I decided to take the specific .cs file, move it to my own mod, and edit it there, I added all references and I have the correct version of .net, but I'm left with major errors inside of the file, so it makes it impossible to build it. Does anyone have suggestions or can anyone possibly link the process in doing this? Editing specific game files rather than creating a mod from scratch?
 
Check out my repository.

It shows you how to add a new CampaignBehavior to add new dialog.

However, if you want to change existing dialog, you'll have to use Harmony transpilers.
Specifically I'm trying to change the 40% party limit requirement to join an army. I've found the specific code already which is inside Sandbox LordConversationCampaignBehavior.cs.

This falls under changing existing stuff so I'm presuming Harmony transpilers are the way to go, any chance you can send me in the right direction?

QUjeYSJ.png
 
Upvote 0
I haven't gotten a chance to try this out but after decompiling a bunch of other mods and looking into harmony I was able to come up with this, I think it does what I need it to so I'll leave it here for anyone who needs the help.


C#:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using HarmonyLib;
using TaleWorlds.CampaignSystem;


namespace ModTest
{
    public class Main
    {
        [HarmonyPatch(typeof(ArmyManagementCalculationModel), "GetPartySizeScore")]
        public class Patch
        {
            static bool Postfix(ref float __result)
            {
                __result = 0;
                return true;
            }
        }
    }
}
 
Upvote 0
Back
Top Bottom