﻿namespace = rel_flavor_undead_pantheon

#Killing 2 faithless pops, choice to convert 2 more or raise 2 of the dead in the capital
rel_flavor_undead_pantheon.1 = {
	type = country_event
	title = "rel_flavor_undead_pantheon.1.t"
	desc = "rel_flavor_undead_pantheon.1.desc"
	picture = crucifixion
	
	goto_location = scope:randomized_country_province
	
	trigger = {
		religion = undead_pantheon
		NOT = { has_variable = rel_flavor_undead_pantheon_1_cooldown }
		any_owned_province = {
			NOT = { dominant_province_religion = undead_pantheon }
			num_other_religion > 3
		}
		capital_scope = { has_province_modifier = undead_city }
	}

	immediate = {
		random_owned_province = {
			limit = {
				NOT = { dominant_province_religion = undead_pantheon }
				total_population > 3
			}
			save_scope_as = randomized_country_province
		}
		hidden_effect = {
			set_variable = {
				name = rel_flavor_undead_pantheon_1_cooldown
				days = 1825
			}
		}
	}

	option = {
		name = "rel_flavor_undead_pantheon.1.a"
		scope:randomized_country_province = {
			random_pops_in_province = {
				kill_pop = yes
			}
			random_pops_in_province = {
				set_pop_culture = undead
				set_pop_religion = undead_pantheon
				move_pop = ROOT.capital_scope
			}
		}
	}
	option = {
		name = "rel_flavor_undead_pantheon.1.b"
		scope:randomized_country_province = {
			random_pops_in_province = {
				limit = {
					NOT = { religion = undead_pantheon}
				}
				kill_pop = yes
			}
			random_pops_in_province = {
				limit = {
					NOT = { religion = undead_pantheon}
				}
				kill_pop = yes
			}
			random_pops_in_province = {
				limit = {
					NOT = { religion = undead_pantheon}
				}
				set_pop_religion = undead_pantheon
			}
			random_pops_in_province = {
				limit = {
					NOT = { religion = undead_pantheon}
				}
				set_pop_religion = undead_pantheon
			}
		}
	}
}

#Getting a Great Temple in a city or getting 3 pops there or in capital if not undead city.
rel_flavor_undead_pantheon.2 = {
	type = country_event
	title = "rel_flavor_undead_pantheon.2.t"
	desc = "rel_flavor_undead_pantheon.2.desc"
	picture = crucifixion
	
	goto_location = scope:randomized_country_province
	
	trigger = {
		religion = undead_pantheon
		NOT = { has_variable = rel_flavor_undead_pantheon_2_cooldown }
		any_owned_province = {
			dominant_province_religion = undead_pantheon
			has_city_status = yes
			can_build_building = temple_building
		}
		capital_scope = { has_province_modifier = undead_city }
	}

	immediate = {
		random_owned_province = {
			limit = {
				dominant_province_religion = undead_pantheon
				has_city_status = yes
				can_build_building = temple_building
			}
			save_scope_as = randomized_country_province
		}
		hidden_effect = {
			set_variable = {
				name = rel_flavor_undead_pantheon_2_cooldown
				days = 1825
			}
		}
	}

	option = {
		name = "rel_flavor_undead_pantheon.2.a"
		scope:randomized_country_province = {
			add_building_level = temple_building
		}
	}
	option = {
		name = "rel_flavor_undead_pantheon.2.b"
		scope:randomized_country_province = {
			if = {
				limit = { has_province_modifier = undead_city }
				define_pop = {
					type = slaves
					culture = undead
					religion = undead_pantheon
				}
				define_pop = {
					type = slaves
					culture = undead
					religion = undead_pantheon
				}
				define_pop = {
					type = slaves
					culture = undead
					religion = undead_pantheon
				}
			}
			if else = {
				ROOT = {
					capital_scope = {
						define_pop = {
							type = slaves
							culture = undead
							religion = undead_pantheon
						}
						define_pop = {
							type = slaves
							culture = undead
							religion = undead_pantheon
						}
						define_pop = {
							type = slaves
							culture = undead
							religion = undead_pantheon
						}
					}
				}
			}
		}
	}
}
#Undead city gets necromantic energy or country gets a new characters. Undead characters have +10 loyalty and should die rarely, so a good consolation when goods replacement is not desirable.
rel_flavor_undead_pantheon.3 = {
	type = country_event
	title = "rel_flavor_undead_pantheon.3.t"
	desc = "rel_flavor_undead_pantheon.3.desc"
	picture = crucifixion
	
	goto_location = scope:randomized_country_province
	
	trigger = {
		religion = undead_pantheon
		NOT = { has_variable = rel_flavor_undead_pantheon_3_cooldown }
		any_owned_province = {
			has_province_modifier = undead_city
			NOT = { trade_goods = necromantic_energy }
		}
	}

	immediate = {
		random_owned_province = {
			limit = {
				has_province_modifier = undead_city
				NOT = { trade_goods = necromantic_energy }
			}
			save_scope_as = randomized_country_province
		}
		hidden_effect = {
			set_variable = {
				name = rel_flavor_undead_pantheon_3_cooldown
				days = 730 #because necromantic energy is extremely rare, let's allow this to happen fairly often. May revisit.
			}
		}
	}

	option = {
		name = "rel_flavor_undead_pantheon.3.a"
		scope:randomized_country_province = {
			set_trade_goods = necromantic_energy
		}
	}
	option = {
		name = "rel_flavor_undead_pantheon.3.b"
		create_character = {
			religion = undead_pantheon
			culture = undead
			age = 20
			add_trait = undead_char_def
		}
	}
}

