BL Coding Where are the Triggers & Scripts?

Users who are viewing this thread

Computica

Grandmaster Knight
M&BWBWF&S
As I'm playing the game I see that a lot of the code from Native Warband is in the game but when I look through the files across the various folders I see definition info in the XML files; but I'm not seeing any code that references that info. Could someone point me where to look?

EDIT:
I found my answer here: https://github.com/Bannerlord-Modding/Documentation/blob/master/_intro/getting-started.md

We can't do any real modding until those files are exposed.
 
Last edited:

Triarii718

Recruit
Seconded. The documentation is still somewhat barren at the moment. I remember the dev blog talking about campaign vs mission behaviors and I can't wait to get access to those and make my own triggers/scripts.

Health regen, magical portals, reworked perks, etc etc.
 
Upvote 0

Cheyros

Recruit
I had to decompile a mod I will remove the guy's code for his privacy but show you his structure how he adds a new behavior to the game...


Code:
namespace ExampleMod
{
    using System.Collections.Generic;
    using System.Linq;
    using Helpers;
    using TaleWorlds.Core;
    using TaleWorlds.MountAndBlade;
    using TaleWorlds.Localization;
    using TaleWorlds.CampaignSystem;
    using TaleWorlds.CampaignSystem.Actions;

    public class MySubModule : MBSubModuleBase
    {
        protected override void OnGameStart(Game game, IGameStarter gameStarterObject)
        {
            base.OnGameStart(game, gameStarterObject);
            if (game.GameType is Campaign)
            {
                CampaignGameStarter cgs = gameStarterObject as CampaignGameStarter;
                cgs.AddBehavior(new ExampleBehavior() as CampaignBehaviorBase);
            }
        }
    }
    internal class ExampleBehavior : CampaignBehaviorBase
    {
        public override void SyncData(IDataStore dataStore)
        {
        }
        public override void RegisterEvents()
        {
            CampaignEvents.PrisonerTaken.AddNonSerializedListener(this, OnPrisonerTaken);
        }
        private void OnPrisonerTaken(PartyBase captorParty, Hero prisoner)
        {
            EndCaptivityAction.ApplyByDeath(prisoner);
        }
    }
}

The best way to learn if you have nothing is to decompile mods that you download. I use VS Code with the extension for ilspy. In visual studio you will be able to see all the different methods and properties to use by editing the code here.
 
Last edited:
Upvote 0

aderrdei

Recruit
WBNW
If you're desperate to dig into the scripts in the game before Ster's documentation is fleshed out you can decompile the .dll files using something like dotpeek.
 
Upvote 0
Top Bottom