emf_nwo_create_male_ruler_effect = {
	random_list = {
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 16
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 17
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 18
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 19
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 20
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 21
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 22
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 23
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 24
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = no
				age = 25
			}
		}
	}
}


emf_nwo_create_female_ruler_effect = {
	random_list = {
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 16
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 17
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 18
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 19
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 20
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 21
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 22
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 23
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 24
			}
		}
		10 = {
			create_character = {
				random_traits = yes
				religion = PREV # Province
				culture = PREV # Province
				dynasty = random
				health = 5
				fertility = 0.5
				female = yes
				age = 25
			}
		}
	}
}

emf_nwo_generate_ancient_religion_provinces_culture = { # Flip specific cultures to ancient religions.
	if = {										        # THIS is the province scope
		limit = {
			celtic_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = celtic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = celtic_pagan_reformed
		}
	}
	if = {
		limit = {
			german_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = german_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = german_pagan_reformed
		}
	}
	if = {
		limit = {
			roman_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = roman_pagan
	}
	if = {
		limit = {
			hellenic_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = hellenic_pagan
	}
	if = {
		limit = {
			norse_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = norse_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = norse_pagan_reformed
		}
	}
	if = {
		limit = {
			zoroastrian_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = zoroastrian
	}
	if = {
		limit = {
			egyptian_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = egyptian_pagan
	}
	if = {
		limit = {
			finnish_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = finnish_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = finnish_pagan_reformed
		}
	}
	if = {
		limit = {
			baltic_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = baltic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = baltic_pagan_reformed
		}
	}
	if = {
		limit = {
			slavic_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = slavic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = slavic_pagan_reformed
		}
	}
	if = {
		limit = {
			tengri_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = tengri_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = tengri_pagan_reformed
		}
	}
	if = {
		limit = {
			arab_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = arab_pagan
	}
	if = {
		limit = {
			zun_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = zun_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = zun_pagan_reformed
		}
	}
	if = {
		limit = {
			jewish_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = jewish_pagan
	}
	if = {
		limit = {
			berber_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = berber_pagan
	}
	if = {
		limit = {
			west_african_culture_trigger = yes
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = west_african_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = west_african_pagan_reformed
		}
	}
	if = {
		limit = {
			tibetan_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = tibetan_pagan
	}
}

emf_nwo_generate_ancient_religion_provinces = { # Flip specific regions to ancient religions.
	if = {										# THIS is the province scope
		limit = {
			OR = {
				region = custom_france 
				region = custom_aquitaine 
				region = custom_aragon 
				region = custom_navarra 
				region = custom_castille 
				region = custom_asturias 
				region = custom_andalusia
				region = custom_ireland
				region = custom_brittany
				region = custom_scotland
				region = custom_portugal
				region = custom_wales
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = celtic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = celtic_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_germany
				region = custom_frisia
				region = custom_lotharingia
				region = custom_burgundy
				region = custom_england
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = german_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = german_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_croatia 
				region = custom_italy
				region = custom_sicily
				duchy = {
					title = d_carinthia
				}
			}
		}
		set_province_flag = ar_setup
		religion = roman_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_serbia 
				region = custom_bulgaria 
				region = custom_byzantium 
				region = custom_nikaea
				region = custom_trebizond
				region = custom_armenia
				region = custom_georgia
			}
		}
		set_province_flag = ar_setup
		religion = hellenic_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_norway 
				region = custom_sweden
				region = custom_denmark
				region = custom_north_sea
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = norse_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = norse_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_persia
				region = custom_mesopotamia
				region = custom_azerbaijan
				region = custom_khorasan
			}
		}
		set_province_flag = ar_setup
		religion = zoroastrian
	}
	if = {
		limit = {
			OR = {
				region = custom_egypt
				region = custom_nubia
			}
		}
		set_province_flag = ar_setup
		religion = egyptian_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_finland
				region = custom_perm
				region = custom_novgorod
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = finnish_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = finnish_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_lithuania
				region = custom_pomerania
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = baltic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = baltic_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_muscovy
				region = custom_rus
				region = custom_bohemia
				region = custom_carpathia
				region = custom_wallachia
				region = custom_poland
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = slavic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = slavic_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_khwarizm
				region = world_steppe
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = tengri_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = tengri_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_arabia
				region = custom_adal
				region = custom_abyssinia
			}
		}
		set_province_flag = ar_setup
		religion = arab_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_baluchistan
				region = custom_afghanistan
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = zun_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = zun_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_jerusalem
				region = custom_syria
			}
		}
		set_province_flag = ar_setup
		religion = jewish_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_africa
				region = custom_morocco
				region = custom_algiers
			}
		}
		set_province_flag = ar_setup
		religion = berber_pagan
	}
	if = {
		limit = {
			region = world_africa_west
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = west_african_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = west_african_pagan_reformed
		}
	}
	if = {
		limit = {
			region = custom_tibet
		}
		religion = tibetan_pagan
	}
}