#Undead city can get a modifier to boost local output and province loyalty
rel_flavor_undead_pantheon.4 = {
	type = country_event
	title = "rel_flavor_undead_pantheon.4.t"
	desc = "rel_flavor_undead_pantheon.4.desc"
	picture = crucifixion
	
	goto_location = scope:randomized_country_province
	
	trigger = {
		religion = undead_pantheon
		NOT = { has_variable = rel_flavor_undead_pantheon_4_cooldown }
		any_owned_province = {
			has_province_modifier = undead_city
			NOT = { has_province_modifier = undeath_absolute }
		}
	}

	immediate = {
		random_owned_province = {
			limit = {
				has_province_modifier = undead_city
				NOT = { has_province_modifier = undeath_absolute }
			}
			save_scope_as = randomized_country_province
		}
		hidden_effect = {
			set_variable = {
				name = rel_flavor_undead_pantheon_4_cooldown
				days = 730 #We do want this to fire quite often
			}
		}
	}

	option = {
		name = "rel_flavor_undead_pantheon.4.a"
		scope:randomized_country_province = {
			add_permanent_province_modifier = {
				name = undeath_absolute
				duration = -1
			}
		}
	}
}

#Undead city can get a modifier to boost local output and province loyalty
rel_flavor_undead_pantheon.5 = {
	type = country_event
	title = "rel_flavor_undead_pantheon.5.t"
	desc = "rel_flavor_undead_pantheon.5.desc"
	picture = crucifixion
	
	goto_location = scope:randomized_country_province
	
	trigger = {
		religion = undead_pantheon
		NOT = { has_variable = rel_flavor_undead_pantheon_5_cooldown }
		any_owned_province = {
			has_province_modifier = undead_city
			NOT = { has_province_modifier = undeath_coordinated }
		}
	}

	immediate = {
		random_owned_province = {
			limit = {
				has_province_modifier = undead_city
				NOT = { has_province_modifier = undeath_coordinated }
			}
			save_scope_as = randomized_country_province
		}
		hidden_effect = {
			set_variable = {
				name = rel_flavor_undead_pantheon_5_cooldown
				days = 730 #We do want this to fire quite often
			}
		}
	}

	option = {
		name = "rel_flavor_undead_pantheon.5.a"
		scope:randomized_country_province = {
			add_permanent_province_modifier = {
				name = undeath_coordinated
				duration = -1
			}
		}
	}
}