Total War: WARHAMMER

Total War: WARHAMMER

Not enough ratings
Modding: Setting a variable unit cap
By Brujah
This Variable Units Caps guide shows relatively experienced Total War modders how to set specific buildings to increase a given unit's capacity (so if you start the game with 2 units available, you could allow the construction of a particular building increase that capacity to 4 for example).
   
Award
Favorite
Favorited
Unfavorite
Intro and First Steps
As per the description, this mod should allow relatively experienced Total War modders to implement a unit cap based on buildings built in their regions.



I'm going to assume readers are comfortable with using the Pack File Manager and TWeak. If not, there are a couple of good guides to help out on TWCenter[www.twcenter.net]. I'm going to write this in the PFM format rather than TWeak.

You need to get your mod set up with the following tables from data.pack -

building_effects_junction_tables
effect_bonus_value_ids_unit_sets_tables
effects_tables
main_units_tables


You also need to get the following table from local_en.pack -
db > effects.loc
Step 1 - effect_bonus_value_ids_unit_sets_tables
This step tells the game what you want your effect to do, and to which unit.

Select the data__core table from effect_bonus_value_ids_unit_sets_tables. Create a new row by adding or cloning a row. Set bonus_value_id to 'unit_cap'. Set effect to whatever you want the name of your effect to be. I used 'br_main_effect_unit_cap_increase_slayers' because it's similar to the naming convention the developers used. As far as I can tell, you can call it what you like, so long as it's unique. Set unit_set to the name of the unit you want the effect to apply to. You should have a drop-down menu to assist with that.

Step 2 - effects_tables
This step tells the game where to use the effect and what icon it should display.

Select the data__core table from effects_tables. Create a new row by adding or cloning a row. Set effect to the same name you used above (so mine is once again 'br_main_effect_unit_cap_increase_slayers'). Note it has to be identical. Set icon and icon_negative to whichever one you like. I find 'replenishment.png' works nicely, but whatever suits your style is fine. It determines the little picture that appears next to the text in the UI for your mod. I'm not certain what priority actually does, but I set it around the same level (100-105) used by most building effects. Set unknown4 to 'campaign'. Make sure unknown5 is ticked. (unknown4 appears to be category and unknown5 is is_positive_value_good in TWeak, but they aren't named in PFM)

Step 3 - building_effects_junction_tables
This step tells the game what building to apply your effect to and by how much it should increase.

Select the data__core table from building_effects_junction_tables. Create a new row by adding or cloning a row. Set building to whatever building(s) you want to control your unit recruitment. I used 'wh_main_dwf_slayer_1', 'wh_main_dwf_slayer_2' and 'wh_main_special_great_slayer_shrine' as the three Dwarf Slayer buildings in the game. Set effect to the same effect name you used in steps 1 and 2 (so mine again would be 'br_main_effect_unit_cap_increase_slayers'). Set effect_scope to 'faction_to_faction_own'. Set value, value_damaged and value_ruined to whatever you see fit. They are literal values, so 2 in value means you increase the unit cap by 2 when that building is constructed, 2 in value_damaged means it provides that even if it's damaged, if you changed that to 1, it would only provide 1. These are cumulative across all your regions.

Step 4 - main_units_tables
This step tells the game what unit cap it should begin with.

Select the data__core table from main_units_tables. Depending on if you're modifying an existing unit or creating your own, you would either add a new row as before, or simply find the unit you want to edit. The only field we care about for the purposes of setting the unit cap is campaign_cap. Set it to anything higher than 0. The number is again literal, so if you set it to 10, it would allow recruitment of 10 of those units. Note this also includes units which are garrisoned, so consider how many of the given unit are likely to be in garrisons before setting the value.

Step 5 - effects.loc
Step 5 - effects.loc

This step tells the game what to display on the tooltip.

Select the effects.loc table from db in the text section. Set Tag to whatever your effect is, but put 'effects_description_' at the start. So in my case 'br_main_effect_unit_cap_increase_slayers' becomes 'effects_description_br_main_effect_unit_cap_increase_slayers'. Set Localised string to whatever text you like. If you want it to include the number you set in Step 3, you need to write '%+n'. If you write something before and after that, it needs to be '%+n%'. For example, mine is 'Slayer Unit capacity: %+n'. I could also have written 'Capacity: %+n% for Slayer Units'.

Step 6 - Tidying Up
Nothing to do with the process, just good practice.

Remember to rename your data__core tables to something unique to avoid conflicts with other mods. Remember to delete everything you haven't created/modified from the mod before you use it.
27 Comments
Ais 27 Feb, 2018 @ 4:54pm 
After a few days of lots of data entry i have all the races setup with basic unit caps! Now just to tweak numbers to fit how i want!
Brujah  [author] 20 Feb, 2018 @ 1:17am 
Sounds like you've got a body of work ahead of you if you're modding every unit! I look forward to seeing the end result. :)
Ais 20 Feb, 2018 @ 1:15am 
Got that to work now too! Apparently, rewriting the tooltip line decided to fix it! Had to dig into other tables to start getting things really moving but thanks to your guide and some other reading i was able to start this process!
Ais 19 Feb, 2018 @ 8:33pm 
Thanks for all the help, figured out what i did wrong! Now just need to nail down the tooltips and bam!
Brujah  [author] 16 Feb, 2018 @ 1:40am 
Remember that each entry you create has to be exactly identical apart from the additional section at the start in step 5. So if you used "Goblin_Spearmen_Unit_Cap_Aisriyth" for your change, then you need to make sure it's the same thing in everything else which references it. I'm not sure if it's case-sensitive, but I always just assume that things are, since it doesn't hurt to be more accurate than you need to be.
Ais 15 Feb, 2018 @ 5:42pm 
I do believe it is the second case, i am running just the mod to make sure nothing conflicts, i suspect the issue is either when i suspect the issue is in step 1 or step 3. I think i am either not referencing goblin spearmen properly or the building properly!
Brujah  [author] 15 Feb, 2018 @ 4:34pm 
Assuming it doesn't crash without your mod running, it's likely it's a conflict where the same variable is being called by multiple mods, or you're calling a variable that doesn't exist.
More likely the second, as I think in the first case it tends to just pick one at random to actually use.
Ais 15 Feb, 2018 @ 3:16pm 
I appreciate it! I intend on trying to do a mod for unit caps on everything and to get my feet wet i started with goblin spearmen but game is crashing now haha! Just gotta figure out what i did wrong and then go through the rest of the units!
Brujah  [author] 15 Feb, 2018 @ 1:30am 
Good luck Aisriyth! Let me know if you're still having trouble and I'll do my best to help. :)
Ais 14 Feb, 2018 @ 8:52pm 
Nvm, found my issue, now just have to track down the text area!