################################################
#
# Events for Tournament
#
# ID 70000 - 70999 is reserved
#
#################################################
#
# Written by Chris King
#
# Rewritten by Niklas Strid
#
# edited for AGOT by Knuckey
namespace = tourney

###################################
#Random Event Generator
###################################
#Can be used in other tournament event chains (e.g. archery)

##Particpant/Spectator Events##
character_event = {
	id = tourney.99
	
	min_age = 14
	hide_window = yes
	capable_only = yes
	prisoner = no
	
	trigger = {
		OR = {
			has_character_flag = attending_tournament
			has_character_flag = attending_archery_tournament
			has_character_flag = attending_melee
		}
		NOT = { has_character_flag = attending_tournament_event }
		any_opinion_modifier_target = {
			is_ruler = yes
			OR = {
				has_character_flag = melee_begins
				has_character_flag = tournament_begins
			}	
			OR = {			
				reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
				reverse_has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
				reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
			}
		}
		NOT_mythical_creature_trigger = yes
		NOT = { is_inaccessible_trigger = yes }
	}
	
	mean_time_to_happen = {
		months = 2
	}	
	
	immediate = {
		random_list = {
			25 = { } #chance of no event
			3 = { # Character becomes craven
				modifier = {
					factor = 0
					OR = {
						has_character_flag = attending_archery_tournament
						trait = craven
						trait = brave
					}
				}
				modifier = {
					factor = 0
					personality_traits = 5
				}
				modifier = {
					factor = 1.66
					NOT = {
						OR = {
							trait = poor_warrior
							trait = trained_warrior
							trait = skilled_warrior
							trait = master_warrior
						}
					}
				}
				modifier = {
					factor = 1.25
					trait = poor_warrior
				}
				modifier = {
					factor = 0.8
					trait = master_warrior
				}
				modifier = {
					factor = 0.75
					OR = {
						trait = skilled_warrior
						trait = master_warrior
					}	
				}
				character_event = { id = 70012 }
			}
			3 = { # Character becomes brave
				modifier = {
					factor = 0
					OR = {
						has_character_flag = attending_archery_tournament
						trait = craven
						trait = brave
					}
				}
				modifier = {
					factor = 0
					personality_traits = 5
				}
				modifier = {
					factor = 0.75
					NOT = {
						OR = {
							trait = poor_warrior
							trait = trained_warrior
							trait = skilled_warrior
							trait = master_warrior
						}
					}
				}
				modifier = {
					factor = 0.8
					trait = poor_warrior
				}
				modifier = {
					factor = 1.25
					trait = master_warrior
				}
				modifier = {
					factor = 1.66
					OR = {
						trait = skilled_warrior
						trait = master_warrior
					}	
				}
				character_event = { id = 70013 }
			}
			1 = { # Character becomes homosexual
				modifier = {
					factor = 0
					OR = {
						is_female = yes
						NOT = { age = 14 }
						trait = homosexual
						has_character_flag = tournament_spectator
					}
				}
				modifier = {
					factor = 0.5
				}
				modifier = {
					factor = 1.1
					culture = summer_islander
				}
				modifier = {
					factor = 1.1
					trait = drunkard
				}
				modifier = {
					factor = 1.1
					trait = celibate
				}
				modifier = {
					factor = 1.1
					trait = hedonist
				}
				modifier = {
					factor = 2
					trait = impaler
				}
				modifier = {
					factor = 0.66
					trait = lustful
				}
				modifier = {
					factor = 1.1
					trait = chaste
				}
				modifier = {
					factor = 0.33
					trait = zealous
				}
				character_event = { id = 70023 }
			}
			1 = { # Character becomes syphilitic
				modifier = {
					factor = 0.25
				}
				modifier = {
					factor = 0
					OR = {
						is_female = yes
						NOT = { age = 16 }
						trait = syphilitic
						trait = celibate
					}
				}
				modifier = {
					factor = 1.1
					culture = summer_islander
				}
				modifier = {
					factor = 0.66
					trait = ugly
				}
				modifier = {
					factor = 1.1
					trait = fair
				}
				modifier = {
					factor = 1.1
					trait = hedonist
				}
				modifier = {
					factor = 5
					trait = lustful
				}
				modifier = {
					factor = 0.1
					trait = chaste
				}
				modifier = {
					factor = 0.33
					trait = zealous
				}
				character_event = { id = 70024 }
			}
			1 = { # Character becomes drunkard
				modifier = {
					factor = 0.5
				}
				modifier = {
					factor = 0
					OR = {
						is_female = yes
						NOT = { age = 16 }
						trait = drunkard
					}
				}
				modifier = {
					factor = 2
					trait = depressed
				}
				modifier = {
					factor = 3
					trait = gluttonous
				}
				modifier = {
					factor = 1.5
					trait = lustful
				}
				modifier = {
					factor = 0.33
					trait = temperate
				}
				modifier = {
					factor = 1.1
					trait = greedy
				}
				character_event = { id = 70025 }
			}
			2 = { # Character becomes duelist
				modifier = {
					factor = 0
					OR = {
						has_character_flag = attending_archery_tournament
						NOT = { age = 16 }
						lifestyle_traits = 1
						has_character_flag = tournament_spectator
					}
				}
				modifier = {
					factor = 1.5
					trait = wroth
				}
				modifier = {
					factor = 0.66
					trait = kind
				}
				modifier = {
					factor = 1.5
					trait = proud
				}
				modifier = {
					factor = 0.66
					trait = humble
				}
				modifier = {
					factor = 0.66
					trait = craven
				}
				modifier = {
					factor = 1.5
					trait = brave
				}
				modifier = {
					factor = 0.66
					trait = just
				}
				modifier = {
					factor = 1.5
					trait = cruel
				}
				character_event = { id = 70026 }
			}
			2 = { # Character gains diplomacy ##fash agot edited to intrigue
				modifier = {
					factor = 0
					NOT = { age = 16 }
				}
				modifier = {
					factor = 2
					trait = elusive_shadow
				}
				modifier = {
					factor = 1.66
					trait = intricate_webweaver
				}
				modifier = {
					factor = 1.4
					trait = flamboyant_schemer
				}
				modifier = {
					factor = 1.2
					trait = amateurish_plotter
				}
				modifier = {
					factor = 0.66
					NOT = {
						OR = {
							trait = elusive_shadow
							trait = intricate_webweaver
							trait = flamboyant_schemer
							trait = amateurish_plotter
						}
					}
				}
				modifier = {
					factor = 2
					trait = deceitful
				}
				modifier = {
					factor = 0.5
					trait = honest
				}
				character_event = { id = 70027 }
			}
			2 = { # Character loses intrigue
				modifier = {
					factor = 0
					NOT = { age = 16 }
				}
				modifier = {
					factor = 0.5
					trait = elusive_shadow
				}
				modifier = {
					factor = 0.6
					trait = intricate_webweaver
				}
				modifier = {
					factor = 0.7
					trait = flamboyant_schemer
				}
				modifier = {
					factor = 0.85
					trait = amateurish_plotter
				}
				modifier = {
					factor = 0.5
					trait = deceitful
				}
				modifier = {
					factor = 2
					trait = honest
				}
				character_event = { id = 70028 }
			}
			2 = { # Character gains stewardship
				modifier = {
					factor = 0
					NOT = { age = 16 }
				}
				modifier = {
					factor = 2
					trait = midas_touched
				}
				modifier = {
					factor = 1.66
					trait = fortune_builder
				}
				modifier = {
					factor = 1.4
					trait = thrifty_clerk 
				}
				modifier = {
					factor = 1.2
					trait = indulgent_wastrel
				}
				modifier = {
					factor = 0.66
					NOT = {
						OR = {
							trait = midas_touched 
							trait = fortune_builder
							trait = thrifty_clerk 
							trait = indulgent_wastrel
						}
					}
				}
				modifier = {
					factor = 2
					trait = diligent
				}
				modifier = {
					factor = 0.5
					trait = slothful
				}
				character_event = { id = 70029 }
			}
			2 = { # Character loses stewardship
				modifier = {
					factor = 0
					NOT = { age = 16 }
				}
				modifier = {
					factor = 0.5
					trait = midas_touched 
				}
				modifier = {
					factor = 0.6
					trait = fortune_builder
				}
				modifier = {
					factor = 0.7
					trait = thrifty_clerk 
				}
				modifier = {
					factor = 0.85
					trait = indulgent_wastrel
				}
				modifier = {
					factor = 0.5
					trait = diligent
				}
				modifier = {
					factor = 2
					trait = slothful
				}
				character_event = { id = 70030 }
			}
			2 = { # Character gains diplomacy
				modifier = {
					factor = 0
					NOT = { age = 16 }
				}
				modifier = {
					factor = 2
					trait = grey_eminence
				}
				modifier = {
					factor = 1.66
					trait = charismatic_negotiator
				}
				modifier = {
					factor = 1.4
					trait = underhanded_rogue
				}
				modifier = {
					factor = 1.2
					trait = naive_appeaser
				}
				modifier = {
					factor = 0.66
					NOT = {
						OR = {
							trait = grey_eminence 
							trait = charismatic_negotiator
							trait = underhanded_rogue
							trait = naive_appeaser
						}
					}
				}
				modifier = {
					factor = 2
					trait = gregarious
				}
				modifier = {
					factor = 0.5
					trait = shy
				}
				character_event = { id = 70031 }
			}
			2 = { # Character loses diplomacy
				modifier = {
					factor = 0
					NOT = { age = 16 }
				}
				modifier = {
					factor = 0.5
					trait = grey_eminence
				}
				modifier = {
					factor = 0.6
					trait = charismatic_negotiator
				}
				modifier = {
					factor = 0.7
					trait = underhanded_rogue
				}
				modifier = {
					factor = 0.85
					trait = naive_appeaser
				}
				modifier = {
					factor = 0.5
					trait = gregarious
				}
				modifier = {
					factor = 2
					trait = shy
				}
				character_event = { id = 70032 }
			}
			3 = { # Character is knighted
				modifier = {
					factor = 0
					OR = {
						NOT = { has_character_flag = attending_tournament }
						is_female = yes
						NOT = { age = 14 }
						trait = knight
						trait = maester
						trait = archmaester
						has_priest_trait_trigger = yes
						has_character_flag = tournament_spectator
						has_character_flag = lost_tournament
					}
				}
				modifier = {
					factor = 0.33
					NOT = { religion = the_seven }
				}
				modifier = {
					factor = 0.5
					NOT = {
						OR = {
							trait = poor_warrior
							trait = trained_warrior
							trait = skilled_warrior
							trait = master_warrior
						}
					}
				}
				modifier = {
					factor = 0.75
					trait = poor_warrior
				}
				modifier = {
					factor = 2
					trait = master_warrior
				}
				modifier = {
					factor = 2
					OR = {
						trait = skilled_warrior
						trait = master_warrior
					}	
				}
				modifier = {
					factor = 0.5
					trait = craven
				}
				modifier = {
					factor = 2
					trait = brave
				}
				modifier = {
					factor = 0.5
					is_weak_trigger = yes
				}
				modifier = {
					factor = 2
					is_strong_trigger = yes
				}
				character_event = { id = 70050 }
			}
			4 = { #Tourny Rivals drama
				modifier = {
					factor = 0
					OR = {
						NOT = { has_character_flag = attending_tournament }
						is_female = yes
						NOT = { age = 15 }
						
						has_character_flag = lost_tournament
						NOT = { prestige = 100 }
						NOT = { has_severe_disability_trigger = yes }
						has_character_flag = tournament_spectator
					}
				}
				character_event = { id = 71061 }
			}
			8 = { #drunkard embarrasses himself
				modifier = {
					factor = 0
					OR = {
						is_female = yes
						NOT = { age = 16 }
						NOT = { trait = drunkard }
						
						trait = wounded
						is_maimed_trigger = yes
						has_character_flag = lost_tournament
					}
				}
				modifier = {
					factor = 1.5
					trait = gregarious
				}
				modifier = {
					factor = 3
					trait = hedonist
				}
				modifier = {
					factor = 0.5
					learning = 10 #knows when not to drink
				}
				modifier = {
					factor = 2
					NOT = { learning = 5 } #will fuck up things
				}
				modifier = { #
					factor = 0.5
					trait = craven
				}
				modifier = { #
					factor = 0.5
					trait = shy
				}
				modifier = {
					factor = 2 #bravery clouds his mind
					trait = brave
				}
				character_event = { id = 70082 }
			}
			5 = { # Young lad helps with armour and horse
				modifier = {
					factor = 0
					OR = {
						NOT = { has_character_flag = attending_tournament }
						NOT = { age = 16 }
						is_ruler = no
						NOT = { trait = knight }
						any_ward = {
							age = 6
							trait = squire
						}
					}
				}
				modifier = {
					factor = 1.5
					trait = kind
				}
				modifier = {
					factor = 1.5
					trait = humble
				}
				modifier = {
					factor = 0.5
					trait = proud
				}
				modifier = {
					factor = 0.5
					trait = cruel
				}
				modifier = {
					factor = 0.5
					trait = wroth
				}
				character_event = { id = tourney.45 }
			}
			5 = { # Hungover squire
				modifier = {
					factor = 0
					OR = {
						NOT = { has_character_flag = attending_tournament }
						NOT = { age = 16 }
						NOT = { trait = knight }
						NOT = {
							any_ward = {
								is_female = no
								age = 13
								NOT = { age = 16 }
								trait = squire
								OR = {
									trait = lustful
									trait = gregarious
								}
								NOT = { trait = shy }
								prisoner = no
								NOT = { trait = incapable }
							}
						}	
					}
				}
				random_ward = {
					limit = {
						is_female = no
						age = 13
						NOT = { age = 16 }
						trait = squire
						OR = {
							trait = lustful
							trait = gregarious
						}
						NOT = { trait = shy }
						prisoner = no
						NOT = { trait = incapable }
					}	
					character_event = { id = tourney.46 }
				}
			}
			5 = { # Training with squire
				modifier = {
					factor = 0
					OR = {
						NOT = { has_character_flag = attending_tournament }
						NOT = { age = 16 }
						NOT = { trait = knight }
						NOT = {
							any_ward = {
								age = 6
								trait = squire
								NOT = { trait = master_warrior }
								NOT = { trait = skilled_warrior }
								is_female = no
							}
						}
					}
				}
				modifier = {
					factor = 2
					trait = diligent
				}
				modifier = {
					factor = 0.5
					trait = proud
				}
				modifier = {
					factor = 0.5
					trait = slothful
				}
				character_event = { id = tourney.48 }
			}
			2 = { # Accuse rival of cheating in tournament
				modifier = {
					factor = 0
					OR = {
						NOT = { num_of_rivals = 1 }
						NOT = { 
							any_rival = {  
								OR = {
									has_character_flag = attending_tournament
									has_character_flag = attending_archery_tournament
									has_character_flag = attending_melee
								}
							}
						}
					}	
				}
				modifier = {
					factor = 0.33
					trait = honest
				}
				modifier = {
					factor = 0.33
					trait = honorable
				}
				modifier = {
					factor = 0.5
					trait = trusting
				}				
				modifier = {
					factor = 3
					trait = deceitful
				}
				modifier = {
					factor = 3
					trait = ruthless
				}
				modifier = {
					factor = 2
					trait = paranoid
				}
				character_event = { id = 100420 }
			}
			20 = { # Make the Eight
				modifier = {
					factor = 0
					OR = {
						NOT = { has_ambition = obj_make_the_eight }
						NOT = { age = 14 }
						is_female = yes
						NOT = {
							any_opinion_modifier_target = {
								is_ruler = yes
								OR = {
									has_character_flag = melee_begins
									has_character_flag = tournament_begins
								}	
								OR = {			
									reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
									reverse_has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
									reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
								}
								OR = {
									culture_group = andal
									culture = ironborn
									culture = northman
									culture_group = dornish
								}	
								NOT = { culture = old_andal }
								NOT = { culture = crownlander }
								NOT = { culture = sisterman }
								NOT = { culture = rhoynar }
							}
						}
					}
				}
				modifier = {
					factor = 2
					trait = hedonist
				}
				character_event = { id = ambition.3 }
			}
			2 = { # Fall in love with common girl
				trigger = {
					age = 16
					NOT = { age = 30 }
					is_female = no
					OR = {
						has_lover = no
						trait = lustful
						has_ambition = obj_make_the_eight
						has_focus = focus_seduction
					}
					OR = {
						NOT = { trait = homosexual }
						AND = {
							trait = lustful
							culture_group = dornish
						}
					}
					NOT = { trait = chaste }
					NOT = { trait = celibate }
					NOT = { trait = eunuch }
					NOT = { trait = proud }
				}
				modifier = {
					factor = 2
					trait = lustful
				}
				modifier = {
					factor = 2
					trait = humble
				}
				modifier = {
					factor = 1.5
					trait = kind
				}
				modifier = {
					factor = 1.5
					trait = honorable
				}
				modifier = {
					factor = 1.5
					trait = just
				}
				modifier = {
					factor = 0.5
					trait = cruel
				}
				modifier = {
					factor = 0.5
					trait = wroth
				}
				modifier = {
					factor = 0.5
					trait = ruthless
				}
				character_event = { id = tourney.95 }
			}
		}
	}
	
	option = {
		name = OK
	}
}	

# Invitations have gone out
character_event = {
	id = tourney.1
	title = "TOURNAMENTTITLE3"
	desc = "EVTDESCtourney.1"
	picture = "GFX_evt_courier"

	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = king_tourny
		clr_character_flag = grand_tourny
		clr_character_flag = normal_tourny
		clr_character_flag = small_tourny
		add_character_modifier = {
			name = holding_large_feast
			duration = 365
		}
	}
	
	option = {
		name = "EVTOPTAtourney.1" #Local Tourney
		ai_chance = {
			factor = 50
		}
		treasury = -75
		prestige = 40
		set_character_flag = small_tourny
		custom_tooltip = {
			text = TOOLTIPtourney.1LOCAL
			hidden_tooltip = {
				character_event = { id = 72003 days = 4 } #Food prep	
				character_event = { id = feast.1 } #Random Events
				top_liege = {
					any_realm_character = {
						limit = {
							#Invite participants
							age = 15					
							NOT = { character = ROOT }
							
							OR = { #Local participants only
								# AND = {
									# ROOT = { tier = COUNT }
									# OR = {
										# is_liege_of = ROOT
										# is_liege_or_above = ROOT
									# }	
								# }	
								AND = {
									is_ruler = yes
									capital_scope = { #Either neighbours or same duchy
										OR = {
											AND = {
												is_capital = yes
												owner = { character = ROOT }
											}
											any_neighbor_province = {
												is_capital = yes
												owner = { character = ROOT }
											}
											duchy = {
												any_direct_de_jure_vassal_title = {
													location = {
														is_capital = yes
														owner = { character = ROOT }
													}
												}
											}
										}	
									}	
								}
								AND = {
									is_ruler = no
									liege = {
										capital_scope = { #Either neighbours or same duchy
											OR = {
												AND = {
													is_capital = yes
													owner = { character = ROOT }
												}
												any_neighbor_province = {
													is_capital = yes
													owner = { character = ROOT }
												}
												duchy = {
													any_direct_de_jure_vassal_title = {
														location = {
															is_capital = yes
															owner = { character = ROOT }
														}
													}
												}
											}	
										}	
									}
								}	
							}
							
							OR = {	#Must either....
								trait = knight #Be a knight
								
								#All of the following....
								AND = {
									OR = { #Have some fighting skill
										trait = poor_warrior
										trait = trained_warrior
										trait = skilled_warrior
										trait = master_warrior
									}
									OR = { #Is either a Lord or liege is a relative
										is_ruler = yes
										liege = { 
											OR = {
												is_close_relative = PREV
												dynasty = PREV
											}	
										}
									}	
								}
								#Is master of arms of the seven religion
								AND = {
									religion = the_seven
									has_job_title = job_marshal
								}	
							}
							NOT = { trait = dragon }
							NOT = { trait = white_walker }
						}
						letter_event = { id = tourney.2 }
					}
					any_realm_lord = {
						limit = {
							NOT = { character = ROOT }	
							NOT = { tier = BARON }	
							capital_scope = { #Either neighbours or same duchy
								OR = {
									AND = {
										is_capital = yes
										owner = { character = ROOT }
									}
									any_neighbor_province = {
										is_capital = yes
										owner = { character = ROOT }
									}
									duchy = {
										any_direct_de_jure_vassal_title = {
											location = {
												is_capital = yes
												owner = { character = ROOT }
											}
										}
									}
								}	
							}
						}
						letter_event = { id = 70086 days=7 }
					}	
				}
			}
		}	
	}
	option = {
		name = "EVTOPTBtourney.1" #Regional Tourney
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0
				NOT = { treasury = 150 }
			}
			modifier = {
				factor = 0.33
				trait = humble
			}
			modifier = {
				factor = 3
				trait = proud
			}
			modifier = {
				factor = 0.33
				trait = content
			}
			modifier = {
				factor = 3
				trait = ambitious
			}
		}
		treasury = -125
		prestige = 80
		set_character_flag = normal_tourny
		capital_scope = {
			kingdom = {
				custom_tooltip = {
					text = TOOLTIPtourney.1REGIONAL
					hidden_tooltip = {
						character_event = { id = 72003 days = 4 } #Food prep	
						character_event = { id = feast.1 } #Random Events
						ROOT = {
							top_liege = {
								any_realm_character = { #Invite participants
									limit = {	
										age = 15
										NOT = { character = ROOT }
										OR = { #Regional participants only
											AND = { #All subjects (non empire)
												ROOT = { NOT = { tier = EMPEROR } }
												OR = {
													is_liege_of = ROOT
													is_liege_or_above = ROOT
												}	
											}	
											any_liege = { #Share same king tier liege
												tier = KING
												is_vassal_or_below = ROOT
											}
											AND = { #Reside in the same kingdom
												is_ruler = yes
												capital_scope = {
													kingdom = {
														any_direct_de_jure_vassal_title = {
															any_direct_de_jure_vassal_title = {
																location = {
																	is_capital = yes
																	owner = { character = ROOT }
																}
															}
														}	
													}
												}	
											}
											AND = {
												is_ruler = no
												liege = {
													capital_scope = {
														kingdom = {
															any_direct_de_jure_vassal_title = {
																any_direct_de_jure_vassal_title = {
																	location = {
																		is_capital = yes
																		owner = { character = ROOT }
																	}
																}
															}	
														}
													}
												}
											}	
										}									
										OR = {	#Must either
											#Have placed in a large tourney
											has_character_flag = grand_tourny_1st
											has_character_flag = grand_tourny_2nd
											has_character_flag = grand_tourny_3rd							
											has_character_flag = normal_tourny_1st
											has_character_flag = normal_tourny_2nd
											#This is a smaller tourney and have placed in a small tourney
											#REGIONAL
											has_character_flag = normal_tourny_3rd
											has_character_flag = small_tourny_1st
											has_character_flag = small_tourny_2nd
											has_character_flag = small_tourny_3rd	
											
											#All of the following....
											AND = {
												OR = { #Is either a Lord or liege is a relative
													higher_tier_than = BARON
													liege = { 
														NOT = { tier = BARON }
														OR = {
															is_close_relative = PREV
															dynasty = PREV
														}	
													}
												}
												OR = { #Is a knight or a trained fighter
													trait = poor_warrior
													trait = trained_warrior
													trait = skilled_warrior
													trait = master_warrior
													trait = knight
												}										
											}
											AND = { #Is an awesome knight
												trait = knight
												OR = {
													trait = master_warrior
													trait = dragon_rider
													trait = kingsguard
													prestige = 300
													trait = skilled_warrior #REGIONAL
												}
											}
										}
										NOT = { trait = dragon }
										NOT = { trait = white_walker }
									}
									letter_event = { id = tourney.2 }
								}
								any_realm_lord = { #Invite all lords as spectators
									limit = {
										NOT = { character = ROOT }
										NOT = { tier = BARON }
										OR = { #Regional participants only
											AND = { #All subjects (non empire)
												ROOT = { NOT = { tier = EMPEROR } }
												OR = {
													is_liege_of = ROOT
													is_liege_or_above = ROOT
												}	
											}	
											any_liege = { #Share same king tier liege
												tier = KING
												is_vassal_or_below = ROOT
											}
											capital_scope = {
												kingdom = {
													any_direct_de_jure_vassal_title = {
														any_direct_de_jure_vassal_title = {
															location = {
																is_capital = yes
																owner = { character = ROOT }
															}
														}
													}	
												}
											}
										}							
									}
									clr_character_flag = tournament_has_ended
									letter_event = { id = 70086 days=7 }
								}
							}
						}	
					}
				}
			}
		}	
	}
	option = {
		name = "EVTOPTCtourney.1" #Grand Tourney
		trigger = {
			top_liege = { tier = EMPEROR }
		}
		ai_chance = {
			factor = 10000
			modifier = {
				factor = 0
				NOT = { treasury = 300 }
			}
			modifier = {
				factor = 0
				NOT = { higher_tier_than = DUKE }
				NOT = {
					OR = {
						trait = ambitious
						trait = proud
						trait = charitable
					}
				}
			}
			modifier = {
				factor = 0
				trait = humble
			}
			modifier = {
				factor = 0
				trait = content
			}
		}		
		if = {
			limit = { tier = EMPEROR }
			set_character_flag = king_tourny
			treasury = -300
		}
		if = {
			limit = { NOT = { tier = EMPEROR } }
			set_character_flag = grand_tourny
			treasury = -200
		}
		prestige = 200
		custom_tooltip = {
			text = TOOLTIPtourney.1GRAND
			hidden_tooltip = {
				character_event = { id = 72003 days = 4 } #Food prep	
				character_event = { id = feast.1 } #Random Events
				top_liege = {  #All characters in realm invited to grand tourneys
					any_realm_character = { #Invite participants
						limit = {	
							age = 15
							NOT = { character = ROOT }						
							OR = {	#Must either
								#Have placed in a large tourney
								has_character_flag = grand_tourny_1st
								has_character_flag = grand_tourny_2nd
								has_character_flag = grand_tourny_3rd							
								has_character_flag = normal_tourny_1st
								has_character_flag = normal_tourny_2nd	
								#All of the following....
								AND = {
									OR = { #Is either a Lord or liege is a relative
										higher_tier_than = BARON
										liege = { 
											NOT = { tier = BARON }
											OR = {
												is_close_relative = PREV
												dynasty = PREV
											}	
										}
									}
									OR = { #Is a knight or a trained fighter
										trait = poor_warrior
										trait = trained_warrior
										trait = skilled_warrior
										trait = master_warrior
										trait = knight
									}										
								}
								AND = { #Is an awesome knight
									trait = knight
									OR = {
										trait = master_warrior
										trait = dragon_rider
										trait = kingsguard
										prestige = 300
									}
								}
							}
							NOT = { trait = dragon }
							NOT = { trait = white_walker }
						}
						letter_event = { id = tourney.2 }
					}
					any_realm_lord = { #Invite all lords as spectators
						limit = {
							NOT = { character = ROOT }
							NOT = { tier = BARON }						
						}
						clr_character_flag = tournament_has_ended
						letter_event = { id = 70086 days = 7 }
					}
				}
			}
		}
	}
	option = {
		name = "EVTOPTDtourney.1" #Change Mind
		ai_chance = { factor = 0 }
		clr_character_flag = epic_tournament
		clr_character_flag = tourny_in_progress
		clr_character_flag = do_not_disturb 					
		remove_character_modifier = holding_epic_tournament
	}
}
# Invitation
letter_event = {
	id = tourney.2
	title = "TOURNAMENTTITLE2"
	picture = "GFX_evt_courier"

	is_triggered_only = yes
	
	desc = {
		text = EVTDESCtourney.2A
		trigger = {
			FROM = { has_character_flag = small_tourny }
		}
	}
	desc = {
		text = EVTDESCtourney.2B
		trigger = {
			FROM = { has_character_flag = normal_tourny }
		}
	}
	desc = {
		text = EVTDESCtourney.2C
		trigger = {
			FROM = { 
				OR = {
					has_character_flag = grand_tourny 
					has_character_flag = king_tourny
				}	
			}
		}
	}
	
	trigger = {
		NOT = { has_character_flag = tourny_in_progress }
		NOT = { has_character_flag = attending_tournament }
		NOT = {
			AND = {
				FROM = { has_character_flag = small_tourny }
				has_character_flag = no_small_tournies
			}
		}
		NOT = {
			AND = {
				FROM = { has_character_flag = normal_tourny }
				has_character_flag = no_regional_tournies
			}
		}
		NOT = { has_character_flag = no_tournies_ever }
		OR = {
			is_ruler = no
			is_feudal = yes
			is_patrician = yes
			is_tribal = yes
		}	
		NOT = { has_severe_disability_trigger = yes }
		NOR = {
			trait = one_legged
			trait = one_handed
		}
		has_epidemic = no
		
		OR = { #Certain disabilities require high skill to enter
			trait = master_warrior
			trait = skilled_warrior
			NOT = {
				OR = {
					trait = dwarf
					trait = clubfooted
					trait = hunchback
					trait = imbecile
					trait = inbred
				}
			}
		}
		
		NOT = { trait = maester }
		NOT = { trait = archmaester }
		OR = {
			NOT = { trait = nightswatch }
			FROM = { has_landed_title = k_nightswatch }
		}	
		NOT = { has_priest_trait_trigger = yes }
		
		OR = {
			religion = the_seven
			trait = knight
			AND = {
				religion_group = westerosi_religion
				OR = { 
					trait = skilled_warrior
					trait = master_warrior
				}
			}	
		}	
		OR = {
			is_female = no
			trait = kingsguard
			AND = {
				trait = brave
				is_strong_trigger = yes
				OR = {
					trait = trained_warrior
					trait = skilled_warrior
					trait = master_warrior
				}
			}
		}
		OR = {		
			trait = master_warrior
			AND = {
				NOT = { age = 60 }
				trait = skilled_warrior
			}
			AND = {
				NOT = { age = 50 }
				trait = trained_warrior
			}
			NOT = { age = 40 }
		}
		prisoner = no
		war = no
		NOT = { is_inaccessible_trigger = yes }
	}
	
	immediate = {
		clr_character_flag = king_tourny
		clr_character_flag = grand_tourny
		clr_character_flag = normal_tourny
		clr_character_flag = small_tourny
		
		if = {
			limit = {
				has_character_flag = title_knight_of_the_greenhand
				NOT = { has_minor_title = title_knight_of_the_greenhand }
			}
			give_minor_title = title_knight_of_the_greenhand
		}
		if = {
			limit = { #find title for loc
				ai = no
				FROM = { has_character_flag = normal_tourny }
			}
			FROM = { capital_scope = { kingdom = { save_event_target_as = tourney_kingdom } } }
		}
	}

	option = {
		name = "EVTOPTA70000"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.2
				OR = {
					has_character_flag = small_tourny_1st
					has_character_flag = small_tourny_2nd
					has_character_flag = small_tourny_3rd
				}	
			}
			modifier = {
				factor = 1.4
				OR = {
					has_character_flag = grand_tourny_3rd
					has_character_flag = normal_tourny_2nd
					has_character_flag = normal_tourny_3rd
				}	
			}
			modifier = {
				factor = 2
				OR = {
					has_character_flag = grand_tourny_1st
					has_character_flag = grand_tourny_2nd
					has_character_flag = normal_tourny_1st
				}	
			}
			modifier = {
				factor = 4
				trait = master_warrior
			}
			modifier = {
				factor = 3
				trait = skilled_warrior
			}
			modifier = {
				factor = 2
				trait = trained_warrior
			}
			modifier = {
				factor = 2
				trait = genius
			}
			modifier = {
				factor = 2
				is_smart_trigger = yes
			}
			modifier = {
				factor = 2
				trait = brave
			}
			modifier = {
				factor = 3
				trait = duelist
			}
			modifier = {
				factor = 1.5
				trait = knight
			}
			modifier = {
				factor = 2
				trait = tall
			}
			modifier = {
				factor = 2
				is_strong_trigger = yes
			}
			modifier = {
				factor = 1.5
				trait = diligent
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
			modifier = {
				factor = 1.5
				trait = gregarious
			}
			modifier = {
				factor = 1.5
				trait = ambitious
			}
			modifier = {
				factor = 1.3
				opinion = { who = FROM value =  20 }
			}
			modifier = {
				factor = 1.3
				opinion = { who = FROM value =  40 }
			}
			modifier = {
				factor = 1.3
				opinion = { who = FROM value =  60 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value =  80 }
			}
		}
		if = { 
			limit = { 
				FROM = { 
					tier = EMPEROR 
					has_character_flag = king_tourny
				} 
			}
			prestige = 40
			set_character_flag = king_tourny
		}	
		if = { 
			limit = { 
				FROM = { 
					NOT = { tier = EMPEROR }
					has_character_flag = grand_tourny
				} 			
			}
			prestige = 20
			set_character_flag = grand_tourny
		}
		if = { 
			limit = { FROM = { has_character_flag = normal_tourny } }
			prestige = 10
			set_character_flag = normal_tourny
		}
		if = { 
			limit = { FROM = { has_character_flag = small_tourny } }
			prestige = 5
			set_character_flag = small_tourny
		}			
		set_character_flag = attending_tournament
		hidden_tooltip = {
			opinion = {
				modifier = opinion_attending_tournament
				who = FROM
				years = 100
			}
			reverse_opinion = {
				modifier = opinion_attending_tournament
				who = FROM
				years = 100
			}
			# any_dynasty_member = { 
				# limit = { is_close_relative = ROOT }
				# character_event = { id = 70086 days = 7 } 
			# }
			any_ward = { #inform squire
				limit = { 
					trait = squire 
					ai = no
				}
				character_event = { id = tourney.299 }
			}
		}	
	}
	option = {
		name = {
			text = "EVTOPTB70000" #No
			trigger = {
				OR = {
					lower_tier_than = FROM
					FROM = { NOT = { has_character_flag = small_tourny }	}
				}
			}
		}	
		name = {
			text = "EVTOPTC70000" #This is below me
			trigger = {
				NOT = { lower_tier_than = FROM }
				FROM = { has_character_flag = small_tourny }
			}
		}	
		ai_chance = {
			factor = 25
			
			modifier = { #This is below me
				factor = 3
				NOT = { lower_tier_than = FROM }
				FROM = { has_character_flag = small_tourny }
			}
			
			modifier = {
				factor = 3
				trait = craven
			}
			modifier = {
				factor = 1.5
				NOT = { trait = knight }
			}
			modifier = {
				factor = 5
				NOT = { religion = the_seven }
				NOT = { trait = knight }
			}
			modifier = {
				factor = 2
				is_weak_trigger = yes
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 1.5
				trait = shy
			}
			modifier = {
				factor = 1.5
				trait = content
			}
			modifier = {
				factor = 1.3
				NOT = { opinion = { who = FROM value =  -20 } }
			}
			modifier = {
				factor = 1.3
				NOT = { opinion = { who = FROM value =  -40 } }
			}
			modifier = {
				factor = 1.3
				NOT = { opinion = { who = FROM value =  -60 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value =  -80 } }
			}
			modifier = {
				factor = 2
				trait = dwarf
			}
			modifier = {
				factor = 4
				is_ill = yes
			}
			modifier = {
				factor = 1.5
				trait = wounded
			}
			
			modifier = {
				factor = 2
				is_dumb_trigger = yes
			}
			modifier = {
				factor = 2
				trait = imbecile
			}
		}
		if = {
			limit = {
				OR = {
					religion = the_seven
					trait = knight
				}	
				OR = {
					lower_tier_than = FROM
					FROM = { NOT = { has_character_flag = small_tourny }	}
				}
				NOT = { is_ill = yes }
			}
			if = { 
				limit = { 
					FROM = { 
						tier = EMPEROR 
						has_character_flag = king_tourny
					} 
				}
				prestige = -50
			}	
			if = { 
				limit = { 
					FROM = { 
						NOT = { tier = EMPEROR }
						has_character_flag = grand_tourny
					} 			
				}
				prestige = -30
			}
			if = { 
				limit = { FROM = { has_character_flag = normal_tourny } }
				prestige = -20
			}
			if = { 
				limit = { FROM = { has_character_flag = small_tourny } }
				prestige = -10
			}
		}	
	}
	option = {
		name = "EVTOPTE70000"
		trigger = { ai = no FROM = { has_character_flag = small_tourny } }
		set_character_flag = no_small_tournies
		prestige = -10
	}
	option = {
		name = "EVTOPTF70000"
		trigger = { ai = no FROM = { has_character_flag = normal_tourny } }
		set_character_flag = no_regional_tournies
		prestige = -20
	}
	option = {
		name = "EVTOPTD70000"
		trigger = { ai = no }
		set_character_flag = no_tournies_ever
		if = { 
			limit = { 
				FROM = { 
					tier = EMPEROR 
					has_character_flag = king_tourny
				} 
			}
			prestige = -50
		}	
		if = { 
			limit = { 
				FROM = { 
					NOT = { tier = EMPEROR }
					has_character_flag = grand_tourny
				} 			
			}
			prestige = -30
		}
		if = { 
			limit = { FROM = { has_character_flag = normal_tourny } }
			prestige = -20
		}
		if = { 
			limit = { FROM = { has_character_flag = small_tourny } }
			prestige = -10
		}	
	}
}	
character_event = { #inform squire going to tourney
	id = tourney.299
	title = "TOURNAMENTTITLE4"
	picture = "GFX_evt_courier"

	is_triggered_only = yes
	
	desc = {
		text = EVTDESCtourney.299A
		trigger = {
			FROMFROM = { has_character_flag = small_tourny }
		}
	}
	desc = {
		text = EVTDESCtourney.299B
		trigger = {
			FROMFROM = { has_character_flag = normal_tourny }
		}
	}
	desc = {
		text = EVTDESCtourney.299C
		trigger = {
			FROMFROM = { 
				OR = {
					has_character_flag = grand_tourny 
					has_character_flag = king_tourny
				}	
			}
		}
	}
	
	immediate = {
		clr_character_flag = king_tourny
		clr_character_flag = grand_tourny
		clr_character_flag = normal_tourny
		clr_character_flag = small_tourny
		
		if = {
			limit = { #find title for loc
				ai = no
				FROM = { has_character_flag = normal_tourny }
			}
			FROMFROM = { capital_scope = { kingdom = { save_event_target_as = tourney_kingdom } } }
		}
	}

	option = {
		name = "EVTOPTAtourney.299"
		FROMFROM = { show_portrait = yes }
		if = { 
			limit = { 
				FROMFROM = {
					tier = EMPEROR 
					has_character_flag = king_tourny
				} 
			}
			set_character_flag = king_tourny
		}	
		if = { 
			limit = { 
				FROMFROM = {
					NOT = { tier = EMPEROR }
					has_character_flag = grand_tourny
				} 			
			}
			set_character_flag = grand_tourny
		}
		if = { 
			limit = { FROMFROM = { has_character_flag = normal_tourny } }
			set_character_flag = normal_tourny
		}
		if = { 
			limit = { FROMFROM = { has_character_flag = small_tourny } }
			set_character_flag = small_tourny
		}			
		set_character_flag = attending_tournament
		set_character_flag = tournament_spectator
		hidden_tooltip = {
			opinion = {
				modifier = opinion_spectating_tournament
				who = FROMFROM
				years = 100
			}
			reverse_opinion = {
				modifier = opinion_spectating_tournament
				who = FROMFROM
				years = 100
			}
		}
	}
}	
# Start of tournament
character_event = {
	id = 70001
	title = "TOURNAMENTTITLE3"
	desc = "EVTDESC70001"
	picture = "GFX_evt_joust"

	is_triggered_only = yes
	
	trigger = {
		has_character_modifier = holding_epic_tournament
	}

	option = {
		name = "EVTOPTA70001"
		trigger = {
			is_ruler = yes
			OR = { #Don't stop for minor wars
				war = no
				AND = {
					is_primary_war_attacker = no
					is_primary_war_defender = no
				}
				AND = {
					NOT = { any_current_enemy = { demesne_size = 1 } }
					NOT = { primary_title = { is_contested = yes } }
				}			
			}			
		}
		hidden_tooltip = {
			event_target:chronicle_player = {
				if = {
					limit = { character = ROOT }
					chronicle = {
						entry = CHRONICLE_GRAND_TOURNAMENT
						picture = GFX_evt_joust
					}
				}
			}
			set_character_flag = tournament_begins
			set_character_flag = attending_tournament		
			#chance of prosperity for capital
			random = {
				chance = 15
				modifier = {
					factor = 3
					has_character_flag = normal_tourny
				}
				modifier = {
					factor = 5.33
					OR = {
						has_character_flag = grand_tourny
						has_character_flag = king_tourny
					}
				}
				character_event = { id = tourney.70 days = 20 random = 10 }
			}
			character_event = { id = 70999 days = 350 } #flag safety catch
			if = { #Only do full tourney if player is involved
				limit = {
					OR = {
						ai = no
						any_opinion_modifier_target = {
							ai = no
							has_character_flag = attending_tournament
							OR = {
								has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
								has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
							}	
						}
					}	
				}
				any_opinion_modifier_target = {
					limit = {
						has_character_flag = attending_tournament
						OR = {
							has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
							has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
						}
					}
					set_character_flag = guest_feast_started
					character_event = { id = feast.3 } #random events			
				}	
				set_character_flag = host_feast_started
				character_event = { id = feast.2 days = 1 } #Random Events
				set_variable = { which = "tourney_competitors" value = 0 }					
				character_event = { id = tourney.4 days = 1 }	
				#Random Summer fair Events
				random_list = {
					10 = { 
						character_event = { id = 74000 days = 10 random = 5 } #Dancing Monkey 
					} 
					10 = { 
						character_event = { id = 74005 days = 10 random = 5 } #Archery
					} 
					10 = { 
						character_event = { id = 74010 days = 10 random = 5 } #Jesters
					} 
					10 = { 
						character_event = { id = 74015 days = 10 random = 5 } #Mummers
					}
					10 = { 
						trigger = {
							is_summer_trigger = yes
						}
						modifier = {
							factor = 0
							NOT = { lower_tier_than = KING }
						}
						character_event = { id = 74020 days = 10 random = 5 } #Summer Fair 
					} 
					10 = { 
						modifier = {
							factor = 0
							OR = {
								NOT = { lower_tier_than = KING }
								NOT = { learning = 10 }
							}	
						}
						character_event = { id = 74025 days = 10 random = 5 } #Strolling Players
					} 
					10 = { 
						character_event = { id = 74030 days = 10 random = 5 } #Jugglers
					}
					10 = { 
						character_event = { id = 74040 days = 10 random = 5} #Mages and Divinators visits the fair
					}
					10 = { 
						character_event = { id = 74042 days = 10 random = 5 } #Errant monk disturbing the fair 
					}
					6 = { 
						character_event = { id = 74044 days = 10 random = 5 } #Peddler are arrested by Marshal for selling stolen goods 
					}
					6 = { 
						character_event = { id = 74045 days = 10 random = 5 } #Too many Peasants enter the city
					}
					6 = { 
						character_event = { id = 4105 days = 10 random = 5 } #Satirical Puppet Show
					}
					6 = { 
						character_event = { id = 4170 days = 10 random = 5 } #Performing Bear
					}
					4 = { 
						modifier = {
							factor = 0
							NAND = {
								trait = dragon_rider
								any_courtier = {
									age = 16
									prisoner = no
									NOT = { trait = incapable }
									ai = yes
									NOT = { trait = dragon }
									NOT = { trait = dragon_rider }
									NOT = { trait = craven }
									NOT = { trait = content }
									NOT = { trait = shy }
									is_ill = no
								}
							}	
						}
						character_event = { id = 74062 days = 10 random = 5 } #Dragon ride
					}
					1 = { 
						modifier = {
							factor = 0
							NAND = {
								age = 14
								NOT = { age = 26 }
								is_female = yes #She is a Maiden...
								NOT = { has_global_flag = not_a_bear }
								is_married = no
								#trait = fair    #...and she is Fair.
								NOT = { trait = ugly } #(...looks like we must lower our standards).
								has_landed_title = c_bearisland
							}	
						}
						character_event = { id = 74060 days = 10 random = 5 } #Pay no attention to this event.
					}		
				}
				break = yes
			}	
			character_event = { id = tourney.550 days = 40 } #If AI only, just find winner and skip all the duels			
		}			
	}
	option = {
		name = "EVTOPTB70001"
		trigger = {
			OR = {
				is_ruler = no
				NOR = { #Don't stop for minor wars
					war = no
					AND = {
						is_primary_war_attacker = no
						is_primary_war_defender = no
					}
					AND = {
						NOT = { any_current_enemy = { demesne_size = 1 } }
						NOT = { primary_title = { is_contested = yes } }
					}			
				}
			}	
		}
		if = { 
			limit = { has_character_flag = king_tourny }
			prestige = -200
			wealth = 250
		}	
		if = { 
			limit = { has_character_flag = grand_tourny }
			prestige = -200
			wealth = 175
		}	
		if = { 
			limit = { has_character_flag = normal_tourny }
			prestige = -100
			wealth = 100
		}	
		if = { 
			limit = { has_character_flag = small_tourny }
			prestige = -50
			wealth = 50
		}	
		hidden_tooltip = {
			any_opinion_modifier_target = {
				limit = {
					has_character_flag = attending_tournament
					OR = {
						has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
						has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
					}	
				}
				character_event = { id = 70037 }
			}
		}
		clr_character_flag = epic_tournament
		remove_character_modifier = holding_epic_tournament
		clr_character_flag = do_not_disturb
	}
}

