﻿namespace = zgc_wedding_relationship_events

#############################
#### Relationship Events ####
#############################

#RELATIONSHIP SETTING Events

#Lover relationship
zgc_wedding_relationship_events.103 = {
	type = character_event
	title = zgc_wedding_relationship_events.103.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { is_attracted_to_gender_of = scope:spouse }
				}
				desc = zgc_wedding_relationship_events.103.unattracted_desc
			}
			desc = zgc_wedding_relationship_events.103.attracted_desc
		}
	}
	theme = marriage
	
	left_portrait = {
		character = root
		animation = flirtation_left
	}

	right_portrait = {
		character = scope:spouse
		animation = flirtation
	}
	
	immediate = {
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
	}
	
	#Accept lover relationship
	option = {
		name = zgc_wedding_relationship_events.103.a
		add_internal_flag = special
		trigger = {
			is_ai = no
			is_attracted_to_gender_of = scope:spouse
			NOT = {
				any_relation = {
					type = lover
					this = scope:spouse
				}
			}
		}

		set_relation_lover = { reason = lover_wedding_relationship target = scope:spouse }
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 2
				months = 2
			}
		}
	}
	
	#Actually, would prefer to be friends
	option = {
		name = zgc_wedding_relationship_events.103.b
		trigger = {
			is_ai = no
			NOT = {
				any_relation = {
					type = lover
					this = scope:spouse
				}
			}
		}
		set_relation_friend = { reason = friend_wedding_relationship target = scope:spouse }
		scope:spouse = {
			add_opinion = {
				modifier = disappointed_opinion
				opinion = -10
				target = root
			}
		}
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 3
				months = 2
			}
		}
	}
	
	# Want no relationship
	option = {
		name = zgc_wedding_relationship_events.103.c
		trigger = {
			is_ai = no
			NOT = {
				any_relation = {
					type = lover
					this = scope:spouse
				}
			}
		}
		scope:spouse = {
			add_opinion = {
				modifier = disappointed_opinion
				opinion = -20
				target = root
			}
		}
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 5
				months = 2
			}
		}
	}
	
	#Existing Relationship	
	option = {
		name = zgc_wedding_relationship_events.103.a
		add_internal_flag = special
		trigger = {
			is_ai = no
			is_attracted_to_gender_of = scope:spouse
			any_relation = {
				type = lover
				this = scope:spouse
			}
		}
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 2
				months = 2
			}
		}
	}

	after = {
		zgc_after_wedding_notices_effect = yes
	}
}

#Soulmate relationship
zgc_wedding_relationship_events.104 = {
	type = character_event
	title = zgc_wedding_relationship_events.104.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { is_attracted_to_gender_of = scope:spouse }
				}
				desc = zgc_wedding_relationship_events.104.unattracted_desc
			}
			desc = zgc_wedding_relationship_events.104.attracted_desc
		}
	}
	
	theme = marriage
	
	left_portrait = {
		character = root
		animation = love
	}

	right_portrait = {
		character = scope:spouse
		animation = love
	}
	
	immediate = {
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
	}
	
	#Accept soulmate relationship
	option = {
		name = zgc_wedding_relationship_events.104.a

		trigger = {
			is_ai = no
			is_attracted_to_gender_of = scope:spouse
			NOT = {
				any_relation = {
					type = soulmate
					this = scope:spouse
				}
			}
		}

		set_relation_soulmate = { reason = soulmate_wedding_relationship target = scope:spouse }
		add_internal_flag = special
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 1
				months = 2
			}
		}
	}
	
	#How about just lovers?
	option = {
		name = zgc_wedding_relationship_events.104.b
		trigger = {
			is_ai = no
			is_attracted_to_gender_of = scope:spouse
			NOT = {
				any_relation = {
					type = soulmate
					this = scope:spouse
				}
			}
		}
		
		set_relation_lover = { reason = lover_wedding_relationship target = scope:spouse }
		scope:spouse = {
			add_opinion = {
				modifier = disappointed_opinion
				opinion = -20
				target = root
			}
		}
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 2
				months = 2
			}
		}
	}
	
	
	#Actually, would prefer to be friends
	option = {
		name = zgc_wedding_relationship_events.104.c
		trigger = {
			is_ai = no
			NOT = {
				any_relation = {
					type = soulmate
					this = scope:spouse
				}
			}
		}
		set_relation_friend = { reason = friend_wedding_relationship target = scope:spouse }
		scope:spouse = {
			add_opinion = {
				modifier = disappointed_opinion
				opinion = -30
				target = root
			}
		}
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 3
				months = 2
			}
		}
	}
	
	# Want no relationship
	option = {
		name = zgc_wedding_relationship_events.104.d
		trigger = {
			is_ai = no
			NOT = {
				any_relation = {
					type = soulmate
					this = scope:spouse
				}
			}
		}
		scope:spouse = {
			add_opinion = {
				modifier = disappointed_opinion
				opinion = -40
				target = root
			}
		}
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 5
				months = 2
			}
		}
	}
	
	#Existing Relationship	
	option = {
		name = zgc_wedding_relationship_events.104.a

		trigger = {
			is_ai = no
			any_relation = {
				type = soulmate
				this = scope:spouse
			}
		}

		add_internal_flag = special
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 1
				months = 2
			}
		}
	}

	after = {
		zgc_after_wedding_notices_effect = yes
	}
}

