#希灵帝国mod专用triggers


#国家是否允许星球和谐化
#scope:country
allow_harmonize = {
		OR = {
				has_valid_civic = civic_harmonious
				has_valid_civic = civic_harmonious_tree
				has_modifier = m_kala_gift
		} 
}
#国家是能够进行星球和谐化
#scope:country
can_harmonize ={
		OR = {
				#和谐蜂群国家获得理想家园传统
				AND = {
					has_valid_civic = civic_harmonious 
					has_swapped_tradition = tr_ideal_homeland
				}
				#非蜂群国家拥有和谐理念
				has_valid_civic = civic_harmonious_tree 
				#拥有卡拉的礼物的国家
				has_modifier = m_kala_gift
		}
}

#是否允许星球和谐化(有突触或生命树，且hive属性人口超过1/3,有和谐国是)
#scope:Planet
can_harmonize_planet = {
		OR = {
				has_building = building_life_tree	
				has_building = building_mother_life_tree  
				has_building = building_hive_synapse
		}
		harmonize_hive_is_enough =  yes	
}
#进行和谐化的蜂群是否足够
#scope:planet
harmonize_hive_is_enough = {
		OR = {
				AND = {
						planet_size < 6
						count_owned_pops = {
								count > 0
								limit = { has_trait = trait_hive_mind }						
						}
				}
				AND = {
						planet_size > 5
						planet_size < 9
						count_owned_pops = {
								count > 1
								limit = { has_trait = trait_hive_mind }						
						}
				}
				AND = {
						planet_size > 8
						planet_size < 12
						count_owned_pops = {
								count > 2
								limit = { has_trait = trait_hive_mind }						
						}
				}
				AND = {
						planet_size > 11
						planet_size < 15
						count_owned_pops = {
								count > 3
								limit = { has_trait = trait_hive_mind }						
						}
				}
				AND = {
						planet_size > 14
						planet_size < 18
						count_owned_pops = {
								count > 4
								limit = { has_trait = trait_hive_mind }						
						}
				}
				AND = {
						planet_size > 17
						planet_size < 21
						count_owned_pops = {
								count > 5
								limit = { has_trait = trait_hive_mind }						
						}
				}
				AND = {
						planet_size > 20
						planet_size < 24
						count_owned_pops = {
								count > 6
								limit = { has_trait = trait_hive_mind }						
						}
				}
				AND = {
						planet_size > 23
						count_owned_pops = {
								count > 7
								limit = { has_trait = trait_hive_mind }						
						}
				}
		}	
}