# Tournament has been cancelled
character_event = {
	id = 70037
	title = "TOURNAMENTTITLE2"
	desc = "EVTDESC70037"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70037"
		remove_character_modifier = holding_epic_tournament
		clr_character_flag = do_not_disturb
		if = { 
			limit = { 
				FROM = { tier = EMPEROR } 
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			prestige = -50
		}	
		if = { 
			limit = { 
				FROM = { tier = KING } 
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			prestige = -30
		}
		if = { 
			limit = { 
				FROM = { tier = DUKE } 
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			prestige = -20
		}
		if = { 
			limit = { 
				FROM = { tier = COUNT } 
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			prestige = -10
		}	
		clr_character_flag = attending_tournament
		clr_character_flag = tournament_spectator
		clr_character_flag = king_tourny
		clr_character_flag = grand_tourny
		clr_character_flag = normal_tourny
		clr_character_flag = small_tourny
		clr_character_flag = tourny_outcome_1
		clr_character_flag = tourny_outcome_2
		clr_character_flag = tourny_outcome_3
		clr_character_flag = tourny_outcome_4
		hidden_tooltip = {	
			remove_opinion = {
				modifier = opinion_attending_tournament
				who = FROM
			}
			remove_opinion = {
				modifier = opinion_spectating_tournament
				who = FROM
			}
			reverse_remove_opinion = {
				modifier = opinion_attending_tournament
				who = FROM
			}
			reverse_remove_opinion = {
				modifier = opinion_spectating_tournament
				who = FROM
			}
		}
	}
}
# Count Competitors
character_event = {
	id = tourney.4	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		set_variable = { which = "count_competitor_iterations" value = 0 } #To make sure it doesn't take too long
			
		any_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_tournament
				NOT = { has_character_flag = lost_tournament }
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}	
			ROOT = { change_variable = { which = "tourney_competitors" value = 1 } }
		}	
		character_event = { id = tourney.5 days = 1 }
	}
	option = {
		name = OK
	}
}	
character_event = {
	id = tourney.5	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {	
		#If 3 or less create randoms to make 4
		if = {
			limit = { NOT = { check_variable = { which = "tourney_competitors" value = 4 } } }
			capital_scope = {
				ROOT = {
					create_character = {
						random_traits = yes
						dynasty = none
						culture = PREV
						religion = PREV
					}
					new_character = {
						set_character_flag = new_knight
						random_list = {
							50 = { add_trait = trained_warrior }
							40 = { add_trait = poor_warrior }
							10 = { add_trait = skilled_warrior }
						}
					}	
				}
			}	
		}	
		if = {
			limit = { NOT = { check_variable = { which = "tourney_competitors" value = 3 } } }
			capital_scope = {
				ROOT = {
					create_character = {
						random_traits = yes
						dynasty = none
						culture = PREV
						religion = PREV
					}
					new_character = {
						set_character_flag = new_knight
						random_list = {
							50 = { add_trait = trained_warrior }
							40 = { add_trait = poor_warrior }
							10 = { add_trait = skilled_warrior }
						}
					}	
				}
			}			
		}	
		if = {
			limit = { NOT = { check_variable = { which = "tourney_competitors" value = 2 } } }
			capital_scope = {
				ROOT = {
					create_character = {
						random_traits = yes
						dynasty = none
						culture = PREV
						religion = PREV
					}
					new_character = {
						set_character_flag = new_knight
						random_list = {
							50 = { add_trait = trained_warrior }
							40 = { add_trait = poor_warrior }
							10 = { add_trait = skilled_warrior }
						}
					}	
				}
			}			
		}	
		if = {
			limit = { NOT = { check_variable = { which = "tourney_competitors" value = 1 } } }
			capital_scope = {
				ROOT = {
					create_character = {
						random_traits = yes
						dynasty = none
						culture = PREV
						religion = PREV
					}
					new_character = {
						set_character_flag = new_knight
						random_list = {
							50 = { add_trait = trained_warrior }
							40 = { add_trait = poor_warrior }
							10 = { add_trait = skilled_warrior }
						}
					}	
				}
			}			
		}	
		#If no skilled knights create one
		if = {
			limit = { 
				NOT = {
					any_courtier = {
						trait = knight
						OR = {
							trait = skilled_warrior
							trait = master_warrior
						}
						has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					}
				}	
			}
			capital_scope = {
				ROOT = {
					create_character = {
						random_traits = yes
						dynasty = none
						culture = PREV
						religion = PREV
					}
					new_character = {
						set_character_flag = new_knight
						random_list = {
							50 = { add_trait = trained_warrior }
							40 = { add_trait = poor_warrior }
							10 = { add_trait = skilled_warrior }
						}
					}	
				}
			}			
		}
		
		any_courtier = {
			limit = { has_character_flag = new_knight }
			clr_character_flag = new_knight
			if = {
				limit = { religion = the_seven }
				knight_character_effect = yes
			}	
			remove_trait = weak
			remove_trait = imbecile
			remove_trait = clubfooted
			remove_trait = inbred
			set_character_flag = attending_tournament
			opinion = {
				modifier = opinion_attending_tournament
				who = ROOT
				years = 100
			}
			reverse_opinion = {
				modifier = opinion_attending_tournament
				who = ROOT
				years = 100
			}
			if = { 
				limit = { ROOT = { has_character_flag = king_tourny } }
				set_character_flag = king_tourny
			}	
			if = { 
				limit = { ROOT = { has_character_flag = grand_tourny } }
				set_character_flag = grand_tourny
			}
			if = { 
				limit = { ROOT = { has_character_flag = normal_tourny } }
				set_character_flag = normal_tourny
			}
			if = { 
				limit = { ROOT = { has_character_flag = small_tourny } }
				set_character_flag = small_tourny
			}	
		}	
		#If 32 or less proceed
		if = {
			limit = { NOT = { check_variable = { which = "tourney_competitors" value = 32 } } }
			set_variable = { which = "tourney_competitors" value = 0 }
			set_character_flag = knights_found
			character_event = { id = tourney.9 days = 1 } 		
		}
		#if more than 32 randomly remove competitors
		if = {
			limit = { 
				NOT = { has_character_flag = knights_found }
				check_variable = { which = "tourney_competitors" value = 32 } 
			} 
			any_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					NOT = { has_character_flag = lost_tournament }
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
				}
				character_event = { id = tourney.6 days = 2 random = 1 }
			}
			change_variable = { which = "count_competitor_iterations" value = 1 }
			#set_variable = { which = "tourney_competitors" value = 0 }
			character_event = { id = tourney.5 days = 4 } #Recount loop
		}
	}
	option = {
		name = OK
	}
}
#Candidate is randomly removed from tourney
character_event = {
	id = tourney.6
	
	is_triggered_only = yes
	
	hide_window = yes
	
	trigger = {
		FROM = {
			NOT = { has_character_flag = knights_found }
			check_variable = { which = "tourney_competitors" value = 32 } 
		}
	}
	
	immediate = {
		c_the_citadel = {
			holder_scope = {
				character_event = { id = tourney.7 } 
			}
		}
	}
	
	option = {
		name = OK
	}
}	
character_event = {
	id = tourney.7
	desc = "AI only tourney.event 7" 
	
	is_triggered_only = yes
	
	option = { #Survive
		name = OK
		ai_chance = { 
			factor = 50
			modifier = {
				factor = 0
				FROM = { #Can no longer compete
					OR = {
						prisoner = yes
						has_epidemic = yes
						has_severe_disability_trigger = yes
					}
				}
			}
			modifier = {
				factor = 6
				FROM = { trait = master_warrior }
			}
			modifier = {
				factor = 3
				FROM = { trait = skilled_warrior }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = knight }
			}
			# modifier = {
				# factor = 4
				# FROM = { has_character_modifier = golden_bow }
			# }
			# modifier = {
				# factor = 2
				# FROM = { has_character_modifier = good_bow }
			# }
			modifier = {
				factor = 3
				FROM = { is_strong_trigger = yes }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = tall }
			}
			modifier = {
				factor = 3
				FROM = { trait = genius }
			}
			modifier = {
				factor = 2
				FROM = { is_smart_trigger = yes }
			}		
			modifier = {
				factor = 1.1
				FROM = {
					any_ward = {
						trait = squire
						OR = {
							trait = poor_warrior
							trait = trained_warrior
						}	
					}
				}	
			}
			modifier = {
				factor = 1.25
				FROM = {
					any_ward = {
						trait = squire
						OR = {
							trait = skilled_warrior
							trait = master_warrior						
						}
					}
				}	
			}
		}	
	}
	
	option = { #Remove
		name = OK
		ai_chance = { 
			factor = 15
			#try to make sure this doesn't loop too much
			modifier = {
				factor = 1.5
				FROM = { FROM = { check_variable = { which = "count_competitor_iterations" value = 2 } } }
			}
			modifier = {
				factor = 1.5
				FROM = { FROM = { check_variable = { which = "count_competitor_iterations" value = 4 } } }
			}
			modifier = {
				factor = 1.5
				FROM = { FROM = { check_variable = { which = "count_competitor_iterations" value = 6 } } }
			}
			modifier = {
				factor = 2
				FROM = { FROM = { check_variable = { which = "count_competitor_iterations" value = 7 } } }
			}
			modifier = {
				factor = 2
				FROM = { FROM = { check_variable = { which = "count_competitor_iterations" value = 8 } } }
			}
			modifier = {
				factor = 1.5
				FROM = { FROM = { check_variable = { which = "count_competitor_iterations" value = 9 } } }
			}
			
			modifier = {
				factor = 6
				FROM = { 
					NOT = {
						OR = {
							trait = master_warrior
							trait = skilled_warrior
							trait = trained_warrior
							trait = poor_warrior
						}
					}
				}	
			}
			modifier = {
				factor = 3
				FROM = { trait = poor_warrior }
			}
			modifier = {
				factor = 3
				FROM = { is_weak_trigger = yes }
			}
			modifier = {
				factor = 100
				FROM = { trait = infirm }
			}
			modifier = {
				factor = 3
				FROM = { trait = imbecile }
			}
			modifier = {
				factor = 2
				FROM = { is_dumb_trigger = yes }
			}	
			modifier = {
				factor = 1.5
				FROM = { trait = craven }
			}
			modifier = {
				factor = 1.5
				FROM = { age = 45 }
			}
			modifier = {
				factor = 1.5
				FROM = { age = 60 }
			}
			modifier = {
				factor = 2
				FROM = { age = 70 }
			}
			modifier = {
				factor = 2
				FROM = { age = 80 }
			}
			modifier = {
				factor = 2
				NOT = { FROM = { age = 16 } }
			}
		}	
		FROM = {	
			set_character_flag = lost_tournament	
			prestige = -30
			hidden_tooltip = {
				any_dynasty_member = {
					limit = {
						ai = no
						is_close_relative = PREV
						has_character_flag = tournament_spectator
						has_character_flag = attending_tournament
					}
					character_event = { id = 70097 }
				}
			}
			if = {
				limit = { ai = no }
				random_opinion_modifier_target = {
					limit = {
						has_character_flag = tourny_in_progress
						reverse_has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
					}
					random_opinion_modifier_target = {
						limit = {				
							has_character_flag = attending_tournament
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							NOT = { has_character_flag = lost_tournament }
							NOT = { character = PREVPREV }
						}
						character_event = { id = tourney.800 }
					}
				}		 
			}	
		}
		FROM = { FROM = { change_variable = { which = "tourney_competitors" value = -1 } } }
			
	}
}	
#Inform lost tourney
character_event = { #scope to random adversary
	id = tourney.800

	is_triggered_only = yes
	hide_window = yes
	
	immediate = { FROMFROM = { character_event = { id = tourney.8 } } }
	
	option = {
		name = "OK"		
	}
}	
character_event = {
	id = tourney.8
	desc = "EVTDESCtourney.8" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = { 
		prestige = 30 
	}
	
	option = {
		name = "EVTOPTAtourney.8"
		prestige = -30	
	}
	
	option = {
		name = "EVTOPTB70005" #blame squire
		trigger = {
			any_ward = { trait = squire }
		}
		prestige = -15	
		random_ward = {
			limit = { trait = squire }
			opinion = {
				modifier = opinion_squire_humiliated
				who = ROOT
				years = 2
			}	
			prestige = -15	
		}
	}
}	
###Final jousters found, inform host###
character_event = {
	id = tourney.9
	title = "TOURNAMENTTITLE3"
	desc = "EVTDESCtourney.9" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = { 
		set_variable = { which = "tourney_competitors" value = 0 } 
		clr_character_flag = knights_found
		set_character_flag = tourney_final_round
		hidden_tooltip = {
			any_opinion_modifier_target = { #inform player
				limit = { 
					ai = no
					has_character_flag = attending_tournament
					OR = {
						AND = {
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							has_character_flag = lost_tournament
						}	
						has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
					}
					NOT = { character = ROOT }
				}
				character_event = { id = tourney.909 }
			}
		}	
	}
	
	option = {
		name = "EVTOPTAtourney.9" 	
		clr_character_flag = inform_of_all_tourney_results	
		#hidden_tooltip = { character_event = { id = tourney.11 days = 1 } }
		custom_tooltip = { text = TOOLTIPtourney.9 }
		any_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_tournament
				NOT = { has_character_flag = lost_tournament }
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			show_portrait = yes
			set_character_flag = tourney.10
			hidden_tooltip = { ROOT = { change_variable = { which = "tourney_competitors" value = 1 } } }
			character_event = { id = tourney.10 tooltip = TOOLTIPtourney.10 }
		}
		custom_tooltip = { text = TOOLTIPtourney.909 } #informs of available decision
	}
	
	option = {
		name = "EVTOPTBtourney.9" #Inform of all tilts
		trigger = {
			ai = no
		}
		custom_tooltip = { text = TOOLTIPEVTOPTBarchery.2 }
		set_character_flag = inform_of_all_tourney_results		
		hidden_tooltip = {
			any_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					NOT = { has_character_flag = lost_tournament }
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
				}
				hidden_tooltip = { ROOT = { change_variable = { which = "tourney_competitors" value = 1 } } }
				character_event = { id = tourney.10 tooltip = TOOLTIPtourney.10 }
			}
		}
	}
}
character_event = { #inform player
	id = tourney.909
	desc = "EVTDESCtourney.909"
	picture = "GFX_evt_melee"

	is_triggered_only = yes

	option = {
		name = "EVTOPTAtourney.909" 
		FROM = {
			custom_tooltip = { text = TOOLTIPtourney.9 }
			any_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					NOT = { has_character_flag = lost_tournament }
					has_opinion_modifier = { who = ROOT_FROM modifier = opinion_attending_tournament }
				}
				show_portrait = yes
				tooltip = { character_event = { id = tourney.10 tooltip = TOOLTIPtourney.10 } }
			}
		}
	}
	option = { #place bet!
		name = "EVTOPTBtourney.909" 
		custom_tooltip = { text = TOOLTIPtourney.909 } #informs of available decision
	}
}
#Inform Archer they made final rounds
character_event = {
	id = tourney.10
	title = "TOURNAMENTTITLE2"
	desc = "EVTDESCtourney.10" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.10" 		
		FROM = {
			custom_tooltip = { text = TOOLTIPtourney.9 }
			any_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					NOT = { has_character_flag = lost_tournament }
					has_opinion_modifier = { who = ROOT_FROM modifier = opinion_attending_tournament }
				}
				show_portrait = yes
				tooltip = { character_event = { id = tourney.10 tooltip = TOOLTIPtourney.10 } }
			}
		}
	}
	option = { #place bet!
		name = "EVTOPTBtourney.909" 
		custom_tooltip = { text = TOOLTIPtourney.909 } #informs of available decision
	}
	after = {
		clr_character_flag = tourney.10
		hidden_tooltip = { character_event = { id = tourney.12 days = 2 random = 1 } } 
	}
}	
###New Match Up###
#Match jousters
character_event = {
	id = tourney.12	
	
	hide_window = yes
	has_character_flag = attending_tournament
	#is_triggered_only = yes
	
	trigger = {	
		NOT = { has_character_flag = lost_tournament }
		any_opinion_modifier_target = {
			has_character_flag = tourney_final_round
			reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
		}	
		OR = {
			NOT = { has_character_flag = in_joust }
			had_character_flag = { flag = in_joust days = 7 }
		}
	}
	
	mean_time_to_happen = { days = 7 }
	
	immediate = {
		if = { 
			limit = {
				OR = {
					prisoner = yes
					has_epidemic = yes
					has_severe_disability_trigger = yes
				}
			}
			set_character_flag = lost_tournament
			random_opinion_modifier_target = {
				limit = {
					has_character_flag = tourney_final_round
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
				}
				change_variable = { which = "tourney_competitors" value = -1 }
			}
			break = yes
		}
		
		random_opinion_modifier_target = {
			limit = {
				has_character_flag = tourny_in_progress
				reverse_has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
			}
			random_opinion_modifier_target = {
				limit = {				
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
					NOT = { has_character_flag = lost_tournament }
					NOT = { character = ROOT }
					OR = {
						NOT = { has_character_flag = in_joust }
						had_character_flag = { flag = in_joust days = 7 }
					}
				}
				set_character_flag = in_joust
				ROOT = { set_character_flag = in_joust }
				character_event = { id = tourney.13 } 
			}			
		}	
	}
	
	option = {
		name = OK	
	}
}	
#Inform 2nd jouster
character_event = {
	id = tourney.13
	desc = "EVTDESCtourney.13" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		clr_character_flag = bribed_to_lose
		clr_character_flag = squire_bribed
	}
	
	option = {
		name = "EVTOPTAtourney.13" 
		ai_chance = {
			factor = 1
		}
		FROM = { character_event = { id = tourney.14 tooltip = TOOLTIPtourney.14 } }		
	}
	
	option = {
		name = "EVTOPTBtourney.13" #Attempt bribe
		trigger = {
			intrigue = 8
			NOT = { trait = honest }
			NOT = { trait = honorable }
			NOT = { trait = just }		
			FROM = {
				lower_tier_than = KING
				NOT = { trait = honest }
				NOT = { trait = honorable }
				NOT = { trait = just }
				OR = {
					trait = greedy
					trait = deceitful
				}
			}	
			wealth = 25
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					trait = content
					trait = slothful
					AND = {
						trait = master_warrior
						FROM = { NOT = { trait = master_warrior } }
					}
					AND = {
						trait = skilled_warrior
						FROM = { 
							NOT = { trait = master_warrior } 
							NOT = { trait = skilled_warrior } 
						}
					}
				}
			}
		}
		tooltip_info = intrigue
		FROM = { character_event = { id = tourney.40 tooltip = TOOLTIPtourney.40 } }		
	}
	
	option = {
		name = "EVTOPTCtourney.13" #bribe squire
		trigger = {
			intrigue = 10
			NOT = { trait = honest }
			NOT = { trait = honorable }
			NOT = { trait = just }				
			FROM = {
				NOT = { reverse_opinion = { who = ROOT value = -30 } }
				any_ward = {
					trait = squire
					age = 12
					NOT = { trait = honest }
					NOT = { trait = honorable }
					NOT = { trait = just }
					OR = {
						trait = greedy
						trait = deceitful
					}
					NOT = { reverse_opinion = { who = PREV value = -15 } }
				}	
			}	
			wealth = 25
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					trait = content
					trait = slothful
					AND = {
						trait = master_warrior
						FROM = { NOT = { trait = master_warrior } }
					}
					AND = {
						trait = skilled_warrior
						FROM = { 
							NOT = { trait = master_warrior } 
							NOT = { trait = skilled_warrior } 
						}
					}
				}
			}
		}
		tooltip_info = intrigue
		FROM = { 
			random_ward = {
				limit = {
					trait = squire
					age = 12
					NOT = { trait = honest }
					NOT = { trait = honorable }
					NOT = { trait = just }
					OR = {
						trait = greedy
						trait = deceitful
					}
					NOT = { reverse_opinion = { who = PREV value = -15 } }
				}
				character_event = { id = tourney.75 tooltip = TOOLTIPtourney.75 } 
			}	
		}		
	}
}	
#Inform 1st jouster
character_event = {
	id = tourney.14
	desc = "EVTDESCtourney.13" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		clr_character_flag = bribed_to_lose
		clr_character_flag = squire_bribed
	}
	
	option = {
		name = "EVTOPTAtourney.13" 
		custom_tooltip = { text = TOOLTIPtourney.14 }
		hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 1 } } } }
	}
	
	option = {
		name = "EVTOPTBtourney.13" #Attempt bribe
		trigger = {
			intrigue = 8
			NOT = { trait = honest }
			NOT = { trait = honorable }
			NOT = { trait = just }		
			FROM = {
				lower_tier_than = KING
				NOT = { trait = honest }
				NOT = { trait = honorable }
				NOT = { trait = just }
				OR = {
					trait = greedy
					trait = deceitful
				}
			}	
			wealth = 25
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					trait = content
					trait = slothful
					AND = {
						trait = master_warrior
						FROM = { NOT = { trait = master_warrior } }
					}
					AND = {
						trait = skilled_warrior
						FROM = { 
							NOT = { trait = master_warrior } 
							NOT = { trait = skilled_warrior } 
						}
					}
				}
			}
		}
		tooltip_info = intrigue
		FROM = { character_event = { id = tourney.40 tooltip = TOOLTIPtourney.40 } }		
	}
	option = {
		name = "EVTOPTCtourney.13" #bribe squire
		trigger = {
			intrigue = 10
			NOT = { trait = honest }
			NOT = { trait = honorable }
			NOT = { trait = just }				
			FROM = {
				NOT = { reverse_opinion = { who = ROOT value = -30 } }
				any_ward = {
					trait = squire
					age = 12
					NOT = { trait = honest }
					NOT = { trait = honorable }
					NOT = { trait = just }
					OR = {
						trait = greedy
						trait = deceitful
					}
					NOT = { reverse_opinion = { who = PREV value = -15 } }
				}	
			}	
			wealth = 25
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					trait = content
					trait = slothful
					AND = {
						trait = master_warrior
						FROM = { NOT = { trait = master_warrior } }
					}
					AND = {
						trait = skilled_warrior
						FROM = { 
							NOT = { trait = master_warrior } 
							NOT = { trait = skilled_warrior } 
						}
					}
				}
			}
		}
		tooltip_info = intrigue
		FROM = { 
			random_ward = {
				limit = {
					trait = squire
					age = 12
					NOT = { trait = honest }
					NOT = { trait = honorable }
					NOT = { trait = just }
					OR = {
						trait = greedy
						trait = deceitful
					}
					NOT = { reverse_opinion = { who = PREV value = -15 } }
				}
				character_event = { id = tourney.75 tooltip = TOOLTIPtourney.75 } 
			}	
		}	
		hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 2 } } } }
	}
}
#Citadel Determines Round Winner
character_event = {
	id = tourney.15

	is_triggered_only = yes
	
	option = {
		name = "FROM wins"
		trigger = { 
			FROM = { is_alive = yes } 
			FROM = { FROM = { is_alive = yes } }
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				FROM = { has_character_flag = bribed_to_lose }
			}	
			modifier = {
				factor = 0.5
				FROM = { has_character_flag = squire_bribed }
			}
			
			# Random factor Rule Effects
			# if these factors are changed the game rule localisation must be changed
			modifier = { #high
				factor = 2
				FROMFROM = { combat_rating_diff = { who = ROOT_FROM value = 3 } }
				has_game_rule = { name = duel_outcome_randomness value = high } 
			}
			modifier = { #low
				factor = 1.75
				FROM = { combat_rating_diff = { who = ROOT_FROMFROM value = 2.5 } }
				has_game_rule = { name = duel_outcome_randomness value = low }
			}
			modifier = {
				factor = 1.286
				FROM = { combat_rating_diff = { who = ROOT_FROMFROM value = 4 } }
				has_game_rule = { name = duel_outcome_randomness value = low }
			}
			modifier = { #very low
				factor = 4.5
				FROM = { combat_rating_diff = { who = ROOT_FROMFROM value = 2.5 } }
				has_game_rule = { name = duel_outcome_randomness value = very_low }
			}
			modifier = {
				factor = 2.667
				FROM = { combat_rating_diff = { who = ROOT_FROMFROM value = 4 } }
				has_game_rule = { name = duel_outcome_randomness value = very_low }
			}
						
			# Skill-at-Arms Effects
			modifier = {
				factor = 2
				FROM = { trait = poor_warrior }
			}
			modifier = {
				factor = 4
				FROM = { trait = trained_warrior }
			}
			modifier = {
				factor = 8
				FROM = { trait = skilled_warrior }
			}
			modifier = {
				factor = 16
				FROM = { trait = master_warrior }
			}

			#Sinful Edits
			modifier = {
				factor = 2
				FROM = { trait = sword_legend }
			}
			modifier = {
				factor = 3
				FROM = {
					OR = {
						trait = sin_armor_knight
						trait = sin_armor_knightplate
					}
				}
			}
			modifier = {
				factor = 2
				FROM = {
					OR = {
						trait = sin_armor_blackplate
						trait = sin_armor_goldplate
						trait = sin_armor_plate
					}
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					OR = {
						trait = sin_armor_blackleather
						trait = sin_armor_bronzemail
						trait = sin_armor_chain
						trait = sin_armor_light
					}
				}
			}
			modifier = {
				factor = 10
				FROM = { trait = sin_armor_valyrian_fitted }
			}
			# Physical Strength Effects
			modifier = {
				factor = 2
				FROM = { is_strong_trigger = yes }
			}
			modifier = {
				factor = 0.5
				FROM = { is_weak_trigger = yes }
			}
			
			# Cunning/Intelligence Effects
			modifier = {
				factor = 2
				FROM = { trait = genius }
			}
			modifier = {
				factor = 1.5
				FROM = { is_smart_trigger = yes }
			}
			modifier = {
				factor = 0.5
				FROM = { trait = imbecile }
			}
			modifier = {
				factor = 0.666
				FROM = { is_dumb_trigger = yes }
			}
			
			# Personality Effects
			modifier = {
				factor = 2
				FROM = { trait = brave }
			}
			modifier = {
				factor = 0.5
				FROM = { trait = craven }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = deceitful }
			}
			modifier = {
				factor = 0.666
				FROM = { trait = honest }
			}
			modifier = {
				factor = 2
				FROM = { trait = ruthless }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = cannibal_trait }
			}
			
			# Wound Effects
			modifier = {
				factor = 0.5
				FROM = { trait = wounded }
			}
			modifier = {
				factor = 0.25
				FROM = { trait = maimed }
			}
			modifier = {
				factor = 0
				FROM = { 
					OR = {
						trait = incapable 
						trait = crippled	
						trait = sick_incapable
					}	
				}
				FROMFROM = { 
					NOR = {
						trait = incapable 
						trait = crippled
						trait = sick_incapable						
					}	
				}
			}
			modifier = {
				factor = 0.25
				FROM = { trait = one_eyed }
			}
			modifier = {
				factor = 0.125
				FROM = { trait = one_handed }
			}
			modifier = {
				factor = 0.125
				FROM = { trait = one_legged }
			}
			modifier = {
				factor = 0.05
				FROM = { trait = mangled }
			}
			modifier = {
				factor = 0.125
				FROM = { trait = severely_injured }
			}
			
			# Health Effects			
			modifier = {
				factor = 0.5
				FROM = { is_ill = yes }
			}	
			modifier = {
				factor = 0.25
				FROM = { trait = infirm }
			}
			modifier = {
				factor = 0.166
				FROM = { has_epidemic = yes }	
			}
			modifier = {
				factor = 0.033
				FROM = {
					OR = {
						trait = blinded
						trait = blinded_age
					}
				}	
			}
			modifier = {
				factor = 0.75
				FROM = { trait = drunkard }
			}
			
			# Body Shape Effects
			modifier = {
				factor = 3
				FROM = { trait = tall }
			}
			modifier = {
				factor = 0.25
				FROM = { trait = hunchback }
			}
			modifier = {
				factor = 0.25
				FROM = { trait = dwarf }
			}
			modifier = {
				factor = 0.25
				FROM = { trait = clubfooted }
			}
			
			# Age Effects
			modifier = {
				factor = 0.5
				FROM = { age = 50 }
			}
			modifier = {
				factor = 0.333
				FROM = { age = 70 }
			}
			
			modifier = {
				factor = 0.5
				NOT = { FROM = { age = 16 } }
			}
			modifier = {
				factor = 0.5
				NOT = { FROM = { age = 12 } }
			}
			modifier = {
				factor = 0.5
				NOT = { FROM = { age = 8 } }
			}
			modifier = {
				factor = 0.5
				NOT = { FROM = { age = 4 } }
			}
			
			# Way of Life war focus effects
			modifier = {
				factor = 1.5
				FROM = { has_character_modifier = wol_duel_training }
			}
			modifier = {
				factor = 1.5
				FROM = { has_character_modifier = wol_war_fit }
			}
					
			# Magical Effects
			modifier = {
				factor = 2
				FROM = { trait = chosen_by_rhllor }
			}
			modifier = {
				factor = 4
				FROM = { trait = resurrected_by_rhllor }
			}
			modifier = {
				factor = 1.25
				FROM = { trait = favored_by_rhllor }
			}
			modifier = {
				factor = 0.8
				107 = { 
					NOT = { has_province_modifier = completeharren3 } 
					NOT = { has_province_flag = pre_harren_harrenhal }
				}
				FROM = { has_landed_title = c_harrenhal }
			}
			modifier = {
				factor = 0.8
				107 = { 
					NOT = { has_province_modifier = completeharren3 } 
					NOT = { has_province_flag = pre_harren_harrenhal }
				}
				c_harrenhal = {
					holder_scope = {
						OR = {
							any_child = { character = FROM }
							any_child = { any_child = { character = FROM } }
						}
					}
				}
			}
			modifier = {
				factor = 2
				FROM = { has_character_modifier = demon_child_non_pagan }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = dragon_dreams } # Can see into the future-ish
			}
			modifier = {
				factor = 5
				FROM = { trait = white_walker } # Counteract age effect
			}
			modifier = {
				factor = 4
				FROM = { trait = immortal } # Counteract age effect
			}
			modifier = {
				factor = 4
				FROM = { trait = undead }
			}
			
			# Misc character modifiers
			modifier = {
				factor = 1.25
				FROM = { has_character_modifier = wolf_blood }
			}
			modifier = {
				factor = 1.25
				FROM = { has_character_modifier = lycanthropy }
			}
			modifier = {
				factor = 1.25
				FROM = { has_character_modifier = manly_skill_wrestling }
			}
			modifier = {
				factor = 4
				FROM = { has_character_modifier = martially_ambidextrous }
			}
			modifier = {
				factor = 1.25
				FROM = { has_character_modifier = iron_hand }
			}
			modifier = {
				factor = 1.5
				FROM = { has_character_modifier = prosthetic_leg }
			}
			modifier = {
				factor = 1.25
				FROM = { has_character_modifier = peg_leg }
			}
			modifier = {
				factor = 0.5
				FROM = { has_character_modifier = phantom_pain }
			}
			modifier = {
				factor = 0.5
				FROM = { has_character_modifier = severe_illness }
			}
			modifier = {
				factor = 0.05
				FROM = { has_character_modifier = bedridden_illness }
			}
					
			modifier = {
				factor = 1.5
				FROM = { trait = knight }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = duelist }
			}			
			modifier = {
				factor = 1.1
				FROM = {
					any_ward = {
						trait = squire
						combat_rating = 2	
					}
				}	
			}
			modifier = {
				factor = 1.25
				FROM = {
					any_ward = {
						trait = squire
						combat_rating = 6
					}
				}	
			}			
			modifier = {
				factor = 1.1
				FROM = {
					OR = {	
						has_character_flag = small_tourny_1st
						has_character_flag = normal_tourny_2nd
						has_character_flag = grand_tourny_3rd
					}
				}	
			}
			modifier = {
				factor = 1.25
				FROM = {
					OR = {	
						has_character_flag = normal_tourny_1st
						has_character_flag = grand_tourny_2nd
					}
				}	
			}
			modifier = {
				factor = 1.5
				FROM = { has_character_flag = grand_tourny_1st }
			}
		}
		if = { #avoid numerous iterations for AI only jousts
			limit = {
				FROMFROM = { ai = yes }
				FROM = { ai = yes }
			}
			FROM = { 
				FROM = { 
					set_character_flag = lost_round
					#Determine outcome
					if = {
						limit = { NOT = { has_character_flag = bribed_to_lose } }				
						random_list = {
							1 = { #0.5
								modifier = { factor = 0.5 }
								set_character_flag = death 
							}
							1 = { 						
								set_character_flag = maimed 
							}
							6 = { 
								set_character_flag = wounded 
							}
							185 = { #92.5
								modifier = { factor = 0.5 }
								set_character_flag = unhorsed 
							}
							#40 = { set_character_flag = survive }
						}
					}	
				} 
			}
		}
		if = {
			limit = {
				OR = {
					FROMFROM = { ai = no }
					FROM = { ai = no }
				}
			}
			FROM = { 
				FROM = { 
					set_character_flag = lost_round
					#Determine outcome
					if = {
						limit = { NOT = { has_character_flag = bribed_to_lose } }				
						random_list = {
							1 = { #0.25
								modifier = { factor = 0.25 }
								set_character_flag = death 
							} 
							1 = { #0.5
								modifier = { factor = 0.5 }
								set_character_flag = maimed 
							}
							3 = { 
								set_character_flag = wounded 
							}
							265 = { #66.25
								modifier = { factor = 0.25 }
								set_character_flag = unhorsed 
							}
							30 = { 
								set_character_flag = survive 
							}
						}
					}	
				} 
			}
		}	
		FROM = { 		
			FROM = { 
				character_event = { id = tourney.19 days = 2 } #New Round	
				character_event = { id = tourney.17 } 		
			} 
			character_event = { id = tourney.16 } 
		}		
	}
	
	option = {
		name = "FROM FROM wins"
		trigger = { 
			FROM = { is_alive = yes } 
			FROM = { FROM = { is_alive = yes } }
		}
		ai_chance = {
			factor = 50
			
			modifier = {
				factor = 0
				FROMFROM = { has_character_flag = bribed_to_lose }
			}		
			modifier = {
				factor = 0.5
				FROMFROM = { has_character_flag = squire_bribed }
			}
			
			# Random factor Rule Effects
			# if these factors are changed the game rule localisation must be changed
			modifier = { #high
				factor = 2
				FROM = { combat_rating_diff = { who = ROOT_FROMFROM value = 3 } }
				has_game_rule = { name = duel_outcome_randomness value = high } 
			}
			modifier = { #low
				factor = 1.75
				FROMFROM = { combat_rating_diff = { who = ROOT_FROM value = 2.5 } }
				has_game_rule = { name = duel_outcome_randomness value = low }
			}
			modifier = {
				factor = 1.286
				FROMFROM = { combat_rating_diff = { who = ROOT_FROM value = 4 } }
				has_game_rule = { name = duel_outcome_randomness value = low }
			}
			modifier = { #very low
				factor = 4.5
				FROMFROM = { combat_rating_diff = { who = ROOT_FROM value = 2.5 } }
				has_game_rule = { name = duel_outcome_randomness value = very_low }
			}
			modifier = {
				factor = 2.667
				FROMFROM = { combat_rating_diff = { who = ROOT_FROM value = 4 } }
				has_game_rule = { name = duel_outcome_randomness value = very_low }
			}
						
			# Skill-at-Arms Effects
			modifier = {
				factor = 2
				FROMFROM = { trait = poor_warrior }
			}
			modifier = {
				factor = 4
				FROMFROM = { trait = trained_warrior }
			}
			modifier = {
				factor = 8
				FROMFROM = { trait = skilled_warrior }
			}
			modifier = {
				factor = 16
				FROMFROM = { trait = master_warrior }
			}

			#Sinful Edits
			modifier = {
				factor = 2
				FROMFROM = { trait = sword_legend }
			}
			modifier = {
				factor = 3
				FROMFROM = {
					OR = {
						trait = sin_armor_knight
						trait = sin_armor_knightplate
					}
				}
			}
			modifier = {
				factor = 2
				FROMFROM = {
					OR = {
						trait = sin_armor_blackplate
						trait = sin_armor_goldplate
						trait = sin_armor_plate
					}
				}
			}
			modifier = {
				factor = 1.5
				FROMFROM = {
					OR = {
						trait = sin_armor_blackleather
						trait = sin_armor_bronzemail
						trait = sin_armor_chain
						trait = sin_armor_light
					}
				}
			}
			modifier = {
				factor = 10
				FROMFROM = { trait = sin_armor_valyrian_fitted }
			}

			# Physical Strength Effects
			modifier = {
				factor = 2
				FROMFROM = { is_strong_trigger = yes }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { is_weak_trigger = yes }
			}
			
			# Cunning/Intelligence Effects
			modifier = {
				factor = 2
				FROMFROM = { trait = genius }
			}
			modifier = {
				factor = 1.5
				FROMFROM = { is_smart_trigger = yes }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { trait = imbecile }
			}
			modifier = {
				factor = 0.666
				FROMFROM = { is_dumb_trigger = yes }
			}
			
			# Personality Effects
			modifier = {
				factor = 2
				FROMFROM = { trait = brave }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { trait = craven }
			}
			modifier = {
				factor = 1.5
				FROMFROM = { trait = deceitful }
			}
			modifier = {
				factor = 0.666
				FROMFROM = { trait = honest }
			}
			modifier = {
				factor = 2
				FROMFROM = { trait = ruthless }
			}
			modifier = {
				factor = 1.5
				FROMFROM = { trait = cannibal_trait }
			}
			
			# Wound Effects
			modifier = {
				factor = 0.5
				FROMFROM = { trait = wounded }
			}
			modifier = {
				factor = 0.25
				FROMFROM = { trait = maimed }
			}
			modifier = {
				factor = 0
				FROMFROM = { 
					OR = {
						trait = incapable 
						trait = crippled	
						trait = sick_incapable
					}	
				}
				FROM = { 
					NOR = {
						trait = incapable 
						trait = crippled
						trait = sick_incapable						
					}	
				}
			}
			modifier = {
				factor = 0.25
				FROMFROM = { trait = one_eyed }
			}
			modifier = {
				factor = 0.125
				FROMFROM = { trait = one_handed }
			}
			modifier = {
				factor = 0.125
				FROMFROM = { trait = one_legged }
			}
			modifier = {
				factor = 0.05
				FROMFROM = { trait = mangled }
			}
			modifier = {
				factor = 0.125
				FROMFROM = { trait = severely_injured }
			}
			
			# Health Effects			
			modifier = {
				factor = 0.5
				FROMFROM = { is_ill = yes }
			}	
			modifier = {
				factor = 0.25
				FROMFROM = { trait = infirm }
			}
			modifier = {
				factor = 0.166
				FROMFROM = { has_epidemic = yes }	
			}
			modifier = {
				factor = 0.033
				FROMFROM = {
					OR = {
						trait = blinded
						trait = blinded_age
					}
				}	
			}
			modifier = {
				factor = 0.75
				FROMFROM = { trait = drunkard }
			}
			
			# Body Shape Effects
			modifier = {
				factor = 3
				FROMFROM = { trait = tall }
			}
			modifier = {
				factor = 0.25
				FROMFROM = { trait = hunchback }
			}
			modifier = {
				factor = 0.25
				FROMFROM = { trait = dwarf }
			}
			modifier = {
				factor = 0.25
				FROMFROM = { trait = clubfooted }
			}
			
			# Age Effects
			modifier = {
				factor = 0.5
				FROMFROM = { age = 50 }
			}
			modifier = {
				factor = 0.333
				FROMFROM = { age = 70 }
			}
			
			modifier = {
				factor = 0.5
				NOT = { FROMFROM = { age = 16 } }
			}
			modifier = {
				factor = 0.5
				NOT = { FROMFROM = { age = 12 } }
			}
			modifier = {
				factor = 0.5
				NOT = { FROMFROM = { age = 8 } }
			}
			modifier = {
				factor = 0.5
				NOT = { FROMFROM = { age = 4 } }
			}
			
			# Way of Life war focus effects
			modifier = {
				factor = 1.5
				FROMFROM = { has_character_modifier = wol_duel_training }
			}
			modifier = {
				factor = 1.5
				FROMFROM = { has_character_modifier = wol_war_fit }
			}
					
			# Magical Effects
			modifier = {
				factor = 2
				FROMFROM = { trait = chosen_by_rhllor }
			}
			modifier = {
				factor = 4
				FROMFROM = { trait = resurrected_by_rhllor }
			}
			modifier = {
				factor = 1.25
				FROMFROM = { trait = favored_by_rhllor }
			}
			modifier = {
				factor = 0.8
				107 = { 
					NOT = { has_province_modifier = completeharren3 } 
					NOT = { has_province_flag = pre_harren_harrenhal }
				}
				FROMFROM = { has_landed_title = c_harrenhal }
			}
			modifier = {
				factor = 0.8
				107 = { 
					NOT = { has_province_modifier = completeharren3 } 
					NOT = { has_province_flag = pre_harren_harrenhal }
				}
				c_harrenhal = {
					holder_scope = {
						OR = {
							any_child = { character = FROMFROM }
							any_child = { any_child = { character = FROMFROM } }
						}
					}
				}
			}
			modifier = {
				factor = 2
				FROMFROM = { has_character_modifier = demon_child_non_pagan }
			}
			modifier = {
				factor = 1.5
				FROMFROM = { trait = dragon_dreams } # Can see into the future-ish
			}
			modifier = {
				factor = 5
				FROMFROM = { trait = white_walker } # Counteract age effect
			}
			modifier = {
				factor = 4
				FROMFROM = { trait = immortal } # Counteract age effect
			}
			modifier = {
				factor = 4
				FROMFROM = { trait = undead }
			}
			
			# Misc character modifiers
			modifier = {
				factor = 1.25
				FROMFROM = { has_character_modifier = wolf_blood }
			}
			modifier = {
				factor = 1.25
				FROMFROM = { has_character_modifier = lycanthropy }
			}
			modifier = {
				factor = 1.25
				FROMFROM = { has_character_modifier = manly_skill_wrestling }
			}
			modifier = {
				factor = 4
				FROMFROM = { has_character_modifier = martially_ambidextrous }
			}
			modifier = {
				factor = 1.25
				FROMFROM = { has_character_modifier = iron_hand }
			}
			modifier = {
				factor = 1.5
				FROMFROM = { has_character_modifier = prosthetic_leg }
			}
			modifier = {
				factor = 1.25
				FROMFROM = { has_character_modifier = peg_leg }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { has_character_modifier = phantom_pain }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { has_character_modifier = severe_illness }
			}
			modifier = {
				factor = 0.05
				FROMFROM = { has_character_modifier = bedridden_illness }
			}
					
			modifier = {
				factor = 1.5
				FROMFROM = { trait = knight }
			}	
			modifier = {
				factor = 1.5
				FROMFROM = { trait = duelist }
			}	
			modifier = {
				factor = 1.1
				FROMFROM = {
					any_ward = {
						trait = squire
						combat_rating = 2	
					}
				}	
			}
			modifier = {
				factor = 1.25
				FROMFROM = {
					any_ward = {
						trait = squire
						combat_rating = 6
					}
				}	
			}			
			modifier = {
				factor = 1.1
				FROMFROM = {
					OR = {	
						has_character_flag = small_tourny_1st
						has_character_flag = normal_tourny_2nd
						has_character_flag = grand_tourny_3rd
					}
				}	
			}
			modifier = {
				factor = 1.25
				FROMFROM = {
					OR = {	
						has_character_flag = normal_tourny_1st
						has_character_flag = grand_tourny_2nd
					}
				}	
			}
			modifier = {
				factor = 1.5
				FROMFROM = { has_character_flag = grand_tourny_1st }
			}
		}
		if = { #avoid numerous iterations for AI only jousts
			limit = {
				FROMFROM = { ai = yes }
				FROM = { ai = yes }
			}
			FROM = { 
				set_character_flag = lost_round
				#Determine outcome
				if = {
					limit = { NOT = { has_character_flag = bribed_to_lose } }				
					random_list = {
						1 = { #0.5
							modifier = { factor = 0.5 }
							set_character_flag = death 
						}
						1 = { 						
							set_character_flag = maimed 
						}
						6 = { 
							set_character_flag = wounded 
						}
						185 = { #92.5
							modifier = { factor = 0.5 }
							set_character_flag = unhorsed 
						}
						#40 = { set_character_flag = survive }
					}
				}		
			} 
		}
		if = {
			limit = {
				OR = {
					FROMFROM = { ai = no }
					FROM = { ai = no }
				}
			}
			FROM = { 
				set_character_flag = lost_round
				#Determine outcome
				if = {
					limit = { NOT = { has_character_flag = bribed_to_lose } }				
					random_list = {
						1 = { #0.25
							modifier = { factor = 0.25 }
							set_character_flag = death 
						} 
						1 = { #0.5
							modifier = { factor = 0.5 }
							set_character_flag = maimed 
						}
						3 = { 
							set_character_flag = wounded 
						}
						265 = { #66.25
							modifier = { factor = 0.25 }
							set_character_flag = unhorsed 
						}
						30 = { 
							set_character_flag = survive 
						}
					}
				}	
			}
		}
		FROM = { 		
			FROM = { 
				character_event = { id = tourney.19 days = 2 } #New Round
				character_event = { id = tourney.16 } 
			} 
			character_event = { id = tourney.17 } 			
		}	
	}
	
	option = {
		name = "archer is dead"
		trigger = { 
			OR = {
				FROM = { is_alive = no } 
				FROM = { FROM = { is_alive = no } }
			}	
		}
		if = {
			limit = { FROM = { is_alive = no } }
			FROM = { FROM = { character_event = { id = tourney.18 } } }
		}
		if = {
			limit = { FROM = { FROM = { is_alive = no } } }
			FROM = { character_event = { id = tourney.18 } }
		}
	}	
}
#Inform Round Won
character_event = {
	id = tourney.16
	desc = "EVTDESCtourney.16" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	show_from_from = yes
		
	option = {
		name = "EVTOPTAtourney.16" 	
	}
}
#Inform Round Lost
character_event = {
	id = tourney.17
	desc = "EVTDESCtourney.17" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	show_from_from = yes
		
	option = {
		name = "EVTOPTAtourney.17" 
	}
}
#Inform Opponent Invalid
character_event = {
	id = tourney.18
	desc = "EVTDESCtourney.18" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	show_from_from = yes
		
	option = {
		name = "EVTOPTAtourney.18" 
		clr_character_flag = in_joust
	}
}
#Re-scope for round outcome
character_event = {
	id = tourney.19
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {		
		FROM = {
			FROM = {
				character_event = { id = tourney.200 }			
			}
		}	
	}
	
	option = {
		name = OK	
	}
}	
character_event = {
	id = tourney.200
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = { has_character_flag = lost_round }
			FROM = { set_character_flag = informed_winner_first }
			if = {
				limit = { has_character_flag = survive }
				clr_character_flag = survive
				FROM = { character_event = { id = tourney.21 days = 1 } }
			}	
			if = {
				limit = { has_character_flag = unhorsed }
				clr_character_flag = unhorsed
				FROM = { character_event = { id = tourney.23 days = 1 } }
			}
			if = {
				limit = { has_character_flag = wounded }
				clr_character_flag = wounded
				FROM = { character_event = { id = tourney.25 days = 1 } }
			}
			if = {
				limit = { has_character_flag = maimed }
				FROM = { character_event = { id = tourney.27 days = 1 } }		
			}
			if = {
				limit = { has_character_flag = death }
				FROM = { character_event = { id = tourney.29 days = 1 } }
			}
			if = {
				limit = { has_character_flag = bribed_to_lose }
				FROM = { character_event = { id = tourney.43 days = 1 } }	
			}			
		}	
		FROM = {		
			if = {
				limit = { 
					has_character_flag = lost_round
					NOT = { has_character_flag = informed_winner_first	}				
				}
				if = {
					limit = { has_character_flag = survive }
					clr_character_flag = survive
					character_event = { id = tourney.20 days = 1 } 
				}	
				if = {
					limit = { has_character_flag = unhorsed }
					clr_character_flag = unhorsed
					character_event = { id = tourney.22 days = 1 } 
				}
				if = {
					limit = { has_character_flag = wounded }
					clr_character_flag = wounded
					character_event = { id = tourney.24 days = 1 } 
				}
				if = {
					limit = { has_character_flag = maimed }
					clr_character_flag = maimed
					character_event = { id = tourney.26 days = 1 }				
				}
				if = {
					limit = { has_character_flag = death }
					character_event = { id = tourney.28 days = 1 }
				}
				if = {
					limit = { has_character_flag = bribed_to_lose }
					character_event = { id = tourney.43 days = 1 }
				}
			}				
		}	
	}
	
	option = {
		name = OK	
	}
}	

