﻿namespace = RE_hold_court

RE_hold_court.1001 = {
	type = court_event
	title = RE_hold_court.1001.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_diplo_first_flag
						scope:diplomat = cp:councillor_chancellor
					}
				}
				desc = RE_hold_court.1001.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:diplomat = cp:councillor_chancellor
				}
				desc = RE_hold_court.1001.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_diplo_first_flag
				}
				desc = RE_hold_court.1001.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1001.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:diplomat
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:diplomat = {
				group = petitioners_group
				animation = chancellor
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_warlike
				has_court_type = court_scholarly
				has_court_type = court_administrative
				has_court_type = court_intrigue
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_diplo_first_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_chancellor
				cp:councillor_chancellor = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_chancellor = { save_scope_as = diplomat }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:diplomat }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = diplomacy
						multiplier = 5
					}
				}
				save_scope_as = diplomat
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:diplomat }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_diplomacy
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = diplomat
				}
				scope:diplomat = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1001.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			family_first = medium_stress_gain
			august = medium_stress_loss
			arrogant = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_first_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_first_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1001.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			family_first = minor_stress_gain
			august = minor_stress_loss
			arrogant = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_first_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_first_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1001.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			just = medium_stress_loss
			humble = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_first_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_first_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1001.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			family_first = minor_stress_loss
			arrogant = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_first_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_first_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1001.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			family_first = medium_stress_loss
			arrogant = medium_stress_loss
			arbitrary = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_first_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_first_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_first_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_first_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_diplo_first_flag
		}
		if = {
			limit = { scope:diplomat = { has_character_flag = REtemp } }
			scope:diplomat = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1002 = {
	type = court_event
	title = RE_hold_court.1002.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_diplo_sec_flag
						scope:diplomat = cp:councillor_chancellor
					}
				}
				desc = RE_hold_court.1002.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:diplomat = cp:councillor_chancellor
				}
				desc = RE_hold_court.1002.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_diplo_sec_flag
				}
				desc = RE_hold_court.1002.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1002.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:diplomat
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:diplomat = {
				group = petitioners_group
				animation = chancellor
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_warlike
				has_court_type = court_scholarly
				has_court_type = court_administrative
				has_court_type = court_intrigue
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_diplo_sec_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_chancellor
				cp:councillor_chancellor = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_chancellor = { save_scope_as = diplomat }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:diplomat }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = diplomacy
						multiplier = 5
					}
				}
				save_scope_as = diplomat
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:diplomat }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_diplomacy
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = diplomat
				}
				scope:diplomat = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1002.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			just = major_stress_gain
			arrogant = major_stress_loss
			humble = medium_stress_gain
			callous = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_sec_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_sec_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1002.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			just = minor_stress_gain
			arrogant = medium_stress_loss
			humble = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_sec_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_sec_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1002.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			calm = minor_stress_loss
			patient = minor_stress_loss
			impatient = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_sec_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_sec_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1002.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = minor_stress_gain
			humble = minor_stress_loss
			family_first = minor_stress_loss
			compassionate = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_sec_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_sec_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1002.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = major_stress_gain
			humble = medium_stress_loss
			family_first = medium_stress_loss
			compassionate = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_sec_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_sec_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_sec_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_sec_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_diplo_sec_flag
		}
		if = {
			limit = { scope:diplomat = { has_character_flag = REtemp } }
			scope:diplomat = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1003 = {
	type = court_event
	title = RE_hold_court.1003.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_diplo_tri_flag
						scope:diplomat = cp:councillor_chancellor
					}
				}
				desc = RE_hold_court.1003.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:diplomat = cp:councillor_chancellor
				}
				desc = RE_hold_court.1003.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_diplo_tri_flag
				}
				desc = RE_hold_court.1003.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1003.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:diplomat
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:diplomat = {
				group = petitioners_group
				animation = chancellor
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_warlike
				has_court_type = court_scholarly
				has_court_type = court_administrative
				has_court_type = court_intrigue
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_diplo_tri_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_chancellor
				cp:councillor_chancellor = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_chancellor = { save_scope_as = diplomat }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:diplomat }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = diplomacy
						multiplier = 5
					}
				}
				save_scope_as = diplomat
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:diplomat }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_diplomacy
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = diplomat
				}
				scope:diplomat = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1003.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diplomat = minor_stress_loss
			craven = medium_stress_gain
			arrogant = minor_stress_loss
			greedy = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_tri_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_tri_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1003.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diplomat = medium_stress_loss
			craven = minor_stress_gain
			greedy = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_tri_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_tri_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1003.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diplomat = major_stress_loss
			august = minor_stress_loss
			gregarious = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_tri_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_tri_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1003.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			august = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_tri_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_tri_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1003.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			august = major_stress_loss
			diplomat = minor_stress_gain
			gregarious = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_tri_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_tri_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.diplomacy >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.diplomacy >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.diplomacy >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_diplo_tri_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_diplo_tri_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_diplo_tri_flag
		}
		if = {
			limit = { scope:diplomat = { has_character_flag = REtemp } }
			scope:diplomat = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1011 = {
	type = court_event
	title = RE_hold_court.1011.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_mart_first_flag
						scope:RE_warrior = cp:councillor_marshal
					}
				}
				desc = RE_hold_court.1011.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_warrior = cp:councillor_marshal
				}
				desc = RE_hold_court.1011.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_mart_first_flag
				}
				desc = RE_hold_court.1011.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1011.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_warrior
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_warrior = {
				group = petitioners_group
				animation = marshal
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_administrative
				has_court_type = court_intrigue
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_mart_first_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_marshal
				cp:councillor_marshal = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_marshal = { save_scope_as = RE_warrior }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_warrior }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = martial
						multiplier = 5
					}
				}
				save_scope_as = RE_warrior
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_warrior }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_martial
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_warrior
				}
				scope:RE_warrior = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1011.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			wrathful = medium_stress_gain
			calm = minor_stress_loss
			craven = medium_stress_loss
			brave = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_first_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_first_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1011.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			wrathful = minor_stress_gain
			craven = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_first_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_first_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1011.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			overseer = minor_stress_loss
			strategist = minor_stress_loss
			diligent = minor_stress_loss
			impatient = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_first_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_first_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1011.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			wrathful = minor_stress_loss
			craven = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_first_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_first_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1011.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			wrathful = medium_stress_loss
			patient = minor_stress_gain
			craven = major_stress_gain
			brave = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_first_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_first_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_first_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_first_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_mart_first_flag
		}
		if = {
			limit = { scope:RE_warrior = { has_character_flag = REtemp } }
			scope:RE_warrior = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1012 = {
	type = court_event
	title = RE_hold_court.1012.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_mart_sec_flag
						scope:RE_warrior = cp:councillor_marshal
					}
				}
				desc = RE_hold_court.1012.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_warrior = cp:councillor_marshal
				}
				desc = RE_hold_court.1012.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_mart_sec_flag
				}
				desc = RE_hold_court.1012.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1012.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_warrior
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_warrior = {
				group = petitioners_group
				animation = marshal
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_administrative
				has_court_type = court_intrigue
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_mart_sec_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_marshal
				cp:councillor_marshal = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_marshal = { save_scope_as = RE_warrior }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_warrior }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = martial
						multiplier = 5
					}
				}
				save_scope_as = RE_warrior
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_warrior }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_martial
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_warrior
				}
				scope:RE_warrior = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1012.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = medium_stress_loss
			craven = minor_stress_gain
			brave = medium_stress_loss
			gallant = medium_stress_loss
			strategist = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_sec_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_sec_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1012.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = minor_stress_loss
			brave = minor_stress_loss
			gallant = minor_stress_loss
			strategist = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_sec_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_sec_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1012.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diligent = minor_stress_loss
			strategist = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_sec_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_sec_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1012.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			gallant = minor_stress_loss
			cynical = minor_stress_loss
			strategist = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_sec_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_sec_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1012.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			gallant = medium_stress_loss
			cynical = medium_stress_loss
			strategist = major_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_sec_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_sec_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_sec_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_sec_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_mart_sec_flag
		}
		if = {
			limit = { scope:RE_warrior = { has_character_flag = REtemp } }
			scope:RE_warrior = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1013 = {
	type = court_event
	title = RE_hold_court.1013.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_mart_tri_flag
						scope:RE_warrior = cp:councillor_marshal
					}
				}
				desc = RE_hold_court.1013.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_warrior = cp:councillor_marshal
				}
				desc = RE_hold_court.1013.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_mart_tri_flag
				}
				desc = RE_hold_court.1013.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1013.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_warrior
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_warrior = {
				group = petitioners_group
				animation = marshal
			}
		}
	}
	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_administrative
				has_court_type = court_intrigue
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_mart_tri_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_marshal
				cp:councillor_marshal = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_marshal = { save_scope_as = RE_warrior }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_warrior }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = martial
						multiplier = 5
					}
				}
				save_scope_as = RE_warrior
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_warrior }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_martial
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_warrior
				}
				scope:RE_warrior = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1013.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			fickle = medium_stress_loss
			stubborn = minor_stress_gain
			paranoid = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_tri_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_tri_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1013.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			fickle = minor_stress_loss
			paranoid = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_tri_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_tri_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1013.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			strategist = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_tri_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_tri_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1013.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			stubborn = minor_stress_loss
			paranoid = minor_stress_gain
			brave = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_tri_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_tri_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1013.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			stubborn = medium_stress_loss
			paranoid = medium_stress_gain
			brave = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_tri_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_tri_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.martial >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.martial >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.martial >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_mart_tri_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_mart_tri_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_mart_tri_flag
		}
		if = {
			limit = { scope:RE_warrior = { has_character_flag = REtemp } }
			scope:RE_warrior = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1021 = {
	type = court_event
	title = RE_hold_court.1021.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_stew_first_flag
						scope:RE_bobuilder = cp:councillor_steward
					}
				}
				desc = RE_hold_court.1021.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_bobuilder = cp:councillor_steward
				}
				desc = RE_hold_court.1021.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_stew_first_flag
				}
				desc = RE_hold_court.1021.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1021.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_bobuilder
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_bobuilder = {
				group = petitioners_group
				animation = steward
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_warlike
				has_court_type = court_intrigue
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_stew_first_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_steward
				cp:councillor_steward = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_steward = { save_scope_as = RE_bobuilder }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_bobuilder }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = stewardship
						multiplier = 5
					}
				}
				save_scope_as = RE_bobuilder
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_bobuilder }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_stewardship
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_bobuilder
				}
				scope:RE_bobuilder = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1021.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = medium_stress_gain
			diligent = minor_stress_loss
			avaricious = minor_stress_gain
			administrator = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_first_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_first_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1021.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = minor_stress_gain
			administrator = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_first_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_first_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1021.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			patient = minor_stress_loss
			calm = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_first_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_first_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1021.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = minor_stress_loss
			generous = minor_stress_gain
			avaricious = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_first_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_first_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1021.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = medium_stress_loss
			generous = medium_stress_gain
			arrogant = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_first_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_first_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_first_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_first_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_stew_first_flag
		}
		if = {
			limit = { scope:RE_bobuilder = { has_character_flag = REtemp } }
			scope:RE_bobuilder = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1022 = {
	type = court_event
	title = RE_hold_court.1022.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_stew_sec_flag
						scope:RE_bobuilder = cp:councillor_steward
					}
				}
				desc = RE_hold_court.1022.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_bobuilder = cp:councillor_steward
				}
				desc = RE_hold_court.1022.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_stew_sec_flag
				}
				desc = RE_hold_court.1022.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1022.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_bobuilder
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_bobuilder = {
				group = petitioners_group
				animation = steward
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_warlike
				has_court_type = court_intrigue
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_stew_sec_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_steward
				cp:councillor_steward = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_steward = { save_scope_as = RE_bobuilder }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_bobuilder }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = stewardship
						multiplier = 5
					}
				}
				save_scope_as = RE_bobuilder
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_bobuilder }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_stewardship
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_bobuilder
				}
				scope:RE_bobuilder = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1022.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = medium_stress_loss
			impatient = medium_stress_loss
			architect = medium_stress_loss
			just = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_sec_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_sec_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1022.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = minor_stress_loss
			impatient = minor_stress_loss
			architect = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_sec_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_sec_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1022.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			just = minor_stress_loss
			diligent = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_sec_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_sec_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1022.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			brave = minor_stress_loss
			wrathful = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_sec_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_sec_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1022.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			brave = medium_stress_loss
			wrathful = medium_stress_loss
			calm = minor_stress_gain
			craven = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_sec_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_sec_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_sec_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_sec_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_stew_sec_flag
		}
		if = {
			limit = { scope:RE_bobuilder = { has_character_flag = REtemp } }
			scope:RE_bobuilder = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1023 = {
	type = court_event
	title = RE_hold_court.1023.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_stew_tri_flag
						scope:RE_bobuilder = cp:councillor_steward
					}
				}
				desc = RE_hold_court.1023.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_bobuilder = cp:councillor_steward
				}
				desc = RE_hold_court.1023.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_stew_tri_flag
				}
				desc = RE_hold_court.1023.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1023.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_bobuilder
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_bobuilder = {
				group = petitioners_group
				animation = steward
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_warlike
				has_court_type = court_intrigue
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_stew_tri_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_steward
				cp:councillor_steward = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_steward = { save_scope_as = RE_bobuilder }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_bobuilder }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = stewardship
						multiplier = 5
					}
				}
				save_scope_as = RE_bobuilder
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_bobuilder }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_stewardship
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_bobuilder
				}
				scope:RE_bobuilder = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1023.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = medium_stress_loss
			generous = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_tri_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_tri_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1023.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = minor_stress_loss
			generous = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_tri_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_tri_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1023.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			administrator = minor_stress_loss
			avaricious = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_tri_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_tri_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1023.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = minor_stress_loss
			generous = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_tri_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_tri_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1023.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			greedy = medium_stress_loss
			generous = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_tri_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_tri_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.stewardship >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.stewardship >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.stewardship >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_stew_tri_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_stew_tri_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_stew_tri_flag
		}
		if = {
			limit = { scope:RE_bobuilder = { has_character_flag = REtemp } }
			scope:RE_bobuilder = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1031 = {
	type = court_event
	title = RE_hold_court.1031.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_intr_first_flag
						scope:RE_sneaky = cp:councillor_spymaster
					}
				}
				desc = RE_hold_court.1031.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_sneaky = cp:councillor_spymaster
				}
				desc = RE_hold_court.1031.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_intr_first_flag
				}
				desc = RE_hold_court.1031.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1031.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_sneaky
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_sneaky = {
				group = petitioners_group
				animation = spymaster
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_warlike
				has_court_type = court_administrative
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_intr_first_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_spymaster = { save_scope_as = RE_sneaky }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_sneaky }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = intrigue
						multiplier = 5
					}
				}
				save_scope_as = RE_sneaky
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_sneaky }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_intrigue
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_sneaky
				}
				scope:RE_sneaky = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1031.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			paranoid = medium_stress_gain
			craven = medium_stress_gain
			deceitful = minor_stress_gain
			vengeful = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_first_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_first_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1031.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			paranoid = minor_stress_gain
			craven = minor_stress_gain
			vengeful = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_first_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_first_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1031.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			deceitful = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_first_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_first_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1031.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			paranoid = minor_stress_loss
			impatient = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_first_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_first_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1031.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			paranoid = medium_stress_loss
			impatient = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_first_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_first_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_first_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_first_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_intr_first_flag
		}
		if = {
			limit = { scope:RE_sneaky = { has_character_flag = REtemp } }
			scope:RE_sneaky = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1032 = {
	type = court_event
	title = RE_hold_court.1032.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_intr_sec_flag
						scope:RE_sneaky = cp:councillor_spymaster
					}
				}
				desc = RE_hold_court.1032.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_sneaky = cp:councillor_spymaster
				}
				desc = RE_hold_court.1032.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_intr_sec_flag
				}
				desc = RE_hold_court.1032.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1032.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_sneaky
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_sneaky = {
				group = petitioners_group
				animation = spymaster
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_warlike
				has_court_type = court_administrative
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_intr_sec_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_spymaster = { save_scope_as = RE_sneaky }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_sneaky }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = intrigue
						multiplier = 5
					}
				}
				save_scope_as = RE_sneaky
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_sneaky }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_intrigue
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_sneaky
				}
				scope:RE_sneaky = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1032.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			shy = medium_stress_gain
			lustful = minor_stress_loss
			gregarious = medium_stress_loss
			seducer = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_sec_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_sec_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1032.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			shy = minor_stress_gain
			gregarious = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_sec_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_sec_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1032.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			schemer = medium_stress_loss
			deceitful = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_sec_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_sec_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1032.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			callous = minor_stress_loss
			sadistic = minor_stress_loss
			compassionate = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_sec_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_sec_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1032.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			callous = medium_stress_loss
			sadistic = medium_stress_loss
			compassionate = major_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_sec_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_sec_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_sec_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_sec_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_intr_sec_flag
		}
		if = {
			limit = { scope:RE_sneaky = { has_character_flag = REtemp } }
			scope:RE_sneaky = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1033 = {
	type = court_event
	title = RE_hold_court.1033.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_intr_tri_flag
						scope:RE_sneaky = cp:councillor_spymaster
					}
				}
				desc = RE_hold_court.1033.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_sneaky = cp:councillor_spymaster
				}
				desc = RE_hold_court.1033.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_intr_tri_flag
				}
				desc = RE_hold_court.1033.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1033.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_sneaky
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_sneaky = {
				group = petitioners_group
				animation = spymaster
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_scholarly
				has_court_type = court_warlike
				has_court_type = court_administrative
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_intr_tri_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_spymaster
				cp:councillor_spymaster = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_spymaster = { save_scope_as = RE_sneaky }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_sneaky }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = intrigue
						multiplier = 5
					}
				}
				save_scope_as = RE_sneaky
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_sneaky }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_intrigue
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_sneaky
				}
				scope:RE_sneaky = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1033.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			callous = minor_stress_loss
			sadistic = medium_stress_loss
			compassionate = major_stress_gain
			torturer = minor_stress_loss
			arrogant = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_tri_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_tri_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1033.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			sadistic = minor_stress_loss
			compassionate = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_tri_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_tri_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1033.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			just = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_tri_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_tri_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1033.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			sadistic = minor_stress_gain
			compassionate = minor_stress_loss
			forgiving = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_tri_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_tri_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1033.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			sadistic = medium_stress_gain
			compassionate = medium_stress_loss
			forgiving = medium_stress_loss
			patient = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_tri_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_tri_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.intrigue >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.intrigue >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.intrigue >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_intr_tri_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_intr_tri_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_intr_tri_flag
		}
		if = {
			limit = { scope:RE_sneaky = { has_character_flag = REtemp } }
			scope:RE_sneaky = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1041 = {
	type = court_event
	title = RE_hold_court.1041.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_lear_first_flag
						scope:RE_smartypants = cp:councillor_court_chaplain
					}
				}
				desc = RE_hold_court.1041.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_smartypants = cp:councillor_court_chaplain
				}
				desc = RE_hold_court.1041.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_lear_first_flag
				}
				desc = RE_hold_court.1041.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1041.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_smartypants
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_smartypants = {
				group = petitioners_group
				animation = chaplain
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_intrigue
				has_court_type = court_warlike
				has_court_type = court_administrative
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_lear_first_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_court_chaplain = { save_scope_as = RE_smartypants }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_smartypants }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = learning
						multiplier = 5
					}
				}
				save_scope_as = RE_smartypants
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_smartypants }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_learning
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_smartypants
				}
				scope:RE_smartypants = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1041.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diligent = medium_stress_loss
			lazy = major_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_first_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_first_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1041.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diligent = minor_stress_loss
			lazy = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_first_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_first_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1041.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			gregarious = minor_stress_loss
			calm = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_first_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_first_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1041.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diligent = medium_stress_gain
			lazy = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_first_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_first_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1041.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			diligent = major_stress_gain
			lazy = major_stress_loss
			scholar = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_first_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_first_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_first_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_first_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_lear_first_flag
		}
		if = {
			limit = { scope:RE_smartypants = { has_character_flag = REtemp } }
			scope:RE_smartypants = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1042 = {
	type = court_event
	title = RE_hold_court.1042.t
	desc = { 
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_lear_sec_flag
						scope:RE_smartypants = cp:councillor_court_chaplain
					}
				}
				desc = RE_hold_court.1042.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_smartypants = cp:councillor_court_chaplain
				}
				desc = RE_hold_court.1042.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_lear_sec_flag
				}
				desc = RE_hold_court.1042.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1042.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_smartypants
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_smartypants = {
				group = petitioners_group
				animation = chaplain
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_intrigue
				has_court_type = court_warlike
				has_court_type = court_administrative
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_lear_sec_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_court_chaplain = { save_scope_as = RE_smartypants }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_smartypants }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = learning
						multiplier = 5
					}
				}
				save_scope_as = RE_smartypants
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_smartypants }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_learning
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_smartypants
				}
				scope:RE_smartypants = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1042.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = medium_stress_loss
			humble = medium_stress_gain
			shy = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_sec_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_sec_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1042.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = minor_stress_loss
			humble = minor_stress_gain
			shy = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_sec_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_sec_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1042.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			just = medium_stress_loss
			calm = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_sec_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_sec_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1042.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = medium_stress_gain
			humble = minor_stress_loss
			shy = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_sec_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_sec_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1042.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			arrogant = major_stress_gain
			humble = medium_stress_loss
			shy = medium_stress_loss
			theologian = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_sec_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_sec_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_sec_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_sec_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_lear_sec_flag
		}
		if = {
			limit = { scope:RE_smartypants = { has_character_flag = REtemp } }
			scope:RE_smartypants = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}