#判断生长完成的蜂群数量是否足够
#scope:planet
grown_harmonize_hive_is_enough = {
		OR = {
				AND = {
						planet_size < 6
						count_owned_pops = {
								count > 0
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
				AND = {
						planet_size > 5
						planet_size < 9
						count_owned_pops = {
								count > 1
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
				AND = {
						planet_size > 8
						planet_size < 12
						count_owned_pops = {
								count > 2
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
				AND = {
						planet_size > 11
						planet_size < 15
						count_owned_pops = {
								count > 3
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
				AND = {
						planet_size > 14
						planet_size < 18
						count_owned_pops = {
								count > 4
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
				AND = {
						planet_size > 17
						planet_size < 21
						count_owned_pops = {
								count > 5
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
				AND = {
						planet_size > 20
						planet_size < 24
						count_owned_pops = {
								count > 6
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
				AND = {
						planet_size > 23
						count_owned_pops = {
								count > 7
								limit = { has_trait = trait_hive_mind  is_growing = no }						
						}
				}
		}	
}

#树灵是否太多需要净化
#scope:Planet
tree_spirit_enough_num_to_purge = {
		OR = {
				has_building = building_life_tree	  
				has_building = building_mother_life_tree
		}
		OR = {
				AND = {
						planet_size < 6
						count_owned_pops = {
								count > 1
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
				AND = {
						planet_size > 5
						planet_size < 9
						count_owned_pops = {
								count > 2
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
				AND = {
						planet_size > 8
						planet_size < 12
						count_owned_pops = {
								count > 3
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
				AND = {
						planet_size > 11
						planet_size < 15
						count_owned_pops = {
								count > 4
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
				AND = {
						planet_size > 14
						planet_size < 18
						count_owned_pops = {
								count > 5
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
				AND = {
						planet_size > 17
						planet_size < 21
						count_owned_pops = {
								count > 6
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
				AND = {
						planet_size > 20
						planet_size < 24
						count_owned_pops = {
								count > 7
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
				AND = {
						planet_size > 23
						count_owned_pops = {
								count > 8
								limit = { has_trait = trait_hive_mind  is_being_purged = no }						
						}
				}
		}		
}

#判断政体是否允许生命树成长为母树
#scope:country
allow_grow_up_to_mother_life_tree = {
		OR = {
				has_valid_civic = civic_harmonious_tree				
				has_modifier = m_kala_gift
		} 
}

#判断是否可以种植生命树种
#SCOPE:PLANET
can_build_life_tree_seed = {
		OR = {
		    #1-5需1个空位
				AND = {
						planet_size = 1
						count_owned_pops = {
								count < 1
								limit = { NOT = {	has_trait = trait_hive_mind }	}
						}
				}
				AND = {
						planet_size = 2
						count_owned_pops = {
								count < 2
								limit = { NOT = {	has_trait = trait_hive_mind }	}	
						}
				}
				AND = {
						planet_size = 3
						count_owned_pops = {
								count < 3
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 4
						count_owned_pops = {
								count < 4
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 5
						count_owned_pops = {
								count < 5
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				#6-8需2个空位
				AND = {
						planet_size = 6
						count_owned_pops = {
								count < 5
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 7
						count_owned_pops = {
								count < 6
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 8
						count_owned_pops= {
								count < 7
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				#9-11需3个空位
				AND = {
						planet_size = 9
						count_owned_pops = {
								count < 7
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 10
						count_owned_pops = {
								count < 8
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 11
						count_owned_pops = {
								count < 9
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				#12-14需4个空位
				AND = {
						planet_size = 12
						count_owned_pops = {
								count < 9
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 13
						count_owned_pops = {
								count < 10
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 14
						count_owned_pops = {
								count < 11
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				#15-17需5个空位
				AND = {
						planet_size = 15
						count_owned_pops = {
								count < 11
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 16
						count_owned_pops = {
								count < 12
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 17
						count_owned_pops = {
								count < 13
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				#18-20需6个空位
				AND = {
						planet_size = 18
						count_owned_pops = {
								count < 13
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 19
						count_owned_pops = {
								count < 14
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 20
						count_owned_pops = {
								count < 15
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				#21-23需7个空位
				AND = {
						planet_size = 21
						count_owned_pops = {
								count < 15
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 22
						count_owned_pops = {
								count < 16
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 23
						count_owned_pops = {
								count < 17
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				#24-25需8个空位
				AND = {
						planet_size = 24
						count_owned_pops = {
								count < 17
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
				AND = {
						planet_size = 25
						count_owned_pops = {
								count < 18
								limit = { NOT = {	has_trait = trait_hive_mind }	}					
						}
				}
		}	
}

#判断树灵保护条例下，是否还能增长人口
#SCOPE:PLANET
can_grow_no_affect_tree_spirit = {
		OR = {
		    #1-5需1个空位
				AND = {
						planet_size = 1
						count_owned_pops = {
								count < 0
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}
						}
				}
				AND = {
						planet_size = 2
						count_owned_pops = {
								count < 1
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}
						}
				}
				AND = {
						planet_size = 3
						count_owned_pops = {
								count < 2
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}			
						}
				}
				AND = {
						planet_size = 4
						count_owned_pops = {
								count < 3
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 5
						count_owned_pops = {
								count < 4
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				#6-8需2个空位
				AND = {
						planet_size = 6
						count_owned_pops = {
								count < 4
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 7
						count_owned_pops = {
								count < 5
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 8
						count_owned_pops= {
								count < 6
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				#9-11需3个空位
				AND = {
						planet_size = 9
						count_owned_pops = {
								count < 6
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 10
						count_owned_pops = {
								count < 7
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 11
						count_owned_pops = {
								count < 8
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				#12-14需4个空位
				AND = {
						planet_size = 12
						count_owned_pops = {
								count < 8
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 13
						count_owned_pops = {
								count < 9
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}					
						}
				}
				AND = {
						planet_size = 14
						count_owned_pops = {
								count < 10
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}					
						}
				}
				#15-17需5个空位
				AND = {
						planet_size = 15
						count_owned_pops = {
								count < 10
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 16
						count_owned_pops = {
								count < 11
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 17
						count_owned_pops = {
								count < 12
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				#18-20需6个空位
				AND = {
						planet_size = 18
						count_owned_pops = {
								count < 12
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}					
						}
				}
				AND = {
						planet_size = 19
						count_owned_pops = {
								count < 13
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 20
						count_owned_pops = {
								count < 14
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				#21-23需7个空位
				AND = {
						planet_size = 21
						count_owned_pops = {
								count < 14
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 22
						count_owned_pops = {
								count < 15
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}			
						}
				}
				AND = {
						planet_size = 23
						count_owned_pops = {
								count < 16
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}					
						}
				}
				#24-25需8个空位
				AND = {
						planet_size = 24
						count_owned_pops = {
								count < 16
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}				
						}
				}
				AND = {
						planet_size = 25
						count_owned_pops = {
								count < 17
								limit = { 
										NOT = {	has_trait = trait_hive_mind }	 
										OR = {
										   is_growing = no
										   has_trait = trait_mechanical
										} 
								}			
						}
				}
		}	
}

#判断行星是否有生命树
#scope:Planet
has_life_tree = {
		OR = {
				has_building = building_life_tree	
				has_building = building_mother_life_tree  
				has_blocker =  tb_growing_life_tree 
		}
}

#判断树灵保护条例下，是否还能增长人口
#scope:Planet
#can_grow_no_affect_tree_spirit = {
#    OR = {
#    		harmonize_hive_is_enough =  yes	
#    		can_build_life_tree_seed = yes
#    }
#}

#判断是否有负面行星moddifier
#scope:planet
has_neg_planet_modifier = {
		OR = {
				has_modifier = bleak_planet
				has_modifier = mineral_poor
				has_modifier = weak_magnetic_field
				has_modifier = high_gravity
		}
}

#判断是否曾经有过负面特性
#scope:planet
has_ever_neg_planet_modifier = {
		OR = {
				has_planet_flag = f_ever_bleak_planet
				has_planet_flag = f_ever_mineral_poor 
				has_planet_flag = f_ever_weak_magnetic_field
				has_planet_flag = f_ever_high_gravity	
		}
}

#判断是否有可升华的行星特性
#scope:planet
has_sublimable_planet_modifier = {
		OR = {
				#不稳定的构造
				has_modifier = unstable_tectonics
				#不能自转
				has_modifier = tidal_locked 
				#暴风雨
				has_modifier = wild_storms
				#危险的气候
				has_modifier = hazardous_weather 
				#危险的野生生物
				has_modifier = dangerous_wildlife
				#陨石撞击
				has_modifier = asteroid_impacts
		}
}

#判断行星是否升华过
#scope:planet
is_planet_sublimed = {
		OR = {
				#地质公园
				has_modifier = m_geological_parks
				#永恒的黄昏
				has_modifier = m_everlasting_dusk
				#雨之都
				has_modifier = m_paradise_of_rain
				#驯服的气候
				has_modifier = m_tamed_weather
				#灵兽
				has_modifier = m_intelligent_friendly_wildlife
				#许愿圣地
				has_modifier = m_holy_place_to_make_wish
		}
}

#判断是否允许建造机器人，而不影响树灵保护
#scope:country
harmony_allow_build_robot_pop = {	 
	 OR = {
	    #没有生命之树公民性或卡拉的礼物
	    allow_grow_up_to_mother_life_tree = no
	 		#是ai,且有行星有树灵保护修正
	 		AND = {
	 				is_ai =  yes
	 				NOT = { any_owned_planet = { has_modifier = m_protect_tree_spirit	} }
	 		}
	 		#不是ai,星区没有行星有树灵保护修正
	 		AND = {
	 				is_ai = no
	 				NOT = { any_owned_planet = {
	 						has_modifier = m_protect_tree_spirit
	 						sector_controlled = yes
	 				} }
	 		}
	 }
}
