#
# 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 }
			}
		}
	}	
}