## Pre-FTL diplo actions

@diplo_flag = custom_preftl_diplomacy # Gigastructural Engineering & More
@cb_subjugation_length = 360

# 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 = {
			OR = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
				NOT = { has_country_flag = @diplo_flag }
				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 = {
					NOR = {
						has_valid_civic = civic_fanatic_purifiers
						# More Primitives
						has_country_flag = purifying_age
						has_country_flag = late_purifying_age
					}
				}
			}
		}
		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 = "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 = {
			OR = {
				has_utopia = yes
				has_first_contact_dlc = yes
			}
			OR = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
				NOT = { has_country_flag = @diplo_flag }
				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 = {
					NOR = {
						has_valid_civic = civic_fanatic_purifiers
						# More Primitives
						has_country_flag = purifying_age
						has_country_flag = late_purifying_age
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_gestalt_consciousness"
			is_gestalt = no
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_gestalt_consciousness"
			from = { is_gestalt = no }
		}
		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 = "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
				capital_scope.observation_outpost = {
					set_event_locked = yes
				}
			}
		}
	}

	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
		}
		# More Primitives
		modifier = {
			add = 25
			has_ethic = ethic_xenophile
			desc = PREFTL_IS_XENOPHILE
		}
		modifier = {
			add = 50
			has_ethic = ethic_fanatic_xenophile
			desc = PREFTL_IS_XENOPHILE
		}
	}
}

# 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 = {
			OR = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
				NOT = { has_country_flag = @diplo_flag }
				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 = {
						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 = {
			OR = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
				NOT = { has_country_flag = @diplo_flag }
				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 = {
						merg_is_habitat = yes
					}
				}
			}
		}
		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 = {
					NOR = {
						has_valid_civic = civic_fanatic_purifiers
						# More Primitives
						has_country_flag = purifying_age
						has_country_flag = late_purifying_age
					}
				}
			}
		}
		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_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
				}
				# More Primitives
				if = {
					limit = { has_country_flag = stone_age }
					set_country_flag = pre_ftl_enlightening_stone_age
				}
				else_if = {
					limit = { has_country_flag = bronze_age }
					set_country_flag = pre_ftl_enlightening_bronze_age
				}
				else_if = {
					limit = { has_country_flag = iron_age }
					set_country_flag = pre_ftl_enlightening_iron_age
				}
				else_if = {
					limit = { has_country_flag = late_medieval_age }
					set_country_flag = pre_ftl_enlightening_late_medieval_age
				}
				else_if = {
					limit = { has_country_flag = renaissance_age }
					set_country_flag = pre_ftl_enlightening_renaissance_age
				}
				else_if = {
					limit = { has_country_flag = philosophy_age }
					set_country_flag = pre_ftl_enlightening_philosophy_age
				}
				else_if = {
					limit = { has_country_flag = industrial_age }
					set_country_flag = pre_ftl_enlightening_industrial_age
				}
				else_if = {
					limit = { has_country_flag = machine_age }
					set_country_flag = pre_ftl_enlightening_machine_age
				}
				else_if = {
					limit = { has_country_flag = pollution_age }
					set_country_flag = pre_ftl_enlightening_pollution_age
				}
				else_if = {
					limit = { has_country_flag = dieselpunk_age }
					set_country_flag = pre_ftl_enlightening_dieselpunk_age
				}
				else_if = {
					limit = {
						OR = {
							has_country_flag = apocalyptic_age
							has_country_flag = post_apocalyptic_age
						}
					}
					set_country_flag = pre_ftl_enlightening_apocalyptic_age
				}
				else_if = {
					limit = { has_country_flag = pollution_age }
					set_country_flag = pre_ftl_enlightening_pollution_age
				}
				# Vanilla
				capital_scope.observation_outpost = {
					set_event_locked = yes
				}
			}
		}
	}

	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
		}
		# More Primitives
		modifier = {
			add = 25
			has_ethic = ethic_xenophile
			desc = PREFTL_IS_XENOPHILE
		}
		modifier = {
			add = 50
			has_ethic = ethic_fanatic_xenophile
			desc = PREFTL_IS_XENOPHILE
		}
		modifier = {
			add = 35
			is_materialist = yes
			desc = PREFTL_IS_MATERIALIST
		}
	}
}

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 = {
			OR = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
				NOT = { has_country_flag = @diplo_flag }
				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 = {
						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
					}
				}
			}
		}
	}
}
# 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
			OR = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
				NOT = { has_country_flag = @diplo_flag }
				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 = {
					NOR = {
						has_valid_civic = civic_fanatic_purifiers
						# More Primitives
						has_country_flag = purifying_age
						has_country_flag = late_purifying_age
					}
				}
			}
		}
		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 = "ACTION_CANNOT_INTERFERE_POLICY"
			OR = {
				has_policy_flag = interference_subtle
				has_policy_flag = interference_active
			}
		}
	}

	on_accept = {
		hidden_effect = {
			from = {
				capital_scope.observation_outpost = {
					add_modifier = {
						modifier = preftl_action_trade_pact
					}
				}
				capital_scope.observation_outpost = {
					set_event_locked = yes
				}
			}
		}
	}

	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
		}
		# More Primitives
		modifier = {
			add = 25
			has_ethic = ethic_xenophile
			desc = PREFTL_IS_XENOPHILE
		}
		modifier = {
			add = 50
			has_ethic = ethic_fanatic_xenophile
			desc = PREFTL_IS_XENOPHILE
		}
		modifier = {
			add = 25
			OR = {
				is_capitalist = yes
				is_competitive = yes
			}
			desc = PREFTL_IS_COMPETETIVE
		}
	}
}

# 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 = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
				NOT = { has_country_flag = @diplo_flag }
				has_pre_ftl_trade = root
				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
					}
				}
			}
		}
	}
}

# 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 = {
				merg_is_default_empire = yes
				# Wula Fallen Empire
				inline_script = {
					script = merger_of_rules/toggled_code
					code = "
						is_country_type = fallen_empire
					"
					toggle = @wula_compatch_var
				}
			}
			from = {
				is_country_type = primitive
			}
		}
	}
}
