#########################################################
#
# Way of Life - Intrigue Events
#
# Written by Henrik Fåhraeus
#
# ID Range: WoL.2000 to WoL.2999
#
# Intrigue skill "levels up", first with
# character modifiers: wol_schemer_1 to wol_schemer_2,
# then the Schemer trait.
#
#########################################################

namespace = WoL

# Schemer level up chance
character_event = {
	id = WoL.2000
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Way of Life"
	}
	
	immediate = {
		
		# Chance of trait adjustments
		if = {
			limit = {
				NOT = { trait = honest }
				NOT = { trait = deceitful }
				random = 85 # 15% chance
			}
			add_trait = deceitful
			character_event = { id = 38255 } # Deceitful notification
		}
		
		if = {
			limit = {
				trait = honest
				random = 50
			}
			remove_trait = honest
			character_event = { id = 38311 } # Honest loss notification
		}
		
		# Chance of various Intrigue boosters
		character_event = { id = WoL.2001 days = 7 } 
		
		# Chance of levelling up Schemer skills
		if = {
			limit = {
				has_character_modifier = wol_schemer_2
			}
			random = {
				chance = 10
				character_event = { id = WoL.2003 days = 4 } # Gain the Schemer or Impaler trait
			}
			break = yes
		}
		if = {
			limit = {
				has_character_modifier = wol_schemer_1
			}
			random = {
				chance = 20
				remove_character_modifier = wol_schemer_1
				add_character_modifier = {
					modifier = wol_schemer_2
					duration = -1
				}
			}
			break = yes
		}
		
		if = {
			limit = {
				NOR = {
					trait = schemer
					trait = impaler
				}
			}
			random = {
				chance = 50
				add_character_modifier = {
					modifier = wol_schemer_1
					duration = -1
				}
			}
		}
	}
}

# Chance of Intrigue boosts
character_event = {
	id = WoL.2001
	
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				trait = amateurish_plotter
			}
			random = {
				chance = 10
				set_character_flag = int_ed_boost
				character_event = { id = WoL.2002 }
			}
			break = yes
		}
		if = {
			limit = {
				trait = flamboyant_schemer
			}
			random = {
				chance = 5
				set_character_flag = int_ed_boost
				character_event = { id = WoL.2002 }
			}
			break = yes
		}
		if = {
			limit = {
				trait = intricate_webweaver
			}
			random = {
				chance = 1
				set_character_flag = int_ed_boost
				character_event = { id = WoL.2002 }
			}
			break = yes
		}
	}
}

character_event = {
	id = WoL.2002
	
	picture = GFX_evt_whispers
	border = GFX_event_normal_frame_intrigue
	
	desc = EVTDESC_WOL_2002
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_81
		
		if = {
			limit = {
				has_character_flag = int_ed_boost
				trait = amateurish_plotter
			}
			hidden_tooltip = { remove_trait = amateurish_plotter }
			add_trait = flamboyant_schemer
			clr_character_flag = int_ed_boost
			break = yes
		}
		if = {
			limit = {
				has_character_flag = int_ed_boost
				trait = flamboyant_schemer
			}
			hidden_tooltip = { remove_trait = flamboyant_schemer }
			add_trait = intricate_webweaver
			clr_character_flag = int_ed_boost
			break = yes
		}
		if = {
			limit = {
				has_character_flag = int_ed_boost
				trait = intricate_webweaver
			}
			hidden_tooltip = { remove_trait = intricate_webweaver }
			add_trait = elusive_shadow
			clr_character_flag = int_ed_boost
			break = yes
		}
	}
}

# Schemer or Impaler trait gained!
character_event = {
	id = WoL.2003
	desc = EVTDESC_WOL_2003
	
	picture = GFX_evt_shadow
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { lifestyle_traits = 1 }
		NOT = { has_character_flag = wol_no_to_intrigue_trait }
	}
	
	option = {
		name = EVTOPTA_WOL_2003
		ai_chance = {
			factor = 100
		}
		remove_character_modifier = wol_schemer_2
		add_trait = schemer
		
		hidden_tooltip = {
			if = {
				limit = {
					has_nickname = no
				}
				random_list = {
					34 = { give_nickname = nick_the_spider }
					33 = { give_nickname = nick_the_whisperer }
					33 = { give_nickname = nick_the_shadow }
				}
			}
		}
		
#		log = "WoL.2003: [Root.GetTitledName] achieves the lifestyle Schemer!"
	}
	option = {
		name = EVTOPTB_WOL_2003
		
		ai_chance = {
			factor = 20
			modifier = {
				factor = 0.1
				trait = kind
			}
			modifier = {
				factor = 0.25
				trait = charitable
			}
			modifier = {
				factor = 2.0
				trait = envious
			}
			modifier = {
				factor = 2.0
				trait = wroth
			}
			modifier = {
				factor = 100.0
				trait = cruel
			}
		}
		
		remove_character_modifier = wol_schemer_2
		add_trait = impaler
		
		hidden_tooltip = {
			if = {
				limit = {
					has_nickname = no
				}
				random_list = {
					25 = { give_nickname = nick_the_cruel }
					25 = { give_nickname = nick_the_terrible }
					25 = { give_nickname = nick_the_impaler }
					25 = { give_nickname = nick_the_devil }
				}
			}
		}
		
#		log = "WoL.2003: [Root.GetTitledName] achieves the lifestyle Impaler!"
	}
	
	option = {
		name = EVTOPTC_WOL_2003
		ai_chance = {
			factor = 0
		}
		set_character_flag = wol_no_to_intrigue_trait
	}
}

#############################################
# "Spy On" Decision event START
#############################################

# "Spy On" Decision event START
character_event = {
	id = WoL.2050
	desc = EVTDESC_WOL_2050
	picture = GFX_evt_eavesdropping
	border = GFX_event_normal_frame_intrigue
	
	capable_only = yes
	prisoner = no
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			save_event_target_as = target_spy_on
		}
		save_event_target_as = target_snooper
		set_character_flag = spy_on_confirmed
	}
	
	option = {
		name = EVTOPTA_WOL_2050
		character_event = { id = WoL.2060 days = 30 random = 60 tooltip = EVTTOOLTIP_WoL_110 }
#		log = "WoL.2050: [Root.GetTitledName] starts spying on [From.GetTitledName]"
	}
}