#SURVIVED
#Inform round loser
character_event = {
	id = tourney.20
	desc = "EVTDESCtourney.20" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		set_character_flag = in_joust
	}
		
	option = {
		name = "EVTOPTAtourney.20" 
		if = {
			limit = { FROM = { NOT = { has_character_flag = informed_winner_first } } }
			FROM = { character_event = { id = tourney.21 tooltip = TOOLTIPtourney.21 } }
		}
		if = {
			limit = { FROM = { has_character_flag = informed_winner_first } }
			custom_tooltip = { text = TOOLTIPtourney.21 }
			hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 2 } } } }
			FROM = { clr_character_flag = informed_winner_first }
		}		
	}
}	
#Inform round winner
character_event = {
	id = tourney.21
	desc = "EVTDESCtourney.21" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		set_character_flag = in_joust
	}
	
	option = {
		name = "EVTOPTAtourney.21" 
		if = {
			limit = { NOT = { has_character_flag = informed_winner_first } }
			custom_tooltip = { text = TOOLTIPtourney.21 }
			hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 2 } } } }
		}
		if = {
			limit = { has_character_flag = informed_winner_first }
			FROM = { character_event = { id = tourney.20 tooltip = TOOLTIPtourney.21 } }
		}					
	}
}
#UNHORSED
#Inform round loser
character_event = {
	id = tourney.22
	desc = "EVTDESCtourney.22" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
	}
		
	option = {
		name = "EVTOPTAtourney.22" 
		if = {
			limit = { FROM = { NOT = { has_character_flag = informed_winner_first } } }
			hidden_tooltip = { FROM = { character_event = { id = tourney.23 } } }
		}
		if = {
			limit = { FROM = { has_character_flag = informed_winner_first } }
			FROM = {
				clr_character_flag = informed_winner_first 
				hidden_tooltip = { character_event = { id = tourney.30 days = 1 } }
			}
		}		
	}
}	
#Inform round winner
character_event = {
	id = tourney.23
	desc = "EVTDESCtourney.23" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		set_character_flag = won_match_up
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
	}
	
	option = {
		name = "EVTOPTAtourney.23" 
		if = {
			limit = { NOT = { has_character_flag = informed_winner_first } }
			hidden_tooltip = { character_event = { id = tourney.30 days = 1 } }
		}	
		if = {
			limit = { has_character_flag = informed_winner_first }
			hidden_tooltip = { FROM = { character_event = { id = tourney.22 } } }
		}				
	}
}
#WOUNDED
#Inform round loser
character_event = {
	id = tourney.24
	desc = "EVTDESCtourney.24" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		set_character_flag = in_joust
	}
		
	option = {
		name = "EVTOPTAtourney.24" 
		if = {
			limit = { NOT = { is_maimed_trigger = yes } }
			add_trait = wounded
		}
		if = {
			limit = { FROM = { NOT = { has_character_flag = informed_winner_first } } }
			FROM = { character_event = { id = tourney.25 tooltip = TOOLTIPtourney.21 } }
		}
		if = {
			limit = { FROM = { has_character_flag = informed_winner_first } }
			custom_tooltip = { text = TOOLTIPtourney.21 }
			hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 2 } } } }
			FROM = { clr_character_flag = informed_winner_first }
		}		
	}
}	
#Inform round winner
character_event = {
	id = tourney.25
	desc = "EVTDESCtourney.25" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		set_character_flag = in_joust
	}
	
	option = {
		name = "EVTOPTAtourney.25" 
		tooltip = {
			FROM = {
				add_trait = wounded
			}
		}
		if = {
			limit = { NOT = { has_character_flag = informed_winner_first } }
			custom_tooltip = { text = TOOLTIPtourney.21 }
			hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 2 } } } }
		}
		if = {
			limit = { has_character_flag = informed_winner_first }
			FROM = { character_event = { id = tourney.24 tooltip = TOOLTIPtourney.21 } }
		}					
	}
}
#MAIMED
#Inform round loser
character_event = {
	id = tourney.26
	desc = "EVTDESCtourney.26" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		hidden_tooltip = { #inform others
			random_opinion_modifier_target = {
				limit = {
					has_character_flag = tourny_in_progress
					reverse_has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
				}
				character_event = { id = 70039 }
				any_opinion_modifier_target = { #Inform rest of tourny
					limit = {
						ai = no
						has_character_flag = attending_tournament
						OR = {
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
						}
						NOT = { character = ROOT }
						NOT = { character = FROM }
						NOT = { character = PREV }
					}	
					character_event = { id = 70090 } 
				}
			}	
		}
	}
		
	option = {
		name = "EVTOPTAtourney.26" 
		hidden_tooltip = { remove_trait = wounded }
		add_maimed_trait_effect = yes
		if = {
			limit = { FROM = { NOT = { has_character_flag = informed_winner_first } } }
			hidden_tooltip = { FROM = { character_event = { id = tourney.27 } } }
		}
		if = {
			limit = { FROM = { has_character_flag = informed_winner_first } }
			FROM = {
				clr_character_flag = informed_winner_first 
				hidden_tooltip = { character_event = { id = tourney.30 days = 1 } }
			}
		}		
	}
}	
#Inform round winner
character_event = {
	id = tourney.27
	desc = "EVTDESCtourney.27" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		set_character_flag = won_match_up
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
	}
	
	option = {
		name = "EVTOPTAtourney.27"
		tooltip = {
			FROM = {
				add_maimed_trait_effect = yes
			}
		}	
		if = {
			limit = { NOT = { has_character_flag = informed_winner_first } }
			hidden_tooltip = { character_event = { id = tourney.30 days = 1 } }
		}
		if = {
			limit = { has_character_flag = informed_winner_first }
			hidden_tooltip = { FROM = { character_event = { id = tourney.26 } } }
		}				
	}
}
#DEATH
#Inform round loser
character_event = {
	id = tourney.28
	desc = "EVTDESCtourney.28" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		hidden_tooltip = { #inform others
			random_opinion_modifier_target = {
				limit = {
					has_character_flag = tourny_in_progress
					reverse_has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
				}
				character_event = { id = 70038 }
				any_opinion_modifier_target = { #Inform rest of tourny
					limit = {
						ai = no
						has_character_flag = attending_tournament
						OR = {
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
						}
						NOT = { character = ROOT }
						NOT = { character = FROM }
						NOT = { character = PREV }
					}	
					character_event = { id = 70089 } 
				}
			}
		}
	}
		
	option = {
		name = "EVTOPTAtourney.28" 
		if = {
			limit = { FROM = { NOT = { has_character_flag = informed_winner_first } } }
			hidden_tooltip = { FROM = { character_event = { id = tourney.29 } } }
		}
		if = {
			limit = { FROM = { has_character_flag = informed_winner_first } }
			FROM = {
				clr_character_flag = informed_winner_first 
				hidden_tooltip = { character_event = { id = tourney.30 } }
			}
		}
		tooltip = { death = yes }
	}
}	
#Inform round winner
character_event = {
	id = tourney.29
	desc = "EVTDESCtourney.29" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		set_character_flag = won_match_up
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
	}
	
	option = {
		name = "EVTOPTAtourney.29" 
		FROM = {
			tooltip = { death = yes }
		}
		if = {
			limit = { NOT = { has_character_flag = informed_winner_first } }
			hidden_tooltip = { character_event = { id = tourney.30 days = 1 } }
		}
		if = {
			limit = { has_character_flag = informed_winner_first }
			hidden_tooltip = { FROM = { character_event = { id = tourney.28 } } }
		}				
	}
}
#Match Up finished, set scopes
character_event = {
	id = tourney.30

	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		random_opinion_modifier_target = {
			limit = {
				has_character_flag = tourney_final_round
				reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			change_variable = { which = "tourney_competitors" value = -1 }
		}
		FROM = {
			if = {
				limit = { 
					NOT = { has_character_flag = won_match_up } 
					NOT = { character = ROOT }
				}
				set_character_flag = lost_tournament 
				character_event = { id = tourney.32 days = 1 }
				break = yes				
			}	
		}
		FROMFROM = {
			if = {
				limit = { 
					NOT = { has_character_flag = won_match_up } 
					NOT = { character = ROOT }
				}
				set_character_flag = lost_tournament 
				character_event = { id = tourney.32 days = 1 }		
			}	
		}	
	}
	
	option = {
		name = OK
	}
}
#Inform Won Matchup
character_event = {
	id = tourney.31
	desc = "EVTDESCtourney.31" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {	
		clr_character_flag = in_joust
		clr_character_flag = bribed_to_lose
		clr_character_flag = squire_bribed
		random_opinion_modifier_target = {
			limit = {
				has_character_flag = tourney_final_round
				reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			#If last competitor inform host of end of tourney
			if = {
				limit = { 
					NOT = {
						any_opinion_modifier_target = {
							has_character_flag = attending_tournament
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							NOT = { has_character_flag = lost_tournament }
							NOT = { character = ROOT }
						}
					}	
				}
				set_character_flag = tournament_winner_found		
				character_event = { id = tourney.34 tooltip = TOOLTIPtourney.34 days = 1 }
				hidden_tooltip = { 
					ROOT = { character_event = { id = 70020 days = 1 } }
					FROM = { 
						character_event = { id = 70021 days = 1 } 
						if = { #won bet?
							limit = {
								ai = no
								has_character_flag = placed_tourney_bet
								has_opinion_modifier = { who = ROOT modifier = opinion_tourney_bet_target } 
							}
							character_event = { id = tourney.56 days = 2 }
						}
					}
					any_opinion_modifier_target = { #Inform rest of tourny
						limit = {
							has_character_flag = attending_tournament
							OR = {
								has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
								has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
							}
							NOT = { character = ROOT }
							NOT = { character = FROM }
							NOT = { character = PREV }
							OR = {
								ai = no
								dynasty = ROOT
								dynasty = FROM
							}
						}	
						character_event = { id = tourney.36 days = 1 } 
						if = { #won bet?
							limit = {
								ai = no
								has_character_flag = placed_tourney_bet
								has_opinion_modifier = { who = ROOT modifier = opinion_tourney_bet_target } 
							}
							character_event = { id = tourney.56 days = 2 }
						}
					}
					if = { #won bet?
						limit = {
							ai = no
							has_character_flag = placed_tourney_bet
							has_opinion_modifier = { who = ROOT modifier = opinion_tourney_bet_target } 
						}
						character_event = { id = tourney.56 days = 2 }
					}
				}
			}
			#If semi-finalist inform host
			if = {
				limit = { 
					NOT = { has_character_flag = tournament_winner_found }
					NOT = {
						any_opinion_modifier_target = {
							has_character_flag = attending_tournament
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							NOT = { has_character_flag = lost_tournament }
							count = 3
						}
					}
				}
				hidden_tooltip = { 
					set_character_flag = tournament_winner_found
					character_event = { id = tourney.33 days = 1 } 
					FROM = { character_event = { id = 70022 days = 1 } }
					any_opinion_modifier_target = { #Inform rest of tourny
						limit = {
							has_character_flag = attending_tournament
							OR = {
								has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
								has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
							}	
							NOT = { character = ROOT }
							NOT = { character = FROM }
							NOT = { character = PREV }
							OR = {
								ai = no
								dynasty = ROOT
								dynasty = FROM
							}
						}	
						character_event = { id = tourney.35 days = 1 } 
					}
				}
			}
			
			#Inform player who placed bet on one of the jousters
			if = {
				limit = { 
					NOT = { has_character_flag = tournament_winner_found }	
				}
				any_opinion_modifier_target = {
					limit = {
						ai = no
						has_character_flag = attending_tournament
						has_character_flag = placed_tourney_bet
						OR = {
							has_opinion_modifier = { who = FROM modifier = opinion_tourney_bet_target }
							has_opinion_modifier = { who = ROOT modifier = opinion_tourney_bet_target }
						}	
						OR = {
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
						}	
						NOT = { character = FROM }
						NOT = { character = ROOT }
						NOT = { character = PREV }
					}	
					set_character_flag = NOT_third
					character_event = { id = tourney.35 days = 1 } 
				}
			}
			if = {
				limit = { 
					NOT = { has_character_flag = tournament_winner_found }
					ai = no
					has_character_flag = placed_tourney_bet
					has_opinion_modifier = { who = FROM modifier = opinion_tourney_bet_target }
				}
				set_character_flag = tournament_winner_found
				hidden_tooltip = { character_event = { id = tourney.33 days = 1 } }
			}
			#Inform player squire
			if = {
				limit = { 
					NOT = { has_character_flag = tournament_winner_found }	
				}
				any_opinion_modifier_target = {
					limit = {
						ai = no
						trait = squire
						educator = {
							OR = {
								character = ROOT
								character = ROOT_FROM
							}
						}	
						has_character_flag = attending_tournament
						OR = {
							has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
							has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
						}	
					}	
					set_character_flag = NOT_third
					character_event = { id = tourney.35 days = 1 } 
				}
			}
			#If human requests all results inform
			if = {
				limit = { 
					NOT = { has_character_flag = tournament_winner_found }
					has_character_flag = inform_of_all_tourney_results		
				}
				hidden_tooltip = { character_event = { id = tourney.33 days = 1 } }
			}
		}
		hidden_tooltip = { 
			character_event = { id = tourney.12 days = 2 random = 1 } #Find New Matchup
			hidden_tooltip = { #inform spectator relative
				any_dynasty_member = {
					limit = {
						ai = no
						is_close_relative = PREV
						has_character_flag = tournament_spectator
						has_character_flag = attending_tournament
					}
					character_event = { id = 70096 }
				}
				FROM = {
					any_dynasty_member = {
						limit = {
							ai = no
							is_close_relative = PREV
							has_character_flag = tournament_spectator
							has_character_flag = attending_tournament
						}
						character_event = { id = 70098 }
					}
				}	
			}
		}  
	}
	
	option = {
		name = "EVTOPTAtourney.31" 
		ai_chance = {
			factor = 1
		}		
	}	
	option = {
		name = "EVTOPTDtourney.35" #Lost bet!
		trigger = { 
			ai = no
			has_character_flag = placed_tourney_bet
			has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
		}
		tooltip_info = yes
	}
	option = {
		name = "EVTOPTBtourney.31" 	#offer a drink?
		trigger = {
			trait = gregarious
			age = 18
			FROM = { age = 18 }
			NOT = { is_friend = FROM }
			NOT = { is_rival = FROM }
			opinion = { who = FROM value = 10 }
			reverse_opinion = { who = FROM value = 10 }
			random = 10
		}
		ai_chance = {
			factor = 0.33
			modifier = {
				factor = 0
				trait = proud
				NOT = { dynasty = 0 }
				FROM = { dynasty = 0 }
			}
			modifier = {
				factor = 0
				trait = proud
				OR = {
					higher_tier_than = BARON
					father_even_if_dead = { higher_tier_than = BARON }
				}
				FROM = {
					NOR = {
						higher_tier_than = BARON
						father_even_if_dead = { higher_tier_than = BARON }
						prestige = 500
					}
				}			
			}
			modifier = {
				factor = 0.25
				num_of_friends = 5
			}
			modifier = {
				factor = 2
				opinion = { who = FROM value = 30 }
			}
			modifier = {
				factor = 3
				trait = drunkard
			}
			modifier = {
				factor = 0.33
				trait = temperate
			}
			
			modifier = {
				factor = 2
				trait = kind
			}
			modifier = {
				factor = 2
				trait = honorable
			}
			modifier = {
				factor = 2
				trait = humble
			}
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 0.5
				trait = proud
			}
			modifier = {
				factor = 0.5
				trait = ruthless
			}
		}
		tooltip_info = gregarious
		FROM = { character_event = { id = tourney.60 days = 1 tooltip = TOOLTIPtourney.60 } }
	}	
	after = {
		if = {
			limit = {
				FROM = { 
					OR = {
						trait = master_warrior
						higher_tier_than = DUKE
					}
				}
			}
			prestige = 20
		}
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { higher_tier_than = DUKE }
					OR = {
						trait = skilled_warrior
						tier = DUKE
					}
				}
			}
			prestige = 10
		}	
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { trait = skilled_warrior }
					NOT = { higher_tier_than = COUNT }
					OR = {
						trait = trained_warrior
						tier = COUNT
					}
				}
			}
			prestige = 5
		}	
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { trait = skilled_warrior }
					NOT = { trait = trained_warrior }
					NOT = { higher_tier_than = BARON }
				}
			}
			prestige = 2
		}
		hidden_tooltip = {
			if = {
				limit = {
					ai = no
					has_character_flag = placed_tourney_bet
					has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
				}
				clr_character_flag = placed_tourney_bet
				clr_character_flag = placed_tourney_bet_self
				clr_character_flag = placed_tourney_bet_5
				clr_character_flag = placed_tourney_bet_20
				clr_character_flag = placed_tourney_bet_40
				set_variable = { which = tourney_bet_odds value = 0 }
				remove_opinion = { who = FROMFROM modifier = opinion_tourney_bet_target }
			}
		}	
	}
}
#Inform Lost Matchup
character_event = {
	id = tourney.32
	desc = "EVTDESCtourney.32" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {	
		clr_character_flag = bribed_to_lose
		if = {
			limit = { FROM = { has_character_flag = won_match_up } }
			FROM = { 
				clr_character_flag = won_match_up 
				character_event = { id = tourney.31 days = 1 } 
			}
		}	
		clr_character_flag = in_joust
		if = {
			limit = { has_character_flag = death }
			death = {
				death_reason = death_tourney_joust
				killer = FROM
			}
			break = yes
		}
		if = { #chance of discovering squire bribery
			limit = { has_character_flag = squire_bribed }
			random = {
				chance = 5
				modifier = {
					factor = 0.5
					NOT = { intrigue = 5 }
				}
				modifier = {
					factor = 2
					intrigue = 10
				}
				modifier = {
					factor = 2
					intrigue = 14
				}
				character_event = { id = tourney.78 days = 1 }
			}
			clr_character_flag = squire_bribed
		}
	}
	
	option = {
		name = {
			text = "EVTOPTAtourney.32" 
			trigger = { 
				NAND = {
					ai = no
					has_character_flag = placed_tourney_bet
					has_character_flag = placed_tourney_bet_self
				}
			}
		}	
		name = {
			text = "EVTOPTDtourney.35" #lost bet!
			trigger = { 
				ai = no
				has_character_flag = placed_tourney_bet
				has_character_flag = placed_tourney_bet_self
			}
		}	
		if = {
			limit = {
				FROM = { 
					OR = {
						trait = master_warrior
						higher_tier_than = DUKE
					}
				}
			}		
			prestige = -2
		}
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { higher_tier_than = DUKE }
					OR = {
						trait = skilled_warrior
						tier = DUKE
					}
				}
			}
			prestige = -5
		}	
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { trait = skilled_warrior }
					NOT = { higher_tier_than = COUNT }
					OR = {
						trait = trained_warrior
						tier = COUNT
					}
				}
			}
			prestige = -10
		}	
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { trait = skilled_warrior }
					NOT = { trait = trained_warrior }
					NOT = { higher_tier_than = BARON }
				}
			}
			prestige = -20
		}	
	}
	
	option = {
		name = "EVTOPTB70005" #blame squire
		trigger = {
			any_ward = { trait = squire }
		}
		if = {
			limit = {
				FROM = { 
					OR = {
						trait = master_warrior
						higher_tier_than = DUKE
					}
				}
			}		
			prestige = -1
			random_ward = {
				limit = { trait = squire }
				opinion = {
					modifier = opinion_squire_humiliated
					who = ROOT
					years = 2
				}	
				prestige = -1
			}
		}
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { higher_tier_than = DUKE }
					OR = {
						trait = skilled_warrior
						tier = DUKE
					}
				}
			}
			prestige = -3
			random_ward = {
				limit = { trait = squire }
				opinion = {
					modifier = opinion_squire_humiliated
					who = ROOT
					years = 2
				}	
				prestige = -2
			}
		}	
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { trait = skilled_warrior }
					NOT = { higher_tier_than = COUNT }
					OR = {
						trait = trained_warrior
						tier = COUNT
					}
				}
			}
			prestige = -5
			random_ward = {
				limit = { trait = squire }
				opinion = {
					modifier = opinion_squire_humiliated
					who = ROOT
					years = 2
				}	
				prestige = -5
			}
		}	
		if = {
			limit = {
				FROM = { 
					NOT = { trait = master_warrior }
					NOT = { trait = skilled_warrior }
					NOT = { trait = trained_warrior }
					NOT = { higher_tier_than = BARON }
				}
			}
			prestige = -10
			random_ward = {
				limit = { trait = squire }
				opinion = {
					modifier = opinion_squire_humiliated
					who = ROOT
					years = 2
				}	
				prestige = -10	
			}
		}		
	}
	after = {
		hidden_tooltip = {
			if = {
				limit = {
					ai = no
					has_character_flag = placed_tourney_bet
					has_character_flag = placed_tourney_bet_self
				}
				clr_character_flag = placed_tourney_bet
				clr_character_flag = placed_tourney_bet_self
				clr_character_flag = placed_tourney_bet_5
				clr_character_flag = placed_tourney_bet_20
				clr_character_flag = placed_tourney_bet_40
				set_variable = { which = tourney_bet_odds value = 0 }
			}
		}	
	}
}
#Inform Host of Semi_final
character_event = {
	id = tourney.33
	desc = "EVTDESCtourney.33" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = tournament_winner_found
	}
	
	option = {
		name = "EVTOPTAtourney.33" 
		FROM = { FROM = { tooltip = { show_portrait = yes } } }
	}
	option = {
		name = "EVTOPTDtourney.35" #Lost bet!
		trigger = { 
			ai = no
			has_character_flag = placed_tourney_bet
			has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
		}
		tooltip_info = yes
	}
	after = {
		hidden_tooltip = {
			if = {
				limit = {
					ai = no
					has_character_flag = placed_tourney_bet
					has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
				}
				clr_character_flag = placed_tourney_bet
				clr_character_flag = placed_tourney_bet_self
				clr_character_flag = placed_tourney_bet_5
				clr_character_flag = placed_tourney_bet_20
				clr_character_flag = placed_tourney_bet_40
				set_variable = { which = tourney_bet_odds value = 0 }
				remove_opinion = { who = FROMFROM modifier = opinion_tourney_bet_target }
			}
		}	
	}
}
#Inform Host of Winner
character_event = {
	id = tourney.34
	desc = "EVTDESCtourney.34" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = tournament_winner_found
		clr_character_flag = tourney_final_round
		hidden_tooltip = {
			##knight of the greenhand?
			if = {
				limit = {
					tier = EMPEROR
					OR = {
						AND = {
							capital_scope = { region = world_reach }
							culture_group = andal
						}
						dynasty = 1254 #Gardener
						has_landed_title = e_reach
					}						
				}
				character_event = { id = knight.32 days = 2 }
			}
			if = {
				limit = {
					NOT = { tier = EMPEROR }
					OR = {
						culture = reachman
						dynasty = 1254 #Gardener
						capital_scope = { region = world_reach }
					}
					OR = {
						has_character_flag = grand_tourny
						has_character_flag = king_tourny
					}	
				}
				any_liege = {
					limit = {
						tier = EMPEROR
						OR = {
							AND = {
								capital_scope = { region = world_reach }
								culture_group = andal
							}
							dynasty = 1254 #Gardener
							has_landed_title = e_reach
						}
					}
					character_event = { id = knight.32 days = 2 }
				}							
			}
			##Queen of Love and Beauty
			if = {
				limit = {
					OR = {
						has_character_flag = grand_tourny
						has_character_flag = king_tourny
					}
				}				
				FROM = {
					character_event = { id = 70053 days = 1 }
				}	
			}	
		}	
	}
	
	option = {
		name = "EVTOPTAtourney.34" 
		FROM = {
			opinion = {
				modifier = opinion_tournament_winner
				who = ROOT
				years = 20
			}
			
		}
		FROM = { FROM = { tooltip = { show_portrait = yes } } }
		character_event = { id = 70002 days = 20 tooltip = TOOLTIPtourney.29 }
	}
	option = {
		name = "EVTOPTDtourney.35" #Lost bet!
		trigger = { 
			ai = no
			has_character_flag = placed_tourney_bet
			has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
		}
		tooltip_info = yes
		FROM = {
			opinion = {
				modifier = opinion_tournament_winner
				who = ROOT
				years = 20
			}
			
		}
		FROM = { FROM = { tooltip = { show_portrait = yes } } }
		character_event = { id = 70002 days = 20 tooltip = TOOLTIPtourney.29 }
	}
	after = {
		hidden_tooltip = {
			if = {
				limit = {
					ai = no
					has_character_flag = placed_tourney_bet
					has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
				}
				clr_character_flag = placed_tourney_bet
				clr_character_flag = placed_tourney_bet_self
				clr_character_flag = placed_tourney_bet_5
				clr_character_flag = placed_tourney_bet_20
				clr_character_flag = placed_tourney_bet_40
				set_variable = { which = tourney_bet_odds value = 0 }
				remove_opinion = { who = FROMFROM modifier = opinion_tourney_bet_target }
			}
		}	
	}
}
#Inform spectator of Semi_final
character_event = {
	id = tourney.35
	desc = "EVTDESCtourney.33" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70088"
		trigger = { 
			OR = {
				NOT = { has_character_flag = tournament_spectator }
				NOT = { dynasty = FROMFROM }
			}
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
	}
	option = {
		name = "EVTOPTBtourney.35"
		trigger = { 
			has_character_flag = tournament_spectator 
			dynasty = FROMFROM
			NOT = { is_close_relative = FROMFROM }
			NOT = { has_character_flag = NOT_third }
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
	}
	option = {
		name = "EVTOPTBtourney.35"
		trigger = { 
			has_character_flag = tournament_spectator 
			dynasty = FROMFROM
			is_close_relative = FROMFROM
			NOT = { has_character_flag = NOT_third }
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			prestige = 15
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			prestige = 10
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			prestige = 3
		}	
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			prestige = 1
		}
	}
	option = {
		name = "EVTOPTDtourney.35" #Lost bet!
		trigger = { 
			ai = no
			has_character_flag = placed_tourney_bet
			has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
		}
		tooltip_info = yes
	}
	after = {
		hidden_tooltip = {
			if = {
				limit = {
					ai = no
					has_character_flag = placed_tourney_bet
					has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
				}
				clr_character_flag = placed_tourney_bet
				clr_character_flag = placed_tourney_bet_self
				clr_character_flag = placed_tourney_bet_5
				clr_character_flag = placed_tourney_bet_20
				clr_character_flag = placed_tourney_bet_40
				set_variable = { which = tourney_bet_odds value = 0 }
				remove_opinion = { who = FROMFROM modifier = opinion_tourney_bet_target }
			}
			clr_character_flag = NOT_third
		}	
	}
}
#Inform spectator of winner
character_event = {
	id = tourney.36
	desc = "EVTDESCtourney.34" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70052"
		trigger = { 
			OR = {
				NOT = { has_character_flag = tournament_spectator }
				AND = {
					NOT = { dynasty = FROM }
					NOT = { dynasty = FROMFROM }
				}	
			}
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
	}
	
	#Relative is winner
	option = {
		name = "EVTOPTC70087"
		trigger = { 
			has_character_flag = tournament_spectator 
			dynasty = FROM
			NOT = { is_close_relative = FROM }
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
	}
	option = {
		name = "EVTOPTC70087"
		trigger = { 
			has_character_flag = tournament_spectator 
			dynasty = FROM
			is_close_relative = FROM
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			prestige = 35
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			prestige = 25
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			prestige = 10
		}	
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			prestige = 5
		}
	}
	
	#Relative is runner up
	option = {
		name = "EVTOPTB70087"
		trigger = { 
			has_character_flag = tournament_spectator 
			dynasty = FROMFROM
			NOT = { is_close_relative = FROMFROM }
			NOT = { dynasty = FROM }		
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
	}
	option = {
		name = "EVTOPTB70087"
		trigger = { 
			has_character_flag = tournament_spectator 
			dynasty = FROMFROM
			is_close_relative = FROMFROM
			OR = {
				NOT = { dynasty = FROM }
				NOT = { is_close_relative = FROM }
			}	
		}
		FROM = {
			tooltip = { show_portrait = yes }
		}
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			prestige = 25
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			prestige = 15
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			prestige = 5
		}	
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			prestige = 2
		}
	}
	option = {
		name = "EVTOPTDtourney.35" #Lost bet!
		trigger = { 
			ai = no
			has_character_flag = placed_tourney_bet
			has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
		}
		tooltip_info = yes
	}
	after = {
		hidden_tooltip = {
			if = {
				limit = {
					ai = no
					has_character_flag = placed_tourney_bet
					has_opinion_modifier = { who = FROMFROM modifier = opinion_tourney_bet_target }
				}
				clr_character_flag = placed_tourney_bet
				clr_character_flag = placed_tourney_bet_self
				clr_character_flag = placed_tourney_bet_5
				clr_character_flag = placed_tourney_bet_20
				clr_character_flag = placed_tourney_bet_40
				set_variable = { which = tourney_bet_odds value = 0 }
				remove_opinion = { who = FROMFROM modifier = opinion_tourney_bet_target }
			}
		}	
	}
}

