# No scope, like on_game_start
on_monthly_pulse = {
	events = {
#		guardian.10 #城邦与所在星系主人，每月+1点信任
#		unrest.162 #奴隶叛乱结局，当没有奴隶时，事件结束
#		unrest.164 #不满低于10，行星奴隶叛乱被安抚
#		syndaw.100 # servitor morale机仆侍奉度计算	
#		marauder.511 # Great Khan Dies
		#marauder.11 # Marauder infighting - commented out for now
#		crisis.120 # Feral Prethoryn
#		crisis.123 # Feral Prethoryn infighting
#		marauder.113
#		guardian.170
#		guardian.172
#		action.85 # flip planets to starbase owner
#		marauder.150 # AI hires Marauder raids
#		marauder.151 # AI hires Marauder mercs
#		action.90 # rebuild outpost for orphaned colonies
#		unrest.166	
		xilin_ai.1 #希灵帝国ai处理入口
		harmonious_planet.1 #星球和谐化处理
		harmonious_planet.13 #失去生命母树后，随机一棵生命树成为母树
		harmonious_planet.14 #种下生命树后非格式塔国家蜂群变为树灵
		harmonious_planet.29	#取消树灵保护法令后的处理
	}
}

# No scope, like on_game_start
on_yearly_pulse = {
	events = {
#		pirate.4 #创建海盗,可开局set_country_flag = birth_of_piracy来阻止本国海盗产生
#		crisis.204 # Spawn Infestors if less than 4 are available, on_yearly_pulse虫族殖民船增援
#		crisis.205 # Spawn Constructors if less than 4 are available, on_yearly_pulse 虫族工程船增援
#		crisis.208 # Destroy Swarm if no planets and only 5 or less ships remain 虫族灭亡
#		crisis.240 # Prethoryn army reinforcements 当虫族没有星球时，陆军援军	
#		crisis.1254 # Destroy EXDs if no portals and only 5 or less ships remain 恶魔灭亡
#		crisis.2080 #合成人恐怖行动
#		crisis.2310 #智械危机随机事件入口
#		action.64 # species assimilation各种类型同化
#		marauder.100
#		crisis.122
#		marauder.85
#		marauder.160
		harmonious_planet.10 #生命母树产种计数
	}
}

# No scope, like on_game_start
on_five_year_pulse = {
	events = {
#		crisis_trigger.1 #危机触发控制
		xilin_crisis_trigger.1 #本mod危机触发控制
	}
}

# Triggers when the game starts
on_game_start = {
	events = {
#		game_start.1  #4个初始事件，概率生产太阳系
#		game_start.2  #首都去除负面修正
#		game_start.3  #游戏帮助初始化
#		game_start.5  #设定游牧到来的时间
#		game_start.31
#希灵帝国初始化,event类型事件
    xilin.1    
	}
}

# Called during empire initialization when starting a new game if has_secondary_species game rule is true.
# Called before empire_init_create_capital_pops.
# scope: planet
# from: secondary species
empire_init_create_capital_secondary_pops = {
	events = {
		#game_start.11	# secondary species: assign trait_machine_unit, turn into robotics, then create pops
		# at this point the species might have changed (because we added traits), so FROM might not be the secondary species anymore
		harmonious_planet.16 #拥有和谐国是非蜂群国家的初始化
	}
}

# A pop has finished migrating to another planet
# Root = pop
# From = Tile on the new planet
# FromFrom = Tile on the old planet
on_pop_migration_end = {
	events = {
#		action.58  #移民buff
		xilin_pop.3 #移民进来，给予眷族身份
		xilin_pop.4 #移民出去，取消眷族身份
		harmonious_planet.24 #移民进来，检查非树灵人口是否达到2/3，树灵是否未达到1/3,若是则树灵保护，给行星加buff
    harmonious_planet.26 #人口移民出去，原行星非树灵人口未达2/3，则移除树灵保护法令buff
	}
}
# We changed a species right
# This = pop
on_pop_rights_change = {
	events = {
#		utopia.90 # remove withdrawal when blissed
#		utopia.91 # add withdrawal after bliss
		xilin_pop.2 #给获得居留权的凡物予以眷族身份
		xilin_pop.10 #给失去居留权的凡物移除眷族身份
		xilin_diplomacy.3 #给食人族打上邪恶国度标记
	}
}