# Hidden 'outcome tombola' event for the "Spy On" decision
character_event = {
	id = WoL.2060
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				OR = {
					prisoner = yes # I have become imprisoned
					trait = incapable # I have become incapable
					AND = {
						NOT = { has_focus = focus_intrigue } # I have changed my focus
						NOT = { trait = schemer }
					}
				}
			}
			character_event = { id = WoL.2069 } # Clear out any flags, etc
			break = yes # Stop execution here
		}
		if = {
			limit = {
				FROMFROM = {
					is_alive = no # Target has died
				}
			}
			character_event = { id = WoL.2061 }
			break = yes
		}
		if = {
			limit = {
				FROMFROM = {
					prisoner = yes # Target has been imprisoned
				}
			}
			character_event = { id = WoL.2062 }
			break = yes
		}
		if = {
			limit = {
				FROMFROM = {
					trait = incapable # Target has become incapable
				}
			}
			character_event = { id = WoL.2063 }
			break = yes
		}
		if = {
			limit = {
				FROMFROM = {
					NOT = { same_realm = ROOT } # Target has left the realm
				}
			}
			character_event = { id = WoL.2064 }
			break = yes
		}
		if = {
			limit = {
				NOT = {
					has_opinion_modifier = {
						who = FROMFROM
						modifier = opinion_spying_on
					}
				}
			}
			break = yes # I have stopped spying on this character
		}
		
		# Fire again for next attempt
		repeat_event = { id = WoL.2060 days = 60 random = 120 } # Fire again with no scope changes
		
		if = {
			limit = {
				FROMFROM = {
					OR = {
						trait = on_hajj
						is_inaccessible_trigger = yes
						trait = on_pilgrimage
						is_not_busy_trigger = no
					}
				}
			}
			break = yes
		}
		random_list = {
			300 = { # Nothing happens
				modifier = {
					factor = 0.75
					attribute_diff = {
						attribute = intrigue
						character = FROMFROM
						value = 3
					}
				}
				modifier = {
					factor = 0.75
					attribute_diff = {
						attribute = intrigue
						character = FROMFROM
						value = 5
					}
				}
				modifier = {
					factor = 0.5
					attribute_diff = {
						attribute = intrigue
						character = FROMFROM
						value = 10
					}
				}
				modifier = {
					factor = 2.0
					NOT = {
						attribute_diff = {
							attribute = intrigue
							character = FROMFROM
							value = -2
						}
					}
				}
				modifier = {
					factor = 3.0
					NOT = {
						attribute_diff = {
							attribute = intrigue
							character = FROMFROM
							value = -4
						}
					}
				}
				modifier = {
					factor = 4.0
					NOT = {
						attribute_diff = {
							attribute = intrigue
							character = FROMFROM
							value = -9
						}
					}
				}
				modifier = {
					factor = 0.75
					has_character_modifier = plot_assisted_spying
				}
				modifier = {
					factor = 0.60
					has_character_modifier = plot_assisted_spying2
				}
				modifier = {
					factor = 0.45
					has_character_modifier = plot_assisted_spying3
				}
				modifier = {
					factor = 0.30
					has_character_modifier = plot_assisted_spying4
				}
				modifier = {
					factor = 0.15
					has_character_modifier = plot_assisted_spying5
				}
				modifier = {
					factor = 0.75
					has_character_modifier = wol_schemer_1
				}
				modifier = {
					factor = 0.5
					has_character_modifier = wol_schemer_2
				}
				modifier = {
					factor = 0.2
					trait = schemer
				}
				modifier = {
					factor = 1.5
					FROMFROM = { has_character_modifier = wol_schemer_1 }
				}
				modifier = {
					factor = 3.0
					FROMFROM = { has_character_modifier = wol_schemer_2 }
				}
				modifier = {
					factor = 5.0
					FROMFROM = { trait = schemer }
				}
				
				random = {
					chance = 25
					character_event = { id = WoL.2065 } # Time to give up?
				}
			}
			100 = { # Plot uncovered
				modifier = {
					factor = 0
					FROMFROM = {
						NOR = {
							AND = {
								has_plot = yes
								NOT = { plot_is_known_by = ROOT }
							}
							any_backed_character = {
								has_plot = yes
								NOT = { plot_is_known_by = ROOT }
							}
						}
					}
				}
				
				character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
				
				if = {
					limit = {
						FROMFROM = {
							has_plot = yes
							NOT = { plot_is_known_by = ROOT }
						}
					}
					FROMFROM = { character_event = { id = WoL.2070 } } # Plot uncovered 
					break = yes
				}	
				FROMFROM = {
					random_backed_character = {
						limit = {
							has_plot = yes
							NOT = { plot_is_known_by = ROOT }
						}
						character_event = { id = WoL.2070 }
					}
				}
			}
			100 = { # Plot assisted
				modifier = {
					factor = 0
					NOR = {
						AND = {
							has_plot = yes
							plot_target_char = { character = FROMFROM }
							NOR = {
								has_character_modifier = plot_assisted_spying
								has_character_modifier = plot_assisted_spying2
								has_character_modifier = plot_assisted_spying3
								has_character_modifier = plot_assisted_spying4
								has_character_modifier = plot_assisted_spying5
							}
						}
						any_backed_character = {
							plot_target_char = { character = FROMFROM }
							NOR = {
								has_character_modifier = plot_assisted_spying
								has_character_modifier = plot_assisted_spying2
								has_character_modifier = plot_assisted_spying3
								has_character_modifier = plot_assisted_spying4
								has_character_modifier = plot_assisted_spying5
							}
						}
					}
				}
				
				character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
				
				character_event = { id = Plus.1500 }
			}
			30 = { # Discovers real father
				modifier = {
					factor = 0
					FROMFROM = {
						OR = {
							trait = bastard
							trait = legit_bastard
							is_child_of = ROOT
							is_father_real_father = yes
							real_father = { character = ROOT }
							has_character_flag = start_of_game_character
							reverse_has_opinion_modifier = { who = ROOT modifier = opinion_spy_discovered_father } # Already done this once
						}
					}
				}
				
				character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
				
				character_event = { id = Plus.1505 }
			}
			30 = { # Discovers lover
				modifier = {
					factor = 2
					OR = {
						is_married = FROMFROM
						is_consort = FROMFROM
					}
				}
				modifier = {
					factor = 0
					FROMFROM = {
						OR = {
							has_lover = no
							has_character_modifier = adulteress
							has_character_modifier = adulterer
							has_character_modifier = incestuous_adulteress
							has_character_modifier = incestuous_adulterer
							has_character_modifier = adulterous_priest
							has_character_modifier = cradle_robber
							has_character_modifier = known_sodomite
							has_character_modifier = known_sodomite_pagan
						}
					}
				}
				modifier = {
					factor = 0
					FROMFROM = {
						is_married = no
						NOT = {
							any_lover = {
								NOT = { any_consort = { character = FROMFROM } }
								OR = {
									is_married = yes
									same_sex = FROMFROM
									is_close_relative = FROMFROM
									is_priest = yes
									trait = monk
									trait = nun
									age_diff = { who = FROMFROM years = 25 }
								}
							}
						}
					}
				}
				modifier = {
					factor = 0
					FROMFROM = {
						NOT = { any_spouse = { character = event_target:target_spy_on } }
					}
				}
				modifier = {
					factor = 0
					has_opinion_modifier = { who = FROMFROM modifier = opinion_spy_discovered_lover } # Already done this once
				}
				
				character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
				
				character_event = { id = Plus.1515 }
			}
			30 = { # Chance to enflame rivalry
				modifier = {
					factor = 0
					has_opinion_modifier = { who = FROMFROM modifier = opinion_spy_enflamed_rivalry } # Already done this once
				}
				modifier = {
					factor = 0
					FROMFROM = { is_ruler = no }
				}
				modifier = {
					factor = 2
					FROMFROM = {
						OR = {
							trait = envious
							trait = wroth
							trait = proud
							trait = cruel
						}
					}
				}
				modifier = {
					factor = 0.5
					FROMFROM = {
						OR = {
							trait = humble
							trait = content
							trait = kind
						}
					}
				}
				modifier = {
					factor = 0
					NOT = {
						FROMFROM = {
							top_liege = {
								any_realm_character = {
									is_ruler = yes
									has_regent = no
									OR = {
										tier = FROMFROM
										vassal_of = FROMFROM
									}
									NOT = { character = FROMFROM }
									NOT = { character = ROOT }
									NOT = { is_rival = FROMFROM }
									NOT = { reverse_opinion = { who = FROMFROM value = 0 } }
									NOT = { opinion = { who = FROMFROM value = 0 } }
								}
							}
						}
					}
				}
				
				character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
				
				character_event = { id = Plus.1525 }
			}
			30 = { # Chance to reduce relations with liege
				modifier = {
					factor = 0
					has_opinion_modifier = { who = FROMFROM modifier = opinion_spy_enflamed_rivalry } # Already done this once
				}
				modifier = {
					factor = 2
					FROMFROM = {
						OR = {
							trait = envious
							trait = wroth
							trait = proud
							trait = cruel
						}
					}
				}
				modifier = {
					factor = 0.5
					FROMFROM = {
						OR = {
							trait = humble
							trait = content
							trait = kind
						}
					}
				}
				modifier = {
					factor = 0
					FROMFROM = { independent = yes }
				}
				modifier = {
					factor = 0
					FROMFROM = { vassal_of = ROOT }
				}
				modifier = {
					factor = 0
					FROMFROM = {
						liege = { is_rival = FROMFROM }
					}
				}
				modifier = {
					factor = 0
					FROMFROM = {
						liege = {
							opinion = { who = FROMFROM value = 0 }
							reverse_opinion = { who = FROMFROM value = 0 }
						}
					}
				}
				
				character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
				
				character_event = { id = Plus.1540 }
			}
			10 = { # Chance to slander
				modifier = {
					factor = 0
					has_opinion_modifier = { who = FROMFROM modifier = opinion_spy_rumors } # Already done this once
				}
				modifier = {
					factor = 0
					FROMFROM = { has_character_modifier = vicious_rumors }
				}
				modifier = {
					factor = 2.0
					OR = {
						trait = lustful
						trait = cruel
						trait = wroth
						trait = craven
					}
				}
				modifier = {
					factor = 0.5
					OR = {
						trait = temperate
						trait = just
						trait = honest
						trait = kind
					}
				}
				modifier = {
					factor = 3.0
					FROMFROM = {
						OR = {
							has_character_modifier = incestuous_adulterer
							has_character_modifier = incestuous_adulteress
							has_character_modifier = adulterer
							has_character_modifier = adulteress
							has_character_modifier = known_sodomite
							has_character_modifier = known_sodomite_pagan
							has_character_modifier = cradle_robber
							has_character_modifier = adulterous_priest
							trait = homosexual
							trait = hedonist
							trait = drunkard
							trait = decadent
							trait = bastard
							trait = legit_bastard
							trait = lunatic
							trait = possessed
							trait = cynical
						}
					}
				}
				
				character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
				
				character_event = { id = WoL.2100 }
			}
		}
	}
}

