namespace = extsynths

# This flag facilitates automatic compatching for other mods.
# Anytime the code needs to check whether this mod is active, the event can just check for the flag.
# If the flag is not set, that means the player is not using this mod, and therefore the connected effect is not triggered.
# If the flag is set, that means the player is using this mod, and therefore the connected effect is triggered.
# This way, any other mod can be written with the code containing IF alternative effects for players both with and 
# without this mod, sparing the author from the need to create separate versions of the same mod.

country_event = {
	id = extsynths.4000
	title = "utopia.2551.name"
	desc = "extsynths.2001.desc"
	picture = GFX_evt_robot_assembly_plant
#	show_sound = event_synthetic_evolution
	is_triggered_only = yes

	trigger = {
		has_tradition = tr_synthetics_adopt
		NOT = {
			has_country_flag = extsynths_4000_fired
		}
	}

	immediate = {
		set_country_flag = extsynths_4000_fired
	}

	option = {
		name = "extsynths.2.r"		#No change - maintain portrait
		set_country_flag = extsynths_option_16
	}
	option = {
		name = "extsynths.2.no"
	}
}

###
country_event = {
	id = extsynths.4001
	title = "utopia.2551.name"
	desc = "extsynths.2001.desc"
	picture = GFX_evt_robot_assembly_plant
	is_triggered_only = yes

	trigger = {
		has_origin = origin_synthetic_fertility
		has_technology = tech_synthetic_workers
		NOT = {
			has_country_flag = extsynths_4000_fired
		}
	}

	immediate = {
		set_country_flag = extsynths_4000_fired
	}

	option = {
		name = "extsynths.2.r"		#No change - maintain portrait
		set_country_flag = extsynths_option_16
	}
	option = {
		name = "extsynths.2.no"
	}

}

event = {
	id = extsynths.1
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		set_global_flag = extended_synths_on
	}
}


# The Synthetic Age - Gateway

country_event = {
	id = extsynths.2
	hide_window = yes
	is_triggered_only = yes
	immediate = {
		if = { 
			limit = { 
				is_ai = yes
			} 
			country_event = { id = utopia.2551 }		 #AI doesn't choose
			break = yes
		}
		if = { limit = { is_ai = no } 
			country_event = { id = extsynths.2001 }
		}
	}
}

country_event = {
	id = extsynths.10
	title = "extsynths.10.name"
	desc = "extsynths.10.desc"
	picture = GFX_evt_robot_assembly_plant
	show_sound = event_default
	is_triggered_only = yes
	
	trigger = {
		last_increased_tech = "tech_robomodding"
		NOT = {
			has_country_flag = extsynths_event_10
		}
	}

	immediate = {
		set_country_flag = extsynths_event_10
	}
	
	
	option = {
		name = "EXCELLENT"
	}
}

country_event = {
	id = extsynths.11
	title = "extsynths.11.name"
	desc = "extsynths.11.desc"
	picture = GFX_evt_robot_assembly_plant
	show_sound = event_default
	is_triggered_only = yes
	
	trigger = {
		always = no
		last_increased_tech = "tech_droid_workers"
		NOT = {		
			has_country_flag = extsynths_event_11
			is_species_class = EXTSYNTH_BIO
		}
	}
	immediate = {
		set_country_flag = extsynths_event_11
	}	
	option = {
		name = "EXCELLENT"
		custom_tooltip = extsynths.newoutfit.tooltip
	}
}

country_event = {
	id = extsynths.12
	title = "extsynths.11.name"
	desc = "extsynths.12.desc"
	picture = GFX_evt_robot_assembly_plant
	show_sound = event_default
	is_triggered_only = yes

	trigger = {
		always = no
		last_increased_tech = "tech_synthetic_workers"
		NOT = {
			has_country_flag = extsynths_event_12
			is_species_class = EXTSYNTH_BIO
		}
	}
	immediate = {
		set_country_flag = extsynths_event_12
	}	
	option = {
		name = "EXCELLENT"
		custom_tooltip = extsynths.newoutfit.tooltip
	}
}

