# -*- ck2.events -*-

namespace = HF

#Written by Joachim
#HF.43000 - HF.43999

#Catholic Zealots joining a war
character_event = {
    id = HF.43000
    desc = EVTDESC_HF_43000
    picture = GFX_evt_melee
    is_triggered_only = yes
    min_age = 16
    only_playable = yes
    has_dlc = "Holy Fury"

    trigger = {
        any_owned_bloodline = {
            has_bloodline_flag = defender_of_the_faith
        }
        any_war = {
            OR = {
                using_cb = crusade
                using_cb = new_crusade
                using_cb = religious
                using_cb = religious_revolt
            }
        }
    }

    immediate = {
        capital_scope = {
            ROOT = {
                spawn_unit = {
                    province = PREV
                    home = PREV
                    owner = THIS
                    match_character = THIS
                    match_mult = 0.075
                    match_min = 100
                    match_max = 2500
                    attrition = 1.0
                    earmark = catholic_zealots_sainthood
                    disband_on_peace = yes
                    can_toggle_looting = no
                }
                spawn_unit = {
                    province = PREV
                    home = PREV
                    owner = THIS
                    match_character = THIS
                    match_mult = 0.075
                    match_min = 100
                    match_max = 2500
                    attrition = 1.0
                    earmark = catholic_zealots_sainthood
                    disband_on_peace = yes
                    can_toggle_looting = no
                }
            }
        }
    }

    option = {
        name = EVTOPTA_HF_43000
    }
}

#Great Theologian Event
character_event = {
    id = HF.43200
    is_triggered_only = yes
    hide_window = yes
    min_age = 16
    only_playable = yes
    has_dlc = "Holy Fury"

    trigger = {
        any_owned_bloodline = {
            has_bloodline_flag = theologian_saintly_bloodline
            founder = {
                religion = ROOT
            }
        }
        NOT = {
            any_courtier = {
                has_character_flag = saintly_bloodline_great_theologian
            }
        }
    }

    immediate = {

        random_owned_bloodline = {
            limit = {
                has_bloodline_flag = theologian_saintly_bloodline
            }
            founder = {
                save_event_target_as = theologian_founder
            }
        }

        create_random_priest = {
            random_traits = yes
            dynasty = random
            attributes = {
                diplomacy = 8
                learning = 15
                stewardship = 2
                intrigue = 2
                martial = 2
            }
        }
        new_character = {
            remove_trait = slow
            remove_trait = imbecile
            remove_trait = dull
            remove_trait = inbred
            remove_trait = cannibal_trait
            
            remove_trait = mystic
            remove_trait = socializer
            remove_trait = gamer
            remove_trait = hedonist
            remove_trait = duelist
            remove_trait = hunter
            remove_trait = strategist
            remove_trait = administrator
            remove_trait = architect
            remove_trait = gardener
            remove_trait = schemer
            remove_trait = impaler
            remove_trait = seducer
            remove_trait = seductress
            remove_trait = theologian
            remove_trait = scholar

            random_list = { # Flavor Randomization
                15 = {
                    change_learning = 2
                }
                20 = {
                    add_trait = theologian
                }
                5 = {
                    add_trait = scholar
                }
                5 = {
                    add_trait = mystic
                }
                10 = {
                    change_learning = 4
                }
                5 = {
                    change_learning = 6
                }
                5 = {
                    add_trait = shrewd
                }
            }

            set_character_flag = saintly_bloodline_great_theologian
            save_event_target_as = great_theologian

            random_list = {
                25 = {
                    give_nickname = nick_the_holy
                }
                25 = {
                    give_nickname = nick_the_kind
                }
                25 = {
                    give_nickname = nick_the_good
                }
                25 = {
                    give_nickname = nick_the_merry
                }
                25 = {
                    give_nickname = nick_the_noble
                }
                25 = {
                    give_nickname = nick_the_wise
                }
            }
        }
        character_event = { id = HF.43250 }
    }
}

