# country
on_startup = {
	events = {
		ck2plus_setup.0 # Start with CK2 TI?
	}
}

# country
on_religion_change = {
	if = {
		limit = {
			NOT = { religion = confucianism }
		}
		remove_country_modifier = neo_confucianism
	}
	if = {
		limit = {
			religion_group = christian
		}
		remove_country_modifier = the_anti_christian_edict
	}
	if = {
		limit = {
			NOT = { religion = orthodox }
		}
		every_known_country = {
			limit = {
				reverse_has_opinion_modifier = {
					who = ROOT
					modifier = closed_down_the_patriarchate
				}
			}
			reverse_remove_opinion = {
				who = ROOT
				modifier = closed_down_the_patriarchate
			}
		}
	}
	if = {
		limit = {
			religion = catholic
			has_ruler_flag = personal_catholic_sympathies
		}
		country_event = { id = protestantism_events.19 }
	}
	if = {
		limit = {
			NOT = { religion = catholic }
			has_ruler_modifier = catholic_zealot
		}
		remove_country_modifier = catholic_zealot
	}
	if = {
		limit = {
			NOT = { religion = catholic }
			has_country_modifier = spanish_bible_translation
		}
		remove_country_modifier = spanish_bible_translation
	}
	if = {
		limit = {
			NOT = { religion = catholic }
			has_country_modifier = supressing_spanish_protestantism
		}
		remove_country_modifier = supressing_spanish_protestantism
	}
	if = {
		limit = {
			NOT = { religion = catholic }
			has_country_modifier = counter_reformation
		}
		remove_country_modifier = counter_reformation
	}
	if = {
		limit = {
			religion = protestant
		}
		set_country_flag = converted_to_protestantism
	}
}

# country.
on_secondary_religion_change = {
	# Done from code: add_prestige = -50 (Define: CHANGE_SECONDARY_PRESTIGE_HIT)
	every_owned_province = {
		limit = { has_province_modifier = tengri_monastic_order }
		remove_province_modifier = tengri_monastic_order
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_shiite_settled_in_capital }
		remove_province_modifier = tengri_shiite_settled_in_capital
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_insincere_leadership }
		remove_province_modifier = tengri_insincere_leadership
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_religious_influx }
		remove_province_modifier = tengri_religious_influx
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_ruler_questioned }
		remove_province_modifier = tengri_ruler_questioned
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_strengthened_local_clans }
		remove_province_modifier = tengri_strengthened_local_clans
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_growing_cities }
		remove_province_modifier = tengri_growing_cities
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_christian_mission }
		remove_province_modifier = tengri_christian_mission
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_unchristian_values }
		remove_province_modifier = tengri_unchristian_values
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_monastic_order }
		remove_province_modifier = tengri_monastic_order
	}
	every_owned_province = {
		limit = { has_province_modifier = hindufication }
		remove_province_modifier = hindufication
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_influx_of_monks }
		remove_province_modifier = tengri_influx_of_monks
	}
	every_owned_province = {
		limit = { has_province_modifier = tengri_abandoning_the_old_ways }
		remove_province_modifier = tengri_abandoning_the_old_ways
	}
	remove_country_modifier = tengri_devout_muslim
	remove_country_modifier = tengri_confucian_elites_alienated
	remove_country_modifier = tengri_confucian_titles
	remove_country_modifier = tengri_traditionalists_strengthened
	remove_country_modifier = tengri_confucian_nobles
	remove_country_modifier = tengri_pali_legal_traditions
	remove_country_modifier = tengri_religious_pilgrimages
	remove_country_modifier = tengri_monks_in_capital
	remove_country_modifier = tengri_influx_of_monks
	remove_country_modifier = tengri_shiite_immigration
	remove_country_modifier = support_of_the_khojas
	remove_country_modifier = black_shamanism_modifier
	remove_country_modifier = tengri_animist_pantheon
	remove_country_modifier = zoroastrian_traders
	remove_country_modifier = spread_of_tengri_tea_ceremony
	remove_country_modifier = tengri_tea_ceremony
	remove_country_modifier = tengri_japanese_swordsmithing
	remove_country_modifier = tengri_bow_and_arrow_defended
	remove_country_modifier = tengri_support_of_shamans
	remove_country_modifier = tengri_hindu_conflict
	remove_country_modifier = tengri_hindu_syncretism
	remove_country_modifier = tengri_devout_christian_ruler
	remove_country_modifier = tengri_personal_confessor
	remove_country_modifier = zoroastrian_traders
	remove_country_modifier = tengri_confucian_administrators
	remove_country_modifier = tengri_traditional_elites_alienated
	remove_country_modifier = tengri_jihad
	remove_country_modifier = tengri_stood_up_for_yassa
	remove_country_modifier = tengri_sufi_teacher
	remove_country_modifier = tengri_qadi
	remove_country_modifier = tengri_religious_influx
	remove_country_modifier = tengri_ibadi_scholars
	remove_country_modifier = tengri_clergy_conflicts
	remove_country_modifier = tengri_shamans_spurned
	clr_country_flag = khojas_established
	clr_country_flag = tengri_christian_devout_court
	clr_ruler_flag = tengri_muslim_ruler_questioned
	if = {
		limit = {
			check_variable = { which = khojas_retained value = 1 }
		}
		set_variable = {
			which = khojas_retained value = 0
		}
	}
}

# country. Spawned when Enforcing Rebel Demands through a Support Rebels-war.
on_enforce_rebel_demands = {
	# ROOT = The winning country
	# FROM = The loosing country
	set_country_flag = helped_rebels_win_war
}

# country
on_colonial_liberation = {
	country_event = { id = colonial_nation.90 days = 1 }
}

# country
on_colonial_reintegration = {
	events = {
		colonial_nation.91
	}
}

# country
on_peace_actor = {
	events = {
		usa_dlc.36				# Evacuation Day
		native_americans.7		# Appoint Peace Chief
	}
}

# country
on_peace_recipient = {
	events = {
		native_americans.7		# Appoint Peace Chief
	}
}

# country
# root = winning country, from = loser country
on_war_won = {
	FROM = { country_event = { id = flavor_cri.6 } }
}

# country
# root = loser country, from = winner country
on_war_lost = {
	ROOT = { country_event = { id = flavor_cri.6 } }
}

# country
# root = winning country, from = loser country
on_battle_won_country = {
}