# Character wins the tournament
character_event = {
	id = 70020
	title = "TOURNAMENTTITLE"
	desc = "EVTDESC70020"
	picture = "GFX_evt_joust"

	is_triggered_only = yes

	immediate = {
		if = { #won bet?
			limit = {
				ai = no
				has_character_flag = placed_tourney_bet
				has_character_flag = placed_tourney_bet_self
			}
			character_event = { id = tourney.56 days = 1 }
		}
		set_character_flag = attending_tournament_event
		set_character_flag = tourney_medalist
		if = {
			limit = {
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = grand_tourny_1st_1 } 
					NOT = { has_character_flag = grand_tourny_1st } 
				}
				add_character_modifier = { 
					name = grand_tourny_1st_1
					duration = -1
				}
				set_character_flag = grand_tourny_1st
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_1st_1
					
				}
				add_character_modifier = { 
					name = grand_tourny_1st_2
					duration = -1
				}
				remove_character_modifier = grand_tourny_1st_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_1st_2
					
				}
				add_character_modifier = { 
					name = grand_tourny_1st_3
					duration = -1
				}
				remove_character_modifier = grand_tourny_1st_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_1st_3
					
				}
				add_character_modifier = { 
					name = grand_tourny_1st_4
					duration = -1
				}
				remove_character_modifier = grand_tourny_1st_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_1st_4
					
				}
				add_character_modifier = { 
					name = grand_tourny_1st_5
					duration = -1
				}
				remove_character_modifier = grand_tourny_1st_4
				break = yes
			}
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = normal_tourny_1st_1 } 
					NOT = { has_character_flag = normal_tourny_1st } 
				}
				add_character_modifier = { 
					name = normal_tourny_1st_1
					duration = -1
				}
				set_character_flag = normal_tourny_1st
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_1st_1
					
				}
				add_character_modifier = { 
					name = normal_tourny_1st_2
					duration = -1
				}
				remove_character_modifier = normal_tourny_1st_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_1st_2
					
				}
				add_character_modifier = { 
					name = normal_tourny_1st_3
					duration = -1
				}
				remove_character_modifier = normal_tourny_1st_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_1st_3
					
				}
				add_character_modifier = { 
					name = normal_tourny_1st_4
					duration = -1
				}
				remove_character_modifier = normal_tourny_1st_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_1st_4
					
				}
				add_character_modifier = { 
					name = normal_tourny_1st_5
					duration = -1
				}
				remove_character_modifier = normal_tourny_1st_4
				break = yes
			}
		}	
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = small_tourny_1st_1 } 
					NOT = { has_character_flag = small_tourny_1st } 
				}
				add_character_modifier = { 
					name = small_tourny_1st_1
					duration = -1
				}
				set_character_flag = small_tourny_1st
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_1st_1
					
				}
				add_character_modifier = { 
					name = small_tourny_1st_2
					duration = -1
				}
				remove_character_modifier = small_tourny_1st_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_1st_2
					
				}
				add_character_modifier = { 
					name = small_tourny_1st_3
					duration = -1
				}
				remove_character_modifier = small_tourny_1st_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_1st_3
					
				}
				add_character_modifier = { 
					name = small_tourny_1st_4
					duration = -1
				}
				remove_character_modifier = small_tourny_1st_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_1st_4
					
				}
				add_character_modifier = { 
					name = small_tourny_1st_5
					duration = -1
				}
				remove_character_modifier = small_tourny_1st_4
				break = yes
			}
		}
				
	}
	
	option = {
		name = "EVTOPTA70020"
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			wealth = 125
			prestige = 300
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			wealth = 75
			prestige = 200
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			wealth = 50
			prestige = 100	
		}
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			wealth = 25
			prestige = 50
		}
		if = { 
			limit = { 
				NOT = { trait = knight }
				religion = the_seven
				NOT = { trait = maester }
				NOT = { trait = archmaester }
				NOT = { has_priest_trait_trigger = yes }
			}
			knight_character_effect = yes
		}
	}
	option = {
		name = "EVTOPTB70003" #squire deserves credit
		trigger = {
			any_ward = { trait = squire }
		}
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			wealth = 90
			prestige = 225
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			wealth = 55
			prestige = 150
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			wealth = 35
			prestige = 75	
		}
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			wealth = 15
			prestige = 35
		}
		if = { 
			limit = { 
				NOT = { trait = knight }
				religion = the_seven
				NOT = { trait = maester }
				NOT = { trait = archmaester }
				NOT = { has_priest_trait_trigger = yes }
			}
			knight_character_effect = yes
		}
		random_ward = {
			limit = { trait = squire }
			opinion = {
				modifier = opinion_squire_honoured
				who = ROOT
				years = 4
			}	
			if = { 
				limit = { ROOT = { has_character_flag = king_tourny } }
				wealth = 35
				prestige = 75			
			}	
			if = { 
				limit = { ROOT = { has_character_flag = grand_tourny } }
				wealth = 20
				prestige = 50			
			}
			if = { 
				limit = { ROOT = { has_character_flag = normal_tourny } }
				wealth = 15
				prestige = 25			
			}
			if = { 
				limit = { ROOT = { has_character_flag = small_tourny } }
				wealth = 10
				prestige = 15			
			}			
		}
	}	
}