character_event = {
    id = HF.43250
    desc = EVTDESC_HF_43250
    picture = GFX_evt_heretic
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {
        name = EVTOPTA_HF_43250
        piety = 50
    }
}


#Random event for Saintly Bloodline - Defender of the Faith, Random Zealots crashing your Capital
character_event = {
    id = HF.43300
    desc = EVTDESC_HF_43300
    picture = GFX_evt_secluded_in_prayer
    min_age = 16
    only_playable = yes
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    trigger = {
        any_owned_bloodline = {
            has_bloodline_flag = defender_of_the_faith
        }
    }

    immediate = {
        any_owned_bloodline = {
            if = {
                limit = {
                    has_bloodline_flag = defender_of_the_faith
                }
                founder = {
                    save_event_target_as = founder_of_zealots
                }
            }
        }
    }

    option = {
        name = EVTOPTA_HF_43300
        trigger = {
            trait = cynical
        }
        tooltip_info = cynical
        piety = -25
        random_list = {
            50 = {
                modifier = {
                    factor = 0.3
                    martial >= 10
                }
                prestige = -50
                custom_tooltip = { text = EVTOPTA_HF_43300_CUSTOM_1 }
                hidden_tooltip = {
                    capital_scope = {
                        add_province_modifier = {
                            name = zealots_running_amok
                            duration = 1095
                        }
                    }
                    character_event = { id = HF.43301 }
                }
            }
            50 = {
                prestige = 50
                custom_tooltip = { text = EVTOPTA_HF_43300_CUSTOM_2 }
                hidden_tooltip = {
                    add_character_modifier = {
                        name = removed_zealots
                        duration = 1825
                    }
                    character_event = { id = HF.43302 }
                }
            }
        }
    }

    option = {
        name = EVTOPTB_HF_43300
        trigger = {
            learning >= 10
        }
        tooltip_info = learning
        wealth = -50
        piety = 25
        random_list = {
            40 = {
                prestige = -50
                modifier = {
                    factor = 0.5
                    learning >= 15
                }
                custom_tooltip = { text = EVTOPTB_HF_43300_CUSTOM_1 }
                hidden_tooltip = {
                    capital_scope = {
                        add_province_modifier = {
                            name = zealots_running_amok 
                            duration = 1095
                        }
                    }
                    character_event = { id = HF.43303 }
                }
            }
            40 = {
                prestige = 50
                modifier = {
                    factor = 1.5
                    learning >= 15
                }
                custom_tooltip = { text = EVTOPTB_HF_43300_CUSTOM_2 }
                hidden_tooltip = {
                    capital_scope = {
                        ROOT = {
                            spawn_unit = {
                                owner = THIS
                                province = PREV
                                home = PREV
                                troops = {
                                    archers = { 200 200 }
                                    light_infantry = { 500 500 }
                                }
                                attrition = 1
                                maintenance_multiplier = 0
                                can_toggle_looting = yes
                            }
                        }
                    }
                    character_event = { id = HF.43304 }
                }
            }
            40 = {
                prestige = 100
                modifier = {
                    factor = 1.5
                    learning >= 15
                }
                custom_tooltip = { text = EVTOPTB_HF_43300_CUSTOM_3 }
                hidden_tooltip = {
                    create_random_soldier = {
                        random_traits = yes
                        dynasty = random
                        female = no
                        attributes = {
                            diplomacy = 1
                            learning = 6
                            stewardship = 3
                            intrigue = 3
                            martial = 10
                        }
                    }
                    new_character = {
                        remove_trait = slow
                        remove_trait = imbecile
                        remove_trait = dull
                        remove_trait = inbred
                        remove_trait = cannibal_trait
                        
                        remove_trait = mystic
                        remove_trait = socializer
                        remove_trait = gamer
                        remove_trait = hedonist
                        remove_trait = duelist
                        remove_trait = hunter
                        remove_trait = strategist
                        remove_trait = administrator
                        remove_trait = architect
                        remove_trait = gardener
                        remove_trait = schemer
                        remove_trait = impaler
                        remove_trait = seducer
                        remove_trait = seductress
                        remove_trait = theologian
                        remove_trait = scholar

                        random_list = { # Flavor Randomization
                            15 = {
                                change_martial = 1
                            }
                            20 = {
                                add_trait = duelist
                            }
                            5 = {
                                add_trait = strategist
                            }
                            5 = {
                                add_trait = theologian
                            }
                            10 = {
                                change_learning = 3
                            }
                            5 = {
                                change_learning = 5
                            }
                            5 = {
                                add_trait = shrewd
                            }
                        }

                        save_event_target_as = zealot_general

                        random_list = {
                            25 = {
                                give_nickname = nick_the_pious
                            }
                            25 = {
                                give_nickname = nick_the_cleansing_flame
                            }
                            25 = {
                                give_nickname = nick_the_witch_hunter
                            }
                            25 = {
                                give_nickname = nick_the_purifier
                            }
                            25 = {
                                give_nickname = nick_the_fearless
                            }
                            25 = {
                                give_nickname = nick_the_ruthless
                            }
                        }
                    }
                    capital_scope = {
                        ROOT = {
                            spawn_unit = {
                                owner = THIS
                                province = PREV
                                home = PREV
                                troops = {
                                    archers = { 200 200 }
                                    light_infantry = { 500 500 }
                                }
                                attrition = 1
                                maintenance_multiplier = 0
                                can_toggle_looting = yes
                            }
                        }
                    }
                    character_event = { id = HF.43305}
                }
            }
        }
    }

    option = {
        name = EVTOPTC_HF_43300
        trigger = {
            learning >= 10
        }
        tooltip_info = learning
        piety = 50
        random_list = {
            50 = {
                modifier = {
                    factor = 0.5
                    learning >= 15
                }
                prestige = -50
                custom_tooltip = { text = EVTOPTC_HF_43300_CUSTOM_1 }
                hidden_tooltip = {
                    capital_scope = {
                        add_province_modifier = {
                            name = zealots_running_amok
                            duration = 1095
                        }
                    }
                    character_event = { id = HF.43306 }
                }
            }
            50 = {
                prestige = 50                
                custom_tooltip = { text = EVTOPTC_HF_43300_CUSTOM_2 }
                hidden_tooltip = {
                    add_character_modifier = {
                        name = removed_zealots
                        duration = 1825
                    }
                    character_event = { id = HF.43307 }
                }
            }
        }
    }

    option = {
        name = EVTOPTD_HF_43300
        capital_scope = {
            add_province_modifier = {
                name = zealots_running_amok
                duration = 1095
            }
        }
    }
}