# country
# root = loser country, from = winner country
on_battle_lost_country = {
	#Yemoya
	if = {
		limit = {
			ROOT = {
				religion = shamanism
				NOT = { has_unlocked_cult = yemoja_cult }
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = yemoja_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.1 } }
	}
	if = {
		limit = {
			FROM = {
				religion = shamanism
				NOT = { has_unlocked_cult = yemoja_cult }
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = yemoja_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.1 } }
	}
	#Roog
	if = {
		limit = {
			ROOT = {
				religion = shamanism
				NOT = { has_unlocked_cult = roog_cult }
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = roog_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.2 } }
	}
	if = {
		limit = {
			FROM = {
				religion = shamanism
				NOT = { has_unlocked_cult = roog_cult }
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = roog_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.2 } }
	}
	#Nyame
	if = {
		limit = {
			ROOT = {
				religion = shamanism
				NOT = { has_unlocked_cult = nyame_cult }
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = nyame_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.3 } }
	}
	if = {
		limit = {
			FROM = {
				religion = shamanism
				NOT = { has_unlocked_cult = nyame_cult }
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = nyame_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.3 } }
	}
	
	#Cwezi / Swezi / Kubandwa
	if = {
		limit = {
			ROOT = {
				religion = shamanism
				NOT = { has_unlocked_cult = cwezi_cult }
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = cwezi_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.101 } }
	}
	if = {
		limit = {
			FROM = {
				religion = shamanism
				NOT = { has_unlocked_cult = cwezi_cult }
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = cwezi_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.101 } }
	}
	
	#Mlira and other Nature Spirits and/or ancestral cults of Central Africa
	if = {
		limit = {
			ROOT = {
				religion = shamanism
				NOT = { has_unlocked_cult = central_african_ancestor_cult }
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = central_african_ancestor_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.102 } }
	}
	if = {
		limit = {
			FROM = {
				religion = shamanism
				NOT = { has_unlocked_cult = central_african_ancestor_cult }
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = central_african_ancestor_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.102 } }
	}
	
	#Mwari
	if = {
		limit = {
			ROOT = {
				religion = shamanism
				NOT = { has_unlocked_cult = mwari_cult }
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = mwari_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.103 } }
	}
	if = {
		limit = {
			FROM = {
				religion = shamanism
				NOT = { has_unlocked_cult = mwari_cult }
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = mwari_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.103 } }
	}
	
	#Enkai
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = enkai_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = enkai_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.201 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = enkai_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = enkai_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.201 } }
	}
	#Waaq
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = waaq_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = waaq_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.202 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = waaq_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = waaq_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.202 } }
	}
	#Zanahary
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = zanahary_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				religion = shamanism
				has_unlocked_cult = zanahary_cult
			}
		}
		ROOT = { country_event { id = fetishist_flavor.203 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = zanahary_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				religion = shamanism
				has_unlocked_cult = zanahary_cult
			}
		}
		FROM = { country_event { id = fetishist_flavor.203 } }
	}
	#Christianity
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = christianity_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion_group = christian
					has_unlocked_cult = christianity_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.400 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = christianity_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = christianity_cult
					religion_group = christian
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.400 } }
	}
	#Islam
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = islam_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion_group = muslim
					has_unlocked_cult = islam_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.401 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = islam_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = islam_cult
					religion_group = muslim
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.401 } }
	}
	#Buddhism
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = buddhism_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion_group = eastern
					has_unlocked_cult = buddhism_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.402 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = buddhism_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = buddhism_cult
					religion_group = eastern
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.402 } }
	}
	#Dharmic Cult
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = dharmic_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion_group = dharmic
					has_unlocked_cult = dharmic_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.403 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = dharmic_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = dharmic_cult
					religion_group = dharmic
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.403 } }
	}
	#Teotl Cult
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = south_central_american_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion = nahuatl
					religion = inti
					religion = mesoamerican_religion
					has_unlocked_cult = south_central_american_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.404 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = south_central_american_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = south_central_american_cult
					religion = nahuatl
					religion = mesoamerican_religion
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.404 } }
	}
	#Norse Cult
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = norse_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion = norse_pagan_reformed
					has_unlocked_cult = norse_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.405 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = norse_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = norse_cult
					religion = norse_pagan_reformed
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.405 } }
	}
	#Jewish Cult
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = jewish_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion = jewish
					has_unlocked_cult = jewish_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.406 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = jewish_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = jewish_cult
					religion = jewish
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.406 } }
	}
	#Zoroastrian Cult
	if = {
		limit = {
			ROOT = {
				NOT = { has_unlocked_cult = zoroastrian_cult }
				religion = shamanism #Fetishism
			}
			FROM = {
				OR = {
					religion = zoroastrian
					has_unlocked_cult = zoroastrian_cult
				}
			}
		}
		ROOT = { country_event { id = fetishist_flavor.407 } }
	}
	if = {
		limit = {
			FROM = {
				NOT = { has_unlocked_cult = zoroastrian_cult }
				religion = shamanism #Fetishism
			}
			ROOT = {
				OR = {
					has_unlocked_cult = zoroastrian_cult
					religion = zoroastrian
				}
			}
		}
		FROM = { country_event { id = fetishist_flavor.407 } }
	}
	random_events = {
		90 = 0
		10 = friendship_events.1 #Historical Friendship Broken
	}
}

# province
# root = location, from = loser country
on_battle_won_province = {
	random_events = {
		1000 = 0
		100 = war_of_the_roses.6	# WotR - Rebel Leaders Captured
	}
}

# province
# root = location, from = country doing it
on_added_to_trade_company ={

}

# province
# root = location, from = country doing it
on_removed_from_company ={

}

# province
# root = location, from = country doing it
on_company_formed ={

}

# province
# root = location, from = country doing it
on_company_disolved ={

}

# province
# root = location, from = winner country
on_battle_lost_province = {
	random_events = {
		1000 = 0
		100 = tyw_events.22	# Capital Battle in Religious War
	}
}

# country
# root = winning country, from = location
on_siege_won_country = {
	events = {
		tyw_events.14 # Fall of Prague in Religious War
	}
}

# country
# root = losing country, from = location
on_siege_lost_country = {
}

# province
# root = location, from = losing country
on_siege_won_province = {
}

# province
# root = location, from = winning country
on_siege_lost_province =  {
	events = {
		war_of_the_roses.10		# Lancaster Stronghold
		war_of_the_roses.11		# York Stronghold
		french_wars_of_religion.7 #Ravening Religious Fanatics
		french_wars_of_religion.9 #french_wars_of_religion.9
	}
}

# province
# root = location, from = country that abandons colony
# Fired right before the colony is abandoned.
on_abandon_colony = {
}

# country 
on_new_monarch = {
	if = {
		limit = {
			NOT = { has_global_flag = death_of_haji_giray } #Also set in history.
			tag = CRI
			exists = TUR
			is_subject = no
			TUR = {
				num_of_cities = ROOT
				is_subject = no
				num_of_ports = 1
			}
		}
		country_event = { id = flavor_cri.1 } #Death of Haji Giray
	}
	if = {
		limit = {
			NOT = { has_global_flag = death_of_haji_giray } #Also set in history.
			tag = CRI
			OR = {
				NOT = { exists = TUR }
				is_subject = yes
				TUR = { NOT = { num_of_cities = ROOT } }
				TUR = { is_subject = yes }
				TUR = { NOT = { num_of_ports = 1 } }
			}
		}
		set_global_flag = death_of_haji_giray
	}
	if = {
		limit = {
			has_consort_regency = no
			any_owned_province = {
				has_province_modifier = domain_of_spouses_family
			}
		}
		random_owned_province = {
			limit = { has_province_modifier = domain_of_spouses_family }
			remove_province_modifier = domain_of_spouses_family
		}
	}
	events = {
		tribal_succession.1	# Harsh anti-tribals.
		9492 			# Remove some event modifiers
		flavor_mlo.1	# The Ambrosian Republic
		flavor_boh.8	# Winter King in Prague
		flavor_kol.1	# Bavarian Archbishop
		war_of_the_roses.101	# WotR - House of Lancaster wins
		war_of_the_roses.102	# WotR - House of York wins
		war_of_the_roses.106	# WotR - Another dynasty has seized the throne
		flavor_tur.102	# Janissary Reward
		flavor_ori.7	# Hamvira Victorious
		flavor_kbo.1	# The two branches of the Sayfawa dynasty
		flavor_kbo.8	# Sayfawa pretenders
		flavor_zan.5	# Coup of Coup of Suleiman and Muhammad al-Mazlum.
		purple_phoenix.1 # BYZ pretenders
		flavor_pol.3480 #The Pacta Conventa
		protestantism_events.15 #Catholic Leaning Monarch
		tengri_events.17 #Keep the Khojas in Power?
		flavor_tus.15 #Savonarola Dies
		flavor_brapru.22 #Succession of Albrecht Achilles
		flavor_brapru.25 #Dispositio Achillea (can also trigger from flavor_brapru.22)
	}
	random_events = { 
		1000 = 0
		100 = flavor_kol.1	# Bavarian Archbishop
		100 = flavor_tim.1	# The Disintegration of the Timurid Empire
		100 = flavor_hsa.3 	# Hansa: Tagfahrt
		100 = inti_events.1	# Birth of a Panaca
		50 = dynastic_events.4
		50 = dynastic_events.5
		25 = harem_events.7 #Failed Policy of Fratricide
	}
}