# A pop has been born
# This = pop
#on_pop_birth = {
#	events = {
#	}
#}

# A pop has been built
# This = pop
#开始建机器人
on_buildable_pop_created = { 
	events = {
#		crisis.2055
#		crisis.2312
		harmonious_planet.31 #检查是否有树灵保护修正，有则停止建造
		harmonious_planet.24 #检查行星是否要添加树灵保护修正
	}
}

# A pop has become fully grown
# This = pop
on_pop_fully_grown = {
	events = {
#		action.66	  # Add new organic sanctuaries & remove unused ones添加新的有机庇护所-删除未使用的
		xilin_pop.2  #给获得居留权的凡物予以眷族身份	
    xilin_pop.7 #制造的使徒获得正确物种种类
    xilin_pop.8 #按政策决定的概率给使徒打上吃电标记
    xilin_diplomacy.2 #给罪恶国家的主体人口打上罪民标记
    harmonious_planet.24	#检查非树灵人口是否达到2/3，树灵是否未达到1/3,若是则树灵保护，给行星加buff
		harmonious_planet.25 #树灵人口达到1/3,移除树灵保护法令buff
	}
}

# A pop has been resettled to another planet
# Root = pop
# From = Tile on the old planet
on_pop_resettled = {
	events = {
#		action.67 #机仆，重新设置有机庇护所
    harmonious_planet.24 #迁移进来，检查非树灵人口是否达到2/3，树灵是否未达到1/3,若是则树灵保护，给行星加buff
    harmonious_planet.27 #人口安置出去，非树灵人口未达2/3，则移除树灵保护法令buff
	}
}


#Fired whenever a new owner is set for a planet,
#be it after a war or through a trade
#From = Country scope (new owner)
#This = Planet scope
on_planet_transfer = {
	events = {
#		action.42 #星球易主，拆掉帝国唯一建筑，若有政策的话腾出空间人口
#		apoc.202 # lose new holy world status		
		xilin_pop.5
		xilin_pop.6 #获得或失去眷族身份
		harmonious_planet.2 #非和谐国家获得和谐星球后，和谐星球崩溃
		harmonious_planet.15 #非和谐国家获得和谐星球后，生命树保护区被清除
		harmonious_planet.17 #和谐国家夺回和谐星球后，没有生命树，树灵继续处于灭绝状态
		harmonious_planet.18 #和谐星球被蜂群夺走，没有生命树则树灵失去树灵特质
		harmonious_planet.30  #生命树星球被不支持生命树国家夺走，一些特定修正被移除
		xilin_pop.11 ##获得星球，普通机器人，智能人转为希灵自律机械
		xilin_pop.12 #星球易主，使徒人口死亡，希灵使徒绝不屈服于任何势力
		xilin_pop.13 #希灵帝国获得星球，星球上的罪民死亡
	}
}

# Executes after a policy has been changed
# use last_changed_policy to identify which policy it was
# This = Country
on_policy_changed = {
	events = {
#		action.35 # Observation Posts set to Passive study when policy is downgraded to Passive
#		syndaw.1300 # banning AI can cause Uprising
#		syndaw.1305 # banning bot workers can cause Uprising
#		leader.30 # banning AI will remove AI-dependent traits from leaders
#		action.80 # banning AI will remove existing Synthetic Armies
		xilin_pop.9 #珊多拉食谱
	}
}

# A planet has been colonized.
# Scope = Planet
on_colonized = {
	events = {
#		crisis.203 #虫族殖民星球
#		anomaly.4171 #gas_rich_planet殖民
#		tutorial.27
#		tutorial.444 #Increase num_colonies variable
		#factions.105 # Colonialists New Colony
#		akx.9499 #时之虫殖民事件
		#action.55
		xilin_pop.5 #获得星球，居民获得眷族身份
	}
}

