﻿namespace = agot_ruins

#LEGACY OF VALYRIA MODIFIED
# Ruin is finished - Choose holding type
agot_ruins.1000 = {
	type = character_event
	title = agot_ruins.1000.t
	desc = agot_ruins.1000.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	left_portrait = {
		character = root
		animation = chancellor
	}

	immediate = {
		scope:completed_ruin = {
			remove_province_modifier = agot_ruin_reconstruction
			barony = { set_coa = holder.house }
		}
		if = {
			limit = {
				scope:completed_ruin.barony = { is_capital_barony = yes }
			}
			if = {
				limit = {
					culture = culture:high_valyrian
					has_game_rule = agot_hv_conversion_offshoots
					scope:completed_ruin.title_province = { geographical_region = world_westeros }
				}
				scope:completed_ruin.county = { set_county_culture = culture:westerosi_valyrian }
			}
			else_if = {
				limit = {
					culture = culture:high_valyrian
					has_game_rule = agot_hv_conversion_offshoots
					NOT = {
						scope:completed_ruin.title_province = { geographical_region = world_westeros }
					}
				}
				scope:completed_ruin.county = { set_county_culture = culture:essosi_valyrian }
			}
			else = {
				scope:completed_ruin.county = { set_county_culture = root.culture }
			}
			scope:completed_ruin.county = { set_county_faith = root.faith }
			scope:completed_ruin.county = { agot_remove_permafrost_modifiers = yes }
		}
		if = {
			limit = {
				scope:completed_ruin = title:b_castamere.title_province
			}
			scope:completed_ruin.barony = { set_capital_barony = yes }
		}
	}

	option = {
		name = agot_ruins.1000.a

		add_prestige = 1000
		scope:completed_ruin = {
			set_holding_type = castle_holding
			add_building = castle_02
		}
	}

	option = {
		name = agot_ruins.1000.b
		trigger = {
			NOR = {
				scope:completed_ruin = title:b_castamere.title_province
				scope:completed_ruin = title:b_summerhall.title_province
				scope:completed_ruin.duchy = title:d_the_wall
			}
		}

		add_prestige = 1000
		scope:completed_ruin = {
			set_holding_type = city_holding
			add_building = city_02
		}
	}

	option = {
		name = agot_ruins.1000.c
		trigger = {
			NOR = {
				scope:completed_ruin = title:b_castamere.title_province
				scope:completed_ruin = title:b_summerhall.title_province
				scope:completed_ruin.duchy = title:d_the_wall
			}
		}

		add_piety = 1000
		scope:completed_ruin = {
			set_holding_type = church_holding
			add_building = temple_02
		}
	}

	option = {
		name = agot_ruins.1000.tribal
		trigger = {
			has_government = tribal_government	
		}
		
		add_prestige = 500
		scope:completed_ruin = {
			set_holding_type = tribal_holding
			add_building = tribe_01
		}
	}
}

agot_ruins.2000 = { # Get dragon egg from restoring Summerhall
	type = character_event
	title = agot_ruins.2000.t
	desc = agot_ruins.2000.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	left_portrait = {
		character = root
		scripted_animation = mde_holding_dragon_egg_animation
	}

	artifact = {
		position = lower_right_portrait
		target = scope:newly_created_artifact
	}

	immediate = {
		if = {
			limit = {
				NAND = {
					has_game_rule = ai_can_not_get_eggs
					is_ai = yes
				}
			}
			random_list = {
				1 = {
					character:dragon_morning = { save_scope_as = dragon_parent }
					create_artifact_dragon_egg_greengrey_effect = { OWNER = root }
				}
				1 = {
					character:dragon_syrax = { save_scope_as = dragon_parent }
					character:dragon_caraxes = { save_scope_as = dragon_parent_other }
					create_artifact_dragon_egg_redblackgold_effect = { OWNER = root }
				}
			}
			set_global_variable = summerhall_egg_found
		}
	}

	option = {
		name = agot_ruins.2000.a

		trigger_event = {
			id = agot_ruins.1000
			days = { 30 60 }
		}
	}
}