on_new_consort = {
	if = {
		country_event = { id = consort_events.2 }
	}
	if = {
		limit = { has_ruler_flag = had_10_years_anniversary }
		clr_ruler_flag = had_10_years_anniversary
	}
	if = {
		limit = { has_ruler_flag = had_20_years_anniversary }
		clr_ruler_flag = had_20_years_anniversary
	}
	if = {
		limit = { has_ruler_flag = consort_had_affection_of_ruler }
		clr_ruler_flag = consort_had_affection_of_ruler
	}
}

# country
on_monarch_death = {
	if = {
		limit = {
			tag = ANS
			BRA = {
				has_country_flag = albrecht_achilles_flag
			}
		}
		BRA = {
			clr_country_flag = albrecht_achilles_flag #Just to be sure
			kill_heir = yes #If Albrecht Achilles dies in Ansbach he will also be dead in Brandenburg, will appear as normal death of heir to BRA.
		}
	}
}

# country 
on_regent = {
	if = {
		limit = {
			NOT = { has_global_flag = death_of_haji_giray } #Also set in history.
			tag = CRI
			exists = TUR
			is_subject = no
			TUR = {
				num_of_cities = ROOT
				is_subject = no
				num_of_ports = 1
			}
		}
		country_event = { id = flavor_cri.1 } #Death of Haji Giray
	}
	if = {
		limit = {
			NOT = { has_global_flag = death_of_haji_giray } #Also set in history.
			tag = CRI
			OR = {
				NOT = { exists = TUR }
				is_subject = yes
				TUR = { NOT = { num_of_cities = ROOT } }
				TUR = { is_subject = yes }
				TUR = { NOT = { num_of_ports = 1 } }
			}
		}
		set_global_flag = death_of_haji_giray
	}
	events = {
		tribal_succession.1	# harsh anti-tribals.
		flavor_mlo.1	# The Ambrosian Republic
	}
}

# country 
on_new_term_election = {
	events = {
		700		# Election event
		elections.720		# Dutch Republic
	}
}

# country 
on_death_election = {
	events = {
		701		# Election event
		elections.721		# Dutch Republic
	}
}

# country 
on_replace_governor = {
	events = {
		elections.707
	}
}


# country
on_bankruptcy = {
}

# country (country annexing, root = target)
on_diplomatic_annex = {
	events = {
		610
	}
}

# country
on_heir_death = {
	if = {
		limit = { has_country_flag = heir_dip_education }
		clr_ruler_flag = heir_dip_education
	}
	if = {
		limit = { has_country_flag = heir_mil_education }
		clr_ruler_flag = heir_mil_education
	}
	if = {
		limit = { has_country_flag = heir_adm_education }
		clr_ruler_flag = heir_adm_education
	}
	if = {
		limit = { has_ruler_flag = well_advised_tutored_heir }
		clr_ruler_flag = well_advised_tutored_heir
	}
	if = {
		limit = { has_ruler_flag = heir_went_on_grand_tour }
		clr_ruler_flag = heir_went_on_grand_tour
	}
	if = {
		limit = { has_country_flag = albrecht_achilles_flag }
		clr_country_flag = albrecht_achilles_flag #Death of original Albrecht Achilles
	}
	if = {
		limit = { has_ruler_flag = sancaga_cikma }
		clr_ruler_flag = sancaga_cikma
		every_owned_province = {
			limit = {
				has_province_modifier = heir_in_training
			}
			remove_province_modifier = heir_in_training
		}
	}
	if = {
		limit = { has_ruler_flag = returned_from_sancaga_sikma_province }
		clr_ruler_flag = returned_from_sancaga_sikma_province
	}
}

# country
on_queen_death = {
	
	if = {
		limit = { has_consort_flag = 10_years_anniversary }
		set_ruler_flag = had_10_years_anniversary
	}
	if = {
		limit = { has_consort_flag = 20_years_anniversary }
		set_ruler_flag = had_20_years_anniversary
	}
	if = {
		limit = { has_consort_flag = consort_has_affection_of_ruler }
		set_ruler_flag = consort_had_affection_of_ruler
	}

	if = {
		limit = {
			has_regency = no
			NOT = { has_ruler_flag = widow_widower }
		}
		set_ruler_flag = widow_widower
	}
	if = {
		limit = { has_consort_regency = no }
		random_owned_province = {
			limit = { has_province_modifier = domain_of_spouses_family }
			remove_province_modifier = domain_of_spouses_family
		}
	}
	if = {
		limit = { has_ruler_flag = accepted_help_from_spouses_family }
		clr_ruler_flag = accepted_help_from_spouses_family
	}
	if = {
		limit = { has_ruler_flag = helped_spouses_family }
		clr_ruler_flag = helped_spouses_family
	}
	if = {
		limit = { has_ruler_flag = refused_to_help_spouses_family }
		clr_ruler_flag = refused_to_help_spouses_family
	}
	if = {
		limit = { has_ruler_flag = lowborn_consort }
		random_owned_province = {
			limit = { has_province_modifier = home_of_consort }
			remove_province_modifier = home_of_consort
		}
	}
	if = {
		limit = { has_ruler_flag = lowborn_consort }
		clr_ruler_flag = lowborn_consort
	}
	if = {
		limit = { has_country_modifier = consort_adm_advice }
		remove_country_modifier = consort_adm_advice
	}
	if = {
		limit = { has_country_modifier = consort_dip_advice }
		remove_country_modifier = consort_dip_advice
	}
	if = {
		limit = { has_country_modifier = consort_mil_advice }
		remove_country_modifier = consort_mil_advice
	}
	if = {
		limit = { has_country_modifier = without_spouse_advice }
		remove_country_modifier = without_spouse_advice
	}
	if = {
		limit = { has_ruler_modifier = affectionate_royal_couple }
		remove_country_modifier = affectionate_royal_couple
	}
	clr_ruler_flag = marriage_length
}

# country
on_new_heir = {
}

# country 
on_weak_heir_claim = {
	events = {
		611		# Pretenders rise up
	}
}

# country : no heir in theocracy
on_heir_needed_theocracy = {
	events = {
		theocracy.1
	}
}

# Emperor from same dynasty
on_successive_emperor = {
	events = {
		900
	}
}

# HRE Prince released by the emperor
on_released_hre_member = {
	events = {
	}
}

# HRE Prince converts to non-Emperor religion
on_hre_member_false_religion = {
	events = {
	}
}

# HRE Prince converts to Emperor religion
on_hre_member_true_religion = {
	events = {
	}
}

# Emperor wins HRE defensive war
on_hre_wins_defensive_war = {
	events = {
	}
}

# HRE member annexed by non-HRE country
on_hre_member_annexed = {
	events = {
	}
}

# HRE member released from non-HRE vassalage
on_hre_released_vassal = {
	events = {
	}
}

# Emperor coming to the defense of a HRE member
on_hre_defense = {
	events = {
	}
}