event = {
	id = extsynths.13
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		always = no
		any_country = {
			NOT = {
				has_country_flag = extsynths_event_13
				has_country_flag = limbo_country
			}
			has_technology = tech_robomodding
			has_technology = tech_synthetic_workers
			has_country_flag = synthetic_age
			any_owned_pop = {
				is_being_purged = no
			}
		}
	}
	
	immediate = {
		every_country = {
			limit = {
				NOR = {
					has_country_flag = extsynths_event_13
					has_country_flag = limbo_country
				}
				has_technology = tech_robomodding
				has_technology = tech_synthetic_workers
				has_country_flag = synthetic_age
				any_owned_pop = {
					is_being_purged = no
				}			
			}
			country_event = { id = extsynths.14 }
		}
	}	
}

country_event = {
	id = extsynths.14
	title = "extsynths.13.name"
	desc = "extsynths.13.desc"
	picture = GFX_evt_robot_assembly_plant
	show_sound = event_default
	is_triggered_only = yes
	trigger = {
		always = no
		NOT = {
			has_country_flag = extsynths_event_13
		}
	}
	
	immediate = {
		set_country_flag = extsynths_event_13
	}	
	option = {
		name = "GOOD"
		custom_tooltip = extsynths.limbo.tooltip
	}
}
###ONE-TIME MODIFICATION COST DISCOUNT USED###
country_event = {
	id = extsynths.15
	title = "extsynths.15.name"
	desc = "extsynths.15.desc"
	picture = GFX_evt_circuitry_modification
	show_sound = event_default
	is_triggered_only = yes
	trigger = {
		NOT = {
			has_country_flag = extsynths_event_15
		}
		has_modifier = extsynths_modding_modifier
		from = {
			OR = {
				is_species_class = EXTSYNTH
				is_species_class = MACHINE
			}
		}
	}
	
	immediate = {
		set_country_flag = extsynths_event_15
		remove_modifier = extsynths_modding_modifier
	}	
	option = {
		name = GOOD
		custom_tooltip = extsynths.15.tooltip
	}
}

###ONE-TIME MODIFICATION COST USED ON OTHER SPECIES###
country_event = {
	id = extsynths.16
	title = "extsynths.16.name"
	desc = "extsynths.16.desc"
	picture = GFX_evt_genetic_modification
	show_sound = event_default
	is_triggered_only = yes
	trigger = {
		NOT = {
			has_country_flag = extsynths_event_15
		}
		has_modifier = extsynths_modding_modifier
		from = {
			NOR = {
				is_species_class = EXTSYNTH
				is_species_class = MACHINE
			}
		}
	}
	
	immediate = {
		set_country_flag = extsynths_event_15
		remove_modifier = extsynths_modding_modifier
	}	
	option = {
		name = OK
		custom_tooltip = extsynths.15.tooltip
	}
}

# The Synthetic Age - Decide which form for new species