agot_ruins.2001 = { # Get dragon egg from restoring Spicetown
	type = character_event
	title = agot_ruins.2001.t
	desc = agot_ruins.2001.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	left_portrait = {
		character = root
		scripted_animation = mde_holding_dragon_egg_animation
	}

	artifact = {
		position = lower_right_portrait
		target = scope:newly_created_artifact
	}

	immediate = {
		set_global_variable = moondancer_egg_found
		character:dragon_moondancer = { save_scope_as = dragon_parent }
		character:dragon_vermax = { save_scope_as = dragon_parent_other }
		create_artifact_dragon_egg_palebluepink_effect = { OWNER = root }
		scope:newly_created_artifact = { save_scope_as = spicetown_egg }
	}

	option = {
		name = agot_ruins.2001.a

		trigger_event = {
			id = agot_ruins.1000
			days = { 30 60 }
		}
		ai_chance = {
			base = 50
			modifier = {
				root.liege = {
					is_ai = no
				}
				factor = 0
			}
		}
	}
	option = {
		name = agot_ruins.2001.b

		trigger_event = {
			id = agot_ruins.1000
			days = { 30 60 }
		}
		root = { save_scope_as = egg_giver }
		ai_chance = {
			base = 50
		}
		root.liege = {
			save_scope_as = egg_reciever
			trigger_event = agot_ruins.2002
		}
	}
}

agot_ruins.2002 = { # Offer egg to liege
	type = character_event
	title = agot_ruins.2002.t
	desc = agot_ruins.2002.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	left_portrait = {
		character = scope:egg_giver
		scripted_animation = mde_holding_dragon_egg_animation
	}
	right_portrait = {
		character = scope:egg_reciever
		animation = personality_bold
	}

	artifact = {
		position = lower_right_portrait
		target = scope:spicetown_egg
	}

	immediate = {

	}

	option = {
		name = agot_ruins.2002.a
		scope:spicetown_egg = { set_owner = scope:egg_reciever }
		ai_chance = {
			base = 100
		}
	}
	option = {
		name = agot_ruins.2002.b

		
		ai_chance = {
			base = 0
		}
	}
}


agot_ruins.3000 = { # Moat Cailin Restoration Begins
	type = character_event
	title = agot_ruins.3000.t
	desc = agot_ruins.3000.d

	theme = stewardship_domain_focus
	override_background = { reference = wilderness_wetlands }

	immediate = {
		add_character_flag = rebuilding_moat_cailin
		add_character_flag = started_rebuilding_moat_cailin
	}

	right_portrait = {
		character = root
		animation = chancellor
	}

	option = {
		name = agot_ruins.3000.a
	}
}

agot_ruins.3001 = { # Moat Cailin Restoration progresses
	type = character_event
	title = agot_ruins.3001.t
	desc = agot_ruins.3001.d

	theme = stewardship_domain_focus
	override_background = { reference = wilderness_wetlands }

	immediate = {
		remove_character_flag = rebuilding_moat_cailin
		remove_character_flag = started_rebuilding_moat_cailin
	}

	right_portrait = {
		character = root
		animation = chancellor
	}

	option = {
		name = agot_ruins.3001.a
		add_piety = 150
		stress_impact = {
			cynical = miniscule_stress_impact_gain
			zealous = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			modifier = {
				has_trait = zealous
				add = 10
			}
			modifier = {
				has_trait = cynical
				add = -10
			}
		}
	}

	option = {
		name = agot_ruins.3001.b
		add_dread = major_dread_gain
		stress_impact = {
			lazy = miniscule_stress_impact_gain
			diligent = miniscule_stress_impact_loss
		}

		ai_chance = {
			base = 50
			modifier = {
				has_trait = zealous
				add = -10
			}
			modifier = {
				has_trait = cynical
				add = 10
			}
		}
	}
}

agot_ruins.3002 = { # Moat Cailin Restoration continues to the final stage
	type = character_event
	title = agot_ruins.3002.t
	desc = agot_ruins.3002.d

	theme = stewardship_domain_focus
	override_background = { reference = wilderness_wetlands }

	immediate = {
		add_character_flag = rebuilding_moat_cailin
		add_character_flag = started_rebuilding_moat_cailin
	}

	right_portrait = {
		character = root
		animation = chancellor
	}

	option = {
		name = agot_ruins.3002.a
		stress_impact = {
			shy = major_stress_impact_gain
			brave = major_stress_impact_loss
		}
	}
}

