# See wg_example.txt for an explanation

#ű߾ñռϵΪϣʹӹ
wg_open_border = {
	casus_belli = cb_open_border
	
	hide_if_no_cb = yes
	#set_defender_wargoal = wg_assert_overlordship
	cede_claims = occupied_only
	
	surrender_acceptance = -50
	
	potential = {
		has_authority = auth_xilin_mind #ϣ۹
	}
	possible = {
		always = yes
	}
		
	on_accept = {
		custom_tooltip = wg_open_border_accept
		hidden_effect = {
		  #ǿȿű߾
			set_country_flag = f_open_border_to_xilin
	    remove_country_flag = f_refuse_open_border_to_xilin
	    #ϣ۹⽻ۣǿǿű߾
			add_opinion_modifier = { modifier = opinion_forced_to_open_border   who = root }
				
			#100Ӱ
			add_influence = 100						
		}
	}
	
	
	ai_weight = {
		weight = 100
	}
}

#ʹӹ()
wg_xilin_servant = {
	casus_belli = cb_xilin_subjugation
	
	hide_if_no_cb = yes
	
	cede_claims = yes
	
	surrender_acceptance = -100
	
	potential = {
		has_authority = auth_xilin_mind #ϣ۹
	}
	possible = {
		always = yes
	}
		
	on_accept = {
		hidden_effect = {
			from = {
				add_threat = {
					who = root
					amount = 0.5
				}				
			}	
		}		
		from = {
			set_subject_of = {
				who = root
				subject_type = xilin_servant
			}	
		}	
	}
	
	
	ai_weight = {
		weight = 150
	}
}

#ͽ
wg_xilin_discipline = {
	casus_belli = cb_xilin_discipline
	
	hide_if_no_cb = yes
	
	cede_claims = yes
	
	surrender_acceptance = -100
	
	potential = {
		has_authority = auth_xilin_mind #ϣ۹
	}
	possible = {
		always = yes
	}
		
	on_accept = {
		hidden_effect = {
			from = {
				add_threat = {
					who = root
					amount = 0.5
				}				
			}	
		}		
		from = {
			set_subject_of = {
				who = root
				subject_type = xilin_discipline
			}	
		}	
	}
	
	
	ai_weight = {
		weight = 150
	}
}

#ϴа
wg_punish_evil = {
	casus_belli = cb_evil
	
	hide_if_no_cb = yes
	total_war = yes
	set_defender_wargoal = wg_against_xilin
	
	surrender_acceptance = -1000
	war_exhaustion = 0.25

	potential = {
		always = yes
	}
	possible = {
		always = yes
	}
	
	ai_weight = {
		weight = 200
	}
}

#ϣ鱩
wg_against_xilin = {
	casus_belli = cb_event

	total_war = yes
	
	surrender_acceptance = -1000
	war_exhaustion = 0.25
	
	potential = {
		always = no # event only
	}
	possible = {
		always = yes
	}
	
	ai_weight = {
		weight = 200
	}
}

#()
wg_xilin_liberate = {
	casus_belli = cb_xilin_liberate
	
	hide_if_no_cb = yes
	
	cede_claims = no
	
	surrender_acceptance = -100
	
	potential = {
		has_authority = auth_xilin_mind #ϣ۹
	}
	possible = {
		#ֳ
		from = {
				always = yes
		}
	}
		
	on_accept = {
		custom_tooltip = wg_xilin_liberate_accept
		hidden_effect = {
		 #ʧֹ
		 if = {
		 			limit = {
		 					NOT = {
		 						#ֳϵ
		 					  from = {		 							
	      					any_system_within_border = {
										any_planet = { 
												is_colony = yes
										}
										root = { has_claim = prev }
									}
								}
		 					}	
		 			}
		 			#log = "no colony claim"
		 			break = yes
		 }
		 #ѡһƵ
		 from = {
				random_owned_planet = {
						limit = {
								is_colony = yes
								solar_system = { root = { has_claim = prev } }
						}
						save_event_target_as = new_country_species
						save_event_target_as = new_country_planet
				}				
		 }
		 #Ƶϵ¹
		 create_country = {
				name = random
				type = default
				#auto_delete = <bool>
				#name_list = <key>
				#ship_prefix = <string>
				species = event_target:new_country_species
				authority = random
				ethos = random
				civics = random 				
				flag =  random 
				day_zero_contact = no		
				ignore_initial_colony_error = yes		
				effect = { 
						#˼
						if = {
								limit = {								
										OR = {
												has_ethic = ethic_fanatic_xenophobe
												has_ethic = ethic_xenophobe
										}
									
								}
								shift_ethic = ethic_xenophile
						}
						if = {
								limit = {
									 has_ethic = ethic_fanatic_authoritarian									
								}
								shift_ethic = ethic_egalitarian
						}
						save_event_target_as = new_country
				} #effect
			}
			#ϵ¹
			from = {
				every_system_within_border = {
						limit = {
								root = { has_claim = prev }
						}
						#ϵڵ¹
						every_system_planet = {
								limit = {	is_colony = yes	}
								set_owner = event_target:new_country
								set_controller = event_target:new_country
						}
						#Ǳ¹
						if = {
							limit = {
								exists = starbase
							}
							starbase = { 
								set_owner = event_target:new_country 								
							}
						}
						#Ƴ
						remove_claims = { who = root }
						remove_claims = { who = prev }
				}
				
		  }
			event_target:new_country = {
			    #⽻ϵӹ۵
					establish_communications_no_message = root
					establish_communications_no_message = from
					establish_contact = { who = root location = event_target:new_country_planet }
					establish_contact = { who = from location = event_target:new_country_planet }						
					add_modifier = {
								modifier = "recently_liberated"
								days = 7200
					}
					add_opinion_modifier = { modifier = opinion_liberated_us who = root }
					root = { add_opinion_modifier = { modifier = opinion_we_liberated who = prev } }
					
					every_country = {
								limit = { is_in_federation_with = root }
								establish_communications_no_message = prev
								establish_contact = { who = prev location = event_target:new_country_planet }
								add_opinion_modifier = { modifier = opinion_we_liberated who = prev }
								event_target:new_country = { add_opinion_modifier = { modifier = opinion_liberated_us who = prev } }				
					}
					#
					create_fleet_from_naval_cap = 0.5
			}
			#Ŀвֵ
			from = {
				add_threat = {
					who = root
					amount = 0.25
				}				
			}
		} #hidden_effect
	}
	
	ai_weight = {
		weight = 150
	}
}