namespace = xilin

#希灵帝国开局设置
event = {
  id = xilin.1
  hide_window = yes
  is_triggered_only = yes
  immediate = {
    #检查开局有没有希灵帝国，若没有则生成希灵帝国
#    if = {
#        limit ={ NOT = { any_country = { has_country_flag = f_xilin_empire } } }
#        random_system = {
#				    spawn_system = { initializer = "xilin_shadow_system" }
#			  }    
#    }
		every_country = {
			limit = { has_country_flag = f_xilin_empire }
			#送科技
      country_event = { id = xilin.2 }
      #更改初始种族特性，设置种族变更效果
      country_event = { id = xilin.4 }
      #设置初始领袖
      country_event = { id = xilin.3 }
      #随机部分人口吃电
      country_event = { id = xilin.5 }
      #设置开局完成标记
      set_country_flag = f_xilin_started      
		}
		#蜂群国家领袖性别统统设为女性(为卡拉剧情做准备)
		every_country = {
			limit = { has_authority = auth_hive_mind }
			leader = {
					set_is_female = yes
			}
		}
	}
}
#初始送科技
country_event = {
  id = xilin.2
  hide_window = yes
  is_triggered_only = yes

  immediate = {
      give_technology = { tech = "tech_ship_armor_1" message = no }
		  give_technology = { tech = "tech_shields_1" message = no }
		  #give_technology = { tech = "tech_solar_panel_network" message = no }
		  give_technology = { tech = "tech_biolab_1" message = no }
		  give_technology = { tech = "tech_engineering_lab_1" message = no }
		  give_technology = { tech = "tech_physics_lab_1" message = no }
		  give_technology = { tech = "tech_planetary_unification" message = no }
		  give_technology = { tech = "tech_xilin_knowledge_architecture" message = no } #希灵科技体系
		  
		  give_technology = { tech = "tech_powered_exoskeletons" message = no } #外骨骼动力
		  give_technology = { tech = "tech_robotic_workers" message = no } #机器人
		  give_technology = { tech = "tech_droid_workers" message = no } #智能人
		  give_technology = { tech = "tech_synthetic_workers" message = no } #合成人
		  give_technology = { tech = "tech_synthetic_leaders" message = no } #合成人领袖
		  give_technology = { tech = "tech_xilin_workers" message = no } #希灵机器人
		  
		  give_technology = { tech = "tech_subdermal_stimulation" message = no } #化学极乐
		  
		  #送3种初始武器
		  give_technology = { tech = "tech_mass_drivers_1" message = no } 
		  give_technology = { tech = "tech_missiles_1" message = no } 
		  give_technology = { tech = "tech_lasers_1" message = no } 
  }
}