agot_ruins.3003 = { # Moat Cailin Restored
	type = character_event
	title = agot_ruins.3003.t
	desc = agot_ruins.3003.d

	theme = stewardship_domain_focus
	override_background = { reference = wilderness_wetlands }

	immediate = {
		remove_character_flag = rebuilding_moat_cailin
		remove_character_flag = started_rebuilding_moat_cailin
	}

	right_portrait = {
		character = root
		animation = chancellor
	}

	option = {
		trigger = { dynasty = dynasty:dynn_Stark }
		name = agot_ruins.3003.a_stark

		add_prestige = 1000
		dynasty = { add_dynasty_prestige = monumental_dynasty_prestige_value }

		ai_chance = {
			base = 50
			modifier = {
				dynasty = dynasty:dynn_Stark
				add = 20
			}
			modifier = {
				OR = {
					has_trait = logistician
					has_trait = unyielding_defender
				}
				add = -30
			}
			modifier = {
				has_trait = ambitious
				add = 10
			}
			modifier = {
				AND = {
					NOT = { title:h_the_iron_throne.holder ?= root }
					liege = title:h_the_iron_throne.holder
				}
				add = 10
			}
		}
	}

	option = {
		trigger = { NOT = { dynasty = dynasty:dynn_Stark } }
		name = agot_ruins.3003.a

		add_prestige = 1000
		dynasty = { add_dynasty_prestige = monumental_dynasty_prestige_value }

		ai_chance = {
			base = 50
			modifier = {
				OR = {
					has_trait = logistician
					has_trait = unyielding_defender
				}
				add = -30
			}
			modifier = {
				has_trait = ambitious
				add = 10
			}
			modifier = {
				AND = {
					NOT = { title:h_the_iron_throne.holder ?= root }
					liege = title:h_the_iron_throne.holder
				}
				add = 10
			}
		}
	}

	option = {
		name = agot_ruins.3003.b

		give_nickname = nick_agot_northern_shield
		add_legitimacy = medium_legitimacy_gain
		dynasty = { add_dynasty_prestige = monumental_dynasty_prestige_value }

		ai_chance = {
			base = 50
			modifier = {
				dynasty = dynasty:dynn_Stark
				add = -20
			}
			modifier = {
				OR = {
					has_trait = logistician
					has_trait = unyielding_defender
				}
				add = 30
			}
			modifier = {
				has_trait = ambitious
				add = -10
			}
			modifier = {
				AND = {
					NOT = { title:h_the_iron_throne.holder ?= root }
					liege = title:h_the_iron_throne.holder
				}
				add = -10
			}
		}
	}
}

agot_ruins.4000 = { # Start Second Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4000.t
	desc = agot_ruins.4000.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		add_character_flag = rebuilding_harrenhal
		add_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4000.a
	}
}

agot_ruins.4001 = { # Finish Second Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4001.t
	desc = agot_ruins.4001.desc

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		remove_character_flag = rebuilding_harrenhal
		remove_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4001.a

		ai_chance = {
			base = 25
		}
	}

	option = {
		name = agot_ruins.4001.b

		trigger = {
			OR = {
				has_trait = patient
				has_trait = diligent
				has_trait = ambitious
			}
		}
		add_stewardship_skill = 3

		ai_chance = {
			base = 25
		}
	}

	option = {
		name = agot_ruins.4001.c

		trigger = {
			OR = {
				has_trait = deceitful
				has_trait = sadistic
				has_trait = callous
			}
		}

		stress_impact = {
			compassionate = miniscule_stress_impact_gain
			honest = miniscule_stress_impact_gain
			just = miniscule_stress_impact_gain

			torturer = major_stress_impact_loss
			deceitful = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_loss
			callous = miniscule_stress_impact_loss
		}

		if = {
			limit = { NOT = { has_trait = torturer } }
			add_trait = torturer
		}

		ai_chance = {
			base = 0
			modifier = {
				ai_compassion <= low_negative_ai_value
				add = 5
			}
			modifier = {
				ai_compassion <= medium_negative_ai_value
				add = 10
			}
			modifier = {
				ai_compassion <= high_negative_ai_value
				add = 20
			}
			modifier = {
				ai_honor <= low_negative_ai_value
				add = 5
			}
			modifier = {
				ai_honor <= medium_negative_ai_value
				add = 10
			}
			modifier = {
				ai_honor <= high_negative_ai_value
				add = 20
			}
		}
	}

	option = {
		name = agot_ruins.4001.d

		trigger = {
			OR = {
				has_trait = generous
				has_trait = gregarious
				has_trait = gluttonous
				has_trait = lifestyle_reveler
			}
		}

		stress_impact = {
			lifestyle_reveler = miniscule_stress_impact_loss
			generous = miniscule_stress_impact_loss
			compassionate = miniscule_stress_impact_loss
			gregarious = miniscule_stress_impact_loss
			gluttonous = miniscule_stress_impact_loss
			sadistic = miniscule_stress_impact_gain
		}

		add_character_modifier = {
			modifier = agot_rewarded_builders
			years = 1
		}

		ai_chance = {
			base = 25
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_modifier = agot_green_man_gold }
				remove_character_modifier = agot_green_man_gold
			}
		}
	}
}