country_event = {
	id = extsynths.2001
	title = "utopia.2551.name"
	desc = "extsynths.2001.desc"	
	picture = GFX_evt_robot_assembly_plant
#	show_sound = event_synthetic_evolution
	is_triggered_only = yes

	after = {
		if = {
			limit = {
				OR = {
					has_country_flag = extsynths_option_1
					has_country_flag = extsynths_option_2
					has_country_flag = extsynths_option_3
					has_country_flag = extsynths_option_4
					has_country_flag = extsynths_option_5
					has_country_flag = extsynths_option_6
					has_country_flag = extsynths_option_7
					has_country_flag = extsynths_option_8
					has_country_flag = extsynths_option_9
					has_country_flag = extsynths_option_10
					has_country_flag = extsynths_option_11
					has_country_flag = extsynths_option_12
					has_country_flag = extsynths_option_13
					has_country_flag = extsynths_option_14
					has_country_flag = extsynths_option_15
					has_country_flag = extsynths_option_16
					has_country_flag = extsynths_option_17
					has_country_flag = extsynths_option_18
					has_country_flag = extsynths_option_19
					has_country_flag = extsynths_option_20
					has_country_flag = extsynths_option_21
					has_country_flag = extsynths_option_22
					has_country_flag = extsynths_option_23
					has_country_flag = extsynths_option_24
					has_country_flag = extsynths_option_25
					has_country_flag = extsynths_option_26
					has_country_flag = extsynths_option_27
					has_country_flag = extsynths_option_28
					has_country_flag = extsynths_option_29
					has_country_flag = extsynths_option_30
				}
			}
			country_event = { id = extsynths.30001 } 
		}
	}
	option = {
		name = "extsynths.2.r"		#No change - maintain portrait
		set_country_flag = extsynths_option_16
	}
	option = {
		name = "extsynths.2.a"
		custom_tooltip = extsynths.2.a.tooltip
		set_country_flag = extsynths_option_1
	}
	option = {
		name = "extsynths.2.b"
		custom_tooltip = extsynths.2.b.tooltip
		set_country_flag = extsynths_option_2
	}
	option = {
		name = "extsynths.2.c"
		custom_tooltip = extsynths.2.c.tooltip
		set_country_flag = extsynths_option_3
	}
	option = {
		name = "extsynths.2.d"
		custom_tooltip = extsynths.2.d.tooltip
		set_country_flag = extsynths_option_4
	}
	option = {
		name = "extsynths.2.e"
		custom_tooltip = extsynths.2.e.tooltip
		set_country_flag = extsynths_option_5
	}
	option = {
		name = "extsynths.2.f"
		custom_tooltip = extsynths.2.f.tooltip
		set_country_flag = extsynths_option_6
	}
	option = {
		name = "extsynths.2.g"
		custom_tooltip = extsynths.2.g.tooltip
		set_country_flag = extsynths_option_7
	}
	option = {
		name = "extsynths.2.h"
		custom_tooltip = extsynths.2.h.tooltip
		set_country_flag = extsynths_option_8
	}
	option = {
		name = "extsynths.2.cube"
		trigger = {
			has_rick_the_cube_dlc = yes
		}
		set_country_flag = extsynths_option_30
	}
	option = {
		name = "extsynths.2.s"		#More choices
		country_event = { id = extsynths.2002 } 
	}
	option = {
		name = "extsynths.2.t"		#Synthetic Dawn options
		trigger = { is_ai = no
		host_has_dlc = "Synthetic Dawn Story Pack" } 
		country_event = { id = extsynths.2003 } 
	}
}


