title_decisions = {
    
    start_horse_conv_quest = {
        is_high_prio = yes
        ai_check_interval = 40

        filter = owned
        ai_target_filter = owned
        only_playable = yes

        potential = {
            tier = COUNT
            FROM = {
                OR = {
                    has_game_rule = {
                        name = animals_conversion_ways
                        value = animal_decision
                    }
                    AND = {
                        has_game_rule = {
                            name = animals_conversion_ways
                            value = animal_instant
                        }
                        ai = no
                    }
                }
                Is_really_animal_trigger = no
                is_nomadic = no
            }
            location = {
                Is_really_animal_trigger = no
                NOT = { has_province_flag = horse_conv_quest_CD }
                terrain = steppe
            }
        }
        allow = {
            FROM = {
                OR = {
                    lifestyle_traits == 0
                    trait = hunter
                }
                wealth = 35
            }
            location = {
                custom_tooltip = {
                    text = tt_horse_horse_building
                    OR = {
                        has_building = tb_steppe_barracks_1
                        has_building = tb_steppe_stable_1
                        has_building = ca_steppe_stable_1
                        has_building = ca_steppe_barracks_1
                        has_building = tb_default_horse_conv_quest
                        has_building = ca_default_horse_conv_quest
                    }
                }
            }
        }

        effect = {
            if = {
                limit = {
                    has_game_rule = {
                        name = animals_conversion_ways
                        value = animal_decision
                    }
                }
                FROM = {
                    wealth = -35
                    piety = -100
                }

                location = {
                    province_event = { id = ani_plus.172 days = 7 random = 7 }
                    province_event = { id = ani_plus.171 years = 10 }
                }
            }
            else = {
                FROM = {
                    culture = horse
                }
                location = {
                    culture = horse
                }
            }
        }

        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0.001
                always = yes
            }

            modifier = {
                factor = 50 # 5%
                OR = {
                    culture_group = altaic
                    culture_group = magyar
                    culture = alan
                    culture_group = iranian
                }
            }
        }
    }

    horse_ritual_conversion_county = {
        is_high_prio = no
        ai_check_interval = 12

        filter = owned
        ai_target_filter = owned
        only_playable = yes

        potential = {
            tier = COUNT
            FROM = {
                culture_group = horse_group
                religion = Horse_religion
            }
            location = {
                NOT = {
                    culture_group = horse_group
                }
            }
            holder_scope = {
                character = FROM
            }
        }
        allow = {
            FROM = {
                has_regent = no
                piety = 100

                OR = {
                    trait = horse_caste_merchant
                    c_moskva = {
                        holder_scope = { religion = Horse_religion }
                    }
                }
                OR = {
                    government = horse_feudal_gov
                    government = horse_merchant_gov
                }
            }
        }

        effect = {
            FROM = {
                piety = -100
                add_character_modifier = {
                    name = horse_conversion_tyrany
                    months = 3
                }
            }

            location = {
                culture = FROM
            }
        }

        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0.15
                always = yes
            }
        }
    }
}