agot_ruins.4002 = { # Start Third Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4002.t
	desc = agot_ruins.4002.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		add_character_flag = rebuilding_harrenhal
		add_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		trigger = { has_trait = lazy }
		name = {
			text = agot_ruins.4002.a_lazy
		}
	}

	option = {
		trigger = { NOT = { has_trait = lazy } }
		name = {
			text = agot_ruins.4002.a
		}
	}
}

agot_ruins.4003 = { # Finish Third Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4003.t
	desc = agot_ruins.4003.desc

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		remove_character_flag = rebuilding_harrenhal
		remove_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4003.a

		ai_chance = {
			base = 20
		}
	}

	option = {
		name = agot_ruins.4003.b

		trigger = {
			trigger_if = {
				limit = {
					OR = {
						has_trait = depressed_1
						has_trait = lunatic_1
						has_trait = possessed_1
					}
				}
				always = yes
			}
			trigger_else = { always = no }
		}

		if = {
			limit = { has_trait = depressed_1 }
			remove_trait = depressed_1
		}
		if = {
			limit = { has_trait = lunatic_1 }
			remove_trait = lunatic_1
		}
		if = {
			limit = { has_trait = possessed_1 }
			remove_trait = possessed_1
		}

		ai_chance = {
			base = 20
		}
	}

	option = {
		trigger = {
			trigger_if = {
				limit = { has_trait = cynical }
				always = yes
			}
			trigger_else = { always = no }
			NOT = { has_trait = inquisitive }
		}
		name = agot_ruins.4003.c
		remove_trait = cynical
		add_trait_force_tooltip = zealous

		stress_impact = {
			base = minor_stress_impact_gain
		}

		ai_chance = {
			base = 20
		}
	}

	option = {
		name = agot_ruins.4003.d

		trigger = {
			trigger_if = {
				limit = { has_trait = paranoid }
				always = yes
			}
			trigger_else = { always = no }
			NOT = { has_trait = wrathful }
		}
		remove_trait = paranoid
		add_trait = calm

		stress_impact = {
			base = minor_stress_impact_gain
		}

		ai_chance = {
			base = 20
		}
	}

	option = {
		name = agot_ruins.4003.e

		trigger = {
			trigger_if = {
				limit = { has_trait = impatient }
				always = yes
			}
			trigger_else = { always = no }
		}
		remove_trait = impatient
		add_trait_force_tooltip = patient

		stress_impact = {
			base = minor_stress_impact_gain
		}

		ai_chance = {
			base = 20
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_modifier = agot_green_man_gold }
				remove_character_modifier = agot_green_man_gold
			}
		}
	}
}

agot_ruins.4004 = { # Start Fourth Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4004.t
	desc = agot_ruins.4004.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		add_character_flag = rebuilding_harrenhal
		add_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4004.a
		name = {
			trigger = { has_trait = cynical }
			text = agot_ruins.4004.b
		}
		name = {
			trigger = { has_trait = cynical }
			text = agot_ruins.4004.c
		}

		ai_chance = {
			base = 33
		}
	}
}

