﻿namespace = coming_of_age_familyromance

# Prepare event for coming of age
coming_of_age_familyromance.0001 = {
	type = character_event
	hidden = yes

	trigger = {		
		exists = scope:educated_child_for_romance
		exists = scope:guardian_for_romance
	}
	
	immediate = {		
		
		if = {
			limit = {
				exists = scope:guardian_for_romance
			}
			# Run for guardian
			scope:guardian_for_romance = {
				trigger_event = coming_of_age_familyromance.0050
			}
			# Run for ward
			scope:educated_child_for_romance = {
				trigger_event = coming_of_age_familyromance.0051
			}
			# As it's non-AI only, one will fail and the other will start
		}
		
	}
	
}
	



# Your child, sibling, niece or nephew has a special feelings for you, if you was the guardian and you have enough relation points.
coming_of_age_familyromance.0050 = {
	type = character_event
	title = fr_coming_at_age_familylove.0050.t

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { is_landless_adventurer = yes }
				desc = fr_coming_at_age_familylove.0050.desc_unland_adv
			}
			desc = fr_coming_at_age_familylove.0050.desc
		}
	}
	
	theme = seduction
	override_background = study
		
	left_portrait = {
		character = scope:educated_child_for_romance
		animation = love
	}
	
	trigger = {
		is_ai = no
				
		familyromance_coming_at_age_player_suitable_to_attraction = yes
		
		scope:educated_child_for_romance = {
			familyromance_coming_at_age_valid_relative = yes
			
			AND = {
				exists = var:fr_your_wards_guardian
				var:fr_your_wards_guardian = root
				var:fr_ward_affection_to_you >=3
			}
		}

		
		NOT = { has_character_flag = block_family_relation_seduce_attempts }
	}
	
	option = { # Yes, become lovers with your former ward
		name = fr_coming_at_age_familylove.0050.a		
		
		had_sex_with_effect = {
			CHARACTER = scope:educated_child_for_romance
			PREGNANCY_CHANCE = pregnancy_chance
	    }
		
		# Become lovers
		trigger = {
			can_set_relation_lover_trigger = { CHARACTER = scope:educated_child_for_romance }
		}
		set_relation_lover = scope:educated_child_for_romance
		
	}
	
	option = { # No
		name = 	fr_coming_at_age_familylove.0050.b
		
	}
	
	option = { # No to all attempts for 10 years
		name = fr_random_familymember_love.0001.d
		custom_tooltip = fr_random_familymember_love.0001.d.tt
		
		add_character_flag = {
			flag = block_family_relation_seduce_attempts
			years = 10
		}
	}
	
}


# Your educator parent, sibling, uncle or aunt has a special feelings for you, if you was the ward.
coming_of_age_familyromance.0051 = {
	type = character_event
	title = fr_coming_at_age_familylove.0050.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { is_landless_adventurer = yes }
				desc = fr_coming_at_age_familylove.0051.desc_unland_adv
			}
			desc = fr_coming_at_age_familylove.0051.desc
		}
	}
	
	
	theme = seduction
	override_background = study
		
	left_portrait = {		
		character = scope:guardian_for_romance
		animation = flirtation
	}
	
	trigger = {
		is_ai = no		
		
		familyromance_coming_at_age_player_suitable_to_attraction = yes
		
		scope:guardian_for_romance  = {
			familyromance_coming_at_age_valid_relative = yes
		}
		
		AND = {
			exists = var:fr_your_relative_guardian_affection
			var:fr_your_relative_guardian_affection >=2 # It is slightly easier now
		}

		NOT = { has_character_flag = block_family_relation_seduce_attempts }
	}
	
	option = { # Yes, become lovers with your former guardian
		name = fr_coming_at_age_familylove.0051.a
		
		had_sex_with_effect = {
			CHARACTER = scope:guardian_for_romance
			PREGNANCY_CHANCE = pregnancy_chance
	    }
		
		# Become lovers
		trigger = {
			can_set_relation_lover_trigger = { CHARACTER = scope:guardian_for_romance }
		}
		set_relation_lover = scope:guardian_for_romance
		
	}
	
	option = { # No
		name = 	fr_coming_at_age_familylove.0051.b
	}
	
	option = { # No to all attempts for 10 years
		name = fr_random_familymember_love.0001.d
		custom_tooltip = fr_random_familymember_love.0001.d.tt
		
		add_character_flag = {
			flag = block_family_relation_seduce_attempts
			years = 10
		}
	}	
	
}





