How to edit perks and leveling?

Users who are viewing this thread

Kauyon

Recruit
Hello, new user here:

How do I edit what perks do? Can't find it in the code. Also, is there a way to edit how many perk points I need to gain for each level? Thanks.
 
Solution
is there a way to edit how many perk points I need to gain for each level?
Found it within TaleWorlds.CampaignSystem.SandBox.GameComponents.DefaultCharacterDevelopmentModel;
C#:
        // Token: 0x06001DF8 RID: 7672 RVA: 0x000730D5 File Offset: 0x000712D5
        // Note: this type is marked as 'beforefieldinit'.
        static DefaultCharacterDevelopmentModel()
        {
        }

        // Token: 0x04000BD1 RID: 3025
        private const int MaxCharacterLevels = 100;

        // Token: 0x04000BD2 RID: 3026
        private const int MaxAttributeLevel = 11;

        // Token: 0x04000BD3 RID: 3027
        private const int SkillPointsAtLevel1 = 120;

        // Token: 0x04000BD4 RID: 3028
        private const int...
You can edit perks within TaleWorlds.CampaignSystem.DefaultPerks, for example Edge Placement I;
C#:
            this.OneHandedEdgePlacement.Initialize("{=Stk3PbV4}Edge Placement I", "{=69cxRmEr}One handed damage increased by 4%.", DefaultSkills.OneHanded, this.GetTierCost(1), this.OneHandedExtraHP, SkillEffect.PerkRole.Personal, 0.04f, SkillEffect.PerkRole.None, 0f, SkillEffect.EffectIncrementType.AddFactor);
Here you can change the float from 0.04f(4%) increased damage to whatever you want. Haven't come across code for perk points per level.
 
Upvote 0
is there a way to edit how many perk points I need to gain for each level?
Found it within TaleWorlds.CampaignSystem.SandBox.GameComponents.DefaultCharacterDevelopmentModel;
C#:
        // Token: 0x06001DF8 RID: 7672 RVA: 0x000730D5 File Offset: 0x000712D5
        // Note: this type is marked as 'beforefieldinit'.
        static DefaultCharacterDevelopmentModel()
        {
        }

        // Token: 0x04000BD1 RID: 3025
        private const int MaxCharacterLevels = 100;

        // Token: 0x04000BD2 RID: 3026
        private const int MaxAttributeLevel = 11;

        // Token: 0x04000BD3 RID: 3027
        private const int SkillPointsAtLevel1 = 120;

        // Token: 0x04000BD4 RID: 3028
        private const int SkillPointsGainNeededInitialValue = 10;

        // Token: 0x04000BD5 RID: 3029
        private const int SkillPointsGainNeededIncreasePerLevel = 5;

        // Token: 0x04000BD6 RID: 3030
        private readonly int[] _skillsRequiredForLevel = new int[100];

        // Token: 0x04000BD7 RID: 3031
        private const int _focusPointsPerLevelConst = 1;

        // Token: 0x04000BD8 RID: 3032
        private const int LevelsPerAttributePointConst = 4;

        // Token: 0x04000BD9 RID: 3033
        private const int FocusPointCostToOpenSkillConst = 0;

        // Token: 0x04000BDA RID: 3034
        private const int FocusPointsAtStartConst = 5;

        // Token: 0x04000BDB RID: 3035
        private const int AttributePointsAtStartConst = 15;

        // Token: 0x04000BDC RID: 3036
        private const int MaxSkillLevels = 1024;

        // Token: 0x04000BDD RID: 3037
        private readonly int[] _xpRequiredForSkillLevel = new int[1024];

        // Token: 0x04000BDE RID: 3038
        private const int XpRequirementForFirstLevel = 30;

        // Token: 0x04000BDF RID: 3039
        private const int traitThreshold1 = 1000;

        // Token: 0x04000BE0 RID: 3040
        private const int traitThreshold2 = 4000;

        // Token: 0x04000BE1 RID: 3041
        private const int traitMaxValue1 = 2500;

        // Token: 0x04000BE2 RID: 3042
        private const int traitMaxValue2 = 6000;

        // Token: 0x04000BE3 RID: 3043
        private static TextObject _attributeText = new TextObject("{=AT6v10NK}Attribute", null);

        // Token: 0x04000BE4 RID: 3044
        private static TextObject _skillFocusText = new TextObject("{=MRktqZwu}Skill Focus", null);

        // Token: 0x04000BE5 RID: 3045
        private static TextObject _overLimitText = new TextObject("{=bcA7ZuyO}Learning Limit Exceeded", null);
    }
}
Above code has all sorts of goodies ie, max character level, max skills, max attributes, skill points per level, focus points per level and much more.