agot_ruins.4005 = { # Finish Fourth Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4005.t
	desc = agot_ruins.4005.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		remove_character_flag = rebuilding_harrenhal
		remove_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = {
			text = agot_ruins.4005.a
			trigger = {
				OR = {
					NOT = { faith.religion = religion:the_seven_religion }
					NOR = {
						has_character_modifier = patron_the_father_modifier
						has_character_modifier = patron_the_mother_modifier
						has_character_modifier = patron_the_warrior_modifier
						has_character_modifier = patron_the_smith_modifier
						has_character_modifier = patron_the_maiden_modifier
						has_character_modifier = patron_the_crone_modifier
						has_character_modifier = patron_the_stranger_modifier
					}
				}
			}
		}
		name = {
			text = agot_ruins.4005.a_father
			trigger = { has_character_modifier = patron_the_father_modifier }
		}
		name = {
			text = agot_ruins.4005.a_mother
			trigger = { has_character_modifier = patron_the_mother_modifier }
		}
		name = {
			text = agot_ruins.4005.a_warrior
			trigger = { has_character_modifier = patron_the_warrior_modifier }
		}
		name = {
			text = agot_ruins.4005.a_smith
			trigger = { has_character_modifier = patron_the_smith_modifier }
		}
		name = {
			text = agot_ruins.4005.a_maiden
			trigger = { has_character_modifier = patron_the_maiden_modifier }
		}
		name = {
			text = agot_ruins.4005.a_crone
			trigger = { has_character_modifier = patron_the_crone_modifier }
		}
		name = {
			text = agot_ruins.4005.a_stranger
			trigger = { has_character_modifier = patron_the_stranger_modifier }
		}

		add_piety = 200

		if = {
			limit = {
				NOT = { religion = religion:the_seven_religion }
				has_trait = zealous
			}
			stress_impact = {
				base = minor_stress_impact_gain
			}
		}

		ai_chance = {
			base = 40
			modifier = {
				has_trait = zealous
				add = 10
			}
		}
	}

	option = {
		trigger = { NOT = { religion = religion:the_seven_religion } }
		name = agot_ruins.4005.b
		trigger_event = agot_ruins.4100

		ai_chance = {
			base = 40
			modifier = {
				has_trait = zealous
				add = -40
			}
		}
	}

	option = {
		trigger = { NOT = { religion = religion:the_seven_religion } }
		name = agot_ruins.4005.c
		if = {
			limit = {
				number_of_personality_traits < personality_trait_limit
				NOT = { has_trait = zealous }
			}
			add_trait = zealous
		}
		add_piety_level = 1

		ai_chance = {
			base = 20
			modifier = {
				has_trait = zealous
				add = 30
			}
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_modifier = agot_green_man_gold }
				remove_character_modifier = agot_green_man_gold
			}
		}
	}
}

agot_ruins.4006 = { # Start Fifth Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4006.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { game_start_date >= 8073.7.1 }
				desc = agot_ruins.4006.d
			}
			triggered_desc = {
				trigger = { game_start_date < 8073.7.1 }
				desc = agot_ruins.4006.d_before_rhaena
			}
		}
	}

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		add_character_flag = rebuilding_harrenhal
		add_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4006.a
	}
}

agot_ruins.4007 = { # Finish Fifth Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4007.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { game_start_date >= 8073.7.1 }
				desc = agot_ruins.4007.desc
			}
			triggered_desc = {
				trigger = { game_start_date < 8073.7.1 }
				desc = agot_ruins.4007.desc_before_rhaena
			}
		}
	}
	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		remove_character_flag = rebuilding_harrenhal
		remove_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4007.a
		add_prestige = 1000

		ai_chance = {
			base = 25
		}
	}

	option = {
		trigger = {
			OR = {
				has_trait = compassionate
				has_trait = humble
			}
			game_start_date >= 8073.7.1
		}
		name = agot_ruins.4007.b

		if = {
			limit = { NOT = { has_trait = gallant } }
			add_trait = gallant
		}

		stress_impact = {
			sadistic = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			humble = minor_stress_impact_loss
			gallant = major_stress_impact_loss
		}

		ai_chance = {
			base = 25
			modifier = {
				has_trait = knight
				add = 10
			}
		}
	}

	option = {
		name = {
			trigger = { game_start_date >= 8073.7.1 }
			text = agot_ruins.4007.c
		}
		name = {
			trigger = { game_start_date < 8073.7.1 }
			text = agot_ruins.4007.c_before_rhaena
		}
		if = {
			limit = { NOT = { has_trait = reclusive } }
			add_trait = reclusive
		}
		stress_impact = { reclusive = major_stress_impact_loss }
		ai_chance = {
			base = 25
			modifier = {
				has_trait = gregarious
				add = -10
			}
			modifier = {
				has_trait = brave
				add = -10
			}
		}
	}

	option = {
		name = {
			trigger = { game_start_date >= 8073.7.1 }
			text = agot_ruins.4007.d
		}
		name = {
			trigger = { game_start_date < 8073.7.1 }
			text = agot_ruins.4007.d_before_rhaena
		}
		if = {
			limit = { NOT = { has_trait = witch } }
			add_trait = witch
		}
		else = {
			add_learning_skill = 3
			custom_tooltip = agot_ruins.4007.d_tt
		}

		ai_chance = {
			base = 0
			modifier = {
				has_trait = witch
				add = 25
			}
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_modifier = agot_green_man_gold }
				remove_character_modifier = agot_green_man_gold
			}
		}
	}
}