# A country has increased the level of a tech, use last_increased_tech trigger to check tech and level.
# This = Country
on_tech_increased = {
	events = {
#		tutorial.6
#		tutorial.64
#		tutorial.73
		#crisis.2190
#		anomaly.1191 #亡者永生事件
#		anomaly.1193 #亡者永生事件
    xilin_ascension_perk.1 #希灵的进化设计飞升
    xilin_ascension_perk.3 #希灵的掌控进化飞升
    xilin_ascension_perk.5 #希灵的血肉皮囊飞升
    xilin_ascension_perk.7 #希灵融合进化条件检测
    xilin_ascension_perk.71 #希灵融合进化飞升
    xilin_ascension_perk.9 #希灵心胜于物飞升
    xilin_ascension_perk.11 #希灵超凡入圣飞升
    xilin_diplomacy.13  #追随者(保护国)晋升追随者(附庸)
    harmonious_planet.20 #培育生命母树特别项目
	}
}

# This = owner of ship 1 (destroyed)
# From = owner of ship 2 (combatant)
# FromFrom = ship 1
# FromFromFrom = ship 2
on_ship_destroyed_victim = {
	events = {
#		syndaw.30   #机械帝国将领备份准备复活
#		mandate.143 #造船任务检查
#		nomad.95  #游牧受攻击，实力受损，改为回避状态
#		guardian.3002 #Horror Destroyed
#		guardian.3101 #无畏舰被打爆
#		guardian.592  #Curator（策展人） Destroyed 
#		guardian.140  #Trader Destroyed
#		crisis.1281  #空间锚被摧毁
#		crisis.1282 #恶魔被杀计数
#		crisis.217 #Prethoryn Kill Count
#		crisis.2070 #Contingency Kill Count(智械危机)
#		crisis.1012 # Portal Destroyed
#		crisis.1115 #Second Portal Destroyed
#		crisis.1215 #Third Portal Destroyed
#		marauder.4
#		marauder.505
#		marauder.509
#		crisis.80
#		marauder.525
		xilin_leader.1 #希灵领导人复活
	}
}

# Executed as a leader has died
# This = Country
# From = Leader
on_leader_death = {
	events = {
#		pretender.1 #国王死后，没有继承人
#		mandate.21 #领袖死后，任务失败
#		akx.9330  #命中注定相会，领袖死后处理
#		marauder.70
		xilin_leader.10 #希灵领导人复活
	}
}

# This = owner of fleet 1
# From = owner of fleet 2
# FromFrom = fleet 1
# FromFromFrom = fleet 2
on_entering_battle = {
	events = {
#		nomad.96 #游牧被打时的处理
#		nomad.98
#		nomad.99
#		guardian.330 #艺术家被打
#		guardian.155 #雪拉公司被打
#		guardian.158 #瑞根公司被打
#		guardian.161 #慕他刚公司被打
#		guardian.595 #策展人被打
    xilin_battle.1 #潘多拉战斗
    xilin_battle.6 #维斯卡战斗
	}
}

# This = Ship
# From = Disabler Ship
#打星堡则变换控制权后触发
on_ship_disabled = {
	events = {
#		country.201	#旗舰被玩家打败，登陆项目(兴趣点1)
#		country.212 #旗舰被玩家打败，登陆项目
#		country.217 #旗舰被玩家打败，登陆项目
#		country.222 #邪教徒旗舰被其他人打败
#		guardian.2100 #神秘堡垒被打瘫
		xilin_battle.11 #潘多拉回归
		xilin_battle.12 #维斯卡回归
	}
}


# This = owner of ship 1 (destroyed)
# From = owner of ship 2 (combatant)
# FromFrom = ship 1
# FromFromFrom = ship 2
#对星堡无效
#on_ship_disengaged_victim = {
#	events = {
#	}
#}



# This = owner of fleet 1 (winner)
# From = owner of fleet 2 (loser)
# FromFrom = fleet 1
# FromFromFrom = fleet 2
#该事件结束时任然处于战斗,对星堡无效(即打败星堡无法触发这个action)
#on_space_battle_won = {
#	events = {
#		#achievement.1	
#	}
#}

# This = owner of fleet 1 (loser)
# From = owner of fleet 2 (winner)
# FromFrom = fleet 1
# FromFromFrom = fleet 2
#该事件结束时任然处于战斗,对星堡无效(即打败星堡无效)
on_space_battle_lost = {
	events = {
		xilin_battle.2 #战斗结束，潘多拉回归
		xilin_battle.7 #战斗结束，维斯卡回归
	}
}