# My target has died!
character_event = {
	id = WoL.2061
	
	desc = EVTDESC_WOL_2061
	picture = GFX_evt_death
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = WoL.2069 }
	}
	
	option = {
		name = EVTOPTA_WOL_2061
	}
}

# My target has been imprisoned!
character_event = {
	id = WoL.2062
	
	desc = EVTDESC_WOL_2062
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = WoL.2069 }
	}
	
	option = {
		name = EVTOPTA_WOL_2061
	}
}

# My target has become incapable!
character_event = {
	id = WoL.2063
	
	desc = EVTDESC_WOL_2063
	picture = GFX_evt_illness
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = WoL.2069 }
	}
	
	option = {
		name = EVTOPTA_WOL_2061
	}
}

# My target is not longer in the same realm
character_event = {
	id = WoL.2064
	
	desc = EVTDESC_WOL_2064
	picture = GFX_evt_courier
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = WoL.2069 }
	}
	
	option = {
		name = EVTOPTA_WOL_2061
	}
}

# My efforts are not bearing fruit. Give up?
character_event = {
	id = WoL.2065
	
	desc = EVTDESC_WOL_2065
	picture = GFX_evt_eavesdropping
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2065 # Give up
		custom_tooltip = { text = EVTTOOLTIP_STOP_SPYING }
		ai_chance = {
			factor = 10
		}
		hidden_tooltip = {
			character_event = { id = WoL.2069 }
		}
	}
	
	option = {
		name = EVTOPTB_WOL_2065 # Keep spying
		custom_tooltip = { text = EVTTOOLTIP_CONTINUE_SPYING }
		ai_chance = {
			factor = 100
		}
	}
}

# End of "Spy On" event to clear out flags, etc
character_event = {
	id = WoL.2069
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		remove_opinion = {
			who = event_target:target_spy_on
			modifier = opinion_spying_on
		}
		add_character_modifier = {
			name = spying_timer
			duration = 365
			hidden = yes
		}
		clear_delayed_event = { id = WoL.2060 }
		
		clr_character_flag = charge_illegitimate
		clr_character_flag = charge_heretic
		clr_character_flag = charge_infidel
		clr_character_flag = charge_deviant
		clr_character_flag = charge_traitor
		clr_character_flag = charge_slanderer
		clr_character_flag = spy_on_confirmed
	}
}

### PLOT UNCOVERED

# Plot uncovered - ping plotter
character_event = {
	id = WoL.2070
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROM = { character_event = { id = WoL.2071 } }
	}
}

