namespace = kcclastvanilla

### Religions in China

# Wax & Wane of Yazidism
character_event = {
	id = kcclastvanilla.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_yazidis" value = 20 }
				NOT = { has_global_flag = yazidi_china_one }
			}
			set_global_flag = yazidi_china_one
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yazidis" value = 40 }
				NOT = { has_global_flag = yazidi_china_two }
			}
			set_global_flag = yazidi_china_two
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yazidis" value = 100 }
				NOT = { has_global_flag = yazidi_china_three }
			}
			set_global_flag = yazidi_china_three
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yazidis" value = 180 }
				NOT = { has_global_flag = yazidi_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = yazidi_china_four
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_yazidis" value = 180 }
				NOT = { has_global_flag = yazidi_china_four }
			}
			set_global_flag = yazidi_china_four
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yazidis" value = 100 } }
				has_global_flag = yazidi_china_three
			}
			clr_global_flag = yazidi_china_three
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yazidis" value = 40 } }
				has_global_flag = yazidi_china_two
			}
			clr_global_flag = yazidi_china_two
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yazidis" value = 20 } }
				has_global_flag = yazidi_china_one
			}
			clr_global_flag = yazidi_china_one
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_yazidis" value = 0 } }
				has_global_flag = yazidis_in_china
			}
			clr_global_flag = yazidis_in_china
			set_variable = { which = "global_chinese_yazidis" value = 0 }
			set_global_flag = kcc_waxwane_yazidis
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = yazidis_in_china }
		}
		modifier = {
			factor = 0
			1513 = { 
				OR = {
					AND = {
						NOT = { has_global_flag = EMF }
						OR = {
							has_province_modifier = kcc_china_persecuted_muslims
							has_province_modifier = kcc_china_persecuted_sunnis
						}
					}
					AND = {
						has_global_flag = EMF
						OR = {
							has_province_modifier = kcc_china_persecuted_mazdans
							has_province_modifier = kcc_zoro_china_persecuted_mazdans
							has_province_modifier = kcc_china_persecuted_yazidis
						}
					}
				}
			}
		}
		modifier = {
			factor = 2
			NOT = { has_global_flag = EMF }
			offmap_china = { offmap_has_like = likes_muslims }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = yazidi } }
			NOR = {
				has_global_flag = yazidi_china_two
				has_global_flag = yazidi_china_three
				has_global_flag = yazidi_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = yazidi } }
			NOR = {
				has_global_flag = yazidi_china_three
				has_global_flag = yazidi_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = yazidi } }
			NOT = { has_global_flag = yazidi_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = yazidi } }
			has_global_flag = yazidi_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = yazidi }
						AND = {
							NOT = { has_global_flag = EMF }
							offmap_china = { offmap_has_like = likes_muslims }
						}
					}
				}
			}
			change_variable = { which = "global_chinese_yazidis" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_yazidis" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yazidi
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yazidi
						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 = yazidi
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yazidi
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = yazidi
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = {
						AND = {
							NOT = { has_global_flag = EMF }
							offmap_china = { offmap_has_like = likes_muslims }
						}
					}
					offmap_china = { offmap_ruler = { religion = yazidi } }
				}
			}
			modifier = {
				factor = 1.2
				NOT = { has_global_flag = EMF }
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = yazidi } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = yazidi } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = yazidi } }
					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 = yazidi } }
					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 = yazidi } } }
					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_yazidi = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_dravidians }
						d_yazidi = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_tibetans }
						d_yazidi = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_germanics }
						d_yazidi = { 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_yazidi = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_byzantines }
						d_yazidi = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_celts }
						d_yazidi = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_finno_ugrics }
						d_yazidi = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_altaics }
						d_yazidi = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_balto_slavics }
						d_yazidi = { 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_yazidi = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_iranians }
						d_yazidi = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_africans }
						d_yazidi = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_mesoamericans }
						d_yazidi = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = yazidi
					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 = {
					AND = {
						NOT = { has_global_flag = EMF }
						offmap_china = { offmap_ruler = { religion_group = christian } }
					}
					AND = {
						has_global_flag = EMF
						offmap_china = { offmap_ruler = { religion = zoroastrian } }
					}
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = yazidi } } }
					has_global_flag = yazidi_chinese_sheikhdom
				}
			}
			modifier = {
				factor = 4
				AND = {
					offmap_china = { offmap_ruler = { religion = yazidi } }
					has_global_flag = yazidi_chinese_sheikhdom
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = yazidi
					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_yazidis" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_yazidis" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = yazidi } }
			}
			modifier = {
				factor = 0
				NOT = { has_global_flag = EMF }
				offmap_china = { offmap_has_like = likes_muslims }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_yazidi_mission }
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_dislike = likes_indians }
						d_yazidi = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_dravidians }
						d_yazidi = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_tibetans }
						d_yazidi = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_germanics }
						d_yazidi = { 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_yazidi = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_byzantines }
						d_yazidi = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_celts }
						d_yazidi = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_finno_ugrics }
						d_yazidi = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_altaics }
						d_yazidi = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_balto_slavics }
						d_yazidi = { 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_yazidi = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_iranians }
						d_yazidi = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_africans }
						d_yazidi = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_mesoamericans }
						d_yazidi = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = yazidi
					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 Druze Islam
