Total War: WARHAMMER III

Total War: WARHAMMER III

Tabletop Caps: Thrones of Decay
DrunkFlamingo  [developer] 13 Apr, 2022 @ 6:59am
Creating a Custom Special Rule
Here is a quick guide on making custom special rules for TTC. If you're looking to make a unit have a different cost for a specific faction or character, this is what you need.

1. script_bonus_value_ids_tables

In this table you need to enter the bonus value ids that you are going to use. The valid IDs are as follows:

ttc_special_rule_UNIT_KEY_to_core ttc_special_rule_UNIT_KEY_to_special ttc_special_rule_UNIT_KEY_to_rare ttc_special_rule_UNIT_KEY_weight

Replace unit key with the main_units_tables key. The exact format for these keys matters.

2. effects_tables

You will need to create an effect for each aspect of your special rule. So, if you want to move a unit to special and set their cost to one, you would want to create two effects.

You can name these effects whatever you like, it does not matter.

3. effect_bonus_value_scripted_junctions_tables

In this table, you connect the effects you created in step #2 to the bonus values you created in step #1.

The first column of this table is always "value". The next column is the effect you created. The third column is the bonus value you created.

4. Whatever tables you want.

At this point, you have an effect which can be used in tables. For example to add the rule to a skill you would go to character_skill_level_to_effects_junctions_tables.

Basically any table that has effects will work. The only thing is that they have to be targeted at characters using the scope.

So, for common examples, skills would use a character_to_character_own scope while technologies would use a faction_to_character_own_unseen scope.

When filling out the 'value' field:
- The weight modifier bonus value is understood by the script as + or - cost. To reduce a unit from 2 special to 1 special, you'd want a value of -1. To make it cost three you'd want a value of +1.
- The other bonus values are understood by the script as on-off switches. To make a unit go to a different group, you would just want to put any value greater than 0.

5. The scripted filter:

The final step to get your special rule to work is to tell the script when it needs to check for one.

Here is a template script for adding a special rule filter:

local units_with_special_rules = { {"UNIT_KEY", {subtype = "wh3_main_ksl_katarin"}} } local ttc = core:get_static_object("tabletopcaps") if ttc then ttc.add_setup_callback(function() ttc.add_special_rule_list(units_with_special_rules) end) end

This would check for special rules for UNIT_KEY on Katarin.

The valid flags for the special rules filter are "subtype", used above, "faction" , and "subculture". These flags have an OR relationship, so for instance:

local units_with_special_rules = { {"UNIT_KEY", {subtype = "wh3_main_dae_belakor", faction = "wh3_main_dae_daemon_prince", subculture = "wh3_main_sc_kho_khorne"}} }

Would check for special rules for UNIT_KEY on Belekor (no matter who owns him), as well as all characters from the Legion of Chaos faction, as well as all characters from any Khornate faction.

Why is this needed? Because otherwise I'd have to check every unit in the game on every lord for a special rule, and that would be bad for performance.

You should put this code in a .lua file in script/ttc/
Last edited by DrunkFlamingo; 10 Jun, 2022 @ 9:46am
< >
Showing 1-3 of 3 comments
Captain Freakout 30 Aug, 2022 @ 10:16am 
Hey DF, I have a small problem that seemingly arose with the latest patch. I made a special rule for a lord from a mod (the Head Honcho from Strat's Gnoblar Horde); even without activating the Gnoblar Horde mod, my submod used to run fine. The problem now is that unless the Gnoblar Horde mod is activated, then my submod crashes the game.

If I remove the DB entries for the special rule, then the mod does not crash even if Gnoblar Horde is not activated along with it. So I'm wondering if something changed with the latest patch regarding - perhaps - dependency between special rules/character DB entries and the mods they're related to.

I'm posting here in case any other submodders are having this problem, but let me know if you prefer to change over to your channel in the Den. Thanks!!
DrunkFlamingo  [developer] 31 Aug, 2022 @ 6:13am 
Well assuming you're junction-ing the effect to a skill, then yeah, that skill has to exist.

I believe common submod practise is to use a minimum priority table (zzzzzz_submod_data or whatever) to define a dummy version of the necessary skill so that it doesn't crash. When the other mod is present, their entry will overwrite yours. If you can't get it working on your own, ask in the mod development channel on the den I'm sure someone can help you.
Captain Freakout 31 Aug, 2022 @ 5:05pm 
Excellent, thank you very much for the pointer, I'll try to figure it out.
< >
Showing 1-3 of 3 comments
Per page: 1530 50