﻿namespace = regula_decipere_interaction_events

##################################################
# Decipere
##################################################
# Decipere (Beguile) a character into giving you stuff
# by Ban10
##################################################

# 0001 : Decipere
# Start event, choose what you want to do
regula_decipere_interaction_events.0001 = {
	type = character_event
	title = regula_decipere_interaction_events.0001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = {
						is_regula_devoted_trigger = yes
					}
				}
				desc = regula_decipere_interaction_events.0001.desc_devoted
			}
			desc = regula_decipere_interaction_events.0001.desc_default
		}
	}

	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = scope:actor
		animation = scheme
	}

	right_portrait = {
		character = scope:recipient
		scripted_animation = {
			triggered_animation = {
				trigger = {
					scope:recipient = {
						is_regula_devoted_trigger = yes
					}
				}
				animation = throne_room_bow_1
			}
			animation = idle
		}
	}

	immediate = {
		# Check if our target has a daughter we can have as ward
		scope:recipient = {
			every_close_family_member = {
				limit = {
					is_child_of = scope:recipient
					is_female = yes
					age <= 16
					age >= 10	# To try and get targets that are more relevent
				}
				save_scope_as = potential_ward
			}

			# If no hit then try again but for any daughter <= 16 of target
			if = {
				limit = {
					NOT = { exists = scope:potential_ward }
				}
				every_close_family_member = {
					limit = {
						is_child_of = scope:recipient
						is_female = yes
						age <= 16
					}
					save_scope_as = potential_ward
				}
			}
		}

		# Grab a random title for single target yoink
		scope:recipient = {
			random_held_title = {
				limit = {
					NOT = { scope:recipient.primary_title = this }
					tier >= tier_county
				}
				save_scope_as = title_to_give
			}
		}
	}

	# Gimme your land!
	option = {
		name = regula_decipere_interaction_events.0001.a
		flavor = regula_decipere_interaction_events.0001.a.tt

		# She has land to give
		trigger = {
			scope:recipient = {
				is_landed = yes
			}
		}

		duel = {
			skills = { diplomacy stewardship learning } # Use three skills for this one
			target = scope:recipient
			15 = {
				desc = regula_decipere_interaction_events.0001.large_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 85
				}
				show_as_tooltip = {
					if = {
						limit = {
							scope:actor = {
								is_landless_adventurer = yes
							}
						}
						scope:actor = {
							save_scope_as = owner
						}
						scope:recipient = {
							save_scope_as = target
						}
						seize_realm_scheme_success_effect = yes
					}
					else = {
						scope:recipient = {
							create_title_and_vassal_change = {
								type = usurped
								save_scope_as = change
								add_claim_on_loss = no
							}
							every_held_title = {
								change_title_holder_include_vassals = {
									holder = scope:actor
									change = scope:change
								}
							}
							resolve_title_and_vassal_change = scope:change
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0101
				}
			}
			35 = {
				desc = regula_decipere_interaction_events.0001.small_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 15
				}

				# Only have this option available if we can give a single title away
				trigger = {
					exists = scope:title_to_give
					scope:actor = {
						is_landless_adventurer = no
					}
				}
				show_as_tooltip = {
					scope:recipient = {
						create_title_and_vassal_change = {
							type = usurped
							save_scope_as = change
							add_claim_on_loss = no
						}
						scope:title_to_give = {
							change_title_holder_include_vassals = {
								holder = scope:actor
								change = scope:change
							}
						}
						resolve_title_and_vassal_change = scope:change
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0102
				}
			}
			50 = {
				desc = regula_decipere_interaction_events.0001.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -45
				}
				show_as_tooltip = {
					add_prestige = -75
					scope:recipient = {
						add_opinion = {
							target = scope:actor
							modifier = respect_opinion
							opinion = -20
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0010
				}
			}
		}
	}

	# Gimme your gold!
	option = {
		name = regula_decipere_interaction_events.0001.b
		flavor = regula_decipere_interaction_events.0001.b.tt

		# She has gold to give
		trigger = {
			scope:recipient = {
				gold > 0
			}
		}

		duel = {
			skill = stewardship
			target = scope:recipient

			15 = {
				desc = regula_decipere_interaction_events.0001.large_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 85
				}
				show_as_tooltip = {
					scope:recipient = {
						pay_reserved_gold = {
							target = scope:actor
							gold = scope:recipient.gold
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0201
				}
			}
			35 = {
				desc = regula_decipere_interaction_events.0001.small_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 15
				}
				show_as_tooltip = {
					scope:recipient = {
						pay_reserved_gold = {
							target = scope:actor
							gold = {
								value = scope:recipient.gold
								multiply = 0.5
							}
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0202
				}
			}
			50 = {
				desc = regula_decipere_interaction_events.0001.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -45
				}
				show_as_tooltip = {
					add_prestige = -75
					scope:recipient = {
						add_opinion = {
							target = scope:actor
							modifier = respect_opinion
							opinion = -20
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0010
				}
			}
		}
	}

	# Gimme your prestige
	option = {
		name = regula_decipere_interaction_events.0001.c
		flavor = regula_decipere_interaction_events.0001.c.tt

		# She has prestige to give
		trigger = {
			scope:recipient = {
				prestige > 0
			}
		}

		duel = {
			skill = diplomacy
			target = scope:recipient

			15 = {
				desc = regula_decipere_interaction_events.0001.large_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 85
				}
				show_as_tooltip = {
					scope:actor = {
						add_prestige = {
							value = scope:recipient.prestige
							max = massive_prestige_value 
						}
					}

					scope:recipient = {
						add_prestige = {
							value = 0
							subtract = scope:recipient.prestige
							multiply = -1
							max = massive_prestige_value
							multiply = -1
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0301
				}
			}
			35 = {
				desc = regula_decipere_interaction_events.0001.small_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 15
				}
				show_as_tooltip = {
					scope:actor = {
						add_prestige = {
							value = scope:recipient.prestige
							max = major_prestige_value
						}
					}

					scope:recipient = {
						add_prestige = {
							value = 0
							subtract = scope:recipient.prestige
							multiply = -1
							max = major_prestige_value
							multiply = -1
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0302
				}
			}
			50 = {
				desc = regula_decipere_interaction_events.0001.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -45
				}
				show_as_tooltip = {
					add_prestige = -75
					scope:recipient = {
						add_opinion = {
							target = scope:actor
							modifier = respect_opinion
							opinion = -20
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0010
				}
			}
		}
	}

	# Gimme your daughters!
	option = {
		name = regula_decipere_interaction_events.0001.d
		flavor = regula_decipere_interaction_events.0001.d.tt

		# She has a daughter to give
		trigger = {
			exists = scope:potential_ward
		}

		duel = {
			skill = diplomacy
			target = scope:recipient

			15 = {
				desc = regula_decipere_interaction_events.0001.large_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 85
				}
				show_as_tooltip = {
					scope:recipient = {
						every_close_family_member = {
							limit = {
								is_child_of = scope:recipient
								is_female = yes
							}
							scope:actor = {
								add_courtier = prev
							}
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0401
				}
			}
			35 = {
				desc = regula_decipere_interaction_events.0001.small_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 15
				}
				show_as_tooltip = {
					scope:actor = {
						add_courtier = scope:potential_ward
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0402
				}
			}
			50 = {
				desc = regula_decipere_interaction_events.0001.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -45
				}
				show_as_tooltip = {
					add_prestige = -75
					scope:recipient = {
						add_opinion = {
							target = scope:actor
							modifier = respect_opinion
							opinion = -20
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0010
				}
			}
		}
	}

	# Gimme your secrets!
	option = {
		name = regula_decipere_interaction_events.0001.e
		flavor = regula_decipere_interaction_events.0001.e.tt

		trigger = {
			scope:recipient = {
				any_secret = {
					NOT = { is_known_by = scope:actor }
					NOT = { secret_owner = scope:actor }
				}
			}
		}

		duel = {
			skill = intrigue
			target = scope:recipient
			50 = {
				desc = regula_decipere_interaction_events.0001.large_success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					max = 45
				}

				root = {
					trigger_event = regula_decipere_interaction_events.0501
				}
			}
			50 = {
				desc = regula_decipere_interaction_events.0001.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -45
				}
				show_as_tooltip = {
					add_prestige = -75
					scope:recipient = {
						add_opinion = {
							target = scope:actor
							modifier = respect_opinion
							opinion = -20
						}
					}
				}
				root = {
					trigger_event = regula_decipere_interaction_events.0010
				}
			}
		}
	}

	# Nevermind...
	option = {
		name = regula_decipere_interaction_events.0001.f
		flavor = regula_decipere_interaction_events.0001.f.tt

		# Consolation prize
		add_prestige = 50

		scope:recipient = {
			add_opinion = {
				modifier = friendliness_opinion
				target = root
				opinion = 10
			}
		}
	}
}

# We cancelled going, remove cooldown
regula_decipere_interaction_events.0002 = {
	type = character_event
	hidden = yes

	immediate = {
		scope:actor = {
			remove_interaction_cooldown_against = { 
				interaction = regula_beguile_interaction
				target = scope:recipient
			}
		}
	}
}

## 0010 - Failure
regula_decipere_interaction_events.0010 = {
	type = character_event
	title = regula_decipere_interaction_events.0010.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0010.desc_devoted
			}
			desc = regula_decipere_interaction_events.0010.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = scope:actor
		animation = shock
	}

	right_portrait = {
		character = scope:recipient
		scripted_animation = {
			triggered_animation = {
				trigger = {
					has_trait = devoted_trait_group
				}
				animation = grief
			}
		}
		animation = rage
	}

	#  Drat!
	option = {
		name = regula_decipere_interaction_events.0010.a

		add_prestige = -75

		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = respect_opinion
				opinion = -20
			}
		}
	}
}

## 0101 - Make her sign away her titles to you
regula_decipere_interaction_events.0101 = {
	type = character_event
	title = regula_decipere_interaction_events.0101.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0101.desc_devoted
			}
			desc = regula_decipere_interaction_events.0101.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = personality_zealous
	}

	# Yoink her land
	option = {
		name = regula_decipere_interaction_events.0101.a

		# If adventurer, we use the seize realm effects
		if = {
			limit = {
				scope:actor = {
					is_landless_adventurer = yes
				}
			}
			scope:actor = {
				save_scope_as = owner
			}
			scope:recipient = {
				save_scope_as = target
			}
			seize_realm_scheme_success_effect = yes
		}
		else = {
			scope:recipient = {
				create_title_and_vassal_change = {
					type = usurped
					save_scope_as = change
					add_claim_on_loss = no
				}
				every_held_title = {
					change_title_holder_include_vassals = {
						holder = scope:actor
						change = scope:change
					}
				}
				resolve_title_and_vassal_change = scope:change
			}
		}
	}
}

## 0102 - Make her sign away a random title to you (not primary)
regula_decipere_interaction_events.0102 = {
	type = character_event
	title = regula_decipere_interaction_events.0102.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0102.desc_devoted
			}
			desc = regula_decipere_interaction_events.0102.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = idle
	}

	# Yoink her land
	option = {
		name = regula_decipere_interaction_events.0102.a

		scope:recipient = {
			create_title_and_vassal_change = {
				type = usurped
				save_scope_as = change
				add_claim_on_loss = no
			}
			scope:title_to_give = {
				change_title_holder_include_vassals = {
					holder = scope:actor
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
	}
}

## 0201 - Take her gold
regula_decipere_interaction_events.0201 = {
	type = character_event
	title = regula_decipere_interaction_events.0201.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0201.desc_devoted
			}
			desc = regula_decipere_interaction_events.0201.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_zealous
	}

	# Yoink her gold
	option = {
		name = regula_decipere_interaction_events.0201.a

		scope:recipient = {
			pay_reserved_gold = {
				target = scope:actor
				gold = scope:recipient.gold
			}
		}
	}

	# Take her clothes as well!
	option = {
		name = regula_decipere_interaction_events.0201.b

		scope:actor = {
			add_gold = minor_gold_value # "Clothing" gold
		}

		scope:recipient = {
			pay_reserved_gold = {
				target = scope:actor
				gold = scope:recipient.gold
			}

			# Even her clothing!
			add_character_modifier = {
				modifier = diplomacy_majesty_4090_no_raiment_modifier
				years = 5
			}
		}
	}
}