country_event = {
	id = extsynths.2002
	title = "utopia.2551.name"
	desc = "extsynths.2001.desc"	
	picture = GFX_evt_robot_assembly_plant

	is_triggered_only = yes

	after = {
		if = {
			limit = {
				OR = {
					has_country_flag = extsynths_option_1
					has_country_flag = extsynths_option_2
					has_country_flag = extsynths_option_3
					has_country_flag = extsynths_option_4
					has_country_flag = extsynths_option_5
					has_country_flag = extsynths_option_6
					has_country_flag = extsynths_option_7
					has_country_flag = extsynths_option_8
					has_country_flag = extsynths_option_9
					has_country_flag = extsynths_option_10
					has_country_flag = extsynths_option_11
					has_country_flag = extsynths_option_12
					has_country_flag = extsynths_option_13
					has_country_flag = extsynths_option_14
					has_country_flag = extsynths_option_15
					has_country_flag = extsynths_option_16
					has_country_flag = extsynths_option_17
					has_country_flag = extsynths_option_18
					has_country_flag = extsynths_option_19
					has_country_flag = extsynths_option_20
					has_country_flag = extsynths_option_21
					has_country_flag = extsynths_option_22
					has_country_flag = extsynths_option_23
					has_country_flag = extsynths_option_24
					has_country_flag = extsynths_option_25
					has_country_flag = extsynths_option_26
					has_country_flag = extsynths_option_27
					has_country_flag = extsynths_option_28
					has_country_flag = extsynths_option_29
					has_country_flag = extsynths_option_30
				}
			}
			country_event = { id = extsynths.30001 } 
		}
	}


			### 	ADDITIONAL CHOICES - If player wants to use robot/droid bodies  	### 
	option = {
		name = "extsynths.2.i"
		custom_tooltip = extsynths.2.i.tooltip
		set_country_flag = extsynths_option_9
	}
	option = {
		name = "extsynths.2.l"
		custom_tooltip = extsynths.2.l.tooltip
		set_country_flag = extsynths_option_10
	}
	option = {
		name = "extsynths.2.m"		#Robot Humanoid
		custom_tooltip = extsynths.2.m.tooltip
		set_country_flag = extsynths_option_11
	}
	option = {
		name = "extsynths.2.n" 		#Android Humanoid
		custom_tooltip = extsynths.2.n.tooltip
		set_country_flag = extsynths_option_12
	}
	option = {
		name = "extsynths.2.o"		#Robot Arthropoid
		custom_tooltip = extsynths.2.o.tooltip
		set_country_flag = extsynths_option_13
	}
	option = {
		name = "extsynths.2.p"		#Android Arthropoid
		custom_tooltip = extsynths.2.p.tooltip
		set_country_flag = extsynths_option_14
	}
	option = {
		name = "extsynths.2.q"		#Ai Consciousness
		custom_tooltip = extsynths.2.q.tooltip
		set_country_flag = extsynths_option_15
	}
	option = {
		name = "extsynths.2.xxz"		#Terminator
		custom_tooltip = extsynths.2.xxz.tooltip
		set_country_flag = extsynths_option_25
	}
	option = {
		name = "extsynths.2.s"		#Backtrack
		country_event = { id = extsynths.2001 } 
	}
	option = {
		name = "extsynths.2.t"		#Synthetic Dawn options
		trigger = { is_ai = no
		host_has_dlc = "Synthetic Dawn Story Pack" } 
		country_event = { id = extsynths.2003 } 
	}
}

country_event = {
	id = extsynths.2003
	title = "utopia.2551.name"
	desc = "extsynths.2001.desc"	
	picture = GFX_evt_robot_assembly_plant
#	show_sound = event_synthetic_evolution
	is_triggered_only = yes

	after = {
		if = {
			limit = {
				OR = {
					has_country_flag = extsynths_option_1
					has_country_flag = extsynths_option_2
					has_country_flag = extsynths_option_3
					has_country_flag = extsynths_option_4
					has_country_flag = extsynths_option_5
					has_country_flag = extsynths_option_6
					has_country_flag = extsynths_option_7
					has_country_flag = extsynths_option_8
					has_country_flag = extsynths_option_9
					has_country_flag = extsynths_option_10
					has_country_flag = extsynths_option_11
					has_country_flag = extsynths_option_12
					has_country_flag = extsynths_option_13
					has_country_flag = extsynths_option_14
					has_country_flag = extsynths_option_15
					has_country_flag = extsynths_option_16
					has_country_flag = extsynths_option_17
					has_country_flag = extsynths_option_18
					has_country_flag = extsynths_option_19
					has_country_flag = extsynths_option_20
					has_country_flag = extsynths_option_21
					has_country_flag = extsynths_option_22
					has_country_flag = extsynths_option_23
					has_country_flag = extsynths_option_24
					has_country_flag = extsynths_option_25
					has_country_flag = extsynths_option_26
					has_country_flag = extsynths_option_27
					has_country_flag = extsynths_option_28
					has_country_flag = extsynths_option_29
					has_country_flag = extsynths_option_30
				}
			}
			country_event = { id = extsynths.30001 } 
		}
	}


			### 	ADDITIONAL CHOICES - Synthetic Dawn Portraits 	### 
	option = {
		name = "extsynths.2.u" 		#Humanoid
		custom_tooltip = extsynths.2.u.tooltip
		set_country_flag = extsynths_option_17
	}
	option = {
		name = "extsynths.2.v"		#Mammal
		custom_tooltip = extsynths.2.v.tooltip
		set_country_flag = extsynths_option_18
	}
	option = {
		name = "extsynths.2.w"		#Reptilian
		custom_tooltip = extsynths.2.w.tooltip
		set_country_flag = extsynths_option_19
	}
	option = {
		name = "extsynths.2.x" 		#Avian
		custom_tooltip = extsynths.2.x.tooltip
		set_country_flag = extsynths_option_20
	}
	option = {
		name = "extsynths.2.y"		#Arthropoid
		custom_tooltip = extsynths.2.y.tooltip
		set_country_flag = extsynths_option_21
	}
	option = {
		name = "extsynths.2.z"		#Molluscoid
		custom_tooltip = extsynths.2.z.tooltip
		set_country_flag = extsynths_option_22
	}
	option = {
		name = "extsynths.2.yz"		#Fungoid
		custom_tooltip = extsynths.2.yz.tooltip
		set_country_flag = extsynths_option_23
	}
	option = {
		name = "extsynths.2.xz"		#Plantoid
		custom_tooltip = extsynths.2.xz.tooltip
		set_country_flag = extsynths_option_24
	}
	option = {
		name = "extsynths.2.lit"		#lithoid
			trigger = { 
				is_ai = no
				has_lithoids = yes
			} 
			custom_tooltip = extsynths.2.lit.tooltip
			set_country_flag = extsynths_option_26
	}
	option = {
		name = "extsynths.2.nec"		#necroids
			trigger = { 
				is_ai = no
				has_necroids = yes
			} 
			custom_tooltip = extsynths.2.nec.tooltip
			set_country_flag = extsynths_option_27
	}
	option = {
		name = "extsynths.2.aqu"		#aquatoid
			trigger = { 
				is_ai = no
				has_aquatics = yes
			} 
			custom_tooltip = extsynths.2.aqu.tooltip
			set_country_flag = extsynths_option_28
	}
	
	option = {
		name = "extsynths.2.tox"		#toxoid
			trigger = { 
				is_ai = no
				has_toxoids = yes
			} 
			custom_tooltip = extsynths.2.tox.tooltip
			set_country_flag = extsynths_option_29
	}
	
	option = {
		name = "extsynths.2.s"		#Backtrack
		country_event = { id = extsynths.2001 } 
	}
}

