namespace = lazy_pla_spe_events

carrier_event = {
	id = lazy_pla_spe_events.1
	title = "lazy_pla_spe_events.1.name"
	desc = "lazy_pla_spe_events.1.desc"
	picture = GFX_evt_ai_planet
	show_sound = event_ai_started
	hide_window = no

	is_triggered_only = yes

	option = { 
		name = "lazy_pla_spe_events.1.a" #custom_tooltip = "_event.1.custom_tooltip.a"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = researcher_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = researcher_carrier_flag
			add_modifier = {
				modifier = building_notification_research
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.b" #custom_tooltip = "_event.2.custom_tooltip.b"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = metallurgist_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = metallurgist_carrier_flag
			add_modifier = {
				modifier = building_notification_alloy
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.c" #custom_tooltip = "_event.3.custom_tooltip.c"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = artisan_carrier_flag
				}
				owner = {
					OR = {
						has_civic = civic_machine_servitor
						NOR = {
							has_authority = auth_hive_mind
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = artisan_carrier_flag
			add_modifier = {
				modifier = building_notification_consumer_goods
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.d" #custom_tooltip = "_event.3.custom_tooltip.c"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = unification_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = unification_carrier_flag
			add_modifier = {
				modifier = building_notification_unity
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.e"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = trade_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = trade_carrier_flag
			add_modifier = {
				modifier = building_notification_trade
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	# option = { 
	# 	name = "lazy_pla_spe_events.1.e" #custom_tooltip = "_event.4.custom_tooltip.d"
	# 	allow = {
	# 		hidden_trigger = {
	# 			NOT = {
	# 				has_carrier_flag = bureaucrat_carrier_flag
	# 			}
	# 		}
	# 	}
	# 	hidden_effect = {
	# 		colony_building_specialisation_reset = yes

	# 		set_carrier_flag = bureaucrat_carrier_flag
	# 		add_modifier = {
	# 			modifier = building_notification_administrative_cap
	# 		}
	# 	}
	# }

	option = { 
		name = "lazy_pla_spe_events.1.f"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = eg_rc_vm_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = eg_rc_vm_carrier_flag
			set_carrier_flag = gas_refiner_carrier_flag
			set_carrier_flag = chemist_carrier_flag
			set_carrier_flag = translucer_carrier_flag
			add_modifier = {
				modifier = building_notification_eg_rc_vm
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.g"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = gas_refiner_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = gas_refiner_carrier_flag
			add_modifier = {
				modifier = building_notification_exotic_gases
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.h"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = chemist_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = chemist_carrier_flag
			add_modifier = {
				modifier = building_notification_volatile_motes
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.i"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = translucer_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_building_specialisation_reset = yes

			set_carrier_flag = translucer_carrier_flag
			add_modifier = {
				modifier = building_notification_rare_crystals
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.x"
		allow = {
			hidden_trigger = {
				always = no
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.j"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = auto_city_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_district_specialisation_reset = yes

			set_carrier_flag = auto_city_carrier_flag
			add_modifier = {
				modifier = building_notification_housing
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	# option = { 
	# 	name = "lazy_pla_spe_events.1.r"
	# 	allow = {
	# 		hidden_trigger = {
	# 			NOT = {
	# 				has_carrier_flag = auto_industrial_carrier_flag
	# 			}
	# 		}
	# 	}
	# 	hidden_effect = {
	# 		colony_district_specialisation_reset = yes

	# 		set_carrier_flag = auto_industrial_carrier_flag
	# 		add_modifier = {
	# 			modifier = building_notification_alloy
	# 		}
	# 	}
	# }

	option = { 
		name = "lazy_pla_spe_events.1.k"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = auto_mining_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_district_specialisation_reset = yes

			set_carrier_flag = auto_mining_carrier_flag
			add_modifier = {
				modifier = building_notification_minerals
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.l"
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = auto_generator_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_district_specialisation_reset = yes

			set_carrier_flag = auto_generator_carrier_flag
			add_modifier = {
				modifier = building_notification_energy
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.m"
		allow = {
			hidden_trigger = {
				NOR = {
					has_carrier_flag = auto_farming_carrier_flag
					is_planet_class = pc_habitat
				}
			}
		}
		hidden_effect = {
			colony_district_specialisation_reset = yes

			set_carrier_flag = auto_farming_carrier_flag
			add_modifier = {
				modifier = building_notification_food
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.n"
		trigger = {
			hidden_trigger = {
				is_planet_class = pc_habitat
			}
		}
		allow = {
			hidden_trigger = {
				NOT = {
					has_carrier_flag = auto_research_d_carrier_flag
				}
			}
		}
		hidden_effect = {
			colony_district_specialisation_reset = yes

			set_carrier_flag = auto_research_d_carrier_flag
			add_modifier = {
				modifier = building_notification_research_d
			}

			carrier_event = {
				id = lazy_pla_spe_events.1
			}
		}
	}

	# option = { 
	# 	name = "lazy_pla_spe_events.1.o"
	# 	trigger = {
	# 		hidden_trigger = {
	# 			is_planet_class = pc_habitat
	# 		}
	# 	}
	# 	allow = {
	# 		hidden_trigger = {
	# 			NOT = {
	# 				has_carrier_flag = auto_amenities_carrier_flag
	# 			}
	# 		}
	# 	}
	# 	hidden_effect = {
	# 		colony_district_specialisation_reset = yes

	# 		set_carrier_flag = auto_amenities_carrier_flag
	# 		add_modifier = {
	# 			modifier = building_notification_amenities
	# 		}
	# 	}
	# }

	option = { 
		name = "lazy_pla_spe_events.1.x"
		allow = {
			hidden_trigger = {
				always = no
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.o"
		hidden_effect = {
			if = {
				limit = {
					OR = {
						has_carrier_flag = translucer_carrier_flag
						has_carrier_flag = researcher_carrier_flag
						has_carrier_flag = metallurgist_carrier_flag
						has_carrier_flag = artisan_carrier_flag
						has_carrier_flag = gas_refiner_carrier_flag
						has_carrier_flag = chemist_carrier_flag
						has_carrier_flag = unification_carrier_flag
						has_carrier_flag = trade_carrier_flag
						has_carrier_flag = eg_rc_vm_carrier_flag
					}
				}
				while = {
					limit = {
						num_buildings = {
							type = any
							value > 1
						}
					}
					remove_random_building = yes
				}
				colony_auto_construct_reset = yes
				# remove_zone = {
				# 	district = district_city
				# 	all = yes
				# }
				# remove_zone = {
				# 	district = district_hive
				# 	all = yes
				# }
				# remove_zone = {
				# 	district = district_nexus
				# 	all = yes
				# }
				# remove_zone = {
				# 	district = district_rw_city
				# 	all = yes
				# }
				# remove_zone = {
				# 	district = district_craglands
				# 	all = yes
				# }
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.p"

		hidden_effect = {
			set_carrier_flag = auto_copy_automation_specialisation_flag

			owner = {
				every_owned_colony = {
					limit = {
						NOR = {
							has_carrier_flag = auto_colony_automation_exclusion_flag
							has_carrier_flag = auto_copy_automation_specialisation_flag
						}
					}
					colony_building_specialisation_reset = yes
					colony_district_specialisation_reset = yes
					if = {
						limit = {
							OR = {
								has_carrier_flag = translucer_carrier_flag
								has_carrier_flag = researcher_carrier_flag
								has_carrier_flag = metallurgist_carrier_flag
								has_carrier_flag = artisan_carrier_flag
								has_carrier_flag = gas_refiner_carrier_flag
								has_carrier_flag = chemist_carrier_flag
								has_carrier_flag = unification_carrier_flag
								has_carrier_flag = trade_carrier_flag
								has_carrier_flag = eg_rc_vm_carrier_flag
							}
						}
						while = {
							limit = {
								num_buildings = {
									type = any
									value > 1
								}
							}
							remove_random_building = yes
						}
						colony_auto_construct_reset = yes
					}
					root = {
						colony_copy_automation_specialisation = {
							TO_COLONY = prev
						}
					}
					set_carrier_flag = auto_buildings_carrier_flag
				}
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.q"

		hidden_effect = {
			owner = {
				every_owned_colony = {
					limit = {
						NOR = {
							has_carrier_flag = auto_colony_automation_exclusion_flag
							has_carrier_flag = auto_copy_automation_specialisation_flag
							has_carrier_flag = auto_buildings_carrier_flag
						}
					}
					if = {
						limit = {
							OR = {
								has_carrier_flag = translucer_carrier_flag
								has_carrier_flag = researcher_carrier_flag
								has_carrier_flag = metallurgist_carrier_flag
								has_carrier_flag = artisan_carrier_flag
								has_carrier_flag = gas_refiner_carrier_flag
								has_carrier_flag = chemist_carrier_flag
								has_carrier_flag = unification_carrier_flag
								has_carrier_flag = trade_carrier_flag
								has_carrier_flag = eg_rc_vm_carrier_flag
							}
						}
						while = {
							limit = {
								num_buildings = {
									type = any
									value > 1
								}
							}
							remove_random_building = yes
						}
						colony_auto_construct_reset = yes
					}
					root = {
						colony_copy_automation_specialisation = {
							TO_COLONY = prev
						}
					}
					set_carrier_flag = auto_buildings_carrier_flag
				}
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.r"
	}

	option = { 
		name = "lazy_pla_spe_events.1.s"

		hidden_effect = {
			owner = {
				every_owned_colony = {
					limit = {
						NOT = {
							has_carrier_flag = auto_copy_automation_specialisation_flag
						}
						has_carrier_flag = auto_buildings_carrier_flag
					}
					colony_building_specialisation_reset = yes
					colony_district_specialisation_reset = yes
					root = {
						colony_copy_automation_specialisation = {
							TO_COLONY = prev
						}
					}
					set_carrier_flag = auto_buildings_carrier_flag
				}
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.t"

		hidden_effect = {
			colony_building_specialisation_reset = yes
			colony_district_specialisation_reset = yes
			remove_modifier = building_notification
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.u"

		hidden_effect = {
			owner = {
				every_owned_colony = {
					colony_building_specialisation_reset = yes
					colony_district_specialisation_reset = yes
					remove_modifier = building_notification
				}
			}
		}
	}

	option = { 
		name = "lazy_pla_spe_events.1.w"
	}

	after = {
		remove_carrier_flag = auto_copy_automation_specialisation_flag
		if = {
			limit = {
				OR = {
					has_carrier_flag = translucer_carrier_flag
					has_carrier_flag = researcher_carrier_flag
					has_carrier_flag = metallurgist_carrier_flag
					has_carrier_flag = artisan_carrier_flag
					# has_carrier_flag = bureaucrat_carrier_flag
					has_carrier_flag = eg_rc_vm_carrier_flag
					has_carrier_flag = gas_refiner_carrier_flag
					has_carrier_flag = chemist_carrier_flag
					has_carrier_flag = unification_carrier_flag
					has_carrier_flag = auto_farming_carrier_flag
					has_carrier_flag = auto_city_carrier_flag
					# has_carrier_flag = auto_industrial_carrier_flag
					has_carrier_flag = auto_mining_carrier_flag
					has_carrier_flag = auto_generator_carrier_flag
					has_carrier_flag = trade_carrier_flag
					has_carrier_flag = auto_research_d_carrier_flag
					# has_carrier_flag = auto_amenities_carrier_flag
				}
			}
			set_carrier_flag = auto_buildings_carrier_flag
		}
		else = {
			remove_carrier_flag = auto_buildings_carrier_flag
		}
	}
}

country_event = {
	id = lazy_pla_spe_events.2
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_country_flag = auto_colony_manager_flag
	}

	immediate = {
		every_owned_colony = {
			limit = {
				has_carrier_flag = auto_buildings_carrier_flag
				NOT = {
					has_modifier = building_notification
				}
			}
			colony_auto_spec_buildings_check = yes
			colony_auto_spec_districts_check = yes
		}
	}
}

# country_event = {
# 	id = lazy_pla_spe_events.3
# 	hide_window = yes
# 	is_triggered_only = yes

# 	trigger = {
# 		has_country_flag = auto_colony_support_flag
# 	}

# 	immediate = {
# 		every_owned_colony = {
# 			limit = {
# 				NOT = {
# 					has_modifier = building_notification
# 				}
# 				free_building_slots >= 1
# 				NOR = {
# 					has_building = building_clinic
# 					has_building = building_hospital
# 					has_building = building_spawning_pool
# 					has_building = building_machine_assembly_plant
# 					has_building = building_machine_assembly_complex
# 				}
# 				prev = {
# 					resource_stockpile_compare = {
# 						resource = minerals
# 						value >= 400
# 						mult = value:positive_modifier_mult|MODIFIER|planet_buildings_cost_mult|
# 					}
# 					if = {
# 						limit = {
# 							NOR = {
# 								has_authority = auth_machine_intelligence
# 								has_authority = auth_hive_mind
# 							}
# 						}
# 						has_technology = tech_frontier_health
# 					}
# 				}
# 			}
# 			if = {
# 				limit = {
# 					prev = {
# 						has_authority = auth_hive_mind
# 					}
# 				}
# 				add_building = building_spawning_pool
# 			}
# 			else_if = {
# 				limit = {
# 					prev = {
# 						has_authority = auth_machine_intelligence
# 					}
# 				}
# 				add_building = building_machine_assembly_plant
# 			}
# 			else = {
# 				add_building = building_clinic
# 			}
# 			add_modifier = {
# 				modifier = building_notification days = 360
# 			}
# 			prev = {
# 				add_resource = {
# 					minerals = 400
# 					mult = value:negative_modifier_mult|MODIFIER|planet_buildings_cost_mult|
# 				}
# 			}
# 		}
# 		every_owned_colony = {
# 			limit = {
# 				NOR = {
# 					has_modifier = building_notification
# 					has_modifier = resort_colony
# 				}
# 				if = {
# 					limit = {
# 						prev = {
# 							has_country_flag = auto_colony_support_free_housing_flag
# 						}
# 					}
# 					free_housing < 10
# 				}
# 				OR = {
# 					num_free_districts = {
# 						type = district_city
# 						value >= 1
# 					}
# 					num_free_districts = {
# 						type = district_nexus
# 						value >= 1
# 					}
# 					num_free_districts = {
# 						type = district_hive
# 						value >= 1
# 					}
# 					num_free_districts = {
# 						type = district_hab_housing
# 						value >= 1
# 					}
# 				}
# 			}
# 			if = {
# 				limit = {
# 					prev = {
# 						resource_stockpile_compare = {
# 							resource = minerals
# 							value >= 500
# 							mult = value:positive_modifier_mult|MODIFIER|planet_districts_cost_mult|
# 						}
# 					}
# 				}
# 				if = {
# 					limit = {
# 						prev = {
# 							has_authority = auth_hive_mind
# 						}
# 					}
# 					add_district = district_hive
# 				}
# 				else_if = {
# 					limit = {
# 						prev = {
# 							has_authority = auth_machine_intelligence
# 						}
# 					}
# 					add_district = district_nexus
# 				}
# 				else_if = {
# 					limit = {
# 						is_planet_class = pc_habitat
# 						num_free_districts = {
# 							type = district_hab_housing
# 							value >= 1
# 						}
# 					}
# 					add_district = district_hab_housing
# 					prev = {
# 						add_resource = {
# 							minerals = 100
# 							mult = value:positive_modifier_mult|MODIFIER|planet_districts_cost_mult|
# 						}
# 					}
# 				}
# 				else = {
# 					add_district = district_city
# 				}
# 				add_modifier = {
# 					modifier = building_notification days = 480
# 				}
# 				prev = {
# 					add_resource = {
# 						minerals = 500
# 						mult = value:negative_modifier_mult|MODIFIER|planet_districts_cost_mult|
# 					}
# 				}
# 			}
# 		}
# 	}
# }