namespace = kcccimmersion

### Religions in China

# Wax & Wane of Adoptionism
character_event = {
	id = kcccimmersion.0001
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_adoptionists" value = 20 }
				NOT = { has_global_flag = adoptionist_china_one }
			}
			set_global_flag = adoptionist_china_one
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_adoptionists" value = 40 }
				NOT = { has_global_flag = adoptionist_china_two }
			}
			set_global_flag = adoptionist_china_two
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_adoptionists" value = 100 }
				NOT = { has_global_flag = adoptionist_china_three }
			}
			set_global_flag = adoptionist_china_three
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_adoptionists" value = 180 }
				NOT = { has_global_flag = adoptionist_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = adoptionist_china_four
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_adoptionists" value = 180 }
				NOT = { has_global_flag = adoptionist_china_four }
			}
			set_global_flag = adoptionist_china_four
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_adoptionists" value = 100 } }
				has_global_flag = adoptionist_china_three
			}
			clr_global_flag = adoptionist_china_three
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_adoptionists" value = 40 } }
				has_global_flag = adoptionist_china_two
			}
			clr_global_flag = adoptionist_china_two
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_adoptionists" value = 20 } }
				has_global_flag = adoptionist_china_one
			}
			clr_global_flag = adoptionist_china_one
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_adoptionists" value = 0 } }
				has_global_flag = adoptionists_in_china
			}
			clr_global_flag = adoptionists_in_china
			set_variable = { which = "global_chinese_adoptionists" value = 0 }
			set_global_flag = kcc_waxwane_adoptionists
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = adoptionists_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_christians
					has_province_modifier = kcc_china_persecuted_latins
					has_province_modifier = kcc_china_persecuted_adoptionists
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_christians }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = adoptionist } }
			NOR = {
				has_global_flag = adoptionist_china_two
				has_global_flag = adoptionist_china_three
				has_global_flag = adoptionist_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = adoptionist } }
			NOR = {
				has_global_flag = adoptionist_china_three
				has_global_flag = adoptionist_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = adoptionist } }
			NOT = { has_global_flag = adoptionist_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = adoptionist } }
			has_global_flag = adoptionist_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = adoptionist }
						offmap_china = { offmap_has_like = likes_christians }
					}
				}
			}
			change_variable = { which = "global_chinese_adoptionists" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_adoptionists" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = adoptionist
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = adoptionist
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = adoptionist
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = adoptionist
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = adoptionist
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_christians }
					offmap_china = { offmap_ruler = { religion = adoptionist } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = adoptionist } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = adoptionist } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = adoptionist } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = adoptionist } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = adoptionist } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_like = likes_indians }
						d_adoptionist = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_dravidians }
						d_adoptionist = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_tibetans }
						d_adoptionist = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_germanics }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_latino_iberians }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_byzantines }
						d_adoptionist = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_celts }
						d_adoptionist = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_finno_ugrics }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_altaics }
						d_adoptionist = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_balto_slavics }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_arabs }
						d_adoptionist = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_iranians }
						d_adoptionist = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_africans }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_mesoamericans }
						d_adoptionist = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = adoptionist
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = muslim } }
					AND = {
						offmap_china = { offmap_ruler = { religion_group = christian } }
						offmap_china = { offmap_ruler = { NOT = { religion = adoptionist } } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = adoptionist } } }
					has_global_flag = d_adoptionist_moved_to_china
				}
			}
			modifier = {
				factor = 4
				AND = {
					offmap_china = { offmap_ruler = { religion = adoptionist } }
					has_global_flag = d_adoptionist_moved_to_china
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = adoptionist
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_adoptionists" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_adoptionists" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = adoptionist } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_adoptionist_mission }
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_dislike = likes_indians }
						d_adoptionist = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_dravidians }
						d_adoptionist = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_tibetans }
						d_adoptionist = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_germanics }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_latino_iberians }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_byzantines }
						d_adoptionist = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_celts }
						d_adoptionist = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_finno_ugrics }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_altaics }
						d_adoptionist = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_balto_slavics }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_arabs }
						d_adoptionist = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_iranians }
						d_adoptionist = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_africans }
						d_adoptionist = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_mesoamericans }
						d_adoptionist = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = adoptionist
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Wax & Wane of Free Spirits
character_event = {
	id = kcccimmersion.0002
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_free_spirits" value = 20 }
				NOT = { has_global_flag = free_spirits_china_one }
			}
			set_global_flag = free_spirits_china_one
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_free_spirits" value = 40 }
				NOT = { has_global_flag = free_spirits_china_two }
			}
			set_global_flag = free_spirits_china_two
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_free_spirits" value = 100 }
				NOT = { has_global_flag = free_spirits_china_three }
			}
			set_global_flag = free_spirits_china_three
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_free_spirits" value = 180 }
				NOT = { has_global_flag = free_spirits_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = free_spirits_china_four
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_free_spirits" value = 180 }
				NOT = { has_global_flag = free_spirits_china_four }
			}
			set_global_flag = free_spirits_china_four
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_free_spirits" value = 100 } }
				has_global_flag = free_spirits_china_three
			}
			clr_global_flag = free_spirits_china_three
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_free_spirits" value = 40 } }
				has_global_flag = free_spirits_china_two
			}
			clr_global_flag = free_spirits_china_two
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_free_spirits" value = 20 } }
				has_global_flag = free_spirits_china_one
			}
			clr_global_flag = free_spirits_china_one
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_free_spirits" value = 0 } }
				has_global_flag = free_spirits_in_china
			}
			clr_global_flag = free_spirits_in_china
			set_variable = { which = "global_chinese_free_spirits" value = 0 }
			set_global_flag = kcc_waxwane_free_spirits
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = free_spirits_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_christians
					has_province_modifier = kcc_china_persecuted_latins
					has_province_modifier = kcc_china_persecuted_free_spirits
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_christians }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = free_spirits } }
			NOR = {
				has_global_flag = free_spirits_china_two
				has_global_flag = free_spirits_china_three
				has_global_flag = free_spirits_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = free_spirits } }
			NOR = {
				has_global_flag = free_spirits_china_three
				has_global_flag = free_spirits_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = free_spirits } }
			NOT = { has_global_flag = free_spirits_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = free_spirits } }
			has_global_flag = free_spirits_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = free_spirits }
						offmap_china = { offmap_has_like = likes_christians }
					}
				}
			}
			change_variable = { which = "global_chinese_free_spirits" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_free_spirits" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = free_spirits
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = free_spirits
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = free_spirits
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = free_spirits
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = free_spirits
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_christians }
					offmap_china = { offmap_ruler = { religion = free_spirits } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = free_spirits } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = free_spirits } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = free_spirits } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = free_spirits } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = free_spirits } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = free_spirits
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = muslim } }
					AND = {
						offmap_china = { offmap_ruler = { religion_group = christian } }
						offmap_china = { offmap_ruler = { NOT = { religion = free_spirits } } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = free_spirits
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_free_spirits" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_free_spirits" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = free_spirits } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_free_spirits_mission }
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = free_spirits
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Wax & Wane of Barlaamite Christianity
character_event = {
	id = kcccimmersion.0003
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_barlaamites" value = 20 }
				NOT = { has_global_flag = barlaamite_china_one }
			}
			set_global_flag = barlaamite_china_one
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_barlaamites" value = 40 }
				NOT = { has_global_flag = barlaamite_china_two }
			}
			set_global_flag = barlaamite_china_two
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_barlaamites" value = 100 }
				NOT = { has_global_flag = barlaamite_china_three }
			}
			set_global_flag = barlaamite_china_three
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_barlaamites" value = 180 }
				NOT = { has_global_flag = barlaamite_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = barlaamite_china_four
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_barlaamites" value = 180 }
				NOT = { has_global_flag = barlaamite_china_four }
			}
			set_global_flag = barlaamite_china_four
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_barlaamites" value = 100 } }
				has_global_flag = barlaamite_china_three
			}
			clr_global_flag = barlaamite_china_three
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_barlaamites" value = 40 } }
				has_global_flag = barlaamite_china_two
			}
			clr_global_flag = barlaamite_china_two
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_barlaamites" value = 20 } }
				has_global_flag = barlaamite_china_one
			}
			clr_global_flag = barlaamite_china_one
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_barlaamites" value = 0 } }
				has_global_flag = barlaamites_in_china
			}
			clr_global_flag = barlaamites_in_china
			set_variable = { which = "global_chinese_barlaamites" value = 0 }
			set_global_flag = kcc_waxwane_barlaamites
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = barlaamites_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_christians
					has_province_modifier = kcc_china_persecuted_byzantines
					has_province_modifier = kcc_china_persecuted_barlaamites
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_christians }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = barlaamite } }
			NOR = {
				has_global_flag = barlaamite_china_two
				has_global_flag = barlaamite_china_three
				has_global_flag = barlaamite_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = barlaamite } }
			NOR = {
				has_global_flag = barlaamite_china_three
				has_global_flag = barlaamite_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = barlaamite } }
			NOT = { has_global_flag = barlaamite_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = barlaamite } }
			has_global_flag = barlaamite_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = barlaamite }
						offmap_china = { offmap_has_like = likes_christians }
					}
				}
			}
			change_variable = { which = "global_chinese_barlaamites" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_barlaamites" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = barlaamite
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = barlaamite
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = barlaamite
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = barlaamite
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = barlaamite
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_christians }
					offmap_china = { offmap_ruler = { religion = barlaamite } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = barlaamite } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = barlaamite } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = barlaamite } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = barlaamite } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = barlaamite } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_like = likes_indians }
						d_barlaamite = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_dravidians }
						d_barlaamite = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_tibetans }
						d_barlaamite = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_germanics }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_latino_iberians }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_byzantines }
						d_barlaamite = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_celts }
						d_barlaamite = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_finno_ugrics }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_altaics }
						d_barlaamite = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_balto_slavics }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_arabs }
						d_barlaamite = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_iranians }
						d_barlaamite = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_africans }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_mesoamericans }
						d_barlaamite = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = barlaamite
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = muslim } }
					AND = {
						offmap_china = { offmap_ruler = { religion_group = christian } }
						offmap_china = { offmap_ruler = { NOT = { religion = barlaamite } } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = barlaamite } } }
					has_global_flag = d_barlaamite_moved_to_china
				}
			}
			modifier = {
				factor = 4
				AND = {
					offmap_china = { offmap_ruler = { religion = barlaamite } }
					has_global_flag = d_barlaamite_moved_to_china
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = barlaamite
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_barlaamites" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_barlaamites" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = barlaamite } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_barlaamite_mission }
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_dislike = likes_indians }
						d_barlaamite = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_dravidians }
						d_barlaamite = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_tibetans }
						d_barlaamite = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_germanics }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_latino_iberians }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_byzantines }
						d_barlaamite = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_celts }
						d_barlaamite = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_finno_ugrics }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_altaics }
						d_barlaamite = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_balto_slavics }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_arabs }
						d_barlaamite = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_iranians }
						d_barlaamite = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_africans }
						d_barlaamite = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_mesoamericans }
						d_barlaamite = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = barlaamite
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Wax & Wane of Judaizing Christianity
character_event = {
	id = kcccimmersion.0004
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_judaizers" value = 20 }
				NOT = { has_global_flag = judaizer_china_one }
			}
			set_global_flag = judaizer_china_one
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_judaizers" value = 40 }
				NOT = { has_global_flag = judaizer_china_two }
			}
			set_global_flag = judaizer_china_two
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_judaizers" value = 100 }
				NOT = { has_global_flag = judaizer_china_three }
			}
			set_global_flag = judaizer_china_three
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_judaizers" value = 180 }
				NOT = { has_global_flag = judaizer_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = judaizer_china_four
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_judaizers" value = 180 }
				NOT = { has_global_flag = judaizer_china_four }
			}
			set_global_flag = judaizer_china_four
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_judaizers" value = 100 } }
				has_global_flag = judaizer_china_three
			}
			clr_global_flag = judaizer_china_three
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_judaizers" value = 40 } }
				has_global_flag = judaizer_china_two
			}
			clr_global_flag = judaizer_china_two
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_judaizers" value = 20 } }
				has_global_flag = judaizer_china_one
			}
			clr_global_flag = judaizer_china_one
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_judaizers" value = 0 } }
				has_global_flag = judaizers_in_china
			}
			clr_global_flag = judaizers_in_china
			set_variable = { which = "global_chinese_judaizers" value = 0 }
			set_global_flag = kcc_waxwane_judaizers
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = judaizers_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_christians
					has_province_modifier = kcc_china_persecuted_nonchalcedonians
					has_province_modifier = kcc_china_persecuted_judaizers
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_christians }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = judaizer } }
			NOR = {
				has_global_flag = judaizer_china_two
				has_global_flag = judaizer_china_three
				has_global_flag = judaizer_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = judaizer } }
			NOR = {
				has_global_flag = judaizer_china_three
				has_global_flag = judaizer_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = judaizer } }
			NOT = { has_global_flag = judaizer_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = judaizer } }
			has_global_flag = judaizer_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = judaizer }
						offmap_china = { offmap_has_like = likes_christians }
					}
				}
			}
			change_variable = { which = "global_chinese_judaizers" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_judaizers" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = judaizer
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = judaizer
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = judaizer
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = judaizer
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = judaizer
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_christians }
					offmap_china = { offmap_ruler = { religion = judaizer } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = judaizer } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = judaizer } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = judaizer } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = judaizer } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = judaizer } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_like = likes_indians }
						d_judaizer = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_dravidians }
						d_judaizer = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_tibetans }
						d_judaizer = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_germanics }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_latino_iberians }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_byzantines }
						d_judaizer = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_celts }
						d_judaizer = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_finno_ugrics }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_altaics }
						d_judaizer = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_balto_slavics }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_arabs }
						d_judaizer = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_iranians }
						d_judaizer = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_africans }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_mesoamericans }
						d_judaizer = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = judaizer
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = muslim } }
					AND = {
						offmap_china = { offmap_ruler = { religion_group = christian } }
						offmap_china = { offmap_ruler = { NOT = { religion = judaizer } } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = judaizer } } }
					has_global_flag = d_judaizer_moved_to_china
				}
			}
			modifier = {
				factor = 4
				AND = {
					offmap_china = { offmap_ruler = { religion = judaizer } }
					has_global_flag = d_judaizer_moved_to_china
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = judaizer
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_judaizers" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_judaizers" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = judaizer } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_judaizer_mission }
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_dislike = likes_indians }
						d_judaizer = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_dravidians }
						d_judaizer = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_tibetans }
						d_judaizer = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_germanics }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_latino_iberians }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_byzantines }
						d_judaizer = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_celts }
						d_judaizer = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_finno_ugrics }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_altaics }
						d_judaizer = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_balto_slavics }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_arabs }
						d_judaizer = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_iranians }
						d_judaizer = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_africans }
						d_judaizer = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_mesoamericans }
						d_judaizer = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = judaizer
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Wax & Wane of Mandeanism
character_event = {
	id = kcccimmersion.0005
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_mandeans" value = 20 }
				NOT = { has_global_flag = mandean_china_one }
			}
			set_global_flag = mandean_china_one
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_mandeans" value = 40 }
				NOT = { has_global_flag = mandean_china_two }
			}
			set_global_flag = mandean_china_two
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_mandeans" value = 100 }
				NOT = { has_global_flag = mandean_china_three }
			}
			set_global_flag = mandean_china_three
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_mandeans" value = 180 }
				NOT = { has_global_flag = mandean_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = mandean_china_four
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_mandeans" value = 180 }
				NOT = { has_global_flag = mandean_china_four }
			}
			set_global_flag = mandean_china_four
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_mandeans" value = 100 } }
				has_global_flag = mandean_china_three
			}
			clr_global_flag = mandean_china_three
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_mandeans" value = 40 } }
				has_global_flag = mandean_china_two
			}
			clr_global_flag = mandean_china_two
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_mandeans" value = 20 } }
				has_global_flag = mandean_china_one
			}
			clr_global_flag = mandean_china_one
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_mandeans" value = 0 } }
				has_global_flag = mandeans_in_china
			}
			clr_global_flag = mandeans_in_china
			set_variable = { which = "global_chinese_mandeans" value = 0 }
			set_global_flag = kcc_waxwane_mandeans
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = mandeans_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_christians
					has_province_modifier = kcc_china_persecuted_nonchalcedonians
					has_province_modifier = kcc_china_persecuted_mandeans
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_christians }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = mandean } }
			NOR = {
				has_global_flag = mandean_china_two
				has_global_flag = mandean_china_three
				has_global_flag = mandean_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = mandean } }
			NOR = {
				has_global_flag = mandean_china_three
				has_global_flag = mandean_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = mandean } }
			NOT = { has_global_flag = mandean_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = mandean } }
			has_global_flag = mandean_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = mandean }
						offmap_china = { offmap_has_like = likes_christians }
					}
				}
			}
			change_variable = { which = "global_chinese_mandeans" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_mandeans" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = mandean
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = mandean
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = mandean
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = mandean
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = mandean
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_christians }
					offmap_china = { offmap_ruler = { religion = mandean } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = mandean } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = mandean } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = mandean } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = mandean } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = mandean } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = mandean
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = muslim } }
					AND = {
						offmap_china = { offmap_ruler = { religion_group = christian } }
						offmap_china = { offmap_ruler = { NOT = { religion = mandean } } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = mandean
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_mandeans" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_mandeans" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = mandean } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_mandean_mission }
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = mandean
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Wax & Wane of Chaldean Christianity
character_event = {
	id = kcccimmersion.0006
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_chaldeans" value = 20 }
				NOT = { has_global_flag = chaldean_china_one }
			}
			set_global_flag = chaldean_china_one
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_chaldeans" value = 40 }
				NOT = { has_global_flag = chaldean_china_two }
			}
			set_global_flag = chaldean_china_two
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_chaldeans" value = 100 }
				NOT = { has_global_flag = chaldean_china_three }
			}
			set_global_flag = chaldean_china_three
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_chaldeans" value = 180 }
				NOT = { has_global_flag = chaldean_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = chaldean_china_four
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_chaldeans" value = 180 }
				NOT = { has_global_flag = chaldean_china_four }
			}
			set_global_flag = chaldean_china_four
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_chaldeans" value = 100 } }
				has_global_flag = chaldean_china_three
			}
			clr_global_flag = chaldean_china_three
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_chaldeans" value = 40 } }
				has_global_flag = chaldean_china_two
			}
			clr_global_flag = chaldean_china_two
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_chaldeans" value = 20 } }
				has_global_flag = chaldean_china_one
			}
			clr_global_flag = chaldean_china_one
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_chaldeans" value = 0 } }
				has_global_flag = chaldeans_in_china
			}
			clr_global_flag = chaldeans_in_china
			set_variable = { which = "global_chinese_chaldeans" value = 0 }
			set_global_flag = kcc_waxwane_chaldeans
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = chaldeans_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_christians
					has_province_modifier = kcc_china_persecuted_nonchalcedonians
					has_province_modifier = kcc_china_persecuted_chaldeans
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_christians }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = chaldean } }
			NOR = {
				has_global_flag = chaldean_china_two
				has_global_flag = chaldean_china_three
				has_global_flag = chaldean_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = chaldean } }
			NOR = {
				has_global_flag = chaldean_china_three
				has_global_flag = chaldean_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = chaldean } }
			NOT = { has_global_flag = chaldean_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = chaldean } }
			has_global_flag = chaldean_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = chaldean }
						offmap_china = { offmap_has_like = likes_christians }
					}
				}
			}
			change_variable = { which = "global_chinese_chaldeans" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_chaldeans" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = chaldean
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = chaldean
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = chaldean
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = chaldean
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = chaldean
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_christians }
					offmap_china = { offmap_ruler = { religion = chaldean } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = chaldean } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = chaldean } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = chaldean } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = chaldean } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = chaldean } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_like = likes_indians }
						d_chaldean = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_dravidians }
						d_chaldean = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_tibetans }
						d_chaldean = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_germanics }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_latino_iberians }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_byzantines }
						d_chaldean = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_celts }
						d_chaldean = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_finno_ugrics }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_altaics }
						d_chaldean = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_balto_slavics }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_arabs }
						d_chaldean = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_iranians }
						d_chaldean = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_africans }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_mesoamericans }
						d_chaldean = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = chaldean
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = muslim } }
					AND = {
						offmap_china = { offmap_ruler = { religion_group = christian } }
						offmap_china = { offmap_ruler = { NOT = { religion = chaldean } } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = chaldean } } }
					has_global_flag = d_chaldean_moved_to_china
				}
			}
			modifier = {
				factor = 4
				AND = {
					offmap_china = { offmap_ruler = { religion = chaldean } }
					has_global_flag = d_chaldean_moved_to_china
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = chaldean
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_chaldeans" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_chaldeans" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = chaldean } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_chaldean_mission }
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_dislike = likes_indians }
						d_chaldean = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_dravidians }
						d_chaldean = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_tibetans }
						d_chaldean = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_germanics }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_latino_iberians }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_byzantines }
						d_chaldean = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_celts }
						d_chaldean = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_finno_ugrics }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_altaics }
						d_chaldean = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_balto_slavics }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_arabs }
						d_chaldean = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_iranians }
						d_chaldean = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_africans }
						d_chaldean = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_mesoamericans }
						d_chaldean = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = chaldean
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Wax & Wane of Apollinarianism
character_event = {
	id = kcccimmersion.0007
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_apollinarians" value = 20 }
				NOT = { has_global_flag = apollinarian_china_one }
			}
			set_global_flag = apollinarian_china_one
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_apollinarians" value = 40 }
				NOT = { has_global_flag = apollinarian_china_two }
			}
			set_global_flag = apollinarian_china_two
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_apollinarians" value = 100 }
				NOT = { has_global_flag = apollinarian_china_three }
			}
			set_global_flag = apollinarian_china_three
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_apollinarians" value = 180 }
				NOT = { has_global_flag = apollinarian_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = apollinarian_china_four
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_apollinarians" value = 180 }
				NOT = { has_global_flag = apollinarian_china_four }
			}
			set_global_flag = apollinarian_china_four
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_apollinarians" value = 100 } }
				has_global_flag = apollinarian_china_three
			}
			clr_global_flag = apollinarian_china_three
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_apollinarians" value = 40 } }
				has_global_flag = apollinarian_china_two
			}
			clr_global_flag = apollinarian_china_two
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_apollinarians" value = 20 } }
				has_global_flag = apollinarian_china_one
			}
			clr_global_flag = apollinarian_china_one
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_apollinarians" value = 0 } }
				has_global_flag = apollinarians_in_china
			}
			clr_global_flag = apollinarians_in_china
			set_variable = { which = "global_chinese_apollinarians" value = 0 }
			set_global_flag = kcc_waxwane_apollinarians
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = apollinarians_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_christians
					has_province_modifier = kcc_china_persecuted_nonchalcedonians
					has_province_modifier = kcc_china_persecuted_apollinarians
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_christians }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = apollinarian } }
			NOR = {
				has_global_flag = apollinarian_china_two
				has_global_flag = apollinarian_china_three
				has_global_flag = apollinarian_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = apollinarian } }
			NOR = {
				has_global_flag = apollinarian_china_three
				has_global_flag = apollinarian_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = apollinarian } }
			NOT = { has_global_flag = apollinarian_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = apollinarian } }
			has_global_flag = apollinarian_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = apollinarian }
						offmap_china = { offmap_has_like = likes_christians }
					}
				}
			}
			change_variable = { which = "global_chinese_apollinarians" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_apollinarians" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = apollinarian
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = apollinarian
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = apollinarian
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = apollinarian
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = apollinarian
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_christians }
					offmap_china = { offmap_ruler = { religion = apollinarian } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = apollinarian } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = apollinarian } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = apollinarian } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = apollinarian } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = apollinarian } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_like = likes_indians }
						d_apollinarian = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_dravidians }
						d_apollinarian = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_tibetans }
						d_apollinarian = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_germanics }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_latino_iberians }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_byzantines }
						d_apollinarian = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_celts }
						d_apollinarian = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_finno_ugrics }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_altaics }
						d_apollinarian = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_balto_slavics }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_arabs }
						d_apollinarian = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_iranians }
						d_apollinarian = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_africans }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_mesoamericans }
						d_apollinarian = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = apollinarian
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = muslim } }
					AND = {
						offmap_china = { offmap_ruler = { religion_group = christian } }
						offmap_china = { offmap_ruler = { NOT = { religion = apollinarian } } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = apollinarian } } }
					has_global_flag = d_apollinarian_moved_to_china
				}
			}
			modifier = {
				factor = 4
				AND = {
					offmap_china = { offmap_ruler = { religion = apollinarian } }
					has_global_flag = d_apollinarian_moved_to_china
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = apollinarian
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_apollinarians" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_apollinarians" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = apollinarian } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_apollinarian_mission }
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_dislike = likes_indians }
						d_apollinarian = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_dravidians }
						d_apollinarian = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_tibetans }
						d_apollinarian = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_germanics }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = north_germanic
								culture_group = central_germanic
								culture_group = west_germanic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_latino_iberians }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_byzantines }
						d_apollinarian = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_celts }
						d_apollinarian = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_finno_ugrics }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_altaics }
						d_apollinarian = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_balto_slavics }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = baltic
								culture_group = east_slavic
								culture_group = west_slavic
								culture_group = south_slavic
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_arabs }
						d_apollinarian = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_iranians }
						d_apollinarian = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_africans }
						d_apollinarian = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_mesoamericans }
						d_apollinarian = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = apollinarian
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Wax & Wane of Yarsan Islam
character_event = {
	id = kcccimmersion.0008
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
	}
	
	after = {
		if = {
			limit = {
				check_variable = { which = "global_chinese_yarsans" value = 20 }
				NOT = { has_global_flag = yarsan_china_one }
			}
			set_global_flag = yarsan_china_one
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yarsans" value = 40 }
				NOT = { has_global_flag = yarsan_china_two }
			}
			set_global_flag = yarsan_china_two
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yarsans" value = 100 }
				NOT = { has_global_flag = yarsan_china_three }
			}
			set_global_flag = yarsan_china_three
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yarsans" value = 180 }
				NOT = { has_global_flag = yarsan_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = yarsan_china_four
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yarsans" value = 180 }
				NOT = { has_global_flag = yarsan_china_four }
			}
			set_global_flag = yarsan_china_four
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yarsans" value = 100 } }
				has_global_flag = yarsan_china_three
			}
			clr_global_flag = yarsan_china_three
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yarsans" value = 40 } }
				has_global_flag = yarsan_china_two
			}
			clr_global_flag = yarsan_china_two
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yarsans" value = 20 } }
				has_global_flag = yarsan_china_one
			}
			clr_global_flag = yarsan_china_one
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yarsans" value = 0 } }
				has_global_flag = yarsans_in_china
			}
			clr_global_flag = yarsans_in_china
			set_variable = { which = "global_chinese_yarsans" value = 0 }
			set_global_flag = kcc_waxwane_yarsans
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = yarsans_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_muslims
					has_province_modifier = kcc_china_persecuted_sunnis
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_muslims }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = yarsan } }
			NOR = {
				has_global_flag = yarsan_china_two
				has_global_flag = yarsan_china_three
				has_global_flag = yarsan_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = yarsan } }
			NOR = {
				has_global_flag = yarsan_china_three
				has_global_flag = yarsan_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = yarsan } }
			NOT = { has_global_flag = yarsan_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = yarsan } }
			has_global_flag = yarsan_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = yarsan }
						offmap_china = { offmap_has_like = likes_muslims }
					}
				}
			}
			change_variable = { which = "global_chinese_yarsans" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_yarsans" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yarsan
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yarsan
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
							culture_group = chinese_group
						}
					}
				}
			}
			modifier = {
				factor = 1.2
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yarsan
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yarsan
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yarsan
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_muslims }
					offmap_china = { offmap_ruler = { religion = yarsan } }
				}
			}
			modifier = {
				factor = 1.2
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = yarsan } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = yarsan } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = yarsan } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_famine
							has_status = china_plague
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				AND = {
					offmap_china = { offmap_ruler = { religion = yarsan } }
					offmap_china = {
						OR = {
							has_status = china_civil_war
							has_status = china_mongol_invasion
							has_status = china_jurchen_invasion
						}
					}
				}
			}
			modifier = {
				factor = 3
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = yarsan } } }
					offmap_china = {
						OR = {
							has_status = china_unrest
							has_status = china_civil_war
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = yarsan
					any_realm_province = {
						region = custom_eastern_access
					}
					NOR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.33
				OR = {
					offmap_china = { offmap_ruler = { religion_group = christian } }
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 0.05
				OR = {
					offmap_china = { offmap_ruler = { religion = shiite } }
					offmap_china = { offmap_ruler = { religion = qarmatian } }
					offmap_china = { offmap_ruler = { religion = hurufi } }
					AND = {
						has_game_rule = {
							name = kcc_who_can_preach
							value = kcc_preach_yes
						}
						offmap_china = { offmap_ruler = { religion = druze } }
					}
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = yarsan
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
			change_variable = { which = "global_chinese_yarsans" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_yarsans" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = yarsan } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_muslims }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_yarsan_mission }
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = yarsan
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
					}
				}
			}
		}
	}
}