character_event = {
	id = kcclastvanilla.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_druzes" value = 20 }
				NOT = { has_global_flag = druze_china_one }
			}
			set_global_flag = druze_china_one
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_druzes" value = 40 }
				NOT = { has_global_flag = druze_china_two }
			}
			set_global_flag = druze_china_two
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_druzes" value = 100 }
				NOT = { has_global_flag = druze_china_three }
			}
			set_global_flag = druze_china_three
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_druzes" value = 180 }
				NOT = { has_global_flag = druze_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = druze_china_four
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_druzes" value = 180 }
				NOT = { has_global_flag = druze_china_four }
			}
			set_global_flag = druze_china_four
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_druzes" value = 100 } }
				has_global_flag = druze_china_three
			}
			clr_global_flag = druze_china_three
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_druzes" value = 40 } }
				has_global_flag = druze_china_two
			}
			clr_global_flag = druze_china_two
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_druzes" value = 20 } }
				has_global_flag = druze_china_one
			}
			clr_global_flag = druze_china_one
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_druzes" value = 0 } }
				has_global_flag = druze_in_china
			}
			clr_global_flag = druze_in_china
			set_variable = { which = "global_chinese_druzes" value = 0 }
			set_global_flag = kcc_waxwane_druze
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = druze_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_muslims
					has_province_modifier = kcc_china_persecuted_shiites
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_muslims }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = druze } }
			NOR = {
				has_global_flag = druze_china_two
				has_global_flag = druze_china_three
				has_global_flag = druze_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = druze } }
			NOR = {
				has_global_flag = druze_china_three
				has_global_flag = druze_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = druze } }
			NOT = { has_global_flag = druze_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = druze } }
			has_global_flag = druze_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = druze }
						offmap_china = { offmap_has_like = likes_muslims }
					}
				}
			}
			change_variable = { which = "global_chinese_druzes" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_druzes" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = druze
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = druze
						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 = druze
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = druze
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = druze
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_muslims }
					offmap_china = { offmap_ruler = { religion = druze } }
				}
			}
			modifier = {
				factor = 1.2
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = druze } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = druze } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = druze } }
					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 = druze } }
					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 = druze } } }
					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 = druze
					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 = sunni } }
					offmap_china = { offmap_ruler = { religion = zikri } }
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = druze
					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_druzes" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_druzes" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = druze } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_muslims }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_druze_mission }
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = druze
					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 Khurmatzas
character_event = {
	id = kcclastvanilla.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_khurmaztas" value = 20 }
				NOT = { has_global_flag = khurmazta_china_one }
			}
			set_global_flag = khurmazta_china_one
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_khurmaztas" value = 40 }
				NOT = { has_global_flag = khurmazta_china_two }
			}
			set_global_flag = khurmazta_china_two
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_khurmaztas" value = 100 }
				NOT = { has_global_flag = khurmazta_china_three }
			}
			set_global_flag = khurmazta_china_three
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_khurmaztas" value = 180 }
				NOT = { has_global_flag = khurmazta_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = khurmazta_china_four
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_khurmaztas" value = 180 }
				NOT = { has_global_flag = khurmazta_china_four }
			}
			set_global_flag = khurmazta_china_four
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_khurmaztas" value = 100 } }
				has_global_flag = khurmazta_china_three
			}
			clr_global_flag = khurmazta_china_three
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_khurmaztas" value = 40 } }
				has_global_flag = khurmazta_china_two
			}
			clr_global_flag = khurmazta_china_two
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_khurmaztas" value = 20 } }
				has_global_flag = khurmazta_china_one
			}
			clr_global_flag = khurmazta_china_one
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_khurmaztas" value = 0 } }
				has_global_flag = khurmaztas_in_china
			}
			clr_global_flag = khurmaztas_in_china
			set_variable = { which = "global_chinese_khurmaztas" value = 0 }
			set_global_flag = kcc_waxwane_khurmaztas
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = khurmaztas_in_china }
		}
		modifier = {
			factor = 0
			1513 = {
				OR = {
					has_province_modifier = kcc_china_persecuted_mazdans
					has_province_modifier = kcc_zoro_china_persecuted_mazdans
					has_province_modifier = kcc_china_persecuted_khurmaztas
				}
			}
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_khurmaztans }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = khurmazta } }
			NOR = {
				has_global_flag = khurmazta_china_two
				has_global_flag = khurmazta_china_three
				has_global_flag = khurmazta_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = khurmazta } }
			NOR = {
				has_global_flag = khurmazta_china_three
				has_global_flag = khurmazta_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = khurmazta } }
			NOT = { has_global_flag = khurmazta_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = khurmazta } }
			has_global_flag = khurmazta_china_four
		}
		modifier = {
			factor = 1.33
			offmap_china = { offmap_ruler = { is_female = yes } }
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = khurmazta }
						offmap_china = { offmap_has_like = likes_khurmaztans }
					}
				}
			}
			change_variable = { which = "global_chinese_khurmaztas" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_khurmaztas" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = khurmazta
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = khurmazta
						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 = khurmazta
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = khurmazta
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = khurmazta
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_khurmaztans }
					offmap_china = { offmap_ruler = { religion = khurmazta } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = khurmazta } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = khurmazta } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = khurmazta } }
					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 = khurmazta } }
					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 = khurmazta } } }
					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 = khurmazta
					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 = zoroastrian } }
					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 = khurmazta
					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_khurmaztas" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_khurmaztas" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = khurmazta } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_khurmaztans }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_khurmazta_mission }
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = khurmazta
					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 Rabbinical Judaism
