﻿namespace = court_amenities_interactions


#########################
# Sumptuary Debate		#
# by James Beaumont		#
# 0001-0004				#
#########################

#	The challenge to debate is issued!
#		by JB
court_amenities_interactions.0001 = {
	type = character_event
	title = court_amenities_interactions.0001.t
	desc = {
		desc = court_amenities_interactions.0001.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:recipient.faith = { has_doctrine_parameter = naked_adherents_active }
				}
				desc = court_amenities_interactions.0001.desc.nakey
			}
			triggered_desc = {
				trigger = {
					scope:actor = { has_trait = born_in_the_purple }
					scope:recipient = { NOT = { has_trait = born_in_the_purple } }
				}
				desc = court_amenities_interactions.0001.desc_byzantine
			}
			triggered_desc = {
				trigger = {
					OR = {
						scope:recipient = { is_landed = yes }
						scope:recipient = { has_any_court_position = yes }
					}
				}
				desc = court_amenities_interactions.0001.desc_court_position
			}
			desc = court_amenities_interactions.0001.desc
		}
		desc = court_amenities_interactions.0001.desc_outro
	}
	theme = party
	override_background = {
		reference = council_chamber
	}
	left_portrait =	root
	right_portrait = scope:actor

	immediate = {
		# Only the initiator of the challenge is destined to be landed
		scope:actor.capital_province.barony = { save_scope_as = debate_locale }
	}

	#I accept the challenge.
	option = {
		name = court_amenities_interactions.0001.a
		duel = {
			skills = {
				stewardship # How well do you understand the law?
				diplomacy # How good are you at convincing people?
			}
			target = scope:actor
			50 = {	#Defender wins the toss.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				# Attractive people are more likely to win the debate
				modifier = {
					add = {
						value = scope:recipient.attraction
						multiply = 5
					}
				}
				modifier = {
					add = {
						value = scope:actor.attraction
						multiply = -5
					}
				}
				min = 5
				custom_tooltip = court_amenities_interactions.0001.a.tt_success
				hidden_effect = {
					random_list = {
						90 = { # Success, gain prestige
							scope:actor = {
								add_character_flag = {
									flag = sumptuary_debate_lost
									years = 1
								}
								trigger_event = {
									id = court_amenities_interactions.0002
									days = 7
								}
							}
							scope:recipient = {
								add_character_flag = {
									flag = sumptuary_debate_won
									years = 1
								}
								trigger_event = {
									id = court_amenities_interactions.0003
									days = 7
								}
							}
						}
						10 = { # Critical success, gain imprisonment reason
							trigger = {
								scope:recipient = {
									is_landed = yes
								}
								scope:actor = {
									is_ai = yes
								}
							}
							compare_modifier = {
								target = scope:recipient
								value = diplomacy
							}
							compare_modifier = {
								target = scope:actor
								value = diplomacy
								multiplier = -1
							}
							scope:actor = {
								save_scope_as = victim
							}
							scope:recipient = {
								trigger_event = {
									id = court_amenities_interactions.0004
									days = 7
								}
							}
						}
					}
				}
			}
			50 = {	#Attacker wins the toss.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				# Attractive people are more likely to win the debate
				modifier = {
					add = {
						value = scope:recipient.attraction
						multiply = -5
					}
				}
				modifier = {
					add = {
						value = scope:actor.attraction
						multiply = 5
					}
				}
				min = 5
				custom_tooltip = court_amenities_interactions.0001.a.tt_failure
				hidden_effect = {
					random_list = {
						90 = { # Success, gain prestige
							scope:recipient = {
								add_character_flag = {
									flag = sumptuary_debate_lost
									years = 1
								}
								trigger_event = {
									id = court_amenities_interactions.0003
									days = 7
								}
							}
							scope:actor = {
								add_character_flag = {
									flag = sumptuary_debate_won
									years = 1
								}
								trigger_event = {
									id = court_amenities_interactions.0002
									days = 7
								}
							}
						}
						10 = { # Critical success, gain imprisonment reason
							trigger = {
								scope:actor = {
									is_landed = yes
								}
								scope:recipient = {
									is_ai = yes
								}
							}
							compare_modifier = {
								target = scope:actor
								value = stewardship
							}
							compare_modifier = {
								target = scope:recipient
								value = stewardship
								multiplier = -1
							}
							scope:recipient = {
								save_scope_as = victim
							}
							scope:actor = {
								trigger_event = {
									id = court_amenities_interactions.0004
									days = 7
								}
							}
						}
					}
				}
			}
		}
		#No stress, as AI is forced to pick this.
		ai_chance = {
			base = 100
		}
	}
	
	#I surrender, opponent gains a weak hook and prestige
	option = {
		name = court_amenities_interactions.0001.b
		trigger = { is_ai = no }	#Only players may opt out.
		add_prestige = medium_prestige_loss
		custom_tooltip = court_amenities_interactions.0001.b.tt
		hidden_effect = {
			scope:actor = {
				send_interface_toast = {
					title = court_amenities_interactions.0001.b_turned_down
					left_icon = scope:recipient
				}
				add_prestige = medium_prestige_gain
				remove_character_modifier = used_sumptuary_debate_modifier
			}
		}
		stress_impact = {
			diligent = minor_stress_impact_gain
			arrogant = minor_stress_impact_gain
			brave = minor_stress_impact_gain
		}
		ai_chance = {	#Unavailable to the AI.
			base = 0
		}
	}
}