# Persecute Adoptionists?
character_event = {
	id = kcccimmersion.0009
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = adoptionists_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = adoptionist } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = adoptionist
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = adoptionist
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = adoptionist_china_three
					has_global_flag = adoptionist_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_jizya
									has_religion_feature = religion_feature_west_african
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = adoptionist
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				OR = {
					offmap_china = { offmap_ruler = { religion = cathar } }
					offmap_china = { offmap_ruler = { religion = fraticelli } }
					offmap_china = { offmap_ruler = { religion = waldensian } }
					offmap_china = { offmap_ruler = { religion = lollard } }
				}
			}
			modifier = {
				factor = 1.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				kcc_latin_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_adoptionists" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_adoptionists years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_adoptionists
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_persecute_latins_effect = yes
			set_global_flag = kcc_china_bullseye_latins
		}
		else = {
			kcc_persecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = adoptionist_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = adoptionist_china_three
						has_global_flag = adoptionist_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = adoptionist_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = adoptionist_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = adoptionist_china_three
						has_global_flag = adoptionist_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = adoptionist_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_adoptionist_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = adoptionist
				}
			}
			modifier = {
				factor = 2
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 8.5
				OR = {
					offmap_china = { offmap_ruler = { religion = cathar } }
					offmap_china = { offmap_ruler = { religion = fraticelli } }
					offmap_china = { offmap_ruler = { religion = waldensian } }
					offmap_china = { offmap_ruler = { religion = lollard } }
				}
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_byzantines_trigger = yes
				kcc_can_persecute_nonchalcedonians_trigger = yes
				kcc_can_persecute_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				kcc_latin_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_adoptionists" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_adoptionists years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_adoptionists
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_overpersecute_latins_effect = yes
			set_global_flag = kcc_china_bullseye_latins
		}
		else = {
			kcc_overpersecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = adoptionist_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = adoptionist_china_three
						has_global_flag = adoptionist_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = adoptionist_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = adoptionist_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = adoptionist_china_three
						has_global_flag = adoptionist_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = adoptionist_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_adoptionist_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Byzantines
				modifier = {
					factor = 0
					kcc_can_persecute_byzantines_trigger = no
				}
				kcc_persecute_byzantines_effect = yes
				set_global_flag = kcc_china_collateral_byzantines
			}
			10 = { #Non-Chalcedonian
				modifier = {
					factor = 0
					kcc_can_persecute_nonchalcedonians_trigger = no
				}
				kcc_persecute_nonchalcedonians_effect = yes
				set_global_flag = kcc_china_collateral_nonchalcedonians
			}
			10 = { #Muslims
				modifier = {
					factor = 0
					kcc_can_persecute_muslims_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_muslims }
				}
				kcc_persecute_muslims_effect = yes
				set_global_flag = kcc_china_collateral_muslims
			}
			10 = { #Sunnis
				modifier = {
					factor = 0
					kcc_can_persecute_sunnis_trigger = no
				}
				kcc_persecute_sunnis_effect = yes
				set_global_flag = kcc_china_collateral_sunnis
			}
			10 = { #Shias
				modifier = {
					factor = 0
					kcc_can_persecute_shias_trigger = no
				}
				kcc_persecute_shias_effect = yes
				set_global_flag = kcc_china_collateral_shias
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = adoptionist
				}
			}
			modifier = {
				factor = 40
				OR = {
					offmap_china = { offmap_ruler = { religion = cathar } }
					offmap_china = { offmap_ruler = { religion = fraticelli } }
					offmap_china = { offmap_ruler = { religion = waldensian } }
					offmap_china = { offmap_ruler = { religion = lollard } }
				}
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
}