decisions = {
    adopt_horse_religion = {
        is_high_prio = yes
        ai_check_interval = 3

        potential = {
            culture_group = horse_group
            NOT = { religion = Horse_religion }
            can_change_religion = yes
        }
        allow = {
            is_adult = yes
            culture_group = horse_group
            has_regent = no
            is_incapable = no
            can_change_religion = yes
        }

        effect = {
            religion = Horse_religion

            if = {
                limit = {
                    OR = {
                        independent = yes
                        liege = { NOT = { religion = Horse_religion } }
                    }
                }
                if = {
                    limit = {
                        has_game_rule = {
                            name = animals_bonus_levy
                            value = Few
                        }
                    }
                    spawn_unit = {
                        province = capital_scope
                        home = capital_scope
                        owner = ROOT
                        leader = none
                        troops = {
                            light_cavalry = { 1250 1250 }
                            knights = { 250 250 }
                        }
                        attrition = 0.1
                        maintenance = no
                    }
                }
                else_if = {
                    limit = {
                        has_game_rule = {
                            name = animals_bonus_levy
                            value = Normal
                        }
                    }
                    spawn_unit = {
                        province = capital_scope
                        home = capital_scope
                        owner = ROOT
                        leader = none
                        troops = {
                            light_cavalry = { 2750 2750 }
                            knights = { 750 750 }
                        }
                        attrition = 0.1
                        maintenance = no

                    }
                }
                else_if = {
                    limit = {
                        has_game_rule = {
                            name = animals_bonus_levy
                            value = Many
                        }
                    }
                    spawn_unit = {
                        province = capital_scope
                        home = capital_scope
                        owner = ROOT
                        leader = none
                        troops = {
                            light_cavalry = { 6000 6000 }
                            knights = { 1000 1000 }
                        }
                        attrition = 0.05
                        maintenance = no

                    }
                }
            }
        
            if = {
                limit = {
                    is_feudal = yes
                }
                set_government_type = horse_feudal_gov
            }
        }
    
        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0

                independent = no
                liege = {
                    NOT = { religion = Horse_religion }
                }
            }
        }
    }

    create_war_hord = {
        only_playable = yes
        ai_check_interval = 30

        is_high_prio = yes

        potential = {
            NOT = { is_title_active = d_war_hord }
            independent = yes
            religion = Horse_religion
            culture_group = horse
            NOT = { has_alternate_start_parameter = { key = religion_names value = random } }
        }
        allow = {
            higher_tier_than = DUKE
            war = no
            piety = 350
        }

        effect = {
            piety = -350
            prestige = 600
            custom_tooltip = {
                text = CREATED_HOLY_ORDER_HORSE_TOOLTIP

                activate_title = { title = d_war_hord status = yes }
                create_character = {
                    random_traits = no
                    dynasty = random
                    religion = ROOT
                    culture = horse
                    female = no
                    age = 25
                    trait = brilliant_strategist
                    trait = zealous
                    trait = humble
                    trait = ambitious
                    trait = strategist
                    trait = holy_warrior
                }
                new_character = {
                    wealth = 500
                    d_war_hord = {
                        grant_title = PREV
                    }
                    set_government_type = order_government
                    create_character = {
                        random_traits = yes
                        dynasty = random
                        religion = ROOT
                        culture = ROOT
                        female = no
                        age = 20
                    }
                    create_character = {
                        random_traits = yes
                        dynasty = random
                        religion = ROOT
                        culture = ROOT
                        female = no
                        age = 19
                    }
                    create_character = {
                        random_traits = yes
                        dynasty = random
                        religion = ROOT
                        culture = ROOT
                        female = no
                        age = 18
                    }
                    create_character = {
                        random_traits = yes
                        dynasty = random
                        religion = ROOT
                        culture = ROOT
                        female = no
                        age = 17
                    }
                    create_character = {
                        random_traits = yes
                        dynasty = random
                        religion = ROOT
                        culture = ROOT
                        female = no
                        age = 16
                    }
                }
                any_player = {
                    narrative_event = { id = ani_plus.070 }
                }
            }
        }
    
        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0.4
            }
            modifier = {
                factor = 0.25
                trait = cynical
            }
        }
    }

    make_younth_rite = {
        only_rulers = yes
        ai_check_interval = 12

        is_high_prio = yes

        potential = {
            culture_group = horse_group
            religion = Horse_religion
            NOT = { has_character_flag = horse_organize_rite_1 }
        }
        allow = {
            #preparation costs
            conditional_tooltip = {
                trigger = {
                    tier = BARON
                }
                wealth = 10
            }
            conditional_tooltip = {
                trigger = {
                    tier = COUNT
                }
                wealth = 25
            }
            conditional_tooltip = {
                trigger = {
                    tier = DUKE
                }
                wealth = 75
            }
            conditional_tooltip = {
                trigger = {
                    tier = KING
                }
                wealth = 200
            }
            conditional_tooltip = {
                trigger = {
                    tier = EMPEROR
                }
                wealth = 500
            }

            war = no
            
            capital_scope = {
                show_scope_change = no
                any_province_character = {
                    age = 6
                    NOT = { age = 9 }
                    culture_group = horse_group
                    #has_landed_title = no

                    custom_tooltip = {
                        text = HORSE_TT_DID_NOT_PARTICIPATE_RITE_1
                    }
                    
                    NOT = { has_character_flag = rite_1_success }
                }
            }

            in_command = no
        }

        effect = {
            set_character_flag = horse_organize_rite_1
            
            # preparation price
            if = {
                limit = {
                    tier = BARON
                }
                wealth = -10
            }
            if = {
                limit = {
                    tier = COUNT
                }
                wealth = -25
            }
            if = {
                limit = {
                    tier = DUKE
                }
                wealth = -75
            }
            if = {
                limit = {
                    tier = KING
                }
                wealth = -200
            }
            if = {
                limit = {
                    tier = EMPEROR
                }
                wealth = -500
            }

            custom_tooltip = {
                text = HORSE_TT_START_RITE_PREPARATION

                character_event = { id = ani_plus.180 days = 10 random = 4 }
            }
        }

        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0.1
                NOT = { ai_honor = 0 }
            }
        }
    }

    create_horse_royal_gard = {
        only_playable = yes
        ai_check_interval = 6

        is_high_prio = yes

        potential = {
            culture_group = horse_group
            religion = Horse_religion
            higher_tier_than = DUKE
            NOT = { has_character_flag = created_royal_guard }
        }
        allow = {
            OR = {
                government = horse_feudal_gov
                government = horse_merchant_gov
            }
            custom_tooltip = {
                text = horse_TT_did_not_create_it_once
                always = yes
            }
            OR = {
                trait = horse_caste_merchant
                trait = horse_caste_warrior
            }

            trigger_if = {
                limit = { tier = KING }
                wealth = 200
            }
            trigger_else = {
                #limit = { tier = EMPEROR}
                wealth = 600
            }
        }

        effect = {
            set_character_flag = created_royal_guard
            
            if = {
                limit = {
                    tier = EMPEROR
                    c_galaz = {
                        location = {
                            religion = Horse_religion
                        }
                        owner = {
                            religion = Horse_religion
                        }
                    }
                }
                wealth = -600
                spawn_unit = {
                    province = capital_scope
                    home = capital_scope
                    
                    earmark = horse_royal_guard
                    
                    maintenance_multiplier = 1.5
                    reinforces = yes # holy site bonus
                    reinforce_rate_multiplier = 0.0625
                    disband_on_peace = no
                    can_toggle_looting = no
                    cannot_inherit = yes
                    troops = {
                        knights = { 500 500 }
                        light_cavalry = { 1000 1500 }
                    }
                }
            }
            else_if = {
                limit = {
                    tier = EMPEROR
                }
                wealth = -600
                spawn_unit = {
                    province = capital_scope
                    home = capital_scope
                    
                    earmark = horse_royal_guard
                    
                    maintenance_multiplier = 1.5
                    reinforces = no
                    disband_on_peace = no
                    can_toggle_looting = no
                    cannot_inherit = yes
                    troops = {
                        knights = { 500 500 }
                        light_cavalry = { 1000 1500 }
                    }
                }
            }
            else_if = {
                limit = {
                    #tier = KING
                    c_galaz = {
                        location = {
                            religion = Horse_religion
                        }
                        owner = {
                            religion = Horse_religion
                        }
                    }
                }
                wealth = -200
                spawn_unit = {
                    province = capital_scope
                    home = capital_scope
                    
                    earmark = horse_royal_guard
                    
                    maintenance_multiplier = 1.5
                    reinforces = yes # holy site bonus
                    reinforce_rate_multiplier = 0.1
                    disband_on_peace = no
                    can_toggle_looting = no
                    cannot_inherit = yes
                    troops = {
                        knights = { 100 100 }
                        light_cavalry = { 750 1000 }
                    }
                }
            }
            else = {
                wealth = -200
                spawn_unit = {
                    province = capital_scope
                    home = capital_scope
                    
                    earmark = horse_royal_guard
                    
                    maintenance_multiplier = 1.5
                    reinforces = no
                    disband_on_peace = no
                    can_toggle_looting = no
                    cannot_inherit = yes
                    troops = {
                        knights = { 100 100 }
                        light_cavalry = { 750 1000 }
                    }
                }
            }
        }

        ai_will_do = {
            factor = 1
        }
    }

    horse_abdicate = {
        only_playable = yes
        ai_check_interval = 12

        is_high_prio = yes

        potential = {
            has_character_flag = created_royal_guard
            NOT = { has_earmarked_regiments = horse_royal_guard }
            religion = Horse_religion
            culture_group = horse_group
        }
        allow = {
            custom_tooltip = {
                text = horse_TT_loose_its_royal_guard
                always = yes
            }
        }

        effect = {
            abdicate = yes
        }

        ai_will_do = {
            factor = 0
        }
    }
}

targetted_decisions = {
    horse_ritual_conversion = {
        is_high_prio = no
        ai_check_interval = 11

        only_playable = yes
        filter = sub_realm

        from_potential = {
            culture_group = horse_group
            religion = Horse_religion
        }
        potential = {
            NOR = {
                culture_group = FROM
                has_character_flag = horse_convert_character
            }
            liege = {
                character = FROM
            }
        }
        allow = {
            FROM = {
                OR = {
                    government = horse_feudal_gov
                    government = horse_merchant_gov
                }
                has_regent = no
                prestige = 125

                OR = {
                    trait = horse_caste_warrior
                    c_kirghiz = {
                        holder_scope = { religion = Horse_religion }
                    }
                }
            }

            is_adult = yes
            OR = {
                prisoner = yes
                has_landed_title = no
            }
        }
        effect = {
            FROM = {
                prestige = -125
                add_character_modifier = {
                    name = horse_conversion_tyrany
                    months = 6
                }
            }
            set_character_flag = horse_convert_character

            culture = FROM

        }
        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0.1

                always = yes
            }
        }
    }
}