# Partially taken from childhood.0998
# Your sister/brother, that was your chilhood crush can become your lover after your's coming at age
coming_of_age_familyromance.0052 = {
	type = character_event
	hidden = yes
	
	trigger = {
		
		OR = {			
			exists = var:had_childhood_crush_variable
			exists = var:unrequited_crush
			
			exists = var:fr_younger_crush
			exists = var:fr_family_unrequired_crush
		}
	}

	immediate = {
		
		if = {
			limit = {
				exists = var:had_childhood_crush_variable
			}
			
			if = {
				limit = {
					var:had_childhood_crush_variable = {
						is_close_family_of_root_trigger = yes
						familyromance_coming_at_age_valid_relative = yes
					}				
				}
				var:had_childhood_crush_variable = {
					save_scope_as = crush
				}
			}
			
			if = {
				limit = {
					is_ai = no
					var:had_childhood_crush_variable = {						
						is_adult = no
						is_close_family_of_root_trigger = yes
					}				
				}
				
				var:had_childhood_crush_variable = {
					set_variable = {
						name = fr_younger_crush
						value = root
					}
				}
				
			}
			
		}
		
		if = {
			limit = {
				is_ai = no
				exists = var:fr_family_unrequired_crush
				
				var:fr_family_unrequired_crush = {
					is_close_family_of_root_trigger = yes
					familyromance_coming_at_age_valid_relative = yes
				}
			}
			
			var:fr_family_unrequired_crush = {
				save_scope_as = crush
			}
		}
		
		if = {
			limit = {
				is_ai = no
				exists = var:unrequited_crush
				
				var:unrequited_crush = {
					is_close_family_of_root_trigger = yes
					is_adult = no					
				}
			}
			
			var:unrequited_crush = {
				set_variable = {
					name = fr_family_younger_unrequired_crush
					value = root
				}
			}

		}
		
		
		if = {
			limit = {				
				exists = var:fr_family_younger_unrequired_crush
			}
			
			if = {
				limit = {
					var:fr_family_younger_unrequired_crush = {
						is_close_family_of_root_trigger = yes						
					}
					
				}
				var:fr_family_younger_unrequired_crush = {
					save_scope_as = fr_crush_on_you
				}
			}
		}
		
		
		
		if = {
			limit = {				
				exists = var:fr_younger_crush				
			}
			
			if = {
				limit = {
					var:fr_younger_crush = {
						is_close_family_of_root_trigger = yes						
					}
					
				}
				var:fr_younger_crush = {
					save_scope_as = fr_crush_on_you
				}
			}
		}
		
				
		
		if = {
			limit = {
				exists = scope:crush
				is_ai = no
			}
			
			scope:crush = {
				save_scope_as = root_crush 
			}
			
			trigger_event = {
				id = coming_of_age_familyromance.0053
			}
		}
		
		
		
		if = {
			limit = {
				exists = scope:fr_crush_on_you
			}
			
			save_scope_as = root_crush
			
			
			scope:fr_crush_on_you = {
				trigger_event = {
					id = coming_of_age_familyromance.0053
				}
			}			
		}
		
		
	}
}


# Your sister/brother that was your chilhood crush can become your lover after your's coming at age
coming_of_age_familyromance.0053 = {
	
	type = character_event
	title = fr_coming_at_age_familylove.0053.t
	desc = {
		desc = fr_coming_at_age_familylove.0053.desc
		triggered_desc = {
			trigger = {
				OR = {
					exists = var:unrequited_crush
					scope:root_crush = {
						exists = var:fr_family_younger_unrequired_crush
					}
				}
			}
			desc = fr_coming_at_age_familylove.0053.desc_unrequited_familylove
		}
		desc = double_line_break
		
		desc = fr_coming_at_age_familylove.0053.desc2
		
	}
	
	theme = seduction
	override_background = farmland
	left_portrait = {
		character = scope:root_crush
		animation = happiness
	}
	
	trigger = {		
		is_ai = no
		
		familyromance_coming_at_age_player_suitable_to_attraction = yes
				
		scope:root_crush = {
			is_close_family_of_root_trigger = yes
			familyromance_coming_at_age_valid_relative = yes
		}		
	}
		
	option = { # Let's try to become lovers
		name = fr_coming_at_age_familylove.0053.a
		
		# Become lovers
		trigger = {
			can_set_relation_lover_trigger = { CHARACTER = scope:root_crush }
		}
		set_relation_lover = scope:root_crush
		
	}
	
	option = { # No, give up
		name = fr_coming_at_age_familylove.0053.b
		
		scope:root_crush = {
			add_character_flag = {
				flag = block_relative_seduce_attempts
				years = 20
			}
			
		}
	}	

	after = {
		
		if = {
				limit = {
					exists = var:fr_younger_crush
				}
				remove_variable = fr_younger_crush
		}

		if = {
				limit = {
					exists = var:fr_family_unrequired_crush
				}
				remove_variable = fr_family_unrequired_crush
		}
		
	}
		
}
