# 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_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_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
#  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, decides if the action is still possible
#  proposable, trigger, root is actor, from is recipient, decides if the action is proposable

@cb_subjugation_length = 360


# Declare war, usable by regular, fallen & awakened empires
action_declare_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
	
	#确保希灵帝国不会对附庸宣战，2.0未确认是否还需如此
	possible = {
			hidden_trigger = {
			    NAND ={
			        has_authority = auth_xilin_mind
			        from = {
			            exists = overlord
									overlord = {
										is_same_value = root
									}			        
			        }
			    }
			}	
	}
	
}

# Set any empire as your rival, gains influence but hurts relations. Usable by regular, fallen & awakened empires.
action_make_rival = {
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	should_show_auto_accept_message_recipient = yes
	should_notify_all_communications = yes
	
	potential = {
		hidden_trigger = {
			is_fallen_machine_empire = no
			from = { is_fallen_machine_empire = no }		
		}	
		custom_tooltip = grants_humiliation_cb_originator
		
		hidden_trigger = {
		  OR ={
		     AND = {
		       is_fallen_machine_empire = no
			     from = { is_fallen_machine_empire = no }
			     NOT = { has_authority = auth_xilin_mind } #通常希灵帝国不能宿敌其它帝国
		     }
		     AND = { #希灵帝国可以宿敌邪恶帝国
						has_authority = auth_xilin_mind  #希灵帝国
						from = {
						   OR = {
						      has_country_flag  = f_evil_country #邪恶国家
	      	        has_country_flag  = f_insult_xilin #侮辱希灵帝国的国家
	      	        has_country_flag  = f_rival_of_xilin #希灵帝国的敌人 		
	      	        has_valid_civic = civic_fanatic_purifiers
	                has_valid_civic = civic_hive_devouring_swarm
	      					has_civic = civic_machine_terminator				   
						   }
						}
				 }	
		  }		
		}	
	}

	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
	}

	on_accept = {
		hidden_effect = {
			check_casus_belli_valid = {
				target = from
				type = cb_humiliation
			}
		}
		hidden_effect = {
			if = {
	      limit = {
	         from = { has_authority = auth_xilin_mind } #若希灵帝国被宿敌
	      }
	      set_country_flag = f_rival_of_xilin
	   	}
	  }
	}
}

# 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 = {
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	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_gestalt_consciousness"
			NAND = { 
			    has_ethic = ethic_gestalt_consciousness
			    NOT = { has_valid_civic = civic_harmonious } 	
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_gestalt_consciousness"
			from = { NAND = { 
					has_ethic = ethic_gestalt_consciousness 
					NOT = { has_valid_civic = civic_harmonious } 
			} }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_inward_perfection"
			from = { NOT = { has_valid_civic = civic_inwards_perfection	} }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_barbaric_despoilers"
			from = { NOT = { has_valid_civic = civic_barbaric_despoilers } }
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_barbaric_despoilers"
			NOT = { has_valid_civic = civic_barbaric_despoilers }
		}
	}
}

# Open borders towards another empire, allowing their ships to traverse your territory. Usable by and against regular empires only.
action_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
	
	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		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
						has_authority = auth_machine_intelligence
					}
				}
			}
		}
	}
	
	on_accept = {
	  #对希灵帝国开启边境
		hidden_effect = {
			if = {
					limit = { from = { has_authority = auth_xilin_mind } }
					from = {
							check_casus_belli_valid = {
								target = root
								type = cb_open_border
							}
					}
			}			
		}
	}
}

# Close borders towards another empire, blocking their ships from entering your territory. Usable by and against regular empires only. Harms relations.
action_close_borders = {
	auto_accepted = yes
	requires_actor_independence = no
	requires_recipient_independence = no
	should_show_auto_accept_message_recipient = yes
	#should_notify_all_communications = yes
	
	possible = {
		can_control_access_for = from
		
		custom_tooltip = {
			fail_text = "XILIN_DEMAND_OPEN_BORDERS"
			NAND = {
			   has_country_flag = f_open_border_to_xilin
			   from = { has_authority = auth_xilin_mind }
			}
		}
	}
	
	on_accept = {
	  #对希灵帝国关闭边境
		hidden_effect = {
			if = {
					limit = { from = { has_authority = auth_xilin_mind } }
					from = {
							check_casus_belli_valid = {
								target = root
								type = cb_open_border
							}
					}
			}			
		}
	}
}

# Turns another empire into a vassal.
# Vassals are unable to colonize and declare wars. Vassals can be integrated and join overlord wars. Vassals are protected by overlord.
# Usable by regular empires only. Cannot be used unless the target empire has at least 40% the total tech level of overlord.
action_demand_vassalization = {
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			from = { NOT = { has_authority = auth_xilin_mind } } #无法向希灵帝国提出附庸请求
		}
	}	
	
	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		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
						has_authority = auth_machine_intelligence
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
		custom_tooltip = {
			fail_text = requires_domination_adopted
			has_non_swapped_tradition = tr_domination_adopt
		}
	}

	proposable = {
		is_neighbor_of = from
		relative_power = { who = from value >= superior }
		custom_tooltip = grants_subjugation_cb
	}

	on_decline = {
		#新希灵帝国不会强制要求附庸
		if = {
				limit = { NOT = { has_authority = auth_xilin_mind } }
				add_casus_belli = {
						type = cb_subjugation
						who = from
						days = @cb_subjugation_length
				}
		}			
	}
}