agot_ruins.4008 = { # Start Sixth Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4008.t
	desc = agot_ruins.4008.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		add_character_flag = rebuilding_harrenhal
		add_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4008.a
	}
}

agot_ruins.4009 = { # Finish Sixth Harrenhal reconstruction
	type = character_event
	title = agot_ruins.4009.t
	desc = agot_ruins.4009.desc

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		remove_character_flag = rebuilding_harrenhal
		remove_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4009.a
		add_prestige = 1000

		ai_chance = {
			base = 30
		}
	}

	option = {
		trigger = {
			trigger_if = {
				limit = { has_trait = lazy }
				always = yes
			}
			trigger_else = { always = no }
		}
		name = agot_ruins.4009.b

		remove_trait = lazy
		add_trait_force_tooltip = diligent

		ai_chance = {
			base = 20
		}
	}

	option = {
		name = agot_ruins.4009.c
		trigger = { NOT = { has_trait = fire_obsessed } }
		add_trait = fire_obsessed

		ai_chance = {
			base = 30
		}
	}

	option = {
		trigger = {
			trigger_if = {
				limit = { has_trait = ambitious }
				always = yes
			}
			trigger_else = { always = no }
		}
		name = agot_ruins.4009.d
		remove_trait = ambitious
		add_trait_force_tooltip = content

		stress_impact = {
			sadistic = miniscule_stress_impact_gain
		}

		ai_chance = {
			base = 20
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_modifier = agot_green_man_gold }
				remove_character_modifier = agot_green_man_gold
			}
		}
	}
}

agot_ruins.4010 = { # Start Final Restoration
	type = character_event
	title = agot_ruins.4010.t
	desc = agot_ruins.4010.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		add_character_flag = rebuilding_harrenhal
		add_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = {
			text = agot_ruins.4010.a
		}
		name = {
			trigger = { has_trait = arrogant }
			text = agot_ruins.4010.a_arrogant
		}
	}
}

agot_ruins.4011 = { # Finish Final Restoration
	type = character_event
	title = agot_ruins.4011.t
	desc = agot_ruins.4011.desc

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	immediate = {
		remove_character_flag = rebuilding_harrenhal
		remove_character_flag = started_rebuilding_harrenhal
	}

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = agot_ruins.4011.a
		add_prestige = 1000
		add_legitimacy = major_legitimacy_gain
		dynasty = { add_dynasty_prestige = 750 }
		add_dread = 25

		ai_chance = {
			base = 20
		}
	}

	option = {
		name = {
			text = agot_ruins.4011.b
		}
		name = {
			trigger = { dynasty = dynasty:dynn_Hoare }
			text = agot_ruins.4011.b_hoare
		}
		give_nickname = nick_agot_black_builder
		add_prestige = 1000
		add_legitimacy = major_legitimacy_gain
		if = {
			limit = { dynasty = dynasty:dynn_Hoare }
			dynasty = { add_dynasty_prestige = 1500 }
		}
		else = { dynasty = { add_dynasty_prestige = 750 } }
		add_dread = 10

		ai_chance = {
			base = 25
			modifier = {
				dynasty = dynasty:dynn_Hoare
				add = 75
			}
			modifier = {
				dynasty = dynasty:dynn_Targaryen
				add = -25
			}
		}
	}

	option = {
		trigger = {
			OR = {
				has_trait = intellect_good_1
				has_trait = intellect_good_2
				has_trait = intellect_good_3
			}
		}
		name = agot_ruins.4011.c
		if = {
			limit = { NOT = { has_trait = military_engineer } }
			add_trait = military_engineer
		}
		else = {
			add_trait_xp = {
				trait = military_engineer
				value = 33
			}
		}
		add_prestige = 1000
		add_legitimacy = major_legitimacy_gain
		dynasty = { add_dynasty_prestige = 750 }

		ai_chance = {
			base = 25
		}
	}

	option = {
		trigger = { has_trait = dragonrider }
		name = agot_ruins.4011.d
		add_trait_xp = {
			trait = dragonrider
			track = dragon_bond
			value = 15
		}
		add_dread = 100
		add_prestige = 1000
		dynasty = { add_dynasty_prestige = 2000 }

		ai_chance = {
			base = 25
			modifier = {
				dynasty = dynasty:dynn_Hoare
				add = -25
			}
			modifier = {
				dynasty = dynasty:dynn_Targaryen
				add = 25
			}
		}
	}

	option = {
		trigger = { has_trait = dragonslayer }
		name = agot_ruins.4011.e
		add_dread = 100
		if = {
			limit = { NOT = { has_trait = strong } }
			add_trait = strong
		}
		add_prestige = 1000
		dynasty = { add_dynasty_prestige = 2000 }

		ai_chance = {
			base = 25
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_modifier = agot_green_man_gold }
				remove_character_modifier = agot_green_man_gold
			}
		}
	}
}