# Plot uncovered
character_event = {
	id = WoL.2071
	
	picture = GFX_evt_shadowy_cabal
	border = GFX_event_normal_frame_intrigue
	
	desc = {
		trigger = {
			event_target:target_spy_on = { character = FROM }
			FROM = { plot_target_char = { NOT = { character = ROOT } } }
		}
		text = EVTDESC_WOL_2071
	}
	desc = {
		trigger = {
			event_target:target_spy_on = { NOT = { character = FROM } }
			FROM = { plot_target_char = { NOT = { character = ROOT } } }
		}
		text = EVTDESC_WOL_2071_B
	}
	desc = {
		trigger = {
			FROM = { plot_target_char = { character = ROOT } }
		}
		text = EVTDESC_WOL_2071_C
	}
	
	is_triggered_only = yes

	immediate = {
		if = {
			limit = {
				FROM = {
					plot_target_char = {
						OR = {
							character = ROOT
							is_married = ROOT
							is_child_of = ROOT
						}
					}
				}
			}
			opinion = {
				modifier = devious_plotter
				who = FROM
				months = 120
			}
		}
	}
	
	option = {
		name = EVTOPTC_WOL_2071 # Attempt to blackmail him
		trigger = {
			FROM = {
				plot_target_char = {
					NOT = { character = ROOT }
					NOT = { is_married = ROOT }
					NOT = { is_child_of = ROOT }
				}
			}
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 3
				trait = greedy
			}
			modifier = {
				factor = 2
				OR = {
					trait = envious
					trait = deceitful
					trait = ambitious
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = kind
					trait = honest
					trait = just
					trait = content
				}
			}
		}
		if = {
			limit = {
				NOT = { trait = honest }
				NOT = { trait = deceitful }
			}
			random = {
				chance = 50
				add_trait = deceitful
				
			}
		}
		if = {
			limit = { trait = honest }
			remove_trait = honest
			
		}
		FROM = {
			reveal_plot = ROOT
			letter_event = { id = 7260 days = 1 tooltip = "EVTTOOLTIP7260" }
		}
	}
	option = {
		name = EVTOPTD_WOL_2071 # Quietly let the target know
		trigger = {
			FROM = {
				plot_target_char = {
					NOT = { character = ROOT }
					NOT = { is_married = ROOT }
					NOT = { is_child_of = ROOT }
					FROM = { NOT = { plot_is_known_by = PREV } }
				}
			}
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0.5
				OR = {
					trait = cruel
					trait = deceitful
					trait = greedy
				}
			}
			modifier = {
				factor = 2
				OR = {
					trait = kind
					trait = honest
					trait = just
				}
			}
			modifier = {
				factor = 0
				FROM = {
					plot_target_char = { NOT = { reverse_opinion = { who = ROOT value = -25 } } }
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					plot_target_char = { NOT = { reverse_opinion = { who = ROOT value = 0 } } }
				}
			}
			modifier = {
				factor = 2
				FROM = {
					plot_target_char = { reverse_opinion = { who = ROOT value = 25 } }
				}
			}
			modifier = {
				factor = 3
				FROM = {
					plot_target_char = { reverse_opinion = { who = ROOT value = 50 } }
				}
			}
			modifier = {
				factor = 5
				FROM = {
					plot_target_char = { reverse_opinion = { who = ROOT value = 75 } }
				}
			}
		}
		FROM = {
			reveal_plot = ROOT
			plot_target_char = {
				letter_event = { id = WoL.2072 days = 1 tooltip = "EVTTOOLTIP_INFORM_TARGET" }
			}
		}
	}
	option = {
		name = EVTOPTA_WOL_2071 # I shall keep this information to myself
		ai_chance = {
			factor = 100
		}
		FROM = {
			reveal_plot = ROOT
		}	
#		log = "WoL.2071: [Root.GetTitledName] unveils [From.GetTitledName]'s plot to [From.GetPlot]!"
	}
	option = {
		name = EVTOPTB_WOL_2071 # Great, now stop spying
		ai_chance = {
			factor = 50
		}
		FROM = {
			reveal_plot = ROOT
		}
		custom_tooltip = { text = EVTTOOLTIP_STOP_SPYING }
		hidden_tooltip = {
			character_event = { id = WoL.2069 } # Clear out flags and end spying
		}
#		log = "WoL.2071: [Root.GetTitledName] unveils [From.GetTitledName]'s plot to [From.GetPlot]!"
	}
}

# Target informed of plot
letter_event = {
	id = WoL.2072
	desc = EVTDESC_WOL_2072
	border = GFX_event_letter_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2072
		opinion = {
			modifier = opinion_grateful
			who = FROM
			months = 60
		}
		FROMFROM = { reveal_plot = yes }
		opinion = {
			modifier = devious_plotter
			who = FROMFROM
			months = 120
		}
		if = {
			limit = {
				liege = { NOT = { character = FROMFROM } }
			}
			liege = {
				opinion = {
					who = FROMFROM
					modifier = devious_plotter
					months = 120
				}
			}
		}
	}
}

### SMEAR CAMPAIGN

