namespace = ep1_character_interaction

##################################################
#
#	Character Interaction Events
#
# 0001 - 0010	Indebt Guest
##################################################










##################################################
# CHARACTER INTERACTION EVENTS

##################################################
# A Sensible Recompense
# by Ewan Cowhig Croft
# 0001 - 0010
##################################################

scripted_trigger ep1_character_interaction_0001_valid_hostile_relation_trigger = {
	# Must be at a court of some kind *other* than your own.
	exists = host
	scope:actor != host
	# And not in scope:actor's prison.
	NOR = {
		imprisoner ?= scope:actor
	}
	# Double check that this'd be an appropriate court to send a plant.
	save_temporary_scope_as = current_target
	scope:actor = {
		OR = {
			# Either you've got a scheme on the go...
			any_scheme = {
				hostile_scheme_trigger = yes
				scheme_target_character = scope:current_target
			}
			# ... or you could start one.
			can_start_hostile_scheme_against_trigger = { TARGET = scope:current_target}
		}
	}
}

scripted_trigger ep1_character_interaction_0001_valid_rival_trigger = {
	ep1_character_interaction_0001_valid_hostile_relation_trigger = yes
	OR = {
		NOT = { exists = scope:actor_nemesis }
		this != scope:actor_nemesis
	}
}

scripted_effect ep1_character_interaction_0001_move_character_and_family_effect = {
	scope:recipient = {
		# Whatever else happens, just move them.
		scope:actor = { remove_courtier_or_guest = scope:recipient }
		$DESTINATION$ = { add_courtier = scope:recipient }
		# If they have any family, quietly send them along too.
		hidden_effect = {
			if = {
				limit = {
					any_traveling_family_member = { }
				}
				every_traveling_family_member = {
					save_temporary_scope_as = family_to_shunt
					scope:actor = { remove_courtier_or_guest = scope:family_to_shunt }
					$DESTINATION$ = { add_courtier = scope:family_to_shunt }
				}
			}
		}
	}
}

