SP Tutorial Module System How to increase party sizes for lords and players.

Users who are viewing this thread

Nord Champion

Grandmaster Knight
Hello modding community, I hope this help you out.

Ok, so easiest thing first, go to module_scripts.

We are going to change the maximum party size for AI Lords.

Search for: party_get_ideal_size

You'll find this code:
  ("party_get_ideal_size",
    [
      (store_script_param_1, ":party_no"),
      (assign, ":limit", 30),
      (try_begin),
        (party_slot_eq, ":party_no", slot_party_type, spt_kingdom_hero_party),
        (party_stack_get_troop_id, ":party_leader", ":party_no", 0),
        (store_faction_of_party, ":faction_id", ":party_no"),
        (assign, ":limit", 10),

        (store_skill_level, ":skill", "skl_leadership", ":party_leader"),
        (store_attribute_level, ":charisma", ":party_leader", ca_charisma),
        (val_mul, ":skill", 5),
        (val_add, ":limit", ":skill"),
        (val_add, ":limit", ":charisma"),

        (troop_get_slot, ":troop_renown", ":party_leader", slot_troop_renown),
        (store_div, ":renown_bonus", ":troop_renown", 25),
        (val_add, ":limit", ":renown_bonus"),

        (try_begin),
          (faction_slot_eq, ":faction_id", slot_faction_leader, ":party_leader"),
          (val_add, ":limit", 100),
        (try_end),

        (try_begin),
          (faction_slot_eq, ":faction_id", slot_faction_marshall, ":party_leader"),
          (val_add, ":limit", 20),
        (try_end),       

        (try_for_range, ":cur_center", castles_begin, castles_end),
          (party_slot_eq, ":cur_center", slot_town_lord, ":party_leader"),
          (val_add, ":limit", 20),
        (try_end),       
      (try_end),
           
      (store_character_level, ":level", "trp_player"), #increase limits a little bit as the game progresses.
      (store_add, ":level_factor", 80, ":level"),
      (val_mul, ":limit", ":level_factor"),
      (val_div, ":limit", 80),
      (assign, reg0, ":limit"),
  ]),

Lets look at this.
The blue number is the base troop size.
The red number is how many troops are added for every 1 point of the "leadership skill" category.
The purple number is how much renown it takes to increase the troop size by 1.
The green number is the troop bonus to kings.
The orange number is the troop bonus to the marshal.
The yellow number is the troop bonus lords get for owning a castle or town.
The teal number is the "final divider for AI lord maximum party size.

Ok, the easiest way to increase the maximum party size of every AI character is to edit the teal number. If you want to double the maximum party size, you change the teal number to 40. The lower you go, the higher the maximum party size.

Everything else is straight forward, increase the number of any of the colored numbers, except for teal, then that will increase what ever it does.

Ok, now remain in module_scripts.

We are going to change the maximum party size for the player.

Search for: game_get_party_companion_limit

You'll find this code:
  ("game_get_party_companion_limit",
    [
      (assign, ":troop_no", "trp_player"),

      (assign, ":limit", 30),
      (store_skill_level, ":skill", "skl_leadership", ":troop_no"),
      (store_attribute_level, ":charisma", ":troop_no", ca_charisma),
      (val_mul, ":skill", 5),
      (val_add, ":limit", ":skill"),
      (val_add, ":limit", ":charisma"),

      (troop_get_slot, ":troop_renown", ":troop_no", slot_troop_renown),
      (store_div, ":renown_bonus", ":troop_renown", 25),
      (val_add, ":limit", ":renown_bonus"),

      (assign, reg0, ":limit"),
      (set_trigger_result, reg0),
  ]),
Lets look at this.
The blue number is the base troop size.
The red number is how many troops are added for every 1 point of the "leadership skill" category.
The purple number is how much renown it takes to increase the player's party size by 1.

Well, now there is no easy way out, you just have to increase the number of the color numbers to increase the maximum party size of players.

Ok, now for the "fun part". (Sarcasm) Why is it "fun", well there is going to be A LOT of nerfing/trial and error/etc to do.