# Spy gets a chance to start a smear campaign against the target
character_event = {
	id = WoL.2100
	picture = GFX_evt_whispers
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	desc = {
		trigger = {
			FROMFROMFROM = {
				OR = {
					has_character_modifier = known_sodomite
					has_character_modifier = known_sodomite_pagan
					has_character_modifier = incestuous_adulterer
					has_character_modifier = incestuous_adulteress
					has_character_modifier = adulterer
					has_character_modifier = adulteress
					has_character_modifier = cradle_robber
					has_character_modifier = adulterous_priest
					trait = homosexual
					trait = hedonist
				}
			}
		}
		text = EVTDESC_WOL_2100_DEVIANT
	}
	desc = {
		trigger = {
			FROMFROMFROM = {
				trait = decadent
			}
		}
		text = EVTDESC_WOL_2100_DECADENT
	}
	desc = {
		trigger = {
			FROMFROMFROM = {
				OR = {
					trait = lunatic
					trait = possessed
				}
			}
		}
		text = EVTDESC_WOL_2100_INSANE
	}
	desc = {
		trigger = {
			FROMFROMFROM = {
				trait = cynical
			}
		}
		text = EVTDESC_WOL_2100_HERETIC
	}
	desc = {
		trigger = {
			FROMFROMFROM = {
				trait = drunkard
			}
		}
		text = EVTDESC_WOL_2100_DRUNK
	}
	desc = {
		trigger = {
			FROMFROMFROM = {
				OR = {
					trait = bastard
					trait = legit_bastard
				}
			}
		}
		text = EVTDESC_WOL_2100_BASTARD
	}
	desc = {
		trigger = {
			FROMFROMFROM = {
				NOR = {
					has_character_modifier = incestuous_adulterer
					has_character_modifier = incestuous_adulteress
					has_character_modifier = adulterer
					has_character_modifier = adulteress
					has_character_modifier = known_sodomite
					has_character_modifier = known_sodomite_pagan
					has_character_modifier = cradle_robber
					has_character_modifier = adulterous_priest
					trait = homosexual
					trait = hedonist
					trait = drunkard
					trait = decadent
					trait = bastard
					trait = legit_bastard
					trait = lunatic
					trait = possessed
					trait = cynical
				}
			}
		}
		text = EVTDESC_WOL_2100
	}
	
	immediate = {
		opinion = {
			who = FROMFROMFROM
			modifier = opinion_spy_rumors
		}
		if = {
			limit = {
				FROMFROMFROM = {
					NOR = {
						has_character_modifier = incestuous_adulterer
						has_character_modifier = incestuous_adulteress
						has_character_modifier = adulterer
						has_character_modifier = adulteress
						has_character_modifier = known_sodomite
						has_character_modifier = known_sodomite_pagan
						has_character_modifier = cradle_robber
						has_character_modifier = adulterous_priest
						trait = homosexual
						trait = hedonist
						trait = drunkard
						trait = decadent
						trait = bastard
						trait = legit_bastard
						trait = lunatic
						trait = possessed
						trait = cynical
					}
				}
			}
			random_list = {
				10 = { set_character_flag = rumor_1 }
				10 = { set_character_flag = rumor_2 }
				10 = { set_character_flag = rumor_3 }
				10 = { set_character_flag = rumor_4 }
				10 = { set_character_flag = rumor_5 }
				10 = { set_character_flag = rumor_6 }
				10 = { set_character_flag = rumor_7 }
				10 = { set_character_flag = rumor_8 }
			}
		}
	}
	
	option = {
		name = {
			text = EVTOPTA_WOL_2100_1
			trigger = { has_character_flag = rumor_1 }
		}
		name = {
			text = EVTOPTA_WOL_2100_2
			trigger = { has_character_flag = rumor_2 }
		}
		name = {
			text = EVTOPTA_WOL_2100_3
			trigger = { has_character_flag = rumor_3 }
		}
		name = {
			text = EVTOPTA_WOL_2100_4
			trigger = { has_character_flag = rumor_4 }
		}
		name = {
			text = EVTOPTA_WOL_2100_5
			trigger = { has_character_flag = rumor_5 }
		}
		name = {
			text = EVTOPTA_WOL_2100_6
			trigger = { has_character_flag = rumor_6 }
		}
		name = {
			text = EVTOPTA_WOL_2100_7
			trigger = { has_character_flag = rumor_7 }
		}
		name = {
			text = EVTOPTA_WOL_2100_8
			trigger = { has_character_flag = rumor_8 }
		}
		name = {
			text = EVTOPTA_WOL_2100_9
			trigger = {
				NOR = {
					has_character_flag = rumor_1
					has_character_flag = rumor_2
					has_character_flag = rumor_3
					has_character_flag = rumor_4
					has_character_flag = rumor_5
					has_character_flag = rumor_6
					has_character_flag = rumor_7
					has_character_flag = rumor_8
				}
			}
		}
		
		ai_chance = {
			factor = 100
		}
		
		clr_character_flag = rumor_1
		clr_character_flag = rumor_2
		clr_character_flag = rumor_3
		clr_character_flag = rumor_4
		clr_character_flag = rumor_5
		clr_character_flag = rumor_6
		clr_character_flag = rumor_7
		clr_character_flag = rumor_8
		
		FROMFROMFROM = {
			add_character_modifier = {
				modifier = vicious_rumors
				years = 5
			}
		}
		
#		log = "WoL.2100: [Root.GetTitledName] spreads vicious rumors about [target_spy_on.GetTitledName]!"
		
		random = {
			chance = 25
			modifier = {
				factor = 0.75
				attribute_diff = {
					attribute = intrigue
					character = FROMFROMFROM
					value = 3
				}
			}
			modifier = {
				factor = 0.75
				attribute_diff = {
					attribute = intrigue
					character = FROMFROMFROM
					value = 5
				}
			}
			modifier = {
				factor = 0.5
				attribute_diff = {
					attribute = intrigue
					character = FROMFROMFROM
					value = 10
				}
			}
			modifier = {
				factor = 1.5
				NOT = {
					attribute_diff = {
						attribute = intrigue
						character = FROMFROMFROM
						value = -2
					}
				}
			}
			modifier = {
				factor = 2.0
				NOT = {
					attribute_diff = {
						attribute = intrigue
						character = FROMFROMFROM
						value = -4
					}
				}
			}
			modifier = {
				factor = 2.0
				NOT = {
					attribute_diff = {
						attribute = intrigue
						character = FROMFROMFROM
						value = -9
					}
				}
			}
			modifier = {
				factor = 0.75
				has_character_modifier = wol_schemer_1
			}
			modifier = {
				factor = 0.5
				has_character_modifier = wol_schemer_2
			}
			modifier = {
				factor = 0.2
				trait = schemer
			}
			modifier = {
				factor = 1.5
				FROMFROMFROM = { has_character_modifier = wol_schemer_1 }
			}
			modifier = {
				factor = 3.0
				FROMFROMFROM = { has_character_modifier = wol_schemer_2 }
			}
			modifier = {
				factor = 5.0
				FROMFROMFROM = { trait = schemer }
			}
			
			FROMFROMFROM = { character_event = { id = WoL.2101 days = 3 tooltip = EVTTOOLTIP_WOL_2101 } } # Target finds out about it
		}
	}
	
	option = {
		name = EVTOPTB_WOL_2100 # Nah
		ai_chance = {
			factor = 1
		}
		
		clr_character_flag = rumor_1
		clr_character_flag = rumor_2
		clr_character_flag = rumor_3
		clr_character_flag = rumor_4
		clr_character_flag = rumor_5
		clr_character_flag = rumor_6
		clr_character_flag = rumor_7
		clr_character_flag = rumor_8
	}
	
	option = {
		name = EVTOPTC_WOL_2100 # End my spying
		ai_chance = {
			factor = 50
		}
		
		hidden_tooltip = {
			character_event = { id = WoL.2069 }
		}
		
		clr_character_flag = rumor_1
		clr_character_flag = rumor_2
		clr_character_flag = rumor_3
		clr_character_flag = rumor_4
		clr_character_flag = rumor_5
		clr_character_flag = rumor_6
		clr_character_flag = rumor_7
		clr_character_flag = rumor_8
	}
}

# Target finds out about the vicious rumours
character_event = {
	id = WoL.2101
	picture = GFX_evt_whispers
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	desc = EVTDESC_WOL_2101
	
	option = {
		name = EVTOPTA_WOL_2101
		
		opinion = {
			who = FROM
			modifier = opinion_slandered
			months = 60
		}
	}
}


#############################################
# "Free from Captivity" Decision event START
#############################################

# Free Prisoner start
character_event = {
	id = WoL.2200
	desc = EVTDESC_WOL_2200
	picture = GFX_evt_jailbreak
	border = GFX_event_normal_frame_intrigue
	
	capable_only = yes
	prisoner = no
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			save_event_target_as = target_captive
		}
		save_event_target_as = target_rescuer
		set_character_flag = freeing_prisoner
	}
	
	option = {
		name = EVTOPTA_WOL_2200
		character_event = { id = WoL.2210 days = 20 random = 20 tooltip = EVTTOOLTIP_WoL_110 }
#		log = "WoL.2200: [Root.GetTitledName] starts planning to liberate [From.GetTitledName] from prison"
	}
}

# Free Forced Concubine start
character_event = {
	id = WoL.2201
	desc = EVTDESC_WOL_2201
	picture = GFX_evt_jailbreak
	border = GFX_event_normal_frame_intrigue
	
	capable_only = yes
	prisoner = no
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			save_event_target_as = target_captive
		}
		save_event_target_as = target_rescuer
		set_character_flag = freeing_concubine
	}
	
	option = {
		name = EVTOPTA_WOL_2200
		character_event = { id = WoL.2210 days = 20 random = 20 tooltip = EVTTOOLTIP_WoL_110 }
#		log = "WoL.2201: [Root.GetTitledName] starts planning to liberate [From.GetTitledName] from concubinage"
	}
}