## 0202 - Take half of her gold
regula_decipere_interaction_events.0202 = {
	type = character_event
	title = regula_decipere_interaction_events.0202.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0202.desc_devoted
			}
			desc = regula_decipere_interaction_events.0202.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = idle
	}

	# Yoink some of her gold
	option = {
		name = regula_decipere_interaction_events.0202.a

		scope:recipient = {
			pay_reserved_gold = {
				target = scope:actor
				gold = {
					value = scope:recipient.gold
					multiply = 0.5
				}
			}
		}
	}
}

## 0301 - Make her praise you
regula_decipere_interaction_events.0301 = {
	type = character_event
	title = regula_decipere_interaction_events.0301.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0301.desc_devoted
			}
			desc = regula_decipere_interaction_events.0301.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = personality_zealous
	}

	# Yoink her prestige
	option = {
		name = regula_decipere_interaction_events.0301.a

		scope:actor = {
			add_prestige = {
				value = scope:recipient.prestige
				max = massive_prestige_value
			}
		}

		scope:recipient = {
			add_prestige = {
				value = 0
				subtract = scope:recipient.prestige
				multiply = -1
				max = massive_prestige_value
				multiply = -1
			}
		}
	}
}

## 0302 - Make her praise you, minor success
regula_decipere_interaction_events.0302 = {
	type = character_event
	title = regula_decipere_interaction_events.0302.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0302.desc_devoted
			}
			desc = regula_decipere_interaction_events.0302.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = idle
	}

	# Yoink her prestige
	option = {
		name = regula_decipere_interaction_events.0301.a

		scope:actor = {
			add_prestige = {
				value = scope:recipient.prestige
				max = major_prestige_value
			}
		}

		scope:recipient = {
			add_prestige = {
				value = 0
				subtract = scope:recipient.prestige
				multiply = -1
				max = major_prestige_value
				multiply = -1
			}
		}
	}
}

