################################################
#
# Events for Tournament
#
# ID 70000 - 70999 is reserved
# Reworked by Rylock
#
#################################################

### INVITATIONS TO THE TOURNAMENT

# Invitations have gone out
character_event = {
	id = 70033
	title = TOURNAMENTTITLE
	desc = EVTDESC70033
	picture = GFX_evt_tournament_gallery

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70033" # the tournament begins soon
		hidden_tooltip = {
			any_realm_character = {
				limit = {
					is_adult = yes
					prisoner = no
					OR = {
						is_feudal = yes
						is_tribal = yes
					}
					is_female = no
					OR = {
						any_spouse = { NOT = { dynasty = 0 } }
						NOT = { dynasty = 0 }
					}
					NOT = {
						has_job_title = job_spiritual
						trait = incapable
						is_maimed_trigger = yes
					}
					is_not_busy_trigger = yes
				}
				character_event = { id = 70000 }
			}
			any_realm_character = {
				limit = {
					is_adult = yes
					prisoner = no
					OR = {
						is_feudal = yes
						is_tribal = yes
					}
					is_female = yes
					OR = {
						any_spouse = { NOT = { dynasty = 0 } }
						NOT = { dynasty = 0 }
					}
					NOT = {
						has_job_title = job_spiritual
						trait = incapable
						is_maimed_trigger = yes
					}
					is_not_busy_trigger = yes
				}
				character_event = { id = FemRule.200 }
			}
		}
	}
}

# Man of the realm receives the invitation
character_event = {
	id = 70000
	title = TOURNAMENTTITLE
	desc = EVTDESC70000
	picture = GFX_evt_tournament_gallery

	is_triggered_only = yes

	trigger = { NOT = { is_inaccessible_trigger = yes } }

	option = {
		name = "EVTOPTA70000" # A chance to prove our worth
		trigger = {
			NOT = { age = 60 }
			NOT = { health_traits = 1 }
		}
		ai_chance = {
			factor = 80
			modifier = {
				factor = 1.5
				OR = {
					trait = duelist
					trait = impaler
					trait = hunter
				}
			}
			modifier = {
				factor = 2
				trait = brave
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.25
				martial = 10
			}
			modifier = {
				factor = 1.25
				martial = 12
			}
			modifier = {
				factor = 1.25
				martial = 14
			}
			modifier = {
				factor = 1.25
				martial = 16
			}
			modifier = {
				factor = 1.25
				martial = 18
			}
			modifier = {
				factor = 2
				martial = 20
			}
			modifier = {
				factor = 0.5
				NOT = { martial = 8 }
			}
			modifier = {
				factor = 0.25
				NOT = { martial = 4 }
			}
			modifier = {
				factor = 0
				NOT = { martial = 2 }
			}
		}
		prestige = 50
		set_character_flag = attending_tournament
		hidden_tooltip = {
			change_variable = { which = "lifestyle_martial" value = 1 }
			character_event = { id = 70999 days = 180 } # Safety catch flag clearing
			add_character_modifier = {
				name = do_not_disturb
				days = 150
				hidden = yes
			}
		}
		if = {
			limit = { is_inaccessible_trigger = yes	}
			end_inaccessibility_effect = yes
		}
	}
	option = {
		name = "EVTOPTC70000" # I will watch from the stands
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0.1
				OR = {
					trait = duelist
					trait = impaler
					trait = hunter
				}
			}
			modifier = {
				factor = 0
				trait = brave
			}
			modifier = {
				factor = 0
				trait = ambitious
			}
			modifier = {
				factor = 0
				trait = proud
			}
			modifier = {
				factor = 0
				martial = 10
			}
			modifier = {
				factor = 4
				trait = craven
			}
			modifier = {
				factor = 2
				trait = content
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 4
				NOT = { martial = 6 }
			}
		}
		set_character_flag = spectating_tournament
		hidden_tooltip = {
			character_event = { id = 70999 days = 180 } # Safety catch flag clearing
			add_character_modifier = {
				name = do_not_disturb
				days = 150
				hidden = yes
			}
		}
		if = {
			limit = { is_inaccessible_trigger = yes	}
			end_inaccessibility_effect = yes
		}		
	}
	option = {
		name = "EVTOPTB70000" # A foolish risk for fleeting glory
		trigger = {
			NOT = { age = 60 }
			NOT = { health_traits = 1 }
		}
		ai_chance = {
			factor = 20
			modifier = {
				factor = 10
				is_inaccessible_trigger = yes
			}
			modifier = {
				factor = 2
				OR = {
					trait = scholar
					trait = gardener
				}
			}
			modifier = {
				factor = 4
				trait = craven
			}
			modifier = {
				factor = 2
				trait = content
			}
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 2
				NOT = { martial = 4 }
			}
			modifier = {
				factor = 2
				age = 40
			}
			modifier = {
				factor = 2
				age = 50
			}
		}
	}
	option = {
		name = "EVTOPTD70000" # I will not be attending
		trigger = {
			OR = {
				age = 60
				health_traits = 1
			}
		}
		ai_chance = {
			factor = 80
			modifier = {
				factor = 10
				is_inaccessible_trigger = yes
			}
		}
	}
}

### TOURNAMENT START & END EVENTS

# Start of tournament
character_event = {
	id = 70001
	title = TOURNAMENTTITLE
	picture = GFX_evt_tournament_gallery

	is_triggered_only = yes

	desc = {
		text = EVTDESC70001
		trigger = { NOT = { religion_group = muslim } }
	}
	
	desc = {
		text = EVTDESC88251
		trigger = { religion_group = muslim }
	}
	
	trigger = {
		has_character_modifier = holding_epic_tournament
	}

	option = {
		name = "EVTOPTA70001" #I will be taking my place among the fighters!
		trigger = {
			is_female = no
			NOT = { trait = incapable }
			NOT = { trait = infirm }
		}
		ai_chance = {
			factor = 120
			modifier = {
				factor = 0
				NOT = { health = 3.1 }
			}
			modifier = {
				factor = 0.5
				NOT = { health = 4.1 }
			}
			modifier = {
				factor = 0.75
				health = 4
				NOT = { health = 5.1 }
			}
			modifier = {
				factor = 2
				martial = 12
			}
			modifier = {
				factor = 2
				martial = 14
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.5
				trait = ambitious
			}
			modifier = {
				factor = 1.25
				trait = duelist
			}
		}
		hidden_tooltip = {
			change_variable = { which = "lifestyle_martial" value = 1 }
			set_character_flag = tournament_begins
			set_character_flag = attending_tournament
			character_event = { id = 70100 days = 3 random = 25 } #participant trigger event
			any_realm_character = {
				limit = { has_character_flag = attending_tournament }
				character_event = { id = 70100 days = 3 random = 25 } #participant trigger event
			}
			any_realm_character = {
				limit = { has_character_flag = spectating_tournament }
				
				character_event = { id = 70200 days = 3 random = 25 } #specttator trigger event
			}
		}
		if = {
			limit = { religion_group = muslim }
			chronicle = {
				entry = CHRONICLE_FURUSIYYA
				picture = GFX_evt_joust
			}
			break = yes
		}
		chronicle = {
			entry = CHRONICLE_GRAND_TOURNAMENT
			picture = GFX_evt_joust
		}
	}
	option = {
		name = "EVTOPTC70001" #I look forward to watching the jousts
		ai_chance = {
			factor = 80
			modifier = {
				factor = 1.25
				NOT = { martial = 10 }
			}
			modifier = {
				factor = 1.25
				NOT = { martial = 8 }
			}
			modifier = {
				factor = 1.25
				NOT = { martial = 5 }
			}
			modifier = {
				factor = 0.5
				trait = proud
			}
			modifier = {
				factor = 1.5
				trait = humble
			}
			modifier = {
				factor = 1.5
				trait = content
			}
		}
		any_vassal = {
			limit = {
				OR = {
					has_minor_title = title_ladys_champion
					has_minor_title = title_champion
				}
				prisoner = no
				NOT = { trait = incapable }
			}
			letter_event = { id = FemRule.201 days = 1 }
		}
		any_courtier = {
			limit = {
				OR = {
					has_minor_title = title_ladys_champion
					has_minor_title = title_champion
				}
				prisoner = no
				NOT = { trait = incapable }
			}
			letter_event = { id = FemRule.201 days = 1 }
		}
		hidden_tooltip = {
			set_character_flag = tournament_begins
			set_character_flag = spectating_tournament
			character_event = { id = 70200 days = 3 random = 25 } #specttator trigger event
			any_realm_character = {
				limit = { has_character_flag = attending_tournament }
				character_event = { id = 70100 days = 3 random = 25 } #participant trigger event
			}
			any_realm_character = {
				limit = { has_character_flag = spectating_tournament }
				
				character_event = { id = 70200 days = 3 random = 25 } #specttator trigger event
			}
		}
		if = {
			limit = { religion_group = muslim }
			chronicle = {
				entry = CHRONICLE_FURUSIYYA
				picture = GFX_evt_joust
			}
			break = yes
		}
		chronicle = {
			entry = CHRONICLE_GRAND_TOURNAMENT
			picture = GFX_evt_joust
		}
	}
	option = {
		name = "EVTOPTD70001" #I will fight in the tournament myself!
		trigger = {
			is_female = yes
			OR = {
				trait = martial_lady_pagan
				trait = martial_lady
				trait = martial_lady_tengri
			}
			NOT = { trait = incapable }
			NOT = { trait = infirm }
		}
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0
				is_pregnant = yes
			}
			modifier = {
				factor = 0
				NOT = { health = 3.1 }
			}
			modifier = {
				factor = 0.1
				NOT = { trait = brave }
			}
			modifier = {
				factor = 0
				OR = {
					trait = craven
					trait = humble
					trait = content
					is_weak_trigger = yes
					NOT = { martial = 8 }
					age = 40
				}
			}
			modifier = {
				factor = 0.5
				NOT = { martial = 12 }
			}
			modifier = {
				factor = 2
				martial = 15
			}
			modifier = {
				factor = 2
				martial = 20
			}
			modifier = {
				factor = 2
				martial = 25 # only JoA should have this much
			}
			modifier = {
				factor = 1.25
				is_strong_trigger = yes
			}
			modifier = {
				factor = 1.25
				trait = ambitious
			}
			modifier = {
				factor = 1.25
				OR = {
					trait = skilled_tactician
					trait = brilliant_strategist
				}
			}
		}
		hidden_tooltip = {
			change_variable = { which = "lifestyle_martial" value = 1 }
			set_character_flag = tournament_begins
			set_character_flag = attending_tournament
			character_event = { id = 70100 days = 3 random = 25 } #participant trigger event
			any_realm_character = {
				limit = { has_character_flag = attending_tournament }
				character_event = { id = 70100 days = 3 random = 25 } #participant trigger event
			}
			any_realm_character = {
				limit = { has_character_flag = spectating_tournament }
				character_event = { id = 70200 days = 3 random = 25 } #specttator trigger event
			}
		}
		if = {
			limit = { religion_group = muslim }
			chronicle = {
				entry = CHRONICLE_FURUSIYYA
				picture = GFX_evt_joust
			}
			break = yes
		}
		chronicle = {
			entry = CHRONICLE_GRAND_TOURNAMENT
			picture = GFX_evt_joust
		}
	}
}