# Emperor NOT coming to the defense of a HRE member
on_hre_non_defense = {
	events = {
		909
	}
}

# HRE Member takes a HRE province from an outs100e country in a peace (province scope)
on_hre_province_reconquest = {
	events = {
	}
}

# When a non-native changes government type
on_government_change = {
	if = {
		limit = {
			NOT = { government = monarchy }
			any_owned_province = {
				has_province_modifier = domain_of_spouses_family
			}
		}
		random_owned_province = {
			limit = { has_province_modifier = domain_of_spouses_family }
			remove_province_modifier = domain_of_spouses_family
		}
	} 
}

# When a native changes government after filling all their advancement groups.
on_native_change_government = {
}

# Nation is integrated after being in union
on_integrate = {
	events = {
		610
	}
}

# Nation annexed
on_annexed = {
	events = {
		japan.1
	}
}

on_dismantle_revolution = {
	change_government = absolute_monarchy
	kill_ruler = yes
	set_revolution_target = xxx
	if = {
		limit = { has_heir = yes }
		kill_heir = yes
	}
}

on_lock_hre_religion = {
	events = {
		religious_leagues.1
		religious_leagues.8
	}
}

on_change_hre_religion = {
	events = {
		religious_leagues.2
		religious_leagues.3
	}
}

on_hre_religion_white_peace = {
	events = {
		religious_leagues.4
	}
}

# province
on_adm_development = {
}

# province
on_dip_development = {
}

# province
on_mil_development = {
}

on_overextension_pulse = {
	random_events = {
		100 = overextension.1
		100 = overextension.2
		100 = overextension.3
		100 = overextension.4
		100 = overextension.5
		100 = overextension.6
		100 = overextension.7
		100 = overextension.8
		100 = overextension.9
		100 = overextension.10
	}
}


on_colonial_pulse = {
	random_events = {
		100 = colonial.1
		100 = colonial.2
		100 = colonial.3
		100 = colonial.4
		100 = colonial.5
		100 = colonial.6
		100 = colonial.7
		100 = colonial.8
		100 = colonial.9
		100 = colonial.10
		100 = colonial.11
		100 = colonial.12
		100 = colonial.13
		100 = colonial.14
		100 = colonial.15
		100 = colonial.16
		100 = colonial.17
		100 = colonial.18
		10000 = 0
	}
}

# country random events
on_bi_yearly_pulse = {
	random_events = {
		# randomevents.txt		
		100 = 3051
		100 = 5008
		100 = 5014
		100 = 5015
		100 = 5017
		100 = 5018
		100 = 5019
		100 = 5020
		100 = 5021
		100 = 5022
		100 = 5023
		100 = 5024
		100 = 5025
		100 = 5027
		100 = 5032
		100 = 5040
		100 = 5045
		100 = 5050
		100 = 5051
		100 = 5052
		100 = 5053
		100 = 5054
		100 = 5055
		100 = 5056
		100 = 5058
		100 = 5059
		100 = 5060
		100 = 5061
		100 = 5064
		100 = 5065
		100 = 5066
		100 = 5068
		100 = 5070
		100 = 5071
		100 = 5072
		100 = 5074
		100 = 5075
		100 = 5076
		100 = 5077
		100 = 5082
		100 = 5083
		100 = 5084
		100 = 5085
		100 = 5086
		100 = 5088
		100 = 5089
		100 = 5090
		100 = 5091
		100 = 5092
		100 = 5093
		100 = 5094
		100 = 5095
		100 = 5096
		100 = 5097
		100 = 5098
		100 = 5099
		100 = 6000
		100 = 6001
		100 = 6003
		100 = 6004
		100 = 6005
		100 = 6006
		100 = 6012
		100 = 6013
		100 = 6015
		100 = 710
		100 = 711
		100 = 712
		100 = 713
		100 = 714
		100 = 715
		100 = 716
		100 = 717
		100 = 718
		100 = 719
		100 = 720
		100 = 722
		100 = 723
		100 = 724
		100 = 725
		100 = 726
		100 = 727
		100 = 728
		100 = 729
		100 = 730
		100 = 731
		100 = 732
		100 = 733
		100 = 734
		100 = 735
		100 = 736
		100 = 737
		100 = 738
		100 = 739
		100 = 740
		100 = 741
		100 = 742
		
		100 = 850
		100 = 851
		100 = 852
		100 = 853
		100 = 854
		100 = 855
		100 = 857
		100 = 858
		100 = 859
		100 = 860
		100 = 861
		100 = 862
		100 = 863
		100 = 864
		100 = 865
		100 = 866
		100 = 867
		100 = 868
		100 = 869
		100 = 870
		100 = 871
		100 = 872
		100 = 873
		100 = 874
		100 = 875
		100 = 876
		100 = 877
		100 = 878
		100 = 879
		100 = 880
		100 = 881
		100 = 882
		100 = 883
		100 = 884
		100 = 885
		100 = 836
		100 = 837
		100 = 838
		
		100 = 9472
		100 = 3097
		100 = 5005
		100 = 5026
		100 = 5037
		100 = 5063
		100 = 6014
		
		100 = random_event.1
		100 = random_event.2
		100 = random_event.3
		100 = random_event.4
		100 = random_event.5
		100 = random_event.6
		100 = random_event.7
		100 = random_event.8
		100 = random_event.9
		100 = random_event.10
		100 = random_event.11
		100 = random_event.12
		100 = random_event.13
		100 = random_event.14
		100 = random_event.15
		100 = random_event.16
		
		100 = random_event.26

		# Old Centralisation/Decentralisation		
		100 = 806

		# Mercantilism
		100 = 6326
		100 = 6327
		100 = 6328
		100 = 6329

		# Trade Specific
		100 = trade.1
		100 = trade.2
		100 = trade.3
		100 = trade.4
		100 = trade.5
		100 = trade.6
		100 = trade.7
		100 = trade.8
		100 = trade.9
		100 = trade.10
		100 = trade.11
		100 = trade.12
		
		# Catholic  Events      
		100 = catholic_flavor.4 
		100 = catholic_flavor.5 
		100 = catholic_flavor.6 
		100 = catholic_flavor.7 
		100 = catholic_flavor.8 
		100 = catholic_flavor.9 
		100 = catholic_flavor.10
		
		# Tradegoods events
		100 = 6418
		100 = 6419
		100 = 6420
		100 = 6421
		100 = 6422
		100 = 6423
		100 = 6424
		100 = 6425
		100 = 6426
		100 = 6427
		100 = 6428
		100 = 6429
		100 = 6431
		100 = 6432
		100 = 6433
		100 = 6434

		# Refoms, when having parliaments.
		100 = reforms.1
		100 = reforms.2
		100 = reforms.3
		100 = reforms.4		

		100 = randomeventsstapehordes.1
		100 = randomeventsstapehordes.2
		100 = randomeventsstapehordes.3
		100 = randomeventsstapehordes.4
		100 = randomeventsstapehordes.5
		100 = randomeventsstapehordes.6
		100 = randomeventsstapehordes.7
		100 = randomeventsstapehordes.8
		100 = randomeventsstapehordes.13
		100 = randomeventsstapehordes.14
		100 = randomeventsstapehordes.17
		100 = randomeventsstapehordes.18
		100 = randomeventsstapehordes.19
		100 = randomeventsstapehordes.20
		100 = randomeventsstapehordes.21
		100 = randomeventsstapehordes.22
		100 = randomeventsstapehordes.23
		100 = randomeventsstapehordes.24

		# Sailor events
		100 = sailor_event.1
		100 = sailor_event.2
		100 = sailor_event.3
		100 = sailor_event.4
		100 = sailor_event.5

		# Corruption Events
		100 = corruption_event.16
		100 = corruption_event.17
		100 = corruption_event.18
		100 = corruption_event.19
		100 = corruption_event.20

		# Trade League Events
		100 = trade_league.1
		100 = trade_league.2
		100 = trade_league.3
		100 = trade_league.4
		100 = trade_league.7
		100 = trade_league.8
		100 = trade_league.9
		100 = trade_league.10
		100 = trade_league.11
		100 = trade_league.12
		100 = trade_league.13
		100 = trade_league.14
		
		# Institution Events
		#Feudalism Spread Events:
		100 = institution_events.8
		100 = institution_events.9
		100 = institution_events.10
		100 = institution_events.11
		
		
		#Personality Events
		25 = personality_events.10 #Just Dilema
		25 = personality_events.11 #A righteous King
		25 = personality_events.12 #A Righteous Republican Ruler
		25 = personality_events.13
		25 = personality_events.14
		25 = personality_events.15
		25 = personality_events.16
		25 = personality_events.17
		25 = personality_events.18
		25 = personality_events.19
		25 = personality_events.20
		25 = personality_events.21
		25 = personality_events.22
		25 = personality_events.23
		25 = personality_events.24
		25 = personality_events.25
		25 = personality_events.26
		25 = personality_events.27
		25 = personality_events.28
		25 = personality_events.29
		25 = personality_events.30
		25 = personality_events.31
		25 = personality_events.32
		25 = personality_events.33
		25 = personality_events.34
		25 = personality_events.35
		25 = personality_events.36
		25 = personality_events.37
		25 = personality_events.38
		25 = personality_events.39
		25 = personality_events.40
		25 = personality_events.41
		25 = personality_events.42
		25 = personality_events.43
		25 = personality_events.44
		25 = personality_events.45
		25 = personality_events.46
		25 = personality_events.47
		25 = personality_events.48
		25 = personality_events.49
		25 = personality_events.50
		25 = personality_events.51
		25 = personality_events.52
		25 = personality_events.53
		25 = personality_events.54
		25 = personality_events.55
		25 = personality_events.56
		25 = personality_events.57
		25 = personality_events.58
		
		1000 = 0
	}
}