A tip when searching through the code is to try a very broad search like "points", although a hundred results will come up try to pick something closer from the list like "FocusPoint". Keep using more specific searches until you find what your looking for.
 
Upvote 0
Solution
@IronheadHasan

Follow that tutorial step by step by step.

You will have access to all the classes exposed by TaleWorlds when you import all those DLLs, however, there seems to be a lot missing still. The community is currently trying to leverage Harmony in the meanwhile.

Without using Harmony the *only* thing I can figure out how to do is to re-Initialize the DefaultPerks in the game. But for instance, let's say you wanted to create a perk like I'm working for atheletics, "You can now sprint for up to 5 seconds. Hold Q to run up to 50% faster."

To implement a totally custom perk like this, you would need to re-Initialize an existing perk:

OneHandedEdgePlacement.Initialize("{=Stk3PbV4}Sprinting ", "{=69cxRmEr}You can now sprint for up to 5 seconds. Hold Q to run up to 50% faster.", DefaultSkills.OneHanded, 25, this.OneHandedExtraHP, SkillEffect.PerkRole.Personal, 0.00f, SkillEffect.PerkRole.None, 0f, SkillEffect.EffectIncrementType.Add);

Basically, I've made EdgePlacement do *nothing*.

And then, you'd need to register some kind of a hook like this:

OnGameStart(Game inGame, IGameStarter inGameStarter) {
base.OnGameStart(inGame, inGameStarter);
CampaignGameStarter campaignGameStarter = (CampaignGameStarter)inGameStarter;
campaignGameStarter.AddBehavior(new SprintFunctionality());
}


internal class SprintFunctionality : CampaignBehaviorBase {
public override void RegisterEvents()
{
CampaignEvents.BattleStarted.AddNonSerializedListener(this, BattleEntered);
CampaignEvents.OnPlayerBattleEndEvent.AddNonSerializedListener(this, BattleEnded);
}
}

The idea being, when you enter the battlefield, "turn on sprint" and when you leave the battlefield, "disable" sprint. And I was thinking, maybe you could have a simple If condition to see if the player has learned Edge Placement I, before allowing sprint. And I was thinking, you could allow sprint to work via:

CampaignEvents.TickEvent.AddNonSerializedListener(this, Sprint);

Where Sprint is a function that on frame-tick adds speed to the player character and drains a UI bar.

But all of this is theory, I haven't been able to accomplish any of this because A) there's no apparent way to make the main character move faster via code B) the TickEvent doesn't work like I think it does C) drawing UI isn't known yet

So a lot of stuff just isn't possible *unless* you go the Harmony route. At best, via the DLLs alone, you could just 'buff' the existing perks by doubling their effect numbers, instead of outright replacing them.

But imagine you wanted to do a Perk that was like "+25% slashing damage with one-handed weapons" even something this simple is not clear to me, either.

*And then* consider the fact non-main characters can learn these perks, too. I am sure this adds even more complexity. For instance, what if you want AI characters to be able to Sprint? Or, what if you want an AI character and a player character to be able to sprint simultaneously?

Outside of very simple tweaks, I would argue perks are not in a state to be modified yet, because we will need a full and total understanding of how to code all this without creating tremendous complexity.
 
Last edited:
Upvote 0
You'll need a decompiler to see the code directly. I personally use dnSpy.

The best practice, for update compatibility and modularity sake, is to create a separate dll that will overwrite the system you want modified in the load order.

But, if you don't know how to do that, or just want to mess around quickly, easiest practice is to use dnSpy to open the .dll and edit the file directly.
 
Upvote 0
Decompiling the code is all well and good, but we should be making our mods using some sort of event-driven framework provided by TW, because they are going to be continuously updating the game and that will break all of our mods when functions disappear or are changed, etc. in updates.

It's a shame they did not use a wholly 100% abstracted interface-driven+IoC/DI+Event driven architecture for this game, because if they had, we could be building mods for code which would 'never change' but still give them plenty of flexibility for development and extension.
 
Upvote 0
wow I didn't expect a reply like this! I appreciate it. Will watch that video asap. I downloaded jetbrains dotpeek earlier and then exported that to Visual studio, edited the file in visual studio, but now I have no clue how to put it back into a Dll lol and i've been stuck ever since.
 
Upvote 0
You'll need a decompiler to see the code directly. I personally use dnSpy.

The best practice, for update compatibility and modularity sake, is to create a separate dll that will overwrite the system you want modified in the load order.

But, if you don't know how to do that, or just want to mess around quickly, easiest practice is to use dnSpy to open the .dll and edit the file directly.
So I downloaded dnspy and edited the perk I wanted to. Used change il and edited bow aim faster from 10% to 100% for ****s and giggles. I saved the module and to see if anything changed I looked at the file through dotpeek and it still shows 10%. Did I edit the line wrong?
 
