########################
#
# Uplift Events
# by Maximilian Olbers
#
########################

namespace = uplift

# Pre-sapients Found
ship_event = {
	id = uplift.6000
	title = uplift.6000.name.2
	desc = {
		text = uplift.6000.wilderness.desc
		exclusive_trigger = {
			controller = {
				is_wilderness_empire = yes
			}
		}
	}
	desc = {
		text = uplift.6000.continental.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_continental
			}
		}
	}
	desc = {
		text = uplift.6000.ocean.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_ocean
			}
		}
	}
	desc = {
		text = uplift.6000.tropical.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_tropical
			}
		}
	}
	desc = {
		text = uplift.6000.arid.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_arid
			}
		}
	}
	desc = {
		text = uplift.6000.desert.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_desert
			}
		}
	}
	desc = {
		text = uplift.6000.savannah.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_savannah
			}
		}
	}
	desc = {
		text = uplift.6000.tundra.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_tundra
			}
		}
	}
	desc = {
		text = uplift.6000.arctic.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_arctic
			}
		}
	}
	desc = {
		text = uplift.6000.alpine.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_alpine
			}
		}
	}
	desc = {
		text = uplift.6000.nuked.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_nuked
			}
		}
	}
	desc = {
		text = uplift.6000.gaia.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_gaia
			}
		}
	}
	desc = {
		text = uplift.6000.relic.desc
		exclusive_trigger = {
			from = {
				is_planet_class = pc_relic
			}
		}
	}
	desc = {
		text = uplift.6000.fallback.desc
	}
	picture = {
		picture = GFX_evt_animal_wildlife
		trigger = {
			from = {
				is_planet_class = pc_gaia
			}
		}
	}
	picture = {
		inline_script = {
			script = events/biogenesis_event_art
			OWNER = owner
			REGULAR_PICTURE = GFX_evt_landing_ship
			BIOSHIP_PICTURE = GFX_evt_bioship_landing
		}
		trigger = {
			from = {
				is_dry = yes
			}
		}
	}
	picture = {
		picture = GFX_evt_big_landing_ship
		trigger = {
			from = {
				is_wet = yes
			}
		}
	}
	picture = {
		picture = GFX_evt_landing_ship_2
		trigger = {
			from = {
				is_cold = yes
			}
		}
	}
	picture = {
		picture = GFX_evt_relic_world_building
		trigger = {
			from = {
				is_planet_class = pc_relic
			}
		}
	}
	picture = {
		picture = GFX_evt_tomb_world
		trigger = {
			from = {
				is_planet_class = pc_nuked
			}
		}
	}
	inline_script = {
		script = events/biogenesis_event_art
		OWNER = owner
		REGULAR_PICTURE = GFX_evt_ship_in_orbit
		BIOSHIP_PICTURE = GFX_evt_bio_ships_orbiting
	}
	location = from
	show_sound = event_default

	is_triggered_only = yes

	trigger = {
		from = {
			has_owner = no
			any_owned_pop_group = {
				is_sapient = no
			}
		}
		leader = {
			NOT = {
				has_leader_flag = nomadic_naturalist
			}
		}
	}

	immediate = {
		owner = {
			set_country_flag = upl_ongoing_generic
			set_country_flag = found_presapients
			country_event = { id = tutorial.57 days = 5 }
			country_event = { id = story.4 days = 30 }
		}
		from = {
			set_carrier_flag = upl_ongoing_planet
			weighted_random_owned_pop_group = {
				limit = {
					is_sapient = no
				}
				species = {
					save_event_target_as = presapient_species
				}
			}
		}
	}

	option = {
		name = uplift.6000.a
		trigger = { owner = { has_technology = tech_epigenetic_triggers } }
	}

	option = {
		name = uplift.6000.b
		trigger = { owner = { NOT = { has_technology = tech_epigenetic_triggers } } }
	}

	option = {
		name = uplift.6000.nomads
		trigger = {
			owner = {
				is_nomadic = yes
				values_others = yes
			}
		}
		from = {
			weighted_random_owned_pop_group = {
				limit = {
					is_sapient = no
				}
				resettle_pop_group = {
					POP_GROUP = this
					PLANET = root.owner.capital_scope
					AMOUNT = 100
				}
			}
		}
	}
}