# Tournament has been cancelled due to war
character_event = {
	id = 70998
	title = TOURNAMENTTITLE
	desc = EVTDESC70998
	picture = GFX_evt_tournament_gallery
	
	only_rulers = yes
	min_age = 16
	
	trigger = {
		war = yes
		has_character_modifier = holding_epic_tournament
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	option = {
		name = CURSES
		wealth = 200
		prestige = -100
		if = {
			limit = {
				religion_group = muslim
				dynasty_head = { character = ROOT }
			}
			piety = -50
		}
		hidden_tooltip = {
			any_realm_character = {
				limit = {
					NOT = { character = ROOT }
					OR = {
						has_character_flag = attending_tournament
						has_character_flag = spectating_tournament
					}
				}
				character_event = { id = 70037 }
			}
			set_character_flag = tournament_cooldown
			remove_character_modifier = epic_tournament
			remove_do_not_disturb_effect = yes
			remove_character_modifier = holding_epic_tournament
			clr_character_flag = tournament_begins
			clr_character_flag = winner
			clr_character_flag = second_place
			clr_character_flag = third_place
			clr_character_flag = attending_tournament
			clr_character_flag = attending_tournament_event
			clr_character_flag = tournament_third_place
			clr_character_flag = tournament_second_place
			clr_character_flag = tournament_winner
			clr_character_flag = beauty_winner
			clr_character_flag = tournament_romance
			clr_character_flag = spectating_tournament
			clr_character_flag = attending_tournament_wound
			clr_character_flag = attending_tournament_sexism
			clr_character_flag = attending_tournament_fear
			clr_character_flag = attending_tournament_MartialEd
			clr_character_flag = attending_tournament_gay
			clr_character_flag = attending_tournament_syph
			clr_character_flag = attending_tournament_drunk
			clr_character_flag = attending_tournament_duelist
			clr_character_flag = attending_tournament_intrigue
			clr_character_flag = attending_tournament_stew
			clr_character_flag = attending_tournament_dip
			clr_character_flag = lady_pride
			clr_character_flag = lady_shyness
			clr_character_flag = lady_honesty
			clr_character_flag = lady_lust
			clr_character_flag = no_msg_death
			clr_character_flag = no_msg_maimed
			clr_character_flag = no_msg_wounded
		}
	}
}

# Inform attendees of cancellation due to war
character_event = {
	id = 70037
	title = TOURNAMENTTITLE
	desc = EVTDESC70037
	picture = GFX_evt_tournament_gallery

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70037"
		if = {
			limit = { has_character_flag = attending_tournament }
			prestige = -50
		}
		hidden_tooltip = {
			remove_do_not_disturb_effect = yes
			clr_character_flag = attending_tournament
			clr_character_flag = attending_tournament_event
			clr_character_flag = tournament_third_place
			clr_character_flag = tournament_second_place
			clr_character_flag = tournament_winner
			clr_character_flag = tournament_romance
			clr_character_flag = spectating_tournament
			clr_character_flag = attending_tournament_wound
			clr_character_flag = championing_liege_lady
			clr_character_flag = attending_tournament_sexism
			clr_character_flag = attending_tournament_fear
			clr_character_flag = attending_tournament_MartialEd
			clr_character_flag = attending_tournament_gay
			clr_character_flag = attending_tournament_syph
			clr_character_flag = attending_tournament_drunk
			clr_character_flag = attending_tournament_duelist
			clr_character_flag = attending_tournament_intrigue
			clr_character_flag = attending_tournament_stew
			clr_character_flag = attending_tournament_dip
			clr_character_flag = lady_pride
			clr_character_flag = lady_shyness
			clr_character_flag = lady_honesty
			clr_character_flag = lady_lust
			clr_character_flag = still_to_show
		}
	}
}

# Tournament is over
character_event = {
	id = 70002
	title = TOURNAMENTTITLE	
	picture = GFX_evt_tournament_gallery
	
	only_rulers = yes
	min_age = 16
	has_character_flag = winner

	desc = {
		text = EVTDESC70002
		trigger = { NOT = { religion_group = muslim } }
	}
	desc = {
		text = EVTDESC88252
		trigger = { religion_group = muslim }
	}

	trigger = {		
		OR = {
			has_character_flag = beauty_winner
			religion_group = muslim
		}		
		has_character_flag = second_place 
		has_character_flag = third_place				
	}

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70002"
		if = {
			limit = {
				has_dlc = "Reapers"
			}
			custom_tooltip = {
				text = capital_prospers_custom_tooltip
				hidden_tooltip = {
					capital_scope = {
						change_variable = { which = prosperity_value value = 15 }
					}
				}
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_court } }
			custom_tooltip = { text = COURTFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_court } set_variable = { which = "faction_mood_increase" value = 2 } }
			}
		}
		if = {
			limit = { any_vassal = { leads_faction = faction_glory } }
			custom_tooltip = { text = GLORYFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_glory } set_variable = { which = "faction_mood_increase" value = 3 } }
			}
		}
		hidden_tooltip = { character_event = { id = PlusFaction.200 days = 1 } } #recalculate faction moods
		if = {
			limit = { tier = EMPEROR }
			ROOT = {
				custom_tooltip = { text = IMPERIAL_DECADENCE_MINUS_1 }
				hidden_tooltip = {
					primary_title = { change_variable = { which = "imperial_decadence" value = -1 } }
					character_event = { id = Plus.1852 }
				}
			}
		}
		hidden_tooltip = {
			remove_do_not_disturb_effect = yes
			remove_character_modifier = holding_epic_tournament
			clr_character_flag = tournament_begins
			clr_character_flag = winner
			clr_character_flag = second_place
			clr_character_flag = third_place
			clr_character_flag = attending_tournament
			clr_character_flag = attending_tournament_sexism
			clr_character_flag = attending_tournament_event
			clr_character_flag = attending_tournament_fear
			clr_character_flag = attending_tournament_MartialEd
			clr_character_flag = attending_tournament_gay
			clr_character_flag = attending_tournament_syph
			clr_character_flag = attending_tournament_drunk
			clr_character_flag = attending_tournament_duelist
			clr_character_flag = attending_tournament_intrigue
			clr_character_flag = attending_tournament_stew
			clr_character_flag = attending_tournament_dip
			clr_character_flag = lady_pride
			clr_character_flag = lady_shyness
			clr_character_flag = lady_honesty
			clr_character_flag = lady_lust
			clr_character_flag = tournament_third_place
			clr_character_flag = tournament_second_place
			clr_character_flag = tournament_winner
			clr_character_flag = beauty_winner
			clr_character_flag = tournament_romance
			clr_character_flag = spectating_tournament
			clr_character_flag = attending_tournament_wound
			clr_character_flag = no_msg_death
			clr_character_flag = no_msg_maimed
			clr_character_flag = no_msg_wounded
		}
		custom_tooltip = { text = EVTTOOLTIP70002 }
		hidden_tooltip = {
			any_realm_character = {
				limit = {
					NOT = { character = ROOT }
					has_character_flag = attending_tournament
					OR = {
						has_character_flag = tournament_third_place
						has_character_flag = tournament_second_place
						has_character_flag = tournament_winner
					}
				}
				set_character_flag = tournament_has_ended
				opinion = {
					modifier = opinion_tournament_participant
					who = ROOT
					years = 2
				}
			}
			any_realm_character = {
				limit = {
					has_character_flag = attending_tournament
					NOT = { character = ROOT }
					NOT = { has_character_flag = tournament_third_place }
					NOT = { has_character_flag = tournament_second_place }
					NOT = { has_character_flag = tournament_winner }
				}
				hidden_tooltip = {
					random_list = {
						10 = { 
							character_event = { id = 70003 } #Did well
						}
						10 = {
							character_event = { id = 70004 } #Did really well
						}
						10 = {
							character_event = { id = 70005 } #Did poorly
						}
						10 = {
							character_event = { id = 70006 } #Did really poorly
						}
						10 = {
							character_event = { id = 70007 } #Gain Martial
						}	
						10 = {	
							character_event = { id = 70008 } #Lose Martial
						}
					}
				}
				opinion = {
					modifier = opinion_tournament_participant
					who = ROOT
					years = 2
				}
			}
		}
		hidden_tooltip = {
			any_realm_character = {
				limit = {
					has_character_flag = spectating_tournament
					NOT = { character = ROOT }
				}
				character_event = { id = FemRule.245 }
			}
			any_realm_character = {
				limit = {
					OR = {
						has_character_flag = spectating_tournament
						has_character_flag = attending_tournament
					}
				}
				hidden_tooltip = {
					remove_do_not_disturb_effect = yes
					clr_character_flag = attending_tournament
					clr_character_flag = attending_tournament_event
					clr_character_flag = attending_tournament_sexism
					clr_character_flag = attending_tournament_fear
					clr_character_flag = attending_tournament_MartialEd
					clr_character_flag = attending_tournament_gay
					clr_character_flag = attending_tournament_syph
					clr_character_flag = attending_tournament_drunk
					clr_character_flag = attending_tournament_duelist
					clr_character_flag = attending_tournament_intrigue
					clr_character_flag = attending_tournament_stew
					clr_character_flag = attending_tournament_dip
					clr_character_flag = lady_pride
					clr_character_flag = lady_shyness
					clr_character_flag = lady_honesty
					clr_character_flag = lady_lust
					clr_character_flag = tournament_third_place
					clr_character_flag = tournament_second_place
					clr_character_flag = tournament_winner
					clr_character_flag = tournament_romance
					clr_character_flag = spectating_tournament
					clr_character_flag = attending_tournament_wound
					clr_character_flag = championing_liege_lady
				}
			}
		}
	}
}