Upvote 0
So I downloaded dnspy and edited the perk I wanted to. Used change il and edited bow aim faster from 10% to 100% for ****s and giggles. I saved the module and to see if anything changed I looked at the file through dotpeek and it still shows 10%. Did I edit the line wrong?
well I tried to compile and i am getting c0234 errors up the wazoo
 
Upvote 0
well I tried to compile and i am getting c0234 errors up the wazoo
sorry to keep posting here but I think it is working, I thought that faster aim mod increased the reload speed of bows, but what it does is pull the bow back quickly. That's what I think at least, now I need to figure out how to make a reload bow faster mod haha.
edit: I lied, it's not working. It shows up in the skills that is has been changed but it's not actually working. I changed the dexterous skill to be 200% and it didn't make a difference.
 
Last edited:
Upvote 0
@IronheadHasan

Follow that tutorial step by step by step.

You will have access to all the classes exposed by TaleWorlds when you import all those DLLs, however, there seems to be a lot missing still. The community is currently trying to leverage Harmony in the meanwhile.

Without using Harmony the *only* thing I can figure out how to do is to re-Initialize the DefaultPerks in the game. But for instance, let's say you wanted to create a perk like I'm working for atheletics, "You can now sprint for up to 5 seconds. Hold Q to run up to 50% faster."

To implement a totally custom perk like this, you would need to re-Initialize an existing perk:

OneHandedEdgePlacement.Initialize("{=Stk3PbV4}Sprinting ", "{=69cxRmEr}You can now sprint for up to 5 seconds. Hold Q to run up to 50% faster.", DefaultSkills.OneHanded, 25, this.OneHandedExtraHP, SkillEffect.PerkRole.Personal, 0.00f, SkillEffect.PerkRole.None, 0f, SkillEffect.EffectIncrementType.Add);

Basically, I've made EdgePlacement do *nothing*.

And then, you'd need to register some kind of a hook like this:

OnGameStart(Game inGame, IGameStarter inGameStarter) {
base.OnGameStart(inGame, inGameStarter);
CampaignGameStarter campaignGameStarter = (CampaignGameStarter)inGameStarter;
campaignGameStarter.AddBehavior(new SprintFunctionality());
}


internal class SprintFunctionality : CampaignBehaviorBase {
public override void RegisterEvents()
{
CampaignEvents.BattleStarted.AddNonSerializedListener(this, BattleEntered);
CampaignEvents.OnPlayerBattleEndEvent.AddNonSerializedListener(this, BattleEnded);
}
}

The idea being, when you enter the battlefield, "turn on sprint" and when you leave the battlefield, "disable" sprint. And I was thinking, maybe you could have a simple If condition to see if the player has learned Edge Placement I, before allowing sprint. And I was thinking, you could allow sprint to work via:

CampaignEvents.TickEvent.AddNonSerializedListener(this, Sprint);

Where Sprint is a function that on frame-tick adds speed to the player character and drains a UI bar.

But all of this is theory, I haven't been able to accomplish any of this because A) there's no apparent way to make the main character move faster via code B) the TickEvent doesn't work like I think it does C) drawing UI isn't known yet

So a lot of stuff just isn't possible *unless* you go the Harmony route. At best, via the DLLs alone, you could just 'buff' the existing perks by doubling their effect numbers, instead of outright replacing them.

But imagine you wanted to do a Perk that was like "+25% slashing damage with one-handed weapons" even something this simple is not clear to me, either.

*And then* consider the fact non-main characters can learn these perks, too. I am sure this adds even more complexity. For instance, what if you want AI characters to be able to Sprint? Or, what if you want an AI character and a player character to be able to sprint simultaneously?

Outside of very simple tweaks, I would argue perks are not in a state to be modified yet, because we will need a full and total understanding of how to code all this without creating tremendous complexity.

I went in and edited the perks faster aim and dexterous to be like 200% and it made no difference. The interface shows the numbers but nothing is actually working. Maybe the percentages are too high? Ill look at harmony as well. This is my first time even opening visual studios so that's how new I am haha.
 
Upvote 0
If the tooltip description changed, but you didn't actually see a change in behavior, it could just be the perk itself is bugged and since many of the perks right now are doing small incremental changes like 3% or 8%, it's honestly hard to know if they actually work in the base-game.
 
Upvote 0
If the tooltip description changed, but you didn't actually see a change in behavior, it could just be the perk itself is bugged and since many of the perks right now are doing small incremental changes like 3% or 8%, it's honestly hard to know if they actually work in the base-game.
i'm going to have to try doing small increases. Because I absolutely hate how slow reloading is for bows, I have edited the animation_combat.XML file to make it faster, the only bad thing is that it affects everyone.
 
Upvote 0
Back
Top Bottom