# This = owner of fleet 1 (destroyed)
# From = owner of fleet 2 (combatant)
# FromFrom = fleet 1
# FromFromFrom = fleet 2
#该事件结束时仍处于战斗状态,对星堡无效
#on_fleet_destroyed_victim = {
#	events = {
#		country.16
#		country.18
#		country.20
#		country.220
#		galactic_features.3
#		country.1021
#		country.1060
#		anomaly.3097
#		guardian.331
#		guardian.1072 #removes modifier if you have a station in orbit of pantagruel
#		guardian.3203
		#guardian.649
#		marauder.51
		#marauder.13 - Marauder infighting aftermath - commented out for now
#		crisis.108
#		crisis.125
#		marauder.115
		#xilin_battle.2 #战斗结束，潘多拉回归
		#xilin_battle.7 #战斗结束，维斯卡回归		
#	}
#}

# This = owner of fleet 1 (combatant)
# From = owner of fleet 2 (destroyed)
# FromFrom = fleet 1
# FromFromFrom = fleet 2
#on_fleet_destroyed_perp = {
#	events = {
#		country.9 # Probe Recovered Through Battle
#		country.11 # Subspace Anomaly Defeated
#		country.14 # Modified Probe Defeated
#		country.215 # Shipyard Destroyed宗教叛军?
#		country.216 # Cultist Ships Defeated
#		country.1020 # Probes destroyed击败无人机(流浪癖事件)
#		country.1043 #Pirates killed by player, porting to diplo击杀海盗，与科学家对话(流浪癖?)
#		colony.181 # Asteroid Destroyed
#		observation.5 # Asteroid Destroyed
#		story.109  # Amoeba kill-check for chain 1
#		#story.114
#		story.209 # Crystal kill-check for chain 1
#		story.309 # Drone kill-check for chain 1
#		story.311 #无人机奖励 击败无人机获50电
#		story.214 # Crystal kill-check for chain 2
#		story.216 # On-action check for destroyed crystal fleet水晶击杀奖励
#		story.332 # station destroyed 无人机矿站被摧毁
#		story.409 # Cloud kill-check for chain 1
#		anomaly.3101 #ransomeer_chain,pirates destroyed, 50/50 port to survival
#		anomaly.3120 #击败海盗基地
#		galactic_features.360 # If Void Cloud fleet destroys two fleets, a new Void Cloud is created
#		crisis.1111 # Extradimensionals Fight Each Other恶魔第一次内讧
#		crisis.70  # Swarm Kill Count
#		guardian.1009 # Stellarite behaviour - chase aggressor setup - from destroyed fleet嗜星者追杀
#		guardian.1012 # Stellarite behaviour - chase aggressor continuation from combat
#		guardian.1015 # Stellarite behavior - return home to feed
#		guardian.1032 #无限神机，战斗后恢复
#		guardian.1040 #无限神机被打爆
#		guardian.648 ## Dragon retaliates if hurt and fleet destroyed被龙灭
#		guardian.655 # On won battle but wounded, hibernate(龙残血,睡眠)
#		guardian.670 ## victorious admiral gains dragonslayer trait获得屠龙者特性
#		guardian.334 # You destroyed an artist station
#		guardian.2014 # Wraith killed
#		guardian.4 # guardian kill check利维坦被灭通知
#		pirate.25 # Destroyed Pirate Station摧毁海盗码头(开局)
#		pirate.13 ## perp port 摧毁海盗星系的船
#		akx.9318  #命中注定相会战斗结束
#		akx.10030 #击败时之虫
#		factions.330 ## Industrialist Recent Monster Extermination工业党要求清除怪物，打标记
#		factions.10 # Killed Guardian打标记
#		crisis.2472 ## Contingency Kill Count(ai危机)
#    xilin_battle.21 #战斗结束，潘多拉回归
#    xilin_battle.71 #战斗借宿，维斯卡回归
#	}
#	random_events = {
#		300 = 0
#		2 = leader.1 ## New Admiral战斗提拔新将领
#		2 = leader.5 # Trickster gained from Victory
#		2 = leader.6 # Aggressive gained from Victory
#		2 = leader.7 # Unyielding gained from Victory
#		2 = leader.8 # Gale Speed gained from Victory
#		2 = leader.9 # Lethargic lost from Victory
#		2 = leader.17 # Nervous lost from Victory
#	}
#}