# The Synthetic Age
country_event = {
	id = extsynths.30001 
	title = "utopia.2551.name"
	desc = {
		text = "utopia.2551.desc"
		trigger = {
			NOT = {
				species = {
					has_trait = trait_psionic
				}
			}
			is_spiritualist = no
		}
	}
	desc = {
		text = "extsynths.2.desc"
		trigger = {
			species = {
				has_trait = trait_psionic
			}
			is_spiritualist = yes
		}
	}
	is_triggered_only = yes
	picture = GFX_evt_robot_assembly_plant
	show_sound = event_synthetic_evolution
	immediate = {
		if = {
			limit = {
				has_country_flag = extsynths_option_16
			}
			random_owned_leader = {
				limit = {
					is_ruler = yes
				}
				save_event_target_as = ruler_target
			}
		}
		set_country_flag = synthetic_empire
		if = {
			limit = {
				OR = {
					has_origin = origin_legendary_leader_dictatorial
					AND = {
						has_country_flag = paragon_origin_reformists_gone
						has_origin = origin_legendary_leader_imperial
					}
				}
				NOT = { has_country_flag = luminary_ascension_path }
				exists = ruler
				ruler = { has_leader_flag = paragon_origin_legendary_leader }
			}
			country_event = {
				id = paragon.5201 days = 3600 random = 7200
			}
		}
		if = {
			limit = {
				has_policy_flag = robots_outlawed
			}
			set_policy = {
				policy = robot_pop_policy
				option = robot_pops_allowed
				cooldown = yes
			}
		}
		if = {
			limit = {
				OR = {
					has_policy_flag = ai_servitude
					has_policy_flag = ai_outlawed
				}
			}
			set_policy = {
				policy = artificial_intelligence_policy
				option = ai_full_rights
				cooldown = yes
			}
		}
		if = {
			limit = {
				OR = {
					is_active_resolution = "resolution_divinity_silence_the_soulless"
					is_active_resolution = "resolution_divinity_a_defined_purpose"
				}
			}
			owner = {
				set_timed_country_flag = { flag = resolution_breached_synthetic_evolution days = 3600 }
			}
		}
		give_technology = { tech = tech_bio_reactor message = no }
		add_modifier = {
			modifier = extsynths_modding_modifier
			days = -1
		}
		random_owned_planet = {
			limit = {
				is_homeworld = yes
			}
			save_event_target_as = new_species_homeworld
		}
		#create species
		create_extsynth_robots = yes
        
		
		if = {
			limit = {
				has_country_flag = extsynths_option_16
			}
			leader = {
				change_leader_portrait = event_target:ruler_target
			}
		}

		every_owned_pop_group = {
			limit = {
				is_being_purged = no
				species = {
					is_robotic = no
					is_livestock = no
				}
			}
			change_species = event_target:synthspecies@root.owner
		}

		every_controlled_ship = {
			limit = {
				is_ship_class = shipclass_colonizer
				species = {
					is_robotic = no
					is_livestock = no
				}
			}
			change_species = event_target:synthspecies@root.owner
		}

		every_owned_army = {
			limit = {
				exists = species
				#exists = planet
				species = {
					is_robotic = no
					is_livestock = no
				}
				army_type = assault_army
			}
			modify_army = {
				name = random
				type = "robotic_army"
				species = event_target:synthspecies@root.owner
			}
		}

		every_owned_army = {
			limit = {
				exists = species
				exists = planet
				species = {
					is_robotic = no
					is_livestock = no
				}
				army_type = defense_army
			}
			modify_army = {
				name = random
				type = "robotic_defense_army"
				species = event_target:synthspecies@root.owner
			}
		}

		every_owned_leader = {
			limit = {
				OR = {
					species = {
						is_robotic = no
						is_livestock = no
					}
					has_trait = leader_trait_synthetic
				}
				NOR = {
					has_leader_flag = renowned_leader
					has_leader_flag = legendary_leader
				}
			}
			change_species = event_target:synthspecies@root.owner
			change_leader_portrait = species
		}
		every_pool_leader = {
			limit = {
				OR = {
					species = {
						is_robotic = no
						is_livestock = no
					}
					has_trait = leader_trait_synthetic
				}
			}
			change_species = event_target:synthspecies@root.owner
			change_leader_portrait = species
		}
		change_dominant_species = { species = event_target:synthspecies@root.owner }

		every_owned_leader = {
			limit = {
				species = { has_trait = trait_mechanical }
				NOR = {
					has_trait = leader_trait_synthetic
					has_leader_flag = renowned_leader
					has_leader_flag = legendary_leader
				}
			}
			add_trait = {
				trait = leader_trait_synthetic
				show_message = no
			}
			remove_trait = leader_trait_cyborg
		}

		create_message = {
			type = MESSAGE_ALL_GAINED_TRAIT
			localization = MESSAGE_ALL_GAINED_TRAIT_DESC
			days = @toast_message_days
			variable = {
				type = key
				value = leader_trait_synthetic
				localization = TRAIT
			}
			variable = {
				key = TRAIT_KEY
				value = leader_trait_synthetic
			}
			variable = {
				key = "border"
				value = "GFX_invisible"
			}
		}

		every_envoy = {
			limit = {
				species = {
					is_robotic = no
					is_livestock = no
				}
			}
			change_species = event_target:synthspecies@root.owner
			change_leader_portrait = species
		}
		every_pool_leader = {
			limit = {
				species = { has_trait = trait_mechanical }
				NOT = { has_trait = leader_trait_synthetic }
			}
			add_trait = {
				trait = leader_trait_synthetic
				show_message = no
			}
			remove_trait = leader_trait_cyborg
		}

		observer_event = { id = observer.4 }
		every_country = {
			limit = {
				is_ai = no
				NOT = { is_same_value = root }
				has_communications = root
			}
			country_event = { id = utopia.2555 days = 5 }
			country_event = { id = utopia.2556 days = 10 }
		}
		if = {
			limit = {
				any_country = {
					OR = {
						is_country_type = fallen_empire
						is_country_type = awakened_fallen_empire
					}
					has_ethic = ethic_fanatic_spiritualist
					has_communications = root
					NOT = { is_same_value = root }
				}
			}
			random_country = {
				limit = {
					OR = {
						is_country_type = fallen_empire
						is_country_type = awakened_fallen_empire
					}
					has_ethic = ethic_fanatic_spiritualist
					has_communications = root
					NOT = { is_same_value = root }
				}
				country_event = { id = utopia.2557 days = 15 }
			}
		}
		else = {
			random_country = {
				limit = {
					is_country_type = default
					has_ethic = ethic_fanatic_spiritualist
					has_communications = root
					NOT = { is_same_value = root }
				}
				country_event = { id = utopia.2557 days = 15 }
			}
		}
		if = {
			limit = {
				any_planet_within_border = {
					has_planet_flag = fotd_seperatist_planet@root
					owner = {
						has_country_flag = fotd_seperatist_country@root
					}
				}
			}
			country_event = { id = origin.6100 days = 5 random = 2 }
		}


		
		ROOT = {
			remove_country_flag = extsynths_option_1
			remove_country_flag = extsynths_option_2
			remove_country_flag = extsynths_option_3
			remove_country_flag = extsynths_option_4
			remove_country_flag = extsynths_option_5
			remove_country_flag = extsynths_option_6
			remove_country_flag = extsynths_option_7
			remove_country_flag = extsynths_option_8
			remove_country_flag = extsynths_option_9
			remove_country_flag = extsynths_option_10
			remove_country_flag = extsynths_option_11
			remove_country_flag = extsynths_option_12
			remove_country_flag = extsynths_option_13
			remove_country_flag = extsynths_option_14
			remove_country_flag = extsynths_option_15
			remove_country_flag = extsynths_option_16
			remove_country_flag = extsynths_option_17
			remove_country_flag = extsynths_option_18
			remove_country_flag = extsynths_option_19
			remove_country_flag = extsynths_option_20
			remove_country_flag = extsynths_option_21
			remove_country_flag = extsynths_option_22
			remove_country_flag = extsynths_option_23
			remove_country_flag = extsynths_option_24	
			remove_country_flag = extsynths_option_25
			remove_country_flag = extsynths_option_26
			remove_country_flag = extsynths_option_27
			remove_country_flag = extsynths_option_28
			remove_country_flag = extsynths_option_29
			remove_country_flag = extsynths_option_30
			country_event = { id = extsynths.30002 } 
		}

	
	}
	option = {
		trigger = {
			is_homicidal = no
		}
		name = "utopia.2551.a"
		custom_tooltip = extsynth.2.tooltip
	}

	option = {
		trigger = {
			is_homicidal = yes
		}
		name = "utopia.2551.a"
		custom_tooltip = extsynth.2.tooltip
	}
}