on_bi_yearly_pulse_2 = {
	random_events = {
		100 = corruption_event.1
		100 = corruption_event.2
		100 = corruption_event.3
		100 = corruption_event.4
		100 = corruption_event.5
		100 = corruption_event.6
		100 = corruption_event.7
		100 = corruption_event.8
		100 = corruption_event.9
		100 = corruption_event.10
		200 = corruption_event.11
		200 = corruption_event.12
		200 = corruption_event.13
		200 = corruption_event.14
		200 = corruption_event.15

		4000 = 0
	}
}

on_bi_yearly_pulse_3 = {
}

on_bi_yearly_pulse_4 = {
}

# country random events
on_thri_yearly_pulse = {
	random_events = {
		# Republics
		100 = republics.4
		100 = republics.5
		100 = republics.6
		100 = republics.7
		100 = republics.8
		100 = republics.9
		100 = republics.10
		100 = republics.11
		100 = republics.12
		100 = republics.13
		100 = republics.14
		100 = republics.15
		100 = republics.16
		100 = republics.17
		100 = republics.18
		100 = republics.19
		100 = republics.20
		100 = republics.21
		100 = republics.22
		100 = republics.23
		100 = republics.24
		100 = republics.25
		100 = republics.26
		100 = republics.27
		100 = republics.28
		100 = republics.29
		100 = republics.30
		100 = republics.31
		100 = republics.32
		100 = republics.33
		100 = republics.34
		100 = republics.35
		100 = republics.36
		100 = republics.37
		100 = republics.38
		100 = republics.39
		100 = republics.40
		100 = republics.41
		100 = republics.42
		100 = republics.43		
		
		# Theocracies
		100 = devotion_events.1
		100 = devotion_events.2
		100 = devotion_events.3
		100 = devotion_events.4
		100 = devotion_events.5
		100 = devotion_events.6
		100 = devotion_events.7
		100 = devotion_events.8
		100 = devotion_events.9
		100 = devotion_events.10
		100 = devotion_events.11
		100 = devotion_events.12
		100 = devotion_events.13
		100 = devotion_events.14
		100 = devotion_events.15
		100 = devotion_events.16
		100 = devotion_events.18
		100 = devotion_events.19
		100 = devotion_events.22
		100 = devotion_events.23
		100 = devotion_events.24
		100 = devotion_events.26
		100 = devotion_events.100
		100 = devotion_events.101
		100 = devotion_events.102
		100 = devotion_events.104
		100 = devotion_events.107
		100 = devotion_events.110
		100 = devotion_events.117
		100 = devotion_events.118
		100 = devotion_events.119
		100 = devotion_events.100
		100 = devotion_events.200
		100 = devotion_events.201
		100 = devotion_events.202
		100 = devotion_events.203
		100 = devotion_events.204
		100 = devotion_events.205
		100 = devotion_events.207
		100 = devotion_events.208
		100 = devotion_events.209
		100 = devotion_events.210
		100 = devotion_events.211
		100 = devotion_events.212
		100 = devotion_events.213
		100 = devotion_events.214
		100 = devotion_events.215
		100 = devotion_events.216
		100 = devotion_events.217
		100 = devotion_events.218
		100 = devotion_events.219
		
		1000 = 0		
	}
}

on_thri_yearly_pulse_2 = {
	random_events = {
		# Random to increase or decrease patriarch authority.
		25 = orthodox_flavor.1
		25 = orthodox_flavor.2
		25 = orthodox_flavor.3
		25 = orthodox_flavor.4
		25 = orthodox_flavor.5
		
		# Muslim Piety Events
		50 = muslim_piety.1
		50 = muslim_piety.2
		50 = muslim_piety.3
		50 = muslim_piety.4
		50 = muslim_piety.5
		50 = muslim_piety.6
		50 = muslim_piety.7
		50 = muslim_piety.8
		50 = muslim_piety.9
		50 = muslim_piety.10
		50 = muslim_piety.11
		50 = muslim_piety.12
		50 = muslim_piety.13
		50 = muslim_piety.14
		50 = muslim_piety.15
		50 = muslim_piety.16
		300 = 0		
	}
}

on_thri_yearly_pulse_3 = {
	random_events = {
		# Subject Interactions
		50 = subject_interaction_events.1
		50 = subject_interaction_events.4
		50 = subject_interaction_events.5
		50 = subject_interaction_events.6
		50 = subject_interaction_events.7
		50 = subject_interaction_events.9
		50 = subject_interaction_events.11
		50 = subject_interaction_events.14
		50 = subject_interaction_events.15
		50 = subject_interaction_events.17
		50 = subject_interaction_events.18
		50 = subject_interaction_events.19
		50 = subject_interaction_events.20
		50 = subject_interaction_events.21
		50 = subject_interaction_events.22
		50 = subject_interaction_events.23
		50 = subject_interaction_events.24
		50 = subject_interaction_events.25
		50 = subject_interaction_events.26
		50 = subject_interaction_events.27
		50 = subject_interaction_events.28
		50 = subject_interaction_events.29
		50 = subject_interaction_events.30
		50 = subject_interaction_events.31
		50 = subject_interaction_events.32
		50 = subject_interaction_events.34
		50 = subject_interaction_events.35
		50 = subject_interaction_events.36
		50 = subject_interaction_events.38
		50 = subject_interaction_events.40
		50 = subject_interaction_events.43
		1000 = 0
	}
}

