# Variables:
# is_listed, boolean, decides if this diplomactic action type is listed in diplomatic view.
# prerequisites, list, the technologies required to enable the player to send this diplomatic action.
# requires_actor_peace, boolean, false by default, will require the actor to be at peace for this action to pass the possible check.
# requires_alliance_vote, boolean, false by default, will require the alliance of the actor to vote for this action before passing it on to the recipient.
# requires_actor_independence, boolean, true by default, will require the actor to be independent.
# requires_recipient_independence, boolean, true by default, will require the recipient to be independent.
# requires_actor_federation_leader, boolean, false by default, if the actor is in a federation, he has to be the leader of it.
# requires_recipient_federation_leader, boolean, true by default, if the recipient is in a federation, he has to be the leader of it.
# show_decline_to_alliance_members, boolean, false by default, will show your alliance members when you decline a proposal of this type.
# should_show_accept_message, decides whether actor gets a response on acceptance (otherwise just on decline)
# should_remove_response_message_when_not_possible, boolean, decides if diplomatic response messages should be removed when the 'possible' check fails.
# should_show_auto_accept_message_recipient, boolean, decides if the recipient gets a message showing the diplomatic action.
# should_open_auto_accept_message_recipient, boolean, decides if the recipient automatically opens this message.
# should_notify_auto_recipient_on_vote_fail, boolean, decides if recipient is notified of vote failure if action was auto accepted.
# should_show_auto_accept_message_actor, boolean, decides if the actor gets a reply showing the diplomatic action.
# should_notify_all_communications, boolean, decides if a message notification is sent to all countries who have communications with actor or recipient
# sound, string, can be used to pick a custom OnAccept sound, optional
# AI_acceptance_base_value, default = 0
# potential, trigger, root is actor, from is recipient, decides if the action is shown
# possible, trigger, root is actor, from is recipient, prev is either requester (if action is done in response to an ask_xxx counterpart) or same as root, decides if the action is still possible
# proposable, trigger, root is actor, from is recipient, decides if the action is proposable
# ai_acceptance: weight field where you can define AI reasons to accept or reject the proposal. root is recipient, from is actor. Does not overwrite hardcoded reasons, and only using add and subtract is recommended, since multiplication won't affect reasons outside the ai_acceptance field


@cb_subjugation_length = 360

# Improve opinion
action_improve_relation = {
	icon = "GFX_diplomacy_improve_relation"
	auto_accepted = yes
	require_envoy = yes
	envoy_assignment = improve_relations
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = positive

	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				OR = {
					is_country_type = default
					AND = {
						is_country_type = primitive
						NOT = {
							has_country_flag = solarpunk_country
						}
						current_awareness_level = full
						observation_owner_is_actor = yes
					}
					is_country_type = exiled
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "DIPLOMACY_STATUS_WAR"
			NOT = { is_at_war_with = from }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "ACTION_CANNOT_INTERFERE_POLICY"
			OR = {
				has_policy_flag = interference_subtle
				has_policy_flag = interference_active
				from = {
					NOT = {
						is_country_type = primitive
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fotd_seperatist"
			from = { NOT = { has_country_flag =  fotd_seperatist_country@root } }
		}
	}

	proposable = {
		custom_tooltip = {
			fail_text = "requires_envoy_not_harming_relations"
			NOT = { is_harming_relations_with = from }
		}
	}
}

# Build Spy Network
action_build_spy_network = {
	icon = "GFX_envoy_action_build_spy_network"
	auto_accepted = yes
	require_envoy = yes
	envoy_assignment = spy_network
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = positive
	sound = fc_ui_spy_network_button

	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				OR = {
					is_country_type = default
					AND = {
						is_country_type = primitive
						observation_owner_is_actor = yes
					}
					AND = {
						is_galactic_emperor = yes
						has_country_flag = fallen_empire_hive_control
						root = { is_galactic_community_member = yes }
					}
					is_country_type = exiled
				}
				NOR = {
					has_country_flag = fotd_seperatist_country
					AND = {
						has_country_flag = solarpunk_country
						is_country_type = primitive
					}
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "diplomacy_wrong_interference_policy"
			OR = {
				from = { is_country_type = default }
				from = { is_country_type = exiled }
				from = { is_fallen_empire = yes }
				AND = {
					from = { is_country_type = primitive }
					NOT = { has_policy_flag = interference_not_allowed }
				}
			}
		}
		custom_tooltip = {
			fail_text = "BLANK_STRING"
			if = {
				limit = {
					from = {
						is_primitive = no
					}
				}
				from = {
					OR = {
						is_fallen_empire = no
						AND = {
							is_galactic_emperor = yes
							has_country_flag = fallen_empire_hive_control
							root = { is_galactic_community_member = yes }
						}
					}
				}
			}
		}
	}
}

# Manage Spy Network
action_manage_spy_network = {
	icon = "GFX_envoy_action_build_spy_network"
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = neutral
	sound = fc_ui_spy_network_button

	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				OR = {
					is_country_type = default
					AND = {
						is_country_type = primitive
						observation_owner_is_actor = yes
					}
					AND = {
						is_galactic_emperor = yes
						has_country_flag = fallen_empire_hive_control
						root = { is_galactic_community_member = yes }
					}
					is_country_type = exiled
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "diplomacy_wrong_interference_policy"
			OR = {
				from = { is_country_type = default }
				from = { is_fallen_empire = yes }
				AND = {
					from = { is_country_type = primitive }
					NOT = { has_policy_flag = interference_not_allowed }
				}
			}
		}
		custom_tooltip = {
			fail_text = "BLANK_STRING"
			if = {
				limit = {
					from = {
						is_primitive = no
					}
				}
				from = {
					OR = {
						is_fallen_empire = no
						AND = {
							is_galactic_emperor = yes
							has_country_flag = fallen_empire_hive_control
							root = { is_galactic_community_member = yes }
						}
					}
				}
			}
		}
	}
}

# Harm opinion
action_harm_relation = {
	icon = "GFX_diplomacy_harm_relation"
	auto_accepted = yes
	require_envoy = yes
	envoy_assignment = harm_relations
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = negative

	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				OR = {
					is_country_type = default
					AND = {
						is_country_type = primitive
						NOT = {
							has_country_flag = solarpunk_country
						}
						current_awareness_level = full
						observation_owner_is_actor = yes
					}
					is_country_type = exiled
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "DIPLOMACY_STATUS_WAR"
			NOT = { is_at_war_with = from }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "ACTION_CANNOT_INTERFERE_POLICY"
			OR = {
				has_policy_flag = interference_subtle
				has_policy_flag = interference_active
				from = {
					NOT = {
						is_country_type = primitive
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fotd_seperatist"
			from = { NOT = { has_country_flag =  fotd_seperatist_country@root } }
		}
	}

	proposable = {
		custom_tooltip = {
			fail_text = "requires_envoy_not_improving_relations"
			NOT = { is_improving_relations_with = from }
		}
	}
}

# Declare war, usable by regular, fallen & awakened empires
action_declare_war = {
	icon = "GFX_diplomacy_status_war"
	requires_actor_independence = no # You are able to declare war only on your overlord when being a vassal, this special case is handled in code instead.
	requires_recipient_independence = no
	requires_alliance_vote = yes
	requires_unanimous_vote = yes
	auto_accepted = yes
	should_show_auto_accept_message_actor = yes
	should_show_auto_accept_message_recipient = yes
	should_open_auto_accept_message_recipient = yes
	should_notify_all_communications = yes
	action_type = aggressive

	possible = {
		custom_tooltip = {
			fail_text = "requires_recipient_not_subject_of_federation_member"
			NOT = {
				any_federation_ally = {
					is_overlord_to = fromfrom
				}
			}
		}
		custom_tooltip = {
			fail_text = "the_fe_is_busy_with_synth_queen"
			OR = {
				from = { is_fallen_empire = no }
				AND = {
					NOT = { has_global_flag = synth_queen_happened }
					from = {
						is_fallen_empire = yes
					}
				}
			}
		}
	}

	on_accept = {
		hidden_effect = {
			set_country_flag = has_declared_war
			country_event = { # Patron Objective Counter: po_declare_war
				id = shroud.10440
			}
		}
	}
}

# Start a proxy war, usable by regular, fallen & awakened empires
action_start_proxy_war = {
	icon = "GFX_diplomacy_status_war"
	requires_actor_independence = no
	requires_recipient_independence = no
	auto_accepted = yes
	action_type = neutral

	potential = {
		hidden_trigger = {
			has_shroud_dlc = yes
			OR = {
				has_tradition = tr_subterfuge_finish
				is_secret_societies_empire = yes
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "NO_RELATION_CAN_DECLARE_WAR"
			any_relation = {
				has_communications = from
			}
		}
		custom_tooltip = {
			fail_text = "PROXY_WAR_ON_COOLDOWN"
			NOT = { has_country_flag = proxy_war_cooldown }
		}
	}
}

# Make peace, usable by regular, fallen & awakened empires - accessed from war view
action_offer_peace = {
	icon = "GFX_diplomacy_status_truce"
	is_listed = no # Peace offers are handled through the war overview.
	requires_actor_independence = no
	requires_recipient_independence = no
	should_notify_all_communications = yes
	should_show_accept_message = no
	should_remove_response_message_when_not_possible = yes
	action_type = positive

	potential = {
		hidden_trigger = {
			NAND = {
				has_origin = origin_mindwardens
				exists = event_target:exiled_country@this
				from = {
					is_country_type = exiled
					is_same_value = event_target:exiled_country@root
				}
			}
		}
	}
}

# Dummy action for opening the war overview from the diplomacy view
action_offer_peace_diplomacy_view = {
	is_listed = yes
}

# Dummy action for opening the claims view from the diplomacy view
action_make_claims_diplomacy_view = {
	is_listed = yes

	potential = {
		hidden_trigger = {
			NOT = {
				has_global_flag = synth_queen_happened
				from = {
					is_fallen_empire = yes
				}
			}
			NOT = {
				from = {
					is_country_type = primitive
				}
			}
			NAND = {
				is_subject = yes
				any_agreement = {
					has_term_value = {
						term = subject_diplomacy
						value = subject_can_not_do_diplomacy
					}
				}
			}
		}
	}
}

# Offer trade deal lets you trade a bunch of stuff. Usable by regular, fallen & awakened empires.
action_offer_trade_deal = {
	icon = "GFX_diplomacy_status_trade"
	requires_recipient_independence = no
	requires_actor_independence = no
	action_type = neutral
	potential = {
		hidden_trigger = {
			is_fallen_empire_berserk_machine = no
			from = { is_fallen_empire_berserk_machine = no }
		}
	}
	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "the_fe_is_busy_with_synth_queen"
			OR = {
				from = { is_fallen_empire = no }
				AND = {
					NOT = { has_global_flag = synth_queen_happened }
					from = {
						is_fallen_empire = yes
					}
				}
			}
		}
	}
}

# Currently disabled
action_cancel_trade_deal = {
	icon = "GFX_diplomacy_status_trade"
	requires_recipient_independence = no
	requires_actor_independence = no
	is_listed = no
	auto_accepted = yes
	action_type = neutral
}

# Set any empire as your rival, gains influence but hurts relations. Usable by regular, fallen & awakened empires.
action_make_rival = {
	icon = "GFX_diplomacy_status_rivalry"
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	should_show_auto_accept_message_recipient = yes
	should_notify_all_communications = yes
	action_type = aggressive

	potential = {
		hidden_trigger = {
			is_fallen_empire_machine = no
			from = { is_fallen_empire_machine = no }
		}

		# Disable against fallen empires for subjects.
		# Can't be rivals with your overlord or their other subjects.
		hidden_trigger = {
			NAND = {
				is_subject = yes
				FROM = {
					OR = {
						is_fallen_empire = yes
						is_overlord_to = ROOT
						has_overlord = ROOT.overlord
					}
				}
			}
		}
		# Can't be rivals with your subjects.
		hidden_trigger = {
			NOT = {
				FROM = {
					is_subject = yes
					has_overlord = ROOT
				}
			}
		}

		custom_tooltip = grants_humiliation_cb_originator
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_assimilator"
			NOT = { has_valid_civic = civic_machine_assimilator }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_terrible_opinion_or_supremacist"
			OR = {
				opinion_level = { who = from level <= terrible }
				is_harming_relations_with = from
				from = { is_at_war_with = prev }
				OR = {
					has_policy_flag = "diplo_stance_supremacist"
					from = { has_policy_flag = "diplo_stance_supremacist" }
					is_fallen_empire = yes
					from = { is_fallen_empire = yes }
					has_policy_flag = "diplo_stance_animosity"
					from = { has_policy_flag = "diplo_stance_animosity" }
				}
				from = { is_rival = prev }

				# We can be rivals with the Mirror Empire no matter relations' level
				from = { is_country_type = mirrored_country }
			}
		}
		custom_tooltip = {
			fail_text = "the_fe_is_busy_with_synth_queen"
			OR = {
				from = { is_fallen_empire = no }
				AND = {
					NOT = { has_global_flag = synth_queen_happened }
					from = {
						is_fallen_empire = yes
					}
				}
			}
		}
	}

	on_accept = {
		hidden_effect = {
			check_casus_belli_valid = {
				target = from
				type = cb_humiliation
			}
			set_country_flag = has_declared_rival
		}
	}
}