country_event = {
	id = extsynths.30002
	hide_window = yes
	is_triggered_only = yes
	immediate = {
		every_owned_leader = {
			limit = {
				species = {
					has_trait = trait_psionic
					is_extsynth_synthetic = yes
				}
			}
			add_trait = {
				trait = leader_trait_extsynth_psionic_synth
				show_message = no
			}
		}
		every_pool_leader = {
			limit = {
				species = {
					has_trait = trait_psionic
					is_extsynth_synthetic = yes
				}
			}
			add_trait = {
				trait = leader_trait_extsynth_psionic_synth
				show_message = no
			}
		}
	}
}



###Ascended Synth shouldn't have obvious organic flaw traits
event = {
	id = extsynths.15000
	hide_window = yes
	is_triggered_only = yes
	trigger = {
		always = no
		any_playable_country = {
			OR = {
				any_owned_leader = {
					species = {
						is_extsynth_synthetic = yes
					}
					OR = {
						has_trait = leader_trait_resilient
						has_trait = leader_trait_substance_abuser
						has_trait = leader_trait_arrested_development
						has_trait = leader_trait_paranoid
						has_trait = leader_trait_custom_AI_assistant
						has_trait = leader_trait_traumatized
						has_trait = leader_trait_maimed
					}
				}
				any_pool_leader = {
					species = {
						is_extsynth_synthetic = yes
					}
					OR = {
						has_trait = leader_trait_resilient
						has_trait = leader_trait_substance_abuser
						has_trait = leader_trait_arrested_development
						has_trait = leader_trait_paranoid
						has_trait = leader_trait_custom_AI_assistant
						has_trait = leader_trait_traumatized
						has_trait = leader_trait_maimed
					}
				}
			}
		}
	}
	immediate = {
		every_playable_country = {
			limit = {
				OR = {
					any_owned_leader = {
						species = {
							is_extsynth_synthetic = yes
						}
						OR = {
							has_trait = leader_trait_resilient
							has_trait = leader_trait_substance_abuser
							has_trait = leader_trait_arrested_development
							has_trait = leader_trait_paranoid
							has_trait = leader_trait_custom_AI_assistant
							has_trait = leader_trait_traumatized
							has_trait = leader_trait_maimed
						}
					}
					any_pool_leader = {
						species = {
							is_extsynth_synthetic = yes
						}
						OR = {
							has_trait = leader_trait_resilient
							has_trait = leader_trait_substance_abuser
							has_trait = leader_trait_arrested_development
							has_trait = leader_trait_paranoid
							has_trait = leader_trait_custom_AI_assistant
							has_trait = leader_trait_traumatized
							has_trait = leader_trait_maimed
						}
					}
				}
			}
		}
	}
}

