namespace = revela_secretum

# 0001 - Character knows secret.
# 0002 - Character doesn't know secret, and can't fabricate one.
# 0003 - 

# Mulsa knows something.
revela_secretum.0001 = {
	type = letter_event
	opening = revela_secretum.0001.opening
	desc = revela_secretum.0001.desc
	sender = {
		character = scope:revela_recipient
		animation = flirtation ### UPDATE - Put something relevant here.
	}

	trigger = {
		scope:revela_recipient = {
			any_secret = {
				NOT = { is_known_by = global_var:magister_character }
			}
		}
	}

	immediate = {
		scope:revela_recipient = {
			random_secret = {
				limit = { NOT = { is_known_by = global_var:magister_character } }
				save_scope_as = secret_to_reveal
			}
		}
	}

	option = { # Know something that would be of use.
		name = revela_secretum.0001.a # UPDATE - generic congratulations
		scope:secret_to_reveal = {
			reveal_to_without_events_effect = {
				CHARACTER = global_var:magister_character
			}	
		}
	}
}

# Mulsa doesn't know how to fabricate a secret.
revela_secretum.0002 = {
	type = character_event
	title = revela_secretum.0002.t
	desc = revela_secretum.0002.desc
	theme = fabricate_hook_scheme
	right_portrait = {
		character = scope:revela_recipient
		animation = grief
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	option = { # Knows nothing.
		name = revela_secretum.0002.a 
	}

	option = {
		name = revela_secretum.0002.b 
		custom_tooltip = revela_secretum.0002.b.tt

		trigger = {	
			custom_description = { ### UPDATE - A custom description shouldn't be required here.  Make sure it doesn't mess anything up.
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 3
				}
			}
		}

		show_as_unavailable = {
			custom_description = {
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank <= 2
				}
			}
		}

		scope:revela_recipient = {
			if = {
				limit = {
					has_trait = honest
				}
				remove_trait = honest
			}
			if = {
				limit = {
					has_trait = trusting
				}
				remove_trait = trusting
			}
			if = {
				limit = {
					NOT = { has_trait = paranoid }
				}
				add_trait = paranoid
			}
			if = {
				limit = {
					NOT = { has_trait = deceitful }
				}
				add_trait = deceitful
			}
			add_perk = truth_is_relative_perk
		}
		scope:actor = {
			add_piety = -150
		}
		trigger_event = {
			on_action = revela_secretum_fabricate_effect # Fabricate hook.  fabricate_hook_outcome.1001 as a guide.
			days = { 10 30 }
		}
	}
}

#Fabrication events

revela_secretum.1001 = { # Honeypot
	type = character_event
	title = revela_secretum.1001.t
	desc = revela_secretum.1001.desc
	theme = fabricate_hook_scheme
	override_background = {
		event_background = throne_room  
	}
	right_portrait = {
		character = scope:revela_recipient
		animation = content
	}
	lower_right_portrait = scope:revela_target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:revela_target = { 
			AND = {
				is_ruler = yes 
				OR = {
					is_married = yes # Doesn't work if they've little to lose.
					is_betrothed = yes
				}
			}
		NOT = { is_consort_of = scope:revela_target } # Can't honeypot your own spouse.
		NOT = { is_spouse_of = scope:revela_target } # Can't honeypot your own spouse.
		}
	}

	# More likely with attractive/lustful Mulsa, or a lustful target.
	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 2
			scope:revela_target = { has_trait = lustful }
		}
		modifier = {
			add = 1
			scope:revela_recipient = { has_trait = lustful }
		}
		modifier = {
			add = 1
			scope:revela_recipient = { has_trait = beauty_good }
		}
		modifier = {
			add = -2
			scope:revela_recipient = { has_trait = beauty_bad }
		}
	}

	immediate = {
		scope:revela_target.court_owner = { # For use in loc
			save_scope_as = court_owner
		}
	}

	option = {
		name = revela_secretum.1001.a
		revela_secretum_success_effect = {
			TYPE = life_threat_hook
		}
	}

	option = {
		name = revela_secretum.1001.b
	}
}

revela_secretum.1002 = { # Forged brothel documents.
	type = character_event
	title = revela_secretum.1002.t
	desc = revela_secretum.1002.desc
	theme = fabricate_hook_scheme
	override_background = {
		event_background = bedchamber 
	}
	right_portrait = {
		character = scope:revela_recipient
		animation = personality_dishonorable
	}
	lower_right_portrait = scope:revela_target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:revela_target = { is_ruler = yes }
	}

	# An easier sell if the target is secretive. Not a big deal if they usually frequent brothels anyway.
	weight_multiplier = {
		base = 0.5
		modifier = {
			scope:revela_target = { has_trait = deceitful }
			add = 2
		}
		modifier = {
			scope:revela_target = { has_trait = rakish }
			add = -2
		}
		modifier = {
			scope:revela_recipient = { has_trait = diligent }
			add = 1
		}
		modifier = {
			scope:revela_recipient = {
				stewardship >= 20
			}
			add = 2
		}
	}

	immediate = {
		scope:revela_target.court_owner = { # For use in loc
			save_scope_as = court_owner
		}
	}

	option = {
		name = revela_secretum.1002.a
		scope:revela_target = {
			add_character_modifier = {
				modifier = fabricate_hook_interfering_with_servants_modifier
				years = 5
			}
		}
		revela_secretum_success_effect = {
			TYPE = fabrication_hook
		}
	}

	option = {
		name = revela_secretum.1002.b
	}
}

revela_secretum.1003 = { # Just hit them with arousal until they make a fool of themselves.
	type = character_event
	title = revela_secretum.1003.t
	theme = fabricate_hook_scheme
	override_background = {
		event_background = throne_room  
	}
	right_portrait = {
		character = scope:revela_recipient
		animation = content
	}
	lower_right_portrait = scope:revela_target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:revela_target = {
						is_male = yes
					}
				}
				desc = revela_secretum.1003.desc.male
			}
			triggered_desc = {
				trigger = {
					scope:revela_target = {
						is_female = yes
					}
				}
				desc = revela_secretum.1003.desc.female
			}
			desc = revela_secretum.1003.desc.fallback
		}
	}



	# More likely with attractive/lustful Mulsa, or a lustful target.
	weight_multiplier = {
		base = 0.5
	}

	immediate = {
		scope:revela_target.court_owner = { # For use in loc
			save_scope_as = court_owner
		}
	}

	option = {
		name = revela_secretum.1003.a
		revela_secretum_success_effect = {
			TYPE = loyalty_hook
		}
	}

	option = {
		name = revela_secretum.1003.b
	}
}