# End a rivalry, 10 year cooldown on new rivalries
action_end_rivalry = {
	icon = "GFX_diplomacy_status_rivalry"
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	should_show_auto_accept_message_recipient = yes
	should_notify_all_communications = yes
	action_type = positive

	potential = {
		hidden_trigger = {
			is_fallen_empire_machine = no
			from = { is_fallen_empire_machine = no }
		}
		custom_tooltip = removes_humiliation_cb_originator
	}

	on_accept = {
		hidden_effect = {
			check_casus_belli_valid = {
				target = from
				type = cb_humiliation
			}
		}
	}
}

# Form a defensive pact with another empire that makes you defend them automatically if attacked and vice versa.
# Usable by regular empires only. Not possible while in a federation. Raises trust over time.
action_form_defensive_pact = {
	icon = "GFX_diplomacy_status_defensive_pact"
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = positive

	potential = {
		hidden_trigger = {
			NOT = { ROOT = { is_overlord_to = FROM } }
		}

		hidden_trigger = {
			NOT = { FROM = { is_overlord_to = ROOT } }
		}
		hidden_trigger = {
			is_subject = no
		}

		hidden_trigger = {
			FROM = { is_subject = no }
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		# Requirements:
		# - 20 Trust OR Good Opinion
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_20_trust_or_good

			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 20
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 10
						}
					}
				}
			}
		}

		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
			}
		}
	}
}

# Break an existing defensive pact, harms relations and sets a 10 year truce.
action_break_defensive_pact = {
	icon = "GFX_diplomacy_status_defensive_pact"
	auto_accepted = yes
	requires_actor_peace = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	action_type = negative
}

# Form a non-aggression pact with another empire, unable to declare war on each other while it is in effect.
# Usable by regular empires only. Not possible while in a federation. Raises trust over time.
action_form_non_aggression_pact = {
	icon = "GFX_diplomacy_status_non_aggression_pact"
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = positive
	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		# Requirements:
		# - 10 Trust OR Neutral Opinion
		# - An Embassy OR Improving Relations.
		custom_tooltip = {
			fail_text = requires_10_trust_or_neutral
			OR = {
				opinion_level = {
					who = from
					level >= neutral
				}
				from = {
					trust = {
						who = root
						value >= 10
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 5
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_improving_relations
			OR = {
				is_improving_relations_with = from
				has_embassy = from
			}
		}
	}
}

# Break an existing non-aggression pact, harms relations and sets a 10 year truce.
action_break_non_aggression_pact = {
	icon = "GFX_diplomacy_status_non_aggression_pact"
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	action_type = negative
}

# Form a commercial pact with another empire, increases value of both trade networks
# Usable by regular empires only. Raises trust over time.
action_form_commercial_pact = {
	icon = "GFX_diplomacy_status_commercial_pact"
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_actor_independence = yes
	requires_recipient_independence = yes
	AI_acceptance_base_value = -50
	action_type = positive
	possible = {
		custom_tooltip = {
			fail_text = "federation_automatic_commercial"
			NOT = { has_free_commercial_pact_with = { TARGET = from } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		#custom_tooltip = {
		#	fail_text = "requires_actor_not_criminal_heritage"
		#	is_criminal_syndicate = no
		#}
		#if = {
		#	limit = { from = { is_criminal_syndicate = yes } }
		#	if = {
		#		limit = {
		#			has_intel = {
		#				who = from
		#				intel = civics
		#			}
		#		}
		#		custom_tooltip = {
		#			fail_text = requires_recipient_not_criminal_heritage
		#			always = no
		#		}
		#	}
		#	else = {
		#		custom_tooltip = {
		#			fail_text = diplo_action_no_low_intel
		#			always = no
		#		}
		#	}
		#}
		custom_tooltip = {
			fail_text = "federation_actor_no_separate_treaties"
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_law = treaties_separate_no }
					NOT = { federation = { any_member = { is_same_value = root.from } } }
				}
			}
		}
		custom_tooltip = {
			fail_text = "federation_recipient_no_separate_treaties"
			from = {
				NOT = {
					AND = {
						has_federation = yes
						federation = {
							has_federation_law = treaties_separate_no
						}
						NOT = { federation = { any_member = { is_same_value = root } } }
					}
				}
			}
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		# Requirements:
		# - 20 Trust OR Good Opinion
		# - An Embassy OR the Diplomatic Networking tradition OR Universal Transactions
		custom_tooltip = {
			fail_text = requires_20_trust_or_good
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 20
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 10
						}
					}
				}
				# We don't take into consideration relations' status when dealing with the Mirror Empire
				from = { is_country_type = mirrored_country }
			}
		}
		if = {
			limit = {
				is_megacorp = no
			}
			custom_tooltip = {
				fail_text = requires_embassy_or_diplomatic_networking
				OR = {
					has_embassy = from
					has_active_tradition = tr_diplomacy_diplomatic_networking
				}
			}
		}
		else = {
			custom_tooltip = {
				fail_text = requires_embassy_diplomatic_networking_or_universal_transactions
				OR = {
					has_embassy = from
					has_active_tradition = tr_diplomacy_diplomatic_networking
					has_ascension_perk = ap_universal_transactions
				}
			}
		}
	}
}

# Break an existing commercial pact, harms relations and sets a 10 year truce.
action_break_commercial_pact = {
	icon = "GFX_diplomacy_status_commercial_pact"
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	action_type = negative
}