# Persecute Free Spirits?
character_event = {
	id = kcccimmersion.0010
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = free_spirits_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = free_spirits } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = free_spirits
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = free_spirits
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = free_spirits_china_three
					has_global_flag = free_spirits_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_jizya
									has_religion_feature = religion_feature_west_african
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = free_spirits
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				OR = {
					offmap_china = { offmap_ruler = { religion = cathar } }
					offmap_china = { offmap_ruler = { religion = fraticelli } }
					offmap_china = { offmap_ruler = { religion = waldensian } }
					offmap_china = { offmap_ruler = { religion = lollard } }
				}
			}
			modifier = {
				factor = 1.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				kcc_latin_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_free_spirits" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_free_spirits years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_free_spirits
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_persecute_latins_effect = yes
			set_global_flag = kcc_china_bullseye_latins
		}
		else = {
			kcc_persecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = free_spirits_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = free_spirits_china_three
						has_global_flag = free_spirits_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = free_spirits_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = free_spirits_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = free_spirits_china_three
						has_global_flag = free_spirits_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = free_spirits_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_free_spirits_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = free_spirits
				}
			}
			modifier = {
				factor = 2
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 8.5
				OR = {
					offmap_china = { offmap_ruler = { religion = cathar } }
					offmap_china = { offmap_ruler = { religion = fraticelli } }
					offmap_china = { offmap_ruler = { religion = waldensian } }
					offmap_china = { offmap_ruler = { religion = lollard } }
				}
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_byzantines_trigger = yes
				kcc_can_persecute_nonchalcedonians_trigger = yes
				kcc_can_persecute_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				kcc_latin_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_free_spirits" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_free_spirits years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_free_spirits
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_overpersecute_latins_effect = yes
			set_global_flag = kcc_china_bullseye_latins
		}
		else = {
			kcc_overpersecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = free_spirits_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = free_spirits_china_three
						has_global_flag = free_spirits_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = free_spirits_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = free_spirits_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = free_spirits_china_three
						has_global_flag = free_spirits_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = free_spirits_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_free_spirits_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Byzantines
				modifier = {
					factor = 0
					kcc_can_persecute_byzantines_trigger = no
				}
				kcc_persecute_byzantines_effect = yes
				set_global_flag = kcc_china_collateral_byzantines
			}
			10 = { #Non-Chalcedonian
				modifier = {
					factor = 0
					kcc_can_persecute_nonchalcedonians_trigger = no
				}
				kcc_persecute_nonchalcedonians_effect = yes
				set_global_flag = kcc_china_collateral_nonchalcedonians
			}
			10 = { #Muslims
				modifier = {
					factor = 0
					kcc_can_persecute_muslims_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_muslims }
				}
				kcc_persecute_muslims_effect = yes
				set_global_flag = kcc_china_collateral_muslims
			}
			10 = { #Sunnis
				modifier = {
					factor = 0
					kcc_can_persecute_sunnis_trigger = no
				}
				kcc_persecute_sunnis_effect = yes
				set_global_flag = kcc_china_collateral_sunnis
			}
			10 = { #Shias
				modifier = {
					factor = 0
					kcc_can_persecute_shias_trigger = no
				}
				kcc_persecute_shias_effect = yes
				set_global_flag = kcc_china_collateral_shias
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = free_spirits
				}
			}
			modifier = {
				factor = 40
				OR = {
					offmap_china = { offmap_ruler = { religion = cathar } }
					offmap_china = { offmap_ruler = { religion = fraticelli } }
					offmap_china = { offmap_ruler = { religion = waldensian } }
					offmap_china = { offmap_ruler = { religion = lollard } }
				}
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
}

