#############################################
#											#
# Nemesis Crisis Menace Objective Events 	#
#		 Written by Hadrien Buytaers		#
#											#
#############################################

namespace = crisis

# Menace Objective - Research Technologies
country_event = {
	id = crisis.7000
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		this = {
			has_ascension_perk = ap_cosmogenesis
		}
	}

	immediate = {
		complete_crisis_objective = crisobj_research_tech
	}
}

# Menace Objective - Research Thesis
# Handled directly in the Thesis events
# Also covers the secrets of the Vultaum things

# Menace Objective - Have Scholarium Vassals
# Fired from on_action 'on_yearly_pulse'
event = {
	id = crisis.7010
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_country = {
			has_ascension_perk = ap_cosmogenesis
			is_overlord = yes
			any_subject = {
				any_agreement = {
					has_active_specialization = specialist_scholarium
				}
			}
		}
	}

	immediate = {
		every_playable_country = {
			if = {
				limit = {
					has_ascension_perk = ap_cosmogenesis
					is_overlord = yes
				}
				every_subject = {
					limit = {
						any_agreement = {
							has_active_specialization = specialist_scholarium
						}
					}
					prev = {
						complete_crisis_objective = crisobj_have_scholarium_vassals
					}
				}
			}
		}
	}
}

# Menace Objective - Galcom Science Resolutions
# Fired from on_action 'on_yearly_pulse'
event = {
	id = crisis.7015
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_country = {
			has_ascension_perk = ap_cosmogenesis
		}
		OR = {
			is_active_resolution = resolution_galacticstudies_cooperative_research_channels
			is_active_resolution = resolution_galacticstudies_astral_studies_network
			is_active_resolution = resolution_galacticstudies_advanced_xenostudies
			is_active_resolution = resolution_galacticstudies_ethical_guideline_refactoring
			is_active_resolution = resolution_galacticstudies_extradimensional_experimentation
		}
	}

	immediate = {
		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_cooperative_research_channels
			}
			every_playable_country = {
				limit = {
					has_ascension_perk = ap_cosmogenesis
				}
				complete_crisis_objective = crisobj_galcom_science_resolution
			}
		}
		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_astral_studies_network
			}
			every_playable_country = {
				limit = {
					has_ascension_perk = ap_cosmogenesis
				}
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
			}
		}
		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_advanced_xenostudies
			}
			every_playable_country = {
				limit = {
					has_ascension_perk = ap_cosmogenesis
				}
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
			}
		}
		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_ethical_guideline_refactoring
			}
			every_playable_country = {
				limit = {
					has_ascension_perk = ap_cosmogenesis
				}
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
			}
		}
		if = {
			limit = {
				is_active_resolution = resolution_galacticstudies_extradimensional_experimentation
			}
			every_playable_country = {
				limit = {
					has_ascension_perk = ap_cosmogenesis
				}
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
				complete_crisis_objective = crisobj_galcom_science_resolution
			}
		}
	}
}

# Menace Objective - Neural Chips Production
# Fired from on_action 'on_monthly_pulse'
event = {
	id = crisis.7017
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_playable_country = {
			has_ascension_perk = ap_cosmogenesis
			has_country_flag = cosmogenesis_world_built
		}
	}

	immediate = {
		every_playable_country = {
			limit = {
				has_ascension_perk = ap_cosmogenesis
				has_country_flag = cosmogenesis_world_built
			}
			if = {
				limit = {
					NOT = { is_variable_set = cosmogenesis_world_advanced_logic_produced }

				}
				set_variable = {
					which = cosmogenesis_world_advanced_logic_produced
					value = 0
				}
			}
			export_resource_income_to_variable = {
				resource = advanced_logic
				variable = cosmogenesis_world_advanced_logic_produced
			}
			complete_crisis_objective = crisobj_neural_chips
		}
	}
}

# Menace Objective - Have Science Nexuses
# Fired from on_action 'on_yearly_pulse'
event = {
	id = crisis.7020
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		any_country = {
			has_ascension_perk = ap_cosmogenesis
			any_owned_megastructure = {
				OR = {
					is_megastructure_type = think_tank_3
					is_megastructure_type = think_tank_4
					is_megastructure_type = think_tank_restored
				}
			}
		}
	}

	immediate = {
		every_playable_country = {
			if = {
				limit = {
					has_ascension_perk = ap_cosmogenesis
				}
				every_owned_megastructure = {
					limit = {
						OR = {
							is_megastructure_type = think_tank_3
							is_megastructure_type = think_tank_4
							is_megastructure_type = think_tank_restored
						}
					}
					prev = {
						complete_crisis_objective = crisobj_have_science_nexuses
					}
				}
			}
		}
	}
}