###Synth leader
country_event = {
	id = extsynths.15002
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		from = {
			species = {
				is_extsynth_synthetic = yes
				has_trait = trait_psionic
			}
		}
	}
	
	immediate = {
		from = {
			add_trait = {
				trait = leader_trait_extsynth_psionic_synth
				show_message = no
			}
		}
	}
}

##Synth leader has psionic trait but no psychic trait
country_event = {
	id = extsynths.15003
	hide_window = yes
	is_triggered_only = yes
	trigger = {
		OR = {
			any_owned_leader = {
				NOR = {
					has_trait = leader_trait_psionic
					has_trait = leader_trait_chosen
				}
				species = {
					has_trait = trait_psionic
					OR = {
						has_trait = trait_mechanical
						has_trait = trait_machine_unit
					}
				}
			}
			any_pool_leader = {
				NOR = {
					has_trait = leader_trait_psionic
					has_trait = leader_trait_chosen
				}
				species = {
					has_trait = trait_psionic
					OR = {
						has_trait = trait_mechanical
						has_trait = trait_machine_unit
					}
				}
			}
		}
	}
	immediate = {
		every_pool_leader = {
			limit = {
				NOR = {
					has_trait = leader_trait_psionic
					has_trait = leader_trait_chosen
				}
				species = {
					has_trait = trait_psionic
					OR = {
						has_trait = trait_mechanical
						has_trait = trait_machine_unit
					}
				}	
			}
			add_trait = {
				trait = leader_trait_psionic
				show_message = no
			} 
		}
		every_owned_leader = {
			limit = {
				NOR = {
					has_trait = leader_trait_psionic
					has_trait = leader_trait_chosen
				}
				species = {
					has_trait = trait_psionic
					OR = {
						has_trait = trait_mechanical
						has_trait = trait_machine_unit
					}
				}	
			}
			add_trait = {
				trait = leader_trait_psionic
				show_message = no
			} 
		}
	}
}



#test
country_event = {
	id = extsynths.50000
	hide_window = yes
	is_triggered_only = yes
	immediate = {
		every_playable_country = {
			limit = {
				NOR = {
					has_ethic = ethic_gestalt_consciousness
					is_same_empire = root
				}
			}
			country_event = {
				id = extsynths.30005
				days = 5
			}
		}
	}
}

#debug
country_event = {
	id = extsynths.50001
	hide_window = yes
	is_triggered_only = yes
	immediate = {
		set_country_flag = synth_assimilation
	}
}