# Turns another empire into a protectorate. Protectorates are subjects that have severely discounted tech and turn into a vassal once they hit 40% the total tech level of overlord.
# Overlord gains influence from protectorates. Protectorates are allowed to colonize and declare wars and are protected by overlord. Protectorates do not join overlord wars.
# Usable by regular empires only. Cannot be used unless the target empire has less than 40% the total tech level of overlord.
action_demand_protectorate = {
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			from = { NOT = { has_authority = auth_xilin_mind } } #无法向希灵帝国提出附庸请求
		}
	}	
	
	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		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
						has_authority = auth_machine_intelligence
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_actor_not_inward_perfection"
			NOT = { has_valid_civic = civic_inwards_perfection }
		}
	}

	proposable = {
		is_neighbor_of = from
		relative_power = { who = from value >= superior }
		custom_tooltip = grants_subjugation_cb
	}

	on_decline = {
		#新希灵帝国不会强制要求附庸
		if = {
				limit = { NOT = { has_authority = auth_xilin_mind } }
				add_casus_belli = {
						type = cb_subjugation
						who = from
						days = @cb_subjugation_length
				}
		}		
	}
}

# Turns another empire into a tributary. Tributaries pay 25% of mineral and energy income to overlord.
# Tributaries are allowed to colonize and declare wars and are NOT protected by overlord. Tributaries do not join overlord wars.
# Usable by regular empires only.
action_demand_tributary = {
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			NOR = {
		     has_authority = auth_xilin_mind #希灵帝国不会提议朝贡国
		     from = {  has_authority = auth_xilin_mind  } #也无法向希灵帝国提议朝贡
		  }
		}
	}	

	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		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
						has_authority = auth_machine_intelligence
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = requires_domination_adopted
			has_non_swapped_tradition = tr_domination_adopt
		}
	}

	proposable = {
		is_neighbor_of = from
		relative_power = { who = from value >= superior }
		custom_tooltip = grants_subjugation_cb
	}

	on_decline = {			
		add_casus_belli = {
			type = cb_subjugation
			who = from
			days = @cb_subjugation_length
		}		
	}
}

# Turns another empire into a Thrall. Thralls pay 25% of mineral and energy income to overlord.
# Thralls are NOT allowed to colonize but may declare wars. They are NOT protected by overlord. They do NOT join overlord wars.
# Usable by Xenophobe Awakened Empires only.
action_demand_thrall = {
	requires_actor_peace = no
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
		  from = { NOT = { has_authority = auth_xilin_mind } } #希灵帝国不会成为附庸			
		}
	}
	
}

# Turns another empire into a Dominion. Dominions pay 25% of mineral and energy income to overlord and have their ethics set to Fanatic Spiritualist/Authoritarian on creation.
# Dominions are NOT allowed to colonize but may declare wars. They are NOT protected by overlord. They do NOT join overlord wars.
# Usable by Spiritualist Awakened Empires only.
action_demand_dominion = {
	requires_actor_peace = no
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
		  from = { NOT = { has_authority = auth_xilin_mind } } #希灵帝国不会成为附庸			
		}
	}
	
}

# Turns another empire into a Satellite. Satellites pay 50% of research income to overlord and are required to ban artificial intelligence via policies.
# Dominions are NOT allowed to colonize but may declare wars. They are NOT protected by overlord. They do NOT join overlord wars.
# Usable by Materialist Awakened Empires only.
action_demand_satellite = {
	requires_actor_peace = no
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
		  from = { NOT = { has_authority = auth_xilin_mind } } #希灵帝国不会成为附庸			
		}
	}
	
}

# Turns another empire into a Signatory. Signatories are required to ban purging and slavery via policies.
# Dominions are allowed to colonize but may NOT declare wars. They are protected by overlord. They do NOT join overlord wars.
# Usable by Xenophile Awakened Empires only.
action_demand_signatory = {
	requires_actor_peace = no
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	requires_recipient_independence = no
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
		  from = { NOT = { has_authority = auth_xilin_mind } } #希灵帝国不会成为附庸			
		}
	}
	
}

# Ask to become vassal, see above for description of this subject type.
action_ask_to_become_vassalized = {
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			NOT = { has_authority = auth_xilin_mind } #希灵帝国不会成为附庸
		}
	}
	
	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		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
						has_authority = auth_machine_intelligence
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_inward_perfection"
			from = { NOT = { has_valid_civic = civic_inwards_perfection	} }
		}
	}
}

# Ask to become protectorate, see above for description of this subject type.
action_ask_to_become_protectorate = {
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			NOT = { has_authority = auth_xilin_mind } #希灵帝国不会成为保护国
		}
	}
	
	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		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
						has_authority = auth_machine_intelligence
					}
				}
			}
		}
		custom_tooltip = {
			fail_text = "requires_recipient_not_inward_perfection"
			from = { NOT = { has_valid_civic = civic_inwards_perfection	} }
		}
	}
}