# Character wins second place in the tournament
character_event = {
	id = 70021
	title = "TOURNAMENTTITLE"
	desc = "EVTDESC70021"
	picture = "GFX_evt_joust"

	is_triggered_only = yes

	immediate = {
		set_character_flag = attending_tournament_event
		set_character_flag = tourney_medalist
		if = {
			limit = {
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = grand_tourny_2nd_1 } 
					NOT = { has_character_flag = grand_tourny_2nd } 
				}
				add_character_modifier = { 
					name = grand_tourny_2nd_1
					duration = -1
				}
				set_character_flag = grand_tourny_2nd
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_2nd_1
					
				}
				add_character_modifier = { 
					name = grand_tourny_2nd_2
					duration = -1
				}
				remove_character_modifier = grand_tourny_2nd_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_2nd_2
					
				}
				add_character_modifier = { 
					name = grand_tourny_2nd_3
					duration = -1
				}
				remove_character_modifier = grand_tourny_2nd_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_2nd_3
					
				}
				add_character_modifier = { 
					name = grand_tourny_2nd_4
					duration = -1
				}
				remove_character_modifier = grand_tourny_2nd_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_2nd_4
					
				}
				add_character_modifier = { 
					name = grand_tourny_2nd_5
					duration = -1
				}
				remove_character_modifier = grand_tourny_2nd_4
				break = yes
			}
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = normal_tourny_2nd_1 } 
					NOT = { has_character_flag = normal_tourny_2nd } 
				}
				add_character_modifier = { 
					name = normal_tourny_2nd_1
					duration = -1
				}
				set_character_flag = normal_tourny_2nd
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_2nd_1
					
				}
				add_character_modifier = { 
					name = normal_tourny_2nd_2
					duration = -1
				}
				remove_character_modifier = normal_tourny_2nd_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_2nd_2
					
				}
				add_character_modifier = { 
					name = normal_tourny_2nd_3
					duration = -1
				}
				remove_character_modifier = normal_tourny_2nd_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_2nd_3
					
				}
				add_character_modifier = { 
					name = normal_tourny_2nd_4
					duration = -1
				}
				remove_character_modifier = normal_tourny_2nd_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_2nd_4
					
				}
				add_character_modifier = { 
					name = normal_tourny_2nd_5
					duration = -1
				}
				remove_character_modifier = normal_tourny_2nd_4
				break = yes
			}
		}	
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = small_tourny_2nd_1 } 
					NOT = { has_character_flag = small_tourny_2nd } 
				}
				add_character_modifier = { 
					name = small_tourny_2nd_1
					duration = -1
				}
				set_character_flag = small_tourny_2nd
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_2nd_1
					
				}
				add_character_modifier = { 
					name = small_tourny_2nd_2
					duration = -1
				}
				remove_character_modifier = small_tourny_2nd_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_2nd_2
					
				}
				add_character_modifier = { 
					name = small_tourny_2nd_3
					duration = -1
				}
				remove_character_modifier = small_tourny_2nd_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_2nd_3
					
				}
				add_character_modifier = { 
					name = small_tourny_2nd_4
					duration = -1
				}
				remove_character_modifier = small_tourny_2nd_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_2nd_4
					
				}
				add_character_modifier = { 
					name = small_tourny_2nd_5
					duration = -1
				}
				remove_character_modifier = small_tourny_2nd_4
				break = yes
			}
		}	
				
	}
	
	option = {
		name = "EVTOPTA70021"
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			wealth = 75
			prestige = 200
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			wealth = 50
			prestige = 100
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			wealth = 25
			prestige = 50
		}
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			wealth = 15
			prestige = 25
		}		
		if = { 
			limit = { 
				NOT = { trait = knight }
				religion = the_seven
				NOT = { trait = maester }
				NOT = { trait = archmaester }
				NOT = { has_priest_trait_trigger = yes }
			}
			knight_character_effect = yes
		}
	}
	option = {
		name = "EVTOPTB70003" #squire deserves credit
		trigger = {
			any_ward = { trait = squire }
		}
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			wealth = 55
			prestige = 150
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			wealth = 35
			prestige = 75
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			wealth = 15
			prestige = 35
		}
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			wealth = 10
			prestige = 15
		}	
		if = { 
			limit = { 
				NOT = { trait = knight }
				religion = the_seven
				NOT = { trait = maester }
				NOT = { trait = archmaester }
				NOT = { has_priest_trait_trigger = yes }
			}
			knight_character_effect = yes
		}
		random_ward = {
			limit = { trait = squire }
			opinion = {
				modifier = opinion_squire_honoured
				who = ROOT
				years = 4
			}
			if = { 
				limit = { ROOT = { has_character_flag = king_tourny } }
				wealth = 20
				prestige = 50		
			}	
			if = { 
				limit = { ROOT = { has_character_flag = grand_tourny } }
				wealth = 15
				prestige = 25			
			}
			if = { 
				limit = { ROOT = { has_character_flag = normal_tourny } }
				wealth = 10
				prestige = 15		
			}
			if = { 
				limit = { ROOT = { has_character_flag = small_tourny } }
				wealth = 5
				prestige = 10		
			}			
		}
	}	
}

# Character gets to semi finals in the tournament
character_event = {
	id = 70022
	title = "TOURNAMENTTITLE"
	desc = "EVTDESC70022"
	picture = "GFX_evt_joust"

	is_triggered_only = yes	

	immediate = {
		set_character_flag = attending_tournament_event
		set_character_flag = tourney_medalist
		if = {
			limit = {
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = grand_tourny_3rd_1 } 
					NOT = { has_character_flag = grand_tourny_3rd } 
				}
				add_character_modifier = { 
					name = grand_tourny_3rd_1
					duration = -1
				}
				set_character_flag = grand_tourny_3rd
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_3rd_1
					
				}
				add_character_modifier = { 
					name = grand_tourny_3rd_2
					duration = -1
				}
				remove_character_modifier = grand_tourny_3rd_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_3rd_2
					
				}
				add_character_modifier = { 
					name = grand_tourny_3rd_3
					duration = -1
				}
				remove_character_modifier = grand_tourny_3rd_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_3rd_3
					
				}
				add_character_modifier = { 
					name = grand_tourny_3rd_4
					duration = -1
				}
				remove_character_modifier = grand_tourny_3rd_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = grand_tourny_3rd_4
					
				}
				add_character_modifier = { 
					name = grand_tourny_3rd_5
					duration = -1
				}
				remove_character_modifier = grand_tourny_3rd_4
				break = yes
			}
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = normal_tourny_3rd_1 } 
					NOT = { has_character_flag = normal_tourny_3rd } 
				}
				add_character_modifier = { 
					name = normal_tourny_3rd_1
					duration = -1
				}
				set_character_flag = normal_tourny_3rd
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_3rd_1
					
				}
				add_character_modifier = { 
					name = normal_tourny_3rd_2
					duration = -1
				}
				remove_character_modifier = normal_tourny_3rd_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_3rd_2
					
				}
				add_character_modifier = { 
					name = normal_tourny_3rd_3
					duration = -1
				}
				remove_character_modifier = normal_tourny_3rd_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_3rd_3
					
				}
				add_character_modifier = { 
					name = normal_tourny_3rd_4
					duration = -1
				}
				remove_character_modifier = normal_tourny_3rd_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = normal_tourny_3rd_4
					
				}
				add_character_modifier = { 
					name = normal_tourny_3rd_5
					duration = -1
				}
				remove_character_modifier = normal_tourny_3rd_4
				break = yes
			}
		}
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			if = {
				limit = { 
					NOT = { has_character_modifier = small_tourny_3rd_1 } 
					NOT = { has_character_flag = small_tourny_3rd } 
				}
				add_character_modifier = { 
					name = small_tourny_3rd_1
					duration = -1
				}
				set_character_flag = small_tourny_3rd
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_3rd_1
					
				}
				add_character_modifier = { 
					name = small_tourny_3rd_2
					duration = -1
				}
				remove_character_modifier = small_tourny_3rd_1
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_3rd_2
					
				}
				add_character_modifier = { 
					name = small_tourny_3rd_3
					duration = -1
				}
				remove_character_modifier = small_tourny_3rd_2
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_3rd_3
					
				}
				add_character_modifier = { 
					name = small_tourny_3rd_4
					duration = -1
				}
				remove_character_modifier = small_tourny_3rd_3
				break = yes
			}
			if = {
				limit = { 
					has_character_modifier = small_tourny_3rd_4
					
				}
				add_character_modifier = { 
					name = small_tourny_3rd_5
					duration = -1
				}
				remove_character_modifier = small_tourny_3rd_4
				break = yes
			}
		}	
				
	}
	
	option = {
		name = "EVTOPTA70022"
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			wealth = 50
			prestige = 100
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			wealth = 25
			prestige = 50
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			wealth = 15
			prestige = 25
		}
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			wealth = 10
			prestige = 10
		}		
		if = { 
			limit = { 
				NOT = { trait = knight }
				religion = the_seven
				NOT = { trait = maester }
				NOT = { trait = archmaester }
				NOT = { has_priest_trait_trigger = yes }
			}
			knight_character_effect = yes
		}
	}
	option = {
		name = "EVTOPTB70003" #squire deserves credit
		trigger = {
			any_ward = { trait = squire }
		}
		if = { 
			limit = {
				has_character_flag = king_tourny
			}
			wealth = 35
			prestige = 75
		}
		if = { 
			limit = {
				has_character_flag = grand_tourny
			}
			wealth = 15
			prestige = 35
		}
		if = { 
			limit = {
				has_character_flag = normal_tourny
			}
			wealth = 10
			prestige = 15
		}
		if = { 
			limit = {
				has_character_flag = small_tourny
			}
			wealth = 7
			prestige = 7
		}	
		if = { 
			limit = { 
				NOT = { trait = knight }
				religion = the_seven
				NOT = { trait = maester }
				NOT = { trait = archmaester }
				NOT = { has_priest_trait_trigger = yes }
			}
			knight_character_effect = yes
		}
		random_ward = {
			limit = { trait = squire }
			opinion = {
				modifier = opinion_squire_honoured
				who = ROOT
				years = 4
			}	
			if = { 
				limit = { ROOT = { has_character_flag = king_tourny } }
				wealth = 15
				prestige = 25		
			}	
			if = { 
				limit = { ROOT = { has_character_flag = grand_tourny } }
				wealth = 10
				prestige = 15			
			}
			if = { 
				limit = { ROOT = { has_character_flag = normal_tourny } }
				wealth = 5
				prestige = 10	
			}
			if = { 
				limit = { ROOT = { has_character_flag = small_tourny } }
				wealth = 3
				prestige = 3	
			}			
		}
	}	
}

# Tournament is over
character_event = {
	id = 70002
	title = "TOURNAMENTTITLE3"
	desc = "EVTDESC70002"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		if = { #calculate prestige for improved tooltip
			limit = { ai = no }
			set_variable = { which = tourney_prestige value = 0 }
			any_opinion_modifier_target = {
				limit = {
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
				}
				if = {
					limit = {
						is_vassal_or_below = ROOT
					}
					ROOT = { change_variable = { which = tourney_prestige value = 10 } }
				}
				if = {
					limit = {
						OR = {
							trait = master_warrior
							higher_tier_than = COUNT
						}
						NOT = { is_vassal_or_below = ROOT }
					}
					ROOT = { change_variable = { which = tourney_prestige value = 5 } }
				}	
				if = {
					limit = {
						NOT = { trait = master_warrior }
						tier = COUNT
						NOT = { is_vassal_or_below = ROOT }
					}
					ROOT = { change_variable = { which = tourney_prestige value = 2 } }
				}
			}	
			any_opinion_modifier_target = {
				limit = {
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
					NOT = { character = ROOT }
				}
				if = {
					limit = { higher_tier_than = DUKE }
					ROOT = { change_variable = { which = tourney_prestige value = 5 } }
				}	
			}	
		}
	}

	option = {
		name = "EVTOPTA70002"
		remove_character_modifier = holding_epic_tournament
		clr_character_flag = do_not_disturb	
		
		clr_character_flag = tourny_in_progress
		clr_character_flag = tournament_begins
		clr_character_flag = attending_tournament
		clr_character_flag = attending_tournament_event
		clr_character_flag = no_msg_death
		clr_character_flag = no_msg_maimed
		clr_character_flag = no_msg_wounded
		clr_character_flag = no_msg_knight
		
		clr_character_flag = lost_tournament
		clr_character_flag = ai_tourney_medal
		clr_character_flag = tourney_final_round
		clr_character_flag = in_joust
		clr_character_flag = lost_round
		clr_character_flag = inform_of_all_tourney_results
		clr_character_flag = bribed_to_lose
		clr_character_flag = squire_bribed
		clr_character_flag = tourney_medalist
		
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		
		hidden_tooltip = { character_event = { id = 72999 } } #clear feast flags
		
		clr_character_flag = ai_tourney_1st_found
		clr_character_flag = ai_tourney_2nd_found
		
		if = { #calculate prestige for improved tooltip
			limit = { ai = no }
			prestige = tourney_prestige
			hidden_tooltip = { set_variable = { which = tourney_prestige value = 0 } }
			clr_character_flag = placed_tourney_bet
			clr_character_flag = placed_tourney_bet_self
			clr_character_flag = placed_tourney_bet_5
			clr_character_flag = placed_tourney_bet_20
			clr_character_flag = placed_tourney_bet_40
			hidden_tooltip = { set_variable = { which = tourney_bet_odds value = 0 } }
		}	
		custom_tooltip = {
			text = TOOLTIPtourneyOPINION
		}
		hidden_tooltip = {
			any_opinion_modifier_target = {
				limit = {
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
				}
				if = {
					limit = { ROOT = { ai = yes } }
					if = {
						limit = {
							is_vassal_or_below = ROOT
						}
						ROOT = { prestige = 10 }
					}
					if = {
						limit = {
							OR = {
								trait = master_warrior
								higher_tier_than = COUNT
							}
							NOT = { is_vassal_or_below = ROOT }
						}
						ROOT = { prestige = 5 }
					}	
					if = {
						limit = {
							NOT = { trait = master_warrior }
							tier = COUNT
							NOT = { is_vassal_or_below = ROOT }
						}
						ROOT = { prestige = 2 }
					}	
				}	
				opinion = {
					modifier = opinion_tournament_participant
					who = ROOT
					years = 2
				}			
				clr_character_flag = attending_tournament
				clr_character_flag = attending_tournament_event
				clr_character_flag = king_tourny
				clr_character_flag = grand_tourny
				clr_character_flag = normal_tourny
				clr_character_flag = small_tourny
				clr_character_flag = lost_tournament
				clr_character_flag = ai_tourney_medal
				clr_character_flag = tourney_final_round
				clr_character_flag = in_joust
				clr_character_flag = lost_round
				clr_character_flag = bribed_to_lose
				clr_character_flag = squire_bribed
				clr_character_flag = guest_feast_started
				clr_character_flag = tourney_medalist
				if = {
					limit = { ai = no }
					character_event = { id = 70003 }
					clr_character_flag = placed_tourney_bet
					clr_character_flag = placed_tourney_bet_self
					clr_character_flag = placed_tourney_bet_5
					clr_character_flag = placed_tourney_bet_20
					clr_character_flag = placed_tourney_bet_40
					hidden_tooltip = { set_variable = { which = tourney_bet_odds value = 0 } }
				}	
				remove_opinion = {
					modifier = opinion_attending_tournament
					who = ROOT
				}
				reverse_remove_opinion = {
					modifier = opinion_attending_tournament
					who = ROOT
				}
			}	
			any_opinion_modifier_target = {
				limit = {
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
					NOT = { character = ROOT }
				}
				if = {
					limit = { 
						higher_tier_than = DUKE 
						ROOT = { ai = yes }
					}
					ROOT = { prestige = 5 }
				}
				opinion = {
					modifier = opinion_tournament_spectator
					who = ROOT
					years = 2
				}	
				if = {
					limit = { ai = no }
					character_event = { id = 70092 }
					clr_character_flag = placed_tourney_bet
					clr_character_flag = placed_tourney_bet_self
					clr_character_flag = placed_tourney_bet_5
					clr_character_flag = placed_tourney_bet_20
					clr_character_flag = placed_tourney_bet_40
					hidden_tooltip = { set_variable = { which = tourney_bet_odds value = 0 } }
				}	
				remove_opinion = {
					modifier = opinion_spectating_tournament
					who = ROOT
				}
				reverse_remove_opinion = {
					modifier = opinion_spectating_tournament
					who = ROOT
				}
				clr_character_flag = attending_tournament
				clr_character_flag = tournament_spectator
				clr_character_flag = attending_tournament_event
				clr_character_flag = king_tourny
				clr_character_flag = grand_tourny
				clr_character_flag = normal_tourny
				clr_character_flag = small_tourny
				clr_character_flag = guest_feast_started
				clr_character_flag = tourney_medalist
			}
		}	
	}			
}

# End of tournament , inform participant
character_event = {
	id = 70003
	title = "TOURNAMENTTITLE2"
	desc = "EVTDESC70003"
	picture = "GFX_evt_joust"

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70003"
	}
}
# character_event = {
	# id = 70007
	# title = "TOURNAMENTTITLE2"
	# desc = "EVTDESC70007"
	# picture = "GFX_evt_joust"

	# is_triggered_only = yes

	# option = {
		# name = "EVTOPTA70007"
		# change_martial = 1
	# }
# }

# character_event = {
	# id = 70008
	# title = "TOURNAMENTTITLE2"
	# desc = "EVTDESC70008"
	# picture = "GFX_evt_joust"

	# is_triggered_only = yes

	# option = {
		# name = "EVTOPTA70008"
		# change_martial = -1
	# }
# }			

# Character becomes craven
character_event = {
	id = 70012
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70012"
	picture = "GFX_evt_melee"

	is_triggered_only = yes
	
	trigger = {
		NOT = {
			trait = craven
		}
		NOT = {
			trait = brave
		}
		NOT = { trait = berserker }
	}

	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70012"
		add_trait = craven
	}
}

# Character becomes brave
character_event = {
	id = 70013
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70013"
	picture = "GFX_evt_melee"

	is_triggered_only = yes
	
	trigger = {
		NOT = {
			trait = brave
		}
		NOT = {
			trait = craven
		}
	}

	immediate = {
		set_character_flag = attending_tournament_event
	}	

	option = {
		name = "EVTOPTA70013"
		add_trait = brave
	}
}

# Character becomes homosexual
character_event = {
	id = 70023
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70023"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	trigger = {	
		NOT = { trait = homosexual }
	}

	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70023"
		add_trait = homosexual
	}
}

# Character becomes syphilitic
character_event = {
	id = 70024
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70024"
	picture = "GFX_evt_lovers"

	is_triggered_only = yes
	
	trigger = {
		NOT = { trait = syphilitic }
		NOT = { trait = celibate }
	}

	immediate = {
		set_character_flag = attending_tournament_event
	}

	option = {
		name = "EVTOPTA70024"
		add_trait = syphilitic
	}
}

# Character becomes drunkard
character_event = {
	id = 70025
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70025"
	picture = "GFX_evt_drunk"
	
	is_triggered_only = yes
	
	trigger = {
		NOT = {
			trait = drunkard
		}
	}

	immediate = {
		set_character_flag = attending_tournament_event
	}

	option = {
		name = "EVTOPTA70025"
		add_trait = drunkard
	}
}

# Character becomes duelist
character_event = {
	id = 70026
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70026"
	picture = "GFX_evt_melee"
	
	is_triggered_only = yes
	
	trigger = {
		NOT = {
			lifestyle_traits = 1
		}
	}
	
	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70026"
		add_trait = duelist
	}
}

# Character gains diplomacy ##fash agot edited to intrigue
character_event = {
	id = 70027
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70027"
	picture = "GFX_evt_whispers"

	is_triggered_only = yes
	
	# trigger = {
	# }
	
	immediate = {
		set_character_flag = attending_tournament_event
	}

	option = {
		name = "EVTOPTA70027"
		change_intrigue = 1
	}
}

# Character loses intrigue
character_event = {
	id = 70028
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70028"
	picture = "GFX_evt_whispers"

	is_triggered_only = yes
	
	# trigger = {
	# }
	
	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70028"
		change_intrigue = -1
	}
}

# Character gains stewardship
character_event = {
	id = 70029
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70029"
	picture = "GFX_evt_market"

	is_triggered_only = yes
	
	# trigger = {
	# }
	
	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70029"
		change_stewardship = 1
	}
}

# Character loses stewardship
character_event = {
	id = 70030
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70030"
	picture = "GFX_evt_market"

	is_triggered_only = yes
	
	# trigger = {
	# }
	
	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70030"
		change_stewardship = -1
	}
}

# Character gains diplomacy
character_event = {
	id = 70031
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70031"
	picture = "GFX_evt_council"

	is_triggered_only = yes
	
	# trigger = {
	# }
	
	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70031"
		change_diplomacy = 1
	}
}

# Character loses diplomacy
character_event = {
	id = 70032
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70032"
	picture = "GFX_evt_council"

	is_triggered_only = yes
	
	# trigger = {
	# }
	
	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70032"
		change_diplomacy = -1
	}
}

##Extra Events###
# Character is knighted
character_event = {
	id = 70050
	desc = "EVTDESC70050"
	picture = "GFX_evt_joust"

	is_triggered_only = yes
	
	trigger = {
		NOT = { trait = knight }
	}

	immediate = {
		set_character_flag = attending_tournament_event
	}

	option = {
		name = "EVTOPTA70050"
		ai_chance = { 
			factor = 25 
			modifier = {
				factor = 4
				trait = cynical
			}
			modifier = {
				factor = 4
				trait = humble
			}
		}
		knight_character_effect = yes
		hidden_tooltip = {
			top_liege = {
				if = {
					limit = {
						reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					}
					character_event = { id = 70051 days = 1 } 
				}	
				any_realm_lord = {
					limit = {
						reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					}	
					character_event = { id = 70051 days = 1 } 
				}	
			}
		}
	}
	option = {
		name = "EVTOPTB70050"
		ai_chance = { 
			factor = 75
			modifier = {
				factor = 0
				religion = the_seven
			}
			modifier = {
				factor = 4
				trait = zealous
			}
			modifier = {
				factor = 4
				trait = proud
			}
		}
		if = { 
			limit = { 
				trait = squire
				age = 16
			}
			remove_trait = squire
		}	
	}
}
# Message about knighted
character_event = {
	id = 70051
	title = "TOURNAMENTTITLE3"
	desc = "EVTDESC70051"
	picture = "GFX_evt_melee"
	
	is_triggered_only = yes

	trigger = {
		NOT = { has_character_flag = no_msg_knight }
	}
	
	option = {
		name = "EVTOPTA70051"
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_knight
	}
}