# End of tournament event
character_event = {
	id = 70003
	title = TOURNAMENTTITLE
	desc = EVTDESC70003
	picture = GFX_evt_joust

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70003"
		prestige = 50
	}
}

# End of tournament event
character_event = {
	id = 70004
	title = TOURNAMENTTITLE
	desc = EVTDESC70004
	picture = GFX_evt_joust

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70004"
		prestige = 100
	}
}

# End of tournament event
character_event = {
	id = 70005
	title = TOURNAMENTTITLE
	desc = EVTDESC70005
	picture = GFX_evt_joust

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70005"
		prestige = -50
	}
}

# End of tournament event
character_event = {
	id = 70006
	title = TOURNAMENTTITLE
	desc = EVTDESC70006
	picture = GFX_evt_joust

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70006"
		prestige = -100
	}
}

# End of tournament event
character_event = {
	id = 70007
	title = TOURNAMENTTITLE
	desc = EVTDESC70007
	picture = GFX_evt_joust

	is_triggered_only = yes

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

# End of tournament event
character_event = {
	id = 70008
	title = TOURNAMENTTITLE
	desc = EVTDESC70008
	picture = GFX_evt_joust

	is_triggered_only = yes

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

# Ruler has died, the tournament is over
character_event = {
	id = 70041
	title = TOURNAMENTTITLE
	desc = EVTDESC70041
	picture = GFX_evt_death

	is_triggered_only = yes

	trigger = {
		OR = {
			has_character_flag = tournament_begins
			has_character_modifier = holding_epic_tournament
		}
	}

	immediate = {
		clr_character_flag = tournament_begins
		clr_character_flag = winner
		clr_character_flag = second_place
		clr_character_flag = third_place
		clr_character_flag = attending_tournament
		clr_character_flag = attending_tournament_event
		clr_character_flag = tournament_third_place
		clr_character_flag = tournament_second_place
		clr_character_flag = tournament_winner
		clr_character_flag = beauty_winner
		clr_character_flag = tournament_romance
		clr_character_flag = spectating_tournament
		clr_character_flag = attending_tournament_wound
		clr_character_flag = attending_tournament_sexism
		clr_character_flag = attending_tournament_fear
		clr_character_flag = attending_tournament_MartialEd
		clr_character_flag = attending_tournament_gay
		clr_character_flag = attending_tournament_syph
		clr_character_flag = attending_tournament_drunk
		clr_character_flag = attending_tournament_duelist
		clr_character_flag = attending_tournament_intrigue
		clr_character_flag = attending_tournament_stew
		clr_character_flag = attending_tournament_dip
		clr_character_flag = lady_pride
		clr_character_flag = lady_shyness
		clr_character_flag = lady_honesty
		clr_character_flag = lady_lust
		any_realm_character = {
			limit = {
				OR = {
					has_character_flag = attending_tournament
					has_character_flag = spectating_tournament
				}
				NOT = { character = ROOT }
			}
			letter_event = {
				id = 70042
				days = 2
				random = 2
				tooltip = EVTTOOLTIP70042
			}
		}		
	}

	option = {
		name = EVTOPTA70041
	}
}

# Inform attendees of cancellation due to ruler's death
letter_event = {
	id = 70042
	title = TOURNAMENTTITLE
	desc = EVTDESC70042
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EVTOPTA70042
		hidden_tooltip = {
			remove_do_not_disturb_effect = yes
			clr_character_flag = attending_tournament
			clr_character_flag = attending_tournament_event
			clr_character_flag = tournament_third_place
			clr_character_flag = tournament_second_place
			clr_character_flag = tournament_winner
			clr_character_flag = tournament_romance
			clr_character_flag = spectating_tournament
			clr_character_flag = attending_tournament_wound
			clr_character_flag = championing_liege_lady
			clr_character_flag = attending_tournament_sexism
			clr_character_flag = attending_tournament_fear
			clr_character_flag = attending_tournament_MartialEd
			clr_character_flag = attending_tournament_gay
			clr_character_flag = attending_tournament_syph
			clr_character_flag = attending_tournament_drunk
			clr_character_flag = attending_tournament_duelist
			clr_character_flag = attending_tournament_intrigue
			clr_character_flag = attending_tournament_stew
			clr_character_flag = attending_tournament_dip
			clr_character_flag = lady_pride
			clr_character_flag = lady_shyness
			clr_character_flag = lady_honesty
			clr_character_flag = lady_lust
		}	
	}
}

### EVENT TRIGGERS

#looping trigger event for participants
character_event = {
	id = 70100
	
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		has_character_flag = attending_tournament
		top_liege = {
			has_character_modifier = holding_epic_tournament
			has_character_flag = tournament_begins
			NOT = { has_character_flag = tournament_has_ended } 
		}		
	}
	
	immediate = {
		random_list = {
			500 = {	#no event				
			}			
			1 = {	#character is killed
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_wound
				}
				modifier = {
					factor = 0.9
					martial = 20
				}
				modifier = {
					factor = 0.9
					martial = 19
				}
				modifier = {
					factor = 0.9
					martial = 18
				}
				modifier = {
					factor = 0.9
					martial = 17
				}
				modifier = {
					factor = 0.9
					martial = 16
				}
				modifier = {
					factor = 0.9
					martial = 15
				}
				modifier = {
					factor = 0.9
					martial = 14
				}
				modifier = {
					factor = 0.9
					martial = 13
				}
				modifier = {
					factor = 0.9
					martial = 12
				}
				modifier = {
					factor = 0.9
					martial = 11
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 7 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 5 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 3 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 1 }
				}
				modifier = {
					factor = 0.5
					trait = craven
				}
				modifier = {
					factor = 2
					trait = brave
				}
				modifier = {
					factor = 2
					is_maimed_trigger = yes
				}
				character_event = { id = 70009 }
			}
			2 = {   #character is maimed
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_wound
				}
				modifier = {
					factor = 0.9
					martial = 20
				}
				modifier = {
					factor = 0.9
					martial = 19
				}
				modifier = {
					factor = 0.9
					martial = 18
				}
				modifier = {
					factor = 0.9
					martial = 17
				}
				modifier = {
					factor = 0.9
					martial = 16
				}
				modifier = {
					factor = 0.9
					martial = 15
				}
				modifier = {
					factor = 0.9
					martial = 14
				}
				modifier = {
					factor = 0.9
					martial = 13
				}
				modifier = {
					factor = 0.9
					martial = 12
				}
				modifier = {
					factor = 0.9
					martial = 11
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 7 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 5 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 3 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 1 }
				}
				modifier = {
					factor = 0.5
					trait = craven
				}
				modifier = {
					factor = 2
					trait = brave
				}
				modifier = {
					factor = 2
					trait = wounded
				}
				character_event = { id = 70010 }
			}
			3 = {   #character is wounded
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_wound
				}
				modifier = {
					factor = 0.9
					martial = 20
				}
				modifier = {
					factor = 0.9
					martial = 19
				}
				modifier = {
					factor = 0.9
					martial = 18
				}
				modifier = {
					factor = 0.9
					martial = 17
				}
				modifier = {
					factor = 0.9
					martial = 16
				}
				modifier = {
					factor = 0.9
					martial = 15
				}
				modifier = {
					factor = 0.9
					martial = 14
				}
				modifier = {
					factor = 0.9
					martial = 13
				}
				modifier = {
					factor = 0.9
					martial = 12
				}
				modifier = {
					factor = 0.9
					martial = 11
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 7 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 5 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 3 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 1 }
				}
				modifier = {
					factor = 0.5
					trait = craven
				}
				modifier = {
					factor = 2
					trait = brave
				}
				character_event = { id = 70011 }
			}
			10 = { #character gets more fearful
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_fear
				}
				modifier = {
					factor = 0.9
					martial = 20
				}
				modifier = {
					factor = 0.9
					martial = 19
				}
				modifier = {
					factor = 0.9
					martial = 18
				}
				modifier = {
					factor = 0.9
					martial = 17
				}
				modifier = {
					factor = 0.9
					martial = 16
				}
				modifier = {
					factor = 0.9
					martial = 15
				}
				modifier = {
					factor = 0.9
					martial = 14
				}
				modifier = {
					factor = 0.9
					martial = 13
				}
				modifier = {
					factor = 0.9
					martial = 12
				}
				modifier = {
					factor = 0.9
					martial = 11
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 7 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 5 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 3 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 1.1
					NOT = { martial = 1 }
				}
				character_event = { id = 70012 }
			}
			
			10 = {	#character gets braver
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_fear
				}
				modifier = {
					factor = 1.1
					martial = 20
				}
				modifier = {
					factor = 1.1
					martial = 19
				}
				modifier = {
					factor = 1.1
					martial = 18
				}
				modifier = {
					factor = 1.1
					martial = 17
				}
				modifier = {
					factor = 1.1
					martial = 16
				}
				modifier = {
					factor = 1.1
					martial = 15
				}
				modifier = {
					factor = 1.1
					martial = 14
				}
				modifier = {
					factor = 1.1
					martial = 13
				}
				modifier = {
					factor = 1.1
					martial = 12
				}
				modifier = {
					factor = 1.1
					martial = 11
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 10 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 9 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 8 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 7 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 6 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 5 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 4 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 3 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 2 }
				}
				modifier = {
					factor = 0.9
					NOT = { martial = 1 }
				}
				character_event = { id = 70013 }
			}
			
			10 = { #character gains a Marttial Education level
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_martial
				}
				modifier = {
					factor = 0
					OR = {
						trait = brilliant_strategist
						NOR = {
							trait = misguided_warrior
							trait = tough_soldier
							trait = skilled_tactician
							trait = brilliant_strategist
						}
					}
				}
				if = {
					limit = { trait = skilled_tactician }
					character_event = { id = 70016 }
				}
				if = {
					limit = { trait = tough_soldier }
					character_event = { id = 70015 }
				}
				if = {
					limit = { trait = misguided_warrior }
					character_event = { id = 70014 }
				}
			}
			10 = { #character loses a Martial Education level
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_martial
				}
				modifier = {
					factor = 0
					OR = {
						trait = misguided_warrior
						NOR ={
							trait = misguided_warrior
							trait = tough_soldier
							trait = skilled_tactician
							trait = brilliant_strategist
						}
					}
				}
				if = {
					limit = { trait = tough_soldier }
					character_event = { id = 70019 }
				}
				if = {
					limit = { trait = skilled_tactician }
					character_event = { id = 70018 }
				}
				if = {
					limit = { trait = brilliant_strategist }
					character_event = { id = 70017 }
				}
			}
			2 = { #character becomes homosexual
				modifier = {
					factor = 0
					OR = {
						trait = homosexual
						trait = eunuch
						trait = celibate
						has_character_flag = attending_tournament_gay
					}
				}
				modifier = {
					factor = 1.1
					trait = drunkard
				}
				modifier = {
					factor = 1.33
					trait = hedonist
				}
				modifier = {
					factor = 1.1
					trait = lustful
				}
				modifier = {
					factor = 0.5
					trait = temperate
				}
				modifier = {
					factor = 0.33
					trait = chaste
				}
				modifier = {
					factor = 0.33
					trait = zealous
				}
				character_event = { id = 70023 }				
			}
			2 = { #character becomes syphilitic
				modifier = {
					factor = 0
					OR = {
						has_character_flag = attending_tournament_syph
						has_character_flag = spectating_tournament_syph
						trait = eunuch
						trait = celibate
						trait = syphilitic
					}
				}
				modifier = {
					factor = 1.1
					trait = drunkard
				}
				modifier = {
					factor = 2
					trait = hedonist
				}
				modifier = {
					factor = 1.33
					trait = lustful
				}
				modifier = {
					factor = 0.5
					trait = temperate
				}
				modifier = {
					factor = 0.33
					trait = chaste
				}
				modifier = {
					factor = 0.33
					trait = zealous
				}
				character_event = { id = 70024 }
			}
			3 = { #character becomes drunkard
				modifier = {
					factor = 0
					OR = {
						trait = drunkard
						has_character_flag = attending_tournament_drunk
					}
				}
				modifier = {
					factor = 1.33
					trait = gluttonous
				}
				modifier = {
					factor = 1.1
					trait = lustful
				}
				modifier = {
					factor = 0.33
					trait = temperate
				}
				modifier = {
					factor = 0.5
					trait = chaste
				}
				character_event = { id = 70025 }
			}
			3 = { #character becomes duelist
				modifier = {
					factor = 0
					OR = {
						has_dlc = "Way of Life" 					
						has_character_flag = attending_tournament_duelist
						NOT = { martial = 5 }					
						trait = content
						trait = kind
						trait = craven
						is_weak_trigger = yes
						lifestyle_traits = 1					
					}
				}
				modifier = {
					factor = 1.33
					trait = diligent
				}
				modifier = {
					factor = 1.33
					trait = wroth
				}
				modifier = {
					factor = 1.33
					trait = brave
				}
				modifier = {
					factor = 1.33
					is_strong_trigger = yes
				}
				modifier = {
					factor = 1.33
					martial = 10
				}
				modifier = {
					factor = 1.33
					martial = 15
				}
				modifier = {
					factor = 1.33
					martial = 20
				}
				character_event = { id = 70026 }
			}
			5 = { #character pursues a romance
				modifier = {
					factor = 0					
					has_character_flag = tournament_romance
				}
				modifier = {
					factor = 0					
					OR = {						
						trait = imbecile						
						trait = celibate
					}
				}				
				modifier = {
					factor = 0
					has_lover = yes
					NOR = {
						trait = lustful
						trait = hedonist
						trait = deceitful
						trait = seducer
						trait = seductress							
					}
				}
				modifier = {
					factor = 0.1					
					OR = {
						trait = ugly
						trait = clubfooted
						trait = dwarf
						trait = hunchback						
						trait = inbred						
					}
				}				
				modifier = {
					factor = 2
					trait = hedonist
				}
				modifier = {
					factor = 2
					trait = lustful
				}
				modifier = {
					factor = 2
					trait = fair
				}
				modifier = {
					factor = 2
					trait = tall
				}
				modifier = {
					factor = 2
					is_strong_trigger = yes
				}
				modifier = {
					factor = 1.33
					trait = poet
				}
				modifier = {
					factor = 1.33
					trait = brave
				}
				modifier = {
					factor = 1.25
					trait = diligent
				}
				modifier = {
					factor = 1.25
					OR = {
						trait = quick
						trait = shrewd
					}
				}
				modifier = {
					factor = 1.25
					trait = genius
				}
				modifier = {
					factor = 1.25
					trait = proud
				}
				modifier = {
					factor = 1.25
					trait = gregarious
				}
				modifier = {
					factor = 1.25
					OR = {
						trait = crusader
						trait = mujahid
						trait = holy_crusader
						trait = viking
						trait = varangian
						trait = scarred
						trait = duelist
					}
				}
				modifier = {
					factor = 1.1
					NOT = { age = 20 }
				}
				modifier = {
					factor = 1.1
					NOT = { age = 25 }
				}
				modifier = {
					factor = 0.8
					age = 35
				}
				modifier = {
					factor = 0.66
					age = 40
				}
				modifier = {
					factor = 0.66
					age = 45
				}
				modifier = {
					factor = 1.1
					martial = 10
				}
				modifier = {
					factor = 1.1
					martial = 13
				}
				modifier = {
					factor = 1.1
					martial = 16
				}
				modifier = {
					factor = 1.1
					martial = 19
				}
				modifier = {
					factor = 1.1
					martial = 22
				}
				modifier = {
					factor = 0.5
					trait = harelip
				}
				modifier = {
					factor = 0.5
					trait = lisp
				}
				modifier = {
					factor = 0.66
					is_married = yes
				}
				modifier = {
					factor = 0
					is_married = yes
					any_spouse = {
						reverse_opinion = { who = ROOT value = 0 }
					}
				}
				modifier = {
					factor = 0.5
					trait = chaste
				}
				modifier = {
					factor = 0.5
					trait = gluttonous
				}
				modifier = {
					factor = 0.66
					OR = {
						trait = slow
						trait = dull
					}
				}
				modifier = {
					factor = 0.5
					trait = craven
				}
				modifier = {
					factor = 0.8
					trait = gardener
				}
				modifier = {
					factor = 0.8
					trait = shy
				}
				modifier = {
					factor = 0.8
					trait = cruel
				}
				modifier = {
					factor = 0.8
					trait = wroth
				}
				modifier = {
					factor = 3
					trait = homosexual
				}
				character_event = { id = FemRule.225 }
			}
			10 = { #female contestant draws flak
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_sexism
				}
				modifier = {
					factor = 0
					is_female = no
				}
				modifier = {
					factor = 1.5
					trait = proud
				}
				modifier = {
					factor = 1.25
					trait = wroth
				}
				modifier = {
					factor = 1.25
					trait = cruel
				}
				modifier = {
					factor = 1.25
					trait = zealous
				}
				modifier = {
					factor = 1.5
					trait = ambitious
				}
				modifier = {
					factor = 1.25
					trait = gregarious
				}
				modifier = {
					factor = 0.8
					trait = tall
				}
				modifier = {
					factor = 0.8
					is_strong_trigger = yes
				}
				modifier = {
					factor = 0.8
					trait = humble
				}
				modifier = {
					factor = 0.8
					trait = shy
				}
				modifier = {
					factor = 0.66
					martial = 20
				}
				modifier = {
					factor = 0.66
					martial = 25
				}	
				character_event = { id = FemRule.218 }
			}
			10 = { #character gains intrigue
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_intrigue
				}
				modifier = {
					factor = 1.5
					trait = elusive_shadow
				}
				modifier = {
					factor = 1.1
					trait = intricate_webweaver
				}
				modifier = {
					factor = 0.9
					trait = flamboyant_schemer
				}
				modifier = {
					factor = 0.8
					trait = amateurish_plotter
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = elusive_shadow
						trait = intricate_webweaver
						trait = flamboyant_schemer
						trait = amateurish_plotter
					}
				}
				modifier = {
					factor = 1.5
					trait = deceitful
				}
				modifier = {
					factor = 0.9
					trait = honest
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				character_event = { id = 70027 }
			}
			10 = { #character loses intrigue
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_intrigue
				}
				modifier = {
					factor = 0.8
					trait = elusive_shadow
				}
				modifier = {
					factor = 0.9
					trait = intricate_webweaver
				}
				modifier = {
					factor = 1.1
					trait = flamboyant_schemer
				}
				modifier = {
					factor = 1.5
					trait = amateurish_plotter
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = elusive_shadow
						trait = intricate_webweaver
						trait = flamboyant_schemer
						trait = amateurish_plotter					
					}
				}
				modifier = {
					factor = 0.9
					trait = deceitful
				}
				modifier = {
					factor = 1.5
					trait = honest
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				character_event = { id = 70028 }
			}
			10 = { #character gains stewardship
				modifier = {
					factor = 0 
					OR = {
						has_character_flag = attending_tournament_stew						
						is_ruler = no
					}
				}
				modifier = {
					factor = 1.5
					trait = midas_touched
				}
				modifier = {
					factor = 1.1
					trait = fortune_builder
				}
				modifier = {
					factor = 0.9
					trait = thrifty_clerk
				}
				modifier = {
					factor = 0.8
					trait = indulgent_wastrel
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = midas_touched
						trait = fortune_builder
						trait = thrifty_clerk
						trait = indulgent_wastrel						
					}
				}
				modifier = {
					factor = 1.5
					trait = diligent
				}
				modifier = {
					factor = 0.9
					trait = slothful
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				character_event = { id = 70029 }
			}
			10 = { #character loses stewardship				
				modifier = {
					factor = 0 
					OR = {
						has_character_flag = attending_tournament_stew
						has_character_flag = spectating_tournament_stew
						is_ruler = no
					}
				}
				modifier = {
					factor = 0.8
					trait = midas_touched
				}
				modifier = {
					factor = 0.9
					trait = fortune_builder
				}
				modifier = {
					factor = 1.1
					trait = thrifty_clerk
				}
				modifier = {
					factor = 1.5
					trait = indulgent_wastrel
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = midas_touched
						trait = fortune_builder
						trait = thrifty_clerk
						trait = indulgent_wastrel
					}
				}
				modifier = {
					factor = 0.9
					trait = diligent
				}
				modifier = {
					factor = 1.5
					trait = slothful
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				character_event = { id = 70030 }
			}
			10 = { #character gains diplomacy
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_dip
				}
				modifier = {
					factor = 1.5
					trait = grey_eminence
				}
				modifier = {
					factor = 1.1
					trait = charismatic_negotiator
				}
				modifier = {
					factor = 0.9
					trait = underhanded_rogue
				}
				modifier = {
					factor = 0.8
					trait = naive_appeaser
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = grey_eminence
						trait = charismatic_negotiator
						trait = underhanded_rogue
						trait = naive_appeaser					
					}
				}
				modifier = {
					factor = 1.5
					trait = gregarious
				}
				modifier = {
					factor = 0.9
					trait = shy
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				character_event = { id = 70031 }
			}
			10 = { #character loses diplomacy
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_dip
				}
				modifier = {
					factor = 0.8
					trait = grey_eminence
				}
				modifier = {
					factor = 0.9
					trait = charismatic_negotiator
				}
				modifier = {
					factor = 1.1
					trait = underhanded_rogue
				}
				modifier = {
					factor = 1.5
					trait = naive_appeaser
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = grey_eminence
						trait = charismatic_negotiator
						trait = underhanded_rogue
						trait = naive_appeaser						
					}
				}
				modifier = {
					factor = 0.9
					trait = gregarious
				}
				modifier = {
					factor = 1.5
					trait = shy
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				character_event = { id = 70032 }
			}
		}
		repeat_event = { id = 70100 days = 5 random = 5 }
	}
}