#Friendship relationship
zgc_wedding_relationship_events.105 = {
	type = character_event
	title = zgc_wedding_relationship_events.105.t
	desc = zgc_wedding_relationship_events.105.desc
	theme = marriage
	
	left_portrait = {
		character = root
		animation = happiness
	}

	right_portrait = {
		character = scope:spouse
		animation = happiness
	}
	
	#Accept friend relationship
	option = {
		name = zgc_wedding_relationship_events.105.a
		add_internal_flag = special
		set_relation_friend = { reason = friend_wedding_relationship target = scope:spouse }
		
		trigger = {
			is_ai = no
			NOR = {
				any_relation = {
					type = friend
					this = scope:spouse
				}
				any_relation = {
					type = best_friend
					this = scope:spouse
				}
			}
		}
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 3
				months = 2
			}
		}
	}
	
	# Want no relationship
	option = {
		name = zgc_wedding_relationship_events.105.b
		trigger = {
			is_ai = no
			NOR = {
				any_relation = {
					type = friend
					this = scope:spouse
				}
				any_relation = {
					type = best_friend
					this = scope:spouse
				}
			}
		}
		scope:spouse = {
			add_opinion = {
				modifier = disappointed_opinion
				opinion = -10
				target = root
			}
		}
		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 5
				months = 2
			}
		}
	}
	
	#Existing Relationship	
	option = {
		name = zgc_wedding_relationship_events.105.a
		add_internal_flag = special
		
		trigger = {
			is_ai = no
			OR = {
				any_relation = {
					type = friend
					this = scope:spouse
				}
				any_relation = {
					type = best_friend
					this = scope:spouse
				}
			}
		}
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 3
				months = 2
			}
		}
	}

	after = {
		zgc_after_wedding_notices_effect = yes
	}
}

#Rival relationship
zgc_wedding_relationship_events.106 = {
	type = character_event
	title = zgc_wedding_relationship_events.106.t
	desc = zgc_wedding_relationship_events.106.desc
	theme = marriage
	
	left_portrait = {
		character = root
		animation = shock
	}

	right_portrait = {
		character = scope:spouse
		animation = rage
	}
	
	#Accept rival relationship - no choice with this one!
	option = {
		name = zgc_wedding_relationship_events.106.a
		set_relation_rival = { reason = rival_wedding_relationship target = scope:spouse }
		
		trigger = {
			is_ai = no
			NOR = {
				any_relation = {
					type = rival
					this = scope:spouse
				}
				any_relation = {
					type = nemesis
					this = scope:spouse
				}
			}
		}
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 4
				months = 2
			}
		}
	}
	
	option = {
		name = zgc_wedding_relationship_events.106.a
		
		trigger = {
			is_ai = no
			OR = {
				any_relation = {
					type = rival
					this = scope:spouse
				}
				any_relation = {
					type = nemesis
					this = scope:spouse
				}
			}
		}
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 4
				months = 2
			}
		}
	}

	after = {
		zgc_after_wedding_notices_effect = yes
	}
}