#	#Debate results: aggressor / actor
#		by James Beaumont
court_amenities_interactions.0002 = {
	type = character_event
	title = court_amenities_interactions.0002.t
	desc = {
		desc = court_amenities_interactions.0002.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = sumptuary_debate_won
					scope:recipient.faith = { has_doctrine_parameter = naked_adherents_active }
				}
				desc = court_amenities_interactions.0002.desc_won.nakey
			}
			triggered_desc = {
				trigger = {
					has_character_flag = sumptuary_debate_won
				}
				desc = court_amenities_interactions.0002.desc_won
			}
			triggered_desc = {
				trigger = {
					has_character_flag = sumptuary_debate_lost
					scope:actor.faith = { has_doctrine_parameter = naked_adherents_active }
				}
				desc = court_amenities_interactions.0002.desc_lost.nakey
			}
			desc = court_amenities_interactions.0002.desc_lost
		}
	}
	theme = party
	override_background = {
		reference = council_chamber
	}
	left_portrait = {
		character = scope:recipient
		triggered_animation = {
			trigger = {
				scope:recipient = { has_character_flag = sumptuary_debate_lost }
			}
			animation = disbelief
		}
		animation = schadenfreude
		triggered_outfit = {
			trigger = {
				scope:recipient = {
					faith = { has_doctrine_parameter = naked_adherents_active }
					has_character_flag = sumptuary_debate_lost
				}
			}
			outfit_tags = { beggar_rags }
		}
	}
	right_portrait = {
		character = scope:actor
		triggered_animation = {
			trigger = {
				scope:actor = { has_character_flag = sumptuary_debate_lost }
			}
			animation = disbelief
		}
		animation = schadenfreude
		triggered_outfit = {
			trigger = {
				scope:actor = {
					faith = { has_doctrine_parameter = naked_adherents_active }
					has_character_flag = sumptuary_debate_lost
				}
			}
			outfit_tags = { beggar_rags }
		}
	}

	immediate = {
		if = {
			limit = {
				scope:recipient = {
					faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
					has_character_flag = sumptuary_debate_lost
				}
			}
			scope:recipient = {
				add_character_flag = is_naked
			}
		}
		if = {
			limit = {
				scope:actor = {
					faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
					has_character_flag = sumptuary_debate_lost
				}
			}
			scope:actor = {
				add_character_flag = is_naked
			}
		}
	}

	#The result.
	option = {
		name = {
			trigger = { has_character_flag = sumptuary_debate_won }
			text = court_amenities_interactions.0002.a_won
		}
		name = {
			trigger = {
				has_character_flag = sumptuary_debate_lost
				has_trait = humble
				faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
			}
			text = court_amenities_interactions.0002.a_lost.humble
		}
		name = {
			trigger = {
				has_character_flag = sumptuary_debate_lost
				has_trait = lustful
				faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
			}
			text = court_amenities_interactions.0002.a_lost.lustful
		}
		name = {
			trigger = { has_character_flag = sumptuary_debate_lost }
			text = court_amenities_interactions.0002.a_lost
		}
		if = {
			limit = { has_character_flag = sumptuary_debate_won }
			add_prestige = major_prestige_gain
			reverse_add_opinion = {
				target = scope:recipient
				modifier = sumptuary_debate_loser_opinion
			}
		}
		else_if = {
			limit = { has_character_flag = sumptuary_debate_lost }
			add_prestige = major_prestige_loss
			reverse_add_opinion = {
				target = scope:recipient
				modifier = sumptuary_debate_victor_opinion
			}
			if = { # Humble and horny characters don't care if people see them naked, naked characters are always upset to wear clothes
				limit = {
					OR = {
						faith = { has_doctrine_parameter = naked_adherents_active }
						NOR = {
							has_trait = humble
							has_trait = lustful
						}
					}
				}
				add_stress = major_stress_gain
			}
		}
		ai_chance = {	#No other options available.
			base = 100
		}
	}
	after = {
		scope:recipient = {
			if = {
				limit = {
					has_character_flag = is_naked
				}
				remove_character_flag = is_naked
			}
		}
		scope:actor = {
			if = {
				limit = {
					has_character_flag = is_naked
				}
				remove_character_flag = is_naked
			}
		}
	}
}