# Persecute Barlaamites?
character_event = {
	id = kcccimmersion.0011
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = barlaamites_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = barlaamite } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = barlaamite
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = barlaamite
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = barlaamite_china_three
					has_global_flag = barlaamite_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_jizya
									has_religion_feature = religion_feature_west_african
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = barlaamite
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				OR = {
					offmap_china = { offmap_ruler = { religion = orthodox } }
					offmap_china = { offmap_ruler = { religion = iconoclast } }
					offmap_china = { offmap_ruler = { religion = bogomilist } }
					offmap_china = { offmap_ruler = { religion = monothelite } }
				}
			}
			modifier = {
				factor = 1.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				kcc_byzantine_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_barlaamites" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_barlaamites years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_barlaamites
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_persecute_byzantines_effect = yes
			set_global_flag = kcc_china_bullseye_byzantines
		}
		else = {
			kcc_persecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = barlaamite_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = barlaamite_china_three
						has_global_flag = barlaamite_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = barlaamite_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = barlaamite_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = barlaamite_china_three
						has_global_flag = barlaamite_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = barlaamite_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_barlaamite_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = barlaamite
				}
			}
			modifier = {
				factor = 2
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 8.5
				OR = {
					offmap_china = { offmap_ruler = { religion = orthodox } }
					offmap_china = { offmap_ruler = { religion = iconoclast } }
					offmap_china = { offmap_ruler = { religion = bogomilist } }
					offmap_china = { offmap_ruler = { religion = monothelite } }
				}
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_latins_trigger = yes
				kcc_can_persecute_nonchalcedonians_trigger = yes
				kcc_can_persecute_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				kcc_byzantine_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_barlaamites" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_barlaamites years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_barlaamites
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_overpersecute_byzantines_effect = yes
			set_global_flag = kcc_china_bullseye_byzantines
		}
		else = {
			kcc_overpersecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = barlaamite_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = barlaamite_china_three
						has_global_flag = barlaamite_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = barlaamite_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = barlaamite_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = barlaamite_china_three
						has_global_flag = barlaamite_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = barlaamite_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_barlaamite_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Latins
				modifier = {
					factor = 0
					kcc_can_persecute_latins_trigger = no
				}
				kcc_persecute_latins_effect = yes
				set_global_flag = kcc_china_collateral_latins
			}
			10 = { #Non-Chalcedonian
				modifier = {
					factor = 0
					kcc_can_persecute_nonchalcedonians_trigger = no
				}
				kcc_persecute_nonchalcedonians_effect = yes
				set_global_flag = kcc_china_collateral_nonchalcedonians
			}
			10 = { #Muslims
				modifier = {
					factor = 0
					kcc_can_persecute_muslims_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_muslims }
				}
				kcc_persecute_muslims_effect = yes
				set_global_flag = kcc_china_collateral_muslims
			}
			10 = { #Sunnis
				modifier = {
					factor = 0
					kcc_can_persecute_sunnis_trigger = no
				}
				kcc_persecute_sunnis_effect = yes
				set_global_flag = kcc_china_collateral_sunnis
			}
			10 = { #Shias
				modifier = {
					factor = 0
					kcc_can_persecute_shias_trigger = no
				}
				kcc_persecute_shias_effect = yes
				set_global_flag = kcc_china_collateral_shias
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = barlaamite
				}
			}
			modifier = {
				factor = 40
				OR = {
					offmap_china = { offmap_ruler = { religion = orthodox } }
					offmap_china = { offmap_ruler = { religion = iconoclast } }
					offmap_china = { offmap_ruler = { religion = bogomilist } }
					offmap_china = { offmap_ruler = { religion = monothelite } }
				}
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
}