character_event = {
	id = kcclastvanilla.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_jewishs" value = 20 }
				NOT = { has_global_flag = jewish_china_one }
			}
			set_global_flag = jewish_china_one
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_jewishs" value = 40 }
				NOT = { has_global_flag = jewish_china_two }
			}
			set_global_flag = jewish_china_two
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_jewishs" value = 100 }
				NOT = { has_global_flag = jewish_china_three }
			}
			set_global_flag = jewish_china_three
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_jewishs" value = 180 }
				NOT = { has_global_flag = jewish_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = jewish_china_four
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_jewishs" value = 180 }
				NOT = { has_global_flag = jewish_china_four }
			}
			set_global_flag = jewish_china_four
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_jewishs" value = 100 } }
				has_global_flag = jewish_china_three
			}
			clr_global_flag = jewish_china_three
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_jewishs" value = 40 } }
				has_global_flag = jewish_china_two
			}
			clr_global_flag = jewish_china_two
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_jewishs" value = 20 } }
				has_global_flag = jewish_china_one
			}
			clr_global_flag = jewish_china_one
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_jewishs" value = 0 } }
				has_global_flag = jews_in_china
			}
			clr_global_flag = jews_in_china
			set_variable = { which = "global_chinese_jewishs" value = 0 }
			set_global_flag = kcc_waxwane_jews
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = jews_in_china }
		}
		modifier = {
			factor = 0
			1513 = { has_province_modifier = kcc_china_persecuted_jews }
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_jews }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOR = {
				has_global_flag = jewish_china_two
				has_global_flag = jewish_china_three
				has_global_flag = jewish_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOR = {
				has_global_flag = jewish_china_three
				has_global_flag = jewish_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOT = { has_global_flag = jewish_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			has_global_flag = jewish_china_four
		}
		modifier = {
			factor = 0.33
			offmap_china = { offmap_ruler = { religion = taoist } }
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion_group = jewish_group }
						offmap_china = { offmap_has_like = likes_jews }
					}
				}
			}
			change_variable = { which = "global_chinese_jewishs" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_jewishs" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = jewish
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = jewish
						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 = jewish
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = jewish
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = jewish
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_jews }
					offmap_china = { offmap_ruler = { religion_group = jewish_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = jewish } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = jewish } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = jewish } }
					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 = jewish } }
					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 = jewish } } }
					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_jewish = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_dravidians }
						d_jewish = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_tibetans }
						d_jewish = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_germanics }
						d_jewish = { 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_jewish = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_byzantines }
						d_jewish = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_celts }
						d_jewish = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_finno_ugrics }
						d_jewish = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_altaics }
						d_jewish = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_balto_slavics }
						d_jewish = { 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_jewish = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_iranians }
						d_jewish = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_like = likes_africans }
						d_jewish = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_like = likes_mesoamericans }
						d_jewish = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = jewish
					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 } }
					offmap_china = { offmap_ruler = { religion_group = christian } }
					offmap_china = { offmap_ruler = { religion_group = zoroastrian_group } }
					offmap_china = {
						offmap_ruler = {
							religion_group = pagan_group
							has_religion_feature = religion_dogmatic
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				AND = {
					offmap_china = { offmap_ruler = { NOT = { religion = jewish } } }
					has_global_flag = d_jewish_moved_to_china
				}
			}
			modifier = {
				factor = 4
				AND = {
					offmap_china = { offmap_ruler = { religion = jewish } }
					has_global_flag = d_jewish_moved_to_china
				}
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = jewish
					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_jewishs" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_jewishs" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = jewish } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_jews }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_jewish_mission }
			}
			modifier = {
				factor = 2
				OR = {
					AND = {
						offmap_china = { offmap_has_dislike = likes_indians }
						d_jewish = { holder_scope = { culture_group = indo_aryan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_dravidians }
						d_jewish = { holder_scope = { culture_group = dravidian_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_tibetans }
						d_jewish = { holder_scope = { culture_group = tibetan_group } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_germanics }
						d_jewish = { 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_jewish = { holder_scope = {
							OR = {
								culture_group = latin
								culture_group = iberian
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_byzantines }
						d_jewish = { holder_scope = { culture_group = byzantine } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_celts }
						d_jewish = { holder_scope = { culture_group = celtic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_finno_ugrics }
						d_jewish = { holder_scope = {
							OR = {
								culture_group = finno_ugric
								culture_group = magyar
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_altaics }
						d_jewish = { holder_scope = { culture_group = altaic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_balto_slavics }
						d_jewish = { 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_jewish = { holder_scope = { culture_group = arabic } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_iranians }
						d_jewish = { holder_scope = { culture_group = iranian } }
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_africans }
						d_jewish = { holder_scope = {
							OR = {
								culture_group = west_african
								culture_group = east_african
							} }
						}
					}
					AND = {
						offmap_china = { offmap_has_dislike = likes_mesoamericans }
						d_jewish = { holder_scope = { culture_group = mesoamerican } }
					}
				}
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = jewish
					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 Samaritanism
character_event = {
	id = kcclastvanilla.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_samaritans" value = 20 }
				NOT = { has_global_flag = samaritan_china_one }
			}
			set_global_flag = samaritan_china_one
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_samaritans" value = 40 }
				NOT = { has_global_flag = samaritan_china_two }
			}
			set_global_flag = samaritan_china_two
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_samaritans" value = 100 }
				NOT = { has_global_flag = samaritan_china_three }
			}
			set_global_flag = samaritan_china_three
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_samaritans" value = 180 }
				NOT = { has_global_flag = samaritan_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = samaritan_china_four
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_samaritans" value = 180 }
				NOT = { has_global_flag = samaritan_china_four }
			}
			set_global_flag = samaritan_china_four
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_samaritans" value = 100 } }
				has_global_flag = samaritan_china_three
			}
			clr_global_flag = samaritan_china_three
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_samaritans" value = 40 } }
				has_global_flag = samaritan_china_two
			}
			clr_global_flag = samaritan_china_two
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_samaritans" value = 20 } }
				has_global_flag = samaritan_china_one
			}
			clr_global_flag = samaritan_china_one
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_samaritans" value = 0 } }
				has_global_flag = samaritans_in_china
			}
			clr_global_flag = samaritans_in_china
			set_variable = { which = "global_chinese_samaritans" value = 0 }
			set_global_flag = kcc_waxwane_samaritans
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = samaritans_in_china }
		}
		modifier = {
			factor = 0
			1513 = { has_province_modifier = kcc_china_persecuted_jews }
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_jews }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOR = {
				has_global_flag = samaritan_china_two
				has_global_flag = samaritan_china_three
				has_global_flag = samaritan_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOR = {
				has_global_flag = samaritan_china_three
				has_global_flag = samaritan_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOT = { has_global_flag = samaritan_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			has_global_flag = samaritan_china_four
		}
		modifier = {
			factor = 0.33
			offmap_china = { offmap_ruler = { religion = taoist } }
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion_group = jewish_group }
						offmap_china = { offmap_has_like = likes_jews }
					}
				}
			}
			change_variable = { which = "global_chinese_samaritans" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_samaritans" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = samaritan
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = samaritan
						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 = samaritan
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = samaritan
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = samaritan
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_jews }
					offmap_china = { offmap_ruler = { religion_group = jewish_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = samaritan } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = samaritan } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = samaritan } }
					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 = samaritan } }
					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 = samaritan } } }
					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 = samaritan
					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 } }
					offmap_china = { offmap_ruler = { religion_group = christian } }
					offmap_china = { offmap_ruler = { religion_group = zoroastrian_group } }
					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 = samaritan
					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_samaritans" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_samaritans" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = samaritan } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_jews }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_samaritan_mission }
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = samaritan
					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 Karaite Judaism
