namespace = cc_events_performance

#monthly
event = {
	id = cc_events_performance.1
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		every_country = {
			if = {
				limit = {
					any_country = {
						OR = {
							is_hostile_to = prev
							is_rival = prev
							is_domineering_to = prev
						}
						relative_power = {
							who = prev
							category = fleet
							value = overwhelming
						}
					}
				}
				set_timed_country_flag = {
					flag = cc_eventperf_has_overwhelming_rival
					months = 1
				}
			}
			if = {
				limit = {
					any_country = {
						OR = {
							is_hostile_to = prev
							is_rival = prev
							is_domineering_to = prev
						}
						relative_power = {
							who = prev
							category = fleet
							value = superior
						}
					}
				}
				set_timed_country_flag = {
					flag = cc_eventperf_has_superior_rival
					months = 1
				}
			}
		}
	}
}


#yearly
event = {
	id = cc_events_performance.1999
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		every_playable_country = {
			country_event = { id = cc_events_performance.11112 days = 1 random = 3 }
		}
	}
}


country_event = {
	id = cc_events_performance.11112
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				OR = {
					AND = {
						pop_amount_percentage = {
							percentage < 0.4
							limit = { is_same_species = root }
						}
						any_owned_species = {
							NOT = { is_same_species = prev }
							species_has_happiness_with_owner = prev
							is_robotic_species = no
							OR = {
								has_citizenship_type = { country = prev type = citizenship_full }
								has_citizenship_type = { country = prev type = citizenship_limited }
							}
						}
					}
				
					any_owned_species = {
						NOT = { is_same_species = prev }
						species_has_happiness_with_owner = prev
						is_robotic_species = no
						OR = {
							has_citizenship_type = { country = prev type = citizenship_full }
							has_citizenship_type = { country = prev type = citizenship_limited }
						}
						root = {
							pop_amount_percentage = {
								percentage > 0.1
								limit = { is_same_species = prev }
							}
						}
					}
				}
			}
			set_timed_country_flag = {
				flag = cc_eventperf_has_minority
				years = 1
			}
			if = {
				limit = {
					pop_amount_percentage = {
						percentage < 0.4
						limit = { is_same_species = owner_species }
					}
				}
				set_timed_country_flag = {
					flag = cc_eventperf_founder_is_minority
					years = 1
				}
			}
			if = {
				limit = {
					any_owned_species = {
						NOR = {
							is_subspecies = prev
							is_same_species = prev
						}
						species_has_happiness_with_owner = prev
						is_robotic_species = no
						OR = {
							has_citizenship_type = { country = prev type = citizenship_full }
							has_citizenship_type = { country = prev type = citizenship_limited }
						}
						prev = {
							pop_amount_percentage = {
								percentage > 0.25
								limit = { is_same_species = prev }
							}
						}
					}
				}
				set_timed_country_flag = {
					flag = cc_eventperf_has_large_minority
					years = 1
				}
			}
		}
		if = {
			limit = {
				is_xenophobe = no

				any_pop_faction = {
					OR = {
						is_pop_faction_type = supremacist
						is_pop_faction_type = isolationist
					}
					support > 0.18
				}
			}
			set_timed_country_flag = {
				flag = cc_eventperf_has_lots_of_xenophobes_min
				years = 1
			}
		}

		if = {
			limit = {
				any_pop_faction = {
					is_pop_faction_type = traditionalist
					support > 0.1
				}
			}
			set_timed_country_flag = {
				flag = cc_enough_spiritualists
				years = 1
			}
		}
		if = {
			limit = {
				any_pop_faction = {
					is_pop_faction_type = technologist
					support > 0.33
				}
			}
			set_timed_country_flag = {
				flag = cc_many_materialists
				years = 1
			}
			if = {
				limit = {
					any_pop_faction = {
						is_pop_faction_type = technologist
						support > 0.5
					}
				}
				set_timed_country_flag = {
					flag = cc_lots_materialists
					years = 1
				}
			}
		}
		if = {
			limit = {
				any_pop_faction = {
					is_pop_faction_type = progressive
					support > 0.1
				}
			}
			set_timed_country_flag = {
				flag = cc_enough_egalitarians
				years = 1
			}
		}
		if = {
			limit = {
				any_pop_faction = {
					is_pop_faction_type = totalitarian
					support > 0.4
				}
			}
			set_timed_country_flag = {
				flag = cc_many2_authoritarians
				years = 1
			}
		}
	}
}



