######################################
# Astral Rifts Events - 3000 to 3200 #
######################################

##########################################
# Astral Rift - Siege On Paradise Events #
##########################################

namespace = astral_rift

astral_rift_event = {
	id = astral_rift.3000
	title = astral_rift.3000.name
	desc = astral_rift.3000.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_initial_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3000.a
		trigger = {
			explorer = {
				OR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3005 }

		ai_chance = {
			modifier = {
				factor = 0
				explorer = {
					OR = {
						is_xenophobe = yes
						is_militarist = yes
						is_unfriendly = yes
					}
				}
			}
		}
	}

	option = {
		name = astral_rift.3000.a
		trigger = {
			explorer = {
				NOR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3006 }

		ai_chance = {
			modifier = {
				factor = 0
				explorer = {
					OR = {
						is_xenophobe = yes
						is_militarist = yes
						is_unfriendly = yes
					}
				}
			}
		}
	}

	option = {
		name = astral_rift.3000.b
		set_next_astral_rift_event = { id = astral_rift.3050 }

		ai_chance = {
			modifier = {
				factor = 0
				explorer = {
					is_xenophobe = no
					is_militarist = no
					is_unfriendly = no
				}
			}
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

######################
# Baol Events Branch #
######################

astral_rift_event = {
	id = astral_rift.3005
	title = astral_rift.3005.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_plantoid = {
					if = {
						limit = {
							explorer = {
								has_event_chain = baol_chain
							}
						}
						text = astral_rift.3005.desc.baol_started_plantoid
					}
					else = {
						text = astral_rift.3005.desc.baol_completed_plantoid
					}
				}
				default = {
					if = {
						limit = {
							explorer = {
								has_event_chain = baol_chain
							}
						}
						text = astral_rift.3005.desc.baol_started_default
					}
					else = {
						text = astral_rift.3005.desc.baol_completed_default
					}
				}
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3005.a
		explorer = {
			astral_thread_small_reward = yes
		}
		set_next_astral_rift_event = { id = astral_rift.3010 }
	}
}

astral_rift_event = {
	id = astral_rift.3006
	title = astral_rift.3006.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_plantoid = { text = astral_rift.3006.desc.plantoid }
				default = { text = astral_rift.3006.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3006.a
		explorer = {
			astral_thread_small_reward = yes
		}
		set_next_astral_rift_event = { id = astral_rift.3015 }
	}
}

astral_rift_event = {
	id = astral_rift.3010
	title = astral_rift.3010.name
	desc = {
		trigger = {
			if = {
				limit = {
					explorer = {
						has_event_chain = baol_chain
					}
				}
				text = astral_rift.3010.desc.baol_started
			}
			else = {
				text = astral_rift.3010.desc.baol_completed
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3010.a
		set_next_astral_rift_event = { id = astral_rift.3020 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
			modifier = {
				add = 100
				explorer = {
					is_xenophile = yes
				}
			}
		}
	}

	option = {
		name = astral_rift.3010.b
		set_next_astral_rift_event = { id = astral_rift.3025 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3015
	title = astral_rift.3015.name
	desc = astral_rift.3015.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3015.a
		set_next_astral_rift_event = { id = astral_rift.3021 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
			modifier = {
				add = 100
				explorer = {
					is_xenophile = yes
				}
			}
		}
	}

	option = {
		name = astral_rift.3015.b
		set_next_astral_rift_event = { id = astral_rift.3025 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3020
	title = astral_rift.3020.name
	desc = {
		trigger = {
			if = {
				limit = {
					explorer = {
						has_event_chain = baol_chain
					}
				}
				text = astral_rift.3020.desc.baol_started
			}
			else = {
				text = astral_rift.3020.desc.baol_completed
			}
			text = astral_rift.3020.desc.common.1
			if = {
				limit = {
					explorer = {
						has_technology = tech_gene_tailoring
					}
				}
				text = astral_rift.3020.desc.option_gene_tailoring
			}
			if = {
				limit = {
					explorer = {
						has_technology = tech_cloaking_1
					}
				}
				text = astral_rift.3020.desc.option_cloaking
			}
			if = {
				limit = {
					explorer = {
						NAND = {
							has_technology = tech_gene_tailoring
							has_technology = tech_cloaking_1
						}
					}
				}
				text = astral_rift.3020.desc.option_astral_shield
			}
			text = astral_rift.3020.desc.common.2
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3020.a
		trigger = {
			explorer = {
				has_technology = tech_gene_tailoring
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3030 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3020.b
		trigger = {
			explorer = {
				has_technology = tech_cloaking_1
			}
		}
		allow = {
			explorer = {
				has_resource = { type = astral_threads amount >= 50 }
			}
		}
		explorer = {
			add_resource = { astral_threads = -50 }
		}
		set_next_astral_rift_event = { id = astral_rift.3035 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3020.c
		set_next_astral_rift_event = { id = astral_rift.3040 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3020.d
		trigger = {
			explorer = {
				NAND = {
					has_technology = tech_gene_tailoring
					has_technology = tech_cloaking_1
				}
			}
		}
		allow = {
			explorer = {
				has_resource = { type = astral_threads amount >= 100 }
			}
		}
		explorer = {
			add_resource = { astral_threads = -100 }
		}
		set_next_astral_rift_event = { id = astral_rift.3049 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3021
	title = astral_rift.3021.name
	desc = {
		trigger = {
			text = astral_rift.3021.desc.common
			if = {
				limit = {
					explorer = {
						has_technology = tech_gene_tailoring
					}
				}
				text = astral_rift.3020.desc.option_gene_tailoring
			}
			if = {
				limit = {
					explorer = {
						has_technology = tech_cloaking_1
					}
				}
				text = astral_rift.3020.desc.option_cloaking
			}
			if = {
				limit = {
					explorer = {
						NAND = {
							has_technology = tech_gene_tailoring
							has_technology = tech_cloaking_1
						}
					}
				}
				text = astral_rift.3020.desc.option_astral_shield
			}
			text = astral_rift.3020.desc.common.2
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3020.a
		trigger = {
			explorer = {
				has_technology = tech_gene_tailoring
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3030 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3020.b
		trigger = {
			explorer = {
				has_technology = tech_cloaking_1
			}
		}
		allow = {
			explorer = {
				has_resource = { type = astral_threads amount >= 50 }
			}
		}
		explorer = {
			add_resource = { astral_threads = -50 }
		}
		set_next_astral_rift_event = { id = astral_rift.3035 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3020.c
		set_next_astral_rift_event = { id = astral_rift.3040 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3020.d
		trigger = {
			explorer = {
				NAND = {
					has_technology = tech_gene_tailoring
					has_technology = tech_cloaking_1
				}
			}
		}
		allow = {
			explorer = {
				has_resource = { type = astral_threads amount >= 100 }
			}
		}
		explorer = {
			add_resource = { astral_threads = -100 }
		}
		set_next_astral_rift_event = { id = astral_rift.3049 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3025
	title = astral_rift.3025.name
	desc = astral_rift.3025.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3025.a
		trigger = {
			explorer = {
				OR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3045 }
	}

	option = {
		name = astral_rift.3025.a
		trigger = {
			explorer = {
				NOR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3046 }
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3030
	title = astral_rift.3030.name
	desc = astral_rift.3030.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_hard_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		explorer = {
			astral_thread_large_reward = yes
			country_event = { id = astral_rift.3031 }
		}
		finish_astral_rift = yes
	}
}

country_event = {
	id = astral_rift.3031
	title = astral_rift.3031.name
	desc = astral_rift.3031.desc
	show_sound = event_custodian_greeting
	is_triggered_only = yes

	picture = GFX_leader_recruitment_bg_renowned
	event_window_type = leader_recruit
	notification_event_icon = "GFX_message_leader_recruitment_lysator"

	immediate = {
		ethic_leader_creator = {
			SPECIES_CLASS = PLANT
			LEADER_PORTRAIT = pla16_baol
			CLASS = commander
			TIER = leader_tier_renowned
			NAME = NAME_Baol_leader
			LEVEL = 5
			GENDER = indeterminable
			IMMORTAL = yes
			ETHIC = gestalt_consciousness
			DESC = baol_leader_desc
			CATCH_PHRASE = baol_leader_catch_phrase
		}
		last_created_leader = {
			add_trait = {
				trait = leader_trait_taskmaster
				consume_selection = yes
			}
			add_trait = {
				trait = subclass_commander_general
				consume_selection = yes
			}
			add_trait = {
				trait = leader_trait_homesteader
				consume_selection = yes
			}
			add_trait = {
				trait = leader_trait_reinforcer_2
				consume_selection = yes
			}
		}
	}

	picture_event_data = {
		portrait = event_target:ethic_leader
		room = ethic_spaceship_room
	}

	option = {
		name = astral_rift.3031.a
		response_text = astral_rift.3031.a.response
		is_dialog_only = yes
	}
	option = {
		name = astral_rift.3031.b
		response_text = astral_rift.3031.b.response
		is_dialog_only = yes
	}
	option = {
		name = astral_rift.3031.c
		response_text = astral_rift.3031.c.response
		is_dialog_only = yes
	}
	option = {
		name = astral_rift.3031.d
		response_text = astral_rift.3031.d.response
		is_dialog_only = yes
	}
	option = {
		name = HIRE
		tag = hire_leader
		hire_event_leader_effect = {
			LEADER = ethic_leader
		}
	}
	option = {
		name = DISMISS
		tag = dismiss_leader
		hidden_effect = {
			ethic_leader_kill_effect = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3035
	title = astral_rift.3035.name
	desc = astral_rift.3035.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_hard_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3035.a
		explorer = {
			astral_thread_large_reward = yes
			custom_tooltip = astral_cloaking_available_tt
			hidden_effect = {
				set_country_flag = astral_cloaking_available
			}
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3040
	title = astral_rift.3040.name
	desc = {
		trigger = {
			if = {
				limit = {
					explorer = {
						has_event_chain = baol_chain
					}
				}
				text = astral_rift.3040.desc.baol_started
			}
			else_if = {
				limit = {
					explorer = {
						has_completed_event_chain = baol_chain
					}
				}
				text = astral_rift.3040.desc.baol_completed
			}
			else = {
				text = astral_rift.3040.desc.default
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_difficulty
	astral_rift = yes

	is_triggered_only = yes

	immediate = {
		solar_system = {
			find_closest_player_planet_local = {
				OWNER_SCOPE = root.explorer
				EVENT_TARGET = closest_planet_found_local
			}
		}
		if = {
			limit = {
				explorer = {
					is_gestalt = yes
				}
			}
			create_hive_baol_species_effect = {
				SPECIES_NAME = "NAME_Baol"
				GLOBAL_TARGET = astral_rift_baol_species
			}
		}
		else = {
			create_baol_species_effect = {
				SPECIES_NAME = "NAME_Baol"
				GLOBAL_TARGET = astral_rift_baol_species
			}
		}
		event_target:astral_rift_baol_species = {
			save_event_target_as = astral_rift_baol_species_local
		}
		clear_global_event_target = astral_rift_baol_species
	}

	option = {
		name = EXCELLENT
		explorer = {
			astral_thread_large_reward = yes
		}
		event_target:closest_planet_found_local = {
			create_pop_group = {
				size = 300
				species = event_target:astral_rift_baol_species_local
				ethos = {
					ethic = ethic_pacifist
				}
			}
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3045
	title = astral_rift.3045.name
	desc = astral_rift.3045.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3045.a
		add_deposit = d_society_25
		hidden_effect = {
			explorer = {
				country_event = {
					id = astral_rift.3047
					days = 720
					random = 720
				}
			}
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3046
	title = astral_rift.3046.name
	desc = astral_rift.3046.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3046.a
		add_deposit = d_society_25
		hidden_effect = {
			explorer = {
				country_event = {
					id = astral_rift.3047
					days = 720
					random = 720
				}
			}
		}
		finish_astral_rift = yes
	}
}

country_event = {
	id = astral_rift.3047
	title = astral_rift.3047.name
	desc = astral_rift.3047.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol

	is_triggered_only = yes

	option = {
		name = UNFORTUNATE
		from = {
			remove_deposit = d_society_25
		}
		add_monthly_resource_mult = {
			resource = society_research
			value = @tier4researchreward
			min = @tier4researchmin
			max = @tier4researchmax
		}
		add_monthly_resource_mult = {
			resource = engineering_research
			value = @tier4researchreward
			min = @tier4researchmin
			max = @tier4researchmax
		}
	}
}

astral_rift_event = {
	id = astral_rift.3049
	title = astral_rift.3049.name
	desc = astral_rift.3049.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_baol
	show_sound = ap_rift_event_30_sentient_trees_planet
	difficulty = @astral_rift_medium_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3049.a
		explorer = {
			astral_thread_large_reward = yes
			add_modifier = { modifier = astral_shield_experimentation }
		}
		finish_astral_rift = yes
	}
}

########################
# Grunur Events Branch #
########################

astral_rift_event = {
	id = astral_rift.3050
	title = astral_rift.3050.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_baol_chain = { text = astral_rift.3050.desc.baol }
				default = { text = astral_rift.3050.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3050.a
		trigger = {
			explorer = {
				OR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3055 }
	}
	option = {
		name = astral_rift.3050.b
		trigger = {
			explorer = {
				NOR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3055 }
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3055
	title = astral_rift.3055.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_robotic = { text = astral_rift.3055.desc.mechanical }
				description_organic = { text = astral_rift.3055.desc.organic }
				description_lithoid = { text = astral_rift.3055.desc.lithoid }
				default = { text = astral_rift.3055.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3055.a
		trigger = {
			explorer = {
				OR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		explorer = {
			switch = {
				trigger = has_technology
				tech_dragon_armor = { prev = { set_astral_rift_flag = picked_tech_dragon_armor } }
				tech_crystal_armor_2 = { prev = { set_astral_rift_flag = picked_tech_crystal_armor_2 } }
				tech_dark_matter_propulsion = { prev = { set_astral_rift_flag = picked_tech_dark_matter_propulsion } }
				tech_nanite_repair_system = { prev = { set_astral_rift_flag = picked_tech_nanite_repair_system } }
				tech_nanite_autocannon = { prev = { set_astral_rift_flag = picked_tech_nanite_autocannon } }
				tech_nanite_flak_batteries = { prev = { set_astral_rift_flag = picked_tech_nanite_flak_batteries } }
				tech_strike_craft_skrand = { prev = { set_astral_rift_flag = picked_tech_strike_craft_skrand } }
				tech_combat_computers_3 = { prev = { set_astral_rift_flag = picked_tech_combat_computers_3 } }
				tech_combat_computers_autonomous = { prev = { set_astral_rift_flag = picked_tech_combat_computers_autonomous } }
				tech_dark_matter_power_core = { prev = { set_astral_rift_flag = picked_tech_dark_matter_power_core } }
				tech_jump_drive_1 = { prev = { set_astral_rift_flag = picked_tech_jump_drive_1 } }
				tech_extradimensional_weapon_1 = { prev = { set_astral_rift_flag = picked_tech_extradimensional_weapon_1 } }
				tech_quantum_catapult = { prev = { set_astral_rift_flag = picked_tech_quantum_catapult } }
				tech_scourge_missile_1 = { prev = { set_astral_rift_flag = picked_tech_scourge_missile_1 } }
				tech_swarm_strike_craft_1 = { prev = { set_astral_rift_flag = picked_tech_swarm_strike_craft_1 } }
				tech_precognition_interface = { prev = { set_astral_rift_flag = picked_tech_precognition_interface } }
				tech_psi_jump_drive_1 = { prev = { set_astral_rift_flag = picked_tech_psi_jump_drive_1 } }
				tech_psionic_barrier = { prev = { set_astral_rift_flag = picked_tech_psionic_barrier } }
				tech_psionic_shield = { prev = { set_astral_rift_flag = picked_tech_psionic_shield } }
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3060 }
	}
	option = {
		name = astral_rift.3055.b
		trigger = {
			explorer = {
				NOR = {
					has_event_chain = baol_chain
					has_completed_event_chain = baol_chain
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3065 }
	}

	after = {
		explorer = {
			if = {
				limit = {
					is_robot_empire = no
					is_gestalt = no
				}
				add_resource = { unity = -50 }
			}
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3060
	title = astral_rift.3060.name
	desc = astral_rift.3060.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes

	is_triggered_only = yes

	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_dragon_armor
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_crystal_armor_2
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_dark_matter_propulsion
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_nanite_repair_system
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_nanite_autocannon
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_nanite_flak_batteries
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_strike_craft_skrand
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_combat_computers_3
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_combat_computers_autonomous
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_dark_matter_power_core
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_jump_drive_1
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_extradimensional_weapon_1
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_quantum_catapult
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_scourge_missile_1
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_swarm_strike_craft_1
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_precognition_interface
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_psi_jump_drive_1
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_psionic_barrier
	}
	inline_script = {
		script = astral_rift/3060_tech_option
		TECH = tech_psionic_shield
	}
	option = {
		name = astral_rift.3060.b
		set_next_astral_rift_event = { id = astral_rift.3075 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}
	option = {
		name = astral_rift.3060.c
		hidden_effect = {
			add_stage_modifier = { modifier = astral_rift_difficulty_increase_1 }
		}
		set_next_astral_rift_event = { id = astral_rift.3095 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3065
	title = astral_rift.3065.name
	desc = astral_rift.3065.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3065.a
		set_next_astral_rift_event = { id = astral_rift.3076 }
	}
	option = {
		name = astral_rift.3065.b
		set_next_astral_rift_event = { id = astral_rift.3080 }

		ai_chance = {
			base = 0
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3070
	title = astral_rift.3070.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				picked_tech_dragon_armor = { text = astral_rift.3070.desc.tech_dragon_armor }
				picked_tech_crystal_armor_2 = { text = astral_rift.3070.desc.tech_crystal_armor_2 }
				picked_tech_dark_matter_propulsion = { text = astral_rift.3070.desc.tech_dark_matter_propulsion }
				picked_tech_nanite_repair_system = { text = astral_rift.3070.desc.tech_nanite_repair_system }
				picked_tech_nanite_autocannon = { text = astral_rift.3070.desc.tech_nanite_autocannon }
				picked_tech_nanite_flak_batteries = { text = astral_rift.3070.desc.tech_nanite_flak_batteries }
				picked_tech_strike_craft_skrand = { text = astral_rift.3070.desc.tech_strike_craft_skrand }
				picked_tech_combat_computers_3 = { text = astral_rift.3070.desc.tech_combat_computers_3 }
				picked_tech_combat_computers_autonomous = { text = astral_rift.3070.desc.tech_combat_computers_autonomous }
				picked_tech_dark_matter_power_core = { text = astral_rift.3070.desc.tech_dark_matter_power_core }
				picked_tech_jump_drive_1 = { text = astral_rift.3070.desc.tech_jump_drive_1 }
				picked_tech_extradimensional_weapon_1 = { text = astral_rift.3070.desc.tech_extradimensional_weapon_1 }
				picked_tech_quantum_catapult = { text = astral_rift.3070.desc.tech_quantum_catapult }
				picked_tech_scourge_missile_1 = { text = astral_rift.3070.desc.tech_scourge_missile_1 }
				picked_tech_swarm_strike_craft_1 = { text = astral_rift.3070.desc.tech_swarm_strike_craft_1 }
				picked_tech_precognition_interface = { text = astral_rift.3070.desc.tech_precognition_interface }
				picked_tech_psi_jump_drive_1 = { text = astral_rift.3070.desc.tech_psi_jump_drive_1 }
				picked_tech_psionic_barrier = { text = astral_rift.3070.desc.tech_psionic_barrier }
				picked_tech_psionic_shield = { text = astral_rift.3070.desc.tech_psionic_shield }
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_hard_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3070.a
		explorer = {
			astral_thread_small_reward = yes
			add_random_research_option = {
				add_progress = 0.25
				category = military_theory
				fail_effects = {
					add_monthly_resource_mult = {
						resource = society_research
						value = @tier3researchreward
						min = @tier3researchmin
						max = @tier3researchmax
					}
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3085 }
	}
}

astral_rift_event = {
	id = astral_rift.3075
	title = astral_rift.3075.name
	desc = astral_rift.3075.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_medium_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3075.a
		set_next_astral_rift_event = { id = astral_rift.3090 }
	}
	option = {
		name = astral_rift.3075.b
		set_next_astral_rift_event = { id = astral_rift.3095 }

		ai_chance = {
			base = 0
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3076
	title = astral_rift.3076.name
	desc = astral_rift.3076.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3076.a
		set_next_astral_rift_event = { id = astral_rift.3090 }
	}
	option = {
		name = astral_rift.3076.b
		set_next_astral_rift_event = { id = astral_rift.3095 }

		ai_chance = {
			base = 0
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3080
	title = astral_rift.3080.name
	desc = {
		trigger = {
			hidden_trigger = {
				has_astral_rift_flag = description_organic
				NOR = {
					has_astral_rift_flag = description_gestalt
					has_astral_rift_flag = description_exterminator
				}
			}
			text = astral_rift.3080.desc.organic
		}
	}
	desc = {
		trigger = {
			hidden_trigger = {
				OR = {
					NOT = { has_astral_rift_flag = description_organic }
					has_astral_rift_flag = description_gestalt
					has_astral_rift_flag = description_exterminator
				}
			}
			text = astral_rift.3080.desc.default
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = astral_rift.3080.a
		explorer = {
			astral_thread_small_reward = yes
		}
		hidden_effect = {
			add_stage_modifier = { modifier = astral_rift_difficulty_increase_1 }
		}
		set_next_astral_rift_event = { id = astral_rift.3095 }
	}
}

astral_rift_event = {
	id = astral_rift.3085
	title = astral_rift.3085.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_pacifist = { text = astral_rift.3085.desc.pacifist }
				description_militarist = {
					switch = {
						trigger = has_astral_rift_flag
						description_exterminator = { text = astral_rift.3085.desc.homicidal_militarist }
						default = { text = astral_rift.3085.desc.militarist }
					}
				}
				description_exterminator = {
					switch = {
						trigger = has_astral_rift_flag
						description_militarist = { text = astral_rift.3085.desc.homicidal_militarist }
						default = { text = astral_rift.3085.desc.homicidal }
					}
				}
				default = { text = astral_rift.3085.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_easy_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		explorer = {
			astral_thread_large_reward = yes
			add_modifier = {
				modifier = grunur_weapon_interface_modifier
			}
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3090
	title = astral_rift.3090.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_baol_chain = { text = astral_rift.3090.desc.baol }
				default = { text = astral_rift.3090.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_medium_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = EXCELLENT
		custom_tooltip = astral_rift.3090.tt
		explorer = {
			astral_thread_large_reward = yes
			add_random_research_option = {
				add_progress = 0.25
				category = military_theory
				fail_effects = {
					add_monthly_resource_mult = {
						resource = society_research
						value = @tier3researchreward
						min = @tier3researchmin
						max = @tier3researchmax
					}
				}
			}
		}
		hidden_effect = {
			explorer = {
				set_country_flag = unlocked_flamestorm_troopers
			}
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3095
	title = astral_rift.3095.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_gestalt = { text = astral_rift.3095.desc.gestalt }
				default = { text = astral_rift.3095.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = ap_rift_event_30_military_alien_march
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes

	is_triggered_only = yes

	option = {
		name = UNFORTUNATE
		explorer = {
			astral_thread_large_reward = yes
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
		hidden_effect = {
			explorer = {
				country_event = {
					id = astral_planes.205
					scopes = { from = prev fromfrom = prev.fleet }
				}
			}
		}
		leader = {
			exile_leader_as = grunur_rift_lost_explorer@owner
		}
		hidden_effect = {
			explorer = {
				country_event = {
					id = astral_rift.3098
					days = 1800
					random = 720
					scopes = { from = prev.fleet }
				}
			}
		}
		finish_astral_rift = yes
	}
}

country_event = {
	id = astral_rift.3098
	hide_window = yes
	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				exists = from
				from = {
					NOT = { exists = leader }
				}
			}
			from = {
				save_event_target_as = returning_ship
			}
		}
		else_if = {
			limit = {
				any_owned_fleet = {
					is_ship_class = shipclass_science_ship
					NOT = { exists = leader	}
				}
			}
			random_owned_fleet = {
				limit = {
					is_ship_class = shipclass_science_ship
					NOT = { exists = leader	}
				}
				save_event_target_as = returning_ship
			}
		}
		else = {
			create_fleet = {
				effect = {
					set_owner = prev
					create_ship = {
						name = random
						random_existing_design = science
					}
					set_fleet_stance = evasive
					set_location = prev.capital_scope.star
					every_owned_ship = {
						set_disabled = yes
					}
					set_fleet_flag = temporary_fleet
					save_event_target_as = returning_ship
				}
			}
		}
		event_target:returning_ship = {
			set_leader = grunur_rift_lost_explorer@prev
			fleet_event = { id = astral_rift.3099 }
		}
	}
}

fleet_event = {
	id = astral_rift.3099
	title = astral_rift.3099.name
	desc = astral_rift.3099.desc
	picture = GFX_evt_astral_rift_siege_on_paradise_grunur
	show_sound = event_robot_encounter

	is_triggered_only = yes

	option = {
		name = OK
		leader = {
			freeze_leader_age = no
			if = {
				limit = { NOT = { has_trait = leader_trait_expertise_propulsion } }
				add_trait = {
					trait = leader_trait_expertise_propulsion
				}
			}
			else = {
				limit = { NOT = { has_trait = leader_trait_expertise_voidcraft } }
				add_trait = {
					trait = leader_trait_expertise_voidcraft
				}
			}
			add_trait = {
				trait = leader_trait_rift_warped
			}
		}
	}

	after = {
		if = {
			limit = {
				has_fleet_flag = temporary_fleet
			}
			delete_fleet = {
				target = this
				kill_leader = no
			}
		}
	}
}
#########################################
# Astral Rift - Tropical Habitat Events #
#########################################

namespace = astral_rift

astral_rift_event = {
	id = astral_rift.3100
	title = astral_rift.3100.name
	desc = astral_rift.3100.desc

	picture = GFX_evt_astral_rift_tropical_habitat
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_initial_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3100.a
		explorer = {
			astral_thread_small_reward = yes
		}
		set_next_astral_rift_event = { id = astral_rift.3105 }
	}
}

astral_rift_event = {
	id = astral_rift.3105
	title = astral_rift.3105.name
	desc = astral_rift.3105.desc

	picture = GFX_evt_astral_rift_tropical_habitat
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_transition_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3105.a
		trigger = {
			OR = {
				has_astral_rift_flag = description_robotic
				has_astral_rift_flag = description_lithoid
				has_astral_rift_flag = description_toxoid
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3110 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
			modifier = {
				add = 100
				explorer = {
					is_spiritualist = yes
				}
			}
		}
	}

	option = {
		name = astral_rift.3105.a
		trigger = {
			NOR = {
				has_astral_rift_flag = description_robotic
				has_astral_rift_flag = description_lithoid
				has_astral_rift_flag = description_toxoid
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3111 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
			modifier = {
				add = 100
				explorer = {
					is_spiritualist = yes
				}
			}
		}
	}

	option = {
		name = astral_rift.3105.b
		set_next_astral_rift_event = { id = astral_rift.3115 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
			modifier = {
				add = 100
				explorer = {
					is_materialist = yes
				}
			}
		}
	}

	after = {
		explorer= {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3110
	title = astral_rift.3110.name
	desc = astral_rift.3110.desc

	picture = GFX_evt_astral_rift_tropical_habitat
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_easy_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3110.a
		explorer = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
		}
		hidden_effect = {
			add_stage_modifier = { modifier = astral_rift_difficulty_decrease_3 }
		}
		set_next_astral_rift_event = { id = astral_rift.3120 }
	}
}

astral_rift_event = {
	id = astral_rift.3111
	title = astral_rift.3111.name
	desc = astral_rift.3111.desc

	picture = GFX_evt_astral_rift_tropical_habitat
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_easy_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3111.a
		explorer = {
			add_monthly_resource_mult = {
				resource = exotic_gases
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3120 }
	}
}

astral_rift_event = {
	id = astral_rift.3115
	title = astral_rift.3115.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_toxoid = { text = astral_rift.3115.desc.toxoid_or_lithoid }
				description_lithoid = { text = astral_rift.3115.desc.toxoid_or_lithoid }
				description_robotic = { text = astral_rift.3115.desc.mechanical }
				default = { text = astral_rift.3115.desc.default }
			}
		}
	}

	picture = GFX_evt_astral_rift_tropical_habitat
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_easy_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3115.a
		trigger = {
			OR = {
				has_astral_rift_flag = description_robotic
				has_astral_rift_flag = description_lithoid
				has_astral_rift_flag = description_toxoid
			}
		}
		hidden_effect = {
			add_stage_modifier = { modifier = astral_rift_difficulty_decrease_3 }
		}
		set_next_astral_rift_event = { id = astral_rift.3120 }
	}

	option = {
		name = astral_rift.3115.b
		trigger = {
			NOR = {
				has_astral_rift_flag = description_robotic
				has_astral_rift_flag = description_lithoid
				has_astral_rift_flag = description_toxoid
			}
		}
		hidden_effect = {
			add_stage_modifier = { modifier = astral_rift_difficulty_decrease_1 }
		}
		set_next_astral_rift_event = { id = astral_rift.3120 }
	}

	after = {
		explorer = {
			add_monthly_resource_mult = {
				resource = exotic_gases
				value = @tier2materialreward
				min = @tier2materialmin
				max = @tier2materialmax
			}
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3120
	title = astral_rift.3120.name
	desc = astral_rift.3120.desc
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_hard_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3120.a
		set_next_astral_rift_event = { id = astral_rift.3125 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3120.b
		set_next_astral_rift_event = { id = astral_rift.3130 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	after = {
		explorer = {
			add_monthly_resource_mult = {
				resource = exotic_gases
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3125
	title = astral_rift.3125.name
	desc = astral_rift.3125.desc
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_medium_plus_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3125.a
		explorer = {
			add_monthly_resource_mult = {
				resource = minerals
				value = @tier3materialreward
				min = @tier3materialmin
				max = @tier3materialmax
			}
			add_monthly_resource_mult = {
				resource = exotic_gases
				value = @tier1materialreward
				min = @tier1materialmin
				max = @tier1materialmax
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3145 }
	}
}

astral_rift_event = {
	id = astral_rift.3130
	title = astral_rift.3130.name
	desc = astral_rift.3130.desc
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_easy_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3130.a
		trigger = {
			NOT = { has_astral_rift_flag = description_toxoid }
		}
		set_next_astral_rift_event = {
			id = astral_rift.3135
			on_roll_failed = astral_rift.3140
			fail_probability = @default_failure_probability
		}

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3130.a
		trigger = {
			has_astral_rift_flag = description_toxoid
		}
		set_next_astral_rift_event = { id = astral_rift.3135 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	option = {
		name = astral_rift.3130.b
		set_next_astral_rift_event = { id = astral_rift.3150 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	after = {
		explorer = {
			astral_thread_small_reward = yes
		}
	}
}

astral_rift_event = {
	id = astral_rift.3135
	title = astral_rift.3135.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_toxoid = { text = astral_rift.3135.desc.toxoid }
				default = { text = astral_rift.3135.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_hard_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3135.a
		explorer = {
			astral_thread_small_reward = yes
		}
		set_next_astral_rift_event = { id = astral_rift.3155 }
	}
}

astral_rift_event = {
	id = astral_rift.3140
	title = astral_rift.3140.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_robotic = { text = astral_rift.3140.desc.robot }
				default = { text = astral_rift.3140.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_medium_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3140.a
		explorer = {
			astral_thread_small_reward = yes
		}
		if = {
			limit = {
				NOT = { has_astral_rift_flag = description_robotic }
			}
			leader = {
				add_trait = {
					trait = leader_trait_maimed
				}
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3155 }
	}
}

astral_rift_event = {
	id = astral_rift.3145
	title = astral_rift.3145.name
	desc = astral_rift.3145.desc
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_easy_difficulty
	is_triggered_only = yes

	option = {
		name = EXCELLENT
		explorer = {
			inverted_switch = {
				trigger = has_technology
				tech_eco_simulation = { give_technology = { tech = tech_eco_simulation } }
				tech_terrestrial_sculpting = { give_technology = { tech = tech_terrestrial_sculpting } }
				tech_gene_crops = { give_technology = { tech = tech_gene_crops } }
				tech_nano_vitality_crops = { give_technology = { tech = tech_nano_vitality_crops } }
				default = {
					give_technology = { tech = tech_repeatable_improved_tile_food_output }
				}
			}
			astral_thread_large_reward = yes
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3150
	title = astral_rift.3150.name
	desc = astral_rift.3150.desc
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_easy_plus_difficulty
	is_triggered_only = yes

	option = {
		name = EXCELLENT
		explorer = {
			inverted_switch = {
				trigger = has_technology
				tech_eco_simulation = { give_technology = { tech = tech_eco_simulation } }
				tech_terrestrial_sculpting = { give_technology = { tech = tech_terrestrial_sculpting } }
				tech_gene_crops = { give_technology = { tech = tech_gene_crops } }
				tech_nano_vitality_crops = { give_technology = { tech = tech_nano_vitality_crops } }
				default = {
					give_technology = { tech = tech_repeatable_improved_tile_food_output }
				}
			}
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier3researchreward
				min = @tier3researchmin
				max = @tier3researchmax
			}
			astral_thread_large_reward = yes
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3155
	title = astral_rift.3155.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_robotic = { text = astral_rift.3155.desc.robotic_or_pacifist }
				description_pacifist = { text = astral_rift.3155.desc.robotic_or_pacifist }
				default = { text = astral_rift.3155.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_tropical_habitat_2
	show_sound = ap_rift_event_31_tropical_paradise

	astral_rift = yes
	difficulty = @astral_rift_transition_difficulty
	is_triggered_only = yes

	option = {
		name = astral_rift.3155.a
		explorer = {
			if = {
				limit = {
					prev = {
						OR = {
							has_astral_rift_flag = description_robotic
							has_astral_rift_flag = description_pacifist
						}
					}
				}
				custom_tooltip = formula_pink_opinion_modifier_tt
				hidden_effect = {
					set_country_flag = formula_pink_opinion_modifier
					every_playable_country = {
						limit = {
							has_communications = prev
							is_affected_by_formula_pink_opinion_modifier = yes
						}
						add_opinion_modifier = { modifier = opinion_formula_pink who = prev }
					}
				}
			}
			else = {
				add_modifier = { modifier = formula_pink_armies }
			}
			astral_thread_large_reward = yes
		}
		finish_astral_rift = yes
	}
}

country_event = {
	id = astral_rift.3190
	hide_window = yes

	is_triggered_only = yes

	trigger = {
		has_astral_planes_dlc = yes
	}

	immediate = {
		if = {
			limit = {
				has_country_flag = formula_pink_opinion_modifier
				from = {
					is_affected_by_formula_pink_opinion_modifier = yes
				}
			}
			from = {
				add_opinion_modifier = { modifier = opinion_formula_pink who = prev }
			}
		}
		if = {
			limit = {
				from = {
					has_country_flag = formula_pink_opinion_modifier
				}
				is_affected_by_formula_pink_opinion_modifier = yes
			}
			add_opinion_modifier = { modifier = opinion_formula_pink who = from }
		}
	}
}
#########################################
# Astral Rift - Psionic Stranger Events #
#########################################

namespace = astral_rift

astral_rift_event = {
	id = astral_rift.3200
	title = astral_rift.3200.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_robotic = {
					switch = {
						trigger = has_astral_rift_flag
						description_psionic = { text = astral_rift.3200.desc.robot_psionic }
						default = { text = astral_rift.3200.desc.robot }
					}
				}
				default = {
					switch = {
						trigger = has_astral_rift_flag
						description_psionic = { text = astral_rift.3200.desc.psionic }
						default = { text = astral_rift.3200.desc.default }
					}
				}
			}
		}
	}
	picture = GFX_evt_frozen
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_initial_difficulty
	astral_rift = yes
	is_triggered_only = yes

	option = {
		name = astral_rift.3200.a
		explorer = { astral_thread_small_reward = yes }
		set_next_astral_rift_event = { id = astral_rift.3205 }
	}
}

astral_rift_event = {
	id = astral_rift.3205
	title = astral_rift.3205.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_gestalt = {
					switch = {
						trigger = has_astral_rift_flag
						completed_zroni_storyline = { text = astral_rift.3205.desc.gestalt_completed_zroni }
						started_zroni_storyline = { text = astral_rift.3205.desc.gestalt_started_zroni }
						default = { text = astral_rift.3205.desc.gestalt_not_started_zroni }
					}
				}
				default = {
					switch = {
						trigger = has_astral_rift_flag
						completed_zroni_storyline = { text = astral_rift.3205.desc.default_completed_zroni }
						started_zroni_storyline = { text = astral_rift.3205.desc.default_started_zroni }
						default = { text = astral_rift.3205.desc.default_not_started_zroni }
					}
				}
			}
		}
	}
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes
	is_triggered_only = yes

	immediate = {
		update_zrony_storyline_flags = yes
	}

	option = {
		name = astral_rift.3205.a
		explorer = { astral_thread_small_reward = yes }
		set_next_astral_rift_event = { id = astral_rift.3210 }
	}
}

astral_rift_event = {
	id = astral_rift.3210
	title = astral_rift.3210.name
	desc = astral_rift.3210.desc
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes
	is_triggered_only = yes

	option = {
		name = astral_rift.3210.a
		trigger = { has_astral_rift_flag = completed_zroni_storyline }
		set_next_astral_rift_event = { id = astral_rift.3215 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}
	option = {
		name = astral_rift.3210.b
		trigger = { has_astral_rift_flag = started_zroni_storyline }
		set_next_astral_rift_event = { id = astral_rift.3220 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}
	option = {
		name = astral_rift.3210.c
		trigger = { has_astral_rift_flag = not_started_zroni_storyline }
		set_next_astral_rift_event = { id = astral_rift.3225 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}
	option = {
		name = astral_rift.3210.d
		trigger = { explorer = { is_materialist = no } }
		set_next_astral_rift_event = { id = astral_rift.3230 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}
	option = {
		name = astral_rift.3210.e
		trigger = { explorer = { is_materialist = yes } }
		set_next_astral_rift_event = { id = astral_rift.3230 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}

	immediate = {
		update_zrony_storyline_flags = yes
	}

	after = {
		explorer = { astral_thread_small_reward = yes }
	}
}

astral_rift_event = {
	id = astral_rift.3215
	title = astral_rift.3215.name
	desc = astral_rift.3215.desc
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_hard_difficulty
	astral_rift = yes
	is_triggered_only = yes

	option = {
		name = astral_rift.3215.a
		set_next_astral_rift_event = { id = astral_rift.3235 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}
	option = {
		name = astral_rift.3215.b
		hidden_effect = {
			add_stage_modifier = { modifier = astral_rift_difficulty_increase_1 }
		}
		set_next_astral_rift_event = { id = astral_rift.3240 }

		ai_chance = {
			inline_script = astral_rift/rift_difficulty_ai_weight
		}
	}
	after = {
		explorer = { astral_thread_small_reward = yes }
	}
}

astral_rift_event = {
	id = astral_rift.3220
	title = astral_rift.3220.name
	desc = astral_rift.3220.desc
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_hard_difficulty
	astral_rift = yes
	is_triggered_only = yes

	option = {
		name = astral_rift.3220.a
		set_next_astral_rift_event = { id = astral_rift.3235 }
	}
	option = {
		name = astral_rift.3220.b
		set_next_astral_rift_event = { id = astral_rift.3240 }
	}
	after = {
		explorer = { astral_thread_small_reward = yes }
	}
}

astral_rift_event = {
	id = astral_rift.3225
	title = astral_rift.3225.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_gestalt = { text = astral_rift.3225.desc.gestalt }
				default = {
					switch = {
						trigger = has_astral_rift_flag
						description_spiritualist = { text = astral_rift.3225.desc.non_gestalt_spiritualist }
						description_materialist = { text = astral_rift.3225.desc.non_gestalt_materialist }
						default = { text = astral_rift.3225.desc.default }
					}
				}
			}
		}
	}
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_hard_difficulty
	astral_rift = yes
	is_triggered_only = yes

	option = {
		name = astral_rift.3225.a
		trigger = {
			explorer = {
				is_fanatic_spiritualist = no
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3235 }
	}
	option = {
		name = astral_rift.3225.b
		trigger = {
			explorer = {
				is_fanatic_materialist = no
			}
		}
		set_next_astral_rift_event = { id = astral_rift.3240 }
	}
	after = {
		explorer = { astral_thread_small_reward = yes }
	}
}

astral_rift_event = {
	id = astral_rift.3230
	title = astral_rift.3230.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				completed_zroni_storyline = { text = astral_rift.3230.desc.completed_zroni }
				started_zroni_storyline = { text = astral_rift.3230.desc.started_zroni }
				default = { text = astral_rift.3230.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_transition_difficulty
	astral_rift = yes
	is_triggered_only = yes

	immediate = {
		update_zrony_storyline_flags = yes
		owner = { set_country_flag = has_left_zroni_to_their_fate }
	}

	option = {
		name = astral_rift.3230.a
		explorer = { astral_thread_small_reward = yes }
		set_next_astral_rift_event = { id = astral_rift.3245 }
	}
}

astral_rift_event = {
	id = astral_rift.3235
	title = astral_rift.3235.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_gestalt = { text = astral_rift.3235.desc.gestalt }
				description_materialist = { text = astral_rift.3235.desc.materialist }
				default = { text = astral_rift.3235.desc.default }
			}
		}
	}
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes
	is_triggered_only = yes

	option = {
		name = astral_rift.3235.a
		explorer = {
			if = {
				limit = {
					OR = {
						is_gestalt = yes
						is_materialist = yes
					}
				}
				add_monthly_resource_mult = {
					resource = energy
					value = @tier3materialreward
					min = @tier3materialmin
					max = @tier3materialmax
				}
			}
			else = {
				add_random_research_option = {
					add_progress = 0.75
					category = psionics
					ignore_prereqs = yes
					fail_effects = {
						add_monthly_resource_mult = {
							resource = society_research
							value = @tier3researchreward
							min = @tier3researchmin
							max = @tier3researchmax
						}
					}
				}
			}
			hidden_effect = {
				country_event = {
					id = astral_rift.3280
					days = 1080
					random = 720
					scopes = {
						from = root
					}
				}
			}
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3240
	title = astral_rift.3240.name
	desc = {
		trigger = {
			switch = {
				trigger = has_astral_rift_flag
				description_gestalt = {
					switch = {
						trigger = has_astral_rift_flag
						completed_zroni_storyline = { text = astral_rift.3240.desc.gestalt_completed_zroni }
						default = { text = astral_rift.3240.desc.gestalt }
					}
				}
				description_materialist = {
					switch = {
						trigger = has_astral_rift_flag
						completed_zroni_storyline = { text = astral_rift.3240.desc.materialist_completed_zroni }
						default = { text = astral_rift.3240.desc.materialist }
					}
				}
				default = {
					switch = {
						trigger = has_astral_rift_flag
						completed_zroni_storyline = { text = astral_rift.3240.desc.default_completed_zroni }
						default = { text = astral_rift.3240.desc.default }
					}
				}
			}
		}
	}
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes
	is_triggered_only = yes

	immediate = {
		update_zrony_storyline_flags = yes
	}

	option = {
		name = astral_rift.3240.a
		explorer = {
			if = {
				limit = {
					OR = {
						is_gestalt = yes
						is_materialist = yes
					}
				}
				add_monthly_resource_mult = {
					resource = energy
					value = @tier3materialreward
					min = @tier3materialmin
					max = @tier3materialmax
				}
			}
			else = {
				add_random_research_option = {
					add_progress = 0.75
					category = psionics
					ignore_prereqs = yes
					fail_effects = {
						add_monthly_resource_mult = {
							resource = society_research
							value = @tier3researchreward
							min = @tier3researchmin
							max = @tier3researchmax
						}
					}
				}
			}
			hidden_effect = {
				country_event = {
					id = astral_rift.3285
					days = 1080
					random = 720
					scopes = {
						from = root
					}
				}
			}
		}
		finish_astral_rift = yes
	}
}

astral_rift_event = {
	id = astral_rift.3245
	title = astral_rift.3245.name
	desc = astral_rift.3245.desc
	picture = GFX_evt_astral_rift_psionic_stranger
	show_sound = ap_rift_event_32_psionic_comms
	difficulty = @astral_rift_easy_plus_difficulty
	astral_rift = yes
	is_triggered_only = yes

	option = {
		name = astral_rift.3245.a
		explorer = {
			astral_thread_large_reward = yes
			add_monthly_resource_mult = {
				resource = minerals
				value = @tier3materialreward
				min = @tier3materialmin
				max = @tier3materialmax
			}
			add_monthly_resource_mult = {
				resource = rare_crystals
				value = @tier3materialreward
				min = @tier3materialmin
				max = @tier3materialmax
			}
		}
		finish_astral_rift = yes
	}
}

country_event = {
	id = astral_rift.3280
	title = astral_rift.3280.name
	desc = {
		trigger = {
			has_country_flag = zroni_intro
		}
		text = astral_rift.3280.desc.started_zroni
	}
	desc = {
		trigger = {
			has_country_flag = zroni_completed
		}
		text = astral_rift.3280.desc.completed_zroni
	}
	desc = {
		text = astral_rift.3280.desc.default
	}
	picture = GFX_evt_astral_rift_psionic_stranger_2
	show_sound = ap_rift_event_32_psionic_comms
	is_triggered_only = yes

	option = {
		name = astral_rift.3280.a
		add_random_research_option = {
			add_progress = 0.75
			only_rare = yes
			fail_effects = {
				add_random_research_option = {
					add_progress = 0.75
					category = particles
				}
			}
		}
		astral_thread_large_reward = yes
	}
}

country_event = {
	id = astral_rift.3285
	title = astral_rift.3285.name
	desc = {
		trigger = {
			has_country_flag = zroni_completed
		}
		text = astral_rift.3285.desc.completed_zroni
	}
	desc = {
		trigger = {
			has_country_flag = zroni_intro
		}
		text = astral_rift.3285.desc.started_zroni
	}
	desc = {
		text = astral_rift.3285.desc.default
	}
	picture = GFX_evt_astral_rift_psionic_stranger_2
	show_sound = ap_rift_event_32_psionic_comms
	is_triggered_only = yes

	option = {
		name = astral_rift.3285.a
		add_modifier = { modifier = zroni_insight_modifier }
        hidden_effect = {
            every_controlled_fleet = {
			limit = { exists = solar_system }
                update_fleet_space_storm_reduction_zroni_rift = yes
            }
        }
		add_monthly_resource_mult = {
			resource = energy
			value = @tier3materialreward
			min = @tier3materialmin
			max = @tier3materialmax
		}
		astral_thread_large_reward = yes
		add_monthly_resource_mult = {
			resource = rare_crystals
			value = @tier5materialreward
			min = @tier5materialmin
			max = @tier5materialmax
		}
	}
}

# Space Storm immunity - fleet entered system
fleet_event = {
	id = astral_rift.3290
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_astral_planes_dlc = yes
		owner = {
			has_modifier = zroni_insight_modifier
		}
	}

	immediate = {
		update_fleet_space_storm_reduction_zroni_rift = yes
	}
}

# Space Storm immunity - storm created or destroyed in system
system_event = {
	id = astral_rift.3291
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_astral_planes_dlc = yes
	}

	immediate = {
		every_fleet_in_system = {
			limit = {
				exists = owner
				owner = {
					has_modifier = zroni_insight_modifier
				}
			}
			update_fleet_space_storm_reduction_zroni_rift = yes
		}
	}
}

# Space Storm immunity - ship created
ship_event = {
	id = astral_rift.3292
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		has_astral_planes_dlc = yes
		owner = {
			has_modifier = zroni_insight_modifier
		}
	}

	immediate = {
		fleet = {
			remove_modifier = zroni_insight_space_storm_reduction_modifier # to re-assign modifier to take new ship into account
			update_fleet_space_storm_reduction_zroni_rift = yes
		}
	}
}