#looping trigger event for spectators
character_event = {
	id = 70200
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		has_character_flag = spectating_tournament		
		top_liege = {
			has_character_modifier = holding_epic_tournament
			has_character_flag = tournament_begins
		}		
	}
	
	immediate = {
		random_list = {
			500 = {	#no event 
			}			
			2 = { #character becomes syphilitic
				modifier = {
					factor = 0
					OR = {
						has_character_flag = attending_tournament_syph
						has_character_flag = spectating_tournament_syph
						trait = eunuch
						trait = celibate
						trait = syphilitic
					}
				}
				modifier = {
					factor = 1.1
					trait = drunkard
				}
				modifier = {
					factor = 2
					trait = hedonist
				}
				modifier = {
					factor = 1.33
					trait = lustful
				}
				modifier = {
					factor = 0.5
					trait = temperate
				}
				modifier = {
					factor = 0.33
					trait = chaste
				}
				modifier = {
					factor = 0.33
					trait = zealous
				}
				log = "Tournament: [This.GetBestName] catches syphillis."
				character_event = { id = 70024 }
			}
			10 = { #character gains stewardship
				modifier = {
					factor = 0 
					OR = {
						has_character_flag = attending_tournament_stew						
						is_ruler = no
					}
				}
				modifier = {
					factor = 1.5
					trait = midas_touched
				}
				modifier = {
					factor = 1.1
					trait = fortune_builder
				}
				modifier = {
					factor = 0.9
					trait = thrifty_clerk
				}
				modifier = {
					factor = 0.8
					trait = indulgent_wastrel
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = midas_touched
						trait = fortune_builder
						trait = thrifty_clerk
						trait = indulgent_wastrel						
					}
				}
				modifier = {
					factor = 1.5
					trait = diligent
				}
				modifier = {
					factor = 0.9
					trait = slothful
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				log = "Tournament: [This.GetBestName] gains stewardship."
				character_event = { id = 70029 }
			}
			10 = { #character loses stewardship				
				modifier = {
					factor = 0 
					OR = {
						has_character_flag = attending_tournament_stew						
						is_ruler = no
					}
				}
				modifier = {
					factor = 0.8
					trait = midas_touched
				}
				modifier = {
					factor = 0.9
					trait = fortune_builder
				}
				modifier = {
					factor = 1.1
					trait = thrifty_clerk
				}
				modifier = {
					factor = 1.5
					trait = indulgent_wastrel
				}
				modifier = {
					factor = 1.5
					NOR = {
						trait = midas_touched
						trait = fortune_builder
						trait = thrifty_clerk
						trait = indulgent_wastrel						
					}
				}
				modifier = {
					factor = 0.9
					trait = diligent
				}
				modifier = {
					factor = 1.5
					trait = slothful
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				log = "Tournament: [This.GetBestName] loses stewardship."
				character_event = { id = 70030 }
			}
			10 = { #character gains diplomacy
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_dip
				}
				modifier = {
					factor = 1.5
					trait = grey_eminence
				}
				modifier = {
					factor = 1.1
					trait = charismatic_negotiator
				}
				modifier = {
					factor = 0.9
					trait = underhanded_rogue
				}
				modifier = {
					factor = 0.8
					trait = naive_appeaser
				}
				modifier = {
					factor = 1.5
					NOT = {
						OR = {
							trait = grey_eminence
							trait = charismatic_negotiator
							trait = underhanded_rogue
							trait = naive_appeaser
						}
					}
				}
				modifier = {
					factor = 1.5
					trait = gregarious
				}
				modifier = {
					factor = 0.9
					trait = shy
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				log = "Tournament: [This.GetBestName] gains diplomacy."
				character_event = { id = 70031 }
			}
			10 = { #character loses diplomacy
				modifier = {
					factor = 0
					has_character_flag = attending_tournament_dip
				}
				modifier = {
					factor = 0.8
					trait = grey_eminence
				}
				modifier = {
					factor = 0.9
					trait = charismatic_negotiator
				}
				modifier = {
					factor = 1.1
					trait = underhanded_rogue
				}
				modifier = {
					factor = 1.5
					trait = naive_appeaser
				}
				modifier = {
					factor = 1.5
					NOT = {
						OR = {
							trait = grey_eminence
							trait = charismatic_negotiator
							trait = underhanded_rogue
							trait = naive_appeaser
						}
					}
				}
				modifier = {
					factor = 0.9
					trait = gregarious
				}
				modifier = {
					factor = 1.5
					trait = shy
				}
				modifier = {
					factor = 4
					martial = 10
				}
				modifier = {
					factor = 0.8
					NOT = {
						martial = 5
					}
				}
				log = "Tournament: [This.GetBestName] loses diplomacy."
				character_event = { id = 70032 }
			}
			10 = { #lady becomes proud
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_pride
						trait = proud
					}
				}
				modifier = {
					factor = 0.25
					trait = humble
				}
				modifier = {
					factor = 0.8
					trait = chaste
				}
				modifier = {
					factor = 0.8
					trait = temperate
				}
				modifier = {
					factor = 0.8
					trait = content
				}
				modifier = {
					factor = 0.8
					trait = kind
				}
				modifier = {
					factor = 0.8
					trait = slothful
				}
				modifier = {
					factor = 0.8
					trait = shy
				}				
				modifier = {
					factor = 1.25
					trait = envious
				}
				modifier = {
					factor = 1.25
					trait = ambitious
				}
				modifier = {
					factor = 1.25
					trait = arbitrary
				}
				modifier = {
					factor = 1.25
					trait = diligent
				}
				modifier = {
					factor = 1.25
					trait = charitable
				}
				modifier = {
					factor = 1.25
					trait = gregarious
				}
				modifier = { 
					factor = 1.1
					trait = fair
				}
				modifier = {
					factor = 1.1
					OR = {
						trait = quick
						trait = shrewd
					}
				}
				modifier = {
					factor = 1.1
					trait = genius
				}
				modifier = {
					factor = 1.1
					trait = tall
				}
				modifier = {
					factor = 0.5
					trait = ugly
				}
				modifier = {
					factor = 0.5
					trait = dwarf
				}
				modifier = {
					factor = 0.5
					trait = hunchback
				}			
				log = "Tournament: [This.GetBestName] becomes proud."
				character_event = { id = FemRule.210 }
			}
			10 = { #lady becomes humble
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_pride
						trait = humble
					}
				}
				modifier = {
					factor = 0.25
					trait = proud
				}
				modifier = {
					factor = 0.8
					trait = envious
				}
				modifier = {
					factor = 0.8
					trait = ambitious
				}
				modifier = {
					factor = 0.8
					trait = arbitrary
				}
				modifier = {
					factor = 0.8
					trait = diligent
				}
				modifier = {
					factor = 0.8
					trait = charitable
				}
				modifier = {
					factor = 0.8
					trait = gregarious
				}
				modifier = {
					factor = 0.67
					trait = fair
				}
				modifier = {
					factor = 0.67
					OR = {
						trait = quick
						trait = shrewd
					}
				}
				modifier = {
					factor = 0.67
					trait = genius
				}
				modifier = {
					factor = 0.67
					trait = tall
				}
				modifier = {
					factor = 4
					trait = humble
				}
				modifier = {
					factor = 2
					OR = {
						trait = dwarf
						trait = hunchback
						trait = clubfooted
						trait = harelip
					}
				}
				modifier = {
					factor = 1.25
					trait = chaste
				}
				modifier = {
					factor = 1.25
					trait = temperate
				}
				modifier = {
					factor = 1.5
					trait = content
				}
				modifier = {
					factor = 1.25
					trait = kind
				}
				modifier = {
					factor = 1.25
					trait = slothful
				}
				modifier = {
					factor = 1.5
					trait = shy
				}
				log = "Tournament: [This.GetBestName] becomes humble."
				character_event = { id = FemRule.211 }
			}
			10 = { #lady becomes gregarious
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_shyness
						trait = gregarious
					}
				}				
				modifier = {
					factor = 0.25
					trait = shy
				}
				modifier = {
					factor = 1.5
					OR = {
						trait = fair
						trait = wroth
						trait = ambitious
						trait = proud
					}
				}
				modifier = {
					factor = 0.8
					OR = {
						trait = ugly
						trait = dwarf
						trait = hunchback
						trait = harelip
						trait = lisp
					}
				}
				modifier = {
					factor = 0.8
					trait = chaste
				}
				modifier = {
					factor = 0.8
					trait = greedy
				}
				modifier = {
					factor = 0.8
					trait = honest
				}
				modifier = {
					factor = 0.8
					trait = cynical
				}
				modifier = {
					factor = 0.8
					trait = scholar
				}
				modifier = {
					factor = 0.8
					trait = gardener
				}
				modifier = {
					factor = 0.8
					trait = hunter
				}
				modifier = {
					factor = 0.8
					trait = falconer
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 10 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 9 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 8 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 7 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 6 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 5 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 4 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 3 }
				}
				modifier = {
					factor = 0.9
					NOT = { diplomacy = 2 }
				}	
				log = "Tournament: [This.GetBestName] becomes gregarious."
				character_event = { id = FemRule.212 }
			}
			10 = { #lady becomes shy
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_shyness
						trait = shy
					}
				}	
				modifier = {
					factor = 0.25
					trait = gregarious
				}				
				modifier = {
					factor = 1.25
					trait = humble
				}
				modifier = {
					factor = 1.25
					trait = craven
				}
				modifier = {
					factor = 2
					OR = {
						trait = ugly
						trait = dwarf
						trait = hunchback
						trait = harelip
						trait = lisp
					}
				}
				modifier = {
					factor = 0.8
					trait = lustful
				}
				modifier = {
					factor = 0.8
					trait = kind
				}
				modifier = {
					factor = 0.8
					trait = deceitful
				}
				modifier = {
					factor = 0.8
					trait = trusting
				}
				modifier = {
					factor = 0.8
					trait = hedonist
				}
				modifier = {
					factor = 0.8
					trait = poet
				}
				modifier = {
					factor = 0.9
					diplomacy = 11
				}
				modifier = {
					factor = 0.9
					diplomacy = 13
				}
				modifier = {
					factor = 0.9
					diplomacy = 15
				}
				modifier = {
					factor = 0.9
					diplomacy = 17
				}
				modifier = {
					factor = 0.9
					diplomacy = 19
				}
				modifier = {
					factor = 0.9
					diplomacy = 21
				}
				log = "Tournament: [This.GetBestName] becomes shy."
				character_event = { id = FemRule.213 }
			}
			10 = { #lady becomes honest
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_honesty
						trait = honest
					}
				}
				modifier = {
					factor = 0.25
					trait = deceitful
				}				
				modifier = {
					factor = 1.25
					trait = trusting
				}
				modifier = {
					factor = 1.25
					trait = charitable
				}
				modifier = {
					factor = 1.25
					trait = proud
				}
				modifier = {
					factor = 1.25
					trait = content
				}
				modifier = {
					factor = 1.25
					trait = diligent
				}
				modifier = {
					factor = 1.25
					is_strong_trigger = yes
				}
				modifier = {
					factor = 1.25
					trait = tall
				}
				modifier = {
					factor = 0.8
					trait = dwarf
				}
				modifier = {
					factor = 0.8
					trait = hunchback
				}
				modifier = {
					factor = 0.8
					is_weak_trigger = yes
				}
				modifier = {
					factor = 0.8
					trait = cynical
				}
				modifier = {
					factor = 0.8
					trait = paranoid
				}
				modifier = {
					factor = 0.8
					trait = ambitious
				}
				modifier = {
					factor = 0.8
					trait = envious
				}
				log = "Tournament: [This.GetBestName] becomes honest."
				character_event = { id = FemRule.214 }
			}
			10 = { #lady becomes deceitful
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_honesty
						trait = deceitful
					}
				}
				modifier = {
					factor = 0.25
					trait = honest
				}				
				modifier = {
					factor = 0.8
					trait = trusting
				}
				modifier = {
					factor = 0.8
					trait = charitable
				}
				modifier = {
					factor = 0.8
					trait = proud
				}
				modifier = {
					factor = 0.8
					trait = content
				}
				modifier = {
					factor = 0.8
					trait = diligent
				}
				modifier = {
					factor = 0.8
					is_strong_trigger = yes
				}
				modifier = {
					factor = 0.8
					trait = tall
				}
				modifier = {
					factor = 1.25
					trait = dwarf
				}
				modifier = {
					factor = 1.25
					trait = hunchback
				}
				modifier = {
					factor = 1.25
					is_weak_trigger = yes
				}
				modifier = {
					factor = 1.25
					trait = cynical
				}
				modifier = {
					factor = 1.25
					trait = paranoid
				}
				modifier = {
					factor = 1.25
					trait = ambitious
				}
				modifier = {
					factor = 1.25
					trait = envious
				}
				log = "Tournament: [This.GetBestName] becomes deceitful."
				character_event = { id = FemRule.215 }
			}
			10 = { #lady becomes lustful
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_lust
						trait = lustful
						trait = celibate
					}
				}
				modifier = {
					factor = 0.25
					trait = chaste
				}				
				modifier = {
					factor = 1.25
					trait = trusting
				}
				modifier = {
					factor = 1.25
					trait = kind
				}
				modifier = {
					factor = 1.25
					trait = proud
				}
				modifier = {
					factor = 1.25
					trait = wroth
				}
				modifier = {
					factor = 1.25
					trait = greedy
				}
				modifier = {
					factor = 1.25
					trait = poet
				}
				modifier = {
					factor = 1.25
					trait = mystic
				}
				modifier = {
					factor = 1.25
					trait = diligent
				}
				modifier = {
					factor = 0.8
					trait = temperate
				}
				modifier = {
					factor = 0.8
					trait = patient
				}
				modifier = {
					factor = 0.8
					trait = slothful
				}
				modifier = {
					factor = 0.8
					trait = cynical
				}
				modifier = {
					factor = 0.8
					trait = paranoid
				}
				modifier = {
					factor = 0.8
					trait = ambitious
				}
				modifier = {
					factor = 0.8
					trait = charitable
				}
				modifier = {
					factor = 0.8
					trait = gardener
				}
				modifier = {
					factor = 0.8
					trait = duelist
				}
				modifier = {
					factor = 0.6
					OR = {
						trait = ugly
						trait = dwarf
						trait = hunchback
						trait = harelip
						trait = clubfooted
					}
				}
				log = "Tournament: [This.GetBestName] becomes lustful."				
				character_event = { id = FemRule.216 }
			}
			10 = { #lady becomes chaste
				modifier = {
					factor = 0
					OR = {
						is_female = no
						has_character_flag = lady_lust
						trait = chaste
						trait = hedonist
					}
				}
				modifier = {
					factor = 0.25
					trait = lustful
				}				
				modifier = {
					factor = 0.4
					trait = hedonist
				}
				modifier = {
					factor = 0.8
					trait = fair
				}
				modifier = {
					factor = 0.8
					trait = trusting
				}
				modifier = {
					factor = 0.8
					trait = kind
				}
				modifier = {
					factor = 0.8
					trait = proud
				}
				modifier = {
					factor = 0.8
					trait = wroth
				}
				modifier = {
					factor = 0.8
					trait = greedy
				}
				modifier = {
					factor = 0.8
					trait = poet
				}
				modifier = {
					factor = 0.8
					trait = mystic
				}
				modifier = {
					factor = 0.8
					trait = diligent
				}
				modifier = {
					factor = 1.25
					trait = temperate
				}
				modifier = {
					factor = 1.25
					trait = patient
				}
				modifier = {
					factor = 1.25
					trait = slothful
				}
				modifier = {
					factor = 1.25
					trait = cynical
				}
				modifier = {
					factor = 1.25
					trait = paranoid
				}
				modifier = {
					factor = 1.25
					trait = ambitious
				}
				modifier = {
					factor = 1.25
					trait = charitable
				}
				modifier = {
					factor = 1.25
					trait = gardener
				}
				modifier = {
					factor = 1.25
					trait = duelist
				}
				modifier = {
					factor = 2
					OR = {
						trait = ugly
						trait = dwarf
						trait = hunchback
						trait = harelip
						trait = clubfooted
					}
				}
				log = "Tournament: [This.GetBestName] becomes chaste."		
				character_event = { id = FemRule.217 }
			}
		}	
		repeat_event = { id = 70200 days = 5 random = 5 }
	}
}