### Uplifting Generic Success
carrier_event = {
	id = uplift.6010
	title = uplift.6010.name
	desc = {
		text = uplift.6010.continental.desc
		exclusive_trigger = {
			is_planet_class = pc_continental
		}
	}
	desc = {
		text = uplift.6010.ocean.desc
		exclusive_trigger = {
			is_planet_class = pc_ocean
		}
	}
	desc = {
		text = uplift.6010.tropical.desc
		exclusive_trigger = {
			is_planet_class = pc_tropical
		}
	}
	desc = {
		text = uplift.6010.arid.desc
		trigger = {
			is_planet_class = pc_arid
		}
	}
	desc = {
		text = uplift.6010.desert.desc
		exclusive_trigger = {
			is_planet_class = pc_desert
		}
	}
	desc = {
		text = uplift.6010.savannah.desc
		exclusive_trigger = {
			is_planet_class = pc_savannah
		}
	}
	desc = {
		text = uplift.6010.tundra.desc
		exclusive_trigger = {
			is_planet_class = pc_tundra
		}
	}
	desc = {
		text = uplift.6010.arctic.desc
		exclusive_trigger = {
			is_planet_class = pc_arctic
		}
	}
	desc = {
		text = uplift.6010.alpine.desc
		exclusive_trigger = {
			is_planet_class = pc_alpine
		}
	}
	desc = {
		text = uplift.6010.nuked.desc
		exclusive_trigger = {
			is_planet_class = pc_nuked
		}
	}
	desc = {
		text = uplift.6010.gaia.desc
		exclusive_trigger = {
			is_planet_class = pc_gaia
		}
	}
	desc = {
		text = uplift.6010.relic.desc
		exclusive_trigger = {
			is_planet_class = pc_relic
		}
	}
	desc = {
		text = uplift.6010.fallback.desc
	}
	picture = GFX_evt_society_research
	location = root
	show_sound = notification_uplift

	is_triggered_only = yes

	trigger = {
		has_carrier_flag = upl_ongoing_planet
	}

	immediate = {
		owner = {
			set_country_flag = found_presapients
			remove_country_flag = upl_ongoing_generic
		}
		remove_carrier_flag = upl_ongoing_planet
	}

	option = {
		name = uplift.6010.a
		custom_tooltip = uplift.6010.tt
		hidden_effect = {
			owner = { country_event = { id = tutorial.58 days = 5 } }
			carrier_event = { id = uplift.7199 }
		}
	}
}

#######################
# Followup Events
#######################

carrier_event = {
	id = uplift.7000
	title = uplift.7000.name
	desc = uplift.7000.desc
	picture = GFX_evt_colony_settlement
	location = from

	is_triggered_only = yes

	option = {
		name = OK
	}
}

carrier_event = {
	id = uplift.7010
	title = uplift.7010.name
	desc = uplift.7010.desc
	picture = GFX_evt_smugglers_in_bar
	location = from

	is_triggered_only = yes

	option = {
		name = OK
		add_modifier = {
			modifier = uplift_rocky
			days = 720
		}
	}
}

######################
# Ethics Events
######################

# Hidden event firing two random ethics events
# fromfrom = uplifted species
# from = planet
carrier_event = {
	id = uplift.7199
	location = from
	hide_window = yes

	is_triggered_only = yes

	immediate = {
		# initial reception
		random_list = {
			30 = { carrier_event = { id = uplift.7000 days = 30 random = 30 } }
			70 = { carrier_event = { id = uplift.7010 days = 30 random = 30 } }
		}
		# set ethics
		random_list = {
			15 = { carrier_event = { id = uplift.7200 days = 40 random = 30 } }
			15 = { carrier_event = { id = uplift.7205 days = 40 random = 30 } }
			15 = { carrier_event = { id = uplift.7210 days = 40 random = 30 } }
			15 = { carrier_event = { id = uplift.7215 days = 40 random = 30 } }
		}
	}
}

# fromfromfrom = uplifted species