# I wanted to make a Selection Box to choose what faith the player wanted so it wasn't just button spam but I could not figure GUI out
agot_ruins.4100 = { # Convert to any Faith of the Seven faith
	type = character_event
	title = agot_ruins.4005.t
	desc = agot_ruins.4005.d

	theme = stewardship_domain_focus
	override_background = { reference = army_camp }

	right_portrait = {
		character = root
		animation = personality_cynical
	}

	option = {
		name = the_seven_main
		set_character_faith = faith:fots_seven
		ai_chance = { base = 10 }
	}

	option = {
		name = servants_of_the_star
		set_character_faith = faith:fots_pure
		ai_chance = { base = 10 }
	}

	option = {
		trigger = { character:Targaryen_82 = { exists = yes } }
		name = baelorism
		set_character_faith = faith:fots_blessed
		ai_chance = { base = 10 }
	}

	option = {
		name = warring_star
		set_character_faith = faith:fots_scourged
		ai_chance = { base = 10 }
	}

	option = {
		trigger = { religion = religion:the_pact_religion }
		name = weirwood_of_the_seven
		set_character_faith = faith:fots_oldnew
		ai_chance = { base = 10 }
	}

	option = {
		name = hugor_start
		set_character_faith = faith:fots_stars
		ai_chance = { base = 10 }
	}

	option = {
		name = original_fots
		set_character_faith = faith:fots_axe
		ai_chance = { base = 10 }
	}

	option = {
		name = agot_ruins.4100.a
		trigger_event = agot_ruins.4005
		ai_chance = { base = 10 }
	}
}

scripted_trigger has_lost_loved_one = {
	OR = {
		has_memory_type = soulmate_died
		has_memory_type = lover_died
		has_memory_type = best_friend_died
		has_memory_type = friend_died
	}
}

scripted_effect get_lost_loved_one = {
	random_memory = {
		limit = { has_lost_loved_one = yes }
		memory_participant:dead_relation = { save_scope_as = deceased_character }
	}
}

scripted_effect get_constructor = {
	if = {
		limit = { $PROVINCE$ = { exists = var:constructor } }
		$PROVINCE$ = { var:constructor = { save_scope_as = restoration_constructor } }
	}
}

agot_ruins.9998 = {
	hidden = yes

	immediate = {
		if = {
			limit = { has_character_flag = cancelled_cailin }
			title:c_moat_cailin.holder = {
				get_lost_loved_one = yes
				get_constructor = { PROVINCE = province:1650 }
				remove_character_flag = cancelled_cailin
			}
		}
		else_if = {
			limit = { has_character_flag = cancelled_harrenhal }
			title:c_harrenhal.holder = {
				get_lost_loved_one = yes
				get_constructor = { PROVINCE = province:1934 }
				remove_character_flag = cancelled_harrenhal
			}
		}
		trigger_event = agot_ruins.9999
	}
}