on_thri_yearly_pulse_4 = {
}

on_four_year_pulse = {
	random_events = {
		# Colonial Nations
		100 = colonial_nation.1
		100 = colonial_nation.4
		100 = colonial_nation.10
		100 = colonial_nation.12
		100 = colonial_nation.14
		100 = colonial_nation.77
		100 = colonial_nation.100
		100 = colonial_nation.102
		100 = colonial_nation.104
		100 = colonial_nation.106
		100 = colonial_nation.108
		100 = colonial_nation.110
		100 = colonial_nation.112
		100 = colonial_nation.114
		100 = colonial_nation.116
		100 = colonial_nation.118
		100 = colonial_nation.120
		100 = colonial_nation.122
		100 = colonial_nation.124
		100 = colonial_nation.126
		100 = colonial_nation.128
		100 = colonial_nation.130
		100 = colonial_nation.132
		100 = colonial_nation.134

		# Dutch Republic
		100 = dutch_republic.1
		100 = dutch_republic.2
		100 = dutch_republic.3
		100 = dutch_republic.4
		100 = dutch_republic.5
		100 = dutch_republic.6
		100 = dutch_republic.7
		100 = dutch_republic.8
		100 = dutch_republic.9
		100 = dutch_republic.10
		150 = dutch_republic.11
		100 = dutch_republic.13
		100 = dutch_republic.14
		100 = dutch_republic.15
		100 = dutch_republic.16
		100 = dutch_republic.17
		100 = dutch_republic.18
		100 = dutch_republic.19
		100 = dutch_republic.20
		100 = dutch_republic.21
		100 = dutch_republic.22
		100 = dutch_republic.23
		100 = dutch_republic.24
		100 = dutch_republic.25
		100 = dutch_republic.27
		
		# Republic Factions
		100 = republic_factions.2
		100 = republic_factions.5
		100 = republic_factions.7
		100 = republic_factions.9
		100 = republic_factions.10
		100 = republic_factions.12
		100 = republic_factions.13
		100 = republic_factions.14
		100 = republic_factions.15
		100 = republic_factions.16
		100 = republic_factions.17
		100 = republic_factions.18
		100 = republic_factions.19
		100 = republic_factions.20
		100 = republic_factions.22
		100 = republic_factions.23
		100 = republic_factions.24
		
		# Revolutionary Republic Factions
		
		100 = revolutionary_republic_factions.0
		100 = revolutionary_republic_factions.1
		100 = revolutionary_republic_factions.2
		100 = revolutionary_republic_factions.3
		100 = revolutionary_republic_factions.4
		100 = revolutionary_republic_factions.5
		100 = revolutionary_republic_factions.6
		100 = revolutionary_republic_factions.7
		100 = revolutionary_republic_factions.8
		100 = revolutionary_republic_factions.9

		# Republican Dictatorship
		100 = republican_dictatorship.1
		100 = republican_dictatorship.2
		100 = republican_dictatorship.3
		100 = republican_dictatorship.4
		100 = republican_dictatorship.5
		100 = republican_dictatorship.6
		100 = republican_dictatorship.7
		100 = republican_dictatorship.8

		# Elective Monarchy
		150 = elective_monarchy.1
		150 = elective_monarchy.2
		25 = elective_monarchy.3
		25 = elective_monarchy.4
		150 = elective_monarchy.6
		150 = elective_monarchy.8
		150 = elective_monarchy.9
		150 = elective_monarchy.10
		150 = elective_monarchy.11
		150 = elective_monarchy.12
		150 = elective_monarchy.14
		150 = elective_monarchy.17
		25 = elective_monarchy.18

		# Free Cities
		25 = free_cities.3
		25 = free_cities.7
		25 = free_cities.8
		25 = free_cities.10
		25 = free_cities.13
		25 = free_cities.17
		25 = free_cities.19
		
		1000 = 0	
	}
}

on_four_year_pulse_2 = {
}

on_four_year_pulse_3 = {
}

on_four_year_pulse_4 = {
}