character_event = {
	id = kcclastvanilla.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_karaites" value = 20 }
				NOT = { has_global_flag = karaite_china_one }
			}
			set_global_flag = karaite_china_one
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_karaites" value = 40 }
				NOT = { has_global_flag = karaite_china_two }
			}
			set_global_flag = karaite_china_two
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_karaites" value = 100 }
				NOT = { has_global_flag = karaite_china_three }
			}
			set_global_flag = karaite_china_three
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_karaites" value = 180 }
				NOT = { has_global_flag = karaite_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = karaite_china_four
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_karaites" value = 180 }
				NOT = { has_global_flag = karaite_china_four }
			}
			set_global_flag = karaite_china_four
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_karaites" value = 100 } }
				has_global_flag = karaite_china_three
			}
			clr_global_flag = karaite_china_three
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_karaites" value = 40 } }
				has_global_flag = karaite_china_two
			}
			clr_global_flag = karaite_china_two
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_karaites" value = 20 } }
				has_global_flag = karaite_china_one
			}
			clr_global_flag = karaite_china_one
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_karaites" value = 0 } }
				has_global_flag = karaites_in_china
			}
			clr_global_flag = karaites_in_china
			set_variable = { which = "global_chinese_karaites" value = 0 }
			set_global_flag = kcc_waxwane_karaites
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = karaites_in_china }
		}
		modifier = {
			factor = 0
			1513 = { has_province_modifier = kcc_china_persecuted_jews }
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_jews }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOR = {
				has_global_flag = karaite_china_two
				has_global_flag = karaite_china_three
				has_global_flag = karaite_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOR = {
				has_global_flag = karaite_china_three
				has_global_flag = karaite_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			NOT = { has_global_flag = karaite_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
			has_global_flag = karaite_china_four
		}
		modifier = {
			factor = 0.33
			offmap_china = { offmap_ruler = { religion = taoist } }
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion_group = jewish_group }
						offmap_china = { offmap_has_like = likes_jews }
					}
				}
			}
			change_variable = { which = "global_chinese_karaites" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_karaites" value = 1 }
		}
		
		ai_chance = {
			factor = 60
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = karaite
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = karaite
						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 = karaite
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = karaite
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = karaite
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_jews }
					offmap_china = { offmap_ruler = { religion_group = jewish_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = karaite } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = karaite } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = karaite } }
					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 = karaite } }
					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 = karaite } } }
					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 = karaite
					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 } }
					offmap_china = { offmap_ruler = { religion_group = christian } }
					offmap_china = { offmap_ruler = { religion_group = zoroastrian_group } }
					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 = karaite
					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_karaites" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_karaites" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = karaite } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_jews }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_karaite_mission }
			}
			modifier = {
				factor = 1.5
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = karaite
					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 Hinduism
character_event = {
	id = kcclastvanilla.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_hindus" value = 20 }
				NOT = { has_global_flag = hindu_china_one }
			}
			set_global_flag = hindu_china_one
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0003 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_hindus" value = 40 }
				NOT = { has_global_flag = hindu_china_two }
			}
			set_global_flag = hindu_china_two
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0004 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_hindus" value = 100 }
				NOT = { has_global_flag = hindu_china_three }
			}
			set_global_flag = hindu_china_three
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0005 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_hindus" value = 180 }
				NOT = { has_global_flag = hindu_china_four }
				kcc_nontaoist_majority_trigger = yes
			}
			kcc_drop_other_religion_effect = yes
			set_global_flag = hindu_china_four
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0007 days = 1 } }
		}
		else_if = {
			limit = {
				check_variable = { which = "global_chinese_hindus" value = 180 }
				NOT = { has_global_flag = hindu_china_four }
			}
			set_global_flag = hindu_china_four
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0006 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_hindus" value = 100 } }
				has_global_flag = hindu_china_three
			}
			clr_global_flag = hindu_china_three
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0008 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_hindus" value = 40 } }
				has_global_flag = hindu_china_two
			}
			clr_global_flag = hindu_china_two
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0009 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_hindus" value = 20 } }
				has_global_flag = hindu_china_one
			}
			clr_global_flag = hindu_china_one
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0010 days = 1 } }
		}
		else_if = {
			limit = {
				NOT = { check_variable = { which = "global_chinese_hindus" value = 0 } }
				has_global_flag = hindus_in_china
			}
			clr_global_flag = hindus_in_china
			set_variable = { which = "global_chinese_hindus" value = 0 }
			set_global_flag = kcc_waxwane_hindus
			any_playable_ruler = { narrative_event = { id = kccspread.0011 days = 1 } }
		}
	}
	
	weight_multiplier = {
		days = 17
		modifier = {
			factor = 0
			NOT = { has_global_flag = hindus_in_china }
		}
		modifier = {
			factor = 0
			1513 = { has_province_modifier = kcc_china_persecuted_dharmans }
		}
		modifier = {
			factor = 2
			offmap_china = { offmap_has_like = likes_hindus }
		}
		modifier = {
			factor = 5
			offmap_china = { offmap_ruler = { religion = hindu } }
			NOR = {
				has_global_flag = hindu_china_two
				has_global_flag = hindu_china_three
				has_global_flag = hindu_china_four
			}
		}
		modifier = {
			factor = 4
			offmap_china = { offmap_ruler = { religion = hindu } }
			NOR = {
				has_global_flag = hindu_china_three
				has_global_flag = hindu_china_four
			}
		}
		modifier = {
			factor = 1.5
			offmap_china = { offmap_ruler = { religion = hindu } }
			NOT = { has_global_flag = hindu_china_four }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = hindu } }
			has_global_flag = hindu_china_four
		}
	}
	
	option = { #No change
	
		ai_chance = {
			factor = 30
		}
	}
	
	option = { #Wax
		if = {
			limit = {
				offmap_china = {
					OR = {
						offmap_ruler = { religion = hindu }
						offmap_china = { offmap_has_like = likes_hindus }
					}
				}
			}
			change_variable = { which = "global_chinese_hindus" value = 2 }
		}
		else = {
			change_variable = { which = "global_chinese_hindus" value = 1 }
		}
		
		ai_chance = {
			factor = 70
			modifier = {
				factor = 1.1
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = hindu
						culture = mongol
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = hindu
						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 = hindu
						OR = {
							culture = khitan
							culture = tangut
							culture = jurchen
						}
					}
				}
				NOT = {
					any_province = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = hindu
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 1.3
				any_province = {
					AND = {
						OR = {
							region = custom_eastern_access
							region = world_india
						}
						religion = hindu
						culture_group = chinese_group
					}
				}
			}
			modifier = {
				factor = 5
				OR = {
					offmap_china = { offmap_has_like = likes_hindus }
					offmap_china = { offmap_ruler = { religion = hindu } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = hindu } }
					offmap_china = { offmap_ruler = { culture_group = chinese_group } }
				}
			}
			modifier = {
				factor = 1.5
				AND = {
					offmap_china = { offmap_ruler = { religion = hindu } }
					offmap_china = { has_status = china_golden_age }
				}
			}
			modifier = {
				factor = 0.2
				AND = {
					offmap_china = { offmap_ruler = { religion = hindu } }
					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 = hindu } }
					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 = hindu } } }
					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 = hindu
					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
				offmap_china = {
					offmap_ruler = {
						religion_group = pagan_group
						has_religion_feature = religion_dogmatic
					}
				}
			}
			modifier = {
				factor = 1.33
				offmap_china = { offmap_ruler = { is_female = yes } }
			}
		}
	}
	
	option = { #Wane
		if = {
			limit = {
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = hindu
					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_hindus" value = -2 }
		}
		else = {
			change_variable = { which = "global_chinese_hindus" value = -1 }
		}
	
		ai_chance = {
			factor = 30
			modifier = {
				factor = 0
				offmap_china = { offmap_ruler = { religion = hindu } }
			}
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_hindus }
			}
			modifier = {
				factor = 0.1
				1513 = { has_province_modifier = kcc_recent_hindu_mission }
			}
			modifier = {
				factor = 2
				any_playable_ruler = {
					independent = yes
					primary_title = { higher_tier_than = DUKE }
					religion = hindu
					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 Yazidis?
character_event = {
	id = kcclastvanilla.0008
	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 = yazidis_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			NOT = { has_global_flag = EMF }
			OR = {
				offmap_china = { offmap_ruler = { religion = sunni } }
				offmap_china = { offmap_ruler = { religion = zikri } }
			}
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = yazidi } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				NOT = { has_global_flag = EMF }
				offmap_china = { offmap_has_dislike = likes_muslims }
			}
			modifier = {
				factor = 0
				has_global_flag = EMF
				offmap_china = { offmap_has_dislike = likes_mazdans }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = yazidi
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								NOT = { has_global_flag = EMF }
								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 = yazidi
					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 = yazidi_china_three
					has_global_flag = yazidi_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 = {
							AND = {
								NOT = { has_global_flag = EMF }
								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 = yazidi
					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
				NOT = { has_global_flag = EMF }
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = shiite
							religion = qarmatian
							religion = hurufi
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = { NOT = { has_global_flag = EMF } }
			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
			}
		}
		else = {
			if = {
				limit = {
					offmap_china = {
						offmap_ruler = {
							religion_group = zoroastrian_group
							NOT = { religion = zoroastrian }
						}
					}
				}
				change_variable = { which = "global_chinese_yazidis" value = -30 }
				1513 = { add_province_modifier = { name = kcc_china_persecuted_yazidis years = 40 hidden = yes } }
				set_global_flag = kcc_china_bullseye_yazidis
			}
			else_if = {
				limit = {
					offmap_china = { offmap_ruler = { religion = zoroastrian } }
				}
				kcc_zoro_persecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_bullseye_mazdans
			}
			else = {
				kcc_persecute_mazdans_effect = yes
				set_global_flag = kcc_china_bullseye_mazdans
			}
		}
		if = {
			limit = { NOT = { has_global_flag = EMF } }
			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
							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
							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
							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
							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
							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
							has_global_flag = yazidi_china_four
						}
					}
					modifier = {
						factor = 3
						offmap_china = { has_status = china_unrest }
					}
					set_global_flag = kcc_yazidi_civil_war
					offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
				}
			}
		}
		else = {
			random_list = {
				40 = { #No Effect
					modifier = {
						factor = 2
						offmap_china = { has_status = china_golden_age }
					}
					modifier = {
						factor = 0.5
						has_global_flag = yazidi_china_four
					}
				}
				20 = { #Unrest
					modifier = {
						factor = 0
						NOR = {
							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
						has_global_flag = yazidi_china_three
					}
					modifier = {
						factor = 0
						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 = yazidi_china_three
							has_global_flag = yazidi_china_four
						}
					}
					modifier = {
						factor = 0.1
						NOT = { has_global_flag = yazidi_china_four }
					}
					modifier = {
						factor = 3
						offmap_china = { has_status = china_unrest }
					}
					set_global_flag = kcc_yazidi_civil_war
					offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
				}
			}
		}
		
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				NOT = { has_global_flag = EMF }
				offmap_china = { offmap_has_like = likes_muslims }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								NOT = { has_global_flag = EMF }
								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 = yazidi
				}
			}
			modifier = {
				factor = 8.5
				NOT = { has_global_flag = EMF }
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = shiite
							religion = qarmatian
							religion = hurufi
						}
					}
				}
			}
		}
	}
	
	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_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 = { NOT = { has_global_flag = EMF } }
			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
			}
		}
		else = {
			if = {
				limit = {
					offmap_china = {
						offmap_ruler = {
							religion_group = zoroastrian_group
							NOT = { religion = zoroastrian }
						}
					}
				}
				change_variable = { which = "global_chinese_yazidis" value = -45 }
				1513 = { add_province_modifier = { name = kcc_china_persecuted_yazidis years = 60 hidden = yes } }
				set_global_flag = kcc_china_bullseye_yazidis
			}
			else_if = {
				limit = {
					offmap_china = { offmap_ruler = { religion = zoroastrian } }
				}
				kcc_zoro_overpersecute_mazdans_effect = yes
				set_global_flag = kcc_zoro_china_bullseye_mazdans
			}
			else = {
				kcc_overpersecute_mazdans_effect = yes
				set_global_flag = kcc_china_bullseye_mazdans
			}
		}
		if = {
			limit = { NOT = { has_global_flag = EMF } }
			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
							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
							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
							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
							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
							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
							has_global_flag = yazidi_china_four
						}
					}
					modifier = {
						factor = 3
						offmap_china = { has_status = china_unrest }
					}
					set_global_flag = kcc_yazidi_civil_war
					offmap_china = { governor = { character_event = { id = kccdragontamer.5 days = 11 } } }
				}
			}
		}
		else = {
			random_list = {
				40 = { #No Effect
					modifier = {
						factor = 2
						offmap_china = { has_status = china_golden_age }
					}
					modifier = {
						factor = 0.5
						has_global_flag = yazidi_china_four
					}
				}
				20 = { #Unrest
					modifier = {
						factor = 0
						NOR = {
							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
						has_global_flag = yazidi_china_three
					}
					modifier = {
						factor = 0
						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 = yazidi_china_three
							has_global_flag = yazidi_china_four
						}
					}
					modifier = {
						factor = 0.1
						NOT = { has_global_flag = yazidi_china_four }
					}
					modifier = {
						factor = 3
						offmap_china = { has_status = china_unrest }
					}
					set_global_flag = kcc_zikri_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 = { #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 }
						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
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				NOT = { has_global_flag = EMF }
				offmap_china = { offmap_has_like = likes_muslims }
			}
			modifier = {
				factor = 10
				NOT = { has_global_flag = EMF }
				offmap_china = { offmap_has_dislike = likes_muslims }
			}
			modifier = {
				factor = 10
				has_global_flag = EMF
				offmap_china = { offmap_has_dislike = likes_mazdans }
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = yazidi
				}
			}
			modifier = {
				factor = 40
				NOT = { has_global_flag = EMF }
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = shiite
							religion = qarmatian
							religion = hurufi
						}
					}
				}
			}
		}
	}
}