This is going to allow the AI Lords to spawn with as many troops as possible, and it'll let towns/castles have more troops as well.

So now go to module_party_templates

Scroll down a bit (or search for: Reinforcements) and you'll find this code:
  ("kingdom_1_reinforcements_a", "{!}kingdom_1_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_swadian_recruit,5,10),(trp_swadian_militia,2,4)]),
  ("kingdom_1_reinforcements_b", "{!}kingdom_1_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_swadian_footman,3,6),(trp_swadian_skirmisher,2,4)]),
  ("kingdom_1_reinforcements_c", "{!}kingdom_1_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_swadian_man_at_arms,2,4),(trp_swadian_crossbowman,1,2)]), #Swadians are a bit less-powered thats why they have a bit more troops in their modernised party template (3-6, others 3-5)

  ("kingdom_2_reinforcements_a", "{!}kingdom_2_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_vaegir_recruit,5,10),(trp_vaegir_footman,2,4)]),
  ("kingdom_2_reinforcements_b", "{!}kingdom_2_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_vaegir_veteran,2,4),(trp_vaegir_skirmisher,2,4),(trp_vaegir_footman,1,2)]),
  ("kingdom_2_reinforcements_c", "{!}kingdom_2_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_vaegir_horseman,2,3),(trp_vaegir_infantry,1,2)]),

  ("kingdom_3_reinforcements_a", "{!}kingdom_3_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_khergit_tribesman,3,5),(trp_khergit_skirmisher,4,9)]), #Khergits are a bit less-powered thats why they have a bit more 2nd upgraded(trp_khergit_skirmisher) than non-upgraded one(trp_khergit_tribesman).
  ("kingdom_3_reinforcements_b", "{!}kingdom_3_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_khergit_horseman,2,4),(trp_khergit_horse_archer,2,4),(trp_khergit_skirmisher,1,2)]),
  ("kingdom_3_reinforcements_c", "{!}kingdom_3_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_khergit_horseman,2,4),(trp_khergit_veteran_horse_archer,2,3)]), #Khergits are a bit less-powered thats why they have a bit more troops in their modernised party template (4-7, others 3-5)

  ("kingdom_4_reinforcements_a", "{!}kingdom_4_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_nord_footman,5,10),(trp_nord_recruit,2,4)]),
  ("kingdom_4_reinforcements_b", "{!}kingdom_4_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_nord_huntsman,2,5),(trp_nord_archer,2,3),(trp_nord_footman,1,2)]),
  ("kingdom_4_reinforcements_c", "{!}kingdom_4_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_nord_warrior,3,5)]),

  ("kingdom_5_reinforcements_a", "{!}kingdom_5_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_rhodok_tribesman,5,10),(trp_rhodok_spearman,2,4)]),
  ("kingdom_5_reinforcements_b", "{!}kingdom_5_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_rhodok_crossbowman,3,6),(trp_rhodok_trained_crossbowman,2,4)]),
  ("kingdom_5_reinforcements_c", "{!}kingdom_5_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_rhodok_veteran_spearman,2,3),(trp_rhodok_veteran_crossbowman,1,2)]),

  ("kingdom_6_reinforcements_a", "{!}kingdom_6_reinforcements_a", 0, 0, fac_commoners, 0, [(trp_sarranid_recruit,5,10),(trp_sarranid_footman,2,4)]),
  ("kingdom_6_reinforcements_b", "{!}kingdom_6_reinforcements_b", 0, 0, fac_commoners, 0, [(trp_sarranid_skirmisher,2,4),(trp_sarranid_veteran_footman,2,3),(trp_sarranid_footman,1,3)]),
  ("kingdom_6_reinforcements_c", "{!}kingdom_6_reinforcements_c", 0, 0, fac_commoners, 0, [(trp_sarranid_horseman,3,5)]),

Now, all we need to look at is the numbers that appear after the troops. The lower number (for the trp_swadian_recruit its 5) is the minimum number of tries this troop gets to spawn. The higher number (for the trp_swadian_recruit its 10) is the maximum number of tries this troop gets to spawn. Of course, the higher the number, the higher the spawn.

The problem is, if you edit these, the really advance troops get left out in the cold (meaning they may spawn way less than these guys.) For example, trp_swadian_knight isn't up there. If you edit these numbers significantly, then this troop may only spawn once per party. To counter this problem, you need to add every troop that isn't up there, while also editing the numbers.

The other problem is nerfing. You can't just times every number by 10 (trust me, I tried), because certain troops will spring ahead. For example, when I tried it the Swadian Recruits outnumbered their Militia friends by 500 troops. (Recruit count in one city: 1000|Militia count in that same city:500) So you will need to try and find a balance at higher numbers of tries.

Thats all the the problems I know about.

So I hoped this has helped! Thanks for looking!
 
A little addon written by caba'drin:

This will add a bonus for the player troop size in case you are King, Marshall and/or hold fiefs.
In module scripts change the game_get_party_companion_limit code to this:

("game_get_party_companion_limit",
    [
      (assign, ":troop_no", "trp_player"),

      (assign, ":limit", 30),
      (store_skill_level, ":skill", "skl_leadership", ":troop_no"),
      (store_attribute_level, ":charisma", ":troop_no", ca_charisma),
      (val_mul, ":skill", 5),
      (val_add, ":limit", ":skill"),
      (val_add, ":limit", ":charisma"),

      (troop_get_slot, ":troop_renown", ":troop_no", slot_troop_renown),
      (store_div, ":renown_bonus", ":troop_renown", 20),
      (val_add, ":limit", ":renown_bonus"),

      (try_begin),
          (gt, "$players_kingdom", 0),
          (faction_slot_eq, "$players_kingdom", slot_faction_leader, ":troop_no"), #bonus for king
          (val_add, ":limit", 100),
          (assign, reg6, 100), #For size report
      (else_try),
          (assign, reg6, 0), #For size report
      (try_end),
      (try_begin),
          (faction_slot_eq, "$players_kingdom", slot_faction_marshall, ":troop_no"), #bonus for marshall
          (val_add, ":limit", 20),
          (assign, reg7, 20), #For size report
        (else_try),
          (assign, reg7, 0), #For size report
        (try_end), 

        (assign, ":fief_count", 0),
        (assign, ":pre_limit", ":limit"),
        (try_for_range, ":cur_center", centers_begin, centers_end),
          (party_slot_eq, ":cur_center", slot_town_lord, ":troop_no"),
          (val_add, ":fief_count", 1),   
          (party_slot_eq, ":cur_center", slot_party_type, spt_castle), #This will do what this loop did previously, giving a 20 troop boost for each castle owned
          (val_add, ":limit", 20),       
        (try_end),
        (store_sub, ":pre_limit", ":limit", ":pre_limit"),
        (assign, reg8, ":pre_limit"), #For size report, castles
        (try_begin),     
          (gt, ":fief_count", 0),
          (val_add, ":limit", bump-for-being-a-lord), #bonus for holding at least one fief and therefore being nobility
          (assign, reg9, bump-for-being-a-lord), #For size report
        (else_try),
          (assign, reg9, 0), #For size report
        (try_end),   

      (assign, reg0, ":limit"),
      (set_trigger_result, reg0),
  ]),

This will display it in the Camp Report screen.
In module game menus change the script_get_party_companion_limit to this:

("party_size_report",0,
  "{s1}",
  "none",
  [(call_script, "script_game_get_party_companion_limit"),
    (assign, ":party_size_limit", reg0),

    (store_skill_level, ":leadership", "skl_leadership", "trp_player"),
    (val_mul, ":leadership", 5),
    (store_attribute_level, ":charisma", "trp_player", ca_charisma),

    (troop_get_slot, ":renown", "trp_player", slot_troop_renown),
    (val_div, ":renown", 25),
    (try_begin),
      (gt, ":leadership", 0),
      (str_store_string, s2, "@{!} +"),
    (else_try),
      (str_store_string, s2, "str_space"),
    (try_end),
    (try_begin),
      (gt, ":charisma", 0),
      (str_store_string, s3, "@{!} +"),
    (else_try),
      (str_store_string, s3, "str_space"),
    (try_end),
    (try_begin),
      (gt, ":renown", 0),
      (str_store_string, s4, "@{!} +"),
    (else_try),
      (str_store_string, s4, "str_space"),
    (try_end),
    (assign, reg5, ":party_size_limit"),
    (assign, reg1, ":leadership"),
    (assign, reg2, ":charisma"),
    (assign, reg3, ":renown"),
    #Size Tweak Additions
    (try_begin),
      (gt, reg9, 0), #Lord
      (str_store_string, s5, "@{!} +{reg9}"),
    (else_try),
      (str_store_string, s5, "str_space"),
    (try_end),
    (try_begin),
      (gt, reg8, 0), #Castles
      (str_store_string, s6, "@{!} +{reg8}"),
    (else_try),
      (str_store_string, s6, "str_space"),
    (try_end),
    (try_begin),
      (gt, reg7, 0), #Marshall
      (str_store_string, s7, "@{!} +{reg7}"),
    (else_try),
      (str_store_string, s7, "str_space"),
    (try_end),
    (try_begin),
      (gt, reg6, 0), #King
      (str_store_string, s8, "@{!} +{reg6}"),
    (else_try),
      (str_store_string, s8, "str_space"),
    (try_end),

    (str_store_string, s1, "@Current party size limit is {reg5}.^Current party size modifiers are:^^Base size:  +30^Leadership: {s2}{reg1}^Charisma: {s3}{reg2}^Renown: {s4}{reg3}^^Lord: {s5}^Castles: {s6}^Marshall: {s7}^King: {s8}^TOTAL:  {reg5}"),
    ],
    [
      ("continue",[],"Continue...",
      [(jump_to_menu, "mnu_reports"),
        ]
      ),
      ]
  ),


I just received this from caba and havent had the chance to properly test it, so please feel free to use this and tell us how it works. I will of course do that as well, but i dont have my old savegames anymore so it might take me a bit to check all of the above :wink:

Working.

PS: Yes i have permission to share :razz:

EDIT: You need to fill in a number into bump-for-being-a-lord :wink:
 
(val_add, ":limit", bump-for-being-a-lord), #bonus for holding at least one fief and therefore being nobility
          (assign, reg9, bump-for-being-a-lord), #For size report

These 2 lines in the module_scripts need a number instead of bump-for-being-a-lord

The number then determines the size of the bonus you receive for being part of nobility. (I chose 10)
 
Although this tutorial has been extremely helpful already, i still do have some unanswered questions.

1.Is there a way to distinguish between the first reinforcement and reinforcement waves after that?
Could i f.e. define that the AI lords get a sudden reinforcement of 100 units after being defeated and then give them several waves thereby slowly increasing their troop size?

2.Also what exactly does this mean:

Now, all we need to look at is the numbers that appear after the troops. The lower number (for the trp_swadian_recruit its 5) is the minimum number of tries this troop gets to spawn. The higher number (for the trp_swadian_recruit its 10) is the maximum number of tries this troop gets to spawn. Of course, the higher the number, the higher the spawn.

(trp_swadian_recruit,5,10)
5 tries = min. 5 swadian recruits being spawned ?
10 tries = max. 10 swadian recruits being spawned ?

So that in a reinforcement wave the AI lord will receive 5-10 swadian recruits and the exact amount is determined randomly?

3.And finally does anybody know where it dertemines "when" its time for a reinforcement wave?

Thanks for the help fellas :wink:
 
1) See the one-time usage of slot_troop_spawned_before in script_create_kingdom_hero_parties - at the beginning of the game they get a much higher arbitrary number of reinforcement tries. Unset this slot value back to 0 upon defeat or remove the check altogether so they always attempt to spawn with the same amount of reinforcement rounds (however they might not have the necessary wealth to do so).
2) Correct. This amount could possibly be modified by set_party_creation_random_limits - haven't really tried playing around with that.
 
TweakMB in 'AI Lord Parties' section talks about an 'amount above/below the player's level that AI lord maximum party sizes are based upon (Default is 0)'. Where do I find this value exactly in the module system? How does it work with actual numbers?

Say, we have two cases:

a) AI lord party size when player is level 1 sits at 100. the Default value referred above equals 0. The player is level 40 now. What is the party size of the AI lord?
b) AI lord party size when player is level 1 sits at 100. the Default value referred above equals 20. The player is level 40 now. What is the party size of the AI lord?

Is there any formula for that?
 
Nord Champion said:
As I know of now, there is no correlation between the player's level and AI party sizes.

I guess I'll just contact the author of the tweak then, I was never under impression personally that character's level actually influences maximum AI lord party size.
 
Achilla said:
Nord Champion said:
As I know of now, there is no correlation between the player's level and AI party sizes.

I guess I'll just contact the author of the tweak then, I was never under impression personally that character's level actually influences maximum AI lord party size.

This tweak comes from the end of the "party_get_ideal_size" script mentioned earlier, specifically the part bolded below:

(store_character_level, ":level", "trp_player"), #increase limits a little bit as the game progresses.
(store_add, ":level_factor", 80, ":level"),
(val_mul, ":limit", ":level_factor"),
(val_div, ":limit", 80),
(assign, reg0, ":limit"),

Since this is just a simple addition equation, increasing the 80 by X is equivalent to telling the game that you're X levels higher than you actually are (within this script at least).  For example, if you change the 80 to a 90, you're basically telling the game that you're 10 levels higher than you actually are, which in turn increases the "level factor" that's figured into the final limit.

When TweakMB handles this tweak, it actually adds 80 to the value you see in TweakMB.  It just does the calculation for you in the background for the sake of simplifying the tweak.  In other words, if you keep the default value of 0, TweakMB will actually insert an 80, which matches the "actual" default value.  If you change the TweakMB value to 20, TweakMB will actually insert 100.  You get the idea.
 
I think I get it now. I suppose it's a guesswork how much does it increase the party limit exactly?

In any way, my flawed understanding on a conceptual level is as follows:

(player level + level factor)/limit  * y * x = final AI party size

default:

level factor = 80 ; the bigger level factor the bigger AI party (80 + tweak value)
limit = 80 ; the lower limit the bigger AI party
y = normal AI party size without 'increase limits script'
x = unknown constant

EDIT:

Darn it, these reinforcements scripts from module are such a moon-speak.
 
It's basically a multiplier. If you were level 40, it would be(80+40)/80=1.5, so whatever ideal party size would be multiplied by 1.5. There is no x in that calculation, and y would be the size before the level scaling (the script is part of Native). The lords will still need wealth and recruits to grow towards that ideal size.
 
Ok i have a few questions about this.

Where to find module_scripts file and how to mod it to get this result?
Or could someone else just make one mod for me.
Just to add the 10 units per 1 leadership skill and 1 per 10 renown points.
Thanks
 
bojan811 said:
Ok i have a few questions about this.

Where to find module_scripts file and how to mod it to get this result?
Or could someone else just make one mod for me.
Just to add the 10 units per 1 leadership skill and 1 per 10 renown points.
Thanks

You need the module system....found here. Go to the downloads section and you'll find the Module System.
 
Ok i got it now what is our next step?
When i unpack the folder there is 3 more folders
Module data
Module system
HDr converter

And I found module_scripts within Module system folder.
But his extension is "py" and should i try to edit this trough notepad ?
And yes when i am done editing in what format to save and where to copy this file?


Thanks
 
bojan811 said:
Ok i got it now what is our next step?
When i unpack the folder there is 3 more folders
Module data
Module system
HDr converter

And I found module_scripts within Module system folder.
But his extension is "py" and should i try to edit this trough notepad ?
And yes when i am done editing in what format to save and where to copy this file?


Thanks

You need python to edit those.

Go here to get the full instructions on the module system (warning though, it is outdated.)
 
Hi.

I have one problem.
I have done all that i have to do but ingame nothings change.

Im new winth moding so i could do something bad so ......
I need some help .

One question ... this Increase is for Native only ???
Work that for another mods ?
 
Back
Top Bottom