establish_everpreg_atalantea_empire_effect = {
	liege = { save_scope_as = former_liege }
	
####	
	title:e_russia = { add_to_list = atalantia_empire }
	title:e_caspian-pontic_steppe = { add_to_list = atalantia_empire }
	title:d_aegean_islands = { add_to_list = atalantia_empire_2 }
	title:c_euboea = { add_to_list = atalantia_empire_3}
	title:c_chalkidike = { add_to_list = atalantia_empire_3}
	title:c_kalliopolis = { add_to_list = atalantia_empire_3}	
	#title:b_skopelos = { add_to_list = atalantia_empire_3}

	every_in_list = {
		list = atalantia_empire
		every_in_de_jure_hierarchy = {
			limit = {
				tier = tier_kingdom
			}
			set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		}
	}

	every_in_list = {
		list = atalantia_empire_2
		every_in_de_jure_hierarchy = {
			limit = {
				tier = tier_duchy
			}
			set_de_jure_liege_title = title:k_pontic_steppe
		}
	}

	every_in_list = {
		list = atalantia_empire_3
		every_in_de_jure_hierarchy = {
			limit = {
				tier = tier_county
			}
			set_de_jure_liege_title = title:d_aegean_islands
		}
	}	
####	
	
	hidden_effect = { #Should shift all dejure of all Empires owned at the time.
		#every_held_title = { #Completely Controlled Kingdoms as well.
		#	limit = {
		#		tier = tier_kingdom
		#		root = { completely_controls = prev }
		#	}
		#	set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#}
		#every_held_title = { #Completely Controlled Kingdoms as well.
		#	limit = {
		#		tier = tier_kingdom
		#		root = { completely_controls = prev }
		#	}
		#	set_de_jure_liege_title = title:e_roman_empire
		#}		
		#title:k_pontic_steppe = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_caspian_steppe = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_caucasus = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_galicia-volhynia = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_ruthenia = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_white_rus' = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_vladimir = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_novgorod = {
		#	every_in_de_jure_hierarchy = {
		#		limit = { tier = tier_county }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:k_bjarmaland = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_kingdom }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		
		#title:e_khazaria = {
		#	every_in_de_jure_hierarchy = {
		#		limit = { tier = tier_empire }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}
		#title:e_russia = {
		#	every_in_de_jure_hierarchy = {
		#		limit = { tier = tier_empire }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}			
		#title:d_aegean_islands = {
		#	every_in_de_jure_hierarchy = {
		#		#limit = { tier = tier_duchy }
		#		set_de_jure_liege_title = title:e_everpreg_atalantea_empire
		#	}
		#}

####
		if = {
			limit = { has_title = title:e_russia }
			destroy_title = title:e_russia
		}
		if = {
			limit = { has_title = title:e_caspian-pontic_steppe }
			destroy_title = title:e_deccan
		}
####		

	}
	
		
	
	#give_nickname = nick_the_resurrector
	

	create_title_and_vassal_change = {
		type = created
		save_scope_as = change
		add_claim_on_loss = no
	}
	#create_title_and_vassal_change = create
	#scope:create = {
	#	set_title_and_vassal_change_type = created
	#}
	title:e_everpreg_atalantea_empire = {
		change_title_holder = {
			holder = root
			change = scope:change
		}
		copy_title_history = title:e_byzantium		
	}
	resolve_title_and_vassal_change = scope:change
	

	#Make ruler independent and give Burgundy to him.
	create_title_and_vassal_change = {
		type = independency
		save_scope_as = change
		add_claim_on_loss = no
	}
	change_liege_or_become_independent = {
		CHANGE = scope:change
		VASSAL = this
	}
	hidden_effect = {
		add_truce_both_ways = {
			character = scope:former_liege
			days = 1825
			name = TRUCE_GRANT_INDEPENDENCE_ROOT
		}
	}
	resolve_title_and_vassal_change = scope:change
	create_title_and_vassal_change = {
		type = created
		save_scope_as = everpreg_atalantea
		add_claim_on_loss = no
	}
	title:e_everpreg_atalantea_empire = {
		change_title_holder = {
			holder = root
			change = scope:everpreg_atalantea
		}
	}
	resolve_title_and_vassal_change = scope:everpreg_atalantea
	scope:former_liege = {
		add_prestige = major_prestige_loss
		add_unpressed_claim = title:e_everpreg_atalantea_empire #Give chance to retaliate
		add_opinion = {
			target = root
			modifier = pretender_opinion
		}
	}	

	###aegean islands region transformation - add pearl mines and custom palace####
	#custom_tooltip = everpreg_atalantia_naxos_awakens_tooltip
	title:c_naxos = { set_title_name = evpereg_charybdos }
	title:b_naxos = { set_title_name = evpereg_grandacropolisofcharybdos }
	title:b_naxos.title_province = {
		add_building_slot = 1
		add_building = holy_site_everpreg_capital_01		
	}
	title:b_tinos.title_province = {
		add_building_slot = 1
		add_building = everpreg_palace_of_grottos_01		
		#add_special_building = everpreg_palace_of_grottos_01		
	}	
	title:b_andros.title_province = {
		add_building_slot = 1
		add_building = everpreg_pearl_mines_01	
		#add_special_building = everpreg_pearl_mines_01		
	}	

	###crimea region transformation####
	#custom_tooltip = everpreg_atalantia_kerch_awakens_tooltip
	title:c_kerch = { set_title_name = evpereg_medusaea }
	title:b_kerch = { set_title_name = evpereg_acropolitaeamedusaea }
	title:b_kerch.title_province = {
		add_building_slot = 1
		add_building = holy_site_everpreg_grand_temple_01	
		#add_special_building = holy_site_everpreg_grand_temple_01
	}

	###kiev region transformation####
	#custom_tooltip = everpreg_atalantia_chernegev_awakens_tooltip
	title:c_chernigov = { set_title_name = evpereg_arachnikaea }
	title:b_chernigovv = { set_title_name = evpereg_acropolitaearachnikaea }
	title:b_chernigov.title_province = {
		add_building_slot = 1
		add_building = holy_site_everpreg_grand_temple_01	
		#add_special_building = holy_site_everpreg_grand_temple_01
	}

	###caspian sea region transformation####
	#custom_tooltip = everpreg_atalantia_astrakhan_awakens_tooltip
	title:c_astrakhan = { set_title_name = evpereg_echidnaea }
	title:b_astrakhan = { set_title_name = evpereg_acropolitaeaechidnaea }
	title:b_astrakhan.title_province = {
		add_building_slot = 1
		add_building = holy_site_everpreg_grand_temple_01	
		#add_special_building = holy_site_everpreg_grand_temple_01
	}
	
	###biarmia region transformation - add forgotten cliffs building, too####
	#custom_tooltip = everpreg_atalantia_karasjohka_awakens_tooltip
	title:c_karasjohka = { set_title_name = evpereg_sirenaea }
	title:b_karasjohka = { set_title_name = evpereg_acropolitasirenaea }
	title:b_karasjohka.title_province = {
		add_building_slot = 1
		add_building = holy_site_everpreg_grand_temple_01	
		#add_special_building = holy_site_everpreg_grand_temple_01
	}

	### Tried experimenting with transforming terrain dynamically. Didn't work. 
	#title:c_karasjohka.title_province = {
	#	terrain.c_karasjohka = floodplains
	#}		



	if = {
		limit = {
			#NOT = { highest_held_title_tier = tier_empire }
			NOT = { has_primary_title = title:e_everpreg_atalantea_empire }
		}
		set_primary_title_to = title:e_everpreg_atalantea_empire
	}

###Change government to everpreg imperial and give all current vassals scutage
	change_government = everpreg_imperial_government
	
			every_vassal_or_below = {
				limit = {
					primary_title.tier >= tier_duchy
					OR = {
						has_government = clan_government
						has_government = feudal_government
						has_government = feudal_government						
					}
				}
				#add_character_flag = { flag = imperial_autonomy_override days = 7 }
				# vassal_contract_set_obligation_level = { type = special_contract_scutage level = 1 }
				#vassal_contract = special_contract_scutage
			}	
	
	title:e_everpreg_atalantea_empire = {
		add_title_law = everpreg_imperial_elective_succession_law
	}


	#Destroy britannia
	#destroy_title = title:e_russia
	#destroy_title = title:e_caspian-pontic_steppe
}