# Persecute Druze?
character_event = {
	id = kcclastvanilla.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 = druze_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			OR = {
				offmap_china = { offmap_ruler = { religion = shiite } }
				offmap_china = { offmap_ruler = { religion = qarmatian } }
				offmap_china = { offmap_ruler = { religion = hurufi } }
				offmap_china = { offmap_ruler = { religion = druze } }
			}
		}
	}
	
	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 = druze
				}
			}
			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 = druze
					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 = druze_china_three
					has_global_flag = druze_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 = druze
					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 = sunni
							religion = zikri
							religion = yarsan
							AND = {
								NOT = { has_global_flag = EMF }
								religion = yazidi
							}
						}
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
			kcc_persecute_shias_effect = yes
			set_global_flag = kcc_china_bullseye_shias
		}
		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 = shiite_china_four
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_four
					}
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = shiite_china_three
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_three
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_three
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_three
						has_global_flag = druze_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 = shiite_china_three
						has_global_flag = qarmatian_china_three
						has_global_flag = hurufi_china_three
						has_global_flag = druze_china_three
					}
				}
				modifier = {
					factor = 0
					OR = {
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_four
						has_global_flag = druze_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 = shiite_china_three
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_three
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_three
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_three
						has_global_flag = druze_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOR = {
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_four
					}
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_druze_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 = druze
				}
			}
			modifier = {
				factor = 8.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = sunni
							religion = zikri
							religion = yarsan
							AND = {
								NOT = { has_global_flag = EMF }
								religion = yazidi
							}
						}
					}
				}
			}
		}
	}
	
	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_shias_effect = yes
			set_global_flag = kcc_china_bullseye_shias
		}
		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 = shiite_china_four
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_four
					}
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = shiite_china_three
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_three
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_three
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_three
						has_global_flag = druze_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 = shiite_china_three
						has_global_flag = qarmatian_china_three
						has_global_flag = hurufi_china_three
						has_global_flag = druze_china_three
					}
				}
				modifier = {
					factor = 0
					OR = {
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_four
						has_global_flag = druze_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 = shiite_china_three
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_three
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_three
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_three
						has_global_flag = druze_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOR = {
						has_global_flag = shiite_china_four
						has_global_flag = qarmatian_china_four
						has_global_flag = hurufi_china_four
						has_global_flag = druze_china_four
					}
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_druze_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 }
						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
			}
		}
	
		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 = druze
				}
			}
			modifier = {
				factor = 40
				offmap_china = {
					offmap_ruler = {
						OR = {
							religion = sunni
							religion = zikri
							religion = yarsan
							AND = {
								NOT = { has_global_flag = EMF }
								religion = yazidi
							}
						}
					}
				}
			}
		}
	}
}