# Form a Wayline Pact between any valid pair (nomad-settled or nomad-nomad).
action_form_waystation_pact = {
	icon = "GFX_diplomacy_status_waystation_pact"
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = no
	should_show_auto_accept_message_recipient = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	AI_acceptance_base_value = 0
	action_type = positive

	potential = {
		hidden_trigger = {
			OR = {
				is_nomadic = yes
				from = { is_nomadic = yes }
			}
			# Only hide the action when an actual bilateral pact exists. If the only pact is the free
			# federation-granted one, keep it shown so the possible block can mark it unavailable with an explanation.
			NOT = {
				AND = {
					has_waystation_pact = from
					NOT = { has_free_waystation_pact_with = { TARGET = from } }
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "federation_automatic_waystation"
			NOT = { has_free_waystation_pact_with = { TARGET = from } }
		}
		# Subject diplomacy check: restrict whichever party is nomadic
		hidden_trigger = {
			if = {
				limit = { is_nomadic = yes }
				NAND = {
					is_subject = yes
					any_agreement = {
						has_term_value = {
							term = subject_diplomacy
							value = subject_can_not_do_diplomacy
						}
					}
				}
			}
			if = {
				limit = { from = { is_nomadic = yes } }
				from = {
					NAND = {
						is_subject = yes
						any_agreement = {
							has_term_value = {
								term = subject_diplomacy
								value = subject_can_not_do_diplomacy
							}
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "DIPLOMACY_STATUS_WAR"
			NOT = { is_at_war_with = from }
		}
		custom_tooltip = {
			fail_text = "requires_no_existing_waystation_pact"
			NOT = { has_waystation_pact = from }
		}
		# Adjacent waystations required for nomad-to-nomad pacts
		if = {
			limit = {
				is_nomadic = yes
				from = { is_nomadic = yes }
			}
			custom_tooltip = {
				fail_text = "requires_adjacent_waystations_fail"
				any_owned_nonprimary_starbase = {
					is_waystation_starbase = yes
					solar_system = {
						any_neighbor_system = {
							any_fleet_in_system = {
								is_waystation_ship = yes
								owner? = {
									is_same_value = from
								}
							}
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		custom_tooltip = {
			fail_text = "federation_actor_no_separate_treaties"
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_law = treaties_separate_no }
					NOT = { federation = { any_member = { is_same_value = root.from } } }
				}
			}
		}
		custom_tooltip = {
			fail_text = "federation_recipient_no_separate_treaties"
			from = {
				NOT = {
					AND = {
						has_federation = yes
						federation = { has_federation_law = treaties_separate_no }
						NOT = { federation = { any_member = { is_same_value = root } } }
					}
				}
			}
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_20_trust_or_good
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 20
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 10
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_improving_relations
			OR = {
				is_improving_relations_with = from
				has_embassy = from
			}
		}
	}

	should_ai_propose = {
		weight = 5
		# More likely to propose if we have waystations near the other empire's space
		modifier = {
			factor = 3
			from = {
				is_nomadic = yes
				any_owned_nonprimary_starbase = {
					is_waystation_starbase = yes
					solar_system = {
						any_neighbor_system = {
							owner? = {
								is_same_value = root
							}
						}
					}
				}
			}
		}
		# More likely to propose if the other empire has waystations near our space
		modifier = {
			factor = 3
			is_nomadic = no
			from = {
				is_nomadic = yes
			}
			any_system_within_border = {
				any_neighbor_system = {
					any_fleet_in_system = {
						is_waystation_ship = yes
						owner? = {
							is_same_value = root.from
						}
					}
				}
			}
		}
		# More likely if both nomads have neighbouring waylines
		modifier = {
			factor = 3
			is_nomadic = yes
			from = {
				is_nomadic = yes
			}
			any_owned_nonprimary_starbase = {
				is_waystation_starbase = yes
				has_neighboring_waystation = yes
				solar_system = {
					any_neighbor_system = {
						any_fleet_in_system = {
							is_waystation_ship = yes
							owner? = {
								is_same_value = root.from
							}
						}
					}
				}
			}
		}
		# More likely if we already have good relations
		modifier = {
			factor = 2
			opinion_level = {
				who = from
				level >= good
			}
		}
		# Less likely if we have poor opinion
		modifier = {
			factor = 0.1
			opinion_level = {
				who = from
				level <= poor
			}
		}
		# Never propose to rivals
		modifier = {
			factor = 0
			is_rival = from
		}
		# Never propose without an active embassy
		modifier = {
			factor = 0
			NOT = { has_embassy = from }
		}
		# Less likely to propose if we are Void Reavers
		modifier = {
			factor = 0.1
			root = {
				has_civic = civic_void_reavers
			}
		}
	}

	ai_acceptance = {
		# Base reluctance
		modifier = {
			add = -35
			desc = BASE_RELUCTANCE
		}
		# Opinion bonus (only the highest matching tier applies)
		modifier = {
			add = 15
			opinion_level = {
				who = from
				level >= neutral
			}
			opinion_level = {
				who = from
				level < good
			}
			desc = OPINION_POSITIVE
		}
		modifier = {
			add = 50
			opinion_level = {
				who = from
				level >= good
			}
			opinion_level = {
				who = from
				level < excellent
			}
			desc = OPINION_POSITIVE
		}
		modifier = {
			add = 75
			opinion_level = {
				who = from
				level >= excellent
			}
			desc = OPINION_POSITIVE
		}
		# Trust bonus
		modifier = {
			add = 25
			from = {
				trust = {
					who = root
					value >= 25
				}
			}
			desc = HIGH_TRUST
		}
		# Existing diplomatic agreements
		modifier = {
			add = 20
			OR = {
				has_commercial_pact = from
				has_research_agreement = from
				has_non_aggression_pact = from
				has_defensive_pact = from
				is_guaranteeing = from
			}
			desc = EXISTING_AGREEMENTS
		}
		# Both members of the Galactic Community
		modifier = {
			add = 25
			is_galactic_community_member = yes
			from = {
				is_galactic_community_member = yes
			}
			desc = GALACTIC_COMMUNITY_MEMBERS
		}
		# Already have neighboring waystations (mutual benefit)
		modifier = {
			add = 25
			from = {
				is_nomadic = yes
				any_owned_nonprimary_starbase = {
					is_waystation_starbase = yes
					solar_system = {
						any_neighbor_system = {
							owner? = {
								is_same_value = root
							}
						}
					}
				}
			}
			desc = NEIGHBORING_WAYSTATIONS
		}
		# Common threat bonus
		modifier = {
			add = 25
			any_country = {
				is_at_war_with = root
				is_at_war_with = from
			}
			desc = COMMON_THREAT
		}
		# Reject if rival
		modifier = {
			add = -1000
			is_rival = from
			desc = RIVALED
		}
		# Reject if poor opinion
		modifier = {
			add = -50
			opinion_level = {
				who = from
				level <= poor
			}
			desc = OPINION_NEGATIVE
		}
		# Void Reavers are reluctant to accept formal agreements
		modifier = {
			add = -150
			root = {
				has_civic = civic_void_reavers
			}
			desc = RECIPIENT_IS_VOID_REAVERS
		}
	}
}

# Either party revokes an existing Waystation Rights agreement.
action_break_waystation_pact = {
	icon = "GFX_diplomacy_status_waystation_pact"
	auto_accepted = yes
	should_notify_all_communications = no
	should_show_auto_accept_message_recipient = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = negative

	potential = {
		hidden_trigger = {
			has_waystation_pact = from
			# Don't offer breaking a free federation-granted Wayline Pact - it cannot be broken bilaterally.
			NOT = { has_free_waystation_pact_with = { TARGET = from } }
		}
	}

	should_ai_propose = {
		weight = 0
		# Note: pact is automatically broken on war declaration
		# Break pact if rivalry declared
		modifier = {
			add = 100
			is_rival = from
		}
		# Break pact if we have no embassy with the nomadic partner
		modifier = {
			add = 50
			NOT = { has_embassy = from }
		}
		# Settled empire: +25 if a pirate waystation (waystation_pirate_hideout) is in our space
		modifier = {
			add = 25
			is_nomadic = no
			from = {
				is_nomadic = yes
				any_owned_nonprimary_starbase = {
					has_starbase_module = waystation_pirate_hideout
					solar_system = {
						space_owner? = {
							is_same_empire = root
						}
					}
				}
			}
		}
		# Either party: break pact if the nomadic empire has a reaver stronghold
		modifier = {
			add = 50
			OR = {
				AND = {
					is_nomadic = yes
					any_owned_nonprimary_starbase = {
						is_waystation_starbase = yes
						has_starbase_module = waystation_reaver_stronghold
					}
				}
				AND = {
					is_nomadic = no
					from = {
						is_nomadic = yes
						any_owned_nonprimary_starbase = {
							is_waystation_starbase = yes
							has_starbase_module = waystation_reaver_stronghold
						}
					}
				}
			}
		}
	}
}

# Form a research agreement with another empire
action_form_research_agreement = {
	icon = "GFX_diplomacy_status_research_agreement"
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_actor_independence = yes
	AI_acceptance_base_value = -50
	action_type = positive
	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				OR = {
					is_country_type = default
					is_country_type = exiled
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		# When actor is organic, requires target is not exterminator
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		custom_tooltip = {
			fail_text = "federation_actor_no_separate_treaties"
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_law = treaties_separate_no }
					NOT = { federation = { any_member = { is_same_value = root.from } } }
				}
			}
		}
		custom_tooltip = {
			fail_text = "federation_recipient_no_separate_treaties"
			from = {
				NOT = {
					AND = {
						has_federation = yes
						federation = {
							has_federation_law = treaties_separate_no
						}
						NOT = { federation = { any_member = { is_same_value = root } } }
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "federation_automatic_research"
			NOT = { has_free_research_pact_with = { TARGET = from } }
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		# Requirements:
		# - 20 Trust OR Good Opinion
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_20_trust_or_good
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 20
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 10
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
			}
		}
		custom_tooltip = {
			fail_text = not_allowed_for_protectorate
			NOT = {
				OR = {
					FROM = {
						is_subject = yes
						any_agreement = { agreement_preset = preset_protectorate }
					}
					AND = {
						is_subject = yes
						any_agreement = { agreement_preset = preset_protectorate }
					}
				}
			}
		}
	}
}

# Break an existing commercial pact, harms relations and sets a 10 year truce.
action_break_research_agreement = {
	icon = "GFX_diplomacy_status_research_agreement"
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	action_type = negative
}

# Guarantee another empire, makes you defend them automatically if attacked.
# Usable by regular empires only. Not possible while in a federation. Raises trust over time.
action_guarantee_independence = {
	icon = "GFX_diplomacy_status_guarantee"
	auto_accepted = no
	diplo_view_acceptance_icon = yes
	should_show_auto_accept_message_recipient = no
	should_notify_all_communications = yes
	requires_recipient_independence = yes
	#requires_actor_independence = yes
	action_type = positive

	potential = {
		# Cannot guarantee if you are in an alliance
		hidden_trigger = {
			NOT = {
				exists = alliance
			}
		}

		# Cannot guarantee if they are in an alliance
		hidden_trigger = {
			exists = from
			from = {
				NOT = {
					exists = alliance
				}
			}
		}

		# Already guaranteeing
		hidden_trigger = {
			exists = from
			NOT = {
				is_guaranteeing = from
			}
		}

		# Defensive Pact
		hidden_trigger = {
			exists = from
			NOT = {
				has_defensive_pact = from
			}
		}

		# Cannot guarantee if target is already a subject.
		hidden_trigger = {
			FROM = { is_subject = no }
		}

		hidden_trigger = {
			is_subject = no
		}

		# Target is not overlord.
		hidden_trigger = {
			NOT = { has_overlord = FROM }
		}

	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		# Requirements:
		# - 10 Trust OR Neutral Opinion
		# - An Embassy OR Improving Relations.
		custom_tooltip = {
			fail_text = requires_10_trust_or_neutral
			OR = {
				opinion_level = {
					who = from
					level >= neutral
				}
				from = {
					trust = {
						who = root
						value >= 10
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 5
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_improving_relations
			OR = {
				is_improving_relations_with = from
				has_embassy = from
			}
		}
	}

	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10420
				scopes = {
					from = from
				}
			}
		}
	}
}

# Break an existing guarantee, harms relations and sets a 10 year truce.
action_break_guarantee = {
	icon = "GFX_diplomacy_status_guarantee"
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	requires_recipient_independence = no
	action_type = negative
}

# Support independence of a subject, makes you help them if they declare an independence war.
# Usable by regular empires only. Not possible while in a federation. Raises trust over time.
action_support_independence = {
	icon = "GFX_diplomacy_status_support_independence"
	auto_accepted = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	action_type = positive

	potential = {
		hidden_trigger = {
			exists = from
			NOT = {
				from = {
					exists = overlord
					overlord = {
						is_same_value = root
					}
				}
			}
		}

		# Actor is subject and has limited diplomacy.
		hidden_trigger = {
			NAND = {
				is_subject = yes
				any_agreement = {
					has_term_value = {
						term = subject_diplomacy
						value = subject_can_not_do_diplomacy
					}
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		# Requirements:
		# - 10 Trust OR Neutral Opinion
		# - An Embassy OR Improving Relations.
		custom_tooltip = {
			fail_text = requires_10_trust_or_neutral
			OR = {
				opinion_level = {
					who = from
					level >= neutral
				}
				from = {
					trust = {
						who = root
						value >= 10
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 5
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_improving_relations
			OR = {
				is_improving_relations_with = from
				has_embassy = from
			}
		}
	}

	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10425
				scopes = {
					from = from
				}
			}
		}
	}
}

# Break an existing support independence, harms relations.
action_break_support = {
	icon = "GFX_diplomacy_status_support_independence"
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	requires_recipient_independence = no
	action_type = negative
}

# Creates a migration treaty that allows pops to move freely between two empires. Only possible if both empires have suitable worlds for each others' pops.
# Usable by regular empires only. Raises trust over time.
action_form_migration_pact = {
	icon = "GFX_diplomacy_status_migration_pact"
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	action_type = positive
	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_gestalt_consciousness"
			NOT = { has_ethic = ethic_gestalt_consciousness	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_gestalt_consciousness"
			from = { NOT = { has_ethic = ethic_gestalt_consciousness } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		if = {
			limit = {
				from = {
					has_valid_civic = civic_selective_kinship
					NOT = { is_same_species_class = ROOT }
				}
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_selective_kinship
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_selective_kinship"
			NAND = {
				has_valid_civic = civic_selective_kinship
				NOT = { from = { is_same_species_class = root } }
			}
		}
		if = {
			limit = { from = { has_valid_civic = civic_barbaric_despoilers } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_barbaric_despoilers
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_barbaric_despoilers"
			NOT = { has_valid_civic = civic_barbaric_despoilers }
		}
		custom_tooltip = {
			fail_text = "federation_internal_migration"
			NOT = {
				AND = {
					has_federation = yes
					federation = { any_member = { is_same_value = root.from } }
					federation = { has_federation_law = free_migration_yes }
				}
			}
		}
		custom_tooltip = {
			fail_text = "federation_actor_no_separate_treaties"
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_law = treaties_separate_no }
					NOT = { federation = { any_member = { is_same_value = root.from } } }
				}
			}
		}
		custom_tooltip = {
			fail_text = "federation_recipient_no_separate_treaties"
			from = {
				NOT = {
					AND = {
						has_federation = yes
						federation = {
							has_federation_law = treaties_separate_no
						}
						NOT = { federation = { any_member = { is_same_value = root } } }
					}
				}
			}
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_pompous"
			NOT = { has_valid_civic = civic_pompous_purists	}
		}
		# Requirements:
		# - 20 Trust OR Good Opinion
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_20_trust_or_good
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 20
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 10
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
			}
		}
#		custom_tooltip = {
#			fail_text = "requires_actor_not_nomad"
#			is_nomadic = no
#		}
#		custom_tooltip = {
#			fail_text = "requires_recipient_not_nomad"
#			FROM = { is_nomadic = no }
#		}
	}
}

# Break an existing migration pact, harms relations.
action_break_migration_pact = {
	icon = "GFX_diplomacy_status_migration_pact"
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = negative
}

# Creates a non-aggression pact between a empire and an entire federation. Requires unanimous vote from the federation.
# Usable by regular empires only. Can only be sent if in a federation. Raises trust over time.
action_offer_federation_association_status = {
	icon = "GFX_diplomacy_status_associate"
	requires_actor_peace = no
	requires_recipient_peace = no
	requires_alliance_vote = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = positive
	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		# When actor is organic, requires target is not exterminator
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		# Requirements:
		# - 20 Trust OR Good Opinion
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_20_trust_or_good
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 20
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 10
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
			}
		}
		# Members of the Galactic Empire can't associate with federations
		custom_tooltip = {
			fail_text = "requires_actor_recipient_not_in_galactic_empire_2"
			NAND = {
				has_galactic_emperor = yes
				from = { is_galactic_community_member = yes }
			}
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
				root = { is_same_value = prevprev } # Bypass check if we are proposing on behalf of recipient
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
	}
	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10415
				scopes = {
					from = from
				}
			}
		}
	}
}

# Break an existing association status from the side of the federation. Requires majority vote from the federation.
# Harms relations and sets a 10 year truce with whole federation.
action_revoke_federation_association_status = {
	icon = "GFX_diplomacy_status_associate"
	auto_accepted = yes
	requires_actor_peace = no
	requires_recipient_peace = no
	requires_alliance_vote = yes
	requires_unanimous_vote = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = negative
}

# Creates a non-aggression pact between a empire and an entire federation. Requires unanimous vote from the federation.
# Usable by regular empires only. Can only be sent to a federation member, if NOT in a federation. Raises trust over time.
action_ask_for_federation_association_status = {
	icon = "GFX_diplomacy_status_associate"
	requires_actor_peace = no
	requires_recipient_peace = no
	requires_recipient_alliance_vote = yes
	diplo_view_acceptance_icon = yes
	AI_acceptance_base_value = -50
	action_type = positive
	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			NOT = { has_valid_civic = civic_fanatic_purifiers	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		# Requirements:
		# - 20 Trust OR Good Opinion
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_20_trust_or_good
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 20
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 10
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
			}
		}
		# Members of the Galactic Empire can't associate with federations
		custom_tooltip = {
			fail_text = "requires_actor_recipient_not_in_galactic_empire_2"
			NAND = {
				has_galactic_emperor = yes
				OR = {
					is_galactic_community_member = yes
					from = { is_galactic_community_member = yes }
				}
			}
		}
	}
	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10410
				scopes = {
					from = from
				}
			}
		}
	}
}