everpreg_giant_cecaelias_effects = {
	house = {
		add_house_modifier = {
			modifier = everpreg_giant_cecaelias_modifier
		}
	}
	dynasty = {
		add_dynasty_prestige = monumental_dynasty_prestige_gain
	}
}


spawn_everpreg_giant_cecaelias_troops_effect = {
	spawn_army = {
		uses_supply = no
		inheritable = yes
		name = everpreg_giant_cecaelias_event_troops
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_sirenbroodmothers
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_sirenbroodmothers
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_giantcecaelias
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_giantcecaelias
			stacks = 5
		}
		location = capital_province
	}
	spawn_army = {
		uses_supply = no
		inheritable = yes
		name = everpreg_giant_cecaelias_event_troops
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_sirenbroodmothers
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_sirenbroodmothers
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_giantcecaelias
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_giantcecaelias
			stacks = 5
		}
		location = capital_province
	}
	spawn_army = {
		uses_supply = no
		inheritable = yes
		name = everpreg_giant_cecaelias_event_troops
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_feralsirens
			stacks = 10
		}
		men_at_arms = {
			type = everpreg_sirenbroodmothers
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_sirenbroodmothers
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_giantcecaelias
			stacks = 5
		}
		men_at_arms = {
			type = everpreg_giantcecaelias
			stacks = 5
		}
		location = capital_province
	}	
}





spawn_twisted_mothers_troops_effect = {
	spawn_army = {
		uses_supply = yes
		inheritable = no
		name = everpreg_twisted_mothers_event_troops
		men_at_arms = {
			type = everpreg_twisted_mothers
			stacks = 5
		}
		#location = county_title
		location = capital_province
	}	
}