# Persecute Khurmaztas?
character_event = {
	id = kcclastvanilla.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 = khurmaztas_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = khurmazta } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_mazdans }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = khurmazta
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							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 = khurmazta
					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 = khurmazta_china_three
					has_global_flag = khurmazta_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 = khurmazta
					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 }
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		if = {
			limit = {
				offmap_china = {
					offmap_ruler = {
						religion_group = zoroastrian_group
						NOT = { religion = zoroastrian }
					}
				}
			}
			change_variable = { which = "global_chinese_khurmaztas" value = -30 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_khurmaztas years = 40 hidden = yes } }
			set_global_flag = kcc_china_bullseye_khurmaztas
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion = zoroastrian } }
			}
			kcc_zoro_persecute_mazdans_effect = yes
			set_global_flag = kcc_zoro_china_bullseye_mazdans
		}
		else = {
			kcc_persecute_mazdans_effect = yes
			set_global_flag = kcc_china_bullseye_mazdans
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = khurmazta_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = khurmazta_china_three
						has_global_flag = khurmazta_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 = khurmazta_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = khurmazta_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 = khurmazta_china_three
						has_global_flag = khurmazta_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = khurmazta_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_khurmazta_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_khurmaztans }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							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 = khurmazta
				}
			}
		}
	}
	
	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_muslims_trigger = yes
				kcc_can_persecute_sunnis_trigger = yes
				kcc_can_persecute_shias_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 = zoroastrian_group
						NOT = { religion = zoroastrian }
					}
				}
			}
			change_variable = { which = "global_chinese_khurmaztas" value = -45 }
			1513 = { add_province_modifier = { name = kcc_china_persecuted_khurmaztas years = 60 hidden = yes } }
			set_global_flag = kcc_china_bullseye_khurmaztas
		}
		else_if = {
			limit = {
				offmap_china = { offmap_ruler = { religion = zoroastrian } }
			}
			kcc_zoro_overpersecute_mazdans_effect = yes
			set_global_flag = kcc_zoro_china_bullseye_mazdans
		}
		else = {
			kcc_overpersecute_mazdans_effect = yes
			set_global_flag = kcc_china_bullseye_mazdans
		}
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = khurmazta_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = khurmazta_china_three
						has_global_flag = khurmazta_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 = khurmazta_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = khurmazta_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 = khurmazta_china_three
						has_global_flag = khurmazta_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = khurmazta_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_khurmazta_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 = { #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 = { #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 }
						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_khurmaztans }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_mazdans }
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = khurmazta
				}
			}
		}
	}
}