# Break an existing association status from the side of the associate. No vote required.
# Harms relations and sets a 10 year truce with whole federation.
action_end_federation_association_status = {
	icon = "GFX_diplomacy_status_associate"
	auto_accepted = yes
	requires_actor_peace = no
	requires_recipient_peace = no
	show_to_alliance_members = yes
	should_notify_all_communications = yes
	action_type = negative
}

# Creates a federation between two empires or invites an empire to an existing federation. Requires unanimous vote from the federation, if one exists already.
# Usable by regular empires only. Raises trust over time.
action_invite_to_federation = {
	icon = "GFX_diplomacy_status_federation"
	requires_actor_peace = yes
	requires_recipient_peace = yes
	requires_alliance_vote = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = positive
	should_show_auto_accept_message_recipient = yes
	should_open_auto_accept_message_recipient = yes
	should_notify_auto_recipient_on_vote_fail = yes

	potential = {
		hidden_trigger = {
			is_fallen_empire_machine = no
			from = { is_fallen_empire_machine = no }
		}
		hidden_trigger = {
			if = {
				limit = {
					FROM = {
						is_subject = yes
					}
				}
				has_federation = yes
				is_overlord_to = FROM
			}
		}
		hidden_trigger = {
			NOT = {
				has_origin = origin_endbringers
			}
			from = {
				NOT = {
					has_origin = origin_endbringers
				}
			}
		}
	}

	possible = {
		if = {
			limit = {
				has_federation = no
				is_subject = yes
			}
			custom_tooltip = {
				fail_text = requires_not_subject_to_start_federation
				OR = {
					is_subject = no
					overlord = { is_same_value = from }
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_not_subject_or_overlord_asking
			from = {
				OR = {
					is_subject = no
					overlord = { is_same_value = root }
				}
			}
		}
		if = {
			limit = {
				has_federation = no
				is_country_type = default
			}
			custom_tooltip = {
				fail_text = requires_tech_federation_code
				has_technology = tech_federation_code
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}

		# When actor is terminator, requires target machine empire/synth
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		# When actor is organic, requires target is not exterminator
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}

		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		# Requirements:
		# - 30 Trust OR Excellent Opinion
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_30_trust_or_excellent
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 30
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 15
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
			}
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
				root = { is_same_value = prevprev } # Bypass check if we are proposing on behalf of recipient
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		# Members of the Galactic Empire can't be in federations
		custom_tooltip = {
			fail_text = "requires_actor_recipient_not_in_galactic_empire"
			NAND = {
				has_galactic_emperor = yes
				OR = {
					is_galactic_community_member = yes
					from = { is_galactic_community_member = yes }
				}
			}
		}
	}

	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10400
				scopes = {
					from = from
				}
			}
		}
	}
}

# Vote for federation law
action_vote_for_federation_law = {
	icon = "GFX_diplomacy_status_federation"
	is_listed = no
	auto_accepted = yes
	requires_alliance_vote = yes
	requires_unanimous_vote = no
	requires_actor_independence = no
	requires_recipient_independence = no
	diplo_view_acceptance_icon = yes
	AI_acceptance_base_value = -50
	action_type = neutral

	potential = {
		custom_tooltip = {
			fail_text = "IS_AT_WAR"
			NOT = {
				any_war = {
					OR = {
						using_war_goal = {
							owner = root
							type = wg_leave_hegemony
						}
						using_war_goal = {
							owner = root
							type = wg_assert_hegemony
						}
					}
				}
			}
		}
	}
}

# Recipient-side federation vote for accepting a trade deal that commits the federation to a war
action_accept_trade_deal_vote = {
	icon = "GFX_diplomacy_status_trade"
	is_listed = no
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = neutral
}

# Vote for federation type
action_vote_for_federation_type = {
	icon = "GFX_diplomacy_status_federation"
	is_listed = no
	auto_accepted = yes
	requires_alliance_vote = yes
	requires_unanimous_vote = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	diplo_view_acceptance_icon = yes
	requires_actor_federation_leader = yes
	AI_acceptance_base_value = -50
	action_type = neutral
}