# Hidden 'outcome tombola' event for the "Liberate" decision
character_event = {
	id = WoL.2210
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				OR = {
					prisoner = yes # I have become imprisoned
					trait = incapable # I have become incapable
					AND = {
						NOT = { has_focus = focus_intrigue } # I have changed my focus
						NOT = { trait = schemer }
					}
				}
			}
			character_event = { id = WoL.2219 } # Clear out any flags, etc
			break = yes # Stop execution here
		}
		
		if = {
			limit = {
				NOT = { has_opinion_modifier = { who = event_target:target_captive modifier = opinion_breaking_out } }
			}
			break = yes
		}
		
		if = {
			limit = {
				event_target:target_captive = {
					is_alive = no
				}
			}
			
			character_event = { id = WoL.2211 }
			break = yes
		}
		if = {
			limit = {
				event_target:target_captive = {
					trait = incapable
				}
			}
			character_event = { id = WoL.2212 }
			break = yes
		}
		if = {
			limit = {
				has_character_flag = freeing_prisoner
				event_target:target_captive = {
					prisoner = no
				}
			}
			character_event = { id = WoL.2213 }
			break = yes
		}
		
		if = {
			limit = {
				has_character_flag = has_liberation_agent
				event_target:target_agent = {
					OR = {
						is_alive = no
						prisoner = yes
						trait = incapable
					}
				}
			}
			character_event = { id = WoL.2230 }
			clear_event_target = target_agent
			clr_character_flag = has_liberation_agent
		}
		
		random_list = {
			1 = { # Nothing happens
				repeat_event = { id = WoL.2210 days = 30 random = 60 } # Fire again with no scope changes
			}
			100 = { # Courtier contacted
				modifier = {
					factor = 0
					has_character_flag = has_liberation_agent
				}
				
				event_target:target_captive = {
					host = {
						random_courtier = {
							limit = {
								is_ruler = no
								prisoner = no
								is_ill = no
								is_adult = yes
								NOT = { trait = incapable }
								NOT = { character = PREVPREV }
								OR = {
									trait = arbitrary
									trait = greedy
									personal_opinion_diff = {
										first = ROOT
										second = liege
										value = 5
									}
									personal_opinion_diff = {
										first = PREVPREV
										second = liege
										value = 5
									}
								}
								NOT = {
									reverse_has_opinion_modifier = {
										who = ROOT
										modifier = opinion_disappointed
									}
								}
							}
							character_event = { id = WoL.2220 }
							break = yes
						}
					}
				}
				
				character_event = { id = WoL.2232 }
			}
			
			100 = { # Liberation attempt
				modifier = {
					factor = 0
					NOT = { has_character_flag = has_liberation_agent }
				}
				
				event_target:target_agent = {
					character_event = { id = WoL.2222 }
				}
			}
			100 = { # Agent wants more money
				modifier = {
					factor = 0
					NOT = { has_character_flag = has_liberation_agent }
				}
				modifier = {
					factor = 0
					event_target:target_agent = {
						NOR = {
							trait = greedy
							trait = arbitrary
							trait = deceitful
							trait = cruel
						}
						OR = {
							is_lover = ROOT
							is_friend = ROOT
						}
					}
				}
				
				letter_event = { id = WoL.2231 }
			}
		}
	}
}

# My target has died!
character_event = {
	id = WoL.2211
	
	desc = EVTOPTA_WOL_2211
	picture = GFX_evt_death
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = WoL.2219 }
	}
	
	option = {
		name = EVTOPTA_WOL_2211
	}
}

# My target has become incapable!
character_event = {
	id = WoL.2212
	
	desc = EVTDESC_WOL_2212
	picture = GFX_evt_illness
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = WoL.2219 }
	}
	
	option = {
		name = EVTOPTA_WOL_2211
	}
}

# My target is not longer a prisoner anymore
character_event = {
	id = WoL.2213
	
	desc = EVTDESC_WOL_2213
	picture = GFX_evt_courier
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	immediate = {
		character_event = { id = WoL.2219 }
	}
	
	option = {
		name = EVTOPTA_WOL_2211
	}
}

# End of "Liberate" event to clear out flags, etc
character_event = {
	id = WoL.2219
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		remove_opinion = {
			who = event_target:target_captive
			modifier = opinion_breaking_out
		}
		
		clr_character_flag = freeing_prisoner
		clr_character_flag = freeing_concubine
		clr_character_flag = has_liberation_agent
	}
}

# Contact approached. Hidden ping.
character_event = {
	id = WoL.2220
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROM = { character_event = { id = WoL.2221 } }
	}
}

# Contact approached. Make plans.
character_event = {
	id = WoL.2221
	
	desc = EVTDESC_WOL_2221
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2221 # Will do it for free
		trigger = {
			FROM = {
				NOT = { trait = greedy }
				personal_opinion_diff = {
					first = ROOT
					second = liege
					value = 20
				}
				personal_opinion_diff = {
					first = event_target:target_captive
					second = liege
					value = 20
				}
			}
		}
		
		ai_chance = {
			factor = 1000
		}
		
		hidden_tooltip = {
			set_character_flag = has_liberation_agent
			FROM = { save_event_target_as = target_agent }
			character_event = { id = WoL.2210 days = 30 random = 60 } # Back to the tombola
		}
	}
	
	option = {
		name = EVTOPTB_WOL_2221 # Will do it for a bribe
		trigger = {
			FROM = {
				OR = {
					trait = greedy
					NOT = {
						personal_opinion_diff = {
							first = ROOT
							second = liege
							value = 20
						}
					}
					NOT = {
						personal_opinion_diff = {
							first = event_target:target_captive
							second = liege
							value = 20
						}
					}
				}
			}
		}
		
		ai_chance = {
			factor = 1
		}
		
		wealth = -10
		FROM = { wealth = 10 }
		
		hidden_tooltip = {
			set_character_flag = has_liberation_agent
			FROM = { save_event_target_as = target_agent }
			character_event = { id = WoL.2210 days = 30 random = 60 } # Back to the tombola
		}
	}
	
	option = {
		name = EVTOPTC_WOL_2221 # Will do it for love
		trigger = {
			trait = seducer
			OR = {
				AND = {
					FROM = { NOT = { trait = homosexual } }
					is_opposite_sex = FROM
				}
				AND = {
					FROM = { trait = homosexual }
					same_sex = FROM
				}
			}
		}
		
		ai_chance = {
			factor = 10000
		}
		
		tooltip_info = seducer
		
		hidden_tooltip = {
			set_character_flag = has_liberation_agent
			FROM = { save_event_target_as = target_agent }
			character_event = { id = WoL.2210 days = 30 random = 60 } # Back to the tombola
		}
	}
	
	option = {
		name = EVTOPTC_WOL_2221 # Will do it for love
		trigger = {
			trait = seductress
			OR = {
				AND = {
					FROM = { NOT = { trait = homosexual } }
					is_opposite_sex = FROM
				}
				AND = {
					FROM = { trait = homosexual }
					same_sex = FROM
				}
			}
		}
		
		ai_chance = {
			factor = 10000
		}
		
		tooltip_info = seductress
		
		hidden_tooltip = {
			set_character_flag = has_liberation_agent
			FROM = { save_event_target_as = target_agent }
			character_event = { id = WoL.2210 days = 30 random = 60 } # Back to the tombola
		}
	}
	
	option = {
		name = EVTOPTD_WOL_2221 # Abort
		ai_chance = {
			factor = 0
		}
		
		hidden_tooltip = {
			character_event = { id = WoL.2219 }
		}
	}
}