### DEATH & INJURY OF PARTICIPANTS

# Message about death
character_event = {
	id = 70038
	title = TOURNAMENTTITLE
	desc = EVTDESC70038
	picture = GFX_evt_death

	is_triggered_only = yes

	trigger = {
		ai = no
		NOT = { has_character_flag = no_msg_death }
	}

	option = {
		name = "EVTOPTA70038"
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_death
	}
}

# Message about maimed
character_event = {
	id = 70039
	title = TOURNAMENTTITLE
	desc = EVTDESC70039
	picture = GFX_evt_emissary

	is_triggered_only = yes

	trigger = {
		ai = no
		NOT = { has_character_flag = no_msg_maimed }
		FROM = {
			OR = {
				dynasty = ROOT
				is_close_relative = ROOT
				is_ruler = yes
				ROOT = { any_courtier = { character = PREVPREV } }
			}
		}
	}

	option = {
		name = "EVTOPTA70038"
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_maimed
	}
}

# Message about wounded
character_event = {
	id = 70040
	title = TOURNAMENTTITLE
	desc = EVTDESC70040
	picture = GFX_evt_emissary

	trigger = {
		NOT = { has_character_flag = no_msg_wounded }
		FROM = {
			OR = {
				is_close_relative = ROOT
				higher_tier_than = BARON
				ROOT = { any_courtier = { character = PREVPREV } }
			}
		}
	}

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70038"
	}
	option = {
		name = "EVTOPTB70038"
		set_character_flag = no_msg_wounded
	}
}

