#
# can_expand = allowed to build outposts to expand borders
# potential = if possible to select in diplomatic interactions
# become_vassal = trigger when it converts into a vassal
# tech_cost_mult = tech cost multiplier if overlord has a tech
# overlord_influence = extra influence given to overlord
# joins_overlord_wars = Joins in if overlord goes to war (Defensive or Offensive)
# calls_overlord_to_war Calls overlord to war (Defensive only)
# can_do_diplomacy Can do some limited diplomacy
# overlord_becomes_warleader, if overlord takes over as warleader. Default true
# gets_sensor(yes): gets overlords sensors
# gets_access(yes): gets overlords access
# can_be_integrated(no): the overlord is able to integrate the subject
# can_switch_to: a list of other subject types this type can switch to.
# diplo_threat: threat generated from diplomatically vassalizing this type of subject
# effect: executes when subject relation is created

@protectorate_tech_threshold = 0.4
@protectorate_tech_switch = 0.5

#ϣ
xilin_blessed = {
	can_expand = yes
	can_be_integrated = no
	
	research_agreement = no
	research_sharing = yes	# for domination finisher
	
	
	joins_overlord_wars = yes
	calls_overlord_to_war = yes
	can_do_diplomacy = no
	
	overlord_influence = 0.25
	
	diplo_threat = 0.75
	
	subject_tax_rate = {
		minerals = 0.4
		energy = 0.4
		physics_research = 0.20
		society_research = 0.20
		engineering_research = 0.20
	}
	
	potential = {
		from = {
			has_authority = auth_xilin_mind #ϣ۹
		}
	}
	
	effect = {
		if = {
			limit = {
				from = { 
					NOT = { has_authority = auth_xilin_mind }
				}
			}
			set_subject_of = {
				who = from
				subject_type = vassal
			}
			else = {
				if = {
					limit = { #ûʥ֮ת
					  has_ethic = ethic_fanatic_xenophobe
					  has_ethic = ethic_xenophobe
					  NOT = { has_valid_civic = civic_inwards_perfection }
					}
					shift_ethic = ethic_xenophile
				}	
				set_timed_country_flag = { flag = f_new_vassal  days = 3600 }
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_blessed  } }
			     add_modifier = { modifier = m_xilin_blessed  }
			   }			   
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_tech_dependence  } }
			     add_modifier = { modifier = m_xilin_tech_dependence  }
			   }
			   
			   #Ƴԭļ
			   remove_modifier = m_xilin_follower 
			   #Ƴű߾flag
			   remove_country_flag = f_refuse_open_border_to_xilin
			   remove_country_flag = f_open_border_to_xilin					
			}
		}				
	}
}
#ϣ׷(ӹ)
xilin_follower_vassal = {
	can_expand = no
	can_be_integrated = no
	
	research_agreement = no
	research_sharing = yes	# for domination finisher
	
	
	joins_overlord_wars = yes
	calls_overlord_to_war = yes
	can_do_diplomacy = no
		
	overlord_influence = 0.25
	
	diplo_threat = 1.5
	
	subject_tax_rate = {
		minerals = 0.25
		energy = 0.25
		physics_research = 0.10
		society_research = 0.10
		engineering_research = 0.10
	}
	
	potential = {
		from = {
			has_authority = auth_xilin_mind #ϣ۹
		}
		OR = {
			tech_unlocked_ratio = {
				who = from
				ratio > @protectorate_tech_threshold
			}
			tech_unlocked_ratio = {
				who = from
				ratio = @protectorate_tech_threshold
			}
		}
	}
	
	effect = {
		if = {
			limit = {
				from = { 
					NOT = { has_authority = auth_xilin_mind }
				}
			}
			set_subject_of = {
				who = from
				subject_type = vassal
			}
			else = {
				if = {
					limit = { #ûʥ֮ת
					  has_ethic = ethic_fanatic_xenophobe
					  has_ethic = ethic_xenophobe
					  NOT = { has_valid_civic = civic_inwards_perfection }
					}
					shift_ethic = ethic_xenophile
				}	
				set_timed_country_flag = { flag = f_new_vassal  days = 3600 }
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_follower  } }
			     add_modifier = { modifier = m_xilin_follower  }
			   }			   
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_tech_dependence  } }
			     add_modifier = { modifier = m_xilin_tech_dependence  }
			   }
			   
			   #Ƴԭļ
			   remove_modifier = m_xilin_servant_vassal
			   #Ƴű߾flag
			   remove_country_flag = f_refuse_open_border_to_xilin
			   remove_country_flag = f_open_border_to_xilin					
			}
		}				
	}
}
#ϣ׷()
xilin_follower_protector  = {
	can_expand = no
	can_be_integrated = no
	
	research_agreement = no
	research_sharing = yes	# for domination finisher

	joins_overlord_wars = no
	calls_overlord_to_war = yes
	can_do_diplomacy = no

	tech_cost_mult = -0.80
	overlord_influence = 0.25
	
	diplo_threat = 0.75
	
	can_switch_to = {
		xilin_follower_vassal
	}
	
	subject_tax_rate = {
		minerals = 0.25
		energy = 0.25
	}

	potential = {
		from = {
			has_authority = auth_xilin_mind #ϣ۹
		}
	}
	
	effect = {
		if = {
			limit = {
				from = { 
					NOT = { has_authority = auth_xilin_mind }
				}
			}
			set_subject_of = {
				who = from
				subject_type = protectorate
			}
			else = {
			  #log = "become follower protector"
				if = {
					limit = {
					  has_ethic = ethic_fanatic_xenophobe
					  has_ethic = ethic_xenophobe
					  NOT = { has_valid_civic = civic_inwards_perfection }
					}
					shift_ethic = ethic_xenophile
				}		
				set_timed_country_flag = { flag = f_new_vassal  days = 3600 }
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_follower  } }
			     add_modifier = { modifier = m_xilin_follower  }
			   }			   
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_tech_dependence  } }
			     add_modifier = { modifier = m_xilin_tech_dependence  }
			   }
			   
			   #Ƴԭļ
			   remove_modifier = m_xilin_servant_vassal
			   #Ƴű߾flag
			   remove_country_flag = f_refuse_open_border_to_xilin
			   remove_country_flag = f_open_border_to_xilin		
			}
		}
	}
			
}
#ʹӹϣ۹
xilin_servant = {
  can_be_integrated = no
	can_expand = no
	joins_overlord_wars = yes
	calls_overlord_to_war = yes
	can_do_diplomacy = no
		
	subject_tax_rate = {
		minerals = 0.25
		energy = 0.25
	}
	
	potential = {
		from = { has_authority = auth_xilin_mind } #ϣ۹
	}
	
	effect = {		
		if = {
			limit = {
				from = { 
					NOT = { has_authority = auth_xilin_mind }
				}
			}
			set_subject_of = {
				who = none
			}
			else = { #Ϊʹӹ,10ͨ⽻תΪͨӹ
			   set_timed_country_flag = { flag = f_new_vassal  days = 3600 }
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_servant_vassal } }
			     add_modifier = { modifier = m_xilin_servant_vassal  }
			   }			   
			   if = {
			     limit = { NOT = { has_modifier = m_xilin_tech_dependence  } }
			     add_modifier = { modifier = m_xilin_tech_dependence  }
			   }
			   
			   #Ƴԭļ
			   remove_modifier =  m_xilin_discipline
			   #Ƴű߾flag
			   remove_country_flag = f_refuse_open_border_to_xilin
			   remove_country_flag = f_open_border_to_xilin
			   #Ƴܾflag
			    remove_country_flag = f_refuse_destroy_claim
			    #ϣ޵
			    remove_country_flag = f_rival_of_xilin
			}
		}
	}	
}


