namespace = sots_pmc

country_event = {
	id = sots_pmc.1
	title = sots_pmc.1.name
	desc = sots_pmc.1.desc.a
	desc = sots_pmc.1.desc.b
	desc = sots_pmc.1.desc.c
	desc = sots_pmc.1.desc.d
	desc = {
		trigger = {
			has_civic = civic_hive_devouring_swarm
		}
		text = sots_pmc.1.desc.swarm
	}
	desc = {
		trigger = {
			has_civic = civic_machine_servitor
		}
		text = sots_pmc.1.desc.servitor
	}
	desc = {
		trigger = {
			has_civic = civic_machine_obsessional_directive
		}
		text = sots_pmc.1.desc.paperclips
	}

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		room = acot_phanon_rival_room
	}
	custom_gui = "acot_enclave_phanon_window"
	custom_gui_option = "acot_enclave_phanon_option"

	immediate = {
		set_country_flag = acot_phanon_diplomacy_engaged
	}

	option = {
		name = sots_pmc.1.a #### advanced army service
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.101 }
		}
	}
	option = {
		name = sots_pmc.1.b #### theta ship service
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.102 }
		}
	}
	option = {
		name = sots_pmc.1.end
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}
}

country_event = {
	id = sots_pmc.101
	title = sots_pmc.101.name
	desc = sots_pmc.101.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		room = acot_phanon_rival_room
	}
	custom_gui = "acot_enclave_phanon_window"
	custom_gui_option = "acot_enclave_phanon_option"

	immediate = {
		set_country_flag = acot_phanon_diplomacy_engaged
	}

	option = {
		name = sots_pmc.101.setlocation.phanon
		custom_tooltip = sots_pmc.101.setlocation.explain
		trigger = {
			NOR = {
				has_country_flag = phanon_dutymen_capital_spawn				
			}
		}
		set_country_flag = phanon_dutymen_capital_spawn
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.101 }
		}
	}
	option = {
		name = sots_pmc.101.setlocation.capital
		custom_tooltip = sots_pmc.101.setlocation.explain
		trigger = {
			has_country_flag = phanon_dutymen_capital_spawn	
		}
		remove_country_flag = phanon_dutymen_capital_spawn
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.101 }
		}
	}
	option = {
		name = sots_pmc.101.a
		response_text = sots_pmc.101.b.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 20000000
			}
			resource_stockpile_compare = {
				resource = alloys
				value >= 20000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 1000
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 500
			}
		}

		custom_tooltip = sots_pmc.101.a.explain
		add_resource = {
			energy = -20000000
			alloys = -20000000
			sm_sr_perfect_runic_energy = -1000
			influence = -500
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					create_army_transport = {
						army_type = sots_phanon_operative
						species = event_target:phanon_species
					}
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_dutymen_capital_spawn								
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}			
				}
				settings = {

				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = sots_pmc.101.b
		response_text = sots_pmc.101.b.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 20000000
			}
			resource_stockpile_compare = {
				resource = alloys
				value >= 20000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 1000
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 500
			}
		}
		custom_tooltip = sots_pmc.101.b.explain
		add_resource = {
			energy = -20000000
			alloys = -20000000
			sm_sr_perfect_runic_energy = -1000
			influence = -500
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					create_army_transport = {
						army_type = sots_phanon_operative_type_b
						species = event_target:phanon_species
					}
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_dutymen_capital_spawn								
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}			
				}
				settings = {

				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = acot_pmc.1.back
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.1 }
		}
	}
	option = {
		name = acot_pmc.1.end
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

}