#Notification events for the zealot responses
character_event = {
    id = HF.43301
    desc = EVTDESC_HF_43301
    picture = GFX_evt_large_army
    notification = yes
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {
        name = OK
    }
}

character_event = {
    id = HF.43302
    desc = EVTDESC_HF_43302
    picture = GFX_evt_large_army
    notification = yes
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {
        name = OK
    }
}

character_event = {
    id = HF.43303
    desc = EVTDESC_HF_43303
    picture = GFX_evt_large_army
    notification = yes
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {      
        name = OK
    }
}

character_event = {
    id = HF.43304
    desc = EVTDESC_HF_43304
    picture = GFX_evt_large_army
    notification = yes
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {      
        name = OK
    }
}

character_event = {
    id = HF.43305
    desc = EVTDESC_HF_43305
    picture = GFX_evt_large_army
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {      
        name = OK
        show_portrait = event_target:zealot_general
    }
}

character_event = {
    id = HF.43306
    desc = EVTDESC_HF_43306
    picture = GFX_evt_large_army
    notification = yes
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {      
        name = OK
    }
}

character_event = {
    id = HF.43307
    desc = EVTDESC_HF_43307
    picture = GFX_evt_large_army
    notification = yes
    is_triggered_only = yes
    has_dlc = "Holy Fury"

    option = {      
        name = OK
    }
}
character_event = {
    id = HF.43400
    desc = EVTDESC_HF_43400
    picture = GFX_evt_monk
    is_triggered_only = yes
    has_dlc = "Holy Fury"
    trigger = {
        has_dlc = "Mystics"
        any_owned_bloodline ={
            has_bloodline_flag = monastic_saintly_bloodline
            founder = {
                religion = ROOT
            }
        }
        capital_scope = {
            NOT = {
                has_province_modifier = monk_society_help
            }
        }
    }

    option = {      
        name = EVTOPTA_HF_43400
        wealth = -100
        capital_scope = {
            add_province_modifier = {
                name = monk_society_help
                duration = 5475
            }
        }
    }
    option = {      
        name = EVTOPTB_HF_43400
        trigger = {
            religion_group = christian
            is_in_society = no
            is_heretic = no
        }
        if = {
            limit = {
                religion = catholic
            }
            join_society = monastic_order_benedictine
            change_society_currency = {
                society = monastic_order_benedictine
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = fraticelli
            }
            join_society = monastic_order_benedictine
            change_society_currency = {
                society = monastic_order_benedictine
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = waldensian
            }
            join_society = monastic_order_benedictine
            change_society_currency = {
                society = monastic_order_benedictine
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = lollard
            }
            join_society = monastic_order_benedictine
            change_society_currency = {
                society = monastic_order_benedictine
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = cathar
            }
            join_society = monastic_order_benedictine
            change_society_currency = {
                society = monastic_order_benedictine
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = adoptionist
            }
            join_society = monastic_order_benedictine
            change_society_currency = {
                society = monastic_order_benedictine
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = arian
            }
            join_society = monastic_order_benedictine
            change_society_currency = {
                society = monastic_order_benedictine
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = orthodox
            }
            join_society = monastic_order_orthodox
            change_society_currency = {
                society = monastic_order_orthodox
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = bogomilist
            }
            join_society = monastic_order_orthodox
            change_society_currency = {
                society = monastic_order_orthodox
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = monothelite 
            }
            join_society = monastic_order_orthodox
            change_society_currency = {
                society = monastic_order_orthodox
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = iconoclast
            }
            join_society = monastic_order_orthodox
            change_society_currency = {
                society = monastic_order_orthodox
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = nestorian
                religion = messalian
            }
            join_society = monastic_order_nestorian
            change_society_currency = {
                society = monastic_order_nestorian
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = syriac
            }
            join_society = monastic_order_nestorian
            change_society_currency = {
                society = monastic_order_nestorian
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = maronite
            }
            join_society = monastic_order_nestorian
            change_society_currency = {
                society = monastic_order_nestorian
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = miaphysite
            }
            join_society = monastic_order_monophysite
            change_society_currency = {
                society = monastic_order_monophysite
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = apostolic
            }
            join_society = monastic_order_monophysite
            change_society_currency = {
                society = monastic_order_monophysite
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = monophysite
            }
            join_society = monastic_order_monophysite
            change_society_currency = {
                society = monastic_order_monophysite
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = paulician
            }
            join_society = monastic_order_monophysite
            change_society_currency = {
                society = monastic_order_monophysite
                value = 350
            }
        }
        else_if = {
            limit = {
                religion = tondrakian
            }
            join_society = monastic_order_monophysite
            change_society_currency = {
                society = monastic_order_monophysite
                value = 350
            }
        }
    }
    option = {
        name = EVTOPTC_HF_43400
        capital_scope = {
            add_province_modifier = {
                name = monk_society_help
                duration = 1825
            }
        }
    }
}