# Choose queen of love and beauty
character_event = {
	id = 70053
	desc = "EVTDESC70053"
	title = "TOURNAMENTTITLE2"
	picture = "GFX_gentle_kiss"
	
	is_triggered_only = yes
	only_men = yes
	
	trigger = {
		is_female = no
	}
	
	immediate = {
		FROM = {
			top_liege = {
				random_realm_character = { #attractive
					limit = { 
						is_female = yes 
						age = 15
						NOT = { age = 30 }
						is_married = no
						is_betrothed = no
						NOT = { trait = incapable }
						prisoner = no
						NOT = { religion = drowned_god }
						trait = fair	
						NOT = { trait = dragon }
						NOT = { trait = white_walker }
						NOT = { is_lover = ROOT }
						OR = {
							religion = the_seven
							culture_group = andal
							culture_group = dornish
							liege = { has_character_flag = attending_tournament }
						}
					}
					set_character_flag = queen_love_beauty
					save_event_target_as = queen_love_beauty_1
				}
				random_realm_character = { #prestigious family
					limit = { 
						is_female = yes 
						age = 15
						NOT = { age = 30 }
						is_married = no
						is_betrothed = no
						NOT = { trait = incapable }
						prisoner = no
						NOT = { religion = drowned_god }
						OR = {
							any_dynasty_member = {
								is_close_relative = PREV
								prestige = 1500
								has_character_flag = attending_tournament
							}	
							any_dynasty_member = { 
								is_close_relative = PREV
								higher_tier_than = DUKE 
								has_character_flag = attending_tournament
							}
						}	
						NOT = { has_character_flag = queen_love_beauty }
						NOT = { trait = dragon }
						NOT = { trait = white_walker }
						NOT = { is_lover = ROOT }
					}
					set_character_flag = queen_love_beauty
					save_event_target_as = queen_love_beauty_2
				}
				random_realm_character = { #high dynasty
					limit = { 
						is_female = yes 
						age = 15
						NOT = { age = 30 }
						is_married = no
						is_betrothed = no
						NOT = { trait = incapable }
						prisoner = no
						NOT = { religion = drowned_god }
						any_dynasty_member = { 
							higher_tier_than = BARON 
							has_character_flag = attending_tournament
						}	
						NOT = { trait = ugly }
						NOT = { trait = dwarf }
						NOT = { trait = inbred }
						NOT = { trait = hunchback }
						NOT = { trait = harelip }			
						NOT = { has_character_flag = queen_love_beauty }
						NOT = { trait = dragon }
						NOT = { trait = white_walker }
						NOT = { is_lover = ROOT }
					}
					set_character_flag = queen_love_beauty
					save_event_target_as = queen_love_beauty_3
				}
				random_realm_character = { #other random
					limit = { 
						is_female = yes 
						age = 15
						NOT = { age = 30 }
						is_married = no
						is_betrothed = no
						NOT = { trait = incapable }
						prisoner = no
						NOT = { religion = drowned_god }
						NOT = { trait = ugly }
						NOT = { trait = dwarf }
						NOT = { trait = inbred }
						NOT = { trait = hunchback }
						NOT = { trait = harelip }
						NOT = { has_character_flag = queen_love_beauty }
						NOT = { trait = dragon }
						NOT = { trait = white_walker }
						NOT = { is_lover = ROOT }
						OR = {
							religion = the_seven
							culture_group = andal
							culture_group = dornish
							liege = { has_character_flag = attending_tournament }
						}
					}
					set_character_flag = queen_love_beauty
					save_event_target_as = queen_love_beauty_4
				}
			}	
		}	
	}
	
	option = {
		name = "EVTOPT70053SPOUSE"
		trigger = { 
			spouse = { 
				is_alive = yes 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = {
				factor = 3
				trait = honorable
			}
			modifier = {
				factor = 3
				trait = just
			}
			modifier = {
				factor = 2
				trait = kind
			}
			modifier = {
				factor = 10
				trait = chaste
			}
			modifier = {
				factor = 2
				trait = honest
			}
			modifier = {
				factor = 0.5
				trait = arbitrary
			}
			modifier = {
				factor = 0.2
				trait = lustful
			}
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 0.5
				trait = deceitful
			}
			modifier = {
				factor = 0.5
				trait = lunatic
			}
			modifier = {
				factor = 0.66
				spouse = { age = 30 }
			}
			modifier = {
				factor = 2
				spouse = { is_lover = ROOT }
			}
			modifier = {
				factor = 1.5
				spouse = { reverse_opinion = { who = ROOT value = 25 } }
			}
			modifier = {
				factor = 1.5
				spouse = { reverse_opinion = { who = ROOT value = 50 } }
			}
			modifier = {
				factor = 1.5
				spouse = { reverse_opinion = { who = ROOT value = 75 } }
			}
			modifier = {
				factor = 1.5
				spouse = { reverse_opinion = { who = ROOT value = 100 } }
			}
			modifier = {
				factor = 0.66
				spouse = { NOT = { reverse_opinion = { who = ROOT value = -24 } } }
			}
			modifier = {
				factor = 0.66
				spouse = { NOT = { reverse_opinion = { who = ROOT value = -49 } } }
			}
			modifier = {
				factor = 0.66
				spouse = { NOT = { reverse_opinion = { who = ROOT value = -74 } } }
			}
			modifier = {
				factor = 0.66
				spouse = { NOT = { reverse_opinion = { who = ROOT value = -99 } } }
			}
		}
		spouse = {
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
	}
	option = {
		name = "EVTOPT70053BETROTHED"
		trigger = { 
			betrothed = { 
				is_alive = yes 
				age = 8
				same_realm = ROOT
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
		}
		ai_chance = { 
			factor = 30 
			modifier = {
				factor = 3
				trait = honorable
			}
			modifier = {
				factor = 3
				trait = just
			}
			modifier = {
				factor = 2
				trait = kind
			}
			modifier = {
				factor = 10
				trait = chaste
			}
			modifier = {
				factor = 2
				trait = honest
			}
			modifier = {
				factor = 0.5
				trait = arbitrary
			}
			modifier = {
				factor = 0.2
				trait = lustful
			}
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 0.5
				trait = deceitful
			}
			modifier = {
				factor = 0.5
				trait = lunatic
			}
			modifier = {
				factor = 0.66
				betrothed = { age = 30 }
			}
			modifier = {
				factor = 2
				betrothed = { is_lover = ROOT }
			}
			modifier = {
				factor = 1.5
				betrothed = { reverse_opinion = { who = ROOT value = 25 } }
			}
			modifier = {
				factor = 1.5
				betrothed = { reverse_opinion = { who = ROOT value = 50 } }
			}
			modifier = {
				factor = 1.5
				betrothed = { reverse_opinion = { who = ROOT value = 75 } }
			}
			modifier = {
				factor = 1.5
				betrothed = { reverse_opinion = { who = ROOT value = 100 } }
			}
			modifier = {
				factor = 0.66
				betrothed = { NOT = { reverse_opinion = { who = ROOT value = -24 } } }
			}
			modifier = {
				factor = 0.66
				betrothed = { NOT = { reverse_opinion = { who = ROOT value = -49 } } }
			}
			modifier = {
				factor = 0.66
				betrothed = { NOT = { reverse_opinion = { who = ROOT value = -74 } } }
			}
			modifier = {
				factor = 0.66
				betrothed = { NOT = { reverse_opinion = { who = ROOT value = -99 } } }
			}
		}
		betrothed = {
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
	}
	option = {
		name = "EVTOPT70053LOVER"		
		trigger = { 
			any_lover = { 
				is_female = yes
				OR = {
					is_main_spouse = no
					NOT = { is_married = ROOT }
				}
				NOT = { FROM = { spouse = { character = PREVPREV } } }
				NOT = { character = FROM }
				NOT = { betrothed = { character = ROOT } }
				
				NOT = { trait = incapable }
				prisoner = no				
			}
		}
		ai_chance = { factor = 20 }
		random_lover = {
			limit = {
				is_female = yes
				OR = {
					is_main_spouse = no
					NOT = { is_married = ROOT }
				}
				NOT = { FROM = { spouse = { character = PREVPREV } } }
				NOT = { character = FROM }
				NOT = { betrothed = { character = ROOT } }
				
				NOT = { trait = incapable }
				prisoner = no
			}
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
				multiplier = 2
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}		
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
		any_spouse = {
			limit = { 
				is_alive = yes
				NOT = { has_character_flag = queen_love_beauty } 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
			opinion = {
				modifier = insulted
				who = ROOT
				multiplier = 1.5
			}
		}
		betrothed = {
			if = {
				limit = {
					NOT = { has_character_flag = queen_love_beauty } 
					age = 8
					same_realm = ROOT
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
				}
				opinion = {
					modifier = insulted
					who = ROOT
					multiplier = 1.5
				}
			}	
		}
	}
	
	option = {
		name = "EVTOPT70053QUEENCONSORT"		
		trigger = { 
			FROM = {
				spouse = { 
					is_alive = yes 
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
					NOT = { character = ROOT }
				}
			}	
		}
		ai_chance = { 
			factor = 6
			modifier = {
				factor = 3
				trait = ambitious
			}
			modifier = {
				factor = 3
				trait = lustful
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 0.33
				trait = chaste
			}
			modifier = {
				factor = 0.5
				trait = shy
			}
			modifier = {
				factor = 0.33
				trait = content
			}
			modifier = {
				factor = 0.66
				FROM = { spouse = { age = 30 } }
			}
			modifier = {
				factor = 2
				FROM = { spouse = { is_lover = ROOT } }
			}
			modifier = {
				factor = 1.5
				FROM = { spouse = { reverse_opinion = { who = ROOT value = 25 } } }
			}
			modifier = {
				factor = 1.5
				FROM = { spouse = { reverse_opinion = { who = ROOT value = 50 } } }
			}
			modifier = {
				factor = 1.5
				FROM = { spouse = { reverse_opinion = { who = ROOT value = 75 } } }
			}
			modifier = {
				factor = 1.5
				FROM = { spouse = { reverse_opinion = { who = ROOT value = 100 } } }
			}
			modifier = {
				factor = 0.66
				FROM = { spouse = { NOT = { reverse_opinion = { who = ROOT value = -15 } } } }
			}
			modifier = {
				factor = 0
				FROM = { spouse = { NOT = { reverse_opinion = { who = ROOT value = -29 } } } }
			}
		}
		FROM = {
			spouse = {
				opinion = {
					modifier = opinion_queen_love_beauty
					who = ROOT
					years = 20
					multiplier = 2
				}
				character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
				set_character_flag = queen_love_beauty
			}
		}	
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
		any_spouse = {
			limit = { 
				is_alive = yes
				NOT = { has_character_flag = queen_love_beauty } 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
			opinion = {
				modifier = insulted
				who = ROOT
				multiplier = 1.5
			}
		}
		betrothed = {
			if = {
				limit = {
					NOT = { has_character_flag = queen_love_beauty } 
					age = 8
					same_realm = ROOT
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
				}
				opinion = {
					modifier = insulted
					who = ROOT
					multiplier = 1.5
				}
			}	
		}
	}
	
	option = {
		name = "EVTOPT70053QUEEN"		
		trigger = { 
			FROM = {
				is_alive = yes 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
				NOT = { character = ROOT }
				OR = {
					is_main_spouse = no
					NOT = { is_married = ROOT }
				}
				NOT = { betrothed = { character = ROOT } }
			}	
		}
		ai_chance = { 
			factor = 6
			modifier = {
				factor = 3
				trait = ambitious
			}
			modifier = {
				factor = 3
				trait = lustful
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 0.33
				trait = chaste
			}
			modifier = {
				factor = 0.5
				trait = shy
			}
			modifier = {
				factor = 0.33
				trait = content
			}
			modifier = {
				factor = 0.66
				FROM = { age = 30 }
			}
			modifier = {
				factor = 2
				FROM = { is_lover = ROOT }
			}
			modifier = {
				factor = 1.5
				FROM = { reverse_opinion = { who = ROOT value = 25 } }
			}
			modifier = {
				factor = 1.5
				FROM = { reverse_opinion = { who = ROOT value = 50 } }
			}
			modifier = {
				factor = 1.5
				FROM = { reverse_opinion = { who = ROOT value = 75 } }
			}
			modifier = {
				factor = 1.5
				FROM = { reverse_opinion = { who = ROOT value = 100 } }
			}
			modifier = {
				factor = 0.66
				FROM = { NOT = { reverse_opinion = { who = ROOT value = -15 } } }
			}
			modifier = {
				factor = 0
				FROM = { NOT = { reverse_opinion = { who = ROOT value = -29 } } }
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
				multiplier = 2
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}	
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
		any_spouse = {
			limit = { 
				is_alive = yes
				NOT = { has_character_flag = queen_love_beauty } 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
				NOT = { character = FROM }
			}
			opinion = {
				modifier = insulted
				who = ROOT
				multiplier = 1.5
			}
		}
		betrothed = {
			if = {
				limit = {
					NOT = { has_character_flag = queen_love_beauty } 
					age = 8
					same_realm = ROOT
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
					NOT = { character = FROM }
				}
				opinion = {
					modifier = insulted
					who = ROOT
					multiplier = 1.5
				}
			}	
		}
	}

	option = {
		name = "EVTOPTA70053"
		ai_chance = { factor = 3 }
		trigger = { 
			event_target:queen_love_beauty_1 = { is_alive = yes }
		}
		event_target:queen_love_beauty_1 = {
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
				multiplier = 2
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
		any_spouse = {
			limit = { 
				is_alive = yes
				NOT = { has_character_flag = queen_love_beauty } 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
			opinion = {
				modifier = insulted
				who = ROOT
				multiplier = 1.5
			}
		}
		betrothed = {
			if = {
				limit = {
					NOT = { has_character_flag = queen_love_beauty } 
					age = 8
					same_realm = ROOT
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
				}
				opinion = {
					modifier = insulted
					who = ROOT
					multiplier = 1.5
				}
			}	
		}
	}
	option = {
		name = "EVTOPTB70053"
		ai_chance = { factor = 3 }
		trigger = { 
			event_target:queen_love_beauty_2 = { is_alive = yes }	
		}
		event_target:queen_love_beauty_2 = {
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
				multiplier = 2
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}	
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
		any_spouse = {
			limit = { 
				is_alive = yes
				NOT = { has_character_flag = queen_love_beauty } 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
			opinion = {
				modifier = insulted
				who = ROOT
				multiplier = 1.5
			}
		}
		betrothed = {
			if = {
				limit = {
					NOT = { has_character_flag = queen_love_beauty } 
					age = 8
					same_realm = ROOT
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
				}
				opinion = {
					modifier = insulted
					who = ROOT
					multiplier = 1.5
				}
			}	
		}
	}
	option = {
		name = "EVTOPTC70053"
		ai_chance = { factor = 3 }
		trigger = { 
			event_target:queen_love_beauty_3 = { is_alive = yes }	
		}
		event_target:queen_love_beauty_3 = {
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
				multiplier = 2
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}	
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
		any_spouse = {
			limit = { 
				is_alive = yes
				NOT = { has_character_flag = queen_love_beauty } 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
			opinion = {
				modifier = insulted
				who = ROOT
				multiplier = 1.5
			}
		}
		betrothed = {
			if = {
				limit = {
					NOT = { has_character_flag = queen_love_beauty } 
					age = 8
					same_realm = ROOT
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
				}
				opinion = {
					modifier = insulted
					who = ROOT
					multiplier = 1.5
				}
			}	
		}
	}
	option = {
		name = "EVTOPTD70053"
		ai_chance = { factor = 1 }
		event_target:queen_love_beauty_4 = {
			opinion = {
				modifier = opinion_queen_love_beauty
				who = ROOT
				years = 20
				multiplier = 2
			}
			character_event = { id = 70057 days = 1 tooltip = "EVTTOOLTIP70057" }
			set_character_flag = queen_love_beauty
		}	
		hidden_tooltip = {
			event_target:queen_love_beauty_1 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_2 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_3 = { clr_character_flag = queen_love_beauty }
			event_target:queen_love_beauty_4 = { clr_character_flag = queen_love_beauty }
		}
		any_spouse = {
			limit = { 
				is_alive = yes
				NOT = { has_character_flag = queen_love_beauty } 
				NOT = { trait = incapable }
				prisoner = no
				is_female = yes
			}
			opinion = {
				modifier = insulted
				who = ROOT
				multiplier = 1.5
			}
		}
		betrothed = {
			if = {
				limit = {
					NOT = { has_character_flag = queen_love_beauty } 
					age = 8
					same_realm = ROOT
					NOT = { trait = incapable }
					prisoner = no
					is_female = yes
				}
				opinion = {
					modifier = insulted
					who = ROOT
					multiplier = 1.5
				}
			}	
		}
	}
}
# queen is informed
character_event = {
	id = 70057
	desc = "EVTDESC70057"
	picture = "GFX_gentle_kiss"
	
	is_triggered_only = yes
	
	trigger = { is_female = yes }
	
	option = {
		name = "EVTOPTA70057"
		prestige = 50
		reverse_opinion = {
			modifier = opinion_queen_love_beauty_chosen
			who = FROM
			years = 20		
		}
		hidden_tooltip = {
			FROM = {
				random_opinion_modifier_target = {
					limit = {
						has_character_flag = tourny_in_progress
						reverse_has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
					}
					character_event = { id = 70058 days = 1 } 
				}
				character_event = { id = 70074 days = 1 }  
			}
			#is this controversial?
			if = {
				limit = { #already married
					is_married = yes
					#exceptions
					NOT = { is_close_relative = FROM } #relative of champion
					NOT = { character = FROMFROM } #host
					spouse = {
						is_alive = yes
						NOT = { dynasty = 0 } #spouse is lowborn
						NOT = { character = FROM } #spouse of champion
						NOT = { character = FROMFROM } #spouse of host
					}
				}
				FROM = { 
					set_character_flag = controversial_queen_love_beauty
					character_event = { id = tourney.350 days = 2 }
				}	
			}
			if = {
				limit = { #already betrothed
					is_betrothed = yes
					#exceptions
					NOT = { is_close_relative = FROM } #relative of champion
					NOT = { character = FROMFROM } #host
					betrothed = {
						is_alive = yes
						NOT = { dynasty = 0 } #betrothed is lowborn
						NOT = { character = FROM } #betrothed of champion
						NOT = { character = FROMFROM } #betrothed of host
					}
				}
				FROM = { 
					set_character_flag = controversial_queen_love_beauty
					character_event = { id = tourney.350 days = 2 }
				}	
			}
		}
		clr_character_flag = queen_love_beauty
	}
}
# tourny holder is informed
character_event = {
	id = 70058
	title = "TOURNAMENTTITLE3"	
	picture = "GFX_gentle_kiss"
	
	desc = {
		text = EVTDESC70058
		trigger = { FROMFROM = { NOT = { has_character_flag = controversial_queen_love_beauty } } }
	}
	desc = {
		text = EVTDESC70058B
		trigger = { FROMFROM = { has_character_flag = controversial_queen_love_beauty } }
	}
	
	is_triggered_only = yes
	
	option = {
		name = {
			text = EVTOPTA70058
			trigger = { FROMFROM = { NOT = { has_character_flag = controversial_queen_love_beauty } } }
		}
		name = {
			text = EVTOPTA70058B
			trigger = { FROMFROM = { has_character_flag = controversial_queen_love_beauty } }
		}
		FROMFROM = {
			tooltip = { show_portrait = yes }
		}
		hidden_tooltip = {
			any_opinion_modifier_target = {
				limit = {
					NOT = { character = FROMFROM }
					has_character_flag = attending_tournament
					OR = {
						has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
						has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
					}	
				}
				character_event = { id = 70059 }
			}
			if = { #inform relatives of controversial choice
				limit = { FROMFROM = { has_character_flag = controversial_queen_love_beauty } }
				FROM = {
					any_close_relative = {
						limit = { 
							is_alive = yes 
							NOT = { character = PREV }
							NOT = { is_married = PREV }
							NOT = { betrothed = { character = ROOT_FROM } }
							OR = {
								sibling = PREV
								is_child_of = PREV
								is_father = PREV
								is_mother = PREV
							}
							NAND = {
								has_character_flag = attending_tournament
								OR = {
									has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
									has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
								}
							}
						}
						character_event = { id = 70059 }
					}
					spouse = {
						if = {
							limit = {
								limit = { 
									NAND = {
										has_character_flag = attending_tournament
										OR = {
											has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
											has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
										}
									}
								}
								character_event = { id = 70059 }
							}
						}
					}
					betrothed = {
						if = {
							limit = {
								limit = { 
									NAND = {
										has_character_flag = attending_tournament
										OR = {
											has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
											has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
										}
									}
								}
								character_event = { id = 70059 }
							}
						}
					}
				}
			}
		}
	}
}
# tourny participant is informed
character_event = {
	id = 70059
	title = "TOURNAMENTTITLE2"
	picture = "GFX_gentle_kiss"
	
	desc = {
		text = EVTDESC70059
		trigger = { FROMFROMFROM = { NOT = { has_character_flag = controversial_queen_love_beauty } } }
	}
	desc = {
		text = EVTDESC70059B
		trigger = { FROMFROMFROM = { has_character_flag = controversial_queen_love_beauty } }
	}
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = {
			text = EVTOPTA70058
			trigger = { FROMFROMFROM = { NOT = { has_character_flag = controversial_queen_love_beauty } } }
		}
		name = {
			text = EVTOPTA70058B
			trigger = { FROMFROMFROM = { has_character_flag = controversial_queen_love_beauty } }
		}
		trigger = { 
			NAND = {
				dynasty = FROMFROM
				is_close_relative = FROMFROM
			}	
		}
		FROMFROMFROM = {
			tooltip = { show_portrait = yes }
		}
	}
	option = {
		name = "EVTOPTB70059"
		trigger = { 
			dynasty = FROMFROM
			is_close_relative = FROMFROM
			FROMFROMFROM = { NOT = { has_character_flag = controversial_queen_love_beauty } }
		}
		FROMFROMFROM = {
			tooltip = { show_portrait = yes }
		}
		prestige = 10
	}
	option = {
		name = "EVTOPTC70059"
		trigger = { 
			dynasty = FROMFROM
			is_close_relative = FROMFROM
			FROMFROMFROM = { has_character_flag = controversial_queen_love_beauty }
		}
		FROMFROMFROM = {
			tooltip = { show_portrait = yes }
		}
		prestige = -20
	}
}
character_event = { #choice is controversial
	id = tourney.350
	desc = EVTDESCtourney.350
	picture = "GFX_gentle_kiss"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.350"
		FROM = {
			any_close_relative = {
				limit = { 
					is_alive = yes 
					NOT = { character = PREV }
					NOT = { is_married = PREV }
					NOT = { betrothed = { character = ROOT_FROM } }
					OR = {
						sibling = PREV
						is_child_of = PREV
						is_father = PREV
						is_mother = PREV
					}
				}
				opinion = { who = ROOT modifier = opinion_qolb_scandal }	
			}
			if = {
				limit = { is_married = yes }
				spouse = {
					opinion = { who = ROOT modifier = opinion_qolb_scandal }
					any_close_relative = {
						limit = { 
							is_alive = yes 
							NOT = { character = PREV }
							NOT = { character = ROOT_FROM }
							OR = {
								sibling = PREV
								is_child_of = PREV
								is_father = PREV
								is_mother = PREV
							}
							NOT = { is_close_relative = ROOT_FROM }
						}
						opinion = { who = ROOT modifier = opinion_qolb_scandal }	
					}
				}	
			}	
			if = {
				limit = { is_betrothed = yes }
				betrothed = {
					opinion = { who = ROOT modifier = opinion_qolb_scandal }
					any_close_relative = {
						limit = { 
							is_alive = yes 
							NOT = { character = PREV }
							NOT = { character = ROOT_FROM }
							OR = {
								sibling = PREV
								is_child_of = PREV
								is_father = PREV
								is_mother = PREV
							}
							NOT = { is_close_relative = ROOT_FROM }
						}
						opinion = { who = ROOT modifier = opinion_qolb_scandal }	
					}
				}	
			}
		}
		piety = -50
	}
	
	after = {
		clr_character_flag = controversial_queen_love_beauty
	}
}
# on death tourny cancelled
# character_event = {
	# id = 70060
	# desc = "EVTDESC70060"
	# title = "TOURNAMENTTITLE3"
	
	# trigger = {
		# has_character_flag = tourny_in_progress
	# }
	
	# is_triggered_only = yes
	
	# option = {
		# name = "EVTOPTA70060"
		# hidden_tooltip = {
			# top_liege = {
				# any_realm_character = {
					# limit = {
						# has_character_flag = attending_tournament
						# has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					# }
					# character_event = { id = 70037 }
				# }
			# }	
		# }
	# }
# }

#Tourny Rivals drama
character_event = {
	id = 71061

	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		random_opinion_modifier_target = {
			limit = {
				has_character_flag = tourny_in_progress
				reverse_has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
			}
			random_opinion_modifier_target = {
				limit = {
					has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
					has_character_flag = attending_tournament
					NOT = { has_character_flag = lost_tournament }
					is_female = no
					OR = {
						AND = {
							NOT = { opinion = { who = ROOT value = 0 } }
							NOT = { reverse_opinion = { who = ROOT value = 0 } }
							OR = {
								culture = ROOT
								same_liege = ROOT
								NOT = { opinion = { who = ROOT value = -50 } }
							}
							NOT = { ROOT = { higher_tier_than = PREV } }
							prestige = 100	
						}
						is_rival = ROOT
						has_opinion_modifier = { who = ROOT modifier = opinion_blood_feud }
					}										
					NOT = { trait = shy }
					NOT = { trait = honorable }						
					NOT = { has_severe_disability_trigger = yes }	
				}	
				character_event = { id = 71062 }
				ROOT = { set_character_flag = attending_tournament_event }
			}
		}
	}	
	
	option = {
		name = OK
	}
}
character_event = { #scope to target
	id = 71062

	is_triggered_only = yes
	hide_window = yes
	
	immediate = {
		FROM = { character_event = { id = 70061 } }
	}	
	
	option = {
		name = OK
	}
}
	
character_event = {
	id = 70061
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70061"
	picture = "GFX_evt_joust"

	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70061" #he just jests
		trigger = { NOT = { trait = berserker } }
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0.33
				OR = {
					is_rival = FROM
					has_opinion_modifier = { who = FROM modifier = opinion_blood_feud }
				}
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 2
				trait = humble
			}
			modifier = {
				factor = 2
				trait = honorable
			}
		}
		prestige = -15
		if = {
			limit = { 
				NOT = { trait = gregarious } 
				NOT = { trait = shy } 
				NOT = { personality_traits = 6 }
			}
			random = {
				chance = 20
				add_trait = gregarious
				hidden_tooltip = {
					character_event = { id = 38265 }
				}
			}	
		}	
		if = {
			limit = { 
				NOT = { trait = craven } 
				NOT = { trait = brave } 
				NOT = { personality_traits = 6 }
			}
			random = {
				chance = 10
				add_trait = craven
				hidden_tooltip = {
					character_event = { id = 38257 }
				}
			}	
		}	
	}
	option = {
		name = "EVTOPTB70061" #I will show him
		ai_chance = {
			factor = 10
			modifier = {
				factor = 2
				trait = proud 
			}			
			modifier = {
				factor = 2
				trait = patient
			}
			modifier = {
				factor = 2
				trait = just
			}
		}
		if = {
			limit = { 
				NOT = { trait = proud } 
				NOT = { trait = humble } 
				NOT = { personality_traits = 6 }
			}
			random = {
				chance = 20
				add_trait = proud
				hidden_tooltip = {
					character_event = { id = 38261 }
				}
			}	
		}
		if = {
			limit = { is_rival = FROM }
			if = {
				limit = {
					NOT = { trait = stressed }
					NOT = { trait = depressed }
				}
				random = {
					chance = 30
					add_trait = stressed
					hidden_tooltip = { # Notify stressed
						character_event = { id = 38282 }
					}
				}	
			}
		}
		if = {
			limit = { NOT = { is_rival = FROM } }
			add_rival = FROM
		}
		FROM = {
			character_event = { id = 70062 days = 1 tooltip = "EVTTOOLTIP70062" }			
		}		
	}
	option = {
		name = "EVTOPTC70061" #Single combat!
		trigger = {
			NOT = { trait = craven }
			NOT = { is_weak_trigger = yes }
		}
		ai_chance = {
			factor = 10
			modifier = {
				factor = 2
				trait = duelist
			}
			modifier = {
				factor = 2
				trait = brave
			}
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = ruthless
			}
			modifier = {
				factor = 0.5
				trait = humble
			}
			modifier = {
				factor = 0.33
				trait = craven
			}
		}
		if = {
			limit = { 
				NOT = { trait = wroth } 
				NOT = { trait = patient } 
				NOT = { personality_traits = 6 }
			}
			random = {
				chance = 25
				add_trait = wroth
				hidden_tooltip = {
					character_event = { id = 38254 }
				}
			}					
		}	
		FROM = {
			character_event = { id = 70063 days = 1 tooltip = "EVTTOOLTIP70063" }
		}
	}
}

#other chaarcter is onformed of rivalry
character_event = {
	id = 70062
	desc = "EVTDESC70062"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	trigger = { FROM = { is_alive = yes } }
	
	option = {
		name = "EVTOPTA70062"
		if = {
			limit = { is_rival = FROM }
			prestige = 10
		}
		if = {
			limit = { NOT = { is_rival = FROM } }
			add_rival = FROM
		}
	}
}

#other character is informed of challenge to single combat!
character_event = {
	id = 70063
	desc = "EVTDESC70063"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	trigger = { FROM = { is_alive = yes } }
	
	option = {
		name = "EVTOPTA70063" #apoligise profusely
		trigger = { NOT = { trait = berserker } }
		ai_chance = {
			factor = 10
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 2
				trait = honorable
			}
			modifier = {
				factor = 2
				trait = patient
			}
			modifier = {
				factor = 2
				trait = craven
			}
		}
		prestige = -30
		if = {
			limit = { 
				NOT = { trait = craven } 
				NOT = { trait = brave } 
				NOT = { personality_traits = 6 }
			}
			random = {
				chance = 20
				add_trait = craven
				hidden_tooltip = {
					character_event = { id = 38257 }
				}
			}	
		}	
		FROM = { character_event = { id = 70064 tooltip = "EVTTOOLTIP70064" } }
	}
	option = {
		name = "EVTOPTB70063" #I accept!
		ai_chance = {
			factor = 10
			modifier = {
				factor = 2
				trait = duelist
			}
			modifier = {
				factor = 2
				trait = brave
			}
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = ruthless
			}
			modifier = {
				factor = 0.5
				trait = humble
			}
		}
		FROM = {
			set_character_flag = tourney_duel_challenger
			set_character_flag = flag_duel_friendly
		}
		set_character_flag = tourney_duel_target
		set_character_flag = flag_duel_friendly
		hidden_tooltip = { e_rebels = { holder_scope = { character_event = { id = duel.1 } } } }			
	}
}
#inform root of apology
character_event = {
	id = 70064
	desc = "EVTDESC70064"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70064"
		prestige = 30
	}
}
#inform root of win
character_event = {
	id = 70065
	desc = "EVTDESC70065"
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTA70065"
		prestige = 30
	}
}
# #inform root of draw
# character_event = {
	# id = 70066
	# desc = "EVTDESC70066"
	# picture = "GFX_evt_melee"
	
	# is_triggered_only = yes
	
	# option = {
		# name = "EVTOPTA70066"
		# prestige = -5
		# if = {
			# limit = {
				# NOT = {
					# is_rival = FROM
				# }
			# }	
			# add_rival = FROM
		# }	
		# hidden_tooltip = {
			# top_liege = {
				# if = {
					# limit = {
						# reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					# }
					# character_event = { id = 70072 } 
				# }
				# any_realm_lord = {
					# limit = {
						# reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					# }	
					# character_event = { id = 70072 } 
				# }	
			# }
		# }
	# }
# }
#inform root of loss
character_event = {
	id = 70067
	desc = "EVTDESC70067"
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70067"
		prestige = -30
	}
}
#inform from of loss
character_event = {
	id = 70068
	desc = "EVTDESC70068"
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70068"
		prestige = -30
	}
}
# #inform from of draw
# character_event = {
	# id = 70069
	# desc = "EVTDESC70069"
	# picture = "GFX_evt_melee"
	
	# is_triggered_only = yes
	
	# option = {
		# name = "EVTOPTA70066"
		# prestige = -5
	# }
# }
#inform from of win
character_event = {
	id = 70070
	desc = "EVTDESC70070"
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTA70065"
		prestige = 30
	}
}
#inform tourny holder of duel
character_event = {
	id = 70071
	desc = "EVTDESC70071"
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70071"
		FROMFROM = { tooltip = { show_portrait = yes } }
	}
}
# #inform tourny holder of duel
# character_event = {
	# id = 70072
	# desc = "EVTDESC70072"
	# picture = "GFX_evt_melee"
	
	# is_triggered_only = yes
	
	# option = {
		# name = "EVTOPTA70071"
		# top_liege = {
			# random_realm_character = {
				# limit = {
					# character = FROMFROM
				# }
				# hidden_tooltip = { prestige = 0 }
			# }
		# }
	# }
# }
#inform tourny holder of duel
character_event = {
	id = 70073
	desc = "EVTDESC70073"
	picture = GFX_evt_family_feud_republic
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70071"
		FROMFROM = { tooltip = { show_portrait = yes } }
	}
}
####

#pursue queen fo love and beauty?
character_event = {
	id = 70074
	desc = "EVTDESC70074"
	picture = GFX_evt_feast
	
	is_triggered_only = yes
	
	min_age = 14
	capable_only = yes
	prisoner = no
	
	trigger = {
		OR = {
			NOT = { trait = chaste }
			is_married = FROM
		}	
		NOT = { trait = celibate }
		NOT = { trait = eunuch }
		is_female = no
		FROM = {
			age = 14
			NOT = { is_lover = ROOT }
			NOT = { trait = celibate }
			NOT = { trait = incapable }
			prisoner = no
		}
	}
	
	option = {
		name = "EVTOPTA70074" #pursue
		ai_chance = {
			factor = 10
			modifier = {
				factor = 5
				trait = lustful
			}
			modifier = {
				factor = 4
				OR = {
					is_married = no
					is_married = FROM
				}	
			}
			modifier = {
				factor = 2
				FROM = { trait = fair }
			}
			modifier = {
				factor = 1.5
				NOT = { age = 40 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value =  30 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value =  60 }
			}	
			modifier = {
				factor = 1.5
				opinion = { who = FROM value =  90 }
			}
		}
		FROM = { character_event = { id = 70075 tooltip = "EVTTOOLTIP70075" } }
	}
	option = {
		ai_chance = {
			factor = 10
			modifier = {
				factor = 2
				is_married = yes
				NOT = { is_married = FROM }
			}
			modifier = {
				factor = 2
				FROM = { trait = ugly }
			}
			modifier = {
				factor = 1.5
				age = 40
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value =  0 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value =  -30 } }
			}	
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value =  -60 } }
			}
		}
		name = "EVTOPTB70074" #no thanks
	}
}
#queen responds
character_event = {
	id = 70075
	desc = "EVTDESC70075"
	picture = GFX_evt_feast
	
	is_triggered_only = yes
		
	option = {
		name = "EVTOPTA70075" #accept
		ai_chance = {
			factor = 10	
			modifier = {
				factor = 3
				trait = chaste
				is_married = FROM
			}			
			modifier = {
				factor = 0
				trait = chaste
				is_married = yes
				NOT = { is_married = FROM }
			}
			modifier = {
				factor = 5
				trait = lustful
			}
			modifier = {
				factor = 2
				FROM = { trait = fair }
			}
			modifier = {
				factor = 1.5
				FROM = { NOT = { age = 40 } }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value =  30 }
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value =  60 }
			}	
			modifier = {
				factor = 2
				opinion = { who = FROM value =  90 }
			}
		}
		FROM = { character_event = { id = 70076 tooltip = "EVTTOOLTIP70076" } }
		add_lover = FROM
	}
	option = {
		ai_chance = {
			factor = 10
			modifier = {
				factor = 2
				age_diff = {
					who = FROM
					years = 20
				}
				NOT = { is_older_than = FROM }
			}
			modifier = {
				factor = 2
				NOT = { age = 18 }
				age_diff = {
					who = FROM
					years = 10
				}
				NOT = { is_older_than = FROM }
			}
			modifier = {
				factor = 1.5
				FROM = { age = 40 }
			}
			modifier = {
				factor = 2
				FROM = { trait = ugly }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value =  0 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value =  -30 } }
			}	
			modifier = {
				factor = 2
				NOT = { opinion = { who = FROM value =  -60 } }
			}
			modifier = {
				factor = 3
				NOT = { opinion = { who = FROM value =  -90 } }
			}
		}
		name = "EVTOPTB70075" #no thanks
		FROM = { 
			character_event = { id = 70077 tooltip = "EVTTOOLTIP70077" }
			opinion = {
				modifier = opinion_spurned
				who = ROOT
				years = 10
			}
		}
	}
}
#ichaarcter informed of new lover
character_event = {
	id = 70076
	desc = "EVTDESC70076"
	picture = "GFX_evt_lovers"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70076"
		add_lover = FROM
	}
}
#ichaarcter informed of rejection
character_event = {
	id = 70077
	desc = "EVTDESC70077"
	picture = "GFX_evt_quarrel"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70077"
	}
}
#show me the medal winners
character_event = {
	id = 70078
	desc = "EVTDESC70078"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70078" #Grand tourny
		hidden_tooltip = {
			character_event = { id = 70079 }
		}	
	}
	option = {
		name = "EVTOPTB70078" #Regional tourny
		hidden_tooltip = {
			character_event = { id = 70080 }
		}	
	}
	option = {
		name = "EVTOPTC70078" #Local tourny
		hidden_tooltip = {
			character_event = { id = 70081  }
		}	
	}
}
#grand tourny medals
character_event = {
	id = 70079
	desc = "EVTDESC70079"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70079" #1st
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = grand_tourny_1st
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
	option = {
		name = "EVTOPTB70079" #2nd
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = grand_tourny_2nd
					NOT = { has_character_flag = grand_tourny_1st }
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
	option = {
		name = "EVTOPTC70079" #3rd
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = grand_tourny_3rd
					NOT = { has_character_flag = grand_tourny_1st }
					NOT = { has_character_flag = grand_tourny_2nd }
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
}
#normal tourny medals
character_event = {
	id = 70080
	desc = "EVTDESC70080"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70079" #1st
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = normal_tourny_1st
					OR = { #Regional participants only
						AND = { #All subjects (non empire)
							ROOT = { NOT = { tier = EMPEROR } }
							OR = {
								is_liege_of = ROOT
								is_liege_or_above = ROOT
							}	
						}	
						any_liege = { #Share same king tier liege
							tier = KING
							is_vassal_or_below = ROOT
						}
						AND = { #Reside in the same kingdom
							is_ruler = yes
							capital_scope = {
								kingdom = {
									any_direct_de_jure_vassal_title = {
										any_direct_de_jure_vassal_title = {
											location = {
												is_capital = yes
												owner = { character = ROOT }
											}
										}
									}	
								}
							}	
						}
						AND = {
							is_ruler = no
							liege = {
								capital_scope = {
									kingdom = {
										any_direct_de_jure_vassal_title = {
											any_direct_de_jure_vassal_title = {
												location = {
													is_capital = yes
													owner = { character = ROOT }
												}
											}
										}	
									}
								}
							}
						}	
					}
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
	option = {
		name = "EVTOPTB70079" #2nd
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = normal_tourny_2nd
					NOT = { has_character_flag = normal_tourny_1st }
					OR = { #Regional participants only
						AND = { #All subjects (non empire)
							ROOT = { NOT = { tier = EMPEROR } }
							OR = {
								is_liege_of = ROOT
								is_liege_or_above = ROOT
							}	
						}	
						any_liege = { #Share same king tier liege
							tier = KING
							is_vassal_or_below = ROOT
						}
						AND = { #Reside in the same kingdom
							is_ruler = yes
							capital_scope = {
								kingdom = {
									any_direct_de_jure_vassal_title = {
										any_direct_de_jure_vassal_title = {
											location = {
												is_capital = yes
												owner = { character = ROOT }
											}
										}
									}	
								}
							}	
						}
						AND = {
							is_ruler = no
							liege = {
								capital_scope = {
									kingdom = {
										any_direct_de_jure_vassal_title = {
											any_direct_de_jure_vassal_title = {
												location = {
													is_capital = yes
													owner = { character = ROOT }
												}
											}
										}	
									}
								}
							}
						}	
					}	
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
	option = {
		name = "EVTOPTC70079" #3rd
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = normal_tourny_3rd
					NOT = { has_character_flag = normal_tourny_1st }
					NOT = { has_character_flag = normal_tourny_2nd }
					OR = { #Regional participants only
						AND = { #All subjects (non empire)
							ROOT = { NOT = { tier = EMPEROR } }
							OR = {
								is_liege_of = ROOT
								is_liege_or_above = ROOT
							}	
						}	
						any_liege = { #Share same king tier liege
							tier = KING
							is_vassal_or_below = ROOT
						}
						AND = { #Reside in the same kingdom
							is_ruler = yes
							capital_scope = {
								kingdom = {
									any_direct_de_jure_vassal_title = {
										any_direct_de_jure_vassal_title = {
											location = {
												is_capital = yes
												owner = { character = ROOT }
											}
										}
									}	
								}
							}	
						}
						AND = {
							is_ruler = no
							liege = {
								capital_scope = {
									kingdom = {
										any_direct_de_jure_vassal_title = {
											any_direct_de_jure_vassal_title = {
												location = {
													is_capital = yes
													owner = { character = ROOT }
												}
											}
										}	
									}
								}
							}
						}	
					}	
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
}
#nsmall tourny medals
character_event = {
	id = 70081
	desc = "EVTDESC70081"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70079" #1st
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = small_tourny_1st
					OR = { #Local participants only
						# AND = {
							# ROOT = { tier = COUNT }
							# OR = {
								# is_liege_of = ROOT
								# is_liege_or_above = ROOT
							# }	
						# }	
						AND = {
							is_ruler = yes
							capital_scope = { #Either neighbours or same duchy
								OR = {
									AND = {
										is_capital = yes
										owner = { character = ROOT }
									}
									any_neighbor_province = {
										is_capital = yes
										owner = { character = ROOT }
									}
									duchy = {
										any_direct_de_jure_vassal_title = {
											location = {
												is_capital = yes
												owner = { character = ROOT }
											}
										}
									}
								}	
							}	
						}
						AND = {
							is_ruler = no
							liege = {
								capital_scope = { #Either neighbours or same duchy
									OR = {
										AND = {
											is_capital = yes
											owner = { character = ROOT }
										}
										any_neighbor_province = {
											is_capital = yes
											owner = { character = ROOT }
										}
										duchy = {
											any_direct_de_jure_vassal_title = {
												location = {
													is_capital = yes
													owner = { character = ROOT }
												}
											}
										}
									}	
								}	
							}
						}	
					}	
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
	option = {
		name = "EVTOPTB70079" #2nd
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = small_tourny_2nd
					NOT = { has_character_flag = small_tourny_1st }
					OR = { #Local participants only
						# AND = {
							# ROOT = { tier = COUNT }
							# OR = {
								# is_liege_of = ROOT
								# is_liege_or_above = ROOT
							# }	
						# }	
						AND = {
							is_ruler = yes
							capital_scope = { #Either neighbours or same duchy
								OR = {
									AND = {
										is_capital = yes
										owner = { character = ROOT }
									}
									any_neighbor_province = {
										is_capital = yes
										owner = { character = ROOT }
									}
									duchy = {
										any_direct_de_jure_vassal_title = {
											location = {
												is_capital = yes
												owner = { character = ROOT }
											}
										}
									}
								}	
							}	
						}
						AND = {
							is_ruler = no
							liege = {
								capital_scope = { #Either neighbours or same duchy
									OR = {
										AND = {
											is_capital = yes
											owner = { character = ROOT }
										}
										any_neighbor_province = {
											is_capital = yes
											owner = { character = ROOT }
										}
										duchy = {
											any_direct_de_jure_vassal_title = {
												location = {
													is_capital = yes
													owner = { character = ROOT }
												}
											}
										}
									}	
								}	
							}
						}	
					}	
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
	option = {
		name = "EVTOPTC70079" #3rd
		top_liege = {
			any_realm_character = {
				limit = {
					has_character_flag = small_tourny_3rd
					NOT = { has_character_flag = small_tourny_1st }
					NOT = { has_character_flag = small_tourny_2nd }
					OR = { #Local participants only
						# AND = {
							# ROOT = { tier = COUNT }
							# OR = {
								# is_liege_of = ROOT
								# is_liege_or_above = ROOT
							# }	
						# }	
						AND = {
							is_ruler = yes
							capital_scope = { #Either neighbours or same duchy
								OR = {
									AND = {
										is_capital = yes
										owner = { character = ROOT }
									}
									any_neighbor_province = {
										is_capital = yes
										owner = { character = ROOT }
									}
									duchy = {
										any_direct_de_jure_vassal_title = {
											location = {
												is_capital = yes
												owner = { character = ROOT }
											}
										}
									}
								}	
							}	
						}
						AND = {
							is_ruler = no
							liege = {
								capital_scope = { #Either neighbours or same duchy
									OR = {
										AND = {
											is_capital = yes
											owner = { character = ROOT }
										}
										any_neighbor_province = {
											is_capital = yes
											owner = { character = ROOT }
										}
										duchy = {
											any_direct_de_jure_vassal_title = {
												location = {
													is_capital = yes
													owner = { character = ROOT }
												}
											}
										}
									}	
								}	
							}
						}	
					}	
				}
				tooltip = { show_portrait = yes }
				if = {
					limit = { NOT = { trait = bastard } }
					custom_tooltip = { text = TOOLTIPMEDALWINNER }
				}
				if = {
					limit = { trait = bastard }
					custom_tooltip = { text = TOOLTIPMEDALWINNERbastard }
				}
			}
		}
	}
}



character_event = { #drunkard embarrasses himself
	id = 70082
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70082"
	picture = "GFX_evt_drunk"

	is_triggered_only = yes
	
	trigger = {
		trait = drunkard
		has_character_flag = attending_tournament
		NOT = { has_character_flag = lost_tournament }
		any_opinion_modifier_target = {
			has_character_flag = tournament_begins
			reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
		}	
		OR = {
			NOT = { has_character_flag = in_joust }
			had_character_flag = { flag = in_joust days = 7 }
		}
	}

	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTA70082"
		add_character_modifier = {
			name = drunken_tournament
			duration = 1095
		}
		set_character_flag = lost_tournament
		random_opinion_modifier_target = {
			limit = {
				has_character_flag = tournament_begins
				reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }	
			}	
			character_event = { id = 70083 days = 1 } 
		}	
	}
}
character_event = { #liege decide on drunkard fate
	id = 70083
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESC70083"
	picture = "GFX_evt_drunk"

	is_triggered_only = yes
	
	immediate = {
		hidden_tooltip = {
			any_opinion_modifier_target = { #inform others
				limit = {
					ai = no
					has_character_flag = attending_tournament
					OR = {
						has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
						has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
					}
					NOT = { character = FROM }
				}
				character_event = { id = tourney.787 days = 2 }			
			}
		}
	}
	
	option = {
		name = "EVTOPTA70083" #a good laugh
		ai_chance = {
			factor = 50
			modifier = {
				factor = 4
				trait = drunkard
			}
			modifier = {
				factor = 3
				trait = gregarious
			}
			modifier = {
				factor = 3
				trait = patient
			}
			modifier = {
				factor = 3
				trait = kind
			}
			modifier = {
				factor = 3
				trait = humble
			}
			modifier = {
				factor = 1.5
				opinion = { who = FROM value =  0 }
			}
			modifier = {
				factor = 2
				opinion = { who = FROM value =  40 }
			}
		}
		prestige = -30
		FROM = {
			opinion = { who = ROOT modifier = opinion_happy months = 12 }
			hidden_tooltip =  { 
				character_event = { id = 70084 } 
			}
		}
	}
	option = {
		name = "EVTOPTB70083" #admonish
		ai_chance = {
			factor = 50
			modifier = {
				factor = 3
				trait = honorable
			}
			modifier = {
				factor = 3
				trait = just
			}
			modifier = {
				factor = 3
				trait = temperate
			}
			modifier = {
				factor = 3
				trait = wroth
			}			
			modifier = {
				factor = 3
				trait = proud
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = FROM value = -40 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = -20 } }
			}
		}
		FROM = {
			hidden_tooltip =  { 
				character_event = { id = 70085 } 
			}
		}
	}
	option = {
		name = "EVTOPTC70083" #imprison
		trigger = { 
			is_vassal_or_below = FROM 
			NOR = {
				trait = patient
				trait = kind
			}
		}
		ai_chance = {
			factor = 20

			modifier = {
				factor = 0
				opinion = { who = FROM value = 0 }
				NOT = { trait = lunatic }
				NOT = { trait = cruel }
			}
			modifier = {
				factor = 3
				trait = cruel
			}
			modifier = {
				factor = 3
				trait = ruthless
			}
			modifier = {
				factor = 3
				trait = zealous
			}
			modifier = {
				factor = 3
				trait = wroth
			}
			modifier = {
				factor = 2
				NOT = { opinion = { who = FROM value = -40 } }
			}
			modifier = {
				factor = 1.5
				NOT = { opinion = { who = FROM value = -20 } }
			}
		}
		FROM = {
			tooltip = { imprison = ROOT }
			hidden_tooltip =  { 
				character_event = { id = tourney.786 } 
			}
		}
	}
}
character_event = { #liege laughed
	id = 70084
	desc = "EVTDESC70084"
	picture = "GFX_evt_drunk"

	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70084" #
	}
}