country_event = {
	id = sots_pmc.102
	title = sots_pmc.102.name
	desc = sots_pmc.102.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		room = acot_phanon_rival_room
	}
	custom_gui = "acot_enclave_phanon_window"
	custom_gui_option = "acot_enclave_phanon_option"

	immediate = {
		set_country_flag = acot_phanon_diplomacy_engaged
	}

	option = {
		name = sots_pmc.102.setlocation.phanon
		custom_tooltip = sots_pmc.102.setlocation.explain
		trigger = {
			NOR = {
				has_country_flag = phanon_fleet_capital_spawn				
			}
		}
		set_country_flag = phanon_fleet_capital_spawn
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.102 }
		}
	}
	option = {
		name = sots_pmc.102.setlocation.capital
		custom_tooltip = sots_pmc.102.setlocation.explain
		trigger = {
			has_country_flag = phanon_fleet_capital_spawn	
		}
		remove_country_flag = phanon_fleet_capital_spawn
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.102 }
		}
	}

	option = {
		name = sots_pmc.102.a
		response_text = sots_pmc.102.a.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 750000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 80
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 100
			}
		}
		custom_tooltip = sots_pmc.102.a.explain
		add_resource = {
			energy = -750000
			sm_sr_perfect_runic_energy = -80
			influence = -100
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					create_ship = {
						name = random
						design = NAME_ACOT_PERFECT_STARFIGHTER_HERO
					}	
					while = {
						count = 3
						create_ship = {
							name = random
							design = NAME_ACOT_PERFECT_STARFIGHTERS
						}				
					}
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_fleet_capital_spawn
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}
				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = sots_pmc.102.b
		response_text = sots_pmc.102.b.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 1000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 100
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 200
			}
		}
		custom_tooltip = sots_pmc.102.b.explain
		add_resource = {
			energy = -1000000
			sm_sr_perfect_runic_energy = 100
			influence = -200
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					while = {
						count = 2
						create_ship = {
							name = random
							design = NAME_ACOT_PERFECT_DESTROYER
						}				
					}
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_fleet_capital_spawn
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}
				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = sots_pmc.102.c
		response_text = sots_pmc.102.c.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 1000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 100
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 200
			}
		}
		custom_tooltip = sots_pmc.102.c.explain
		add_resource = {
			energy = -1000000
			sm_sr_perfect_runic_energy = 100
			influence = -200
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					create_ship = {
						name = random
						design = NAME_ACOT_PERFECT_DEVASTATOR
					}	
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_fleet_capital_spawn
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}
				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = sots_pmc.102.d
		response_text = sots_pmc.102.d.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 15000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 300
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 450
			}
		}
		custom_tooltip = sots_pmc.102.d.explain
		add_resource = {
			energy = -15000000
			sm_sr_perfect_runic_energy = -300
			influence = -450
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					create_ship = {
						name = random
						design = NAME_ACOT_PERFECT_DECIMATOR
					}	
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_fleet_capital_spawn
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}
				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = sots_pmc.102.e
		response_text = sots_pmc.102.e.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 15000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 300
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 450
			}
		}
		custom_tooltip = sots_pmc.102.e.explain
		add_resource = {
			energy = -15000000
			sm_sr_perfect_runic_energy = -300
			influence = -450
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					create_ship = {
						name = random
						design = NAME_ACOT_PERFECT_DOMINATOR_II
					}	
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_fleet_capital_spawn
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}
				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = sots_pmc.102.f
		response_text = sots_pmc.102.f.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 36000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 1800
			}
			resource_stockpile_compare = {
				resource = influence
				value >= 800
			}
		}
		custom_tooltip = sots_pmc.102.f.explain
		add_resource = {
			energy = -36000000
			sm_sr_perfect_runic_energy = -1800
			influence = -800
		}
		capital_scope = {
			create_fleet = {
				effect = {
					set_owner = root
					create_ship = {
						name = random
						design = NAME_ACOT_PERFECT_ANNIHILATOR
					}	
					if = {
						limit = { 
							root = {
								has_country_flag = phanon_fleet_capital_spawn
							}
						}
						add_modifier = {
							modifier = acot_phanon_shipping_debuff
							years = 1
						}
						set_location = {
							target = prev
							distance = 5
							angle = random
						}
					}	
					else = {
						set_location = {
							target = event_target:acot_phanon_vault
							distance = 5
							angle = random
						}
					}
				}
			}	
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}

	option = {
		name = sots_pmc.102.g
		trigger = {
			NOT = {
				has_country_flag = purchased_perfect_phanon_schematics
			}
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.1021 }
		}
	}
	option = {
		name = acot_pmc.1.back
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.1 }
		}
	}
	option = {
		name = acot_pmc.1.end
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
		}
	}
}

country_event = {
	id = sots_pmc.1021
	title = sots_pmc.1021
	desc = sots_pmc.1021.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		room = acot_phanon_rival_room
	}
	custom_gui = "acot_enclave_phanon_window"
	custom_gui_option = "acot_enclave_phanon_option"

	immediate = {
		set_country_flag = acot_phanon_diplomacy_engaged
	}
	
	option = {
		name = sots_pmc.1021.a
		response_text = sots_pmc.1021.a.response
		allow = {
			resource_stockpile_compare = {
				resource = energy
				value >= 100000000
			}
			resource_stockpile_compare = {
				resource = sm_sr_perfect_runic_energy
				value >= 5000
			}
		}
		#custom_tooltip = sots_pmc.1021.a.explain
		add_resource = {
			energy = -100000000
			sm_sr_perfect_runic_energy = 5000
		}
		add_tech_progress = {
			tech = tech_theta_phanon_assembly
			progress = 0.10
		}
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			set_country_flag = purchased_perfect_phanon_schematics
		}
	}
	option = {
		name = sots_pmc.1021.back
		hidden_effect = {
			remove_country_flag = acot_phanon_diplomacy_engaged
			country_event = { id = sots_pmc.102 }
		}
	}
}

country_event = {
	id = sots_pmc.103
	title = sots_pmc.103
	desc = sots_pmc.103.desc

	is_triggered_only = yes
	diplomatic = yes

	picture_event_data = {
		room = acot_phanon_rival_room
	}
	custom_gui = "acot_enclave_phanon_window"
	custom_gui_option = "acot_enclave_phanon_option"

	immediate = {
		set_country_flag = acot_phanon_diplomacy_engaged
	}
}