# Persecute Jews?
character_event = {
	id = kcclastvanilla.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 = jews_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = taoist } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_china = { offmap_has_dislike = likes_jews } }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = jewish
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
							religion_group = christian
						}
					}
				}
			}
			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 = jewish
					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 = jewish_china_three
					has_global_flag = jewish_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 = jewish
					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 = 1.2
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		kcc_persecute_jews_effect = yes
		set_global_flag = kcc_china_bullseye_jewss
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = jewish_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = jewish_china_three
						has_global_flag = jewish_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = jewish_china_three
						has_global_flag = jewish_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = jewish_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_jewish_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_jews }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
							religion_group = christian
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = jewish
				}
			}
		}
	}
	
	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_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
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		kcc_overpersecute_jews_effect = yes
		set_global_flag = kcc_china_bullseye_jews
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = jewish_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = jewish_china_three
						has_global_flag = jewish_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = jewish_china_three
						has_global_flag = jewish_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = jewish_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_jewish_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 = { #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 }
						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
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_jews }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_china = { offmap_has_dislike = likes_jews } }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = jewish
				}
			}
		}
	}
}

# Persecute Samaritans?
character_event = {
	id = kcclastvanilla.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 = samaritans_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = taoist } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_china = { offmap_has_dislike = likes_jews } }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = samaritan
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
							religion_group = christian
						}
					}
				}
			}
			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 = samaritan
					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 = samaritan_china_three
					has_global_flag = samaritan_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 = samaritan
					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 = 1.2
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		kcc_persecute_jews_effect = yes
		set_global_flag = kcc_china_bullseye_jews
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = samaritan_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = samaritan_china_three
						has_global_flag = samaritan_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = samaritan_china_three
						has_global_flag = samaritan_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = samaritan_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_samaritan_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_jews }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
							religion_group = christian
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = samaritan
				}
			}
		}
	}
	
	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_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
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		kcc_overpersecute_jews_effect = yes
		set_global_flag = kcc_china_bullseye_jews
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = samaritan_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = samaritan_china_three
						has_global_flag = samaritan_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = samaritan_china_three
						has_global_flag = samaritan_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = samaritan_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_samaritan_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 = { #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 }
						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
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_jews }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_china = { offmap_has_dislike = likes_jews } }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = samaritan
				}
			}
		}
	}
}