#	Trick a guest into a debt & turn them into an agent.
ep1_character_interaction.0001 = {
	type = character_event
	title = ep1_character_interaction.0001.t
	desc = {
		desc = ep1_character_interaction.0001.desc.intro
		first_valid = {
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:lustful }
				desc = ep1_character_interaction.0001.desc.lustful
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:chaste }
				desc = ep1_character_interaction.0001.desc.chaste
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:gluttonous }
				desc = ep1_character_interaction.0001.desc.gluttonous
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:temperate }
				desc = ep1_character_interaction.0001.desc.temperate
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:greedy }
				desc = ep1_character_interaction.0001.desc.greedy
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:generous }
				desc = ep1_character_interaction.0001.desc.generous
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:lazy }
				desc = ep1_character_interaction.0001.desc.lazy
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:diligent }
				desc = ep1_character_interaction.0001.desc.diligent
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:wrathful }
				desc = ep1_character_interaction.0001.desc.wrathful
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:calm }
				desc = ep1_character_interaction.0001.desc.calm
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:patient }
				desc = ep1_character_interaction.0001.desc.patient
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:impatient }
				desc = ep1_character_interaction.0001.desc.impatient
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:arrogant }
				desc = ep1_character_interaction.0001.desc.arrogant
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:humble }
				desc = ep1_character_interaction.0001.desc.humble
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:deceitful }
				desc = ep1_character_interaction.0001.desc.deceitful
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:honest }
				desc = ep1_character_interaction.0001.desc.honest
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:craven }
				desc = ep1_character_interaction.0001.desc.craven
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:brave }
				desc = ep1_character_interaction.0001.desc.brave
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:shy }
				desc = ep1_character_interaction.0001.desc.shy
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:gregarious }
				desc = ep1_character_interaction.0001.desc.gregarious
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:ambitious }
				desc = ep1_character_interaction.0001.desc.ambitious
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:content }
				desc = ep1_character_interaction.0001.desc.content
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:arbitrary }
				desc = ep1_character_interaction.0001.desc.arbitrary
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:just }
				desc = ep1_character_interaction.0001.desc.just
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:cynical }
				desc = ep1_character_interaction.0001.desc.cynical
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:zealous }
				desc = ep1_character_interaction.0001.desc.zealous
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:paranoid }
				desc = ep1_character_interaction.0001.desc.paranoid
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:trusting }
				desc = ep1_character_interaction.0001.desc.trusting
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:compassionate }
				desc = ep1_character_interaction.0001.desc.compassionate
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:callous }
				desc = ep1_character_interaction.0001.desc.callous
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:sadistic }
				desc = ep1_character_interaction.0001.desc.sadistic
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:stubborn }
				desc = ep1_character_interaction.0001.desc.stubborn
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:fickle }
				desc = ep1_character_interaction.0001.desc.fickle
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:vengeful }
				desc = ep1_character_interaction.0001.desc.vengeful
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:forgiving }
				desc = ep1_character_interaction.0001.desc.forgiving
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:fallback_1 }
				desc = ep1_character_interaction.0001.desc.fallback_1
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:fallback_2 }
				desc = ep1_character_interaction.0001.desc.fallback_2
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:fallback_3 }
				desc = ep1_character_interaction.0001.desc.fallback_3
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:fallback_4 }
				desc = ep1_character_interaction.0001.desc.fallback_4
			}
			triggered_desc = {
				trigger = { scope:false_flag_type = flag:fallback_5 }
				desc = ep1_character_interaction.0001.desc.fallback_5
			}
		}
		desc = ep1_character_interaction.0001.desc.outro
	}
	theme = intrigue_skulduggery_focus
	left_portrait = {
		character = scope:actor
		animation = schadenfreude
	}
	right_portrait = {
		character = scope:recipient
		animation = fear
	}
	lower_center_portrait = scope:actor_nemesis
	lower_right_portrait = scope:actor_rival
	override_background = { reference = throne_room }

	immediate = {
		# Apply the interaction's effects.
		indebt_guest_interaction_accepted_effect = yes
		# Roll the offending crime.
		## Percentages even throughout: we're not fussed about which result you roll.
		scope:recipient = {
			random_list = {
				# lustful
				100 = {
					trigger = { has_trait = lustful }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:lustful
					}
				}
				# chaste
				100 = {
					trigger = { has_trait = chaste }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:chaste
					}
				}
				# gluttonous
				100 = {
					trigger = { has_trait = gluttonous }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:gluttonous
					}
				}
				# temperate
				100 = {
					trigger = { has_trait = temperate }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:temperate
					}
				}
				# greedy
				100 = {
					trigger = { has_trait = greedy }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:greedy
					}
				}
				# generous
				100 = {
					trigger = { has_trait = generous }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:generous
					}
				}
				# lazy
				100 = {
					trigger = { has_trait = lazy }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:lazy
					}
				}
				# diligent
				100 = {
					trigger = { has_trait = diligent }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:diligent
					}
				}
				# wrathful
				100 = {
					trigger = { has_trait = wrathful }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:wrathful
					}
				}
				# calm
				100 = {
					trigger = { has_trait = calm }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:calm
					}
				}
				# patient
				100 = {
					trigger = { has_trait = patient }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:patient
					}
				}
				# impatient
				100 = {
					trigger = { has_trait = impatient }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:impatient
					}
				}
				# arrogant
				100 = {
					trigger = { has_trait = arrogant }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:arrogant
					}
				}
				# humble
				100 = {
					trigger = { has_trait = humble }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:humble
					}
				}
				# deceitful
				100 = {
					trigger = { has_trait = deceitful }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:deceitful
					}
				}
				# honest
				100 = {
					trigger = { has_trait = honest }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:honest
					}
				}
				# craven
				100 = {
					trigger = { has_trait = craven }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:craven
					}
				}
				# brave
				100 = {
					trigger = { has_trait = brave }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:brave
					}
				}
				# shy
				100 = {
					trigger = { has_trait = shy }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:shy
					}
				}
				# gregarious
				100 = {
					trigger = { has_trait = gregarious }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:gregarious
					}
				}
				# ambitious
				100 = {
					trigger = { has_trait = ambitious }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:ambitious
					}
				}
				# content
				100 = {
					trigger = { has_trait = content }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:content
					}
				}
				# arbitrary
				100 = {
					trigger = { has_trait = arbitrary }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:arbitrary
					}
				}
				# just
				100 = {
					trigger = { has_trait = just }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:just
					}
				}
				# cynical
				100 = {
					trigger = { has_trait = cynical }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:cynical
					}
				}
				# zealous
				100 = {
					trigger = { has_trait = zealous }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:zealous
					}
				}
				# paranoid
				100 = {
					trigger = { has_trait = paranoid }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:paranoid
					}
				}
				# trusting
				100 = {
					trigger = { has_trait = trusting }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:trusting
					}
				}
				# compassionate
				100 = {
					trigger = { has_trait = compassionate }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:compassionate
					}
				}
				# callous
				100 = {
					trigger = { has_trait = callous }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:callous
					}
				}
				# sadistic
				100 = {
					trigger = { has_trait = sadistic }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:sadistic
					}
				}
				# stubborn
				100 = {
					trigger = { has_trait = stubborn }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:stubborn
					}
				}
				# fickle
				100 = {
					trigger = { has_trait = fickle }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:fickle
					}
				}
				# vengeful
				100 = {
					trigger = { has_trait = vengeful }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:vengeful
					}
				}
				# forgiving
				100 = {
					trigger = { has_trait = forgiving }
					save_scope_value_as = {
						name = false_flag_type
						value = flag:forgiving
					}
				}
				# fallback_1
				100 = {
					save_scope_value_as = {
						name = false_flag_type
						value = flag:fallback_1
					}
				}
				# fallback_2
				100 = {
					save_scope_value_as = {
						name = false_flag_type
						value = flag:fallback_2
					}
				}
				# fallback_3
				100 = {
					save_scope_value_as = {
						name = false_flag_type
						value = flag:fallback_3
					}
				}
				# fallback_4
				100 = {
					save_scope_value_as = {
						name = false_flag_type
						value = flag:fallback_4
					}
				}
				# fallback_5
				100 = {
					save_scope_value_as = {
						name = false_flag_type
						value = flag:fallback_5
					}
				}
			}
		}
		# Sort scopes for event options.
		scope:actor = {
			# If scope:actor has a nemesis, save them for loc.
			if = {
				limit = {
					any_relation = {
						type = nemesis
						count >= 1
						ep1_character_interaction_0001_valid_hostile_relation_trigger = yes
					}
				}
				random_relation = {
					type = nemesis
					limit = { ep1_character_interaction_0001_valid_hostile_relation_trigger = yes }
					save_scope_as = actor_nemesis
				}
			}
			# If scope:actor has any valid rivals, pick a random one for option B.
			if = {
				limit = {
					any_relation = {
						type = rival
						count >= 1
						ep1_character_interaction_0001_valid_rival_trigger = yes
					}
				}
				random_relation = {
					type = rival
					# Prefer rivals that are targets of hostile schemes.
					limit = {
						any_targeting_scheme = {
							scheme_owner = scope:actor
							is_hostile = yes
						}
						ep1_character_interaction_0001_valid_rival_trigger = yes
					}
					# Failing that, rivals who are targets of any schemes.
					alternative_limit = {
						any_targeting_scheme = {
							scheme_owner = scope:actor
							is_hostile = no
						}
						ep1_character_interaction_0001_valid_rival_trigger = yes
					}
					# Otherwise just any rando rival who could be schemed against.
					alternative_limit = { ep1_character_interaction_0001_valid_rival_trigger = yes }
					save_scope_as = actor_rival
				}
			}
		}
	}

	# *Cackling* Oh yes, [actor_nemesis.GetFirstName] will never see this coming!
	option = {
		name = ep1_character_interaction.0001.a
		trigger = { exists = scope:actor_nemesis }

		# Quietly add scope:recipient as a courtier of scope:actor_nemesis.
		ep1_character_interaction_0001_move_character_and_family_effect = { DESTINATION = scope:actor_nemesis }

		stress_impact = {
			patient = miniscule_stress_impact_loss
			vengeful = minor_stress_impact_loss
			impatient = medium_stress_impact_gain
			trusting = major_stress_impact_gain
		}
		ai_chance = {
			# If valid, this should always be the choice selected.
			base = 100
		}
	}
	
	# Excellent! Now, you will deliver yourself to [actor_rival.GetFirstNamePossessive] court...
	option = {
		name = ep1_character_interaction.0001.b
		trigger = { exists = scope:actor_rival }

		# Quietly add scope:recipient as a courtier of scope:actor_rival.
		ep1_character_interaction_0001_move_character_and_family_effect = { DESTINATION = scope:actor_rival }

		stress_impact = {
			patient = miniscule_stress_impact_loss
			vengeful = minor_stress_impact_loss
			impatient = medium_stress_impact_gain
			trusting = major_stress_impact_gain
		}
		ai_chance = {
			# Never pick this option...
			base = 0
			# ... unless there's no nemesis, in which case it should be the default.
			modifier = {
				add = 100
				NOT = { exists = scope:actor_rival }
			}
		}
	}
	
	# Now, begone till I have need of you.
	option = {
		name = ep1_character_interaction.0001.c

		# Boot 'em out.
		hidden_effect = {
			scope:recipient = { select_and_move_to_pool_effect = yes }
		}
		show_as_tooltip = {
			remove_courtier_or_guest = scope:recipient
		}

		stress_impact = {
			shy = minor_stress_impact_loss
			gregarious = minor_stress_impact_gain
		}
		ai_chance = {
			# AI should never be taking this without a nemesis, but if they do, it doesn't matter where they send scope:recipient.
			base = 0
		}
	}

	# Naturally, you will stay where I can keep an eye on you.
	option = {
		name = ep1_character_interaction.0001.d

		# Status quo: no extra changes here.

		# No stress impact necessary for the fallback option.
		ai_chance = {
			# AI should never be taking this without a nemesis, but if they do, it doesn't matter where they send scope:recipient.
			base = 0
		}
	}
}

