######################
# PARAGON DECISIONS #
######################
decision_deploy_beholder = {
	owned_planets_only = yes
	sound = event_administrative_work
	icon = decision_deploy_temple_of_whispers

	allow = {
		custom_tooltip = {
			fail_text = cannot_deploy_during_psi_inoculation
			NOT = { has_carrier_flag = psi_inoculating_pops }
		}
	}

	resources = {
		category = decisions
		cost = {
			sr_zro = 100
		}
	}

	potential = {
		exists = event_target:beholder_leader
		has_building = building_the_beholder
	}

	effect = {
		custom_tooltip = decision_deploy_beholder_custom_tooltip
		hidden_effect = {
			# Remove building
			remove_building = building_the_beholder

			event_target:beholder_leader = {
				remove_trait = leader_trait_governor_psionic_communion
				remove_trait = leader_trait_mediator
				remove_trait = leader_trait_generator_focus_2
				remove_trait = leader_trait_intellectual
				remove_trait = subclass_official_governor
				change_leader_class = commander
				add_trait = {
					trait = subclass_commander_admiral
					show_message = no
					consume_selection = yes
				}
				add_trait = {
					trait = leader_trait_scout
					show_message = no
					consume_selection = yes
				}
				add_trait = {
					trait = leader_trait_energy_weapon_specialist
					show_message = no
					consume_selection = yes
				}
				add_trait = {
					trait = leader_trait_cautious
					show_message = no
					consume_selection = yes
				}
				add_trait = {
					trait = leader_trait_psionic
					show_message = no
					consume_selection = yes
				}
			}

			create_fleet = {
				name = "NAME_Temple_of_Whispers"
				settings = {
					can_upgrade = no
					can_change_composition = no
					can_change_leader = no
					can_disband = no
					spawn_debris = no
				}
				effect = {
					set_owner = root.owner
					create_ship_design = {
						design = NAME_Temple_of_Whispers
					}
					create_ship = {
						design = last_created_design
						name = "NAME_Temple_of_Whispers"
						prefix = no
						upgradable = no
						effect = {
							set_ship_flag = is_beholder_ship
							save_global_event_target_as = beholder_ship
						}
					}
					set_location = prev
					assign_leader = event_target:beholder_leader
				}
			}
		}
	}

	ai_weight = {
		weight = 5

		# Save up some buffer zro before deploying
		modifier = {
			factor = 0
			has_resource = { type = sr_zro amount < 150 }
		}
	}
}

decision_psi_inoculate_pops = {
	owned_planets_only = yes
	sound = event_activating_unknown_technology
	icon = decision_psi_inoculate_pops

	resources = {
		category = decisions
		cost = {
			sr_zro = 50
		}
	}

	allow = {
		custom_tooltip = {
			fail_text = no_organic_pops_on_planet
			any_owned_pop_group = {
				is_organic_species = yes
				is_being_assimilated = no
				is_being_purged = no
				NOR = {
					has_trait = trait_cybernetic
					is_psionic_species = yes
					has_trait = trait_hive_mind
				}
			}
		}
		custom_tooltip = {
			fail_text = beholder_psi_pops_cooldown_tooltip
			NOT = {
				has_carrier_flag = beholder_psi_pops_cooldown_timer
			}
		}
	}

	potential = {
		exists = event_target:beholder_leader
		has_building = building_the_beholder
		NOT = {
			has_carrier_flag = psi_inoculating_pops
		}
	}

	effect = {
		custom_tooltip = decision_psi_inoculate_pops_custom_tooltip
		hidden_effect = {
			set_carrier_flag = psi_inoculating_pops
			if = {
				limit = {
					NOT = {
						has_carrier_flag = beholder_psi_pops_timer
					}
				}
				set_saved_date = {
					key = beholder_psi_pops_timer
					days_from_present = 180
					expires = 180
				}
				carrier_event = {
					id = paragon.50
					days = 180
				}
			}
		}
	}

	ai_weight = {
		weight = 2
	}
}

decision_cease_psi_inoculate_pops = {
	owned_planets_only = yes
	sound = event_activating_unknown_technology
	icon = decision_psi_inoculate_pops

	resources = {
	}

	potential = {
		exists = event_target:beholder_leader
		has_building = building_the_beholder
		has_carrier_flag = psi_inoculating_pops
	}

	effect = {
		custom_tooltip = decision_cease_psi_inoculate_pops_custom_tooltip
		hidden_effect = {
			remove_carrier_flag = psi_inoculating_pops
			remove_carrier_flag = beholder_psi_pops_timer
			set_saved_date = {
				key = beholder_psi_pops_cooldown_timer
				days_from_present = 180
				expires = 180
			}
		}
	}

	ai_weight = {
		weight = 2
	}
}

decision_paragon_origin_subdue_reformists = {
	owned_planets_only = yes
	sound = event_administrative_work
	icon = decision_smugglers_in_bar

	enactment_time = 180

	potential = {
		exists = owner
		owner = {
			exists = ruler
			ruler = {
				has_leader_flag = paragon_origin_legendary_leader
			}
			any_situation = { is_situation_type = paragon_origin_reformists_struggle }
			is_regular_empire = yes
		}
		has_modifier = paragon_origin_reformists
	}

	allow = {
	}

	abort_trigger = {
		exists = ruler
		ruler = {
			NOT = { has_leader_flag = paragon_origin_legendary_leader }
		}
	}

	resources = {
		category = decisions
		cost = {
			unity = 1
			multiplier = colony.value:pop_ethic_amount_value|ETHIC|egalitarian|
		}
	}

	effect = {
		custom_tooltip = decision_paragon_origin_subdue_reformists_tt
		owner = {
			if = {
				limit = {
					any_situation = {
						is_situation_type = paragon_origin_reformists_struggle
						situation_progress > 9
					}
				}
				random_situation = {
					limit = { is_situation_type = paragon_origin_reformists_struggle }
					add_situation_progress = -8
				}
			}
		}
		hidden_effect = {
			weighted_random_owned_pop_group = {
				limit = {
					has_ethic = ethic_egalitarian
				}
				pop_group_transfer_effect = {
					POP_GROUP = this
					OLD_ETHOS = ethic_egalitarian
					ETHOS = ethic_authoritarian
					AMOUNT = 100
					RANDOM = 25
				}
			}
			weighted_random_owned_pop_group = {
				limit = { has_ethic = ethic_egalitarian }
				pop_force_remove_ethic = {
					ethic = ethic_egalitarian
					amount = 100
				}
				kill_single_pop = yes
			}
			owner = {
				ruler = { paragon_origin_gain_delusion = yes }
			}
			if = {
				limit = {
					NOT = {
						any_owned_pop_group = {
							has_ethic = ethic_egalitarian
						}
					}
				}
				remove_modifier = paragon_origin_reformists
			}
		}
	}

	ai_weight = {
		weight = 5
	}
}