# Agent attemps liberation
character_event = {
	id = WoL.2222
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		FROM = { character_event = { id = WoL.2000 days = 3 } } # Level up chance 
	
		random_list = {
			100 = { # Success!
				modifier = {
					factor = 1.5
					liege = {
						NOT = {
							attribute_diff = {
								attribute = intrigue
								character = FROM
								value = -2
							}
						}
					}
				}
				modifier = {
					factor = 1.5
					liege = {
						NOT = {
							attribute_diff = {
								attribute = intrigue
								character = FROM
								value = -5
							}
						}
					}
				}
				modifier = {
					factor = 2.0
					liege = {
						NOT = {
							attribute_diff = {
								attribute = intrigue
								character = FROM
								value = -9
							}
						}
					}
				}
				
				event_target:target_captive = { 
					character_event = { id = WoL.2223 }
				}
			}
			
			100 = { # Failure
				modifier = {
					factor = 1.5
					liege = {
						attribute_diff = {
							attribute = intrigue
							character = FROM
							value = 3
						}
					}
				}
				modifier = {
					factor = 1.5
					liege = {
						attribute_diff = {
							attribute = intrigue
							character = FROM
							value = 6
						}
					}
				}
				modifier = {
					factor = 2.0
					liege = {
						attribute_diff = {
							attribute = intrigue
							character = FROM
							value = 10
						}
					}
				}
				
				event_target:target_captive = { 
					character_event = { id = WoL.2226 }
				}
				
				liege = {
					ROOT = { imprison = PREV }
				}
			}
		}
	}
}

# Prisoner freed
character_event = {
	id = WoL.2223
	
	desc = EVTDESC_WOL_2223
	picture = GFX_evt_jailbreak
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2223 # Freedom!
		
		hidden_tooltip = {
			host = {
				character_event = { id = WoL.2224 } # Notify jailor
			}
		}
		
		if = {
			limit = {
				prisoner = no
				is_consort = yes
				FROMFROM = { has_character_flag = freeing_concubine }
			}
			consort = {
				remove_consort = ROOT
			}
			move_character = FROMFROM
		}
		
		hidden_tooltip = {
			FROMFROM = {
				character_event = { id = WoL.2219 } # Clean up
				character_event = { id = WoL.2225 } # Notify liberator
			}
		}
		
		if = {
			limit = { prisoner = yes }
			imprison = no
		}
		
		opinion = {
			who = FROM
			modifier = opinion_grateful
			months = 120
		}
		opinion = {
			who = FROMFROM
			modifier = opinion_grateful
			months = 120
		}
	}
}

# Prisoner freed - jailor notified
character_event = {
	id = WoL.2224
	
	desc = {
		text = EVTDESC_WOL_2224
		trigger = { FROM = { prisoner = yes } }
	}
	desc = {
		text = EVTDESC_WOL_2224_CONSORT
		trigger = { FROM = { prisoner = no } }
	}
	
	picture = GFX_evt_jailbreak
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2224
	}
}

# Prisoner freed - liberator notified
character_event = {
	id = WoL.2225
	
	desc = EVTDESC_WOL_2225
	picture = GFX_evt_jailbreak
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		
		opinion = {
			who = FROMFROM
			modifier = opinion_grateful
			months = 120
		}
	}
}

# Prisoner - failed escape attempt
character_event = {
	id = WoL.2226
	
	desc = EVTDESC_WOL_2226
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2226
		
		hidden_tooltip = {
			add_character_modifier = {
				modifier = failed_escape
				years = 5
			}
			
			host = {
				character_event = { id = WoL.2227 } # Notify jailor
			}
			FROMFROM = {
				character_event = { id = WoL.2219 } # Clean up
				character_event = { id = WoL.2229 } # Notify the would-be liberator
			}
		}
	}
}

# Jailor - failed escape attempt
character_event = {
	id = WoL.2227
	
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	desc = {
		text = EVTDESC_WOL_2227
		trigger = { FROM = { prisoner = yes } }
	}
	desc = {
		text = EVTDESC_WOL_2227_CONSORT
		trigger = { FROM = { prisoner = no } }
	}
	
	option = {
		name = EVTOPTA_WOL_2227 # To the oubliette!
		trigger = {
			FROM = {
				prisoner = yes
				NOT = { has_character_modifier = the_oubliette }
			}
		}
		
		ai_chance = {
			factor = 100
			modifier = {
				factor = 5.0
				trait = cruel
			}
			modifier = {
				factor = 5.0
				trait = impaler
			}
		}
		
		opinion = {
			who = FROMFROM
			modifier = opinion_traitor
		}
		
		FROM = {
			add_character_modifier = {
				modifier = the_oubliette
				duration = -1
			}
			
			hidden_tooltip = {
				character_event = { id = WoL.2228 days = 3 } # Notify prisoner
			}
		}
	}
	
	option = {
		name = EVTOPTB_WOL_2227 # Tighten security
		ai_chance = {
			factor = 100
			modifier = {
				factor = 5.0
				trait = kind
			}
		}
		
		opinion = {
			who = FROMFROM
			modifier = opinion_traitor
		}
	}
}

# Prisoner - thrown in the oubliette
character_event = {
	id = WoL.2228
	
	desc = EVTDESC_WOL_2228
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2228
	}
}

# Escape fails - liberator notified
character_event = {
	id = WoL.2229
	
	desc = EVTDESC_WOL_2229
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2229
		
		opinion = {
			who = FROMFROM
			modifier = opinion_grateful
			months = 120
		}
	}
}

# My agent is no longer able to help
character_event = {
	id = WoL.2230
	
	desc = EVTDESC_WOL_2230
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2230
	}
}

# My agent wants more money
letter_event = {
	id = WoL.2231
	
	desc = EVTDESC_WOL_2231
	border = GFX_event_letter_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2231 # Pay
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0.1
				trait = greedy
			}
		}
		wealth = -10
		event_target:target_agent = {
			wealth = 10
		}
		hidden_tooltip = {
			character_event = { id = WoL.2210 days = 30 random = 60 } # Back to the tombola
		}
	}
	
	option = {
		name = EVTOPTA_WOL_2230 # Find another agent
		ai_chance = {
			factor = 100
		}
		hidden_tooltip = {
			opinion = {
				who = event_target:target_agent
				modifier = opinion_disappointed
				months = 36
			}
			
			clear_event_target = target_agent
			clr_character_flag = has_liberation_agent
			
			character_event = { id = WoL.2210 days = 30 random = 60 } # Back to the tombola
		}
	}
	
	option = {
		name = EVTOPTC_WOL_2231 # Abort the plan
		ai_chance = {
			factor = 1
		}
		
		hidden_tooltip = {
			character_event = { id = WoL.2219 } # Clear out any flags, etc
		}
	}
}

# Unable to find a willing agent
character_event = {
	id = WoL.2232
	
	desc = EVTDESC_WOL_2232
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_intrigue
	
	show_from_from_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2232 # Keep looking
		ai_chance = {
			factor = 10
		}
		hidden_tooltip = {
			character_event = { id = WoL.2210 days = 30 random = 60 } # Back to the tombola
		}
	}
	option = {
		name = EVTOPTB_WOL_2232 # Give up
		ai_chance = {
			factor = 100
		}
		hidden_tooltip = {
			character_event = { id = WoL.2219 } # Clear out any flags, etc
		}
	}
}