# Character is killed
character_event = {
	id = 70009
	title = TOURNAMENTTITLE
	desc = EVTDESC70009
	picture = GFX_evt_death

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_wound }
		top_liege = {
			has_character_flag = tournament_begins
		}
	}	

	immediate = {
		clr_character_flag = attending_tournament
	}

	option = {
		name = "EVTOPTA70009"
		death = {
			death_reason = death_battle
		}
		hidden_tooltip = {
			if = {
				limit = {
					top_liege = { NOT = { character = ROOT } }
					OR = {
						NOT = { has_character_flag = championing_liege_lady }
						top_liege = { NOT = { is_liege_of = ROOT } }
					}
				}
				top_liege = { character_event = { id = 70038 } }
			}
		}
		hidden_tooltip = {
			if = {
				limit = { has_character_flag = championing_liege_lady }
				clr_character_flag = championing_liege_lady
				liege = { character_event = { id = FemRule.202 } }
			}
		}
	}
}

# Character is maimed
character_event = {
	id = 70010
	title = TOURNAMENTTITLE
	desc = EVTDESC70010
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		can_be_maimed_trigger = yes
		NOT = {
			has_character_flag = attending_tournament_wound			
		}
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		clr_character_flag = attending_tournament
		remove_do_not_disturb_effect = yes
	}

	option = {
		name = "EVTOPTA70010"
		add_maimed_trait_effect = yes
		hidden_tooltip = {
			if = {
				limit = {
					top_liege = { NOT = { character = ROOT } }
					OR = {
						NOT = { has_character_flag = championing_liege_lady }
						top_liege = { NOT = { is_liege_of = ROOT } }
					}
				}
				top_liege = { character_event = { id = 70039 } }
			}
		}
		hidden_tooltip = {
			if = {
				limit = { has_character_flag = championing_liege_lady }
				clr_character_flag = championing_liege_lady
				liege = { character_event = { id = FemRule.203 } }
			}
		}
	}
}