#设置初始领袖
country_event = {
  id = xilin.3
  hide_window = yes
  is_triggered_only = yes

  immediate = {  		
      #创建神性人类
  		create_species = {
				name = "SP_GOD"
				plural = "SP_GOD"
				class = XILIN_WORLD
				portrait = human_god
				traits = {
					trait = trait_divinity
				}
			}
			last_created_species = {
			   save_global_event_target_as = GOD_HUMAN
			}
		 
     #陈倩(总督)，创建，并确保是女性
     set_country_flag=f_creating_leader
  	 create_leader = {
					type = governor
					species = last_created									
					name = "NAME_chenqian"
					traits = {
						trait = leader_trait_architectural_interest
						trait = leader_trait_intellectual
						trait = leader_trait_chenqian
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_chenqian
			    set_leader_flag = f_npc			    
     }
	   remove_country_flag = f_creating_leader
	   
		 #许浅浅(研究员，她会研究啥。。。)
		 set_country_flag=f_creating_leader
     create_leader = {
					type = scientist
					species = last_created										
					name = "NAME_xuqianqian"
					traits = {
						trait = leader_trait_meticulous
					  trait = leader_trait_roamer
					  trait = leader_trait_archaeologist 
					  trait = leader_trait_xuqianqian
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_xuqianqian
			    set_leader_flag = f_npc   
     }
     remove_country_flag = f_creating_leader
     
		  #林雪(总督)，创建，并确保是女性
     set_country_flag=f_creating_leader
     create_leader = {
					type = governor
					species = last_created		
					name = "NAME_linxue"
					traits = {
						trait = leader_trait_architectural_interest
						trait = leader_trait_intellectual
						trait = leader_trait_linxue
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_linxue
			    set_leader_flag = f_npc		   
     }
     remove_country_flag = f_creating_leader
      #陈俊
      create_leader = {
					type = governor
					species = last_created		
					name = "NAME_chenjun"	
					traits = {
						trait = leader_trait_architectural_interest
						trait = leader_trait_intellectual
						trait = leader_trait_chenjun
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = no
					set_leader_flag = f_chenjun
			    set_leader_flag = f_npc		   
     }
     assign_leader = last_created_leader
      every_owned_leader = { 
	      limit = {
					leader_class = ruler
				}
				#change_species = last_created
	      #set_age = 20
	      remove_trait = trait_ruler_corvette_focus
	      remove_trait = trait_ruler_destroyer_focus
	      remove_trait = trait_ruler_fortifier
	      remove_trait = trait_ruler_battleship_focus
	      remove_trait = trait_ruler_recruiter
	      remove_trait = trait_ruler_military_pioneer
	      remove_trait = trait_ruler_warlike
	      remove_trait = trait_ruler_world_shaper
	      remove_trait =trait_ruler_home_in_the_sky
	      remove_trait =trait_ruler_industrialist
	      remove_trait =trait_ruler_champion_of_the_people
	      remove_trait=trait_ruler_expansionist
	      remove_trait=trait_ruler_fertility_preacher
	      remove_trait=trait_ruler_investor
	      remove_trait=trait_ruler_space_miner
	      remove_trait=trait_ruler_explorer
	      remove_trait=trait_ruler_eye_for_talent
	      add_trait =trait_ruler_cruiser_focus
	      add_trait =trait_ruler_logistic_understanding
	      add_trait =trait_ruler_architectural_sense
	      add_trait =trait_ruler_frontier_spirit
	      add_trait =trait_ruler_deep_connections
	      add_trait =trait_ruler_charismatic
	      add_trait =leader_trait_chenjun
	      set_leader_flag = f_chenjun
	      set_leader_flag = f_npc
	   }	
	   
	   #潘多拉
		 set_country_flag=f_creating_leader
     create_leader = {
					type = admiral
					species = owner_main_species				
					name = "NAME_panduola"
					traits = {
						trait = leader_trait_aggressive
					  trait = leader_trait_cautious 
					  trait = leader_trait_panduola
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_panduola
			    set_leader_flag = f_npc
     }
     remove_country_flag = f_creating_leader
     
     #西卡罗
     set_country_flag=f_creating_leader
     create_leader = {
					type = general
					species = owner_main_species					
					name = "NAME_xikaluo"
					traits = {
						trait = leader_trait_glory_seeker
					  trait = leader_trait_charismatic  
					  trait = leader_trait_xikaluo
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = no
					set_leader_flag = f_xikaluo
			    set_leader_flag = f_npc
     }
     remove_country_flag = f_creating_leader
     
     #西维斯
     set_country_flag=f_creating_leader
     create_leader = {
					type = admiral
					species = owner_main_species						
					name = "NAME_xiweisi"
					traits = {
						trait = leader_trait_aggressive
					  trait = leader_trait_cautious  
					  trait = leader_trait_xiweisi
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_xiweisi
			    set_leader_flag = f_npc
     }
     remove_country_flag = f_creating_leader
     
     #塔维尔
     set_country_flag=f_creating_leader
     create_leader = {
					type = scientist
					species = owner_main_species						
					name = "NAME_taweier"
					traits = {
						trait = leader_trait_sapient_AI_assistant
					  trait = leader_trait_scientist_chosen 
					  trait = leader_trait_taweier
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_taweier
			    set_leader_flag = f_npc		 
     }
     remove_country_flag = f_creating_leader
     
      #珊多拉
     set_country_flag=f_creating_leader
     create_leader = {
					type = governor
					species = owner_main_species						
					name = "NAME_shanduola"
					traits = {
						trait = leader_trait_architectural_interest
						trait = leader_trait_intellectual
						trait = leader_trait_shanduola
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_shanduola
			    set_leader_flag = f_npc
     }
     remove_country_flag = f_creating_leader
     
     #维斯卡
		 set_country_flag=f_creating_leader
     create_leader = {
					type = admiral
					species = owner_main_species		
					name = "NAME_weisika"
					traits = {
						trait = leader_trait_aggressive
					  trait = leader_trait_cautious 
					  trait = leader_trait_weisika
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_weisika
			    set_leader_flag = f_npc	   
     }
     remove_country_flag = f_creating_leader
     
     #阿赖耶
     set_country_flag=f_creating_leader
     create_leader = {
					type = scientist
					species = owner_main_species						
					name = "NAME_anaiye"
					traits = {
						trait = leader_trait_sapient_AI_assistant
					  trait = leader_trait_scientist_chosen 
					  trait = leader_trait_anaiye
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_anaiye
			    set_leader_flag = f_npc			     	   
     }
     remove_country_flag = f_creating_leader
     
     #泡泡
     set_country_flag=f_creating_leader
     create_leader = {
					type = scientist
					species = owner_main_species						
					name = "NAME_paopao"
					traits = {
						trait = leader_trait_sapient_AI_assistant
					  trait = leader_trait_scientist_chosen 
					  trait = leader_trait_paopao
					}
		 }
		 last_created_leader = {               
					set_age = 20
					set_is_female = yes
					set_leader_flag = f_paopao
			    set_leader_flag = f_npc
     }
     remove_country_flag = f_creating_leader
     ####  
  }
}

#更改初始种族特性，移除大陆宜居特性
country_event = {
  id = xilin.4
  hide_window = yes
  is_triggered_only = yes

  immediate = {
      #创建希灵使徒
  		create_species = {
  		  class = "XILIN_WORLD"
		    portrait = "xilin_apostle"
		    name = "PRESCRIPTED_species_name_xilin_apostle"
		    plural = "PRESCRIPTED_species_plural_xilin_apostle"
		    adjective = "PRESCRIPTED_species_adjective_xilin_apostle"
				traits = {
					trait = trait_magic_machine
				}
				new_pop_resource_requirement = {
#			    type = robot_food
			    value = 10.0  #基础值10，易生长
		    }
		    #pops_auto_growth = 1.0
		   
			}
			
			last_created_species = {
			  save_event_target_as = t_xilin_apostle_species
			}
      every_owned_leader ={
      		change_species = last_created
  		}
      capital_scope = {
           #清除障碍
      	   every_tile={
      				remove_blocker = yes
      	   }
      	   #移除所有人口的大陆适应特性
      		 every_owned_pop={
      		    change_species = last_created
      		 }
      
      }
      #奠基种族
     random_owned_pop = {
					root = { change_dominant_species = { species = prev } }
			}
  }
}

#初始随机部分人口吃电
country_event = {
  id = xilin.5
  hide_window = yes
  is_triggered_only = yes

  immediate = {
       every_owned_pop = {
          random_list = {
				    50 = { pop_event = { id = xilin_pop.1  } } 
				    50 = {   }
				    
			    }
       }
  }
}

