decisions = {
    duck_conversion_quest = {
        is_high_prio = yes
        ai_check_interval = 60
        only_playable = yes

        potential = {
            OR = {
                has_game_rule = {
                    name = animals_conversion_ways
                    value = animal_decision
                }
                AND = {
                    has_game_rule = {
                        name = animals_conversion_ways
                        value = animal_instant
                    }
                    ai = no
                }
            }
            any_realm_province = {
                port = yes
            }
            NOT = { Is_really_animal_trigger = yes }
            NOT = { has_character_modifier = panda_conversion_quest_cooldown }
        }

        allow = {
            is_adult = yes
            is_incapable = no
            has_regent = no
            OR = {
                trait = administrator
                lifestyle_traits == 0
            }
            any_demesne_province = {
                port = yes
                custom_tooltip = {
                    text = DUCK_HAS_SHIPYARD_TT
                    OR = {
                        has_building = ca_shipyard_1
                        has_building = tb_shipyard_1
                        has_building = ct_shipyard_1
                        has_building = tp_shipyard_1
                    }
                }
            }
        }
        effect = {
            if = {
                limit = {
                    has_game_rule = {
                        name = animals_conversion_ways
                        value = animal_decision
                    }
                }

                add_character_modifier = {
                    name = panda_conversion_quest_cooldown
                    years = 11
                    hidden = yes
                }

                character_event = { id = ani_plus.100 days = 7 }
            }
            else = {
                culture = duck_culture
            }
        }
        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0
                NOR = {
                    trait = gluttonous
                    trait = paranoid
                    trait = lunatic
                }
            }
            modifier = {
                factor = 0.001 #1 / 1000
                always = yes
            }
            modifier = {
                factor = 2.5
                trait = gluttonous
            }
            modifier = {
                factor = 5
                trait = paranoid
            }
            modifier = {
                factor = 2.5
                trait = lunatic
            }
        }
    }

    adopt_duck_religion = {
        is_high_prio = yes
        ai_check_interval = 3

        potential = {
            culture_group = duck_group
            NOT = { religion = Duck_religion }
            can_change_religion = yes
        }
        allow = {
            is_adult = yes
            culture_group = duck_group
            has_regent = no
            is_incapable = no
            can_change_religion = yes
        }
        effect = {
            religion = Duck_religion
            if = {
                limit = {
                    OR = {
                        independent = yes
                        liege = { NOT = { religion = Duck_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 = {
                            heavy_infantry = { 750 750 }
                            light_infantry = { 750 750 }
                        }
                        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 = {
                            heavy_infantry = { 1800 1800 }
                            light_infantry = { 2200 2200 }
                        }
                        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 = {
                            heavy_infantry = { 4000 4000 }
                            light_infantry = { 6000 6000 }
                        }
                        attrition = 0.05
                        maintenance = no

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

            modifier = {
                factor = 0

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

    create_sea_master = {
        only_playable = yes
        ai_check_interval = 80

        is_high_prio = yes
        only_playable = yes

        potential = {
            NOT = { is_title_active = d_sea_master }
            independent = yes
            religion = Duck_religion
            culture_group = duck_group
            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_DUCK_TOOLTIP

                activate_title = { title = d_sea_master status = yes }
                create_character = {
                    random_traits = no
                    dynasty = random
                    religion = ROOT
                    culture = duck_culture
                    female = no
                    age = 25
                    trait = brilliant_strategist
                    trait = zealous
                    trait = humble
                    trait = ambitious
                    trait = strategist
                    trait = holy_warrior
                }
                new_character = {
                    wealth = 500
                    d_sea_master = {
                        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.5
                trait = cynical
            }
        }
    }
}

targetted_decisions = {

    duck_cultural_convert_character = {
        is_high_prio = no
        ai_check_interval = 15

        filter = home_court
        ai_target_filter = home_court
        only_rulers = yes
        from_potential = {
            culture_group = duck_group
        }
        potential = {
            Is_really_animal_trigger = no
            is_adult = yes
            ai = no
        }
        allow = {
            custom_tooltip = {
                text = DUCK_is_on_boat
                location = {
                    OR = {
                        terrain = inland_ocean #terrain exist but dosn't have localisation, don't know if used...
                        terrain = ocean         #terrain also dosn't seems to have a localisation...
                        terrain = coastal_desert
                    }
                    NOT = {
                        province_id = 1950 #only landed province with ocean terrain
                    }
                }
            }
            FROM = {
                religion = Duck_religion
                prestige = 340
                piety = 160
            }
        }
        effect = {
            FROM = {
                prestige = -340
                piety = -160
            }

            character_event = { id = ani_plus.102 }
        }
        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0
                NOT = { trait = zealous }
            }
        }
    }
}

title_decisions = {

    duck_invasion_conversion = {
        is_high_prio = no
        ai_check_interval = 12

        filter = sub_realm_owned
        ai_target_filter = owned
        only_playable = yes

        potential = {
            tier = COUNT
            FROM = {
                culture_group = duck_group
                religion = Duck_religion
            }
            location = {
                NOT = { culture_group = duck_group }
            }
        }
        allow = {
            location = {
                show_scope_change = no
                custom_tooltip = {
                    text = DUCK_same_cul_neighbor
                    any_neighbor_province = {
                        culture_group = duck_group
                    }
                }
                OR = {
                    custom_tooltip = {
                        text = DUCK_neighbor_high_dev
                        any_neighbor_province = {
                            culture_group = duck_group
                            check_variable = { which=duck_dev_var value=6 }
                        }
                    }
                    c_venezia = {
                        holder_scope = {
                            show_scope_change = no
                            religion = Duck_religion
                        }
                    }
                    c_socotra = {
                        holder_scope = {
                            show_scope_change = no
                            religion = Duck_religion
                        }
                    }
                }
            }
            FROM = {
                conditional_tooltip = {
                    trigger = {
                        NOR = {
                            c_venezia = {
                                holder_scope = { religion = Duck_religion }
                            }
                            c_socotra = {
                                holder_scope = { religion = Duck_religion }
                            }
                        }
                    }
                    prestige = 700
                    piety = 200
                }
                conditional_tooltip = {
                    trigger = {
                        NAND = { #at least 1
                            c_venezia = {
                                holder_scope = { religion = Duck_religion }
                            }
                            c_socotra = {
                                holder_scope = { religion = Duck_religion }
                            }
                        }
                        OR = {
                            c_venezia = {
                                holder_scope = { religion = Duck_religion }
                            }
                            c_socotra = {
                                holder_scope = { religion = Duck_religion }
                            }
                        }
                    }
                    prestige = 400
                    piety = 100
                }
                conditional_tooltip = {
                    trigger = {
                        c_venezia = {
                            holder_scope = { religion = Duck_religion }
                        }
                        c_socotra = {
                            holder_scope = { religion = Duck_religion }
                        }
                    }
                    prestige = 150
                    piety = 50
                }
            }
        }
        effect = {
            if = {
                limit = {
                    FROM = {
                        NOR = {
                            c_venezia = {
                                holder_scope = { religion = Duck_religion }
                            }
                            c_socotra = {
                                holder_scope = { religion = Duck_religion }
                            }
                        }
                    }
                }
                FROM = {
                    prestige = -700
                    piety = -200
                }
                location = {
                    custom_tooltip = {
                        text = DUCK_reduce_dev_tt
                        any_neighbor_province = {
                            limit = { culture_group = duck_group }
                            duck_reduce_dev_effect = yes
                        }
                    }
                }
            }
            else_if = {
                limit = {
                    c_venezia = {
                        holder_scope = { religion = Duck_religion }
                    }
                    c_socotra = {
                        holder_scope = { religion = Duck_religion }
                    }
                }
                FROM = {
                    prestige = -150
                    piety = -50
                }
            }
            else = {
                FROM = {
                    prestige = -400
                    piety = -100
                }
            }
            location = {
                culture = FROM
                hidden_tooltip = {
                    duck_calculate_max_dev_level_effect = yes
                    set_variable = {
                        which = duck_dev_var
                        value = 5
                    }
                    duck_adapt_dev_province_modifier_effect = yes
                }
                custom_tooltip = {
                    text = DUCK_non_duck_death_TT
                    any_province_character = {
                        limit = { NOT = { culture_group = duck_group} }
                        random = {
                            chance = 50
                            death = yes
                        }
                    }
                }
            }
        }
        ai_will_do = {
            factor = 1
        }
    }

    duck_invest_in_province = {
        is_high_prio = no
        ai_check_interval = 36

        filter = owned
        ai_target_filter = owned
        only_playable = yes

        potential = {
            tier = COUNT
            FROM = {
                culture_group = duck_group
                religion = Duck_religion
            }
            location = {
                culture_group = duck_group
                NOT = {
                    check_variable = {
                        which = duck_dev_var
                        value = 9
                    }
                }
                NOT = { has_province_flag = duck_dev_invest }
            }
        }
        allow = {
            location = {
                show_scope_change = no

                custom_tooltip = {
                    text = DUCK_Can_improve_dev
                    NOT = {
                        check_variable = {
                            which = duck_max_dev
                            value = 9
                        }
                    }
                }
            }
            FROM = {
                scaled_wealth = {
                    value = 0.4
                    max = 200
                    min = 20
                }
            }
        }
        effect = {
            location = {
                set_province_flag = duck_dev_invest
                province_event = { id = ani_plus.109 }
            }
        }
        ai_will_do = {
            factor = 1

            modifier = {
                factor = 0
                OR = {
                    location = { is_capital = no }
                    FROM = { NOT = { culture_group = duck_group } }
                    FROM = { NOT = { wealth = 100 } }
                    location = { NOT = { check_variable = { which = duck_max_dev value = 6 } } }
                }
            }
            modifier = {
                factor = 0.1
                FROM = {
                    NOT = { wealth = 50 }
                }
            }
            modifier = {
                factor = 0.25
                FROM = {
                    NOT = { wealth = 100 }
                }
            }
            modifier = {
                factor = 0.5
                FROM = {
                    NOT = { wealth = 150 }
                }
            }
            modifier = {
                factor = 0.5
                FROM = {
                    NOT = { wealth = 250 }
                }
            }
        }
    }
}
