namespace = utopia

# Instrument - Pop Upkeep
country_event = {
	id = utopia.3340
	title = "utopia.3340.name"
	desc = "utopia.3340.desc"
	picture = GFX_evt_unspeakable_horror
	show_sound = event_mystic_reveal
	location = root

	is_triggered_only = yes

	immediate = {
		random_list = {
			20 = {
				set_country_flag = instrument_craving_consumer_goods
			}
			20 = {
				set_country_flag = instrument_craving_alloys
			}
			10 = {
				set_country_flag = instrument_craving_unity
			}
			10 = {
				modifier = {
					factor = 0
					has_monthly_income = { 
						resource = exotic_gases
						value < 5
					}
				}
				set_country_flag = instrument_craving_gas
			}
			10 = {
				modifier = {
					factor = 0
					has_monthly_income = { 
						resource = rare_crystals
						value < 5
					}
				}
				set_country_flag = instrument_craving_crystal
			}
			10 = {
				modifier = {
					factor = 0
					has_monthly_income = { 
						resource = volatile_motes
						value < 5
					}
				}
				set_country_flag = instrument_craving_motes
			}
			10 = {
				modifier = {
					factor = 0
					has_monthly_income = { 
						resource = sr_zro
						value < 1
					}
				}
				set_country_flag = instrument_craving_zro
			}
			10 = {
				modifier = {
					factor = 0
					has_monthly_income = { 
						resource = sr_dark_matter
						value < 1
					}
				}
				set_country_flag = instrument_craving_dark_matter
			}
			10 = {
				modifier = {
					factor = 0
					has_monthly_income = { 
						resource = sr_living_metal
						value < 1
					}
				}
				set_country_flag = instrument_craving_living_metal
			}
			10 = {
				modifier = {
					factor = 0
					has_monthly_income = { 
						resource = nanites
						value < 1
					}
				}
				set_country_flag = instrument_craving_nanites
			}
			5 = {
				modifier = {
					factor = 0
					acot_should_not_crave_dark_energy = yes
				}
				set_country_flag = instrument_craving_dark_energy
			}
			5 = {
				modifier = {
					factor = 0
					acot_should_not_crave_stellarite = yes
				}
				set_country_flag = instrument_craving_stellarite
			}
			# AOT
			5 = {
				modifier = {
					factor = 0
					aot_should_not_crave_runic_power = yes
				}
				set_country_flag = instrument_craving_runic_power
			}
			# Gigastructural Engineering & More
			5 = {
				modifier = {
					factor = 0
					giga_should_not_crave_iodizium = yes
				}
				set_country_flag = instrument_craving_iodizium
			}
			5 = {
				modifier = {
					factor = 0
					giga_should_not_crave_supertensiles = yes
				}
				set_country_flag = instrument_craving_amb_megaconstruction
			}
			5 = {
				modifier = {
					factor = 0
					giga_should_not_crave_sublimate = yes
				}
				set_country_flag = instrument_craving_psionic_sublimate
			}
			10 = {
				modifier = {
					factor = 0
					giga_should_not_crave_negative_mass = yes
				}
				set_country_flag = instrument_craving_negative_mass
			}
			10 = {
				modifier = {
					factor = 0
					giga_should_not_crave_sentient_metal = yes
				}
				set_country_flag = instrument_craving_sentient_metal
			}
			# Planetary Diversity
			5 = {
				modifier = {
					factor = 0
					pd_should_not_crave_acean = yes
				}
				set_country_flag = instrument_craving_acean
			}
			5 = {
				modifier = {
					factor = 0
					pd_should_not_crave_eludium = yes

				}
				set_country_flag = instrument_craving_eludium
			}
			5 = {
				modifier = {
					factor = 0
					pd_should_not_crave_rad_bloom = yes
				}
				set_country_flag = instrument_craving_rad_bloom
			}
			5 = {
				modifier = {
					factor = 0
					pd_should_not_crave_tiyanki_parts = yes
				}
				set_country_flag = instrument_craving_tiyanki_parts
			}
		}
		country_event = { id = utopia.3344 days = 720 }
	}

	option = {
		name = "utopia.3338.opt.a"
		add_modifier = {
			modifier = instrument_cravings
			days = 720
		}
	}
}

#Instrument - flag cleanup event
country_event = { 
	id = utopia.3344
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		remove_country_flag = instrument_craving_consumer_goods
		remove_country_flag = instrument_craving_alloys
		remove_country_flag = instrument_craving_unity
		remove_country_flag = instrument_craving_gas
		remove_country_flag = instrument_craving_crystal
		remove_country_flag = instrument_craving_motes
		remove_country_flag = instrument_craving_zro
		remove_country_flag = instrument_craving_dark_matter
		remove_country_flag = instrument_craving_living_metal
		remove_country_flag = instrument_craving_nanites
		# ACOT
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				remove_country_flag = instrument_craving_dark_energy
				remove_country_flag = instrument_craving_stellarite
			"
			toggle = @has_ancient_caches
		}
		# AOT
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				remove_country_flag = instrument_craving_runic_power
			"
			toggle = @has_acquisition_of_tech
		}
		# Gigastructural Engineering & More
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				remove_country_flag = instrument_craving_iodizium
				remove_country_flag = instrument_craving_amb_megaconstruction
				remove_country_flag = instrument_craving_psionic_sublimate
				remove_country_flag = instrument_craving_negative_mass
				remove_country_flag = instrument_craving_sentient_metal
			"
			toggle = @has_gigastructures
		}
		# Planetary Diversity
		inline_script = {
			script = merger_of_rules/toggled_code
			code = "
				remove_country_flag = instrument_craving_eludium
				remove_country_flag = instrument_craving_acean
				# remove_country_flag = instrument_craving_rad_bloom
				# remove_country_flag = instrument_craving_tiyanki_parts
			"
			toggle = @has_planetary_diversity_unique_worlds
		}
	}
}