#Agreement relationship - the neutral fallback
zgc_wedding_relationship_events.107 = {
	type = character_event
	title = zgc_wedding_relationship_events.107.t
	desc = zgc_wedding_relationship_events.107.desc
	theme = marriage
	

	left_portrait = {
		character = root
	}

	right_portrait = {
		character = scope:spouse
	}
	
	#No relationship with this one
	option = {
		name = zgc_wedding_relationship_events.107.a
		
		trigger = {
			is_ai = no
		}		
		#For participant notification event
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 5
				months = 2
			}
		}
	}
	
	after = {
		zgc_after_wedding_notices_effect = yes
	}
}

zgc_wedding_relationship_events.203 = {
	type = character_event

	hidden = yes
		
	immediate = {
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 2
				months = 2
			}
		}
		if = {
			limit = {
				NOT = {
					any_relation = {
						type = lover
						this = scope:spouse
					}
				}
			}
			set_relation_lover = { reason = lover_wedding_relationship target = scope:spouse }
		}
		zgc_after_wedding_notices_effect = yes
	}
	
}

zgc_wedding_relationship_events.204 = {
	type = character_event

	hidden = yes
		
	immediate = {
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 1
				months = 2
			}
		}
		if = {
			limit = {
				NOT = {
					any_relation = {
						type = soulmate
						this = scope:spouse
					}
				}
			}
			set_relation_soulmate = { reason = soulmate_wedding_relationship target = scope:spouse }
		}
		zgc_after_wedding_notices_effect = yes
	}
	
}

zgc_wedding_relationship_events.205 = {
	type = character_event

	hidden = yes
		
	immediate = {
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 3
				months = 2
			}
		}
		if = {
			limit = {
				NOR = {
					any_relation = {
						type = friend
						this = scope:spouse
					}
					any_relation = {
						type = best_friend
						this = scope:spouse
					}
				}
			}
			set_relation_friend = { reason = friend_wedding_relationship target = scope:spouse }
		}
		zgc_after_wedding_notices_effect = yes
	}
	
}

zgc_wedding_relationship_events.206 = {
	type = character_event

	hidden = yes
		
	immediate = {
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 4
				months = 2
			}
		}
		if = {
			limit = {
				NOR = {
					any_relation = {
						type = rival
						this = scope:spouse
					}
					any_relation = {
						type = nemesis
						this = scope:spouse
					}
				}
			}
			set_relation_rival = { reason = rival_wedding_relationship target = scope:spouse }
		}
		zgc_after_wedding_notices_effect = yes
	}
	
}

zgc_wedding_relationship_events.207 = {
	type = character_event

	hidden = yes
		
	immediate = {
		had_sex_with_effect = {
			CHARACTER = scope:spouse
			PREGNANCY_CHANCE = pregnancy_chance
		}
		scope:spouse = {
			set_variable = {
				name = end_relationship
				value = 5
				months = 2
			}
		}
		zgc_after_wedding_notices_effect = yes
	}
	
}

