namespace = winter_ruins
character_event = {#Turn Winter titles to ruins?
	id = winter_ruins.1
	hide_window = yes
	is_triggered_only = yes

	trigger = {
		FROM = {
			real_tier = COUNT#Should only affect counties
			NOR = {#Exclude the Wall
				title = c_castle_black
				title = c_shadow_tower
				title = c_eastwatch
			}
		}
		FROMFROM = {
			culture_group = winter_group#Should cover all possible evil holders
		}
		NOT = { culture_group = winter_group }#Make sure it's not fired when Winter shuffles its titles
	}
	immediate = {#Add the ruin modifier and fire the event to build the ruin.
		FROM = {
			location = {
				add_province_modifier = {
					name = ruined_province
					duration = -1
				}
				set_province_flag = ruined_province
			}
			holder_scope = {
				character_event = {
					id = winter_ruins.2
				}
			}
		}
	}
}

character_event = {
	id = winter_ruins.2
	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = { culture_group = unoccupied_group }
		any_demesne_province = {
			has_province_flag = ruined_province
			NOT = { has_province_flag = colony_province }
			county = { holder_scope = { character = ROOT } }
		}
	}

	option = {
		name = OK
		create_character = {
			name = ""
			religion="ruins"
			culture="ruin"	
			attributes = {
				martial = 0
				diplomacy = 0
				intrigue = 0
				stewardship = 0
				learning = 0
			}
			trait = ruin
		}
		new_character = {
			ROOT = {
				random_demesne_title = { 
					limit = {
						tier = COUNT
						location = {
							has_province_flag = ruined_province
							NOT = { has_province_flag = colony_province }
						}
					}
					gain_title = PREVPREV 
				}					
			}	
			set_defacto_liege = THIS
			character_event = { id = unoccupied.101 }
		}	
	}
}