# Persecute Karaites?
character_event = {
	id = kcclastvanilla.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 = karaites_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion_group = jewish_group } }
		}
		modifier = {
			factor = 0
			offmap_china = { offmap_ruler = { religion = taoist } }
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_china = { offmap_has_dislike = likes_jews } }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = karaite
				}
			}
			modifier = {
				factor = 0.2
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
							religion_group = christian
						}
					}
				}
			}
			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 = karaite
					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 = karaite_china_three
					has_global_flag = karaite_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 = karaite
					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 = 1.2
				offmap_china = { offmap_ruler = { religion_group = muslim } }
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		kcc_persecute_jews_effect = yes
		set_global_flag = kcc_china_bullseye_jews
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = karaite_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = karaite_china_three
						has_global_flag = karaite_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = karaite_china_three
						has_global_flag = karaite_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = karaite_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_karaite_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_jews }
			}
			modifier = {
				factor = 1.5
				offmap_china = {
					offmap_ruler = {
						OR = {
							AND = {
								religion_group = pagan_group
								has_religion_feature = religion_dogmatic
							}
							religion_group = christian
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = karaite
				}
			}
		}
	}
	
	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_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
			}
		}
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0002 days = 1 } }
		kcc_overpersecute_jews_effect = yes
		set_global_flag = kcc_china_bullseye_jews
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = karaite_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = karaite_china_three
						has_global_flag = karaite_china_four
					}
				}
				modifier = {
					factor = 0
					offmap_china = { has_status = china_unrest }
				}
				offmap_china = { governor = { character_event = { id = kccdragontamer.3 days = 11 } } }
			}
			40 = { #Civil War
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = karaite_china_three
						has_global_flag = karaite_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = karaite_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_karaite_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 = { #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 }
						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
			}
		}
	
		ai_chance = {
			factor = 5
			modifier = {
				factor = 0
				offmap_china = { offmap_has_like = likes_jews }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_china = { offmap_has_dislike = likes_jews } }
			}
			modifier = {
				factor = 4
				kcc_unmonastic_china_trigger = yes
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = karaite
				}
			}
		}
	}
}

# Persecute Hindus?
character_event = {
	id = kcclastvanilla.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 = hindus_in_china }
		}
		modifier = {
			factor = 0
			kcc_china_has_persecuted_trigger = yes
		}
		modifier = {
			factor = 0
			OR = {
				offmap_china = { offmap_ruler = { religion = buddhist } }
				offmap_china = { offmap_ruler = { religion = jain } }
				offmap_china = { offmap_ruler = { religion = hindu } }
			}
		}
	}
	
	option = { #Nope
	
		ai_chance = {
			factor = 85
			modifier = {
				factor = 0
				offmap_china = { offmap_has_dislike = likes_hindus }
			}
			modifier = {
				factor = 0.66
				has_global_flag = buddhists_in_china
				offmap_china = { offmap_has_dislike = likes_buddhists }
			}
			modifier = {
				factor = 0.66
				has_global_flag = jains_in_china
				offmap_china = { offmap_has_dislike = likes_jains }
			}
			modifier = {
				factor = 0.1
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = hindu
				}
			}
			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 = hindu
					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 = hindu_china_three
					has_global_flag = hindu_china_four
				}
			}
			modifier = {
				factor = 3
				offmap_china = {
					offmap_ruler = {
						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 = hindu
					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 }
					}
				}
			}
		}
	}
	
	option = { #Persecute
	
		any_playable_ruler = { narrative_event = { id = kccpnews.0001 days = 1 } }
		kcc_persecute_dharmans_effect = yes
		set_global_flag = kcc_china_bullseye_dharmans
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = hindu_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = hindu_china_three
						has_global_flag = hindu_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 = hindu_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = hindu_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 = hindu_china_three
						has_global_flag = hindu_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = hindu_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_hindu_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_hindus }
			}
			modifier = {
				factor = 0.66
				has_global_flag = buddhists_in_china
				offmap_china = { offmap_has_dislike = likes_buddhists }
			}
			modifier = {
				factor = 0.66
				has_global_flag = jains_in_china
				offmap_china = { offmap_has_dislike = likes_jains }
			}
			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 = hindu
				}
			}
		}
	}
	
	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_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_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 } }
		kcc_overpersecute_dharmans_effect = yes
		set_global_flag = kcc_china_bullseye_dharmans
		random_list = {
			40 = { #No Effect
				modifier = {
					factor = 2
					offmap_china = { has_status = china_golden_age }
				}
				modifier = {
					factor = 0.5
					has_global_flag = hindu_china_four
				}
			}
			20 = { #Unrest
				modifier = {
					factor = 0
					NOR = {
						has_global_flag = hindu_china_three
						has_global_flag = hindu_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 = hindu_china_three
				}
				modifier = {
					factor = 0
					has_global_flag = hindu_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 = hindu_china_three
						has_global_flag = hindu_china_four
					}
				}
				modifier = {
					factor = 0.1
					NOT = { has_global_flag = hindu_china_four }
				}
				modifier = {
					factor = 3
					offmap_china = { has_status = china_unrest }
				}
				set_global_flag = kcc_hindu_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 = { #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 = { #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_hindus }
			}
			modifier = {
				factor = 0.66
				has_global_flag = buddhists_in_china
				offmap_china = { offmap_has_like = likes_buddhists }
			}
			modifier = {
				factor = 0.66
				has_global_flag = jains_in_china
				offmap_china = { offmap_has_like = likes_jains }
			}
			modifier = {
				factor = 10
				offmap_china = { offmap_has_dislike = likes_hindus }
			}
			modifier = {
				factor = 2
				has_global_flag = buddhists_in_china
				offmap_china = { offmap_has_dislike = likes_buddhists }
			}
			modifier = {
				factor = 2
				has_global_flag = jains_in_china
				offmap_china = { offmap_has_dislike = likes_jains }
			}
			modifier = {
				factor = 3
				any_province = {
					de_jure_liege = d_jiuquan
					NOT = { culture_group = chinese_group }
					religion = hindu
				}
			}
		}
	}
}