#########################
### For Other Modders ###
#########################

#########################
###### County Setup #####
#########################

Here is an example of how to setup the cultures and faiths of provinces yourself (e.g. at game start)
In this example:
    - The Barony of Rome will have 5 faiths (70% catholic, 8% conversos, 12% rabbinic, 5% orthodox, 5% mozarabic)
    - The Barony of Cordoba will have 2 cultures (40% bedouin, 60% basque)
    - The Barony of Skolt will be 100% catholic and 100% basque
File location : common/scripted_effects/

#########
E_kCAFG_custom_setup_example = {
    # Example: Edit Faiths Only
    title:b_roma.title_province = { # Access the province of Roma
        E_kCAFG_custom_province_setup_clear_faiths = yes # Clear existing faiths Only
        E_kCAFG_set_province_faith_percentage = { FAITH = catholic          VALUE = 70 }
        E_kCAFG_set_province_faith_percentage = { FAITH = conversos         VALUE = 8 }
        E_kCAFG_set_province_faith_percentage = { FAITH = rabbinism         VALUE = 12 }
        E_kCAFG_set_province_faith_percentage = { FAITH = orthodox          VALUE = 5 }
        E_kCAFG_set_province_faith_percentage = { FAITH = mozarabic_church  VALUE = 5 }
    }

    # Example: Edit Culture Only
    title:b_cordoba.title_province = { # Access the province of Cordoba
        E_kCAFG_custom_province_setup_clear_cultures = yes # Clear existing cultures Only
        E_kCAFG_set_province_culture_percentage = { CULTURE = bedouin       VALUE = 40 }
        E_kCAFG_set_province_culture_percentage = { CULTURE = basque        VALUE = 60 }
    }

    # Example: Edit both
    title:b_skolt.title_province = { # Access the province of Skolt
        E_kCAFG_custom_province_setup_clear_all = yes # Clear existing Cultures & Faiths
        E_kCAFG_set_province_culture_percentage = { CULTURE = basque        VALUE = 100 }
        E_kCAFG_set_province_faith_percentage = {   FAITH = catholic        VALUE = 100 }
    }

    # This effect is required at the end of your custom setup
    # to properly update tension & internal variables
    # for all edited provinces
    E_kCAFG_finish_custom_setup = yes
}
#########

Errors will be logged if the total culture or faith of a province is not equal to 100%, don't forget to check the error.log file.


Here is an example of a file containing an on_action that triggers after the county setup of this mod, in which the aforementioned effect can be called:

Example: my_custom_setup_on_actions.txt
File location : common/on_action/

#########
kCAFG_on_counties_setup_finished = {
    on_actions = {
        on_kCAFG_custom_setup
    }
}

on_kCAFG_custom_setup = {
    effect = {
        E_kCAFG_custom_setup_example = yes
    }
}
#########

#########################
### Population System ###
#########################

This mod also allows a province-level population weighted system (i.e. a province with more population will have a bigger negative effect on the county if the tension is high).
It was initially made for an upcoming simple population mod idea I had, but it can also be used by other mods.
A script value has to be replaced and a global variable has to be enabled to allow my system to take any dynamic "province population" value into account (See mod files).

Script value representing population (or any provincial scaling effect) : V_kCAFG_province_values_scale
Override by replacing this value in a file loaded after the file kei_cafg_province_values.txt

You'll also need to set the global variable kCAFG_province_values_scale_overriden at game start,
this will allow the cultural/religious setup to take it into account and the mod windows and map modes to display population numbers along with the original percentages.