emf_nwo_generate_ancient_religion_provinces_specific = { # Flip only some provinces to ancient religions
	if = {
		limit = {
			OR = {
				region = custom_germany
				region = custom_frisia
				region = custom_england
			}
			OR = {
				culture_group = central_germanic
				culture_group = west_germanic
				culture_group = franco_germanic
				culture_group = east_germanic
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = german_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = german_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_ireland
				region = custom_brittany
				region = custom_scotland
				region = custom_wales
				region = custom_cornwall
			}
			culture_group = celtic
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = celtic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = celtic_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_byzantium 
				region = custom_nikaea
				region = custom_trebizond
			}
			OR = {
				culture_group = byzantine
			}
		}
		set_province_flag = ar_setup
		religion = hellenic_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_sicily
			}
			OR = {
				culture_group = east_romance
				AND = {
					culture_group = latin
					NOT = { culture = norman }
				}
				
			}
		}
		set_province_flag = ar_setup
		religion = roman_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_norway 
				region = custom_sweden
				region = custom_denmark
				region = custom_north_sea
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = norse_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = norse_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_persia
				region = custom_khorasan
			}
			OR = {
				culture_group = iranian
				culture_group = tocharian_group
			}
		}
		set_province_flag = ar_setup
		religion = zoroastrian
	}
	if = {
		limit = {
			OR = {
				region = custom_egypt
			}
		}
		set_province_flag = ar_setup
		religion = egyptian_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_finland
				region = custom_perm
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = finnish_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = finnish_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_lithuania
				region = custom_pomerania
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = baltic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = baltic_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_muscovy
				region = custom_rus
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = slavic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = slavic_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_adal
				AND = {
					region = custom_arabia
					NOT = { region = custom_medina }
				}
			}
		}
		set_province_flag = ar_setup
		religion = arab_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_baluchistan
				region = custom_afghanistan
			}
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = zun_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = zun_pagan_reformed
		}
	}
	if = {
		limit = {
			OR = {
				region = custom_jerusalem
			}
		}
		set_province_flag = ar_setup
		religion = jewish_pagan
	}
	if = {
		limit = {
			OR = {
				region = custom_morocco
				region = custom_algiers
			}
		}
		set_province_flag = ar_setup
		religion = berber_pagan
	}
	if = {
		limit = {
			region = world_africa_west
		}
		set_province_flag = ar_setup
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = west_african_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = west_african_pagan_reformed
		}
	}
	if = {
		limit = {
			tibetan_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = tibetan_pagan
	}
}

emf_nwo_generate_ancient_religion_characters = { # Flip specific character to ancient religions, based on their culture.
	if = {
		limit = {
			celtic_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = celtic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = celtic_pagan_reformed
		}
	}
	if = {
		limit = {
			german_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = german_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = german_pagan_reformed
		}
	}
	if = {
		limit = {
			roman_pagan_culture_trigger = yes
		}
		religion = roman_pagan
	}
	if = {
		limit = {
			hellenic_pagan_culture_trigger = yes
		}
		religion = hellenic_pagan
	}
	if = {
		limit = {
			norse_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = norse_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = norse_pagan_reformed
		}
	}
	if = {
		limit = {
			zoroastrian_culture_trigger = yes
		}
		religion = zoroastrian
	}
	if = {
		limit = {
			egyptian_pagan_culture_trigger = yes
		}
		religion = egyptian_pagan
	}
	if = {
		limit = {
			finnish_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = finnish_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = finnish_pagan_reformed
		}
	}
	if = {
		limit = {
			baltic_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = baltic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = baltic_pagan_reformed
		}
	}
	if = {
		limit = {
			slavic_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = slavic_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = slavic_pagan_reformed
		}
	}
	if = {
		limit = {
			tengri_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = tengri_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = tengri_pagan_reformed
		}
	}
	if = {
		limit = {
			arab_pagan_culture_trigger = yes
		}
		religion = arab_pagan
	}
	if = {
		limit = {
			zun_pagan_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = zun_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = zun_pagan_reformed
		}
	}
	if = {
		limit = {
			jewish_pagan_culture_trigger = yes
		}
		religion = jewish_pagan
	}
	if = {
		limit = {
			berber_pagan_culture_trigger = yes
		}
		religion = berber_pagan
	}
	if = {
		limit = {
			west_african_culture_trigger = yes
		}
		if = {
			limit = {
				NOT = {
					has_game_rule = {
						name = pagan_reformation
						value = start_reformed
					}
				}
			}
			religion = west_african_pagan
		}
		if = {
			limit = {
				has_game_rule = {
					name = pagan_reformation
					value = start_reformed
				}
			}
			religion = west_african_pagan_reformed
		}
	}
	if = {
		limit = {
			tibetan_pagan_culture_trigger = yes
		}
		set_province_flag = ar_setup
		religion = tibetan_pagan
	}
}