character_event = { #liege admonished you
	id = 70085
	desc = "EVTDESC70085"
	picture = "GFX_evt_drunk"

	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70085" #	
		prestige = -50		
		FROM = {
			opinion = { who = ROOT modifier = despise_drunkard months = 48 }
		}
	}
}

character_event = { #liege imprisoned you
	id = tourney.786
	desc = "EVTDESCtourney.786"
	picture = "GFX_evt_drunk"

	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.786" #	
		imprison = FROM
		prestige = -50		
		FROM = {
			opinion = { who = ROOT modifier = despise_drunkard months = 48 }
		}
	}
}

long_character_event = { #inform other attendees
	id = tourney.787	
	picture = "GFX_evt_drunk"

	is_triggered_only = yes
	show_from_from = yes
	
	desc = {
		text = "EVTDESCtourney.787A" #liege laughed
		trigger = {
			FROMFROM = { 
				prisoner = no 
				NOT = { reverse_has_opinion_modifier = { who = ROOT_FROM modifier = despise_drunkard } }
			}
		}
	}
	desc = {
		text = "EVTDESCtourney.787B" #liege admonished
		trigger = {
			FROMFROM = { 
				prisoner = no 
				reverse_has_opinion_modifier = { who = ROOT_FROM modifier = despise_drunkard }
			}
		}
	}
	desc = {
		text = "EVTDESCtourney.787C" #liege imprisoned
		trigger = {
			FROMFROM = { 
				prisoner = yes
				reverse_has_opinion_modifier = { who = ROOT_FROM modifier = despise_drunkard }
			}
		}
	}
	
	option = {
		name = "EVTOPTAtourney.787"	
		FROM = { show_portrait = yes }
	}
}
# uneligible lords Invited to spectate
letter_event = {
	id = 70086
	title = "TOURNAMENTTITLE2"
	picture = "GFX_evt_courier"

	is_triggered_only = yes
	
	desc = {
		text = EVTDESC70086A
		trigger = {
			FROM = { has_character_flag = small_tourny }
		}
	}
	desc = {
		text = EVTDESC70086B
		trigger = {
			FROM = { has_character_flag = normal_tourny }
		}
	}
	desc = {
		text = EVTDESC70086C
		trigger = {
			FROM = { 
				OR = {
					has_character_flag = grand_tourny 
					has_character_flag = king_tourny
				}	
			}
		}
	}
	
	trigger = {
		NOT = { has_character_flag = tourny_in_progress }
		NOT = { has_character_flag = attending_tournament }
		NOT = {
			AND = {
				FROM = { has_character_flag = small_tourny } 
				has_character_flag = no_small_tournies
			}
		}
		NOT = {
			AND = {
				FROM = { has_character_flag = normal_tourny } 
				has_character_flag = no_regional_tournies
			}
		}
		NOT = { has_character_flag = no_tournies_ever }
		OR = {
			is_ruler = no
			is_feudal = yes
			is_patrician = yes
			is_tribal = yes
		}	
		NOT = { trait = incapable }
		NOT = { trait = maester }
		NOT = { trait = archmaester }
		NOT = { trait = nightswatch }		
		prisoner = no
		war = no
		NOT = { is_inaccessible_trigger = yes }
	}
	
	immediate = {
		clr_character_flag = king_tourny
		clr_character_flag = grand_tourny
		clr_character_flag = normal_tourny
		clr_character_flag = small_tourny
		
		if = {
			limit = { #find title for loc
				ai = no
				FROM = { has_character_flag = normal_tourny }
			}
			FROM = { capital_scope = { kingdom = { save_event_target_as = tourney_kingdom } } }
		}
	}

	option = {
		name = "EVTOPTA70086"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.2
				OR = {
					has_character_flag = small_tourny_1st
					has_character_flag = small_tourny_2nd
					has_character_flag = small_tourny_3rd
				}	
			}
			modifier = {
				factor = 1.4
				OR = {
					has_character_flag = grand_tourny_3rd
					has_character_flag = normal_tourny_2nd
					has_character_flag = normal_tourny_3rd
				}	
			}
			modifier = {
				factor = 2
				OR = {
					has_character_flag = grand_tourny_1st
					has_character_flag = grand_tourny_2nd
					has_character_flag = normal_tourny_1st
				}	
			}
			modifier = {
				factor = 1.2
				trait = knight
			}
			modifier = {
				factor = 1.2
				trait = diligent
			}
			modifier = {
				factor = 1.2
				trait = wroth
			}
			modifier = {
				factor = 1.4
				trait = proud
			}
			modifier = {
				factor = 1.4
				trait = gregarious
			}
			modifier = {
				factor = 1.4
				trait = ambitious
			}
			modifier = {
				factor = 1.4
				opinion = { who = FROM value =  20 }
			}
			modifier = {
				factor = 1.4
				opinion = { who = FROM value =  40 }
			}
			modifier = {
				factor = 1.4
				opinion = { who = FROM value =  60 }
			}
			modifier = {
				factor = 1.4
				opinion = { who = FROM value =  80 }
			}
		}		
		set_character_flag = attending_tournament
		set_character_flag = tournament_spectator
		hidden_tooltip = {
			opinion = {
				modifier = opinion_spectating_tournament
				who = FROM
				years = 100
			}
			reverse_opinion = {
				modifier = opinion_spectating_tournament
				who = FROM
				years = 100
			}
		}	
	}
	option = {
		name = {
			text = "EVTOPTB70086" #No
			trigger = {
				OR = {
					lower_tier_than = FROM
					FROM = { NOT = { has_character_flag = small_tourny }	}
				}
			}
		}	
		name = {
			text = "EVTOPTC70000" #This is below me
			trigger = {
				NOT = { lower_tier_than = FROM }
				FROM = { has_character_flag = small_tourny }
			}
		}
		ai_chance = {
			factor = 25
			
			modifier = { #This is below me
				factor = 3
				NOT = { lower_tier_than = FROM }
				FROM = { has_character_flag = small_tourny }
			}
			modifier = {
				factor = 1.2
				NOT = { trait = knight }
			}
			modifier = {
				factor = 1.2
				trait = slothful
			}
			modifier = {
				factor = 1.4
				trait = shy
			}
			modifier = {
				factor = 1.2
				trait = content
			}
			modifier = {
				factor = 1.4
				NOT = { opinion = { who = FROM value =  -20 } }
			}
			modifier = {
				factor = 1.4
				NOT = { opinion = { who = FROM value =  -40 } }
			}
			modifier = {
				factor = 1.4
				NOT = { opinion = { who = FROM value =  -60 } }
			}
			modifier = {
				factor = 1.4
				NOT = { opinion = { who = FROM value =  -80 } }
			}
			modifier = {
				factor = 2
				is_ill = yes
			}
		}
		if = { 
			limit = { FROM = { has_character_flag = king_tourny } }
			prestige = -50
		}	
		if = { 
			limit = { FROM = { has_character_flag = grand_tourny} }
			prestige = -30
		}
		if = { 
			limit = { FROM = { has_character_flag = normal_tourny } }
			prestige = -20
		}
		if = { 
			limit = { FROM = { has_character_flag = small_tourny } }
			prestige = -10
		}	
	}
	option = {
		name = "EVTOPTE70000"
		ai_chance = { factor = 0 }
		trigger = { FROM = { has_character_flag = small_tourny } } 
		set_character_flag = no_small_tournies
		prestige = -10
	}
	option = {
		name = "EVTOPTF70000"
		ai_chance = { factor = 0 }
		trigger = { FROM = { has_character_flag = normal_tourny } } 
		set_character_flag = no_regional_tournies
		prestige = -20
	}
	option = {
		name = "EVTOPTD70000"
		ai_chance = { factor = 0 }
		set_character_flag = no_tournies_ever
		if = { 
			limit = { FROM = { has_character_flag = king_tourny } }
			prestige = -50
		}	
		if = { 
			limit = { FROM = { has_character_flag = grand_tourny} }
			prestige = -30
		}
		if = { 
			limit = { FROM = { has_character_flag = normal_tourny } }
			prestige = -20
		}
		if = { 
			limit = { FROM = { has_character_flag = small_tourny } }
			prestige = -10
		}	
	}
}	
###more information for participants
# Message about death
character_event = {
	id = 70038
	title = "TOURNAMENTTITLE3"
	desc = "EVTDESC70038"
	picture = "GFX_evt_death"
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { has_character_flag = no_msg_death }
	}
	
	option = {
		name = "EVTOPTA70038"
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_death
	}
}
# Inform participant about death
character_event = {
	id = 70089
	title = "TOURNAMENTTITLE2"
	desc = "EVTDESC70038"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { has_character_flag = no_msg_death }
	}
	
	option = {
		name = "EVTOPTA70089"
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_death
	}
}
# Message about maimed
character_event = {
	id = 70039
	title = "TOURNAMENTTITLE3"
	desc = "EVTDESC70039"
	picture = "GFX_evt_emissary"
	
	is_triggered_only = yes

	trigger = {
		NOT = { has_character_flag = no_msg_maimed }
	}
	
	option = {
		name = "EVTOPTA70038"
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_maimed
	}
}
# Inform participant about maimed
character_event = {
	id = 70090
	title = "TOURNAMENTTITLE2"
	desc = "EVTDESC70039"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { has_character_flag = no_msg_maimed }
	}
	
	option = {
		name = "EVTOPTA70089"
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_maimed
	}
}

# Inform spectator tourney finished
character_event = {
	id = 70092
	title = "TOURNAMENTTITLE2"
	desc = "EVTDESC70092"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA70092"
	}
}
# # Inform spectator of relative's great outcome
# character_event = {
	# id = 70095
	# title = "TOURNAMENTTITLE4"
	# desc = "EVTDESC70095"
	# picture = "GFX_evt_joust"
	
	# is_triggered_only = yes
	
	# option = {
		# name = "EVTOPTC70095"
		# FROM = {
			# FROM = {
				# tooltip = { show_portrait = yes }
			# }
		# }
		# if = { 
			# limit = { FROMFROM = { has_character_flag = king_tourny } }
			# prestige = 15
		# }	
		# if = { 
			# limit = { FROMFROM = { has_character_flag = grand_tourny } }
			# prestige = 8
		# }
		# if = { 
			# limit = { FROMFROM = { has_character_flag = normal_tourny } }
			# prestige = 4
		# }
		# if = { 
			# limit = { FROMFROM = { has_character_flag = small_tourny } }
			# prestige = 2
		# }	
	# }