# Persecute Judaizers?
character_event = {
	id = kcccimmersion.0012
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = judaizers_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = judaizer } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = judaizer
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = judaizer
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = judaizer_china_three
					has_global_flag = judaizer_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_jizya
									has_religion_feature = religion_feature_west_african
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = judaizer
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				offmap_china = { offmap_ruler = { religion = monophysite } }
			}
			modifier = {
				factor = 1.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_judaizers" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_judaizers years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_judaizers
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_persecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_persecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = judaizer_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = judaizer_china_three
						has_global_flag = judaizer_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = judaizer_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = judaizer_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = judaizer_china_three
						has_global_flag = judaizer_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = judaizer_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_judaizer_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = judaizer
				}
			}
			modifier = {
				factor = 2
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 8.5
				offmap_china = { offmap_ruler = { religion = monophysite } }
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_latins_trigger = yes
				kcc_can_persecute_byzantines_trigger = yes
				kcc_can_persecute_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_judaizers" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_judaizers years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_judaizers
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_overpersecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_overpersecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = judaizer_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = judaizer_china_three
						has_global_flag = judaizer_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = judaizer_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = judaizer_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = judaizer_china_three
						has_global_flag = judaizer_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = judaizer_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_judaizer_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Latins
				modifier = {
					factor = 0
					kcc_can_persecute_latins_trigger = no
				}
				kcc_persecute_latins_effect = yes
				set_global_flag = kcc_china_collateral_latins
			}
			10 = { #Byzantines
				modifier = {
					factor = 0
					kcc_can_persecute_byzantines_trigger = no
				}
				kcc_persecute_byzantines_effect = yes
				set_global_flag = kcc_china_collateral_byzantines
			}
			10 = { #Muslims
				modifier = {
					factor = 0
					kcc_can_persecute_muslims_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_muslims }
				}
				kcc_persecute_muslims_effect = yes
				set_global_flag = kcc_china_collateral_muslims
			}
			10 = { #Sunnis
				modifier = {
					factor = 0
					kcc_can_persecute_sunnis_trigger = no
				}
				kcc_persecute_sunnis_effect = yes
				set_global_flag = kcc_china_collateral_sunnis
			}
			10 = { #Shias
				modifier = {
					factor = 0
					kcc_can_persecute_shias_trigger = no
				}
				kcc_persecute_shias_effect = yes
				set_global_flag = kcc_china_collateral_shias
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = judaizer
				}
			}
			modifier = {
				factor = 40
				offmap_china = { offmap_ruler = { religion = monophysite } }
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
}