########################################
# RANDOM INTRIGUE EVENTS
########################################

# Your spymaster is plotting!
character_event = {
	id = WoL.2300
	
	desc = EVTDESC_WOL_2300
	picture = GFX_evt_eavesdropping
	border = GFX_event_normal_frame_intrigue
	
	only_playable = yes
	prisoner = no
	only_capable = yes
	
	trigger = {
		has_focus = focus_intrigue
		has_regent = no
		in_command_trigger = no
		job_spymaster = {
			OR = {
				AND = {
					has_plot = yes
					NOT = { plot_is_known_by = ROOT }
				}
				any_backed_character = {
					has_plot = yes
					NOT = { plot_is_known_by = ROOT }
				}
				ROOT = { trait = paranoid }
			}
			NOT = { has_character_flag = spymaster_noticed_liege }
		}
	}
	
	mean_time_to_happen = {
		months = 60
		modifier = {
			factor = 0.25
			trait = schemer
			NOT = { trait = paranoid }
		}
		modifier = {
			factor = 0.5
			NOT = { trait = paranoid }
			has_character_modifier = wol_schemer_2
		}
		modifier = {
			factor = 0.75
			NOT = { trait = paranoid }
			has_character_modifier = wol_schemer_1
		}
		modifier = {
			factor = 0.5
			NOT = { trait = paranoid }
			has_character_modifier = seduced_loyal_spy_maid
		}
		
		modifier = {
			factor = 0.5
			job_spymaster = {
				NOT = {
					attribute_diff = {
						attribute = intrigue
						character = ROOT
						value = -4
					}
				}
			}
		}
		modifier = {
			factor = 0.5
			job_spymaster = {
				NOT = {
					attribute_diff = {
						attribute = intrigue
						character = ROOT
						value = -9
					}
				}
			}
		}
		modifier = {
			factor = 2.0
			job_spymaster = {
				attribute_diff = {
					attribute = intrigue
					character = ROOT
					value = 5
				}
			}
		}
		modifier = {
			factor = 2.0
			job_spymaster = {
				attribute_diff = {
					attribute = intrigue
					character = ROOT
					value = 10
				}
			}
		}
		modifier = {
			factor = 4.0
			trait = paranoid
			job_spymaster = {
				NOR = {
					AND = {
						has_plot = yes
						NOT = { plot_is_known_by = ROOT }
					}
					any_backed_character = {
						has_plot = yes
						NOT = { plot_is_known_by = ROOT }
					}
				}
			}
		}
	}
	
	immediate = {
		job_spymaster = {
			save_event_target_as = intrigue_spymaster
		}
	}
	
	option = {
		name = EVTOPTA_WOL_2300 # Spy on the spymaster
		ai_chance = {
			factor = 100
		}
		
		hidden_tooltip = {
			random_list = {
				200 = { # Plot uncovered, spymaster arrested
					modifier = {
						factor = 0
						job_spymaster = {
							NOR = {
								AND = {
									has_plot = yes
									NOT = { plot_is_known_by = ROOT }
								}
								any_backed_character = {
									has_plot = yes
									NOT = { plot_is_known_by = ROOT }
								}
							}
						}
					}
					
					if = {
						limit = {
							job_spymaster = {
								has_plot = yes
								NOT = { plot_is_known_by = ROOT }
							}
						}
						job_spymaster = { character_event = { id = WoL.2301 days = 3 random = 7 } }
						break = yes
					}
					job_spymaster = {
						random_backed_character = {
							limit = {
								has_plot = yes
								NOT = { plot_is_known_by = ROOT }
							}
							character_event = { id = WoL.2301 days = 3 random = 7 }
						}
					}
				}
				50 = { # Nothing discovered
					character_event = { id = WoL.2304 days = 7 random = 7 }
				}
				50 = { # Spymaster notices
					job_spymaster = { character_event = { id = WoL.2305 days = 3 random = 7 } }
				}
			}
		}
	}
	
	option = {
		name = EVTOPTB_WOL_2300 # I trust him/her
		ai_chance = {
			factor = 1
			modifier = {
				factor = 300
				trait = trusting
			}
		}
	}
}

# Spying on Spymaster - plotter ping
character_event = {
	id = WoL.2301
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		FROM = { character_event = { id = WoL.2302 } }
	}
}

# Spying on Spymaster - plot uncovered
character_event = {
	id = WoL.2302
	
	desc = EVTDESC_WOL_2302
	
	picture = GFX_evt_shadowy_cabal
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			reveal_plot = ROOT
		}
		character_event = { id = WoL.2000 days = 1 } # Chance of levelling up Intrigue skills
	}
	
	option = {
		name = EVTOPTA_WOL_2302 # Arrest the spymaster!
		
		ai_chance = {
			factor = 100
		}
		
		trigger = {
			FROM = {
				OR = {
					has_plot = plot_kill_character
					has_plot = plot_kill_spouse
				}
			}
		}
		
		event_target:intrigue_spymaster = {
			character_event = { id = WoL.2303 }
			imprison = ROOT
		}
		
		if = {
			limit = {
				FROM = {
					plot_target_char = {
						OR = {
							character = ROOT
							is_close_relative = ROOT
						}
					}
				}
			}
			opinion = {
				who = event_target:intrigue_spymaster
				modifier = opinion_traitor
			}
		}
	}
	
	option = {
		name = EVTOPTB_WOL_2302 # Let them plot...
		
		ai_chance = {
			factor = 1
		}
		
		if = {
			limit = {
				FROM = {
					OR = {
						has_plot = plot_kill_character
						has_plot = plot_kill_spouse
					}
					plot_target_char = {
						OR = {
							character = ROOT
							is_close_relative = ROOT
						}
					}
				}
			}
			opinion = {
				who = event_target:intrigue_spymaster
				modifier = opinion_traitor
			}
		}
	}
}

# Spying on Spymaster - arrest notification
character_event = {
	id = WoL.2303
	
	desc = EVTDESC_WOL_2303
	
	picture = GFX_evt_shadowy_cabal
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = DAMNATION
	}
}

# Spying on Spymaster - nothing found
character_event = {
	id = WoL.2304
	
	desc = EVTDESC_WOL_2304
	
	picture = GFX_evt_shadowy_cabal
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2304
		ai_chance = {
			factor = 100
		}
	}
	
	option = {
		name = EVTOPTB_WOL_2304 # Replace
		ai_chance = {
			factor = 10
			modifier = {
				factor = 50
				trait = paranoid
			}
		}
		
		job_spymaster = {
			remove_title = job_spymaster
		}
	}
}

# Spying on Spymaster - Spymaster notices
character_event = {
	id = WoL.2305
	
	desc = EVTDESC_WOL_2305
	
	picture = GFX_evt_eavesdropping
	border = GFX_event_normal_frame_intrigue
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_WOL_2305
		
		hidden_tooltip = {
			set_character_flag = spymaster_noticed_liege
			character_event = { id = WoL.2304 }
		}
	}
}