# }
# Inform spectator of relative's win in later round
character_event = {
	id = 70096
	title = "TOURNAMENTTITLE4"
	desc = "EVTDESC70096"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTC70096"
		FROM = {
			FROM = {
				tooltip = { show_portrait = yes }
			}
		}
		prestige = 5
	}
}
# Inform spectator of relative's kncoked out in early round
character_event = {
	id = 70097
	desc = "EVTDESC70097"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTC70097"
		prestige = -15	
	}
}
# Inform spectator of relative's knocked out in later round
character_event = {
	id = 70098
	desc = "EVTDESC70098"
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTC70098"
		FROM = {
			tooltip = { show_portrait = yes }
		}
		prestige = -10	
	}
}
###Bribery
character_event = {
	id = tourney.40
	desc = "EVTDESCtourney.40"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.40" #YES
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = content
			}
			modifier = {
				factor = 2
				trait = humble
			}
			modifier = {
				factor = 2
				is_ruler = no
			}
			modifier = {
				factor = 2
				NOT = { wealth = 0 }
			}
		}
		set_character_flag = bribed_to_lose
		wealth = 25	
		FROM = { character_event = { id = tourney.41 tooltip = TOOLTIPtourney.41 } }
	}
	option = {
		name = "EVTOPTBtourney.40" #NO
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = zealous
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 2
				higher_tier_than = FROM
			}
			modifier = {
				factor = 4
				is_rival = FROM
			}
		}
		FROM = { character_event = { id = tourney.42 tooltip = TOOLTIPtourney.42 } }
	}
}
character_event = { #INFORM BRIBE SUCCESSFUL
	id = tourney.41
	desc = "EVTDESCtourney.41"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.41" #OK
		wealth = -25	
		custom_tooltip = { text = TOOLTIPtourney.14 }
		hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 1 } } } }
	}
}
character_event = { #INFORM BRIBE NOT SUCCESSFUL
	id = tourney.42
	desc = "EVTDESCtourney.42"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.42" #OK
		custom_tooltip = { text = TOOLTIPtourney.14 }
		hidden_tooltip = { c_the_citadel = { holder_scope = { character_event = { id = tourney.15 days = 1 } } } }
	}
}
#UNHORSED (BRIBED)
#Inform round loser
character_event = {
	id = tourney.43
	desc = "EVTDESCtourney.43" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
	}
		
	option = {
		name = "EVTOPTAtourney.43" 
		if = {
			limit = { FROM = { NOT = { has_character_flag = informed_winner_first } } }
			hidden_tooltip = { FROM = { character_event = { id = tourney.44 } } }
		}
		if = {
			limit = { FROM = { has_character_flag = informed_winner_first } }
			FROM = {
				clr_character_flag = informed_winner_first 
				hidden_tooltip = { character_event = { id = tourney.30 days = 1 } }
			}
		}		
	}
}	
#Inform round winner
character_event = {
	id = tourney.44
	desc = "EVTDESCtourney.44" 
	picture = "GFX_evt_joust"
	
	is_triggered_only = yes
	
	immediate = {
		clr_character_flag = lost_round
		set_character_flag = won_match_up
	}
	
	option = {
		name = "EVTOPTAtourney.44" 
		if = {
			limit = { NOT = { has_character_flag = informed_winner_first } }
			hidden_tooltip = { character_event = { id = tourney.30 days = 1 } }
		}	
		if = {
			limit = { has_character_flag = informed_winner_first }
			hidden_tooltip = { FROM = { character_event = { id = tourney.43 } } }
		}				
	}
}
# Young lad helps with armour and horse
character_event = {
	id = tourney.45
	#title = "TOURNAMENTTITLE"
	desc = "EVTDESCtourney.45"
	picture = "GFX_evt_guardian"

	is_triggered_only = yes
	
	trigger = {
		trait = knight	
	}

	immediate = {
		set_character_flag = attending_tournament_event
		random_opinion_modifier_target = {
			limit = {
				is_ruler = yes
				OR = {
					has_character_flag = melee_begins
					has_character_flag = tournament_begins
				}	
				OR = {			
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				}
			}	
			capital_scope = {
				ROOT = {
					create_character = {
						age = 12
						dynasty = none
						female = no
						culture = PREV
						religion = PREV
						trait = diligent
						attributes = {
							martial = 3
							diplomacy = 2
							intrigue = 3
							stewardship = 1
							learning = 1
						}
					}
					new_character = {
						save_event_target_as = tourney_squire_lad						
						remove_trait = slothful
						add_trait = poor_warrior
						random_list = {
							20 = { add_trait = gregarious }
							20 = { add_trait = ambitious }
							20 = { add_trait = brave }
						}
						random_list = {
							20 = { add_trait = kind }
							20 = { add_trait = honorable }
							20 = { add_trait = proud }
						}
						if = {
							limit = { NOT = { trait = genius } }
							random = {
								chance = 3
								add_trait = quick
							}
						}	
						remove_trait = imbecile
						remove_trait = inbred
						remove_trait = slow
						remove_trait = infirm
						remove_trait = incapable
						remove_trait = leper
						remove_trait = possessed
						remove_trait = ill
						remove_trait = pneumonic
						remove_trait = maimed
					}
				}	
			}
		}
	}
	
	option = {
		name = "EVTOPTAtourney.45" #Yes
		ai_chance = {
			factor = 50
			modifier = {
				factor = 3
				trait = gregarious
			}
			modifier = {
				factor = 3
				trait = kind
			}
			modifier = {
				factor = 3
				trait = humble
			}
			modifier = {
				factor = 3
				trait = patient
			}
		}
		event_target:tourney_squire_lad = {
			add_trait = squire
			set_guardian = ROOT
			opinion = {
				modifier = opinion_happy_with_guardian
				who = ROOT
				years = 5
				multiplier = 2
			}
		}
	}
	option = {
		name = "EVTOPTBtourney.45" #No
		ai_chance = {
			factor = 50
			modifier = {
				factor = 3
				trait = shy
			}
			modifier = {
				factor = 3
				trait = cruel
			}
			modifier = {
				factor = 3
				trait = proud
			}
			modifier = {
				factor = 3
				trait = wroth
			}
		}
		hidden_tooltip = {
			event_target:tourney_squire_lad = {
				death = {
					death_reason = death_missing
				}
			}
		}
	}
}
# Hungover squire
character_event = {
	id = tourney.46
	desc = "EVTDESCtourney.46"
	picture = "GFX_evt_drunk"

	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.46" 
		FROM = { character_event = { id = tourney.47 tooltip = TOOLTIPtourney.47 } }
	}
}
character_event = {
	id = tourney.47
	desc = "EVTDESCtourney.47"
	picture = "GFX_evt_drunk"

	is_triggered_only = yes

	option = {
		name = "EVTOPTAtourney.47" #Oh well
		ai_chance = {
			factor = 50
			modifier = {
				factor = 3
				trait = lustful
			}
			modifier = {
				factor = 3
				trait = hedonist
			}
			modifier = {
				factor = 2
				trait = gluttonous
			}
			modifier = {
				factor = 2
				trait = gregarious
			}
			modifier = {
				factor = 1.5
				trait = kind
			}
			modifier = {
				factor = 1.5
				trait = patient
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
		}
		FROM = {
			opinion = {
				who = ROOT
				modifier = opinion_happy_with_guardian
				years = 5
			}
			if = {
				limit = { 
					NOT = { personality_traits = 5 } 
					NOT = { trait = lustful }
					NOT = { trait = chaste }
				}
				random  = {
					chance = 20
					add_trait = lustful
					hidden_tooltip = {
						ROOT = {
							character_event = {
								id = 38172
							}
						}
						character_event = {
							id = 38272
						} 
					}
				}
			}
		}
	}
	
	option = {
		name = "EVTOPTBtourney.47" #Chastise him
		ai_chance = {
			factor = 50
			modifier = {
				factor = 3
				trait = chaste
			}
			modifier = {
				factor = 2
				trait = temperate
			}
			modifier = {
				factor = 2
				trait = honorable
			}
			modifier = {
				factor = 2
				trait = just
			}
			modifier = {
				factor = 2
				trait = diligent
			}
		}
		FROM = {
			prestige = -20
			if = {
				limit = { 
					NOT = { personality_traits = 5 } 
					NOT = { trait = temperate }
					NOT = { trait = gluttonous }
				}
				random  = {
					chance = 33
					add_trait = temperate
					hidden_tooltip = {
						ROOT = {
							character_event = {
								id = 38176
							}
						}
						character_event = {
							id = 38276
						} 
					}
				}
			}
		}
	}
	
	option = {
		name = "EVTOPTCtourney.47" #Beat him
		trigger = {
			NOT = { trait = kind}
		}
		ai_chance = {
			factor = 20
			modifier = {
				factor = 3.5
				trait = lunatic
			}
			modifier = {
				factor = 3.5
				trait = cruel
			}
			modifier = {
				factor = 3.5
				trait = wroth
			}
			modifier = {
				factor = 2.5
				trait = proud
			}
		}
		FROM = {
			opinion = {
				who = ROOT
				modifier = opinion_sad
				years = 5
			}
			if = {
				limit = { 
					NOT = { personality_traits = 5 } 
					NOT = { trait = wroth }
					NOT = { trait = patient }
				}
				random  = {
					chance = 20
					add_trait = wroth
					hidden_tooltip = {
						ROOT = {
							character_event = {
								id = 38154
							}
						}
						character_event = {
							id = 38254
						} 
					}
				}
			}
		}
	}
}
# Training with squire
character_event = {
	id = tourney.48
	desc = "EVTDESCtourney.48"
	picture = "GFX_evt_melee"

	is_triggered_only = yes

	immediate = {
		set_character_flag = attending_tournament_event
	}
	
	option = {
		name = "EVTOPTAtourney.48" #Yes
		random_ward = {
			limit = {
				age = 6
				trait = squire
				NOT = { trait = master_warrior }
				NOT = { trait = skilled_warrior }
				is_female = no
			}
			tooltip = {
				if = {
					limit = { trait = trained_warrior }
					random = {
						chance = 15
						add_trait = skilled_warrior
						hidden_tooltip = { remove_trait = trained_warrior }
					}
				}	
				if = {
					limit = { trait = poor_warrior }
					random = {
						chance = 30
						add_trait = trained_warrior
						hidden_tooltip = { remove_trait = poor_warrior }
					}
				}
				if = {
					limit = { 
						NOT = { trait = skilled_warrior }
						NOT = { trait = trained_warrior }
						NOT = { trait = poor_warrior }					
					}
					random = {
						chance = 50
						add_trait = poor_warrior
					}
				}
			}	
			opinion = {
				who = ROOT
				modifier = opinion_happy_with_guardian
				years = 5
			}
			hidden_tooltip = { character_event = { id = tourney.49 } }
		}
	}
}
character_event = {
	id = tourney.49
	desc = "EVTDESCtourney.49"
	picture = "GFX_evt_melee"

	is_triggered_only = yes

	option = {
		name = "EVTOPTAtourney.49" 
		if = {
			limit = { trait = trained_warrior }
			random = {
				chance = 15
				add_trait = skilled_warrior
				hidden_tooltip = { remove_trait = trained_warrior }
			}
		}	
		if = {
			limit = { trait = poor_warrior }
			random = {
				chance = 30
				add_trait = trained_warrior
				hidden_tooltip = { remove_trait = poor_warrior }
			}
		}
		if = {
			limit = { 
				NOT = { trait = skilled_warrior }
				NOT = { trait = trained_warrior }
				NOT = { trait = poor_warrior }					
			}
			random = {
				chance = 50
				add_trait = poor_warrior
			}
		}
	}
}		
#Place tourney bet
character_event = {
	id = tourney.55	
	picture = GFX_evt_relaxed_ruler

	is_triggered_only = yes
	
	desc = {
		text = "EVTDESCtourney.55"
		trigger = { NOT = { is_variable_equal = { which = tourney_bet_odds value = 1 } } }
	}
	desc = {
		text = "EVTDESCtourney.55B"
		trigger = { is_variable_equal = { which = tourney_bet_odds value = 1 } } #evens
	}
	
	immediate = {
		##calculate odds##
		
		#find host
		random_opinion_modifier_target = {
			limit = {
				is_ruler = yes
				has_character_flag = tourney_final_round
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_attending_tournament }
				OR = {
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_spectating_tournament }
				}
			}	
			save_event_target_as = tourney_host
		}
		if = {
			limit = {
				is_ruler = yes
				has_character_flag = tourney_final_round
				reverse_has_opinion_modifier = { who = FROM modifier = opinion_attending_tournament }
			}	
			save_event_target_as = tourney_host
		}
		
		#count number of remaining competitors
		set_variable = { which = remaining_competitors value = 0 }
		event_target:tourney_host = {
			any_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					NOT = { has_character_flag = lost_tournament }
					has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
				}
				ROOT = { change_variable = { which = remaining_competitors value = 1 } }
			}
		}
		
		#calculate base odds
		#tourney_bet_odds_temp = (remaining_competitors-1)-(remaining_competitors/10)
		#(remaining_competitors/10) = variable_B     #this skews odds in favour of the bookmaker
		#e.g. 10 remaining competitors, default odds 8-1
		set_variable = { which = variable_B which = remaining_competitors }
		divide_variable = { which = variable_B value = 10 }
		
		set_variable = { which = tourney_bet_odds_temp which = remaining_competitors }		
		subtract_variable = { which = tourney_bet_odds_temp value = 1 }	
		subtract_variable = { which = tourney_bet_odds_temp which = variable_B }
	
		#for each competitor that they are better than decrease odds
		#for each competitor that they are worse than increase odds
		#scaled based on combat difference
		
		#factors depend on remaining competitors
		#tourney_bet_odds_pos_factor = 1*(remaining_competitors/(remaining_competitors-0.7))
		#(remaining_competitors-0.7) = variable_C
		set_variable = { which = variable_C which = remaining_competitors }
		subtract_variable = { which = variable_C value = 0.7 }
		
		set_variable = { which = tourney_bet_odds_pos_factor which = remaining_competitors }	
		divide_variable = { which = tourney_bet_odds_pos_factor which = variable_C }
		multiply_variable = { which = tourney_bet_odds_pos_factor value = 1 }
		
		#tourney_bet_odds_neg_factor = 1/tourney_bet_odds_pos_factor
		set_variable = { which = tourney_bet_odds_neg_factor value = 1 }
		divide_variable = { which = tourney_bet_odds_neg_factor which = tourney_bet_odds_pos_factor }
		
		#apply the combat factors to the odds
		event_target:tourney_host = {	
			any_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					NOT = { has_character_flag = lost_tournament }
					has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
					NOT = { character = ROOT_FROM }
				}
				if = {
					limit = { combat_rating_diff = { who = ROOT_FROM value = 2.5 } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_pos_factor } }
				}
				if = {
					limit = { combat_rating_diff = { who = ROOT_FROM value = 4 } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_pos_factor } }
				}
				if = {
					limit = { combat_rating_diff = { who = ROOT_FROM value = 5 } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_pos_factor } }
				}
				if = {
					limit = { combat_rating_diff = { who = ROOT_FROM value = 6 } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_pos_factor } }
				}
				if = {
					limit = { ROOT_FROM = { combat_rating_diff = { who = PREV value = 2.5 } } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_neg_factor } }
				}
				if = {
					limit = { ROOT_FROM = { combat_rating_diff = { who = PREV value = 4 } } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_neg_factor } }
				}
				if = {
					limit = { ROOT_FROM = { combat_rating_diff = { who = PREV value = 5 } } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_neg_factor } }
				}
				if = {
					limit = { ROOT_FROM = { combat_rating_diff = { who = PREV value = 6 } } }
					ROOT = { multiply_variable = { which = tourney_bet_odds_temp which = tourney_bet_odds_neg_factor } }
				}
			}
		}
		
		#round the odds and find denominator
		set_variable = { which = tourney_bet_odds value = 0 }
		if = { #odds>10, round to nearest integer
			limit = { check_variable = { which = tourney_bet_odds_temp value = 9.99 } }
			set_variable = { which = denominator value = 1 }
			while = {
				limit = { check_variable = { which = tourney_bet_odds_temp value = 0.5 } }
				change_variable = { which = tourney_bet_odds_temp value = -1 }
				change_variable = { which = tourney_bet_odds value = 1 }
			}
			set_variable = { which = tourney_bet_odds_displayed which = tourney_bet_odds } #combined with denominator variable to display odds to player in a nice way
			break = yes
		}
		if = { #10>odds>2, round to nearest 0.5
			limit = { check_variable = { which = tourney_bet_odds_temp value = 1.99 } }
			set_variable = { which = denominator value = 1 }
			while = {
				limit = { check_variable = { which = tourney_bet_odds_temp value = 0.25 } }
				change_variable = { which = tourney_bet_odds_temp value = -0.5 }
				change_variable = { which = tourney_bet_odds value = 0.5 }
				multiply_variable = { which = denominator value = -1 } #this determines whether odds are an integer
			}
			set_variable = { which = tourney_bet_odds_displayed which = tourney_bet_odds } #combined with denominator variable to display odds to player in a nice way			
			if = { #odds are an integer
				limit = { check_variable = { which = denominator value = 0 } }
				set_variable = { which = denominator value = 1 }
			}
			if = { #odds are not an integer
				limit = { NOT = { check_variable = { which = denominator value = 0 } } }
				set_variable = { which = denominator value = 2 }
				multiply_variable = { which = tourney_bet_odds_displayed value = 2 }
			}
			break = yes
		}
		if = { #2>odds>1, round to nearest 0.2
			limit = { check_variable = { which = tourney_bet_odds_temp value = 0.99 } }
			set_variable = { which = denominator value = 10 }
			while = {
				limit = { check_variable = { which = tourney_bet_odds_temp value = 0.1 } }
				change_variable = { which = tourney_bet_odds_temp value = -0.2 }
				change_variable = { which = tourney_bet_odds value = 0.2 }
			}
			set_variable = { which = tourney_bet_odds_displayed which = tourney_bet_odds } #combined with denominator variable to display odds to player in a nice way
			multiply_variable = { which = tourney_bet_odds_displayed value = 10 }
			break = yes
		}
		#1>odds, round to nearest 0.1
		set_variable = { which = denominator value = 10 }
		if = { #min 0.1
			limit = { NOT = { check_variable = { which = tourney_bet_odds_temp value = 0.05 } } }
			set_variable = { which = tourney_bet_odds value = 0.1 }
		}
		while = {
			limit = { check_variable = { which = tourney_bet_odds_temp value = 0.05 } }
			change_variable = { which = tourney_bet_odds_temp value = -0.1 }
			change_variable = { which = tourney_bet_odds value = 0.1 }
		}		
		set_variable = { which = tourney_bet_odds_displayed which = tourney_bet_odds } #combined with denominator variable to display odds to player in a nice way
		multiply_variable = { which = tourney_bet_odds_displayed value = 10 }
	}

	option = {
		name = "EVTOPTAtourney.55" #small
		wealth = -5
		set_character_flag = placed_tourney_bet_5		
	}
	option = {
		name = "EVTOPTBtourney.55" #medium
		wealth = -20
		set_character_flag = placed_tourney_bet_20
	}
	option = {
		name = "EVTOPTCtourney.55" #large
		wealth = -40
		set_character_flag = placed_tourney_bet_40	
	}
	option = {
		name = "EVTOPTDtourney.55" 
		clr_character_flag = placed_tourney_bet
		clr_character_flag = placed_tourney_bet_self
		hidden_tooltip = { 
			set_variable = { which = tourney_bet_odds value = 0 }
			remove_opinion = { who = FROM modifier = opinion_tourney_bet_target } 
		}
	}
	after = {
		hidden_tooltip = {
			set_variable = { which = variable_B value = 0 }
			set_variable = { which = variable_C value = 0 }
			set_variable = { which = remaining_competitors value = 0 }		
			set_variable = { which = tourney_bet_odds_temp value = 0 }
			set_variable = { which = tourney_bet_odds_displayed value = 0 }
			set_variable = { which = tourney_bet_odds_pos_factor value = 0 }
			set_variable = { which = tourney_bet_odds_neg_factor value = 0 }
			set_variable = { which = denominator value = 0 }
		}
	}
}	
#Won bet
character_event = {
	id = tourney.56
	desc = "EVTDESCtourney.56"
	picture = GFX_evt_relaxed_ruler

	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = { has_character_flag = placed_tourney_bet_5 }
			set_variable = { which = tourney_bet_winnings value = 5 }
		}
		if = {
			limit = { has_character_flag = placed_tourney_bet_20 }
			set_variable = { which = tourney_bet_winnings value = 20 }
		}
		if = {
			limit = { has_character_flag = placed_tourney_bet_40 }
			set_variable = { which = tourney_bet_winnings value = 40 }
		}
		set_variable = { which = tourney_bet_profit which = tourney_bet_winnings }
		multiply_variable = { which = tourney_bet_profit which = tourney_bet_odds }	
		change_variable = { which = tourney_bet_winnings which = tourney_bet_profit }
	}
	
	option = {
		name = "EVTOPTAtourney.56" 
		custom_tooltip = {
			text = TOOLTIPtourney_bet_winnings
		}
		hidden_tooltip = {
			while = {
				limit = { check_variable = { which = tourney_bet_winnings value = 1 } }
				wealth = 1
				change_variable = { which = tourney_bet_winnings value = -1 }
			}
			clr_character_flag = placed_tourney_bet
			clr_character_flag = placed_tourney_bet_self
			clr_character_flag = placed_tourney_bet_5
			clr_character_flag = placed_tourney_bet_20
			clr_character_flag = placed_tourney_bet_40
			set_variable = { which = tourney_bet_winnings value = 0 }
			set_variable = { which = tourney_bet_profit value = 0 }
			set_variable = { which = tourney_bet_odds value = 0 }
			remove_opinion = { who = FROM modifier = opinion_tourney_bet_target }		
		}
	}
}	
#Defeated jouster is offered a drink by the victor
character_event = {
	id = tourney.60
	desc = "EVTDESCtourney.60"
	picture = GFX_evt_feast

	is_triggered_only = yes

	option = {
		name = "EVTOPTAtourney.60" #OK!
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				lower_tier_than = FROM
			}
			modifier = {
				factor = 3
				opinion = { who = FROM value = 30 }
			}
			modifier = {
				factor = 3
				trait = drunkard
			}
			modifier = {
				factor = 3
				trait = humble
			}
			modifier = {
				factor = 3
				trait = kind
			}
			modifier = {
				factor = 3
				trait = patient
			}
			modifier = {
				factor = 3
				trait = honorable
			}
			modifier = {
				factor = 3
				trait = gregarious
			}
		}
		tooltip = { add_friend = FROM }
		prestige = -25
		hidden_tooltip = { character_event = { id = tourney.61 } }
	}
	option = {
		name = "EVTOPTBtourney.60" #No!
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				trait = proud
				NOT = { dynasty = 0 }
				FROM = { dynasty = 0 }
			}
			modifier = {
				factor = 0
				trait = proud
				OR = {
					higher_tier_than = BARON
					father_even_if_dead = { higher_tier_than = BARON }
				}
				FROM = {
					NOR = {
						higher_tier_than = BARON
						father_even_if_dead = { higher_tier_than = BARON }
						prestige = 500
					}
				}			
			}
			modifier = {
				factor = 3
				trait = proud
			}
			modifier = {
				factor = 3
				trait = cruel
			}
			modifier = {
				factor = 3
				trait = wroth
			}
			modifier = {
				factor = 3
				trait = ruthless
			}
			modifier = {
				factor = 3
				trait = shy
			}
			modifier = {
				factor = 3
				trait = temperate
			}
		}
		FROM = {
			opinion = { who = ROOT modifier = opinion_offended months = 12 }
			hidden_tooltip = { character_event = { id = tourney.62 } }
		}
	}
}	
character_event = { #drink accepted
	id = tourney.61
	desc = "EVTDESCtourney.61"
	picture = GFX_evt_feast

	is_triggered_only = yes

	option = {
		name = "EVTOPTAtourney.61"
		add_friend = FROM
	}
}	
character_event = { #drink rejected
	id = tourney.62
	desc = "EVTDESCtourney.62"
	picture = GFX_evt_quarrel

	is_triggered_only = yes

	option = {
		name = "EVTOPTAtourney.62"
		prestige = -25
	}
}	
#Propsperity for capital
character_event = {
	id = tourney.70
	desc = "EVTDESCtourney.70"
	picture = GFX_evt_market

	is_triggered_only = yes

	option = {
		name = "EVTOPTAtourney.70" #OK!
		if = {
			limit = {
				has_dlc = "Reapers"
			}
			custom_tooltip = {
				text = capital_prospers_custom_tooltip
				hidden_tooltip = {
					capital_scope = {
						change_variable = { which = prosperity_value value = 25 }
					}
				}
			}
		}
		if = {
			limit = {
				NOT = { has_dlc = "Reapers" }
			}
			capital_scope = {
				add_province_modifier = {
					name = tourney_prosperity
					duration = 1825
				}
			}
		}
	}
}	
###Squire Bribery
character_event = {
	id = tourney.75
	desc = "EVTDESCtourney.75"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.75" #YES
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				NOT = { reverse_opinion = { who = FROMFROM value = -40 } }
			}
			modifier = {
				factor = 2
				NOT = { reverse_opinion = { who = FROMFROM value = -70 } }
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 2
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = content
			}
			modifier = {
				factor = 2
				trait = humble
			}
			modifier = {
				factor = 2
				is_ruler = no
			}
			modifier = {
				factor = 2
				NOT = { wealth = 0 }
			}
		}
		FROMFROM = { set_character_flag = squire_bribed }
		wealth = 25	
		FROM = { 
			opinion = { who = ROOT modifier = opinion_squire_bribed months = 3 }
			character_event = { id = tourney.76 tooltip = TOOLTIPtourney.76 } 
		}
	}
	option = {
		name = "EVTOPTBtourney.75" #NO
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = zealous
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 2
				higher_tier_than = FROM
			}
			modifier = {
				factor = 4
				is_rival = FROM
			}
		}
		FROM = { character_event = { id = tourney.77 tooltip = TOOLTIPtourney.77 } }
	}
}
character_event = { #INFORM BRIBE SUCCESSFUL
	id = tourney.76
	desc = "EVTDESCtourney.76"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.76" #OK
		wealth = -25	
		custom_tooltip = { text = TOOLTIPtourney.77 }
	}
}
character_event = { #INFORM BRIBE NOT SUCCESSFUL
	id = tourney.77
	desc = "EVTDESCtourney.77"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.77" #OK	
	}
}
character_event = { #Loser discovers bribery
	id = tourney.78
	desc = "EVTDESCtourney.78"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	show_from_from = yes
	
	trigger = {
		any_ward = { reverse_has_opinion_modifier = { who = FROMFROM modifier = opinion_squire_bribed } }
		FROMFROM = { NOT = { has_character_flag = tourney_medalist } } #too complicated to correct placing for now
	}
	
	immediate = {
		random_ward = {
			limit = { reverse_has_opinion_modifier = { who = FROMFROM modifier = opinion_squire_bribed } }
			save_event_target_as = bribed_squire
		}
	}
	
	option = {
		name = "EVTOPTAtourney.78" #confront him
		FROMFROM = {
			tooltip = {
				if = {
					limit = { 
						is_rival = ROOT
					}
					opinion = { who = ROOT modifier = opinion_hatred months = 12 }
				}
				if = {
					limit = { 
						NOT = { is_rival = ROOT } 
						NOT = { is_friend = ROOT } 
					}
					add_rival = ROOT
				}
				if = {
					limit = { is_friend = ROOT }
					remove_friend = ROOT
				}
			}
			character_event = { id = tourney.79 tooltip = TOOLTIPtourney.79 }
		}
		event_target:bribed_squire = { 
			show_portrait = yes 
			hidden_tooltip = { character_event = { id = tourney.80 } }
		}
	}
	option = {
		name = "EVTOPTBtourney.78" #complain to tourney host
		random_opinion_modifier_target = {
			limit = {
				has_character_flag = tourney_final_round
				reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			character_event = { id = tourney.81 tooltip = TOOLTIPtourney.81 }
		}	
	}
}
character_event = { #inform briber discovered and confronted
	id = tourney.79
	desc = "EVTDESCtourney.79"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.79"
		if = {
			limit = { 
				is_rival = FROM 
			}
			FROM = { opinion = { who = ROOT modifier = opinion_hatred months = 12 } }
			hidden_tooltip = { opinion = { who = FROM modifier = opinion_hatred months = 12 } }
		}
		if = {
			limit = { 
				NOT = { is_rival = FROM } 
				NOT = { is_friend = FROM } 
			}
			add_rival = FROM
		}
		if = {
			limit = { is_friend = FROM }
			remove_friend = FROM
		}
		event_target:bribed_squire = { 
			show_portrait = yes 
		}
	}
}
character_event = { #inform squire discovered and confronted
	id = tourney.80
	desc = "EVTDESCtourney.80"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.80"
		FROMFROMFROM = { show_portrait = yes }
		FROM = { opinion = { who = ROOT modifier = opinion_betrayed multiplier = 3 months = 60 } }		
	}
}
character_event = { #host informed of bribery
	id = tourney.81
	desc = "EVTDESCtourney.81"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.81" #ignore
		FROMFROMFROM = { 
			show_portrait = yes 
			opinion = { who = ROOT modifier = opinion_defended_me months = 60 }
			hidden_tooltip = { character_event = { id = tourney.82 } }
		}
		FROM = {
			opinion = { who = ROOT modifier = opinion_denied_redress months = 60 }
			hidden_tooltip = { character_event = { id = tourney.84 } }
		}
		event_target:bribed_squire = { 
			show_portrait = yes 
			hidden_tooltip = { character_event = { id = tourney.83 } }
		}
		hidden_tooltip = {
			any_opinion_modifier_target = { #Inform rest of tourny
				limit = {
					ai = no
					has_character_flag = attending_tournament
					OR = {
						has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
						has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
					}
					NOT = { character = ROOT }
					NOT = { character = FROM }
					NOT = { character = FROMFROMFROM }					
				}	
				character_event = { id = tourney.88 } 
			}
		}
	}
	option = {
		name = "EVTOPTBtourney.81" #disqualify
		FROMFROMFROM = {
			custom_tooltip = {
				text = TOOLTIPtourneyDISQUALIFIED
				set_character_flag = lost_tournament
			}
			opinion = { who = ROOT modifier = opinion_disgruntled multiplier = 2 months = 60 }		
			hidden_tooltip = { character_event = { id = tourney.85 } }
		}
		FROM = {	
			if = {
				limit = { NOT = { has_severe_disability_trigger = yes }	}
				custom_tooltip = {
					text = TOOLTIPtourneyREINSTATED
				}
			}	
			opinion = {
				who = ROOT
				modifier = opinion_granted_redress
				months = 36
			}
			hidden_tooltip = { character_event = { id = tourney.87 } }
		}	
		event_target:bribed_squire = { 
			show_portrait = yes 
			hidden_tooltip = { character_event = { id = tourney.86 } }
		}	
		hidden_tooltip = {
			any_opinion_modifier_target = { #Inform rest of tourny
				limit = {
					ai = no
					has_character_flag = attending_tournament
					OR = {
						has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
						has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
					}
					NOT = { character = ROOT }
					NOT = { character = FROM }
					NOT = { character = FROMFROMFROM }					
				}	
				character_event = { id = tourney.89 } 
			}
		}		
	}
	option = {
		name = "EVTOPTCtourney.81" #imprison!
		trigger = {
			is_vassal_or_below = FROMFROMFROM
		}
		FROMFROMFROM = {
			imprison = ROOT
			custom_tooltip = {
				text = TOOLTIPtourneyDISQUALIFIED
				set_character_flag = lost_tournament
			}
			opinion = { who = ROOT modifier = opinion_disgruntled multiplier = 2 months = 60 }	
		}
		FROM = {	
			if = {
				limit = { NOT = { has_severe_disability_trigger = yes }	}
				custom_tooltip = {
					text = TOOLTIPtourneyREINSTATED
				}
			}
			opinion = {
				who = ROOT
				modifier = opinion_granted_redress
				months = 36
			}
		}
		hidden_tooltip = {
			any_opinion_modifier_target = { #Inform rest of tourny
				limit = {
					ai = no
					has_character_flag = attending_tournament
					OR = {
						has_opinion_modifier = { who = PREV modifier = opinion_attending_tournament }
						has_opinion_modifier = { who = PREV modifier = opinion_spectating_tournament }
					}
					NOT = { character = ROOT }
					NOT = { character = FROM }
					NOT = { character = FROMFROMFROM }					
				}	
				character_event = { id = tourney.89 } 
			}
		}
	}
}
character_event = { #inform briber discovered but cleared
	id = tourney.82
	desc = "EVTDESCtourney.82"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTAtourney.82"
		FROM = { show_portrait = yes }
		FROMFROM = {
			opinion = { who = ROOT modifier = scheming_bastard months = 60 }
		}
		event_target:bribed_squire = { 
			show_portrait = yes 
		}
	}
}
character_event = { #inform squire discovered but cleared
	id = tourney.83
	desc = "EVTDESCtourney.83"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTAtourney.83"
		FROM = { show_portrait = yes }
		FROMFROMFROMFROM = { show_portrait = yes }
		FROMFROM = { opinion = { who = ROOT modifier = opinion_betrayed multiplier = 3 months = 60 } }		
	}
}
character_event = { #inform victim host cleared
	id = tourney.84
	desc = "EVTDESCtourney.84"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.84"
		prestige = -40		
		FROMFROMFROMFROM = { show_portrait = yes }
	}
}
character_event = { #inform briber discovered and disqualified
	id = tourney.85
	desc = "EVTDESCtourney.85"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTAtourney.85"
		custom_tooltip = {
			text = TOOLTIPtourneyDISQUALIFIED
			set_character_flag = lost_tournament
		}
		prestige = -75
		FROM = { show_portrait = yes }
		FROMFROM = {
			opinion = { who = ROOT modifier = scheming_bastard months = 60 }
		}
		event_target:bribed_squire = { 
			show_portrait = yes 
		}
	}
}
character_event = { #inform squire discovered and disqualified
	id = tourney.86
	desc = "EVTDESCtourney.86"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTAtourney.86"
		prestige = -50
		FROM = { show_portrait = yes }
		FROMFROMFROM = { show_portrait = yes }
		FROMFROM = { opinion = { who = ROOT modifier = opinion_betrayed multiplier = 3 months = 60 } }		
	}
}
character_event = { #inform victim host believed them
	id = tourney.87
	desc = "EVTDESCtourney.87"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTAtourney.87"
		prestige = 25	
		if = {
			limit = { NOT = { has_severe_disability_trigger = yes }	}
			custom_tooltip = {
				text = TOOLTIPtourneyREINSTATED
				clr_character_flag = lost_tournament
				character_event = { id = tourney.12 days = 2 random = 1 } #Find New Matchup
			}
		}
	}
}
character_event = { #inform others host ignored
	id = tourney.88
	desc = "EVTDESCtourney.88"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTAtourney.88"
		FROM = { show_portrait = yes }
		FROMFROMFROMFROM = { 
			show_portrait = yes 
		}
		event_target:bribed_squire = { 
			show_portrait = yes 
		}
	}
}
character_event = { #inform others host disqualified
	id = tourney.89
	desc = "EVTDESCtourney.89"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	show_from_from = yes
	
	option = {
		name = "EVTOPTAtourney.89"
		FROM = { show_portrait = yes }
		FROMFROM = {
			if = {
				limit = { NOT = { has_severe_disability_trigger = yes }	}
				custom_tooltip = {
					text = TOOLTIPtourneyREINSTATED
				}
			}	
		}
		FROMFROMFROMFROM = { 
			show_portrait = yes 
			custom_tooltip = {
				text = TOOLTIPtourneyDISQUALIFIED
			}
		}
		event_target:bribed_squire = { 
			show_portrait = yes 
		}
	}
}
###Fall in love with common girl###
character_event = {
	id = tourney.95
	desc = "EVTDESCtourney.95"
	picture = "GFX_evt_shadowy_cabal"
	
	is_triggered_only = yes
	hide_from = yes
	
	trigger = {
		any_opinion_modifier_target = {
			has_character_flag = tournament_begins
			reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			demesne_size = 1
		}	
	}
	
	immediate = {
		hidden_tooltip = {
			set_character_flag = attending_tournament_event
			random_opinion_modifier_target = {
				limit = {
					has_character_flag = tournament_begins
					reverse_has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }	
					demesne_size = 1
				}	
				capital_scope = {
					create_character = {
						random_traits = yes
						dynasty = none
						female = yes
						culture = THIS
						religion = THIS
						age = 18
						trait = fair
						historical = yes
					}
					new_character = {	
						change_learning = -5
						change_stewardship = -5
						change_diplomacy = -5
						change_martial = -5
						change_intrigue = -3
						save_event_target_as = tourney_lover
						move_character = PREVPREV
					}
				}
			}
		}	
	}
	
	option = {
		name = "EVTOPTAtourney.95" #Love and leave
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				trait = ruthless
			}
			modifier = {
				factor = 3
				trait = cruel
			}
			modifier = {
				factor = 3
				trait = wroth
			}
			modifier = {
				factor = 3
				trait = arbitrary
			}
		}
		if = {
			limit = { NOT = { trait = stressed } }
			random = {
				chance = 20
				add_trait = stressed
				hidden_tooltip = {
					character_event = {
						id = 38282 #Notify Stressed
					}
				}
			}
		}
		hidden_tooltip = {
			event_target:tourney_lover = { death = { death_reason = death_missing } }
		}
	}
	option = {
		name = "EVTOPTBtourney.95" #I dont care for her
		trigger = { trait = ruthless }
		tooltip_info = ruthless
		ai_chance = {
			factor = 200
			modifier = {
				factor = 2
				trait = cruel
			}
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
		}
		piety = -20
		hidden_tooltip = {
			event_target:tourney_lover = { death = { death_reason = death_missing } }
		}
	}
	option = {
		name = "EVTOPTCtourney.95" #Take home as lover
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				trait = honorable
				OR = {
					is_married = yes
					is_betrothed = yes
				}
			}
			modifier = {
				factor = 3
				trait = lustful
			}
			modifier = {
				factor = 3
				trait = humble
			}
			modifier = {
				factor = 3
				trait = kind
			}
			modifier = {
				factor = 3
				trait = honorable
			}
			modifier = {
				factor = 3
				trait = just
			}
		}
		event_target:tourney_lover = { 
			show_portrait = yes
			add_lover = ROOT
			if = {
				limit = { ROOT = { is_ruler = yes } }
				move_character = ROOT
			}
			if = {
				limit = { ROOT = { is_ruler = no } }
				ROOT = { liege = { reverse_banish = PREVPREV } }
			}
		}
	}
	option = {
		name = "EVTOPTDtourney.95" #murder
		trigger = { 
			trait = cruel 
			NOT = { trait = honorable }
			NOT = { trait = just }
		}
		tooltip_info = cruel
		ai_chance = {
			factor = 200
			modifier = {
				factor = 2
				trait = ruthless
			}
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 2
				trait = lunatic
			}
			modifier = {
				factor = 2
				trait = impaler
			}
		}
		piety = -20
		if = {
			limit = {
				NOT = { trait = impaler }
				NOT = { lifestyle_traits = 1 }
			}
			random = {
				chance = 20
				add_trait = impaler
			}
		}
		event_target:tourney_lover = { 
			death = { 
				death_reason = death_murder_unknown 
				killer = ROOT
			} 
		}
	}
	option = {
		name = "EVTOPTEtourney.95" #who are you?
		trigger = { 
			trait = drunkard
		}
		tooltip_info = drunkard
		ai_chance = {
			factor = 200
			modifier = {
				factor = 2
				trait = ruthless
			}
			modifier = {
				factor = 2
				trait = cruel
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
		}
		event_target:tourney_lover = { 
			opinion = { who = ROOT modifier = opinion_spurned }
		}
	}
}
# AI resolved tourney (If player is not involved, optimise)
#Find Winner
character_event = {
	id = tourney.550
	
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = 70002 days = 3 } #end tourney
		#Random deaths/injuries
		random = {
			chance = 5
			modifier = {
				factor = 3
				has_character_flag = normal_tourny
			}
			modifier = {
				factor = 4
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			random_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					prisoner = no
					NOT = { trait = incapable }
				}
				ROOT = {
					random_opinion_modifier_target = {
						limit = { 
							has_character_flag = attending_tournament
							has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
							prisoner = no
							NOT = { trait = incapable }
							NOT = { character = PREVPREV }
						}
						death = {
							death_reason = death_tourney_joust
							killer = PREVPREV
						}
					}	
				}
			}
		}
		random = {
			chance = 5
			modifier = {
				factor = 3
				has_character_flag = normal_tourny
			}
			modifier = {
				factor = 4
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			random_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					prisoner = no
					NOT = { trait = incapable }
					NOT = { is_maimed_trigger = yes }
				}
				add_maimed_trait_effect = yes
			}
		}
		random = {
			chance = 15
			modifier = {
				factor = 3
				has_character_flag = normal_tourny
			}
			modifier = {
				factor = 4
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			random_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					prisoner = no
					NOT = { trait = incapable }
					NOT = { trait = wounded }
				}
				add_trait = wounded
			}
		}
		random = {
			chance = 10
			modifier = {
				factor = 3
				has_character_flag = normal_tourny
			}
			modifier = {
				factor = 4
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			random_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					prisoner = no
					NOT = { trait = incapable }
					NOT = { trait = wounded }
				}
				add_trait = wounded
			}
		}
		random = {
			chance = 5
			modifier = {
				factor = 3
				has_character_flag = normal_tourny
			}
			modifier = {
				factor = 4
				OR = {
					has_character_flag = king_tourny
					has_character_flag = grand_tourny
				}
			}
			random_opinion_modifier_target = {
				limit = { 
					has_character_flag = attending_tournament
					has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
					prisoner = no
					NOT = { trait = incapable }
					NOT = { trait = wounded }
				}
				add_trait = wounded
			}
		}
		
		##Find Winners
		#16+
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_tournament
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
				OR = {
					combat_rating = 8
					AND = {
						is_strong_trigger = yes
						combat_rating = 6
					}
				}	
				prisoner = no
				NOT = { trait = incapable }	
			}
			set_character_flag = ai_tourney_medal
			character_event = { id = 70020 }
			ROOT = { set_character_flag = ai_tourney_1st_found }
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				OR = {
					combat_rating = 8
					AND = {
						is_strong_trigger = yes
						combat_rating = 6
					}
				}	
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			set_character_flag = ai_tourney_medal
			character_event = { id = 70021 }
			ROOT = { set_character_flag = ai_tourney_2nd_found }
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				OR = {
					combat_rating = 8
					AND = {
						is_strong_trigger = yes
						combat_rating = 6
					}
				}	
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			set_character_flag = ai_tourney_medal
			character_event = { id = 70022 }
			break = yes
		}
		#9+
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				OR = {
					combat_rating = 6.34
					AND = {
						is_strong_trigger = yes
						combat_rating = 1
					}
				}	
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					ROOT = { has_character_flag = ai_tourney_1st_found } 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
			if = {
				limit = { ROOT = { NOT = { has_character_flag = ai_tourney_1st_found } } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70020 }
				ROOT = { set_character_flag = ai_tourney_1st_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				OR = {
					combat_rating = 6.34
					AND = {
						is_strong_trigger = yes
						combat_rating = 1
					}
				}		
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				OR = {
					combat_rating = 6.34
					AND = {
						is_strong_trigger = yes
						combat_rating = 1
					}
				}		
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			set_character_flag = ai_tourney_medal
			character_event = { id = 70022 }
			break = yes
		}
		#3+
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				combat_rating = 3.17
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					ROOT = { has_character_flag = ai_tourney_1st_found } 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
			if = {
				limit = { ROOT = { NOT = { has_character_flag = ai_tourney_1st_found } } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70020 }
				ROOT = { set_character_flag = ai_tourney_1st_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				combat_rating = 3.17
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				combat_rating = 3.17
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			set_character_flag = ai_tourney_medal
			character_event = { id = 70022 }
			break = yes
		}
		#0+
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				combat_rating = 0
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					ROOT = { has_character_flag = ai_tourney_1st_found } 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
			if = {
				limit = { ROOT = { NOT = { has_character_flag = ai_tourney_1st_found } } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70020 }
				ROOT = { set_character_flag = ai_tourney_1st_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				combat_rating = 0
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				combat_rating = 0
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			set_character_flag = ai_tourney_medal
			character_event = { id = 70022 }
			break = yes
		}
		#Rest
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					ROOT = { has_character_flag = ai_tourney_1st_found } 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
			if = {
				limit = { ROOT = { NOT = { has_character_flag = ai_tourney_1st_found } } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70020 }
				ROOT = { set_character_flag = ai_tourney_1st_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			if = {
				limit = { ROOT = { has_character_flag = ai_tourney_2nd_found } }
				set_character_flag = ai_tourney_medal
				character_event = { id = 70022 }
				break = yes
			}
			if = {
				limit = { 
					NOT = { has_character_flag = ai_tourney_2nd_found }
				}
				set_character_flag = ai_tourney_medal
				character_event = { id = 70021 }
				ROOT = { set_character_flag = ai_tourney_2nd_found }
			}
		}
		random_opinion_modifier_target = {
			limit = { 
				has_character_flag = attending_melee
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_melee }
				prisoner = no
				NOT = { trait = incapable }
				NOT = { has_character_flag = ai_tourney_medal }
			}	
			set_character_flag = ai_tourney_medal
			character_event = { id = 70022 }
			break = yes
		}
	}
	option = {
		name = OK
	}
}	
###########################################
# Flag management                         #
###########################################

# Safety catch - clears character flags and modifiers
character_event = {
	id = 70999

	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = { has_character_modifier = holding_epic_tournament }
	
	immediate = {
		remove_character_modifier = holding_epic_tournament
		clr_character_flag = do_not_disturb
		
		clr_character_flag = tourny_in_progress
		clr_character_flag = tournament_begins
		clr_character_flag = attending_tournament
		clr_character_flag = attending_tournament_event
		clr_character_flag = no_msg_death
		clr_character_flag = no_msg_maimed
		clr_character_flag = no_msg_wounded
		clr_character_flag = no_msg_knight
		
		clr_character_flag = lost_tournament
		clr_character_flag = ai_tourney_medal
		clr_character_flag = tourney_final_round
		clr_character_flag = in_joust
		clr_character_flag = lost_round
		clr_character_flag = inform_of_all_tourney_results
		clr_character_flag = tourney_medalist
		
		clr_character_flag = survive
		clr_character_flag = unhorsed
		clr_character_flag = wounded
		clr_character_flag = maimed
		clr_character_flag = death
		
		clr_character_flag = host_feast_started
		remove_character_modifier = holding_large_feast	
		
		clr_character_flag = ai_tourney_1st_found
		clr_character_flag = ai_tourney_2nd_found
		
		clr_character_flag = placed_tourney_bet
		clr_character_flag = placed_tourney_bet_self
		clr_character_flag = placed_tourney_bet_5
		clr_character_flag = placed_tourney_bet_20
		clr_character_flag = placed_tourney_bet_40
		hidden_tooltip = { set_variable = { which = tourney_bet_odds value = 0 } }
		
		any_opinion_modifier_target = {
			limit = {
				has_character_flag = attending_tournament
				has_opinion_modifier = { who = ROOT modifier = opinion_attending_tournament }
			}
			
			clr_character_flag = attending_tournament
			clr_character_flag = attending_tournament_event
			clr_character_flag = king_tourny
			clr_character_flag = grand_tourny
			clr_character_flag = normal_tourny
			clr_character_flag = small_tourny
			
			clr_character_flag = lost_tournament
			clr_character_flag = ai_tourney_medal
			clr_character_flag = in_joust
			clr_character_flag = lost_round
			clr_character_flag = tourney_medalist
			
			clr_character_flag = survive
			clr_character_flag = unhorsed
			clr_character_flag = wounded
			clr_character_flag = maimed
			clr_character_flag = death
			clr_character_flag = bribed_to_lose
			clr_character_flag = squire_bribed
			
			clr_character_flag = guest_feast_started
			
			clr_character_flag = placed_tourney_bet
			clr_character_flag = placed_tourney_bet_self
			clr_character_flag = placed_tourney_bet_5
			clr_character_flag = placed_tourney_bet_20
			clr_character_flag = placed_tourney_bet_40
			hidden_tooltip = { set_variable = { which = tourney_bet_odds value = 0 } }
			
			remove_opinion = {
				modifier = opinion_attending_tournament
				who = ROOT
			}
			reverse_remove_opinion = {
				modifier = opinion_attending_tournament
				who = ROOT
			}
		}	
		if = { 
			limit = {
				higher_tier_than = DUKE		
			}	
			top_liege = {
				any_realm_character = {
					limit = {
						is_female = yes
						OR = {
							has_character_flag = queen_love_beauty_1
							has_character_flag = queen_love_beauty_2
							has_character_flag = queen_love_beauty_3
							has_character_flag = queen_love_beauty_4
						}
					}
					clr_character_flag = queen_love_beauty_1
					clr_character_flag = queen_love_beauty_2
					clr_character_flag = queen_love_beauty_3
					clr_character_flag = queen_love_beauty_4
				}	
			}	
		}	
	}
}

		