﻿namespace = necro_spellcasting

#main spellcasting UI and manager
necro_spellcasting.1 = {
	type = country_event
	hidden = no
	title = "necro_spellcasting.1.t"
	desc = "necro_spellcasting.1.desc"
	#placeholder image
	picture = crucifixion
	
	trigger = {
		always = yes
	}

	#note that all these are going to be totally out of order, as I name them as I develop them but order them by necro power needed
	option = {
		name = "necro_spellcasting.1.b"
		if = {
			limit = {
				OR = {
					has_country_modifier = necromancy_i
					has_country_modifier = necromancy_ii
					has_country_modifier = necromancy_iii
					has_country_modifier = necromancy_iv
					has_country_modifier = necromancy_v
					has_country_modifier = necromancy_vi
					has_country_modifier = necromancy_vii
					has_country_modifier = necromancy_viii
					has_country_modifier = necromancy_ix
					has_country_modifier = necromancy_x
				}
				NOT = { has_variable = necro_charmaker }
			}
			add_treasury = -50
			add_political_influence = -10
			create_character = {
				religion = undead_pantheon
				culture = undead
				add_trait = undead_char_def
			}
			set_variable = {
				name = necro_charmaker
				days = 30
			}
		}
		trigger_event = necro_spellcasting.1
	}
	option = {
		name = "necro_spellcasting.1.e"
		if = {
			limit = { has_country_modifier = necro_tomb_raiding }
			remove_country_modifier = necro_tomb_raiding
		}
		else_if = {
			limit = {
				OR = {
					has_country_modifier = necromancy_ii
					has_country_modifier = necromancy_iii
					has_country_modifier = necromancy_iv
					has_country_modifier = necromancy_v
					has_country_modifier = necromancy_vi
					has_country_modifier = necromancy_vii
					has_country_modifier = necromancy_viii
					has_country_modifier = necromancy_ix
					has_country_modifier = necromancy_x
				}
			}
			add_country_modifier = {
				name = necro_tomb_raiding
				duration = -1
			}
		}
		trigger_event = necro_spellcasting.1
	}
	option = {
		name = "necro_spellcasting.1.g"
		if = {
			limit = { has_country_modifier = necro_administration }
			remove_country_modifier = necro_administration
		}
		else_if = {
			limit = {
				OR = {
					has_country_modifier = necromancy_iv
					has_country_modifier = necromancy_v
					has_country_modifier = necromancy_vi
					has_country_modifier = necromancy_vii
					has_country_modifier = necromancy_viii
					has_country_modifier = necromancy_ix
					has_country_modifier = necromancy_x
				}
			}
			add_country_modifier = {
				name = necro_administration
				duration = -1
			}
		}
		trigger_event = necro_spellcasting.1
	}
	option = {
		name = "necro_spellcasting.1.c"
		if = {
			limit = {
				OR = {
					has_country_modifier = necromancy_v
					has_country_modifier = necromancy_vi
					has_country_modifier = necromancy_vii
					has_country_modifier = necromancy_viii
					has_country_modifier = necromancy_ix
					has_country_modifier = necromancy_x
				}
			}
			add_treasury = -500
			add_political_influence = -100
			add_stability = -10
			current_ruler = {
				set_culture = undead
				if = {
					limit = { NOT = { has_trait = undead_char_def }}
					add_trait = undead_char_def
				}
				add_trait = lichking
			}
		}
		trigger_event = necro_spellcasting.1
	}
	option = {
		name = "necro_spellcasting.1.d"
		if = {
			limit = {
				OR = {
					has_country_modifier = necromancy_vi
					has_country_modifier = necromancy_vii
					has_country_modifier = necromancy_viii
					has_country_modifier = necromancy_ix
					has_country_modifier = necromancy_x
				}
				country_population > 50
				NOT = { has_variable = necro_ruler_empower }
			}
			add_treasury = -500
			add_political_influence = -20
			add_stability = -5
			current_ruler = {
				random_list = {
					1 = { add_zeal = 1 }
					1 = { add_martial = 1 }
					1 = { add_finesse = 1 }
					1 = { add_charisma = 1 }
				}
			}
			while = {
				count = 50
				random_owned_province = {
					limit = {
						NOT = { dominant_province_culture = undead }
					}
					random_pops_in_province = { kill_pop = yes }
				}
			}
			set_variable = {
				name = necro_ruler_empower
				days = 365
			}
		}
		trigger_event = necro_spellcasting.1
	}
	option = {
		name = "necro_spellcasting.1.f"
		if = {
			limit = { 
				OR = {
					has_country_modifier = necromancy_x
					has_country_modifier = necromancy_ix
				}
				any_neighbour_country = {
					NOT = { has_country_modifier = necro_plague }
					NOT = { is_subject_of = ROOT }
				}
			}
			add_treasury = -500
			add_political_influence = -20
			every_neighbour_country = {
				limit = {
					NOT = { is_subject_of = ROOT }
				}
				add_country_modifier = {
					name = necro_plague #note that this just plops the modifier down which is why the second event fires
					duration = 1825
				}
				trigger_event = necro_spellcasting.2
			}
		}
		trigger_event = necro_spellcasting.1
	}
	option = {
		name = "necro_spellcasting.1.a"
		if = {
			limit = { has_country_modifier = necrostorm }
			remove_country_modifier = necrostorm
		}
		else_if = {
			limit = { has_country_modifier = necromancy_x }
			add_country_modifier = {
				name = necrostorm
				duration = -1
			}
		}
		trigger_event = necro_spellcasting.1
	}
	#at end of options, close
	option = {
		name = "necro_menuclose"
	}
}

#alert that this has been cast on another nation. Effect isn't applied here because otherwise it doesn't stop event availability
necro_spellcasting.2 = {
	type = country_event
	hidden = no
	title = "necro_spellcasting.2.t"
	desc = "necro_spellcasting.2.desc"
	#placeholder image
	picture = crucifixion

	trigger = {
		always = yes
	}

	option = {
		name = "necro_spellcasting.2.a"
	}
}