# A fleet has successfully escaped from combat, executed right before the fleet enters FTL
# This = escaping fleet
# From = system escaped from
# FromFrom = system escaping to
on_emergency_ftl = {
	events = {
#		nomad.97 ### Nomads get attacked when weak and change fleet stance ###逃离，改为被动状态
#		guardian.1010
#		guardian.1013
#		guardian.1014
#		guardian.1020
#		guardian.1031
#		guardian.650
#		guardian.654
    xilin_battle.4 #逃脱战场，潘多拉回归
    xilin_battle.5 #对手逃走，潘多拉回归
    xilin_battle.9 #逃脱战场，维斯卡回归
    xilin_battle.10 #对手逃脱，维斯卡回归
	}
#	random_events = {
#		310 = 0
#		10 = leader.10
#		10 = leader.12
#		10 = leader.13
#		10 = leader.14
#		10 = leader.11		
#	}
}

# A fleet has entered a system
# Scope = Fleet
# From = System
on_entering_system_fleet = {
	events = {
#		action.40
#		country.211
#		country.1002
#		anomaly.3095
#		country.204
#		country.205
#		country.206
#		story.218
#		story.220
#		story.330
		#story.408
#		anomaly.3114
#		anomaly.3115
#		nomad.3
#		nomad.7
#		nomad.8
#		guardian.96
#		guardian.1005
#		pirate.10
#		guardian.610
#		guardian.1030
#		akx.9200
#		akx.9300
#		akx.9600
#		akx.9610
    xilin_battle.3 #若无战斗，潘多拉返航
    xilin_battle.8 #若无战斗，维斯卡返航
	}
#	random_events = {
#		99 = 0
#		1 = akx.9000 #时之虫百分一触发几率
#	}
}

# This = Planet scope
# From = Country
# FromFrom = Pop
on_purge_complete = {
	events = {
#		crisis.202  #当星球只剩1人时，行星变虫巢
#		crisis.2044  #ai危机，平民被屠杀只剩1个人口时星球归AI帝国所有
		# mandate.131
#		action.21 # Opinion effect on other empires其它帝国对种族灭绝的反应
#		utopia.180 # Gain resources for fanatic purifiers civic #种族灭绝获凝聚力
#		utopia.181 # Gain resources for devouring swarm
#		syndaw.1330 # Gain resources for exterminators
    xilin_diplomacy.1 #当有国家进行种族灭绝时，希灵帝国视其为罪恶国度，其国民为罪民。
	}
}

# This = country
# From = opponent war leader#指的是领导战争的国家
on_entering_war = {
	events = {
	  xilin_diplomacy.4 #与希灵战争，移除对希灵开放边境的flag
	}
}

# A war has been lost
# Root = Loser Warleader
# From = Winner Warleader
# FromFrom = War
on_war_lost = {
	events = {
#		action.38
#		fallen_empires.2  #堕落刺杀
#		fallen_empires.12 #堕落战败打战败flag
		xilin_diplomacy.14 #侮辱希灵帝国的，战败领袖被处决
	}
}

#A building construction has been completed. 
#只有第一次建时触发，拆掉重建不会触发这个action,会触发on_building_replaced
# This = Planet
# From = Tile
#on_building_complete = {
#	events = {
#		tutorial.14
#		tutorial.140
#		akx.10000 #欧米伽建成，召唤时之虫
#		harmonious_planet.5 #生命树种下后，变成保护区
#	}
#}

# A building construction has finished, replacing another building.
# This = Planet
# From = Tile
#on_building_replaced = {
#	events = {
#		colony.2020 #古怪工厂建筑被改建
#		guardian.305 #艺术纪念碑被改建，计数减一
#		akx.10000 #欧米伽建成，召唤时之虫
#		harmonious_planet.5 #生命树种下后，变成保护区
#	}
#}

# A tile building has been ruined
# This = Planet
# From = Tile
on_building_ruined = {
	events = {
		 harmonious_planet.12 #生命树与生命母树不能被毁坏
	}
}