﻿namespace = heresy_historical

heresy_historical.0001 = {
    hidden = yes
    scope = faith

    immediate = {
        save_scope_as = origin_faith

        clear_saved_scope = heresy_faith
        # Each choice is gated independently. This avoids one eligible faith
        # starving all alternatives, and Catholic/Orthodox pools remain separate.
        random_list = {
            100 = {
                trigger = { pam_heresy_theoadamist_eligible_trigger = yes }
                faith:theoadamist_faith = { save_scope_as = heresy_faith }
            }
            100 = {
                trigger = { pam_heresy_marblist_eligible_trigger = yes }
                faith:marblist = { save_scope_as = heresy_faith }
            }
            100 = {
                trigger = { pam_heresy_elysian_eligible_trigger = yes }
                faith:elysian = { save_scope_as = heresy_faith }
            }
            100 = {
                trigger = { pam_heresy_illuminated_eligible_trigger = yes }
                faith:illuminated_faith = { save_scope_as = heresy_faith }
            }
            100 = {
                trigger = { pam_heresy_neo_fraticelli_eligible_trigger = yes }
                faith:neo_fraticelli_faith = { save_scope_as = heresy_faith }
            }
            100 = {
                trigger = { pam_heresy_catholic_tribunal_eligible_trigger = yes }
                faith:catholic_tribunal_faith = { save_scope_as = heresy_faith }
            }
            100 = {
                trigger = { pam_heresy_cadaverist_eligible_trigger = yes }
                faith:cadaverist_faith = { save_scope_as = heresy_faith }
            }
            100 = {
                trigger = { pam_heresy_penitente_eligible_trigger = yes }
                faith:penitente_faith = { save_scope_as = heresy_faith }
            }
        }

        if = {
            limit = { exists = scope:heresy_faith }
            if = {
                limit = { scope:heresy_faith = faith:marblist }
                random_faith_ruler = {
                    limit = { pam_heresy_marblist_epicenter_trigger = yes }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }
            else_if = {
                limit = { scope:heresy_faith = faith:illuminated_faith }
                random_faith_ruler = {
                    limit = {
                        pam_heresy_neow_epicenter_trigger = yes
                        capital_province = { pam_heresy_illuminated_region_trigger = yes }
                    }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }
            else_if = {
                limit = { scope:heresy_faith = faith:neo_fraticelli_faith }
                random_faith_ruler = {
                    limit = {
                        pam_heresy_neow_epicenter_trigger = yes
                        capital_province = { pam_heresy_neo_fraticelli_region_trigger = yes }
                    }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }
            else_if = {
                limit = { scope:heresy_faith = faith:catholic_tribunal_faith }
                random_faith_ruler = {
                    limit = {
                        pam_heresy_neow_epicenter_trigger = yes
                        capital_province = { pam_heresy_catholic_tribunal_region_trigger = yes }
                    }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }
            else_if = {
                limit = { scope:heresy_faith = faith:cadaverist_faith }
                random_faith_ruler = {
                    limit = {
                        pam_heresy_neow_epicenter_trigger = yes
                        capital_province = { pam_heresy_cadaverist_region_trigger = yes }
                    }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }
            else_if = {
                limit = { scope:heresy_faith = faith:penitente_faith }
                random_faith_ruler = {
                    limit = {
                        pam_heresy_neow_epicenter_trigger = yes
                        capital_province = { pam_heresy_penitente_region_trigger = yes }
                    }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }
            else_if = {
                limit = { scope:heresy_faith = faith:elysian }
                random_faith_ruler = {
                    limit = {
                        pam_heresy_neow_epicenter_trigger = yes
                        capital_province = { pam_heresy_elysian_region_trigger = yes }
                    }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                        modifier = { factor = 0.75 highest_held_title_tier >= tier_empire }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }
            else_if = {
                limit = { scope:heresy_faith = faith:theoadamist_faith }
                random_faith_ruler = {
                    limit = { pam_heresy_neow_epicenter_trigger = yes }
                    weight = {
                        base = 100
                        modifier = { factor = 1.5 has_trait = zealous }
                        modifier = { factor = 1.5 has_trait = theologian }
                        modifier = { factor = 0.75 highest_held_title_tier >= tier_empire }
                    }
                    save_scope_as = epicenter_ruler
                    save_scope_as = founder
                    capital_county = { save_scope_as = heresy_origin_county }
                }
            }

            if = {
                limit = {
                    exists = scope:epicenter_ruler
                    exists = scope:heresy_origin_county
                }

                if = {
                    limit = { scope:heresy_faith = { this = faith:marblist } }
                    scope:epicenter_ruler = {
                        create_character = {
                            template = priest_character_template
                            name = "Konst_a_act_ntios"
                            gender = male
                            age = 38
                            dynasty = none
                            employer = scope:epicenter_ruler
                            culture = culture:aromanian 
                            faith = scope:heresy_faith
                            rite = scope:heresy_faith.main_rite
                            save_scope_as = founder
                        }
                    }
                }

                if = {
                    limit = { scope:heresy_faith = faith:catholic_tribunal_faith }
                    scope:epicenter_ruler = {
                        create_character = {
                            template = priest_character_template
                            name = "neow_catholic_tribunal_jozef_ratzinger_name"
                            gender = male
                            age = 50
                            dynasty = none
                            employer = scope:epicenter_ruler
                            culture = culture:bavarian
                            faith = scope:heresy_faith
                            rite = scope:heresy_faith.main_rite
                            save_scope_as = founder
                        }
                    }
                    scope:founder = { add_trait = heresiarch }
                    set_global_variable = {
                        name = neow_catholic_tribunal_jozef
                        value = scope:founder
                    }
                }

                scope:heresy_faith.main_rite = { set_can_convert_to_rite = yes }
                if = {
                    limit = { scope:epicenter_ruler = { is_ai = yes } }
                    scope:epicenter_ruler = {
                        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
                        if = {
                            limit = {
                                NOT = { has_trait = heresiarch }
                                NOT = { scope:heresy_faith = faith:catholic_tribunal_faith }
                            }
                            add_trait = heresiarch
                        }
                    }
                }

                if = {
                    limit = {
                        scope:heresy_faith = { this = faith:theoadamist_faith }
                        NOT = { exists = title:k_theoadamist_hof.holder }
                    }
                    create_title_and_vassal_change = {
                        type = created
                        save_scope_as = theoadamist_title_change
                        add_claim_on_loss = no
                    }
                    title:k_theoadamist_hof = {
                        change_title_holder = {
                            holder = scope:epicenter_ruler
                            change = scope:theoadamist_title_change
                        }
                    }
                    resolve_title_and_vassal_change = scope:theoadamist_title_change
                }

                # Use the same geographical check on the initially converted
                # county AND each neighbour. No unrestricted Catholic ring.
                scope:heresy_origin_county = {
                    if = {
                        limit = { pam_heresy_neow_permitted_county_trigger = yes }
                        set_county_faith = scope:heresy_faith
                    }
                    every_neighboring_county = {
                        limit = {
                            faith = scope:origin_faith
                            pam_heresy_neow_permitted_county_trigger = yes
                        }
                        set_county_faith = scope:heresy_faith
                    }
                }

                scope:heresy_faith = { save_scope_as = c3_spread_owner }
                scope:c3_spread_owner = {
                    set_variable = {
                        name = c3_spread_remaining_converts
                        value = pam_heresy_c3_spread_budget_base_value
                    }
                }
                trigger_event = { id = heresy_historical.0011 days = { 5 10 } }

                every_player = {
                    limit = {
                        faith = scope:origin_faith
                        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
                    }
                    if = {
                        limit = { scope:heresy_faith = { this = faith:theoadamist_faith } }
                        trigger_event = heresy_historical.0050
                    }
                    else_if = {
                        limit = { scope:heresy_faith = { this = faith:marblist } }
                        trigger_event = heresy_historical.0051
                    }
                    else_if = {
                        limit = { scope:heresy_faith = { this = faith:elysian } }
                        trigger_event = heresy_historical.0052
                    }
                    else_if = {
                        limit = { scope:heresy_faith = faith:illuminated_faith }
                        trigger_event = heresy_historical.0053
                    }
                    else_if = {
                        limit = { scope:heresy_faith = faith:neo_fraticelli_faith }
                        trigger_event = heresy_historical.0054
                    }
                    else_if = {
                        limit = { scope:heresy_faith = faith:catholic_tribunal_faith }
                        trigger_event = heresy_historical.0055
                    }
                    else_if = {
                        limit = { scope:heresy_faith = faith:cadaverist_faith }
                        trigger_event = heresy_historical.0056
                    }
                    else_if = {
                        limit = { scope:heresy_faith = faith:penitente_faith }
                        trigger_event = heresy_historical.0057
                    }
                }

                if = {
                    limit = { scope:heresy_faith = { this = faith:theoadamist_faith } }
                    set_global_variable = {
                        name = pam_heresy_theoadamist_cooldown
                        value = yes
                        years = 50
                    }
                }
                else_if = {
                    limit = { scope:heresy_faith = { this = faith:marblist } }
                    set_global_variable = {
                        name = pam_heresy_marblist_cooldown
                        value = yes
                        years = 50
                    }
                }
                else_if = {
                    limit = { scope:heresy_faith = { this = faith:elysian } }
                    set_global_variable = {
                        name = pam_heresy_elysian_cooldown
                        value = yes
                        years = 50
                    }
                }
                else_if = {
                    limit = { scope:heresy_faith = faith:illuminated_faith }
                    set_global_variable = {
                        name = pam_heresy_illuminated_cooldown
                        value = yes
                        years = 50
                    }
                }
                else_if = {
                    limit = { scope:heresy_faith = faith:neo_fraticelli_faith }
                    set_global_variable = {
                        name = pam_heresy_neo_fraticelli_cooldown
                        value = yes
                        years = 50
                    }
                }
                else_if = {
                    limit = { scope:heresy_faith = faith:catholic_tribunal_faith }
                    set_global_variable = {
                        name = pam_heresy_catholic_tribunal_cooldown
                        value = yes
                        years = 50
                    }
                }
                else_if = {
                    limit = { scope:heresy_faith = faith:cadaverist_faith }
                    set_global_variable = {
                        name = pam_heresy_cadaverist_cooldown
                        value = yes
                        years = 50
                    }
                }
                else_if = {
                    limit = { scope:heresy_faith = faith:penitente_faith }
                    set_global_variable = {
                        name = pam_heresy_penitente_cooldown
                        value = yes
                        years = 50
                    }
                }
                pam_heresy_fervor_reset_effect = { COMPONENT = 3 }
            }
        }
    }
}

heresy_historical.0050 = {
    type = character_event
    window = big_event_window
    title = neow_theoadamist_heresy.0050.t
    desc = neow_theoadamist_heresy.0050.desc
    major = yes
    theme = christian
    major_trigger = { faith = scope:origin_faith }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_theoadamist_heresy.0050.a
        add_internal_flag = dangerous
        trigger = {
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        set_character_faith_with_conversion = scope:heresy_faith
        add_character_flag = { flag = recently_converted_by_heresy years = 10 }
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_theoadamist_heresy.0050.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0051 = {
    type = character_event
    window = big_event_window
    title = neow_marblist_heresy.0051.t
    desc = neow_marblist_heresy.0051.desc
    major = yes
    theme = christian
    major_trigger = {
        faith = scope:origin_faith
        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
    }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_marblist_heresy.0051.a
        add_internal_flag = dangerous
        trigger = {
            capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_marblist_heresy.0051.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0052 = {
    type = character_event
    window = big_event_window
    title = neow_elysian_heresy.0052.t
    desc = neow_elysian_heresy.0052.desc
    major = yes
    theme = christian
    major_trigger = {
        faith = scope:origin_faith
        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
    }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_elysian_heresy.0052.a
        add_internal_flag = dangerous
        trigger = {
            capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_elysian_heresy.0052.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0053 = {
    type = character_event
    window = big_event_window
    title = neow_illuminated_heresy.0053.t
    desc = neow_illuminated_heresy.0053.desc
    major = yes
    theme = christian
    major_trigger = {
        faith = scope:origin_faith
        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
    }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_illuminated_heresy.0053.a
        add_internal_flag = dangerous
        trigger = {
            capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_illuminated_heresy.0053.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0054 = {
    type = character_event
    window = big_event_window
    title = neow_neo_fraticelli_heresy.0054.t
    desc = neow_neo_fraticelli_heresy.0054.desc
    major = yes
    theme = christian
    major_trigger = {
        faith = scope:origin_faith
        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
    }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_neo_fraticelli_heresy.0054.a
        add_internal_flag = dangerous
        trigger = {
            capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_neo_fraticelli_heresy.0054.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0055 = {
    type = character_event
    window = big_event_window
    title = neow_catholic_tribunal_heresy.0055.t
    desc = neow_catholic_tribunal_heresy.0055.desc
    major = yes
    theme = christian
    major_trigger = {
        faith = scope:origin_faith
        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
    }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_catholic_tribunal_heresy.0055.a
        add_internal_flag = dangerous
        trigger = {
            capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_catholic_tribunal_heresy.0055.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0056 = {
    type = character_event
    window = big_event_window
    title = neow_cadaverist_heresy.0056.t
    desc = neow_cadaverist_heresy.0056.desc
    major = yes
    theme = christian
    major_trigger = {
        faith = scope:origin_faith
        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
    }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_cadaverist_heresy.0056.a
        add_internal_flag = dangerous
        trigger = {
            capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_cadaverist_heresy.0056.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0057 = {
    type = character_event
    window = big_event_window
    title = neow_penitente_heresy.0057.t
    desc = neow_penitente_heresy.0057.desc
    major = yes
    theme = christian
    major_trigger = {
        faith = scope:origin_faith
        capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
    }
    left_portrait = {
        character = scope:founder
        animation = preaching
        camera = camera_event_right_forward
    }
    option = {
        name = neow_penitente_heresy.0057.a
        add_internal_flag = dangerous
        trigger = {
            capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
            NOR = {
                faith.religious_head ?= this
                rite.head_of_rite ?= this
            }
        }
        pam_heresy_convert_ruler_to_heresy_faith_effect = yes
        change_spiritual_fulfillment = 20
        ai_chance = { base = 0 }
    }
    option = {
        name = neow_penitente_heresy.0057.b
        add_piety = medium_piety_gain
        ai_chance = { base = 100 }
    }
}

heresy_historical.0011 = {
	hidden = yes
	scope = faith

	trigger = {
		exists = scope:origin_faith
		exists = scope:heresy_faith
		exists = scope:epicenter_ruler
        exists = scope:heresy_origin_county
		exists = scope:founder
		exists = scope:c3_spread_owner
		scope:c3_spread_owner = {
			var:c3_spread_remaining_converts > 0
		}
	}

	immediate = {
		clear_saved_scope = convert_ruler

		scope:origin_faith = {
			random_faith_ruler = {
				limit = {
					is_physically_able_ai = yes
					OR = {
						AND = {
							is_landed = yes
							highest_held_title_tier >= tier_county
						}
						any_held_title = { has_clerical_region = yes }
					}
					NAND = {
						scope:heresy_faith = { has_doctrine = doctrine_theocracy_lay_clergy }
						any_held_title = { has_clerical_region = yes }
					}
					NOR = {
						this = scope:founder
						this = scope:epicenter_ruler
						this = faith.religious_head
						any_held_title = { is_head_of_faith = yes }
						has_character_flag = recently_converted_by_heresy
						recently_converted_faith_trigger = yes
					}
					exists = capital_county
					capital_county = { pam_heresy_neow_permitted_county_trigger = yes }
					OR = {
						AND = {
							faith = { has_doctrine_parameter = has_clerical_regions }
							exists = capital_county.clerical_region_title
							scope:heresy_origin_county.clerical_region_title ?= capital_county.clerical_region_title
						}
						capital_county = {
							squared_distance = {
								target = scope:heresy_origin_county
								value <= squared_distance_small
							}
						}
					}
				}

				weight = {
					base = 100

					modifier = {
						add = -40
						capital_county = {
							squared_distance = {
								target = scope:heresy_origin_county
								value > squared_distance_small
							}
						}
					}

					modifier = {
						factor = 1.5
						culture = { has_same_culture_heritage = scope:epicenter_ruler.culture }
					}

					modifier = {
						factor = 0.4
						highest_held_title_tier >= tier_kingdom
					}

					modifier = {
						factor = 5
						any_held_title = { has_clerical_region = yes }
					}

					modifier = {
						factor = 3
						faith = { has_doctrine_parameter = has_clerical_regions }
						exists = capital_county.clerical_region_title
						scope:heresy_origin_county.clerical_region_title ?= capital_county.clerical_region_title
					}

					modifier = {
						factor = 1.5
						OR = {
							has_trait = zealous
							has_trait = lifestyle_mystic
							has_trait = lifestyle_scholar
							has_trait = theologian
						}
					}

					modifier = {
						factor = 0.001
						OR = {
							government_has_flag = government_is_nomadic
							government_has_flag = government_is_herder
						}
					}
				}

				save_scope_as = convert_ruler
			}
		}

		if = {
			limit = { exists = scope:convert_ruler }

			if = {
				limit = {
					scope:heresy_faith = { pam_heresy_faith_is_pre_declaration_trigger = yes }
					exists = scope:new_rite
				}
				scope:convert_ruler = {
					pam_heresy_convert_ruler_to_new_rite_effect = yes
				}
			}
			else = {
				scope:convert_ruler = {
					pam_heresy_convert_ruler_to_heresy_faith_effect = yes
				}
			}

			scope:c3_spread_owner = {
				if = {
					limit = {
						scope:convert_ruler = {
							highest_held_title_tier >= tier_kingdom
						}
					}
					change_variable = {
						name = c3_spread_remaining_converts
						subtract = 4
					}
				}
				else_if = {
					limit = {
						scope:convert_ruler = {
							highest_held_title_tier = tier_duchy
						}
					}
					change_variable = {
						name = c3_spread_remaining_converts
						subtract = 2
					}
				}
				else = {
					change_variable = {
						name = c3_spread_remaining_converts
						subtract = 1
					}
				}

				if = {
					limit = { var:c3_spread_remaining_converts <= 0 }
					remove_variable = c3_spread_remaining_converts
				}
			}
			if = {
				limit = {
					scope:c3_spread_owner = { has_variable = c3_spread_remaining_converts }
				}
				trigger_event = {
					id = heresy_historical.0011
					days = { 5 12 }
				}
			}

			if = {
				limit = {
					trigger_if = {
						limit = {
							scope:heresy_faith = { pam_heresy_faith_is_pre_declaration_trigger = yes }
							exists = scope:new_rite
						}
						scope:convert_ruler ?= { rite = scope:new_rite }
					}
					trigger_else = {
						scope:convert_ruler ?= { faith = scope:heresy_faith }
					}
				}
				pam_heresy_send_spread_message_effect = { TITLE = heresy_historical.spread.title }
			}
		}
		else = {
			scope:c3_spread_owner = {
				remove_variable = c3_spread_remaining_converts
			}
		}
	}
}