#	#Debate results: defender / recipient
#		by James Beaumont
court_amenities_interactions.0003 = {
	type = character_event
	title = court_amenities_interactions.0002.t
	desc = {
		desc = court_amenities_interactions.0002.desc_intro
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = sumptuary_debate_won
					scope:actor.faith = { has_doctrine_parameter = naked_adherents_active }
				}
				desc = court_amenities_interactions.0003.desc_won.nakey
			}
			triggered_desc = {
				trigger = {
					has_character_flag = sumptuary_debate_won
					scope:actor.faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
				}
				desc = court_amenities_interactions.0003.desc_won
			}
			triggered_desc = {
				trigger = {
					has_character_flag = sumptuary_debate_lost
					scope:recipient.faith = { has_doctrine_parameter = naked_adherents_active }
				}
				desc = court_amenities_interactions.0002.desc_lost.nakey
			}
			desc = court_amenities_interactions.0002.desc_lost
		}
	}
	theme = party
	override_background = {
		reference = council_chamber
	}
	left_portrait = {
		character = scope:actor
		triggered_animation = {
			trigger = {
				scope:actor = { has_character_flag = sumptuary_debate_lost }
			}
			animation = disbelief
		}
		animation = schadenfreude
		triggered_outfit = {
			trigger = {
				scope:actor = {
					has_character_flag = sumptuary_debate_lost
					faith = { has_doctrine_parameter = naked_adherents_active }
				}
			}
			outfit_tags = { beggar_rags }
		}
	}
	right_portrait = {
		character = scope:recipient
		triggered_animation = {
			trigger = {
				scope:recipient = { has_character_flag = sumptuary_debate_lost }
			}
			animation = disbelief
		}
		animation = schadenfreude
		triggered_outfit = {
			trigger = {
				scope:recipient = {
					has_character_flag = sumptuary_debate_lost
					faith = { has_doctrine_parameter = naked_adherents_active }
				}
			}
			outfit_tags = { beggar_rags }
		}
	}

	immediate = {
		if = {
			limit = {
				scope:recipient = {
					faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
					has_character_flag = sumptuary_debate_lost
				}
			}
			scope:recipient = {
				add_character_flag = is_naked
			}
		}
		if = {
			limit = {
				scope:actor = {
					faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
					has_character_flag = sumptuary_debate_lost
				}
			}
			scope:actor = {
				add_character_flag = is_naked
			}
		}
	}

	#The result.
	option = {
		name = {
			trigger = { has_character_flag = sumptuary_debate_won }
			text = court_amenities_interactions.0002.a_won
		}
		name = {
			trigger = {
				has_character_flag = sumptuary_debate_lost
				has_trait = humble
				faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
			}
			text = court_amenities_interactions.0002.a_lost.humble
		}
		name = {
			trigger = {
				has_character_flag = sumptuary_debate_lost
				has_trait = lustful
				faith = { NOT = { has_doctrine_parameter = naked_adherents_active } }
			}
			text = court_amenities_interactions.0002.a_lost.lustful
		}
		name = {
			trigger = { has_character_flag = sumptuary_debate_lost }
			text = court_amenities_interactions.0002.a_lost
		}
		if = {
			limit = { has_character_flag = sumptuary_debate_won}
			add_prestige = major_prestige_gain
			reverse_add_opinion = {
				target = scope:actor
				modifier = sumptuary_debate_loser_opinion
			}
		}
		else_if = {
			limit = { has_character_flag = sumptuary_debate_lost }
			add_prestige = major_prestige_loss
			reverse_add_opinion = {
				target = scope:actor
				modifier = sumptuary_debate_victor_opinion
			}
			if = { # Humble and horny characters don't care if people see them naked, naked characters are always upset to wear clothes
				limit = {
					OR = {
						faith = { has_doctrine_parameter = naked_adherents_active }
						NOR = {
							has_trait = humble
							has_trait = lustful
						}
					}
				}
				add_stress = major_stress_gain
			}
		}
		#No stress, as the AI is forced to get here.
		ai_chance = {	#No other options available.
			base = 100
		}
	}
	after = {
		if = {
			limit = {
				scope:recipient = {
					has_character_flag = is_naked
				}
			}
			scope:recipient = {
				remove_character_flag = is_naked
			}
		}
		if = {
			limit = {
				scope:actor = {
					has_character_flag = is_naked
				}
			}
			scope:actor = {
				remove_character_flag = is_naked
			}
		}
	}
}

################################
# Things go really bad for the defender
# by James Beaumont
################################
court_amenities_interactions.0004 = {
	type = character_event
	title = court_amenities_interactions.0001.t
	desc = {
		desc = court_amenities_interactions.0002.desc_intro
		desc = court_amenities_interactions.0004.desc
	}
	theme = party
	override_background = {
		reference = council_chamber
	}
	left_portrait = {
		character = root
		animation = scheme
	}
	right_portrait = {
		character = scope:victim
		animation = pain
	}
	
	option = { # Let them off with a warning
		name = court_amenities_interactions.0004.a
		add_hook = {
			type = sumptuary_crime_hook
			target = scope:victim
		}
	}
	
	option = { # Arrest them
		name = court_amenities_interactions.0004.b
		add_opinion = {
			modifier = sumptuary_violation_opinion
			target = scope:victim
		}
		rightfully_imprison_character_effect = {
			TARGET = scope:victim
			IMPRISONER = root
		}
	}
}
