namespace = easycheats_main_religion


easycheats_main_religion.1 = { # religion
	type = country_event
	title = "easycheats_main_religion.1.title"
	desc = "easycheats_main_religion.1.desc"
	
    picture = easycheats_main_bg

    immediate = {
        if = {
            limit = {
                NOT = {
                    has_global_variable = easycheats_religion_page
                }
            }
            set_global_variable = {
                name = easycheats_religion_page
                value = 0
            }
        }
        save_scope_as = easycheats_temp_country

        if = {
            limit = {
                NOT = {
                    has_global_variable = has_setup_easycheats_religion_page
                }
            }
            
            set_global_variable = {
                name = easycheats_religion_page_max
                value = 0
            }

            religion:buddhism = { add_to_list = easycheats_religion_list }
            religion:judaism = { add_to_list = easycheats_religion_list }
            religion:egyptian_pantheon = { add_to_list = easycheats_religion_list }
            religion:anatolian_religion = { add_to_list = easycheats_religion_list }
            religion:animism = { add_to_list = easycheats_religion_list }
            religion:arabian_pantheon = { add_to_list = easycheats_religion_list }
            religion:armenian_religion = { add_to_list = easycheats_religion_list }
            religion:berber_religion = { add_to_list = easycheats_religion_list }
            religion:bon_religion = { add_to_list = easycheats_religion_list }
            religion:carthaginian_pantheon = { add_to_list = easycheats_religion_list }
            religion:caucasian_religion = { add_to_list = easycheats_religion_list }
            religion:druidism = { add_to_list = easycheats_religion_list }
            religion:eastern_animism = { add_to_list = easycheats_religion_list }
            religion:germanic_religion = { add_to_list = easycheats_religion_list }
            religion:hindu = { add_to_list = easycheats_religion_list }
            religion:indo_iranian_religion = { add_to_list = easycheats_religion_list }
            religion:jainism = { add_to_list = easycheats_religion_list }
            religion:matrist_religion = { add_to_list = easycheats_religion_list }
            religion:mesopotamian_religion = { add_to_list = easycheats_religion_list }
            religion:roman_pantheon = { add_to_list = easycheats_religion_list }
            religion:shamanism = { add_to_list = easycheats_religion_list }
            religion:zoroaster = { add_to_list = easycheats_religion_list }

            every_in_list = {
                list = easycheats_religion_list
                change_global_variable = {
                    name = easycheats_religion_page_max
                    add = 1
                }
            }

            change_global_variable = {
                name = easycheats_religion_page_max
                subtract = 1
            }

            set_global_variable = has_setup_easycheats_religion_page
        }

        set_global_variable = {
            name = easycheats_index
            value = 0
        }
        
        every_in_list = { 
            list = easycheats_religion_list

            if = {
                limit = {                    
                    global_var:easycheats_index = global_var:easycheats_religion_page
                }
                save_scope_as = easycheats_religion_target
                      
                if = {
                    limit = {
                        exists = scope:easycheats_religion_target_p
                    }
                    scope:easycheats_religion_target_p = {
                        set_character_religion = scope:easycheats_religion_target
                    }
                }
                else = {                    
                    scope:easycheats_temp_country = {
                        create_character = {
                            culture = iceni
                            religion = scope:easycheats_religion_target
                            age = 23
                            save_scope_as = easycheats_religion_target_p
                        }
                        
                        scope:easycheats_religion_target_p = {
                            set_character_religion = scope:easycheats_religion_target
                        }
                    }
                }
            }

            change_global_variable = {
                name = easycheats_index
                add = 1
            }
        }

        clear_saved_scope = easycheats_temp_country
    }

	option = {
		name = "easycheats_exit"
        
        set_global_variable = {
            name = easycheats_religion_page
            value = 0
        }
        
        remove_global_variable = has_setup_easycheats_religion_page

        scope:easycheats_religion_target_p = {
            death = {
                death_reason = death_mysteriously_retired
            }
        }

		ai_chance = { 
            factor = 100 
        }
	}
    
	option = {
		name = "easycheats_back_to_common"

        set_global_variable = {
            name = easycheats_religion_page
            value = 0
        }
        
        remove_global_variable = has_setup_easycheats_religion_page

        scope:easycheats_religion_target_p = {
            death = {
                death_reason = death_mysteriously_retired
            }
        }

        trigger_event = {
            id = easycheats_main.3
        }

		ai_chance = { 
            factor = 0 
        }
    }
    
	option = {
		name = "easycheats_next"

        trigger = {
            AND = {
                global_var:easycheats_religion_page < global_var:easycheats_religion_page_max
                global_var:easycheats_religion_page_max > 0
            }
        }

        change_global_variable = {
            name =  easycheats_religion_page
            add = 1                
        }

        trigger_event = {
            id = easycheats_main_religion.1
        }

		ai_chance = { 
            factor = 0 
        }
    }

    option = {
		name = "easycheats_back"

        trigger = {            
            global_var:easycheats_religion_page > 0
            global_var:easycheats_religion_page_max > 0
        }
        
        change_global_variable = {
            name =  easycheats_religion_page
            subtract = 1                
        }

        trigger_event = {
            id = easycheats_main_religion.1
        }

		ai_chance = { 
            factor = 0 
        }
    }

    option = {
        name = "easycheats_religion_convert"        
        
        highlight = yes
        
        trigger = {
            OR = {
                any_living_character = {
                    country = root
                    NOT = {
                        has_religion = scope:easycheats_religion_target
                    }
                }
                any_owned_province = {
                    any_pops_in_province = {
                        NOT = {                    
                            pop_religion = scope:easycheats_religion_target
                        }
                    }
                }
                NOT = {
                    religion = scope:easycheats_religion_target
                }
            }
        }

        every_living_character = {
            limit = {
                country = root
                NOT = {
                    has_religion = scope:easycheats_religion_target
                }
            }
            
            set_character_religion = scope:easycheats_religion_target
        }
        
        every_owned_province = {
            limit = {                
                NOT = {                    
                    pop_religion = scope:easycheats_religion_target
                }
            }
            every_pops_in_province = {
                limit = {
                    NOT = {                    
                        pop_religion = scope:easycheats_religion_target
                    }
                }
                set_pop_religion = scope:easycheats_religion_target
            }
        }

        if = {
            limit = {
                global_var:easycheats_religion_page = 0
            }
            set_country_religion = buddhism
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 1
            }
            set_country_religion = judaism
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 2
            }
            set_country_religion = egyptian_pantheon
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 3
            }
            set_country_religion = anatolian_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 4
            }
            set_country_religion = animism
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 5
            }
            set_country_religion = arabian_pantheon
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 6
            }
            set_country_religion = armenian_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 7
            }
            set_country_religion = berber_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 8
            }
            set_country_religion = bon_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 9
            }
            set_country_religion = carthaginian_pantheon
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 10
            }
            set_country_religion = caucasian_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 11
            }
            set_country_religion = druidism
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 12
            }
            set_country_religion = eastern_animism
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 13
            }
            set_country_religion = germanic_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 14
            }
            set_country_religion = hindu
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 15
            }
            set_country_religion = indo_iranian_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 16
            }
            set_country_religion = jainism
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 17
            }
            set_country_religion = matrist_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 18
            }
            set_country_religion = mesopotamian_religion
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 19
            }
            set_country_religion = roman_pantheon
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 20
            }
            set_country_religion = shamanism
        }
        else_if = {
            limit = {
                global_var:easycheats_religion_page = 21
            }
            set_country_religion = zoroaster
        }
        
        trigger_event = {
            id = easycheats_main_religion.1
        }
        
		ai_chance = { 
            factor = 0 
        }
	}
}