RE_hold_court.1043 = {
	type = court_event
	title = RE_hold_court.1043.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					AND = {
						has_character_flag = RE_lear_tri_flag
						scope:RE_smartypants = cp:councillor_court_chaplain
					}
				}
				desc = RE_hold_court.1043.desc_regcont
			}
			triggered_desc = {
				trigger = {
					scope:RE_smartypants = cp:councillor_court_chaplain
				}
				desc = RE_hold_court.1043.desc_regnew
			}
			triggered_desc = {
				trigger = {
					has_character_flag = RE_lear_tri_flag
				}
				desc = RE_hold_court.1043.desc_irregcont
			}
			triggered_desc = {
				trigger = {
					always = yes
				}
				desc = RE_hold_court.1043.desc_irregnew
			}	
		}
	}
	theme = realm
	court_scene = {
		button_position_character = scope:RE_smartypants
		court_event_force_open = yes
		show_timeout_info = no
		should_pause_time = yes
		roles = {
			scope:RE_smartypants = {
				group = petitioners_group
				animation = chaplain
			}
		}
	}

	widget = {
		gui = "event_window_widget_event_chain_progress"
		container = "custom_widgets_container"
		controller = event_chain_progress
	}

	weight_multiplier = {
		base = 3

		modifier = {
			factor = 0
			OR = {
				has_court_type = court_diplomatic
				has_court_type = court_intrigue
				has_court_type = court_warlike
				has_court_type = court_administrative
				has_court_type = court_tribal
			}
		}
		
		modifier = {
			add = -2
			has_character_flag = RE_lear_tri_flag
		}
	}

	immediate = {
		if = {
			limit = {
				exists = cp:councillor_court_chaplain
				cp:councillor_court_chaplain = {
					is_available_ai_adult = yes
				}
			}
			cp:councillor_court_chaplain = { save_scope_as = RE_smartypants }
		}
		if = {
			limit = { 
				AND = { 
					NOT = { exists = scope:RE_smartypants }
					any_courtier = {
						is_available_ai_adult = yes
					}
				}
			}
			random_courtier = {
				limit = {
					is_available_ai_adult = yes
				}
				weight = {
					base = 1
					compare_modifier = {
						value = learning
						multiplier = 5
					}
				}
				save_scope_as = RE_smartypants
				court_event_character_flag_effect = yes
			}
		}
		if = {
			limit = { 
				NOT = { exists = scope:RE_smartypants }
			}
			hidden_effect = {
				create_character = {
					template = pool_repopulate_learning
					dynasty = none
					location = root.capital_province
					faith = root.faith
					culture = root.culture
					save_scope_as = RE_smartypants
				}
				scope:RE_smartypants = {
					add_character_flag = REtemp
				}
			}
		}
		# Trigger next event in chain.
		hold_court_queue_next_event_effect = yes
	}

	option = { 
		name = RE_hold_court.1043.a
		ai_chance = {
			base = 0
		}
		stress_impact = {
			callous = minor_stress_loss
			stubborn = medium_stress_loss
			fickle = medium_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_tri_giga_verhigh_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_tri_standard_verhigh_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1043.b
		ai_chance = {
			base = 0
		}
		stress_impact = {
			stubborn = minor_stress_loss
			fickle = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_tri_giga_high_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_tri_standard_high_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1043.c
		ai_chance = {
			base = 0
		}
		stress_impact = {
			gregarious = minor_stress_loss
			patient = minor_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_tri_giga_mid_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_tri_standard_mid_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1043.d
		ai_chance = {
			base = 0
		}
		stress_impact = {
			fickle = minor_stress_loss
			gregarious = medium_stress_loss
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_tri_giga_low_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_tri_standard_low_modifier
				years = 5		
			}
		}
	}
	
	option = {
		name = RE_hold_court.1043.e
		ai_chance = {
			base = 0
		}
		stress_impact = {
			fickle = medium_stress_loss
			gregarious = major_stress_loss
			scholar = minor_stress_loss
			shy = minor_stress_gain
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 25
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_tri_giga_verlow_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_tri_standard_verlow_modifier
				years = 5		
			}
		}
	}
	
	option = {
		trigger = {
			is_ai = yes
		}
		ai_chance = {
			base = 100
		}
		if = {
			limit = {
				OR = {
					AND = {
						root.learning >= 20
						root.court_grandeur_current >= 80
					}
					AND = {
						root.learning >= 15
						root.court_grandeur_current >= 40
						root.court_grandeur_current < 80
					}
					AND = {
						root.learning >= 10
						root.court_grandeur_current < 40
					}
				}
			}
			add_character_modifier = {
				modifier = RE_lear_tri_giga_ai_modifier
				years = 5		
			}
		}
		else = {
			add_character_modifier = {
				modifier = RE_lear_tri_standard_ai_modifier
				years = 5		
			}
		}
	}
	
	after = {
		RE_remove_court_flags = yes
		if = {
			limit = { is_ai = no }
			add_character_flag = RE_lear_tri_flag
		}
		if = {
			limit = { scope:RE_smartypants = { has_character_flag = REtemp } }
			scope:RE_smartypants = { silent_disappearance_effect = yes }
		}
		# Finish up the chain if relevant.
		hold_court_queue_post_event_effect = yes
	}
}