Bandit/looter party speed

Users who are viewing this thread

Butterfan

Recruit
Hello all, i'm looking for some help. I modded my bandits and other evildoers to have larger parties with the added consequence that because of their size they move extremely slow. I'm trying to speed them up but I cannot figure out how to program it in using C# and a limited amount of time. I figured that the place to be is TaleWorlds.CampaignSystem.SandBox.GameComponents.Map.DefaultPartySpeedCalculatingModel but I don't know where to go from here.

This could be a cool practice exercise for a beginning programmer or a quick modding fix for a pro. Is anyone willing to help?
 
You'll need to create a custom party speed calculating model that derives from the DefaultPartySpeedCalculatingModel. Something like that should work.

C#:
using TaleWorlds.Localization;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents.Map;

public class CustomPartySpeedCalculatingModel : DefaultPartySpeedCalculatingModel
    {
        public override ExplainedNumber CalculateFinalSpeed(MobileParty mobileParty, ExplainedNumber finalSpeed)
        {
            if (mobileParty.IsBandit)
            {
                finalSpeed.Add(3f, new TextObject("{=*}Increased Bandit Speed"));
            }


            return finalSpeed;
        }
    }

Then add this model to the CampaignGameStarter object on your MBSubModuleBase.

C#:
protected override void OnGameStart(Game game, IGameStarter gameStarter)
        {
            if (game.GameType is Campaign campaign)
            {
                CampaignGameStarter campaignStarter = (CampaignGameStarter)gameStarter;
                campaignStarter.AddModel(new CustomPartySpeedCalculatingModel());
            }
        }
 
Upvote 1
You'll need to create a custom party speed calculating model that derives from the DefaultPartySpeedCalculatingModel. Something like that should work.

C#:
using TaleWorlds.Localization;
using TaleWorlds.CampaignSystem;
using TaleWorlds.CampaignSystem.SandBox.GameComponents.Map;

public class CustomPartySpeedCalculatingModel : DefaultPartySpeedCalculatingModel
    {
        public override ExplainedNumber CalculateFinalSpeed(MobileParty mobileParty, ExplainedNumber finalSpeed)
        {
            if (mobileParty.IsBandit)
            {
                finalSpeed.Add(3f, new TextObject("{=*}Increased Bandit Speed"));
            }


            return finalSpeed;
        }
    }

Then add this model to the CampaignGameStarter object on your MBSubModuleBase.

C#:
protected override void OnGameStart(Game game, IGameStarter gameStarter)
        {
            if (game.GameType is Campaign campaign)
            {
                CampaignGameStarter campaignStarter = (CampaignGameStarter)gameStarter;
                campaignStarter.AddModel(new CustomPartySpeedCalculatingModel());
            }
        }
Thanks for your reply, i'll try it out soon!
 
Upvote 0
Back
Top Bottom