# Persecute Mandeans?
character_event = {
	id = kcccimmersion.0013
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = mandeans_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = mandean } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = mandean
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = mandean
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = mandean_china_three
					has_global_flag = mandean_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_jizya
									has_religion_feature = religion_feature_west_african
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = mandean
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				offmap_china = { offmap_ruler = { religion = monophysite } }
			}
			modifier = {
				factor = 1.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_mandeans" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_mandeans years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_mandeans
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_persecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_persecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = mandean_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = mandean_china_three
						has_global_flag = mandean_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = mandean_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = mandean_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = mandean_china_three
						has_global_flag = mandean_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = mandean_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_mandean_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = mandean
				}
			}
			modifier = {
				factor = 2
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 8.5
				offmap_china = { offmap_ruler = { religion = monophysite } }
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_latins_trigger = yes
				kcc_can_persecute_byzantines_trigger = yes
				kcc_can_persecute_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_mandeans" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_mandeans years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_mandeans
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_overpersecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_overpersecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = mandean_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = mandean_china_three
						has_global_flag = mandean_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = mandean_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = mandean_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = mandean_china_three
						has_global_flag = mandean_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = mandean_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_mandean_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Latins
				modifier = {
					factor = 0
					kcc_can_persecute_latins_trigger = no
				}
				kcc_persecute_latins_effect = yes
				set_global_flag = kcc_china_collateral_latins
			}
			10 = { #Byzantines
				modifier = {
					factor = 0
					kcc_can_persecute_byzantines_trigger = no
				}
				kcc_persecute_byzantines_effect = yes
				set_global_flag = kcc_china_collateral_byzantines
			}
			10 = { #Muslims
				modifier = {
					factor = 0
					kcc_can_persecute_muslims_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_muslims }
				}
				kcc_persecute_muslims_effect = yes
				set_global_flag = kcc_china_collateral_muslims
			}
			10 = { #Sunnis
				modifier = {
					factor = 0
					kcc_can_persecute_sunnis_trigger = no
				}
				kcc_persecute_sunnis_effect = yes
				set_global_flag = kcc_china_collateral_sunnis
			}
			10 = { #Shias
				modifier = {
					factor = 0
					kcc_can_persecute_shias_trigger = no
				}
				kcc_persecute_shias_effect = yes
				set_global_flag = kcc_china_collateral_shias
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = mandean
				}
			}
			modifier = {
				factor = 40
				offmap_china = { offmap_ruler = { religion = monophysite } }
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
}