# Spiritualist or Materialist
carrier_event = {
	id = uplift.7200
	title = uplift.7200.name
	desc = uplift.7200.desc
	picture = GFX_evt_colony_settlement
	location = root
	show_sound = event_cityscape

	is_triggered_only = yes

	trigger = {
		any_owned_pop_group = {
			has_trait = trait_uplifted
			NOT = { has_pop_group_flag = upl_ethic_spimat }
		}
	}

	option = {
		name = uplift.7200.a
	}

	option = {
		name = uplift.7200.b
		custom_tooltip = uplift.7200.b.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_spiritualist
						POP_GROUP_FLAG = upl_ethic_spimat
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}

	option = {
		name = uplift.7200.c
		custom_tooltip = uplift.7200.c.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_materialist
						POP_GROUP_FLAG = upl_ethic_spimat
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}
}

# Pacifist or Militarist
carrier_event = {
	id = uplift.7205
	title = uplift.7205.name
	desc = uplift.7205.desc
	picture = GFX_evt_colony_settlement
	location = root
	show_sound = event_cityscape

	is_triggered_only = yes

	trigger = {
		any_owned_pop_group = {
			has_trait = trait_uplifted
			NOT = { has_pop_group_flag = upl_ethic_pacmil }
		}
	}

	option = {
		name = uplift.7205.a
	}

	option = {
		name = uplift.7205.b
		custom_tooltip = uplift.7205.b.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_pacifist
						POP_GROUP_FLAG = upl_ethic_pacmil
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}

	option = {
		name = uplift.7205.c
		custom_tooltip = uplift.7205.c.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_militarist
						POP_GROUP_FLAG = upl_ethic_pacmil
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}
}

# Xenophile or Xenophobe
carrier_event = {
	id = uplift.7210
	title = uplift.7210.name
	desc = uplift.7210.desc
	picture = GFX_evt_colony_settlement
	location = root
	show_sound = event_cityscape

	is_triggered_only = yes

	trigger = {
		any_owned_pop_group = {
			has_trait = trait_uplifted
			NOT = { has_pop_group_flag = upl_ethic_xenoph }
		}
	}

	option = {
		name = uplift.7210.a
	}

	option = {
		name = uplift.7210.b
		custom_tooltip = uplift.7210.b.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_xenophile
						POP_GROUP_FLAG = upl_ethic_xenoph
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}

	option = {
		name = uplift.7210.c
		custom_tooltip = uplift.7210.c.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_xenophobe
						POP_GROUP_FLAG = upl_ethic_xenoph
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}
}

# Authoritarian or Materialist
carrier_event = {
	id = uplift.7215
	title = uplift.7215.name
	desc = uplift.7215.desc
	picture = GFX_evt_colony_settlement
	location = root
	show_sound = event_cityscape

	is_triggered_only = yes

	trigger = {
		any_owned_pop_group = {
			has_trait = trait_uplifted
			NOT = { has_pop_group_flag = upl_ethic_colind }
		}
	}

	option = {
		name = uplift.7215.a
	}

	option = {
		name = uplift.7215.b
		custom_tooltip = uplift.7215.b.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_authoritarian
						POP_GROUP_FLAG = upl_ethic_colind
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}

	option = {
		name = uplift.7215.c
		custom_tooltip = uplift.7215.c.tooltip
		hidden_effect = {
			every_owned_pop_group = {
				limit = {
					has_trait = trait_uplifted
					has_any_ethic = yes
				}
				from = {
					pop_group_add_ethic_effect = {
						POP_GROUP = prev
						ETHOS = ethic_egalitarian
						POP_GROUP_FLAG = upl_ethic_colind
						PERCENTAGE = 1 # 100%
						RANDOM = 0
					}
				}
			}
		}
	}
}


#######################################
# Pre-Sapient Pop Interaction Events
#######################################

# Pre-Sapients damage currency stores
carrier_event = {
	id = uplift.7500
	title = uplift.7500.name
	desc = uplift.7500.desc
	picture = GFX_evt_alien_cavemen
	location = root

	pre_triggers = { has_owner = yes }

	trigger = {
		owner = {
			NOR = {
				is_ai = yes
				is_guided_sapience_empire = yes
				is_wilderness_empire = yes
			}
			resource_stockpile_compare = { resource = energy value >= 300 }
		}
		NOT = { has_carrier_flag = chainblocked }
		any_owned_pop_group = {
			is_sapient = no
			NOT = { has_trait = trait_nascent_stage }
		}
	}

	mean_time_to_happen = { months = 1200 }

	immediate = { set_carrier_flag = chainblocked }

	option = {
		name = UNFORTUNATE
		trigger = { owner = { resource_stockpile_compare = { resource = energy value >= 300 } } }
		owner = { add_resource = { energy = -300 } }
	}

	option = {
		name = UNFORTUNATE
		trigger = { owner = { resource_stockpile_compare = { resource = energy value < 300 } } }
		owner = { add_resource = { energy = -100 } }
	}
}