# Ask to become tributary, see above for description of this subject type.
action_ask_to_become_tributary = {
	requires_actor_peace = yes
	requires_recipient_peace = yes
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			 NOR = {
		     has_authority = auth_xilin_mind #希灵帝国不会成为朝贡国
		     from = {  has_authority = auth_xilin_mind  } #希灵帝国也不接受朝贡国
		   }
		}
	}
	
	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
							has_authority = auth_machine_intelligence
						}
					}
				}
			}
		}
		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
						has_authority = auth_machine_intelligence
					}
				}
			}
		}
	}
}

# Ask to become thrall, see above for description of this subject type.
action_ask_to_become_thrall = {
	requires_actor_peace = yes
	requires_recipient_peace = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			NOT = { has_authority = auth_xilin_mind } #希灵帝国不会成为附庸
		}
	}
	
}

# Ask to become dominion, see above for description of this subject type.
action_ask_to_become_dominion = {
	requires_actor_peace = yes
	requires_recipient_peace = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			NOT = { has_authority = auth_xilin_mind } #希灵帝国不会成为附庸
		}
	}
	
}

# Ask to become satellite, see above for description of this subject type.
action_ask_to_become_satellite = {
	requires_actor_peace = yes
	requires_recipient_peace = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			NOT = { has_authority = auth_xilin_mind } #希灵帝国不会成为附庸
		}
	}
	
}

# Ask to become signatory, see above for description of this subject type.
action_ask_to_become_signatory = {
	requires_actor_peace = yes
	requires_recipient_peace = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	potential = {
		hidden_trigger = {
			NOT = { has_authority = auth_xilin_mind } #希灵帝国不会成为附庸
		}
	}
	
}

# Release a subject of any type. Hurts relations and sets a 10 year truce.
action_release_subject = {
	requires_recipient_independence = no
	auto_accepted = yes
	should_notify_all_communications = yes
	should_show_auto_accept_message_recipient = yes
	
	on_accept = {
	   if = {
	      limit = { has_authority = auth_xilin_mind } #希灵帝国释放附庸，则移除附庸buff和flag
	      from = { country_event = { id = xilin_diplomacy.5 } }
	   }
	}
	
}

# 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 = {
	requires_actor_independence = no
	diplo_view_acceptance_icon = yes
	should_notify_all_communications = yes
	AI_acceptance_base_value = -50
	
	on_accept = {
	  if = {
	     limit = { from = { has_authority = auth_xilin_mind  }  } #希灵帝国释放附庸，则移除附庸buff和flag
	     country_event = { id = xilin_diplomacy.5 }
	  }
	}
	
}

# Send an insult. Harms relations.
action_insult = {
	requires_recipient_independence = no
	requires_actor_independence = no
	auto_accepted = yes
	should_show_auto_accept_message_recipient = yes
	
	potential = {
		hidden_trigger = {
			NAND = { 
			  has_authority = auth_xilin_mind 
			  is_ai = yes
			} #希灵帝国不屑于口头侮辱,确保ai希灵帝国不会用该项
		}
	}
	
	possible = {
	   custom_tooltip = {
			  fail_text = "IS_DIPLOMACY_WHITH_OTHER_COUNTRY"
			  NAND = {
				   has_authority = auth_xilin_mind 
			     has_country_flag = more_diplomacy_engaged
			  }
		 }
		 #希灵的附庸不能明面上侮辱希灵
		 custom_tooltip = {
			  fail_text = "XILIN_SUBJECT_CANNOT_INSULT_XILIN"
			  NAND = {
				   from = { has_authority = auth_xilin_mind }
			     #希灵附庸
			     AND = {
			        exists = overlord
			        overlord = { is_same_empire = from }
			     }
			  }
		 }
	}
	
	on_accept = {
	   if = {
	      limit = {
	         from = { has_authority = auth_xilin_mind } #若希灵帝国被侮辱
	      }
	      set_country_flag = f_insult_xilin
	   }
	   if = {
	      limit = {
	         has_authority = auth_xilin_mind  #若是希灵帝国发出且非ai，则改为更多的外交选项
	         is_ai = no
	      }
	      from = {remove_opinion_modifier = { who = root  modifier = opinion_insult } }
	      from = { save_event_target_as = Dip_More_OP_Country }	 
	      set_country_flag = more_diplomacy_engaged     
	      country_event = { id = xilin_diplo_dlg.1 }    #打开更多外交选项的外交界面	      
	   }
	}
}

# Annex a subject of a type that permits annexation. Costs influence and takes time based on the size of the subject.
action_integrate_subject = {
	auto_accepted = yes
	requires_recipient_independence = no
	should_notify_all_communications = yes
	
	potential = {
		hidden_trigger = {
			NOT = { 
			  has_authority = auth_xilin_mind 			  
			} #希灵帝国不会合并附庸
		}
	}
	
}