# Persecute Chaldeans?
character_event = {
	id = kcccimmersion.0014
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = chaldeans_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = chaldean } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = chaldean
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = chaldean
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = chaldean_china_three
					has_global_flag = chaldean_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_jizya
									has_religion_feature = religion_feature_west_african
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = chaldean
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				offmap_china = { offmap_ruler = { religion = messalian } }
			}
			modifier = {
				factor = 1.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_chaldeans" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_chaldeans years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_chaldeans
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_persecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_persecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = chaldean_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = chaldean_china_three
						has_global_flag = chaldean_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = chaldean_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = chaldean_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = chaldean_china_three
						has_global_flag = chaldean_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = chaldean_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_chaldean_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = chaldean
				}
			}
			modifier = {
				factor = 2
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 8.5
				offmap_china = { offmap_ruler = { religion = messalian } }
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_latins_trigger = yes
				kcc_can_persecute_byzantines_trigger = yes
				kcc_can_persecute_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_chaldeans" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_chaldeans years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_chaldeans
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_overpersecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_overpersecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = chaldean_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = chaldean_china_three
						has_global_flag = chaldean_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = chaldean_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = chaldean_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = chaldean_china_three
						has_global_flag = chaldean_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = chaldean_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_chaldean_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Latins
				modifier = {
					factor = 0
					kcc_can_persecute_latins_trigger = no
				}
				kcc_persecute_latins_effect = yes
				set_global_flag = kcc_china_collateral_latins
			}
			10 = { #Byzantines
				modifier = {
					factor = 0
					kcc_can_persecute_byzantines_trigger = no
				}
				kcc_persecute_byzantines_effect = yes
				set_global_flag = kcc_china_collateral_byzantines
			}
			10 = { #Muslims
				modifier = {
					factor = 0
					kcc_can_persecute_muslims_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_muslims }
				}
				kcc_persecute_muslims_effect = yes
				set_global_flag = kcc_china_collateral_muslims
			}
			10 = { #Sunnis
				modifier = {
					factor = 0
					kcc_can_persecute_sunnis_trigger = no
				}
				kcc_persecute_sunnis_effect = yes
				set_global_flag = kcc_china_collateral_sunnis
			}
			10 = { #Shias
				modifier = {
					factor = 0
					kcc_can_persecute_shias_trigger = no
				}
				kcc_persecute_shias_effect = yes
				set_global_flag = kcc_china_collateral_shias
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = chaldean
				}
			}
			modifier = {
				factor = 40
				offmap_china = { offmap_ruler = { religion = messalian } }
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
}

# Persecute Apollinarians?
character_event = {
	id = kcccimmersion.0015
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = apollinarians_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = apollinarian } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = apollinarian
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = apollinarian
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = apollinarian_china_three
					has_global_flag = apollinarian_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_jizya
									has_religion_feature = religion_feature_west_african
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = apollinarian
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				offmap_china = { offmap_ruler = { religion = messalian } }
			}
			modifier = {
				factor = 1.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_apollinarians" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_apollinarians years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_apollinarians
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_persecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_persecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = apollinarian_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = apollinarian_china_three
						has_global_flag = apollinarian_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = apollinarian_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = apollinarian_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = apollinarian_china_three
						has_global_flag = apollinarian_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = apollinarian_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_apollinarian_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = apollinarian
				}
			}
			modifier = {
				factor = 2
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 8.5
				offmap_china = { offmap_ruler = { religion = messalian } }
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_latins_trigger = yes
				kcc_can_persecute_byzantines_trigger = yes
				kcc_can_persecute_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				kcc_nonchalcedonian_christians_trigger = yes
			}
			change_variable = { which = "global_chinese_apollinarians" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_apollinarians years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_apollinarians
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = christian } }
			}
			kcc_overpersecute_nonchalcedonians_effect = yes
			set_global_flag = kcc_china_bullseye_nonchalcedonians
		}
		else = {
			kcc_overpersecute_christians_effect = yes
			set_global_flag = kcc_china_bullseye_christians
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = apollinarian_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = apollinarian_china_three
						has_global_flag = apollinarian_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					has_global_flag = apollinarian_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = apollinarian_china_four
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = apollinarian_china_three
						has_global_flag = apollinarian_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = apollinarian_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_apollinarian_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Latins
				modifier = {
					factor = 0
					kcc_can_persecute_latins_trigger = no
				}
				kcc_persecute_latins_effect = yes
				set_global_flag = kcc_china_collateral_latins
			}
			10 = { #Byzantines
				modifier = {
					factor = 0
					kcc_can_persecute_byzantines_trigger = no
				}
				kcc_persecute_byzantines_effect = yes
				set_global_flag = kcc_china_collateral_byzantines
			}
			10 = { #Muslims
				modifier = {
					factor = 0
					kcc_can_persecute_muslims_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_muslims }
				}
				kcc_persecute_muslims_effect = yes
				set_global_flag = kcc_china_collateral_muslims
			}
			10 = { #Sunnis
				modifier = {
					factor = 0
					kcc_can_persecute_sunnis_trigger = no
				}
				kcc_persecute_sunnis_effect = yes
				set_global_flag = kcc_china_collateral_sunnis
			}
			10 = { #Shias
				modifier = {
					factor = 0
					kcc_can_persecute_shias_trigger = no
				}
				kcc_persecute_shias_effect = yes
				set_global_flag = kcc_china_collateral_shias
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_christians }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_christians }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = apollinarian
				}
			}
			modifier = {
				factor = 40
				offmap_china = { offmap_ruler = { religion = messalian } }
			}
			modifier = {
				factor = 0.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = muslim
							religion = manichean
						}
					}
				}
			}
		}
	}
}