# Guest ending event
zgc_wedding_relationship_events.7151 = {
	type = activity_event
	title = zgc_wedding_relationship_events.7151.t
	desc = {
		desc = zgc_wedding_relationship_events.7151.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						scope:host = {
							has_royal_court = yes
							amenity_level = { target = court_food_quality value >= 5 }
						}
						scope:activity = {
							has_activity_option = {
								category = feast_option_courses
								option = feast_courses_good
							}
						}
					}
				}
				desc = feast_default.9002.desc_exotic
			}
			triggered_desc = {
				trigger = {
					OR = {
						scope:host = {
							has_royal_court = yes
							amenity_level = { target = court_food_quality value >= 3 }
						}
						scope:activity = {
							has_activity_option = {
								category = feast_option_courses
								option = feast_courses_normal
							}
						}
					}
				}
				desc = feast_default.9002.desc_lavish
			}
			triggered_desc = {
				trigger = {
					OR = {
						scope:host = {
							has_royal_court = yes
							amenity_level = { target = court_food_quality value <= 1 }
						}
						scope:activity = {
							has_activity_option = {
								category = feast_option_courses
								option = feast_courses_normal
							}
						}
					}
				}
				desc = feast_default.9002.desc_meager
			}
			desc = feast_default.9002.desc_ending
		}
	}
	theme = feast_activity
	left_portrait = {
		character = root
		animation = happiness
	}
	center_portrait = {
		character = scope:host
		animation = toast_goblet
	}
	right_portrait = {
		trigger = { exists = scope:bride }
		character = scope:bride
		animation = happiness
	}
	cooldown = { years = 5 }

	immediate = {
		play_music_cue = "mx_cue_in_taberna_instrumental"
		root = {
			primary_spouse = {
				save_scope_as = bride
			}
		}
	}

	# Time to go home
	option = {
		name = zgc_wedding_relationship_events.7151.a
		hidden_effect = {
			reveler_lifestyle_rank_up_check_effect = yes
		}
		show_as_tooltip = {
			disburse_feast_reveler_rewards = yes
		}
		#Stress loss
		if = {
			limit = {
				OR = {
					has_trait = shy
					has_trait = reclusive
				}
			}
			custom_tooltip = host_feast_decision_desc_shy
		}
		else = {
			if = {
				limit = {
					has_royal_court = yes
						amenity_level = { target = court_food_quality value >= 5 }
				}
				stress_impact = {
					base = exotic_feast_stress_loss_value
					gluttonous = feast_stress_loss_value
					gregarious = feast_stress_loss_value
					lifestyle_reveler = feast_stress_loss_value
					drunkard = feast_stress_loss_value
					comfort_eater = feast_stress_loss_value
					generous = feast_stress_loss_value
					greedy = activity_stress_gain_impact
				}
			}
			else_if = {
				limit = {
					has_royal_court = yes
					amenity_level = { target = court_food_quality value >= 4 }
				}
				stress_impact = {
					base = lavish_feast_stress_loss_value
					gluttonous = feast_stress_loss_value
					gregarious = feast_stress_loss_value
					lifestyle_reveler = feast_stress_loss_value
					drunkard = feast_stress_loss_value
					comfort_eater = feast_stress_loss_value
					generous = feast_stress_loss_value
					greedy = activity_stress_gain_impact
				}
			}
		    else_if = {
				limit = {
					has_royal_court = yes
					amenity_level = { target = court_food_quality value >= 3 }
				}
				stress_impact = {
					base = medium_feast_stress_loss_value
					gluttonous = feast_stress_loss_value
					gregarious = feast_stress_loss_value
					lifestyle_reveler = feast_stress_loss_value
					drunkard = feast_stress_loss_value
					comfort_eater = feast_stress_loss_value
					generous = feast_stress_loss_value
					greedy = activity_stress_gain_impact
				}
			}
			else_if = {
				limit = {
					has_royal_court = yes
					amenity_level = { target = court_food_quality value <= 1 }
				}
				stress_impact = {
					base = meager_feast_stress_loss_value
					gluttonous = feast_stress_loss_value
					gregarious = feast_stress_loss_value
					lifestyle_reveler = feast_stress_loss_value
					drunkard = feast_stress_loss_value
					comfort_eater = feast_stress_loss_value
					generous = feast_stress_loss_value
					greedy = activity_stress_gain_impact
				}
			}
			else = {
				stress_impact = {
					base = feast_stress_loss_value
					gluttonous = activity_stress_loss_impact
					gregarious = activity_stress_loss_impact
					lifestyle_reveler = activity_stress_loss_impact
					drunkard = activity_stress_loss_impact
					comfort_eater = activity_stress_loss_impact
					generous = activity_stress_loss_impact
					greedy = activity_stress_gain_impact
				}
			}
		}
		root = {
			if = {
				limit = {
					has_opinion_modifier = {
						modifier = wedding_message_opinion
						target = scope:host
					}
				}	
				remove_opinion = {
					modifier = wedding_message_opinion
					target = scope:host
				}	
			}
			add_opinion = {
				target = scope:host
				modifier = feast_for_wedding_opinion
				opinion = 15
			}
		}
		scope:bride = {
			if = {
				limit = {
					has_opinion_modifier = {
						modifier = wedding_message_opinion
						target = scope:host
					}
				}	
				remove_opinion = {
					modifier = wedding_message_opinion
					target = scope:host
				}	
			}
			add_opinion = {
				target = scope:host
				modifier = feast_for_wedding_spouse_opinion
				opinion = 10
			}
		}
		root = {
			every_spouse = {
				limit = {
					NOT = { this = scope:bride }
				}
				if = {
					limit = {
						has_opinion_modifier = {
							modifier = wedding_message_opinion
							target = scope:host
						}
					}	
					remove_opinion = {
						modifier = wedding_message_opinion
						target = scope:host
					}	
				}
				add_opinion = {
					target = scope:host
					modifier = feast_for_wedding_other_spouse_opinion
					opinion = 5
				}
			}
		}
	}
}