on_five_year_pulse = {
	random_events = {

		# Aristocracy 		13  (8g 5b)
		100 = ideagroups.100
		100 = ideagroups.101
		100 = ideagroups.102
		100 = ideagroups.103
		100 = ideagroups.104
		100 = ideagroups.105
		100 = ideagroups.106
		100 = ideagroups.107
		100 = ideagroups.108
		100 = ideagroups.109
		100 = ideagroups.110
		100 = ideagroups.111
		100 = ideagroups.112

	
		# Plutocracy 		19 (12g 7b)
		100 = ideagroups.200
		100 = ideagroups.201
		100 = ideagroups.202
		100 = ideagroups.203
		100 = ideagroups.204
		100 = ideagroups.205
		100 = ideagroups.206
		100 = ideagroups.207
		100 = ideagroups.208
		100 = ideagroups.209
		100 = ideagroups.210
		100 = ideagroups.211
		100 = ideagroups.212
		100 = ideagroups.213
		100 = ideagroups.214
		100 = ideagroups.215
		100 = ideagroups.216
		100 = ideagroups.217
		100 = ideagroups.218

		# Innovativenes		11 (7g 4b)
		100 = ideagroups.300
		100 = ideagroups.301
		100 = ideagroups.302
		100 = ideagroups.303
		100 = ideagroups.304
		100 = ideagroups.305
		100 = ideagroups.306
		100 = ideagroups.307
		100 = ideagroups.308
		100 = ideagroups.309
		100 = ideagroups.310

		# Religious		18 (11g 7b)
		100 = ideagroups.400
		100 = ideagroups.401
		100 = ideagroups.402
		100 = ideagroups.403
		100 = ideagroups.404
		100 = ideagroups.405
		100 = ideagroups.406
		100 = ideagroups.407
		100 = ideagroups.408
		100 = ideagroups.409
		100 = ideagroups.410
		100 = ideagroups.411
		100 = ideagroups.412
		100 = ideagroups.413
		100 = ideagroups.414
		100 = ideagroups.415
		100 = ideagroups.416
		100 = ideagroups.417
		

		# Spy			9 (6g 3b)
		100 = ideagroups.500
		100 = ideagroups.501
		100 = ideagroups.502
		100 = ideagroups.503
		100 = ideagroups.504
		100 = ideagroups.505
		100 = ideagroups.506
		100 = ideagroups.507
		100 = ideagroups.508
		
		
		# Diplomatic		9 (6g 3b)
		100 = ideagroups.600
		100 = ideagroups.601
		100 = ideagroups.602
		100 = ideagroups.603
		100 = ideagroups.604
		100 = ideagroups.605
		100 = ideagroups.606
		100 = ideagroups.607
		100 = ideagroups.608


		# Offensive 		14 (9g 5b)
		100 = ideagroups.700
		100 = ideagroups.701
		100 = ideagroups.702
		100 = ideagroups.703
		100 = ideagroups.704
		100 = ideagroups.705
		100 = ideagroups.706
		100 = ideagroups.707
		100 = ideagroups.708
		100 = ideagroups.709
		100 = ideagroups.710
		100 = ideagroups.711
		100 = ideagroups.712
		100 = ideagroups.713

		
		# Defensive		11 (5g 6b)
		100 = ideagroups.800
		100 = ideagroups.801
		100 = ideagroups.802
		100 = ideagroups.803
		100 = ideagroups.804
		100 = ideagroups.805
		100 = ideagroups.806
		100 = ideagroups.807
		100 = ideagroups.808
		100 = ideagroups.809
		100 = ideagroups.810
		100 = ideagroups.811
		100 = ideagroups.812
		100 = ideagroups.813
		100 = ideagroups.814
		100 = ideagroups.815

		
		# Trade			6 (7g 4b)
		100 = ideagroups.900
		100 = ideagroups.901
		100 = ideagroups.902
		100 = ideagroups.903
		100 = ideagroups.904
		100 = ideagroups.905
		100 = ideagroups.906
		100 = ideagroups.907
		100 = ideagroups.908
		100 = ideagroups.909
		100 = ideagroups.910
		
		# Maritime			22 (14g 8b)
		100 = ideagroups.1000
		100 = ideagroups.1001
		100 = ideagroups.1002
		100 = ideagroups.1003
		100 = ideagroups.1004
		100 = ideagroups.1005
		100 = ideagroups.1006
		100 = ideagroups.1007
		100 = ideagroups.1008
		100 = ideagroups.1009
		100 = ideagroups.1010
		100 = ideagroups.1011
		100 = ideagroups.1012
		100 = ideagroups.1013
		100 = ideagroups.1014
		100 = ideagroups.1015
		100 = ideagroups.1016
		100 = ideagroups.1017
		100 = ideagroups.1018
		100 = ideagroups.1019
		100 = ideagroups.1020
		100 = ideagroups.1021
		
		# Economic		11 (7g 4b)
		100 = ideagroups.1100
		100 = ideagroups.1101
		100 = ideagroups.1102
		100 = ideagroups.1103
		100 = ideagroups.1104
		100 = ideagroups.1105
		100 = ideagroups.1106
		100 = ideagroups.1107
		100 = ideagroups.1108
		100 = ideagroups.1109
		100 = ideagroups.1110
		
		# Exploration		11 (7g 4b)
		100 = ideagroups.1200
		100 = ideagroups.1201
		100 = ideagroups.1202
		100 = ideagroups.1203
		100 = ideagroups.1204
		100 = ideagroups.1205
		100 = ideagroups.1206
		100 = ideagroups.1207
		100 = ideagroups.1208
		100 = ideagroups.1209
		100 = ideagroups.1210
		
		# Quality		11 (7g 4b)
		100 = ideagroups.1300
		100 = ideagroups.1301
		100 = ideagroups.1302
		100 = ideagroups.1303
		100 = ideagroups.1304
		100 = ideagroups.1305
		100 = ideagroups.1306
		100 = ideagroups.1307
		100 = ideagroups.1308
		100 = ideagroups.1309
		100 = ideagroups.1310
		
		# Quantity		11 (7g 4b)
		100 = ideagroups.1400
		100 = ideagroups.1401
		100 = ideagroups.1402
		100 = ideagroups.1403
		100 = ideagroups.1404
		100 = ideagroups.1405
		100 = ideagroups.1406
		100 = ideagroups.1407
		100 = ideagroups.1408
		100 = ideagroups.1409
		100 = ideagroups.1410
		

		# Expansion		11 (7g 4b)
		100 = ideagroups.1500
		100 = ideagroups.1501
		100 = ideagroups.1502
		100 = ideagroups.1503
		100 = ideagroups.1504
		100 = ideagroups.1505
		100 = ideagroups.1506
		100 = ideagroups.1507
		100 = ideagroups.1508
		100 = ideagroups.1509
		100 = ideagroups.1510
		
		# Administrative	3 (1g 2b)
		100 = ideagroups.1600
		100 = ideagroups.1601
		100 = ideagroups.1602
		100 = ideagroups.1603
		100 = ideagroups.1604
		100 = ideagroups.1605
		100 = ideagroups.1606
		100 = ideagroups.1607
		100 = ideagroups.1608
		100 = ideagroups.1609
		100 = ideagroups.1610

		# Naval		11 (7g 4b)
		100 = ideagroups.1700
		100 = ideagroups.1701
		100 = ideagroups.1702
		100 = ideagroups.1703
		100 = ideagroups.1704
		100 = ideagroups.1705
		100 = ideagroups.1706
		100 = ideagroups.1707
		100 = ideagroups.1708
		100 = ideagroups.1709
		100 = ideagroups.1710

		# Influence		11 (7g 4b)
		100 = ideagroups.1800
		100 = ideagroups.1801
		100 = ideagroups.1802
		100 = ideagroups.1803
		100 = ideagroups.1804
		100 = ideagroups.1805
		100 = ideagroups.1806
		100 = ideagroups.1807
		100 = ideagroups.1808
		100 = ideagroups.1809
		100 = ideagroups.1810
		
		# Humanist		11 (7g 4b)
		100 = ideagroups.1900
		100 = ideagroups.1901
		100 = ideagroups.1902
		100 = ideagroups.1903
		100 = ideagroups.1904
		100 = ideagroups.1905
		100 = ideagroups.1906
		100 = ideagroups.1907
		100 = ideagroups.1908
		100 = ideagroups.1909
		100 = ideagroups.1910
		
		1000 = 0
	}
	
	events = {
		seven_cities_events.1000 #Clearing of Seven Cities Hunt when goal is no longer possible
	}
}


# Estates pulse
on_five_year_pulse_2 = {
	random_events = {	
		# Burghers	
		100 = burghers_estate_events.1
		100 = burghers_estate_events.2
		100 = burghers_estate_events.3
		100 = burghers_estate_events.4
		100 = burghers_estate_events.5
		100 = burghers_estate_events.6
		100 = burghers_estate_events.7
		100 = burghers_estate_events.8
		100 = burghers_estate_events.9
		400 = burghers_estate_events.10 #Demands
		100 = burghers_estate_events.11 #Bonus
		100 = burghers_estate_events.12
		100 = burghers_estate_events.13
		400 = burghers_estate_events.14 #Demands
		100 = burghers_estate_events.15 #Disloyal
		# Nobles
		100 = nobles_estate_events.1 #Demands
		100 = nobles_estate_events.2
		100 = nobles_estate_events.3
		100 = nobles_estate_events.4
		400 = nobles_estate_events.5 #Demands
		100 = nobles_estate_events.6
		100 = nobles_estate_events.7
		400 = nobles_estate_events.8 #Disloyal
		400 = nobles_estate_events.9 #Disloyal
		50 = nobles_estate_events.10
		100 = nobles_estate_events.11 #Bonus
		# Clergy
		100 = church_estate_events.1
			#Regional Variations:
			100 = church_estate_events.101 
			100 = church_estate_events.102
			100 = church_estate_events.103
			100 = church_estate_events.104
			100 = church_estate_events.105
		100 = church_estate_events.2
		100 = church_estate_events.3
		100 = church_estate_events.4
		400 = church_estate_events.5 #Disloyal
		400 = church_estate_events.6 #Demands
		100 = church_estate_events.7 #Bonus
		100 = church_estate_events.8
		100 = church_estate_events.9
		100 = church_estate_events.10
		# Dhimmi
		100 = dhimmi_estate_events.1
		400 = dhimmi_estate_events.2 #Demands
		100 = dhimmi_estate_events.3
		100 = dhimmi_estate_events.4
		100 = dhimmi_estate_events.5
		100 = dhimmi_estate_events.6
		400 = dhimmi_estate_events.7 #Disloyal
		100 = dhimmi_estate_events.8
		# Cossacks
		100 = cossack_estate_events.1
		#100 = cossack_estate_events.2 (triggers in neighbor country)
		100 = cossack_estate_events.8
		100 = cossack_estate_events.9
		100 = cossack_estate_events.10
		100 = cossack_estate_events.11
		400 = cossack_estate_events.12 #Disloyal
		100 = cossack_estate_events.13
		400 = cossack_estate_events.14 #Demands
		# Tribes
		100 = tribal_estate_events.1
		100 = tribal_estate_events.2
		100 = tribal_estate_events.3
		100 = tribal_estate_events.4
		100 = tribal_estate_events.5
		100 = tribal_estate_events.6
		100 = tribal_estate_events.7
		100 = tribal_estate_events.8
		100 = tribal_estate_events.9
		150 = tribal_estate_events.11 #Demands
		150 = tribal_estate_events.12 #Demands
		150 = tribal_estate_events.13 #Demands
		150 = tribal_estate_events.14 #Demands
		
		1000 = 0              
	}
}