## 0401 - Make her give all of her daughters (to your court)
regula_decipere_interaction_events.0401 = {
	type = character_event
	title = regula_decipere_interaction_events.0401.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0401.desc_devoted
			}
			desc = regula_decipere_interaction_events.0401.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = personality_zealous
	}

	# Yoink her daughters
	option = {
		name = regula_decipere_interaction_events.0401.a

		scope:recipient = {
			every_close_family_member = {
				limit = {
					is_child_of = scope:recipient
					is_female = yes
				}
				hidden_effect = {
					scope:actor = {
						add_courtier = prev
					}
				}
				scope:actor.current_travel_plan = {
					add_companion = prev
				}
			}
		}
	}
}

## 0402 - Make her give one of her daughters to you
regula_decipere_interaction_events.0402 = {
	type = character_event
	title = regula_decipere_interaction_events.0401.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0401.desc_devoted
			}
			desc = regula_decipere_interaction_events.0401.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = idle
	}

	# Yoink her daughter
	option = {
		name = regula_decipere_interaction_events.0401.a

		hidden_effect = {
			scope:actor = {
				add_courtier = scope:potential_ward
			}
		}
		scope:actor.current_travel_plan = {
			add_companion = scope:potential_ward
		}
	}
}

## 0501 - Make her tell you the secrets she knows (including her own)
regula_decipere_interaction_events.0501 = {
	type = character_event
	title = regula_decipere_interaction_events.0501.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient = { has_trait = devoted_trait_group }
				}
				desc = regula_decipere_interaction_events.0501.desc_devoted
			}
			desc = regula_decipere_interaction_events.0501.desc_default
		}
	}
	theme = regula_theme
	override_background = {
		reference = council_chamber
	}

	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:recipient
		animation = personality_zealous
	}

	# Yoink her secrets
	option = {
		name = regula_decipere_interaction_events.0501.a

		scope:recipient = {
			every_known_secret = {
				limit = {
					NOT = { is_known_by = scope:actor }
					NOT = { secret_owner = scope:actor }
				}
				reveal_to = scope:actor
			}
		}
	}
}