# Character is wounded
character_event = {
	id = 70011
	title = TOURNAMENTTITLE
	desc = EVTDESC70011
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		can_be_maimed_trigger = yes
		NOR = {
			trait = wounded			
			has_character_flag = attending_tournament_wound
		}
		top_liege = {
			has_character_flag = tournament_begins
		}
	}	

	immediate = {
		set_character_flag = attending_tournament_wound
	}

	option = {
		name = "EVTOPTA70011"
		add_trait = wounded
		hidden_tooltip = {
			if = {
				limit = {
					top_liege = { NOT = { character = ROOT } }
					OR = {
						NOT = { has_character_flag = championing_liege_lady }
						top_liege = { NOT = { is_liege_of = ROOT } }
					}
				}
				top_liege = { character_event = { id = 70040 } }
			}
		}
		hidden_tooltip = {
			if = {
				limit = { has_character_flag = championing_liege_lady }
				clr_character_flag = championing_liege_lady
				liege = { character_event = { id = FemRule.204 } }
			}
		}
	}
}

### TOURNAMENT PARTICIPANT EVENTS

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

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_fear }
		NOR = { 
			trait = craven 
			trait = berserker
		}
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		set_character_flag = attending_tournament_fear
	}

	option = {
		name = "EVTOPTA70012"
		if = {
			limit = { trait = brave }
			remove_trait = brave
			break = yes
		}
		add_trait = craven
	}
}

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

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_fear }
		NOT = { trait = brave }
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	mean_time_to_happen = {
		months = 250
		modifier = {
			factor = 0.9
			martial = 20
		}
		modifier = {
			factor = 0.9
			martial = 19
		}
		modifier = {
			factor = 0.9
			martial = 18
		}
		modifier = {
			factor = 0.9
			martial = 17
		}
		modifier = {
			factor = 0.9
			martial = 16
		}
		modifier = {
			factor = 0.9
			martial = 15
		}
		modifier = {
			factor = 0.9
			martial = 14
		}
		modifier = {
			factor = 0.9
			martial = 13
		}
		modifier = {
			factor = 0.9
			martial = 12
		}
		modifier = {
			factor = 0.9
			martial = 11
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 10 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 9 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 8 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 7 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 6 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 5 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 4 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 3 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 2 }
		}
		modifier = {
			factor = 1.1
			NOT = { martial = 1 }
		}
	}

	immediate = {
		set_character_flag = attending_tournament_fear
	}

	option = {
		name = "EVTOPTA70013"
		if = {
			limit = { trait = craven }
			remove_trait = craven
			break = yes
		}
		add_trait = brave
	}
}

# Character becomes tough soldier
character_event = {
	id = 70014
	title = TOURNAMENTTITLE
	desc = EVTDESC70014
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_MartialEd }
		trait = misguided_warrior
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		set_character_flag = attending_tournament_MartialEd
	}

	option = {
		name = "EVTOPTA70014"
		remove_trait = misguided_warrior
		add_trait = tough_soldier
	}
}

# Character becomes skilled tactician
character_event = {
	id = 70015
	title = TOURNAMENTTITLE
	desc = EVTDESC70015
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_MartialEd }
		trait = tough_soldier
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		set_character_flag = attending_tournament_MartialEd
	}

	option = {
		name = "EVTOPTA70015"
		remove_trait = tough_soldier
		add_trait = skilled_tactician
	}
}

# Character becomes brilliant strategist
character_event = {
	id = 70016
	title = TOURNAMENTTITLE
	desc = EVTDESC70016
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_MartialEd }
		trait = skilled_tactician
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		set_character_flag = attending_tournament_MartialEd
	}

	option = {
		name = "EVTOPTA70016"
		remove_trait = skilled_tactician
		add_trait = brilliant_strategist
	}
}

# Character becomes skilled tactician
character_event = {
	id = 70017
	title = TOURNAMENTTITLE
	desc = EVTDESC70017
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_MartialEd }
		trait = brilliant_strategist
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		set_character_flag = attending_tournament_MartialEd
	}

	option = {
		name = "EVTOPTA70017"
		remove_trait = brilliant_strategist
		add_trait = skilled_tactician
	}
}

# Character becomes tough soldier
character_event = {
	id = 70018
	title = TOURNAMENTTITLE
	desc = EVTDESC70018
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_MartialEd }
		trait = skilled_tactician
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		set_character_flag = attending_tournament_MartialEd
	}

	option = {
		name = "EVTOPTA70018"
		remove_trait = skilled_tactician
		add_trait = tough_soldier
	}
}

# Character becomes misguided warrior
character_event = {
	id = 70019
	title = TOURNAMENTTITLE
	desc = EVTDESC70019
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_MartialEd }
		trait = tough_soldier
		top_liege = {
			has_character_flag = tournament_begins
		}
	}

	immediate = {
		set_character_flag = attending_tournament_MartialEd
	}

	option = {
		name = "EVTOPTA70019"
		remove_trait = tough_soldier
		add_trait = misguided_warrior
	}
}

# Character becomes homosexual
character_event = {
	id = 70023
	title = TOURNAMENTTITLE
	desc = EVTDESC70023
	picture = GFX_evt_shadowy_cabal

	min_age = 16
	only_men = yes
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_gay }
		NOR = {
			trait = homosexual
			trait = celibate
		}
		NOT = { trait = eunuch }
	}


	immediate = {
		set_character_flag = attending_tournament_gay
	}

	option = {
		name = "EVTOPTA70023"
		add_trait = homosexual
	}
}

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

	min_age = 16
	only_men = yes
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		OR = {
			has_character_flag = attending_tournament
			has_character_flag = spectating_tournament
		}
		NOR = {
			has_character_flag = attending_tournament_syph			
			trait = syphilitic
			trait = celibate
		}
		NOT = { trait = eunuch }
	}

	immediate = {
		set_character_flag = attending_tournament_syph		
	}

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

# Character becomes drunkard
character_event = {
	id = 70025
	title = TOURNAMENTTITLE
	desc = EVTDESC70025
	picture = "GFX_evt_drunk"

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_drunk }
		NOT = {
			trait = drunkard
		}
	}

	immediate = {
		set_character_flag = attending_tournament_drunk
	}

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

# Character becomes duelist
character_event = {
	id = 70026
	title = TOURNAMENTTITLE
	desc = EVTDESC70026
	picture = "GFX_evt_melee"

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes
	lacks_dlc = "Way of Life"

	trigger = {		
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_duelist }
		martial = 5
		NOR = {
			trait = content
			trait = kind
			trait = craven
			is_weak_trigger = yes
			lifestyle_traits = 1
		}
	}

	immediate = {
		set_character_flag = attending_tournament_duelist
	}

	option = {
		name = "EVTOPTA70026"
		add_trait = duelist
	}
}

# Character gains intrigue
character_event = {
	id = 70027
	title = TOURNAMENTTITLE
	desc = EVTDESC70027
	picture = GFX_evt_whispers

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament	
		NOT = { has_character_flag = attending_tournament_intrigue }
	}

	immediate = {
		set_character_flag = attending_tournament_intrigue
	}

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

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

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		has_character_flag = attending_tournament
		NOT = { has_character_flag = attending_tournament_intrigue }
	}

	immediate = {
		set_character_flag = attending_tournament_intrigue
	}

	option = {
		name = "EVTOPTA70028"
		change_intrigue = -1
	}
}

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

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		is_ruler = yes
		OR = {
			has_character_flag = attending_tournament
			has_character_flag = spectating_tournament
		}
		NOT = { has_character_flag = attending_tournament_stew }
	}

	immediate = {
		set_character_flag = attending_tournament_stew
	}

	option = {
		name = "EVTOPTA70029"
		change_stewardship = 1
	}
}

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

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		is_ruler = yes
		OR = {
			has_character_flag = attending_tournament
			has_character_flag = spectating_tournament
		}
		NOT = { has_character_flag = attending_tournament_stew }		
	}

	immediate = {
		set_character_flag = attending_tournament_stew		
	}

	option = {
		name = "EVTOPTA70030"
		change_stewardship = -1
	}
}

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

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes 

	trigger = {
		OR = {
			has_character_flag = attending_tournament
				has_character_flag = spectating_tournament
			}
		NOT = { has_character_flag = attending_tournament_dip }
	}

	immediate = {
		set_character_flag = attending_tournament_dip		
	}

	option = {
		name = "EVTOPTA70031"
		change_diplomacy = 1
	}
}

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

	min_age = 16
	capable_only = yes
	prisoner = no
	is_triggered_only = yes

	trigger = {
		OR = {
			has_character_flag = attending_tournament
			has_character_flag = spectating_tournament
		}
		NOT = { has_character_flag = attending_tournament_dip }
	}

	immediate = {
		set_character_flag = attending_tournament_dip		
	}

	option = {
		name = "EVTOPTA70032"
		change_diplomacy = -1
	}
}