# Persecute Yarsans?
character_event = {
	id = kcccimmersion.0016
	hide_window = yes
	
	is_triggered_only = yes
	
	has_dlc = "Jade Dragon"
	only_playable = yes
	
	trigger = {
		has_landed_title = e_china_west_governor
		NOR = {
			offmap_china = { has_status = china_civil_war }
			offmap_china = { has_status = china_mongol_invasion }
			offmap_china = { has_status = china_jurchen_invasion }
		}
	}
	
	after = {
		kcc_post_persecution_effect = yes
	}
	
	weight_multiplier = {
		days = 153
		modifier = {
			factor = 0
			NOT = { has_global_flag = yarsans_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			OR = {
				offmap_china = { offmap_ruler = { religion = sunni } }
				offmap_china = { offmap_ruler = { religion = zikri } }
				offmap_china = { offmap_ruler = { religion = yarsan } }
				AND = {
					NOT = { has_global_flag = EMF }
					has_game_rule = {
						name = kcc_who_can_preach
						value = kcc_preach_yes
					}
					offmap_china = { offmap_ruler = { religion = yazidi } }
				}
			}
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_muslims }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = yarsan
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = christian
							religion = zoroastrian
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
						}
					}
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					offmap_china = { has_status = china_unrest }
					offmap_china = { has_status = china_famine }
					offmap_china = { has_status = china_plague }
				}
			}
			modifier = {
				factor = 0.5
				any_playable_ruler = {
					religion = yarsan
					OR = {
						independent = yes
						is_powerful_vassal = yes
					}
					OR = {
						has_character_modifier = angered_china_modifier
						has_character_modifier = war_with_china_modifier
						has_character_modifier = failed_invasion_of_china
						has_character_modifier = china_raid_active
						has_character_modifier = china_raid_grace_cd
						has_character_modifier = chinese_missionaries_bad
					}
					primary_title = { higher_real_tier_than = DUKE }
				}
			}
			modifier = {
				factor = 2
				NOT = { offmap_china = { has_status = china_golden_age } }
				OR = {
					has_global_flag = yarsan_china_three
					has_global_flag = yarsan_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = jain
							AND = {
								religion_group = pagan_group
								OR = {
									has_religion_feature = religion_peaceful
									has_religion_feature = religion_cosmopolitan
									has_religion_feature = religion_syncretic
									has_religion_feature = religion_feature_hellenic
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						OR = {
							has_religion_feature = religion_jizya
							has_religion_feature = religion_feature_west_african
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					religion = yarsan
					realm_size = 250
					any_realm_province = {
						region = custom_eastern_access
					}
					OR = {
						has_character_modifier = peace_deal_with_china
						has_character_modifier = chinese_imperial_trade_contract
						has_character_modifier = chinese_favored_in_trade
						has_offmap_currency = { offmap = offmap_china value = 1000 }
					}
				}
			}
			modifier = {
				factor = 0.176
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = shiite
							religion = qarmatian
							religion = hurufi
							AND = {
								has_game_rule = {
									name = kcc_who_can_preach
									value = kcc_preach_yes
								}
								religion = druze
							}
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
			kcc_persecute_sunnis_effect = yes
			set_global_flag = kcc_china_bullseye_sunnis
		}
		else = {
			kcc_persecute_muslims_effect = yes
			set_global_flag = kcc_china_bullseye_muslims
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					OR = {
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_four
						}
					}
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = sunni_china_three
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_three
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_three
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							OR = {
								has_global_flag = yazidi_china_three
								has_global_flag = yazidi_china_four
							}
						}
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					OR = {
						has_global_flag = sunni_china_three
						has_global_flag = zikri_china_three
						has_global_flag = yarsan_china_three
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_three
						}
					}
				}
				modifier = {
					factor = 0
					OR = {
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_four
						}
					}
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = sunni_china_three
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_three
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_three
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							OR = {
								has_global_flag = yazidi_china_three
								has_global_flag = yazidi_china_four
							}
						}
					}
				}
				modifier = {
					factor = 0.1
					NOR = {
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_four
						}
					}
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_yarsan_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_muslims }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion_group = christian
							religion = zoroastrian
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = yarsan
				}
			}
			modifier = {
				factor = 8.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = shiite
							religion = qarmatian
							religion = hurufi
							AND = {
								has_game_rule = {
									name = kcc_who_can_preach
									value = kcc_preach_yes
								}
								religion = druze
							}
						}
					}
				}
			}
		}
	}
	
	option = { #Great Purge
		trigger = {
			OR = {
				kcc_can_persecute_christians_trigger = yes
				kcc_can_persecute_latins_trigger = yes
				kcc_can_persecute_byzantines_trigger = yes
				kcc_can_persecute_nonchalcedonians_trigger = yes
				kcc_can_persecute_mazdans_trigger = yes
				kcc_zoro_can_persecute_mazdans_trigger = yes
				kcc_can_persecute_dharmans_trigger = yes
				kcc_can_persecute_all_pagans_trigger = yes
				kcc_can_persecute_northern_pagans_trigger = yes
				kcc_can_persecute_eastern_pagans_trigger = yes
				kcc_can_persecute_classical_pagans_trigger = yes
				kcc_can_persecute_africans_trigger = yes
				kcc_can_persecute_aztecs_trigger = yes
				kcc_can_persecute_jews_trigger = yes
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
			kcc_overpersecute_sunnis_effect = yes
			set_global_flag = kcc_china_bullseye_sunnis
		}
		else = {
			kcc_overpersecute_muslims_effect = yes
			set_global_flag = kcc_china_bullseye_muslims
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					OR = {
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_four
						}
					}
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = sunni_china_three
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_three
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_three
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							OR = {
								has_global_flag = yazidi_china_three
								has_global_flag = yazidi_china_four
							}
						}
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			5 = { #Fix Unrest, Scapegoating was true after all
				modifier = {
					factor = 0.6
					OR = {
						has_global_flag = sunni_china_three
						has_global_flag = zikri_china_three
						has_global_flag = yarsan_china_three
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_three
						}
					}
				}
				modifier = {
					factor = 0
					OR = {
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_four
						}
					}
				}
				modifier = {
					factor = 0
					NOT = { offmap_china = { has_status = china_unrest } }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.4 days = 21 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = sunni_china_three
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_three
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_three
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							OR = {
								has_global_flag = yazidi_china_three
								has_global_flag = yazidi_china_four
							}
						}
					}
				}
				modifier = {
					factor = 0.1
					NOR = {
						has_global_flag = sunni_china_four
						has_global_flag = zikri_china_four
						has_global_flag = yarsan_china_four
						AND = {
							NOT = { has_global_flag = EMF }
							has_global_flag = yazidi_china_four
						}
					}
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_yarsan_civil_war
				offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
			}
		}
		random_list = {
			10 = { #Christians
				modifier = {
					factor = 0
					kcc_can_persecute_christians_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_christians }
				}
				kcc_persecute_christians_effect = yes
				set_global_flag = kcc_china_collateral_christians
			}
			10 = { #Latins
				modifier = {
					factor = 0
					kcc_can_persecute_latins_trigger = no
				}
				kcc_persecute_latins_effect = yes
				set_global_flag = kcc_china_collateral_latins
			}
			10 = { #Byzantines
				modifier = {
					factor = 0
					kcc_can_persecute_byzantines_trigger = no
				}
				kcc_persecute_byzantines_effect = yes
				set_global_flag = kcc_china_collateral_byzantines
			}
			10 = { #Non-Chalcedonian
				modifier = {
					factor = 0
					kcc_can_persecute_nonchalcedonians_trigger = no
				}
				kcc_persecute_nonchalcedonians_effect = yes
				set_global_flag = kcc_china_collateral_nonchalcedonians
			}
			10 = { #Mazdans
				modifier = {
					factor = 0
					kcc_can_persecute_mazdans_trigger = no
				}
				modifier = {
					factor = 3
					offmap_china = { offmap_has_dislike = likes_mazdans }
				}
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_collateral_mazdans
			}
			20 = { #Zoro China Mazdans
				modifier = {
					factor = 0
					kcc_zoro_can_persecute_mazdans_trigger = no
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_collateral_mazdans
			}
			10 = { #Dharmans
				modifier = {
					factor = 0
					kcc_can_persecute_dharmans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_buddhists }
						offmap_china = { offmap_has_dislike = likes_jains }
						AND = {
							has_game_rule = {
								name = kcc_who_can_preach
								value = kcc_preach_yes
							}
							offmap_china = { offmap_has_dislike = likes_hindus }
						}
					}
				}
				kcc_persecute_dharmans_effect = yes
				set_global_flag = kcc_china_collateral_dharmans
			}
			10 = { #All Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_all_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						AND = {
							offmap_china = { offmap_has_dislike = likes_tengris }
							has_global_flag = tengri_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_zunists }
							has_global_flag = zun_in_china
						}
						AND = {
							offmap_china = { offmap_has_dislike = likes_bon }
							has_global_flag = bon_in_china
						}
					}
				}
				kcc_persecute_all_pagans_effect = yes
				set_global_flag = kcc_china_collateral_pagans
			}
			10 = { #Northern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_northern_pagans_trigger = no
				}
				kcc_persecute_northern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_northern_pagans
			}
			10 = { #Eastern Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_eastern_pagans_trigger = no
				}
				modifier = {
					factor = 3
					OR = {
						offmap_china = { offmap_has_dislike = likes_tengris }
						offmap_china = { offmap_has_dislike = likes_zunists }
						offmap_china = { offmap_has_dislike = likes_bon }
					}
				}
				kcc_persecute_eastern_pagans_effect = yes
				set_global_flag = kcc_china_collateral_eastern_pagans
			}
			10 = { #Classical Pagans
				modifier = {
					factor = 0
					kcc_can_persecute_classical_pagans_trigger = no
				}
				kcc_persecute_classical_pagans_effect = yes
				set_global_flag = kcc_china_collateral_classical_pagans
			}
			10 = { #Africans
				modifier = {
					factor = 0
					kcc_can_persecute_africans_trigger = no
				}
				kcc_persecute_africans_effect = yes
				set_global_flag = kcc_china_collateral_africans
			}
			10 = { #Aztecs
				modifier = {
					factor = 0
					kcc_can_persecute_aztecs_trigger = no
				}
				kcc_persecute_aztecs_effect = yes
				set_global_flag = kcc_china_collateral_aztecs
			}
			20 = { #Jews
				modifier = {
					factor = 0
					kcc_can_persecute_jews_trigger = no
				}
				kcc_persecute_jews_effect = yes
				set_global_flag = kcc_china_collateral_jews
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_muslims }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_muslims }
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = yarsan
				}
			}
			modifier = {
				factor = 40
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = shiite
							religion = qarmatian
							religion = hurufi
							AND = {
								has_game_rule = {
									name = kcc_who_can_preach
									value = kcc_preach_yes
								}
								religion = druze
							}
						}
					}
				}
			}
		}
	}
}