on_five_year_pulse_3 = {
}

on_five_year_pulse_4 = {
}

# El Dorado
on_explore_coast = {
	random_events = {
		10 = exploration_events.1
		10 = exploration_events.2
		10 = exploration_events.3
		10 = exploration_events.4
		10 = exploration_events.5
		10 = exploration_events.6
		10 = exploration_events.7
		10 = exploration_events.8
		10 = exploration_events.9
		10 = exploration_events.10
		10 = exploration_events.11
		10 = exploration_events.12
		10 = exploration_events.13
		10 = exploration_events.14
		10 = exploration_events.15
	}
}
on_conquistador_empty = {
	random_events = {
		10 = seven_cities_events.1
		10 = seven_cities_events.2
		10 = seven_cities_events.3
		10 = seven_cities_events.4
		10 = seven_cities_events.5
		10 = seven_cities_events.6
		10 = seven_cities_events.7
		10 = seven_cities_events.8
		
		10 = seven_cities_events.100
		10 = seven_cities_events.101
		10 = seven_cities_events.102
		10 = seven_cities_events.103
		10 = seven_cities_events.104
		10 = seven_cities_events.105
		
		50 = seven_cities_events.200
		50 = seven_cities_events.201
		50 = seven_cities_events.202
		50 = seven_cities_events.203
		50 = seven_cities_events.204
		50 = seven_cities_events.205
		50 = seven_cities_events.206
		50 = seven_cities_events.207
		50 = seven_cities_events.208
		50 = seven_cities_events.209
		50 = seven_cities_events.210
		50 = seven_cities_events.211
		50 = seven_cities_events.212
		50 = seven_cities_events.213
		50 = seven_cities_events.214
		50 = seven_cities_events.215
		50 = seven_cities_events.216
		50 = seven_cities_events.217
		50 = seven_cities_events.218
		50 = seven_cities_events.219
		50 = seven_cities_events.220
		50 = seven_cities_events.221
		50 = seven_cities_events.222
		50 = seven_cities_events.223
		
		10 = seven_cities_events.302
		10 = seven_cities_events.303
		10 = seven_cities_events.308
		10 = seven_cities_events.309
		
		10 = seven_cities_events.400
		10 = seven_cities_events.401
		10 = seven_cities_events.402
		10 = seven_cities_events.405
		10 = seven_cities_events.406
		10 = seven_cities_events.407
		10 = seven_cities_events.408
		10 = seven_cities_events.409
		10 = seven_cities_events.410
		10 = seven_cities_events.413
		10 = seven_cities_events.414
		
		2000 = 0
	}
}

on_conquistador_native = {
	random_events = {
		10 = seven_cities_events.300
		10 = seven_cities_events.301
		10 = seven_cities_events.303
		10 = seven_cities_events.304
		10 = seven_cities_events.305
		10 = seven_cities_events.306
		10 = seven_cities_events.307
		10 = seven_cities_events.308
		10 = seven_cities_events.309
		10 = seven_cities_events.310
		
		250 = 0
	}
}

on_buy_religious_reform = {
	events = {
		religious_reforms.1
		religious_reforms.2
		religious_reforms.3
	}
}

on_circumnavigation = {
	events = {
		exploration_events.17
		exploration_events.16 #First Circumnavigation Europe
	}
}

on_become_free_city = {
	events = {
		free_cities.1
	}
}

on_remove_free_city = {
	events = {
		free_cities.2
	}
}

on_revoke_estate_land_ai = { #AI can't handle the rebels atm or perform a gradual revoke, sorry
}

on_revoke_estate_land = {
	if = {
		limit = {
			has_estate = estate_cossacks
			owner = {
				NOT = {
					estate_loyalty = {
						estate = estate_cossacks
						loyalty = 40
					}
				}
			}
		}
		spawn_rebels = {
			type = cossack_rebels
			size = 1
		}
		province_event = { id = cossack_estate_events.15 }
	}
	if = {
		limit = {
			has_estate = estate_dhimmi
			owner = {
				NOT = {
					estate_loyalty = {
						estate = estate_dhimmi
						loyalty = 40
					}
				}
			}
		}
		spawn_rebels = {
			type = religious_rebels
			size = 1
		}
		province_event = { id = dhimmi_estate_events.9 }
	}
	if = {
		limit = {
			has_estate = estate_church
			has_owner_religion = yes
			owner = {
				NOT = {
					estate_loyalty = {
						estate = estate_church
						loyalty = 40
					}
				}
			}
		}
		spawn_rebels = {
			type = religious_rebels
			size = 1
		}
		province_event = { id = church_estate_events.11 }
	}
	if = {
		limit = {
			has_estate = estate_church
			has_owner_religion = no
			owner = {
				NOT = {
					estate_loyalty = {
						estate = estate_church
						loyalty = 40
					}
				}
			}
		}
		spawn_rebels = {
			type = particularist_rebels
			size = 1
		}
		province_event = { id = church_estate_events.11 }
	}
	if = {
		limit = {
			has_estate = estate_nobles
			owner = {
				NOT = {
					estate_loyalty = {
						estate = estate_nobles
						loyalty = 40
					}
				}
			}
		}
		spawn_rebels = {
			type = noble_rebels
			size = 1
		}
		province_event = { id = nobles_estate_events.12 }
	}
	if = {
		limit = {
			has_estate = estate_burghers
			owner = {
				NOT = {
					estate_loyalty = {
						estate = estate_burghers
						loyalty = 40
					}
				}
			}
		}
		spawn_rebels = {
			type = particularist_rebels
			size = 1
		}
		province_event = { id = burghers_estate_events.16 }
	}
	if = {
		limit = {
			has_estate = estate_nomadic_tribes
			owner = {
				NOT = {
					estate_loyalty = {
						estate = estate_nomadic_tribes
						loyalty = 40
					}
				}
			}
		}
		spawn_rebels = {
			type = tribal_rebels
			size = 1
		}
	}
}

on_grant_estate_land = {
}

on_death_has_harem = {
	if = {
		limit = {
			has_heir = no
		}
		country_event = { id = harem_events.2 }
	}
}

on_select_heir_from_harem = {
}

on_fetishist_cult_change = {
	country_event = { id = fetishist_flavor.302 days = 10 } #removing tomb if incompatible cult is picked
	country_event = { id = fetishist_flavor.304 days = 10 } #rebuilding tomb if lost
	if = {
		limit = {
			has_country_flag = lost_ancestral_lands
			NOT = { has_adopted_cult = zanahary_cult }
			NOT = { has_adopted_cult = central_african_ancestor_cult }
		}
		clr_country_flag = lost_ancestral_lands
	}
}

# country
on_gain_great_power_status = {
	if = {
		limit = {
			NOT = { has_country_flag = became_great_power_flag }
		}
		set_country_flag = became_great_power_flag
	}
}

# country
on_lose_great_power_status = {
}

# province
on_province_religion_converted = {
}

# province
on_province_culture_converted = {
}

# province
on_province_owner_change = {
}