#ͽ,ϣ۹Ĺ
xilin_discipline = {
  can_be_integrated = no
	can_expand = no
	joins_overlord_wars = no
	calls_overlord_to_war = yes
	can_do_diplomacy = no
		
	subject_tax_rate = {
		minerals = 0.5
		energy = 0.5
	}
	
	potential = {
		from = { has_authority = auth_xilin_mind } #ϣ۹
	}
	
	effect = {		
		if = {
			limit = {
				from = { 
					NOT = { has_authority = auth_xilin_mind }
				}
			}
			set_subject_of = {
				who = none
			}
			else = { #Ϊͽ,20ͷ⽻̬ȾǷתΪʹ,ͷš
			    add_modifier = { modifier = m_xilin_discipline  }
			    #Ƴű߾flag
			    remove_country_flag = f_refuse_open_border_to_xilin
			    remove_country_flag = f_open_border_to_xilin
			    #Ƴܾflag
			    remove_country_flag = f_refuse_destroy_claim
			    #ϣ޵
			    remove_country_flag = f_rival_of_xilin
			    #ʽʶƳͽʶ,ᷢɱ¼
			    if =  {
			    		limit = { has_ethic = ethic_gestalt_consciousness }
			    		remove_country_flag = f_insult_xilin
			    }
			    #20󴥷¼
			    country_event = { id = xilin_diplomacy.6  days = 7200 }
			}
		}
	}	
}