### TOURNAMENT CHAMPION EVENTS

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

	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = attending_tournament

	trigger = {
		top_liege = {
			had_character_flag = { flag = tournament_begins days = 50 }
			NOT = { has_character_flag = winner }
		}
		NOT = {
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				attribute_diff = {
					character = ROOT
					attribute = martial
					value = 5
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 1
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = tournament_begins days = 60 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = tournament_begins days = 70 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = tournament_begins days = 80 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = tournament_begins days = 90 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = tournament_begins days = 100 }
			}
		}
		modifier = {
			factor = 1.5
			trait = wounded
		}
		#This shouldn't happen at all, but still...
		modifier = {
			factor = 3
			is_maimed_trigger = yes
		}
		modifier = {
			factor = 1.5
			health_traits = 1
		}
		modifier = {
			factor = 0.75
			trait = duelist
		}
		modifier = {
			factor = 0.75
			trait = brave
		}
		modifier = {
			factor = 1.25
			trait = craven
		}
		modifier = {
			factor = 2
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 4 }
			}
		}
		modifier = {
			factor = 1.75
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 3 }
			}
		}
		modifier = {
			factor = 1.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 2 }
			}
		}
		modifier = {
			factor = 1.25
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 1 }
			}
		}
		modifier = {
			factor = 3
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				attribute_diff = { character = ROOT attribute = martial value = 4 }
			}
		}
		modifier = {
			factor = 2.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				attribute_diff = { character = ROOT attribute = martial value = 3 }
			}
		}
		modifier = {
			factor = 2
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				attribute_diff = { character = ROOT attribute = martial value = 2 }
			}
		}
		modifier = {
			factor = 1.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				attribute_diff = { character = ROOT attribute = martial value = 1 }
			}
		}
		modifier = {
			factor = 0.5
			NOT = {
				any_character = {
					has_character_flag = attending_tournament
					same_realm = ROOT
					NOT = { character = ROOT }
					martial = ROOT
				}
			}
		}
	}

	immediate = {
		set_character_flag = attending_tournament_event
		set_character_flag = tournament_winner
		top_liege = {
			set_character_flag = winner
		}
	}

	option = {
		name = "EVTOPTA70020"
		wealth = 100
		prestige = 300
		add_trait = tournament_winner
		if = {
			limit = {
				religion_group = muslim
			}
			piety = 50
		}
		hidden_tooltip = {
			if = {
				limit = {
					top_liege = { NOT = { character = ROOT } }
					OR = {
						NOT = { has_character_flag = championing_liege_lady }
						top_liege = { NOT = { is_liege_of = ROOT } }
					}
				}
				top_liege = { character_event = { id = 70034 } }
			}
		}
		hidden_tooltip = {
			if = {
				limit = { has_character_flag = championing_liege_lady }
				liege = { character_event = { id = FemRule.205 } }
				clr_character_flag = championing_liege_lady
			}
		}
	}
}

# Inform about winner
character_event = {
	id = 70034
	title = TOURNAMENTTITLE
	desc = EVTDESC70034
	picture = GFX_evt_joust

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70034"
		opinion = {
			modifier = opinion_tournament_winner
			who = FROM
			years = 20
		}
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_TOURNAMENT
				portrait = [From.GetID]
			}
		}
	}
}

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

	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = attending_tournament

	trigger = {
		NOT = { has_character_flag = tournament_winner }
		top_liege = {
			had_character_flag = { flag = tournament_begins days = 50 }
			had_character_flag = { flag = winner days = 1 }
			NOT = { has_character_flag = second_place }
		}
		NOT = {
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				attribute_diff = {
					character = ROOT
					attribute = martial
					value = 5
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 1
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = winner days = 10 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = winner days = 20 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = winner days = 30 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = winner days = 40 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = winner days = 50 }
			}
		}
		modifier = {
			factor = 1.5
			trait = wounded
		}
		modifier = {
			factor = 3
			is_maimed_trigger = yes
		}
		modifier = {
			factor = 1.5
			health_traits = 1
		}
		modifier = {
			factor = 0.75
			trait = duelist
		}
		modifier = {
			factor = 0.75
			trait = brave
		}
		modifier = {
			factor = 1.25
			trait = craven
		}
		modifier = {
			factor = 2
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 4 }
			}
		}
		modifier = {
			factor = 1.75
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 3 }
			}
		}
		modifier = {
			factor = 1.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 2 }
			}
		}
		modifier = {
			factor = 1.25
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 1 }
			}
		}
		modifier = {
			factor = 3
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				attribute_diff = { character = ROOT attribute = martial value = 4 }
			}
		}
		modifier = {
			factor = 2.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				attribute_diff = { character = ROOT attribute = martial value = 3 }
			}
		}
		modifier = {
			factor = 2
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				attribute_diff = { character = ROOT attribute = martial value = 2 }
			}
		}
		modifier = {
			factor = 1.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				attribute_diff = { character = ROOT attribute = martial value = 1 }
			}
		}
		modifier = {
			factor = 0.5
			NOT = {
				any_character = {
					has_character_flag = attending_tournament
					same_realm = ROOT
					NOT = { character = ROOT }
					NOT = { has_character_flag = tournament_winner }
					martial = ROOT
				}
			}
		}
	}

	immediate = {
		set_character_flag = attending_tournament_event
		set_character_flag = tournament_second_place
		top_liege = {
			set_character_flag = second_place
		}
	}

	option = {
		name = "EVTOPTA70021"
		wealth = 75
		prestige = 250
		if = {
			limit = {
				religion_group = muslim
			}
			piety = 25
		}
		hidden_tooltip = {
			if = {
				limit = {
					top_liege = { NOT = { character = ROOT } }
					OR = {
						NOT = { has_character_flag = championing_liege_lady }
						top_liege = { NOT = { is_liege_of = ROOT } }
					}
				}
				top_liege = { character_event = { id = 70035 } }
			}
		}
		hidden_tooltip = {
			if = {
				limit = { has_character_flag = championing_liege_lady }
				liege = { character_event = { id = FemRule.206 } }
				clr_character_flag = championing_liege_lady
			}
		}
	}
}

# Inform about second place
character_event = {
	id = 70035
	title = TOURNAMENTTITLE
	desc = EVTDESC70035
	picture = GFX_evt_joust

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70035"
		opinion = {
			modifier = opinion_tournament_second_place
			who = FROM
			years = 15
		}
		if = {
			limit = {
				OR = {
					has_character_flag = beauty_winner
					religion_group = muslim
				}
				has_character_flag = winner
				has_character_flag = second_place 
				has_character_flag = third_place
			}
			character_event = { id = 70002 days = 5 }
		}
	}
}

# Character wins third place in the tournament
character_event = {
	id = 70022
	title = TOURNAMENTTITLE
	desc = EVTDESC70022
	picture = GFX_evt_melee

	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = attending_tournament

	trigger = {
		NOT = { has_character_flag = tournament_winner }
		NOT = { has_character_flag = tournament_second_place }
		top_liege = {
			had_character_flag = { flag = tournament_begins days = 50 }
			had_character_flag = { flag = second_place days = 1 }
			NOT = { has_character_flag = third_place }
		}
		NOT = {
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				attribute_diff = {
					character = ROOT
					attribute = martial
					value = 5
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 1
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = second_place days = 10 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = second_place days = 20 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = second_place days = 30 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = second_place days = 40 }
			}
		}
		modifier = {
			factor = 0.5
			top_liege = {
				had_character_flag = { flag = second_place days = 50 }
			}
		}
		modifier = {
			factor = 1.5
			trait = wounded
		}
		modifier = {
			factor = 3
			is_maimed_trigger = yes
		}
		modifier = {
			factor = 1.5
			health_traits = 1
		}
		modifier = {
			factor = 0.75
			trait = duelist
		}
		modifier = {
			factor = 0.75
			trait = brave
		}
		modifier = {
			factor = 1.25
			trait = craven
		}
		modifier = {
			factor = 2
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 4 }
			}
		}
		modifier = {
			factor = 1.75
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 3 }
			}
		}
		modifier = {
			factor = 1.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 2 }
			}
		}
		modifier = {
			factor = 1.25
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				NOT = { attribute_diff = { character = ROOT attribute = martial value = 1 } }
				ROOT = { NOT = { attribute_diff = { character = PREV attribute = martial value = 1 } } }
				combat_rating_diff = { character = ROOT value = 1 }
			}
		}
		modifier = {
			factor = 3
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				attribute_diff = { character = ROOT attribute = martial value = 4 }
			}
		}
		modifier = {
			factor = 2.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				attribute_diff = { character = ROOT attribute = martial value = 3 }
			}
		}
		modifier = {
			factor = 2
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				attribute_diff = { character = ROOT attribute = martial value = 2 }
			}
		}
		modifier = {
			factor = 1.5
			any_character = {
				has_character_flag = attending_tournament
				same_realm = ROOT
				NOT = { character = ROOT }
				NOT = { has_character_flag = tournament_winner }
				NOT = { has_character_flag = tournament_second_place }
				attribute_diff = { character = ROOT attribute = martial value = 1 }
			}
		}
		modifier = {
			factor = 0.5
			NOT = {
				any_character = {
					has_character_flag = attending_tournament
					same_realm = ROOT
					NOT = { character = ROOT }
					NOT = { has_character_flag = tournament_winner }
					NOT = { has_character_flag = tournament_second_place }
					martial = ROOT
				}
			}
		}
	}

	immediate = {
		set_character_flag = attending_tournament_event
		set_character_flag = tournament_third_place
		top_liege = {
			set_character_flag = third_place
		}
	}

	option = {
		name = "EVTOPTA70022"
		wealth = 50
		prestige = 200
		if = {
			limit = {
				religion_group = muslim
			}
			piety = 10
		}
		hidden_tooltip = {
			if = {
				limit = {
					top_liege = { NOT = { character = ROOT } }
					OR = {
						NOT = { has_character_flag = championing_liege_lady }
						top_liege = { NOT = { is_liege_of = ROOT } }
					}
				}
				top_liege = { character_event = { id = 70036 } }
			}
		}
		hidden_tooltip = {
			if = {
				limit = { has_character_flag = championing_liege_lady }
				liege = { character_event = { id = FemRule.207 } }
				clr_character_flag = championing_liege_lady
			}
		}
	}
}

# Inform about third place
character_event = {
	id = 70036
	title = TOURNAMENTTITLE
	desc = EVTDESC70036
	picture = GFX_evt_joust

	is_triggered_only = yes

	option = {
		name = "EVTOPTA70036"
		opinion = {
			modifier = opinion_tournament_third_place
			who = FROM
			years = 10
		}
		if = {
			limit = {
				OR = {
					has_character_flag = beauty_winner
					religion_group = muslim
				}
				has_character_flag = winner
				has_character_flag = second_place 
				has_character_flag = third_place
			}
			character_event = { id = 70002 days = 5 }
		}
	}
}

###########################################
# Flag management                         #
###########################################

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

	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		remove_character_modifier = holding_epic_tournament
		clr_character_flag = tournament_begins
		clr_character_flag = winner
		clr_character_flag = second_place
		clr_character_flag = third_place
		clr_character_flag = attending_tournament
		clr_character_flag = attending_tournament_event
		clr_character_flag = tournament_third_place
		clr_character_flag = tournament_second_place
		clr_character_flag = tournament_winner
		clr_character_flag = tournament_has_ended
		clr_character_flag = beauty_winner
		clr_character_flag = tournament_romance
		clr_character_flag = spectating_tournament
		clr_character_flag = attending_tournament_wound
		clr_character_flag = championing_liege_lady
		clr_character_flag = no_msg_death
		clr_character_flag = no_msg_maimed
		clr_character_flag = no_msg_wounded
	}
}