emf_nwo_generate_male_child = { # Generates male child based on the age of ROOT
	if = {
		limit = { NOT = { num_of_children = 2 } } # Don't want to generate children for characters who already have 2 or more children
		if = {
			limit = { # If younger than 22, but older than 16
				NOT = { age = 22 }
				age = 17
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 1
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 2
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 3
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 26, but older than 21
				NOT = { age = 26 }
				age = 22
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 4
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 5
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 6
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 29, but older than 25
				NOT = { age = 29 }
				age = 26
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 7
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 8
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 9
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 32, but older than 28
				NOT = { age = 32 }
				age = 29
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 10
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 11
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 12
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 35, but older than 31
				NOT = { age = 35 }
				age = 32
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 13
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 14
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 15
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 38, but older than 34
				NOT = { age = 38 }
				age = 35
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 19
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 20
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 21
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If older than 37
				age = 38
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 22
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 23
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 24
						female = no
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		new_character = {
			if = {
				limit = { ROOT = { is_female = no } }
				set_father = ROOT
			}
			if = {
				limit = { ROOT = { is_female = yes } }
				set_mother = ROOT
			}
			ROOT = {
				random_spouse = {
					limit = { age_diff = { who = PREVPREV years = 16 } }
					if = {
						limit = { is_female = no }
						new_character = { set_father = PREV }
					}
					if = {
						limit = { is_female = yes }
						new_character = { set_mother = PREV }
					}
				}
			}
			if = {
				limit = { religion_group = indian_group }
				add_trait = kshatriya
				character_event = { id = RoI.30121 }
			}
			set_character_flag = start_of_game_character
			character_event = { id = Plus.324 }
		}
		recalc_succession = yes
	}
}

emf_nwo_generate_female_child = { # Generates female child based on the age of ROOT
	if = {
		limit = { NOT = { num_of_children = 2 } } # Don't want to generate children for characters who already have 2 or more children
		if = {
			limit = { # If younger than 22, but older than 16
				NOT = { age = 22 }
				age = 17
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 1
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 2
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 3
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 26, but older than 21
				NOT = { age = 26 }
				age = 22
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 4
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 5
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 6
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 29, but older than 25
				NOT = { age = 29 }
				age = 26
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 7
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 8
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 9
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 32, but older than 28
				NOT = { age = 32 }
				age = 29
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 10
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 11
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 12
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 35, but older than 31
				NOT = { age = 35 }
				age = 32
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 13
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 14
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 15
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If younger than 38, but older than 34
				NOT = { age = 38 }
				age = 35
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 19
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 20
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 21
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		if = {
			limit = { # If older than 37
				age = 38
			}
			random_list = {
				34 = {
					create_character = {
						random_traits = yes
						age = 22
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 23
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
				33 = {
					create_character = {
						random_traits = yes
						age = 24
						female = yes
						culture = ROOT
						religion = ROOT
						dynasty = ROOT
					}
				}
			}
		}
		new_character = {
			if = {
				limit = { ROOT = { is_female = no } }
				set_father = ROOT
			}
			if = {
				limit = { ROOT = { is_female = yes } }
				set_mother = ROOT
			}
			ROOT = {
				random_spouse = {
					limit = { age_diff = { who = PREVPREV years = 16 } }
					if = {
						limit = { is_female = no }
						new_character = { set_father = PREV }
					}
					if = {
						limit = { is_female = yes }
						new_character = { set_mother = PREV }
					}
				}
			}
			if = {
				limit = { religion_group = indian_group }
				add_trait = kshatriya
				character_event = { id = RoI.30121 }
			}
			set_character_flag = start_of_game_character
			character_event = { id = Plus.324 }
		}
		recalc_succession = yes
	}
}