agot_ruins.9999 = { # Cancel great ruin restoration
	type = character_event
	title = agot_ruins.9999.t

	desc = {
		desc = agot_ruins.9999.opening

		random_valid = {
			triggered_desc = { # Recent Death Memory
				trigger = {
					exists = scope:deceased_character

					any_memory = {
						OR = {
							has_memory_type = friend_died
							has_memory_type = best_friend_died
							has_memory_type = lover_died
							has_memory_type = soulmate_died
						}
						memory_age_years < 3
					}
				}
				desc = agot_ruins.9999.recent_loss
			}

			triggered_desc = { # At war
				trigger = {
					is_at_war = yes
				}
				desc = agot_ruins.9999.at_war
			}

			triggered_desc = { # Less than 100 gold
				trigger = {
					AND = {
						root.gold < 100
						root.gold > 0
						has_character_flag = started_rebuilding_moat_cailin
					}
				}
				desc = agot_ruins.9999.poor
			}

			triggered_desc = { # Bankrupt
				trigger = {
					AND = {
						root.gold < 0
						has_character_flag = started_rebuilding_moat_cailin
					}
				}
				desc = agot_ruins.9999.bankrupt
			}

			triggered_desc = { # Is Lazy
				trigger = {
					has_trait = lazy
				}
				desc = agot_ruins.9999.lazy
			}

			triggered_desc = { # Is Greedy
				trigger = {
					AND = {
						has_trait = greedy
						has_character_flag = started_rebuilding_moat_cailin
					}
				}
				desc = agot_ruins.9999.greedy
			}

			triggered_desc = { # Is Fickle
				trigger = {
					has_trait = fickle
				}
				desc = agot_ruins.9999.fickle
			}

			triggered_desc = { # Is Paranoid
				trigger = {
					has_trait = paranoid
				}
				desc = agot_ruins.9999.paranoid
			}

			triggered_desc = { # Is Impatient
				trigger = {
					has_trait = impatient
				}
				desc = agot_ruins.9999.impatient
			}

			triggered_desc = { # Relative started the project
				trigger = {
					AND = {
						NOT = {
							has_character_flag = started_rebuilding_moat_cailin
						}
						scope:restoration_constructor.dynasty = root.dynasty
					}
				}
				desc = agot_ruins.9999.relation
			}

			triggered_desc = { # Someone else took over
				trigger = {
					NOT = {
						has_character_flag = started_rebuilding_moat_cailin
						scope:restoration_constructor.dynasty = root.dynasty
					}
				}
				desc = agot_ruins.9999.someone_else
			}

			triggered_desc = { # No stress
				trigger = {
					stress < 100
				}
				desc = agot_ruins.9999.no_stress
			}

			triggered_desc = { # Level one stress
				trigger = {
					AND = {
						stress >= 100
						stress < 200
					}
				}
				desc = agot_ruins.9999.one_stress
			}

			triggered_desc = { # Level two stress
				trigger = {
					AND = {
						stress >= 200
						stress < 300
					}
				}
				desc = agot_ruins.9999.two_stress
			}

			triggered_desc = { # Level three stress
				trigger = {
					AND = {
						stress >= 300
					}
				}
				desc = agot_ruins.9999.three_stress
			}
		}
		desc = agot_ruins.9999.outro
	}

	theme = stewardship_domain_focus

	override_background = {
		trigger = { has_character_flag = rebuilding_moat_cailin }
		reference = wilderness_wetlands
	}

	right_portrait = {
		character = root
		animation = sadness
	}

	option = {
		name = agot_ruins.9999.a
		if = {
			limit = { has_character_flag = rebuilding_moat_cailin }
			remove_character_flag = rebuilding_moat_cailin
			province:1650 = { remove_variable = constructor }

			if = {
				limit = { has_character_flag = started_rebuilding_moat_cailin }
				remove_character_flag = started_rebuilding_moat_cailin
			}
		}

		if = {
			limit = { has_character_flag = rebuilding_harrenhal }
			remove_character_flag = rebuilding_harrenhal
			province:1934 = { remove_variable = constructor }

			if = {
				limit = { has_character_flag = started_rebuilding_harrenhal }
				remove_character_flag = started_rebuilding_harrenhal
			}
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = { has_character_modifier = agot_green_man_gold }
				remove_character_modifier = agot_green_man_gold
			}
		}
	}
}