# Unethical experiments on pre-sapients
carrier_event = {
	id = uplift.7510
	title = uplift.7510.name
	desc = uplift.7510.desc
	picture = GFX_evt_alien_cavemen
	location = root

	pre_triggers = { has_owner = yes }

	trigger = {
		owner = {
			NOR = {
				is_ai = yes
				is_guided_sapience_empire = yes
				is_wilderness_empire = yes
			}
		}
		NOT = { has_carrier_flag = unethical_presapient_experiments }
		any_owned_pop_group = {
			is_sapient = no
			NOT = { has_trait = trait_nascent_stage }
		}
	}

	mean_time_to_happen = { months = 1200 }

	immediate = { set_carrier_flag = unethical_presapient_experiments }

	option = {
		name = uplift.7510.a
		add_modifier = {
			modifier = unproductive_without_experiments
			days = 720
		}
	}

	option = {
		name = uplift.7510.b
		custom_tooltip = uplift.7510.b.tooltip
		trigger = { owner = { is_xenophobe = no } }
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
		}
		add_modifier = {
			modifier = unhappy_with_experiments
			days = 720
		}
	}

	option = {
		name = uplift.7510.c
		trigger = { owner = { is_xenophobe = yes } }
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier2researchreward
				min = @tier2researchmin
				max = @tier2researchmax
			}
			add_monthly_resource_mult = {
				resource = influence
				value = @tier2influencereward
				min = @tier2influencemin
				max = @tier2influencemax
			}
			if = {
				limit = { is_fanatic_xenophobe = no }
				shift_ethic = ethic_fanatic_xenophobe
			}
		}
	}
}

# Fidgeting
carrier_event = {
	id = uplift.7520
	title = uplift.7520.name
	desc = uplift.7520.desc
	picture = GFX_evt_colony_settlement
	location = root

	pre_triggers = { has_owner = yes }

	trigger = {
		owner = {
			NOR = {
				is_ai = yes
				has_country_flag = fidgeting_natives
				is_guided_sapience_empire = yes
				is_wilderness_empire = yes
			}
		}
		any_owned_pop_group = {
			is_sapient = no
			NOT = { has_trait = trait_nascent_stage }
		}
	}

	mean_time_to_happen = { months = 5000 }

	immediate = {
		owner = { set_country_flag = fidgeting_natives }
	}

	option = {
		name = uplift.7520.a
		trigger = { owner = { is_xenophobe = no } }
		owner = {
			add_monthly_resource_mult = {
				resource = unity
				value = @tier1unityreward
				min = @tier1unitymin
				max = @tier1unitymax
			}
		}
	}

	option = {
		name = uplift.7520.b
		custom_tooltip = uplift.7520.b.tooltip
		trigger = { owner = { is_xenophobe = yes } }
		owner = {
			add_monthly_resource_mult = {
				resource = influence
				value = @tier1influencereward
				min = @tier1influencemin
				max = @tier1influencemax
			}
		}
	}

	option = {
		name = uplift.7520.c
		trigger = { owner = { is_xenophile = yes } }
		hidden_effect = { carrier_event = { id = uplift.7525 days = 5 } }
	}
}

carrier_event = {
	id = uplift.7525
	title = uplift.7525.name
	desc = uplift.7525.desc
	picture = GFX_evt_colony_settlement
	location = from

	is_triggered_only = yes

	option = {
		name = FASCINATING
		owner = {
			add_monthly_resource_mult = {
				resource = society_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
			add_monthly_resource_mult = {
				resource = engineering_research
				value = @tier1researchreward
				min = @tier1researchmin
				max = @tier1researchmax
			}
		}
	}
}