# Kick a member in a federation of at least 3 members. Requires majority vote from the federation.
# Harms relations and sets a 10 year truce with whole federation.
action_kick_from_federation = {
	icon = "GFX_diplomacy_status_federation"
	auto_accepted = yes
	should_show_auto_accept_message_recipient = yes
	requires_actor_peace = yes
	requires_recipient_peace = yes
	requires_alliance_vote = yes
	requires_unanimous_vote = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = aggressive

	potential = {
		hidden_trigger = {
			NAND = {
				is_subject = yes
				has_overlord = FROM
			}
		}
	}

	proposable = {
		custom_tooltip = {
			fail_text = requires_federation_leader_exists
			federation = { federation_election_underway = no }
		}
	}
}

# Ask to join an existing federation. Requires unanimous vote from the federation.
# Usable by regular empires only. Raises trust over time.
action_ask_to_join_federation = {
	icon = "GFX_diplomacy_status_federation"
	requires_actor_peace = yes
	requires_recipient_peace = yes
	requires_recipient_alliance_vote = yes
	diplo_view_acceptance_icon = yes
	AI_acceptance_base_value = -50
	action_type = positive

	potential = {
		hidden_trigger = {
			is_fallen_empire_machine = no
			from = { is_fallen_empire_machine = no }
		}
		hidden_trigger = {
			NOT = {
				has_origin = origin_endbringers
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = requires_not_subject_or_subject_asking_overlord
			OR = {
				is_subject = no
				AND = {
					is_subject = yes
					from = { is_same_value = root.overlord }
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			OR = {
				from = { has_valid_civic = civic_hive_devouring_swarm }
				NOT = { has_valid_civic = civic_hive_devouring_swarm	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			OR = {
				has_valid_civic = civic_hive_devouring_swarm
				from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		# Requirements:
		# - 30 Trust OR Excellent Opinion
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_30_trust_or_excellent
			OR = {
				opinion_level = {
					who = from
					level >= good
				}
				from = {
					trust = {
						who = root
						value >= 30
					}
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 15
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
			}
		}
		custom_tooltip = {
			fail_text = requires_actor_to_be_federation_leader
			from = {
				if = {
					limit = {
						federation = {
							has_federation_law = invite_members_president_vote_hegemony
						}
					}
					is_federation_leader = yes
				}
			}
		}
	}

	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10405
				scopes = {
					from = from
				}
			}
		}
	}
}

# Leave a federation. Harms relations and sets a 10 year truce with whole federation.
action_leave_federation = {
	icon = "GFX_diplomacy_status_federation"
	auto_accepted = yes
	requires_actor_peace = yes
	show_to_alliance_members = yes
	should_notify_all_communications = yes
	action_type = negative

	# We do not want the AI to leave federations because it does not like its subjects
	should_ai_propose = {
		weight = 1
		modifier = {
			factor = 0
			exists = from
			from = { is_subject = yes }
		}
	}

	potential = {
		hidden_trigger = {
			is_subject = no
		}
	}
	proposable = {
		custom_tooltip = {
			fail_text = requires_federation_leader_exists
			federation = { federation_election_underway = no } #messes up federation election chains
		}
	}
}

action_ask_to_leave_federation = {
	icon = "GFX_diplomacy_status_federation"
	auto_accepted = no
	requires_actor_peace = yes
	show_to_alliance_members = yes
	should_notify_all_communications = yes
	action_type = negative

	# We do not want the AI to leave federations because it does not like its subjects
	should_ai_propose = {
		weight = 1
		modifier = {
			factor = 0
			exists = from
			from = { is_subject = yes }
		}
	}

	potential = {
		hidden_trigger = {
			has_federation = yes
			federation = {
				has_federation_type = hegemony_federation
			}
		}
	}

	proposable = {
		custom_tooltip = {
			fail_text = requires_federation_leader_exists
			federation = { federation_election_underway = no } #messes up federation election chains
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_already_asked"
			NOT = { has_country_flag = asked_to_leave_hegemony }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_rebelled"
			NOT = { has_country_flag = failed_hegemony_rebellion }
		}
	}
}

# Open borders towards another empire, allowing their ships to traverse your territory. Usable by and against regular empires only.
action_open_borders = {
	icon = "GFX_diplomacy_status_open_borders"
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	should_show_auto_accept_message_recipient = yes
	#should_notify_all_communications = yes
	action_type = positive

	potential = {
		custom_tooltip_fail = {
			text = requires_actor_not_nomadic
			has_borders_trigger = yes
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
	}
}

# Close borders towards another empire, blocking their ships from entering your territory. Usable by and against regular empires only. Harms relations.
action_close_borders = {
	icon = "GFX_diplomacy_status_closed_borders"
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	should_show_auto_accept_message_recipient = yes
	#should_notify_all_communications = yes
	action_type = negative

	potential = {
		custom_tooltip_fail = {
			text = requires_actor_not_nomadic
			has_borders_trigger = yes
		}
	}

	possible = {
		hidden_trigger = {
			can_control_access_for = from
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous_borders
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}

		if = {
			limit = {
				from = {
					has_menace_perk = menp_behemoth_mind_meld
				}
			}
			custom_tooltip = {
				fail_text = behemoth_no_borders
				always = no
			}
		}
	}
	on_accept = {
        hidden_effect = {
            from = {
				if = {
					limit = {
						any_owned_fleet = {
							is_inside_border = ROOT
							is_mobile = yes
						}
					}
					random_owned_fleet = {
						limit = {
							is_inside_border = ROOT
							is_mobile = yes
						}
						fleet_event = {
							id = arkship.860
							scopes = { from = solar_system }
						}
					}
				}
            }
        }
    }
}

# Turns another empire into a subject peacefully.
# Intricacies of this relationship, including subject type, are determined by terms of the Agreement between Overlord and subject.
action_demand_subjugation = {
	icon = "GFX_diplomacy_status_has_vassal"
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = no
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	action_type = aggressive

	potential = {
		hidden_trigger = {
			FROM = {
				NOT = {
					has_overlord = ROOT
				}
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_in_galactic_empire"
			NAND = {
				has_galactic_emperor = yes
				is_galactic_community_member = no
				from = { is_galactic_community_member = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_custodian"
			from = { is_galactic_custodian = no }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_gal_emperor"
			from = { is_galactic_emperor = no }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_btc"
			from = { has_been_declared_crisis = no }
		}
		custom_tooltip = {
			fail_text = "requires_not_guaranteeing_independence"
			NOT = {
				is_guaranteeing = from
			}
		}
		if = {
			limit = {
				NOR = {
					has_menace_perk = menp_intimidation
					has_valid_civic = civic_feudal_realm
					has_valid_civic = civic_franchising
				}
			}
			# Requirements:
			# - 50 Trust OR Excellent Opinion OR Can ignore trust values
			# - An Embassy OR the Diplomatic Networking tradition.
			custom_tooltip = {
				fail_text = requires_50_trust_or_excellent
				OR = {
					opinion_level = {
						who = from
						level >= excellent
					}
					from = {
						trust = {
							who = root
							value >= 50
						}
					}
					can_ignore_trust_requirements_for_subjects = yes
					AND = {
						has_valid_civic = civic_hive_familiar_face
						from = {
							trust = {
								who = root
								value >= 25
							}
						}
					}
				}
			}
			custom_tooltip = {
				fail_text = requires_embassy_or_diplomatic_networking
				OR = {
					has_embassy = from
					has_active_tradition = tr_diplomacy_diplomatic_networking
					can_ignore_trust_requirements_for_subjects = yes
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
	}

	proposable = {
		if = {
			limit = {
				hidden_trigger = { from = { is_country_type = awakened_fallen_empire } }
			}
			hidden_trigger = { always = yes }
		}
	}

	should_ai_propose = {
		modifier = {
			mult = 0
			from = {
				trust = {
					who = root
					value < 50
				}
			}
		}
	}

	ai_acceptance = {
		modifier = {
			add = -100
			from = {
				trust = {
					who = root
					value < 50
				}
				NOT = { has_country_flag = heir_of_the_khan_khan }
			}
			desc = LACK_OF_TRUST
		}
		modifier = {
			add = -50
			root = {
				is_militarist = yes
				has_faction = imperialist
			}
			desc = TOO_IMPERIAL
		}
		modifier = { # If the Khan is bordering you, you are a lot more likely to be a subject
			add = 50
			from = {
				has_country_flag = heir_of_the_khan_khan
				is_neighbor_of = root
			}
			desc = NEIGHBORING_KHAN
		}
		modifier = { # If any of your neighbors are a satrapy, then that too makes you likely to be a subject
			add = 25
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
			any_neighbor_country = {
				is_subject = yes
				any_agreement = { agreement_preset = preset_satrapy }
			}
			desc = NEIGHBORING_SATRAPY
		}
		modifier = { # AI Heirs of the Khan empires will join you
			add = 50
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
			has_origin = origin_heirs_of_the_khan
			desc = RIGHTFUL_KHAN
		}

		modifier = { # If you have defensive pacts then you are less likely to submit to the player Khan
			subtract = value:num_defensive_pacts_times_25
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
			desc = NUMBER_OF_DEFENSIVE_PACTS
		}

		modifier = {
			subtract = 100
			desc = IN_GALACTIC_EMPIRE
			has_galactic_emperor = yes
			is_galactic_community_member = yes
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
		}
		modifier = {
			subtract = 100
			desc = IN_GLACTIC_COMMUNITY_CUSTODIAN
			has_galactic_custodian = yes
			is_galactic_community_member = yes
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
		}

		modifier = { # Nomads never want to be subjects
			subtract = 100
			desc = WANTS_TO_BE_FREE
			is_nomadic = yes
		}

		modifier = { # Planetbound empires don't trust nomadic overlords
			subtract = 100
			desc = NOMADIC_OVERLORD
			is_nomadic = no
			from = {
				is_nomadic = yes
			}
		}

		modifier = { # If you are equal or stronger than the Khan, disregard all of the above modifiers
			mult = 0
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
			relative_power = {
				who = from
				category = all
				value >= equivalent
			}
			desc = BLANK_STRING
		}
	}
}

# Ask to become subject.
# Intricacies of this relationship, including subject type, are determined by terms of the Agreement between Overlord and subject.
action_ask_to_become_subjugated = {
	icon = "GFX_diplomacy_status_has_vassal"
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = no
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = positive

	potential = {
		hidden_trigger = {
			is_subject = no
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			NOT = { has_valid_civic = civic_fanatic_purifiers	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "federation_actor_no_separate_treaties"
			NOT = {
				AND = {
					has_federation = yes
					federation = { has_federation_law = treaties_separate_no }
					NOT = { federation = { any_member = { is_same_value = root.from } } }
				}
			}
		}
		custom_tooltip = {
			fail_text = "federation_recipient_no_separate_treaties"
			from = {
				NOT = {
					AND = {
						has_federation = yes
						federation = {
							has_federation_law = treaties_separate_no
						}
						NOT = { federation = { any_member = { is_same_value = root } } }
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_not_in_galactic_empire"
			OR = {
				NAND = {
					has_galactic_emperor = yes
					is_galactic_community_member = no
					from = { is_galactic_community_member = yes }
				}
				NAND = {
					has_galactic_emperor = yes
					is_galactic_community_member = yes
					from = { is_galactic_community_member = no }
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_custodian"
			is_galactic_custodian = no
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_gal_emperor"
			is_galactic_emperor = no
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_btc"
			has_been_declared_crisis = no
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_pompous"
			NOT = { has_valid_civic = civic_pompous_purists	}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		# Requirements:
		# - 50 Trust OR Excellent Opinion OR Can ignore trust values
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_50_trust_or_excellent
			OR = {
				opinion_level = {
					who = from
					level >= excellent
				}
				from = {
					trust = {
						who = root
						value >= 50
					}
				}
				from = {
					can_ignore_trust_requirements_for_subjects = yes
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 25
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
				from = { can_ignore_trust_requirements_for_subjects = yes }
			}
		}
	}

	should_ai_propose = {
		modifier = { # If the Khan is bordering you, you are a lot more likely to be a subject
			add = 50
			from = {
				has_country_flag = heir_of_the_khan_khan
				is_neighbor_of = root
			}
			desc = NEIGHBORING_KHAN
		}
		modifier = { # If any of your neighbors are a satrapy, then that too makes you likely to be a subject
			add = 25
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
			any_neighbor_country = {
				is_subject = yes
				any_agreement = { agreement_preset = preset_satrapy }
			}
			desc = NEIGHBORING_SATRAPY
		}
		modifier = { # AI Heirs of the Khan empires will join you
			add = 50
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
			has_origin = origin_heirs_of_the_khan
			desc = RIGHTFUL_KHAN
		}

		modifier = { # If you have defensive pacts then you are less likely to submit to the player Khan
			subtract = value:num_defensive_pacts_times_25
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
			desc = NUMBER_OF_DEFENSIVE_PACTS
		}

		modifier = {
			subtract = 100
			desc = IN_GALACTIC_EMPIRE
			has_galactic_emperor = yes
			is_galactic_community_member = yes
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
		}
		modifier = {
			subtract = 100
			desc = IN_GLACTIC_COMMUNITY_CUSTODIAN
			has_galactic_custodian = yes
			is_galactic_community_member = yes
			from = {
				has_country_flag = heir_of_the_khan_khan
			}
		}

		modifier = { # Nomads never want to be subjects
			subtract = 100
			desc = WANTS_TO_BE_FREE
			from = { is_nomadic = yes }
		}

		modifier = { # Planetbound empires don't trust nomadic overlords
			subtract = 100
			desc = NOMADIC_OVERLORD
			is_nomadic = yes
			from = {
				is_nomadic = no
			}
		}

		modifier = {
			mult = 0
			from = {
				trust = {
					who = root
					value < 50
				}
				NOT = { has_country_flag = heir_of_the_khan_khan }
			}
		}
		modifier = {
			mult = 0
			relative_power = {
				who = from
				category = all
				value >= equivalent
			}
		}
		modifier = {
			add = -100
			root = {
				is_militarist = yes
				has_faction = imperialist
			}
			desc = TOO_IMPERIAL
		}
	}

	ai_acceptance = {
		modifier = {
			add = -100
			from = {
				trust = {
					who = root
					value < 50
				}
			}
			NOT = { has_country_flag = heir_of_the_khan_khan }
			desc = LACK_OF_TRUST
		}
	}
}

# Release a subject of any type. Hurts relations and sets a 10 year truce.
action_release_subject = {
	icon = "GFX_diplomacy_status_has_vassal"
	requires_recipient_independence = no
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	action_type = positive

	possible = {
		custom_tooltip = {
			fail_text = is_a_purging_subject
			NOT = { has_origin = origin_nomadic_purger }
		}
	}
}

# Ask to be released as subject of any type (overlord must accept). Hurts relations and sets a 10 year truce.
action_ask_to_be_released_subject = {
	icon = "GFX_diplomacy_status_has_vassal"
	requires_actor_independence = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	action_type = neutral

	ai_acceptance = {
		modifier = {
			add = -100
			has_origin = origin_slavers
			desc = personality_decadent_capitalists
		}
	}
}

action_negotiate_existing_agreement = {
	icon = "GFX_action_negotiate_existing_agreement"
	requires_actor_independence = no
	requires_recipient_independence = no
	requires_actor_federation_leader = no
	requires_recipient_federation_leader = no
	diplo_view_acceptance_icon = no

	potential = {
		NOT = { is_at_war_with = FROM }
	}
}

# Send an insult. Harms relations.
action_insult = {
	icon = "GFX_diplomacy_status_war"
	requires_recipient_independence = no
	requires_actor_independence = no
	auto_accepted = yes
	should_show_auto_accept_message_recipient = yes
	action_type = aggressive

	potential = {
		hidden_trigger = {
			from = {
				NOT = { is_country_type = mirrored_country }
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_poor_or_worse_opinion"

			OR = {
				opinion_level = { who = from level <= poor }
				is_fallen_empire = yes
				from = { is_fallen_empire = yes }
				is_harming_relations_with = from
				from = { is_at_war_with = prev }
			}
		}
		custom_tooltip = {
			fail_text = "the_fe_is_busy_with_synth_queen"
			OR = {
				from = { is_fallen_empire = no }
				AND = {
					NOT = { has_global_flag = synth_queen_happened }
					from = {
						is_fallen_empire = yes
					}
				}
			}
		}
	}

	on_accept = {
		from = {
			add_trust = {
				amount = -5
				who = root
			}
		}
		if = {
			limit = {
				has_technology = tech_satisfying_insults
				NOT = {
					has_modifier = satisfying_insult_recently
				}
			}
			add_modifier = {
				modifier = satisfying_insult_recently
				days = 1800
			}
			add_resource = { influence = 50 }
			country_event = {
				id = fircon.20
				days = 1800
			}
		}
	}
}

# Annex a subject of a type that permits annexation. Costs influence and takes time based on the size of the subject.
action_integrate_subject = {
	icon = "GFX_diplomacy_status_being_integrated"
	auto_accepted = yes
	requires_recipient_independence = no
	should_notify_all_communications = yes
	action_type = neutral

	possible = {
		custom_tooltip = {
			fail_text = "not_matching_nomad_regular"
			OR = {
				AND = {
					is_nomadic = yes
					FROM = { is_nomadic = yes }
				}
				AND = {
					is_nomadic = no
					FROM = { is_nomadic = no }
				}
			}
		}
	}

	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10390
				scopes = {
					from = from
				}
			}
		}
	}
}

# Cancel an ongoing integration.
action_cancel_subject_integration = {
	icon = "GFX_diplomacy_status_being_integrated"
	auto_accepted = yes
	requires_recipient_independence = no
	should_notify_all_communications = yes
	action_type = neutral
}

action_ask_to_join_galactic_empire = {
	icon = "GFX_diplomacy_status_join_galactic_empire"
	auto_accepted = no
	should_notify_all_communications = yes
	action_type = neutral
}

action_add_imperial_council_member = {
	icon = "GFX_diplomacy_status_add_imperial_council_member"
	auto_accepted = yes
	requires_recipient_independence = no
	should_notify_all_communications = yes
	action_type = positive

	on_accept = {
		hidden_effect = {
			from = {
				add_permanent_councillor = yes
				add_opinion_modifier = {
					who = root
					modifier = opinion_emperor_gave_council_seat
				}
			}
		}
	}
}

action_remove_imperial_council_member = {
	icon = "GFX_diplomacy_status_remove_imperial_council_member"
	auto_accepted = yes
	requires_recipient_independence = no
	should_notify_all_communications = yes
	action_type = negative

	on_accept = {
		hidden_effect = {
			from = {
				add_opinion_modifier = {
					who = root
					modifier = opinion_emperor_removed_council_seat
				}
			}
		}
	}
}

# Create embassies in both of your capitals. Affects intel and improve relations
action_embassy = {
	icon = "GFX_embassy_our"
	auto_accepted = no
	diplo_view_acceptance_icon = yes
	requires_recipient_independence = no
	requires_actor_independence = no
	should_notify_all_communications = no
	action_type = positive

	possible = {
		custom_tooltip = {
			fail_text = "DIPLOMACY_STATUS_WAR"
			NOT = { is_at_war_with = from }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_purge_vassal"
			NOT = { has_origin = origin_nomadic_purger }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_purge_vassal"
			from = { NOT = { has_origin = origin_nomadic_purger } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "HAS_RIVALRY"
			NOR = {
				is_rival = from
				from = { is_rival = prev }
			}
		}
		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
	}

	on_accept = {
		hidden_effect = {
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10395
				scopes = {
					from = from
				}
			}
		}
	}

	should_ai_propose = {
		weight = 0

		modifier = {
			add = 1
			has_attitude_behavior = { target = from behavior = trade }
			opinion = { who = from value > 50 }
		}

		modifier = {
			factor = 0
			has_ai_personality_behaviour = isolationist
		}

		modifier = {
			factor = 0
			has_origin = origin_nomadic_purger
		}
	}
}

action_recall_embassy = {
	icon = "GFX_embassy_our"
	auto_accepted = yes
	requires_recipient_independence = no
	requires_actor_independence = no
	should_notify_all_communications = no
	should_show_auto_accept_message_recipient = yes
	action_type = negative

	should_ai_propose = {
		weight = 0

		modifier = {
			add = 1
			opinion = { who = from value < -50 }
		}
	}
}

action_pledge_secret_fealty = {
	icon = "GFX_diplomacy_status_secret_fealty"
	auto_accepted = yes
	diplo_view_acceptance_icon = no
	requires_actor_independence = no
	requires_recipient_independence = yes
	requires_actor_federation_leader = no
	requires_recipient_federation_leader = no
	should_show_accept_message = no
	should_show_auto_accept_message_recipient = yes
	should_open_auto_accept_message_recipient = yes
	should_show_auto_accept_message_actor = no
	should_notify_all_communications = no
	action_type = positive
	possible = {
		custom_tooltip = {
			fail_text = recent_failed_betrayal_subject
			NOR = {
				has_modifier = failed_betrayal
				has_modifier = failed_betrayal_status_quo
			}
		}

		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}

		if = {
			limit = { from = { has_valid_civic = civic_fanatic_purifiers } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_fanatic_purifiers
					OR = {
						is_same_species = from
						from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
					}
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					OR = {
						is_same_species = from
						NOT = { has_valid_civic = civic_fanatic_purifiers }
					}
				}
			}
		}

		if = {
			limit = { from = { has_valid_civic = civic_hive_devouring_swarm } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_devouring_swarm
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}

		if = {
			limit = { from = { has_valid_civic = civic_machine_terminator } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_machine_terminator
					AND = {
						from = { has_civic = civic_machine_terminator }
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					AND = {
						from = { has_civic = civic_machine_terminator }
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}

		if = {
			limit = { from = { is_genocidal_infernal = yes } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_scorched_earth
					OR = {
						is_infernal_empire = yes
						from = { is_genocidal_infernal = no }
					}
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					OR = {
						is_genocidal_infernal = no
						from = { is_infernal_empire = yes }
					}
				}
			}
		}

		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}

		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}

		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm }
		}

		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_khan"
			NOT = { has_country_flag = heir_of_the_khan_khan }
		}
		# Requirements:
		# - 50 Trust OR Excellent Opinion OR the target can Ignore trust values
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_50_trust_or_excellent
			OR = {
				opinion_level = {
					who = from
					level >= excellent
				}
				from = {
					trust = {
						who = root
						value >= 50
					}
				}
				from = {
					can_ignore_trust_requirements_for_subjects = yes
				}
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 25
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
				from = { can_ignore_trust_requirements_for_subjects = yes }
			}
		}
	}
}

action_propose_secret_fealty = {
	icon = "GFX_diplomacy_status_secret_fealty"
	auto_accepted = no
	diplo_view_acceptance_icon = yes
	requires_recipient_independence = no
	requires_actor_independence = yes
	requires_actor_federation_leader = no
	requires_recipient_federation_leader = no
	should_notify_all_communications = no
	action_type = neutral
	possible = {
		custom_tooltip = {
			fail_text = recent_failed_betrayal_overlord
			NOT = {
				FROM = {
					OR = {
						has_modifier = failed_betrayal
						has_modifier = failed_betrayal_status_quo
					}
				}
			}
		}

		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}

		if = {
			limit = { from = { has_valid_civic = civic_fanatic_purifiers } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_fanatic_purifiers
					OR = {
						is_same_species = from
						from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
					}
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					OR = {
						is_same_species = from
						NOT = { has_valid_civic = civic_fanatic_purifiers }
					}
				}
			}
		}

		if = {
			limit = { from = { has_valid_civic = civic_hive_devouring_swarm } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_devouring_swarm
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}

		if = {
			limit = { from = { has_valid_civic = civic_machine_terminator } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_machine_terminator
					AND = {
						from = { has_civic = civic_machine_terminator }
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					AND = {
						from = { has_civic = civic_machine_terminator }
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		if = {
			limit = { from = { is_genocidal_infernal = yes } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = "requires_recipient_not_scorched_earth"
					OR = {
						is_infernal_empire = yes
						from = { is_genocidal_infernal = no }
					}
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					OR = {
						is_genocidal_infernal = no
						from = { is_infernal_empire = yes }
					}
				}
			}
		}

		if = {
			limit = {
				from = { has_valid_civic = civic_pompous_purists }
				NOT = { root = { is_overlord_to = from } }
			}
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_pompous
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}

		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}

		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm }
		}

		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_khan"
			from = { NOT = { has_country_flag = heir_of_the_khan_khan } }
		}
		# Requirements:
		# - 50 Trust OR Excellent Opinion OR Can ignore trust values
		# - An Embassy OR the Diplomatic Networking tradition.
		custom_tooltip = {
			fail_text = requires_50_trust_or_excellent
			OR = {
				opinion_level = {
					who = from
					level >= excellent
				}
				from = {
					trust = {
						who = root
						value >= 50
					}
				}
				can_ignore_trust_requirements_for_subjects = yes
				AND = {
					has_valid_civic = civic_hive_familiar_face
					from = {
						trust = {
							who = root
							value >= 25
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_embassy_or_diplomatic_networking
			OR = {
				has_embassy = from
				has_active_tradition = tr_diplomacy_diplomatic_networking
				can_ignore_trust_requirements_for_subjects = yes
			}
		}
	}
}

action_break_secret_fealty = {
	icon = "GFX_diplomacy_status_secret_fealty"
	auto_accepted = yes
	should_notify_all_communications = no
	should_show_auto_accept_message_recipient = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = negative
}

action_propose_to_break_secret_fealty = {
	icon = "GFX_diplomacy_status_secret_fealty"
	auto_accepted = yes
	should_notify_all_communications = no
	should_show_auto_accept_message_recipient = yes
	requires_recipient_independence = no
	action_type = negative
}

## Pre-FTL diplo actions

# Reveal Presence (set Awareness to Full)
action_reveal_presence = {
	icon = "GFX_diplomacy_reveal_presence"
	auto_accepted = yes
	sound = fc_ui_reveal_yourself_button

	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				is_country_type = primitive
				NOT = { current_awareness_level = full }
				observation_owner_is_actor = yes
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_not_ongoing_singularity_situation"
			NOT = {
				has_active_event = { action.2 }
			}
		}

		custom_tooltip = {
			fail_text = "requires_not_ongoing_singularity_situation"
			NOT = {
				any_situation = { is_situation_type = situation_pre_ftl_singularity }
			}
		}
		custom_tooltip = {
			fail_text = "requires_not_ongoing_observation_event_chain"
			NOT = {
				from = {
					any_situation = {
						has_situation_flag = has_ongoing_observation_event_chain
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		# When actor is organic, requires target is not exterminator
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "ACTION_CANNOT_INTERFERE_POLICY"
			NOT = { has_policy_flag = interference_not_allowed }
		}
		if = {
			limit = {
				has_policy_flag = interference_subtle
				from = { NOT = { current_awareness_level = high } }
			}
			custom_tooltip = {
				fail_text = "ACTION_CANNOT_LOW_AWARENESS"
				always = no
			}
		}
	}

	on_accept = {
		from = {
			switch = {
				trigger = current_awareness_level
				none = {
					capital_scope = {
						add_modifier = {
							modifier = culture_shock_diplomacy
							years = 50
						}
					}
				}
				low = {
					capital_scope = {
						add_modifier = {
							modifier = culture_shock_diplomacy
							years = 30
						}
					}
				}
				medium = {
					capital_scope = {
						add_modifier = {
							modifier = culture_shock_diplomacy
							years = 15
						}
					}
				}
				high = {
					capital_scope = {
						add_modifier = {
							modifier = culture_shock_diplomacy
							years = 5
						}
					}
				}
			}
		}
		hidden_effect = {
			country_event = { id = first_contact.6000 scopes = { from = from } }
		}
	}

	should_ai_propose = {
		weight = 0

		modifier = {
			add = 1
			has_ai_personality_behaviour = uplifter
		}
	}
}

# Societal Guidance (shifts ethic)
action_societal_enlightenment = {
	icon = "GFX_diplomacy_societal_enlightenment"
	diplo_view_acceptance_icon = yes
	AI_acceptance_base_value = -50
	action_type = negative
	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				is_country_type = primitive
				NOR = {
					is_under_societal_enlightenment = root
					has_country_flag = solarpunk_country
				}
				current_awareness_level = full
				observation_owner_is_actor = yes
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_recipient_not_invaded"
			NOT = { is_hostile = from }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fotd_seperatist"
			from = { NOT = { has_country_flag =  fotd_seperatist_country@root } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_gestalt_consciousness"
			NOT = { has_ethic = ethic_gestalt_consciousness	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_gestalt_consciousness"
			from = { NOT = { has_ethic = ethic_gestalt_consciousness } }
		}
		custom_tooltip = {
			if = {
				limit = { from = { has_valid_civic = civic_inwards_perfection } }
				if = {
					limit = {
						has_intel = {
							who = from
							intel = civics
						}
					}
					custom_tooltip = {
						fail_text = requires_recipient_not_inward_perfection
						always = no
					}
				}
				else = {
					custom_tooltip = {
						fail_text = diplo_action_no_low_intel
						always = no
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		# When actor is organic, requires target is not exterminator
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "ACTION_CANNOT_INTERFERE_POLICY"
			OR = {
				has_policy_flag = interference_subtle
				has_policy_flag = interference_active
			}
		}
	}

	on_accept = {
		hidden_effect = {
			from = {
				set_country_flag = preftl_societal_enlightenment_pact
				set_country_flag = preftl_societal_enlightenment_pact_with@root
				if = {
					limit = { capital_scope = { has_observation_outpost = yes } }
					capital_scope.observation_outpost = {
						set_event_locked = yes
					}
				}
			}
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10430
				scopes = {
					from = from
				}
			}
		}
	}

	should_ai_propose = {
		weight = 0

		modifier = {
			add = 1
			has_ai_personality_behaviour = uplifter
		}
	}

	ai_acceptance = {
		modifier = {
			add = -100
			capital_scope = {
				has_modifier = culture_shock_diplomacy
			}
			desc = NO_DIPLOMATIC_CULTURE_SHOCK
		}
		modifier = {
			add = -1000
			capital_scope = {
				has_modifier = pre_ftl_distrustful
			}
			desc = pre_ftl_distrustful
		}
	}
}

# Break existing social enlightenment pact
action_stop_societal_enlightenment = {
	icon = "GFX_diplomacy_societal_enlightenment"
	auto_accepted = yes
	should_show_auto_accept_message_recipient = yes
	action_type = positive
	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				is_country_type = primitive
				is_under_societal_enlightenment = root
				observation_owner_is_actor = yes
			}
		}
	}

	on_accept = {
		hidden_effect = {
			from = {
				remove_country_flag = preftl_societal_enlightenment_pact
				remove_country_flag = preftl_societal_enlightenment_pact_with@root
				if = {
					limit = { capital_scope = { has_observation_outpost = yes } }
					if = {
						limit = {
							NOR = {
								has_country_flag = preftl_societal_enlightenment_pact
								has_country_flag = open_technological_enlightenment_pact
								capital_scope.observation_outpost = {
									has_modifier = preftl_action_trade_pact
								}
							}
						}
						capital_scope.observation_outpost = {
							set_event_locked = no
						}
					}
				}
			}
		}
	}
}

# Open Technological Enlightment (tech progress ++)
action_open_technological_enlightenment = {
	icon = "GFX_diplomacy_open_technological_enlightenment"
	diplo_view_acceptance_icon = yes
	AI_acceptance_base_value = -50
	action_type = positive
	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				is_country_type = primitive
				current_awareness_level = full
				NOR = {
					is_under_open_technological_enlightenment = root
					has_country_flag = solarpunk_country
				}
				observation_owner_is_actor = yes
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_recipient_not_invaded"
			NOT = { is_hostile = from }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fotd_seperatist"
			from = { NOT = { has_country_flag =  fotd_seperatist_country@root } }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_tech_frozen"
			from = {
				NOR = {
					has_country_flag =  tech_frozen
					capital_scope = {
						is_planet_class = pc_habitat
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers	}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm	}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		# When actor is organic, requires target is not exterminator
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}

		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "ACTION_CANNOT_INTERFERE_POLICY"
			OR = {
				has_policy_flag = interference_subtle
				has_policy_flag = interference_active
			}
		}
		custom_tooltip = {
			fail_text = "ACTION_CANNOT_ENLIGHTEN_POLICY"
			has_policy_flag = enlightenment_allowed
		}
	}

	on_accept = {
		hidden_effect = {
			from = {
				set_country_flag = open_technological_enlightenment_pact
				# set a flag necessary for the Enlightened Times achievement
				if = {
					limit = {
						pre_ftl_ancient_era = yes
					}
					set_country_flag = started_enlightening_from_ancient_era
				}
				if = {
					limit = { capital_scope = { has_observation_outpost = yes } }
					capital_scope.observation_outpost = {
						set_event_locked = yes
					}
				}
			}
			country_event = { # Patron Objective Counter: po_establish_diplomatic_pact
				id = shroud.10435
				scopes = {
					from = from
				}
			}
		}
	}

	should_ai_propose = {
		weight = 0

		modifier = {
			add = 1
			has_ai_personality_behaviour = uplifter
		}
	}

	ai_acceptance = {
		modifier = {
			add = -100
			capital_scope = {
				has_modifier = culture_shock_diplomacy
			}
			desc = NO_DIPLOMATIC_CULTURE_SHOCK
		}
		modifier = {
			add = -1000
			capital_scope = {
				has_modifier = pre_ftl_distrustful
			}
			desc = pre_ftl_distrustful
		}
	}
}

action_stop_open_technological_enlightenment = {
	icon = "GFX_diplomacy_open_technological_enlightenment"
	auto_accepted = yes
	should_show_auto_accept_message_recipient = yes
	action_type = negative

	potential = {
		hidden_trigger = {
			is_country_type = default
			from = {
				is_country_type = primitive
				is_under_open_technological_enlightenment = root
				observation_owner_is_actor = yes
			}
		}
	}

	on_accept = {
		hidden_effect = {
			from = {
				remove_country_flag = open_technological_enlightenment_pact
				if = {
					limit = {
						has_country_flag = started_enlightening_from_ancient_era
					}
					remove_country_flag = started_enlightening_from_ancient_era
				}
				if = {
					limit = { capital_scope = { has_observation_outpost = yes } }
					if = {
						limit = {
							NOR = {
								has_country_flag = preftl_societal_enlightenment_pact
								has_country_flag = open_technological_enlightenment_pact
								capital_scope.observation_outpost = {
									has_modifier = preftl_action_trade_pact
								}
							}
						}
						capital_scope.observation_outpost = {
							set_event_locked = no
						}
					}
				}
			}
		}
	}
}

# Stratified Technological Enlightment (tech progress +)
# action_stratified_technological_enlightenment = {
# 	icon = "GFX_diplomacy_stratified_technological_enlightenment"
# 	auto_accepted = yes
# 	#AI_acceptance_base_value = -50
# 	action_type = negative
# 	potential = {
# 		hidden_trigger = {
# 			is_country_type = default
# 			from = {
# 				is_country_type = primitive
# 				NOT = {
# 					is_under_stratified_technological_enlightenment = root
# 					current_awareness_level = none
# 					current_awareness_level = low
# 				}
# 			}
# 		}
# 	}

# 	on_accept = {
# 		hidden_effect = {
# 		}
# 	}

# 	should_ai_propose = {
# 	}
# }

# action_stop_stratified_technological_enlightenment = {
# 	icon = "GFX_diplomacy_stratified_technological_enlightenment"
# 	auto_accepted = yes
# 	action_type = positive

# 	potential = {
# 		hidden_trigger = {
# 			is_country_type = default
# 			from = {
# 				is_country_type = primitive
# 				is_under_stratified_technological_enlightenment = root
# 				NOT = {
# 					current_awareness_level = none
# 					current_awareness_level = low
# 				}
# 			}
# 		}
# 	}

# 	on_accept = {
# 		hidden_effect = {
# 		}
# 	}

# 	should_ai_propose = {
# 	}
# }

# Trade deal, increases output of observation stations
action_pre_ftl_trade = {
	icon = "GFX_diplomacy_pre_ftl_trade"
	diplo_view_acceptance_icon = yes
	AI_acceptance_base_value = -50
	action_type = positive
	potential = {
		hidden_trigger = {
			has_first_contact_dlc = yes
			is_country_type = default
			from = {
				is_country_type = primitive
				NOT = { has_pre_ftl_trade = root }
				current_awareness_level = full
				NOT = { has_country_flag =  fotd_seperatist_country@root }
				observation_owner_is_actor = yes
			}
		}
	}

	possible = {
		custom_tooltip = {
			fail_text = "requires_recipient_not_invaded"
			NOT = { is_hostile = from }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				NOT = { has_valid_civic = civic_fanatic_purifiers }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_fanatic_purifiers"
			OR = {
				is_same_species = from
				from = { NOT = { has_valid_civic = civic_fanatic_purifiers } }
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_devouring_swarm"
			NOT = { has_valid_civic = civic_hive_devouring_swarm }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_devouring_swarm"
			from = { NOT = { has_valid_civic = civic_hive_devouring_swarm } }
		}
		if = {
			limit = { from = { has_valid_civic = civic_inwards_perfection } }
			if = {
				limit = {
					has_intel = {
						who = from
						intel = civics
					}
				}
				custom_tooltip = {
					fail_text = requires_recipient_not_inward_perfection
					always = no
				}
			}
			else = {
				custom_tooltip = {
					fail_text = diplo_action_no_low_intel
					always = no
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_machine_terminator"
			OR = {
				is_same_species = from
				NOT = { has_civic = civic_machine_terminator }
				AND = {
					has_civic = civic_machine_terminator
					from = {
						OR = {
							has_country_flag = synthetic_empire
							is_machine_empire = yes
							is_individual_machine = yes
						}
					}
				}
			}
		}
		# When actor is organic, requires target is not exterminator
		custom_tooltip = {
			fail_text = "requires_recipient_not_machine_terminator"
			OR = {
				is_same_species = from
				from = { NOT = { has_civic = civic_machine_terminator } }
				AND = {
					from = { has_civic = civic_machine_terminator }
					OR = {
						has_country_flag = synthetic_empire
						is_machine_empire = yes
						is_individual_machine = yes
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_scorched_earth"
			OR = {
				is_genocidal_infernal = no
				from = { is_infernal_empire = yes }
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_scorched_earth"
			OR = {
				is_infernal_empire = yes
				from = { is_genocidal_infernal = no }
			}
		}
		custom_tooltip = {
			fail_text = "ACTION_CANNOT_INTERFERE_POLICY"
			OR = {
				has_policy_flag = interference_subtle
				has_policy_flag = interference_active
			}
		}
	}

	on_accept = {
		hidden_effect = {
			from = {
				if = {
					limit = { capital_scope = { has_observation_outpost = yes } }
					capital_scope.observation_outpost = {
						add_modifier = {
							modifier = preftl_action_trade_pact
						}
					}
					capital_scope.observation_outpost = {
						set_event_locked = yes
					}
				}
				else = {
					capital_scope = {
						add_modifier = { modifier = preftl_nomad_trade_pact }
					}
				}
			}
			country_event = { # Patron Objective Counter: po_establish_trade_agreement / po_establish_diplomatic_pact
				id = shroud.10360
				scopes = {
					from = from
				}
			}
		}
	}

	should_ai_propose = {
		weight = 0

		modifier = {
			add = 1
			has_ai_personality_behaviour = uplifter
		}

		modifier = {
			add = 1
			has_corporate_government = yes
		}
	}

	ai_acceptance = {
		modifier = {
			add = -100
			capital_scope = {
				has_modifier = culture_shock_diplomacy
			}
			desc = NO_DIPLOMATIC_CULTURE_SHOCK
		}
		modifier = {
			add = -1000
			capital_scope = {
				has_modifier = pre_ftl_distrustful
			}
			desc = pre_ftl_distrustful
		}
	}
}

# Break trade agreement
action_stop_pre_ftl_trade = {
	icon = "GFX_diplomacy_pre_ftl_trade"
	auto_accepted = yes
	should_show_auto_accept_message_recipient = yes
	action_type = negative

	potential = {
		hidden_trigger = {
			OR = {
				is_country_type = default
				is_nomadic = yes
			}
			from = {
				is_country_type = primitive
				OR = {
					has_pre_ftl_trade = root
					capital_scope = { has_modifier = preftl_nomad_trade_pact }
				}
				observation_owner_is_actor = yes
			}
		}
	}

	on_accept = {
		hidden_effect = {
			from = {
				if = {
					limit = { capital_scope = { has_observation_outpost = yes } }
					capital_scope.observation_outpost = {
						remove_modifier = preftl_action_trade_pact
					}
					if = {
						limit = {
							NOR = {
								has_country_flag = preftl_societal_enlightenment_pact
								has_country_flag = open_technological_enlightenment_pact
								capital_scope.observation_outpost = {
									has_modifier = preftl_action_trade_pact
								}
							}
						}
						capital_scope.observation_outpost = {
							set_event_locked = no
						}
					}
				}
				else = {
					capital_scope = {
						remove_modifier = preftl_nomad_trade_pact
					}
				}
			}
		}
	}
}

# Used to open the Pre FTL's Homeworld
action_open_pre_ftl_homeworld = {
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	action_type = neutral

	potential = {
		hidden_trigger = {
			OR = {
				is_country_type = default
				is_nomadic = yes
			}
			from = {
				is_country_type = primitive
			}
		}
	}
}