zgc_wedding_relationship_events.7101 = {
	type = activity_event
	title = zgc_wedding_relationship_events.7101.t
	desc = {
		desc = zgc_wedding_relationship_events.7101.desc
		first_valid = { #extra flavour
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = {
							category = feast_option_food
							option = feast_food_good
						}
					}
				}
				desc = feast_default.9001.desc_exotic
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = {
							category = feast_option_food
							option = feast_food_normal
						}
					}
				}
				desc = feast_default.9001.desc_lavish
			}
			triggered_desc = {
				trigger = {
					scope:activity = {
						has_activity_option = {
							category = feast_option_food
							option = feast_food_bad
						}
					}
				}
				desc = feast_default.9001.desc_meager
			}
			desc = feast_default.9001.desc
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:spouse }
				desc = feast_default.9001.spouse
			}
			desc = feast_default.9001.no_spouse
		}
	}
	theme = feast_activity
	left_portrait = {
		character = root
		animation = happiness
	}
	center_portrait = {
		trigger = { exists = scope:activity.special_guest:honorary_wedding_guest }
		character = scope:honorary_wedding_guest
		animation = personality_honorable
	}
	right_portrait = {
		trigger = { exists = scope:bride }
		character = scope:bride
		animation = happiness
	}

	immediate = {
		save_scope_as = root_scope
		play_music_cue = grandfeast_cue
		if = {
			limit = {
				NOT = { exists = scope:spouse }
				is_married = yes
			}
			random_spouse = {	
				limit = {
					is_available = yes
					this = root.primary_spouse
				}
				alternative_limit = {
					is_available = yes
				}
				save_scope_as = spouse
			}
		}
		if = {
			limit = {
				exists = scope:activity.special_guest:honorary_wedding_guest 
			}
			scope:activity.special_guest:honorary_wedding_guest = {
				primary_spouse = {
					save_scope_as = bride
				}
			}
			scope:activity.special_guest:honorary_wedding_guest = {
				save_scope_as = honorary_wedding_guest
			}
		}
	}

	# Nice
	option = {
		name = zgc_wedding_relationship_events.7101.a
		hidden_effect = {
			reveler_lifestyle_rank_up_check_effect = yes
		}
		show_as_tooltip = { #we give these out in the on_complete of the activity
			disburse_feast_activity_rewards = yes #includes magnificence and stress loss rewards
		}
	}
}
